GNU libmatheval is a library (callable from C and Fortran) to parse and evaluate symbolic expressions input as text.