Some years ago, I had the same problem.
Since writing a robust parser is not a trivial exercise, I decided to not try it in TeX, but use Python (version 3.6 or later) instead.
The result was the TeXcalc module.
The input looks like this:
from texcalc import Calculation c = Calculation() c.add('rho_f', '1.62', 'g/cm^3', 'Fiber density') c.add('rho_r', '1.2', 'g/cm^3', "Resin density") c.add('v_f', '0.3', '-', 'Fiber volume fraction') c.add('W_f', '450', 'g/m^2', "Area weight fibers", fmt=".0f") c.add('t_f', 'W_f/(10000*rho_f)*10', 'mm') c.add('t', 't_f/v_f', 'mm', "Laminate thickness") c.add('t_r', 't-t_f', 'mm') c.add('W_r', 't_f/10*(10000*rho_r)', 'g/m^2', "Area weight resin", fmt=".0f") print(c)
It outputs an align* environment (from the amsmath package) and uses siunitx to typeset the units. After processing with LaTeX, the output looks like this. 
Adapted to the MWE on request
The following are the contents of mwe.py
from texcalc import Calculation c = Calculation() c.add('b', 4) c.add('a', 1) c.add('c', 3) c.add('x1', '(-b+sqrt(b**2-4*a*c))/2', 'cm', 'first root') c.add('x2', '(-b-sqrt(b**2-4*a*c))/2', 'cm', 'second root') print(c)
Run this as python3 mwe.py > foo.tex
This is mwe.tex:
\documentclass[preview=true]{standalone} \usepackage{amsmath,siunitx} \begin{document} \input{foo.tex} \end{document}
Run this with pdflatex mwe.tex.
This results in: 
The goal of TeXcalc is to clarify complicated calculations that have multiple steps, as shown in the first example. This to make it easier for others to follow.
So it cannot exactly match your MWE, since it doesn't produce in-line math. Although in this case, you could extract the necessary data from foo.tex.