When it comes to "how to do the math" this repo was my starting point: https://github.com/Raskoll2/LLMcalc