Tess is a computer algebra system that has been in the works for quite some time now. Initially created to express the solutions to quadratic polynomial equations algebraically, it has evidently grown to become far more than what I initially set out to make. Source code

- Type or paste your mathematical expression (in ASCII math) in the provided textbox. If the expression parses incorrectly, use parentheses to clarify the order of operations.
- All angles must be in radians.
- Press enter to simplify your expression.
- Any rendered expression can be copied as Latex by clicking on the expression.
- You can use Desmos, which can evaluate Latex, to verify the value of an expression.

- Basic Algebraic Expression: (x+3)(x-2)+6
- Manipulating constants: (2pi+3pie^2+7pi+3e^3(1/pi)e^(-1)+27*(pi/e^3)*(e^2/(9pi^2)))/(9+6)
- Radicals and factoring: (sqrt(2+sqrt12)a+sqrt(2+sqrt12)b)/(sqrt2c+sqrt2d)
- Evaluation of constructible trigonometric ratios: tan(3pi/16)

- Expressions are sometimes rendered unconventionally (for example, \(\pi3\) instead of \(3\pi\)). This is because all factors in a term are sorted according to their hashes, and this order might not always be what is conventionally expected. A fix is being worked on.
- Some compute intensive expressions (like tan(9p/16)) take a while to evaluate, during which time the browser tab becomes unusable. A fix is being worked on where all compute tasks are delegated to a service worker, leaving the primary thread free.

## The data structure

Tess can take an ASCII math expression and represent it using nested arrays. Each expression is an array where every element represents a term in an addition operation. Each term is itself an array, with each element representing a factor in a multiplication operation. Each factor is an array, where the first element stores the base and the second element stores the exponent. For example, 4/x + 3x^2 would be represented as [[[4, 1], [x, -1]], [[3, 1], [x, 2]]]. Every element in the factor arrays can be a simple number, a variable, or another expression array. If the expression is an argument to a function, the function name is stored as a parameter of the expression object. This allows Tess to represent any mathematical expression.

## Expression parsing

The input strings (in ASCII math) are parsed using the Shunting - yard algorithm. The input string is first split into tokens, which are then sequenced in reverse polish. Instead of evaluating the expression for its value, Tess transforms the RPN into the nested array data structure described above. However, this method can introduce redundant expressions (“wrapper expressions”) because the evaluator can only accept two operands for binary operators(like + and *) which are associative and usually have multiple operands. For example, x+y+z would be parsed as (x+y) +z, with x + y in one expression, which is then added to z. The resulting output is unnecessarily bloated, violates the associativity of these operands, and is difficult to manipulate. To address this, the output of the parser is fed to a standardizer, which eliminates unnecessary nesting by merging the contents of child expressions into their parent expressions if they do not serve a structural purpose. The standardizer also sorts all elements of all arrays in a specific order according to their hash values. This speeds up simplification by ensuring that if two arrays have the same elements, they are in the same order.

## Latex representation

Tess can convert any expression represented by its native data structure into LaTeX, which can be rendered using a mathematics library like MathJax. The stringify method works recursively to produce the final output. When called on an expression, it gets the LaTeX representation of all its children by calling their respective stringify methods and combines them appropriately before returning the result.

## Expression evaluation

Tess can numerically evaluate an expression, provided it does not contain any undefined variables. The evaluation logic is similar to the stringify function: children return their values to their parents, which combine them according to the designated operation and return the result to their parent.

## Simplification

Tess can perform basic simplifications. It can combine like terms in addition and multiplication, factor expressions, and use factorization to simplify by canceling out common factors. However, the child-to-parent cascading strategy used in the stringify and evaluation methods proves inadequate for more complex simplifications. For example, a parent expression might require a child expression to be formatted differently based on the type of simplification being attempted. While this method is sufficient for simple tasks like combining like terms and factoring out a common factor, a more sophisticated algorithm is needed for more involved simplification.

## Trigonometric function Evaluator

Tess can algebraically evaluate some trigonometric ratios. It applies standard trigonometric formulae to construct new trigonometric ratios from known ones.