# 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.

## 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.

## 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.