I have a series of equations where I use eliminate to get a new equation with desired variables. This equation is then solved for a specific variable and then the result is presented in a specific InputForm. Here is how I am doing it currently.

Eliminate[{f == x^2 + y^2, a == x + y, b == x y}, {x, y}]
2 b + f == a^2

Solve[2 b + f == a^2, b]
{{b -> 1/2 (a^2 - f)}}

Format[b, InputForm] /. {b -> 1/2 (a^2 - f)}
(a^2 - f)/2

So, I copy the result from Eliminate and then solve it for my variable and then copy the output and format it later.

Is there an easier way to do all this? For example, can I somehow specify in a single step the variables I want to eliminate and the variable for which I want to solve the equation and then get the output in InputForm?

I will probably have to do this for a lot of equations. So, copying each output, again and again, gets very tiresome.


  • $\begingroup$ Reduce[{f == x^2 + y^2, a == x + y, b == x y}, {a, b}, {x, y}] $\endgroup$
    – cvgmt
    Jan 15, 2021 at 9:15

1 Answer 1

b /. First@
  Solve[{f == x^2 + y^2, a == x + y, b == x y}, 
b, {x, y}] // InputForm

(*   (a^2 - f)/2   *)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.