# Math library This library adds extra math functions to Ground. Unlike the official math library, all these features are coded in pure Ground. Please note that you cannot copy a single function from the package, as some functions rely on other functions in the library. ## Functions # Trigonometry fun -double !sin -double &input: Gets the sin of input. fun -double !cos -double &input: Gets the cos of input. fun -double !tan -double &input: Gets the tan of input. fun -double !asin -double &input: Finds the angle *x* in the range [-pi/2, pi/2] such that sin(x) equals the input. fun -double !acos -double &input: Finds the angle *x* in the range [0, pi] such that cos(x) equals the input. fun -double !atan -double &input: Finds the angle *x* in the range [-pi/2, pi/2] such that tan(x) equals the input. fun -double !atan2 -double &y -double &x: Finds the angle in the range (-pi, pi] between the positive x axis and the point (x,y). This is equivalent to atan(y/x) for positive values of x. # Exponents and Logarithms fun -double !intexp -double &base -int &power: Returns base^power, for positive integer values of power. Returns 1 if power is non-positive (and thus is inaccurate for negative values of power). fun -double !exp -double &input: Finds exp($input), where exp(x)=e^x; e is Euler's number = 2.718281828... fun -double !ln -double &in: Finds the natural log (log_e) of $input, i.e. finds x such that e^x = $input; e is Euler's number = 2.718281828... fun -double !sqrt -double &input: Returns the positive value *x* that satisfies x^2 = input. Throws an error if input is negative. # Integer Operations fun -double !mod -double &in -double &modulus: Returns *n* such that *n* is congruent to the input modulo $modulus, where *n* is at least 0 and less than $modulus. fun -double !abs -double &in: Returns the absolute value of the input. fun -int !factorial -int &in: Returns the factorial of the input. # Constants fun -double !pi: Returns pi to the maximum accuracy that doubles can store. fun -double !e: Returns e to the maximum accuracy that doubles can store. # Misc fun -double !random -int &seed: Gets a random double in the domain [0,1), using a LCG. A seed is required. fun -double !rpn -list &rpn: Calculates a function in reverse polish notation. The list should have a form similar to `[3, 5, '+', 2, '-']`, i.e. only numbers and the `+`, `-`, `*`, `/` characters. **Requires the lists package to use**. fun -double !itod -int &input: Returns the input as a double. fun -int !dtoi -double &input: Returns the input as an integer.