# Math functions

## Math function

abs() | ceil() | customizable\_round\_multiply() | customizable\_round\_division() | exp() | fac() | floor() | int() | int\_to\_string() | is\_float() | is\_int() | log() | max() | md5() | min() | pow() | random() | round() | sha1() | sha256() | sqrt() | sin() | cos() | tan() | asin() | acos() | atan() | atan2()

<details>

<summary>Description</summary>

**abs(num)** - absolute value (converts a number to its positive equivalent).\
Example: abs(-256) returns 256

**ceil(num)** - rounds a number up to the nearest integer.\
Example: ceil(25.66) returns 26

**customizable\_round\_division(a,b,count)** - divides two numbers and rounds the result to a specified number of decimal places (count), where a is the dividend and b is the divisor.

**customizable\_round\_multiply(a,b,count)** - multiplies two numbers and rounds the result to a specified number of decimal places (count), where a and b are the factors.

**exp(num)** - raising Euler’s number&#x20;e to the power of the parameter.\
Example: exp(2) returns approximately 7.38905609893065

**fac(num)** - factorial of a number (takes one parameter).\
Example: fac(5) returns 120

**floor(num)** - returns the integer part of a number (rounds down).\
Example: floor(25.66) returns 25

**int(num)** - converts a floating-point number to an integer by truncating the decimal part.\
Example: int(1.8) returns 1

**int\_to\_string(number, delimiter)** - converts a number to a string with the specified delimiter.&#x20;

**is\_float(txt)** - checks whether a string is a number (including decimals).

**is\_int(txt)** - checks whether a string is a number. \
Example: is\_int("5") returns True, while is\_int("text") returns False

**log(num, base)** - calculates the logarithm of a number taking two parameters: the number and the base (default is&#x20;e).\
Example: log(E) returns 1 (where E is Euler’s number), log(100, 10) returns 2

**max(a, b, c)** - finds the maximum number among the listed values accepting an unlimited number of parameters (each must be a number).\
Example: max(4, 2, 9, 6) returns 9

**md5(text)** - generates an MD5 hash from a string.\
Example: hash = md5("Hello world") returns 3e25960a79dbc69b674cd4ec67a72c62

**min(a, b, c)** - finds the minimum number among the listed values accepting an unlimited number of parameters (each must be a number).\
Example: min(4, 2, 9, 6) returns 2

**pow(num, st)** - raises a number to a power taking two parameters: the base number and the exponent.\
Example: pow(5, 2) returns 25

**pyt(a, b)** - Calculates the square root of the sum of the squares of two values accepting two parameters: a and b.\
Example: pyt(5, 2) returns 5.385164807134504

**random(low, high)** - generates a random number. The function takes two parameters: the lower bound and the upper bound.\
Example: random(-10, 10)

**round(num)** - performs mathematical rounding of a number.&#x20;Example: round(1.8).

You can also round to a specific number of decimal places.\
Example: round(1.8888888, 2) returns 1.89.&#x20;

**sha1(text)** - generates a SHA-1 hash from a string.\
Example: hash = sha1("Hello world") returns 7b502c3a1f48c8609ae212cdfb639dee39673f5e

**sha256(text)** - generates a SHA-256 hash from a string.\
Example: hash = sha256("Hello world") returns 64ec88ca00b268e5ba1a35678a1b5316d212f4f366b2477232534a8aeca37f3c

**sqrt(num)** - calculates the square root of a number taking one parameter: the number.\
Example: sqrt(25) returns 5

**sin() cos() tan() asin() acos() atan() atan2()** - trigonometric functions (remember to consider their domains).

{% hint style="success" %}
Mathematical functions can be performed not only in the "Calculator" field but also directly in the "Message" field by writing expressions in the following format: **#{2+2}, #{random(0,100)}**, and etc.
{% endhint %}

</details>

<details>

<summary>Example</summary>

Let’s try this function! It’s really simple: just enter it, specify the parameters, and get the result — just like in math!

<div data-with-frame="true"><figure><img src="/files/GC6j5sFnnd09a30QBnP8" alt=""><figcaption></figcaption></figure></div>

Here is the result:

<div data-with-frame="true"><figure><img src="/files/ZGF9yg3yQ5TPUJOTo1nA" alt="" width="375"><figcaption></figcaption></figure></div>

Example of using **int\_to\_string()**:

<div data-with-frame="true"><figure><img src="/files/AM57NgQGFECYyH4cja4G" alt="" width="375"><figcaption></figcaption></figure></div>

<div data-with-frame="true"><figure><img src="/files/aT74a786ZQZP3Wd7vESH" alt="" width="375"><figcaption></figcaption></figure></div>

</details>

<details>

<summary>Code example for copying</summary>

Code for the "Message" field:

```
abs(#{A}) = #{a1} 
ceil(#{X}) = #{b1} 
customizable_round_multiply(#{X}, #{Y}, 2) = #{c1}
customizable_round_division(#{X}, #{Y}, 3) = #{d1} 
exp(4) = #{e1}
fac(#{C}) = #{f1}
floor(#{X}) = #{g1}        
floor(#{Y}) = #{floor(#{Y})}
int(#{X}) = #{h1}            
int(#{Y}) = #{int(#{Y})}
is_float("#{text}") = #{i1}      
is_float("#{X}") = #{is_float("#{X}")}    
is_int("#{text}") = #{j1}         
is_int("#{C}") = #{is_int("#{C}")}
is_int("#{X}") = #{is_int("#{X}")}
log(#{C}) = #{k1}
max(#{X}, #{Y}, #{C}) = #{l1} 
md5("#{text}") = #{m1} 
min(#{X}, #{Y}, #{C}) = #{n1}
pow(#{C},#{C}) = #{o1} 
pyt(5,2) = #{o2}
random(0, #{C}) = #{p1} 
round(#{Y}) = #{r1}
sha1("#{text}") = #{s1}
sha256("#{text}") = #{t1}
sqrt(#{C}) = #{u1} 
sin(#{X}) = #{v1}
cos(#{X}) = #{w1}
tan(#{X}) = #{x1} 
asin(#{L}) = #{y1} 
acos(#{L}) = #{a2} 
atan(#{X}) = #{b2} 
atan2(#{X},#{Y}) = #{c2}
```

Code for the "Calculator" field:

```
/*setting universal numbers for calculations*/
X=1.275
Y=5.822
A=-2.352
C=5
L=0.5
text="Hello, World!"
/*calculation*/
a1=abs(A) 
b1=ceil(X) 
c1=customizable_round_multiply(X,Y,2) 
d1=customizable_round_division(X,Y,3) 
e1=exp(4) 
f1=fac(C) 
g1=floor(X) 
h1=int(X) 
i1=is_float(text) 
j1=is_int(text) 
k1=log(C) 
l1=max(X,Y,C) 
m1=md5(text) 
n1=min(X,Y,C) 
o1=pow(C,C) 
o2=pyt(5,2)
p1=random(0,C) 
r1=round(Y) 
s1=sha1(text) 
t1=sha256(text) 
u1=sqrt(C) 
v1=sin(X) 
w1=cos(X) 
x1=tan(X) 
y1=asin(L) 
a2=acos(L) 
b2=atan(X) 
c2=atan2(X,Y)
```

</details>

## Working with coordinates

**distance()**

<details>

<summary>Description</summary>

**distance(lat1, lon1, lat2, lon2)**- calculates the distance between two coordinates in kilometers

**lat1, lat2** - latitude of the starting and ending points

**lon1, lon2** - longitude of the starting and ending points

</details>

<details>

<summary>Examples</summary>

Example: `distance(52.2296756, 21.0122287, 52.406374, 16.9251681)`

Result: `278.5459739738798`

</details>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.mavibot.ai/chatbot/functions/calculator/math.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
