### Using the calculator

Matrix calculator brought to you by: a random impluse when building a physics simulator

# Data types

### NUMBER

The data type representing all numbers in the calculator (signed, unsigned, integers, and decimals all use this type).

### FUNCTION

The data type of all functions and methods, including user-defined functions.

### ARRAY

Data type of all arrays.

### MATRIX

Data type of all matrices.

### NONE

Undefined quantities have this data type.

# Builtin functions and variables

### Mathematical functions

• sin(x: NUMBER) --- Return the sine of x (measured in radians).
• cos(x: NUMBER) --- Return the cosine of x (measured in radians).
• sqrt(x: NUMBER) --- Return the square root of x.
• pow(x: NUMBER, y: NUMBER) --- Return x raised to the power of y (x^y).

### Matrix functions

• matrix(arr: ARRAY) --- Create a matrix from the array arr.
• multiply(A: MATRIX, B: MATRIX) --- Compute the matrix product AB.
• scale(A: MATRIX, k: NUMBER) --- Return a copy of A scaled by k.
• det(A: MATRIX) --- Compute the determinant of a square matrix using LU decomposition.
• detCofactorExpansion(A: MATRIX) --- Compute the determinant of a square matrix A using cofactor expansion. This method will always give exact results for integer matrices, but the computation grows with the factorial of the dimension. For this reason, use det() instead for larger matrices, i.e. 8x8 or larger.
• add(A: MATRIX, B: MATRIX) --- Return the sum of A and B (A+B).
• sub(A: MATRIX, B: MATRIX) --- Return the difference of A and B (A-B).
• rref(A: MATRIX) --- Return the reduced row-echelon form of A.
• minors(A: MATRIX) --- Return the matrix of minors corresponding to A.
• cofactors(A: MATRIX) --- Return the matrix of cofactors corresponding to A.
• inverse(A: MATRIX) --- Return the inverse of A, if it exists (det(A) != 0).
• identity(n: NUMBER) --- Return the n by n identity matrix.
• randomMatrix(m: NUMBER, n: NUMBER) --- Return an m by n matrix of random numbers between 0 and 1 (inclusive).
• randomIntegerMatrix(m: NUMBER, n: NUMBER, lowerBound: NUMBER, upperBound: NUMBER) --- Return an m by n matrix of random numbers between lowerBound and upperBound (inclusive).
• emptyMatrix(m: NUMBER, n: NUMBER) --- Return an m by n matrix of zeros.
• fillMatrix(m: NUMBER, n: NUMBER, value: NUMBER) --- Return an m by n matrix where all entries are equal to value.
• rotationMatrix(angle: NUMBER) --- Return the 2 by 2 rotation matrix for the given angle (measured in radians).

### Calculator functions

• displayLatex(A: MATRIX) --- Render the matrix A in LaTeX typesetting.
• clear() --- Clear the calculator, retain cached inputs and input index.
• restart() --- Completely restart the calculator, erasing cached inputs and resetting the input index.
• func(expr: expression, argNames: ARRAY, argTypes: ARRAY, returnType: data type) --- Define a new function with argNames as arguments. argTypes is an array of the data types of each argument, and returnType is the dataType returned by the function. Recursion is not supported. When the function is called, expr will be evaluated with the values passed in. The function has its own namespace, so variable name collision will not happen.

### Builtin variables

• pi: NUMBER --- The constant pi.