# SyMAT Wiki

### Site Tools

code:functions

This is an old revision of the document!

# Built-in Functions

SyMAT has many built-in functions. These are available from JavaScript and Python.

Reason: Not all functions are documented yet.

This page is official documentation from the SyMAT team. It is locked for editing indefinitely.

## Symbols

These are only some symbols present in SyMAT. Because of differences between JavaScript and Python, syntax-specific symbols are omitted.

• `+`: Addition.
• `-`: Subtraction.
• `*`: Multiplication.
• `/`: Division.
• `( )`: Used to enclose arguments to functions, and for math. Note that b(4+5) will attempt to run the function b with the argument 4+5, not multiply variable b with the sum (4+5). For multiplication, use b*(4+5).
• `,`: Separates arguments in functions.
• `"`: (Double quote) Denotes the start and end of text (strings).
• `'`: (Single quote) Same as the double quote above.
• `=`: Assign a value to a variable. `x=5` will assign the value 5 to variable x.

## Input/Output/Storage

• `notify(message)`: Display a pop-up box with the given message text and an OK button.
• `ask(question)`: Display a pop-up box with the given question and an input box. Returns a String.
• `print(text)`: Output a line of text to the Output box.
• `readfile(filename)`: Read the contents of the given text file and return the data.
• `savefile(filename,data)`: Write the given text data to a file.
• `load(key)`: Return the text corresponding to the given key.
• `save(key,text)`: Link the given text to the given key.

## Simple Math

• `add(n,n,n...)` or `add(n[])`: Add together the given numbers or array of numbers and return the sum.
• `subtract(n,n,n...)` or `subtract(n[])`: Subtract the given numbers or array of numbers and return the difference. Calculates from first number to last (i.e. n1-n2-n3).
• `times(n,n,n...)` or `times(n[])`: Multiply together the given numbers or array of numbers and return the product.
• `divide(n,n,n...)` or `divide(n[])`: Divide the given numbers or array of numbers and return the quotient. Calculates from first number to last (i.e. (n1/n2)/n3).
• `mod(n,n,n...)` or `mod(n[])`: Calculate the modulus of the given numbers or array of numbers and return the result. Calculates from first number to last (i.e. (n1 mod n2) mod n3).
• `min(n1,n2,...)`: Returns the smallest of the given numbers.
• `max(n1,n2,...)`: Returns the largest of the given numbers.
• `pow(x,y)`: Raise x to y (x^y) and return the result.
• `exp(x)`: Calculate e^x.
• `log(x)`: Calculate natural log (base e) of x.
• `ceil(n)`: Round n up to the nearest larger integer.
• `floor(n)`: Round n down to the nearest smaller integer.

## Graphing

• `plot()`: Display a plot window.
• `plot(formula)`: Plot the given formula and display it.
• `plotname(name)`: Set the title of the plot.
• `plotname()`: Get the title of the plot.
• `xlim(min,max)`: Set the x-axis min and max values. Can only be used before graphing a function.
• `drawdot(x,y)`: Place a dot at the specified coordinates.
• `plotclr()`: Clear all formulas and dots from the plot.

## Random Numbers

The random number generator used in SyMAT is considered cryptographically strong.

• `rand()`: Returns a fraction between 0 (inclusive) and 1 (exclusive).
• `rand(min,max)`: Returns an Integer between min and max, inclusive.
• `randb()`: Returns either True or False (“coin toss”).

## Trigonometry

• `sin(n)`: Find the sine of the given number in radians.
• `cos(n)`: Find the cosine of the given number in radians.
• `tan(n)`: Find the tangent of the given number in radians.
• `asin(n)`: Find the Arcsine (inverse sine) of the given number.
• `acos(n)`: Find the Arccosine (inverse cosine) of the given number.
• `atan(n)`: Find the Arctangent (inverse tangent) of the given number.
• `deg(n)`: Convert the given radians to degrees.
• `rad(n)`: Convert the given degrees to radians.