5

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?

Drew
  • 75,699
  • 9
  • 109
  • 225
Conor
  • 475
  • 3
  • 11

2 Answers2

7

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.

Omar
  • 4,732
  • 1
  • 17
  • 32
2

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.

db48x
  • 15,741
  • 1
  • 19
  • 23