4
$\begingroup$

Suppose there is an equation like this (overly simplified example):

eqn1 = ui - ua r1 / (r1 + r2) == 0

How can I get Mathematica to "solve" the equation in terms of:

eqn2 = v == ua / ui

i.e. have Mathematica deliver v == 1 + r2 / r1 as a result? Despite googling I cannot find the proper way (tried equation system, Eliminate, LinearSolve, ...). Thanks in advance - Rob

$\endgroup$
0

2 Answers 2

5
$\begingroup$

You can combine Solve with Eliminate:

Solve[
    Eliminate[{ui-ua r1/(r1+r2)==0,v==ua/ui}, ua],
    v
]

{{v -> (r1 + r2)/r1}}

$\endgroup$
2
  • $\begingroup$ works like a charm, thx. Shouldn't the 2nd parameter on Eliminate be the list {ua , ui} rather than {ua} ? $\endgroup$ May 30, 2019 at 0:03
  • $\begingroup$ @RobertGIDS. With only two equations, I think it's safer to try to eliminate just one variable. $\endgroup$
    – Carl Woll
    May 30, 2019 at 0:17
5
$\begingroup$

Although not currently documented, you can include in Solve a list of variables to be eliminated.

Solve[{ui - ua r1/(r1 + r2) == 0, v == ua/ui}, v, {ua}][[1]] // Expand

(* {v -> 1 + r2/r1} *)
$\endgroup$
2
  • $\begingroup$ Thx, this works indeed - though I'm confused as the Language Reference designates Solve's 3rd parameter as "domain", e.g. Integers, Reals, Complexes - it never occured to me that "domain" could also be used for variable elimination. I guess not many folks are aware of this context - so kudos to you for pointing this out. I'd appreciate if you kindly comment on this "[ [1] ]" construct - what is it's meaning ? $\endgroup$ May 29, 2019 at 23:56
  • $\begingroup$ @RobertGIDS. - As I stated, the use of a list of variable to be eliminated is not documented. It was a long time ago and presumably still functions to maintain backward compatibility. Consequently, the third argument here is not being used to specify a domain. The [[1]] takes the first element of a list (see Part). In this case it removes an extra set of list brackets. $\endgroup$
    – Bob Hanlon
    May 30, 2019 at 0:06

Your Answer

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

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