User Tools

Site Tools


code:functions

Built-in Functions

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

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

Symbols

These are only some of the symbols present in SyMAT. Because of differences between coding languages, 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 (except in Java).
  • =: 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.
  • filedialog(): Show a file selection dialog and return the chosen file path.
  • textbox(): Returns an instance of a multiline text box.
  • browser(): Returns an instance of a web browser.

Basic Math and Algebra

  • 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.
  • solve(f,x,n): Calculate the values of x that make function f equal to n and return an array.

Advanced Math

  • primes(n): Find all prime numbers less than n and return them in an array.
  • isprime(n): Calculates if the given number is prime.
  • gcd(n1,n2): Find the greatest common divisor of n1 and n2.
  • diff(f,x): Differentiate function f with respect to variable x.
  • integrate(f,x): Integrate function f with respect to variable x.

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.
  • sinh(n): Find the hyperbolic sine of the given number.
  • cosh(n): Find the hyperbolic cosine of the given number.
  • tanh(n): Find the hyperbolic tangent of the given number.
  • sec(n): Find the secant of the given number in radians.
  • csc(n): Find the cosecant of the given number in radians.
  • cot(n): Find the cotangent of the given number in radians.
  • asec(n): Find the inverse secant of the given number.
  • acsc(n): Find the inverse cosecant of the given number.
  • acot(n): Find the inverse cotangent of the given number.
  • sech(n): Find the hyperbolic secant of the given number.
  • csch(n): Find the hyperbolic cosecant of the given number.
  • coth(n): Find the hyperbolic cotangent of the given number.
  • deg(n): Convert the given radians to degrees.
  • rad(n): Convert the given degrees to radians.

Matrix Operations

  • mtimes(m1,m2): Multiply the given matrices together.
  • mpower(m,n): Raise m to the power n.
  • minvert(m): Invert the given matrix.
  • printa(m): Get a textual representation of the given array or matrix.
code/functions.txt · Last modified: 2015/12/28 01:31 by skylarmt