## Description

I first joined Photomath as a content creator, solving mathematical problems that were too difficult for *PM Solver*, a Mathematica-like proprietary software. PM Solver creates step-by-step solutions to simple mathematical problems. For more difficult problems, content creators help PM Solver by, for example, setting up equations from a “word problem”. The difficulty is that content creators write mathematics in LaTeX, whereas PM Solver has its own syntax, so a lot of time was wasted doing error-prone syntax conversions by hand.

Deciding to resolve the problem, I wrote a transpiler which converts LaTeX into PM Solver syntax; similar to how TypeScript gets converted into JavaScript. Photomath adopted this solution and hired me into the web development team. The transpiler is still used by thousands of people as of 2021.

## Example

Consider the following LaTeX expression:

\sin{x}+\cos{y}=\frac{1}{2}\\ \frac{x^2+10x+2}{10y}+y=5 \end{aligned}

When rendered, it produces:

A content creator needs to write a solution to this system of equations. Without the LaTeX transpiler, this would involve writing Photomath Solver syntax by hand. But with the transpiler, the following Photomath Solver input is automatically generated:

system(sin(x)+cos(y)={{1}/{2}},{{x^2+10x+2}/{10y}}+y=5)

## Technologies used

The project core relied on formal language theory, namely context-free grammar and parser generators. However, the core needed to be embedded within an editor as can be seen on the picture at the start of this page, thus a lot more tooling was required.

- React
- PEG.js
- MobX
- Semantic UI
- Webpack
- Jest
- NodeJS