# Can I use calc-eval to solve an equation?

I regularly use calc-eval in the *scratch* buffer to work out some quick calculations. I know that I can use some simple functions inside the calculation string, e.g. log. However I am not certain whether I can use the solver in the same way.

Is it possible to write a calc-eval expression that solves for, say, a particular variable?

Yes, for example:

(calc-eval "solve([x+y=3, x-y=1], [x,y])")


evaluates to:

"[x = 2, y = 1]"


You might find it more comfortable to use a calc-mode buffer than running calc-eval in the scratch buffer, though.

Check out section 11.6 of the Calc manual, which is about solving equations. I just use calc-mode rather than calling calc-eval by hand, but it seems like you'd be able to use the functions it describes.