3
$\begingroup$

I have 2 equations, p4a and r4p which relate $a,p,r$ and want to see 6 equations relating all ordered pairs of these 3 variables. Below is an example of doing semi-manually by using Eliminate combined with Solve. This approach feels like I'm re-implementing built-in functionality (why was manual Eliminate step necessary here?), is there a simpler way?

p4a = 1/(1 - a);
r4p = 1/(-1 + p);


temp = Eliminate[{p == p4a, r == r4p}, p];
a4r = First@SolveValues[temp, a];
solve[eq_, var_] := Print[var, "=", First@SolveValues[eq, var]];
solve[p == p4a, p]
solve[r == r4p, r]
solve[a == a4r, a]
solve[p == p4a, a]
solve[r == r4p, p]
solve[a == a4r, r]
$\endgroup$
5
  • 2
    $\begingroup$ Yes, just solve for the three possible pairs. In[331]:= SolveValues[{p == p4a, r == r4p}, {p, r}] Out[331]= {{1/(1 - a), (1 - a)/a}} In[332]:= SolveValues[{p == p4a, r == r4p}, {p, a}] Out[332]= {{(1 + r)/r, 1/(1 + r)}} In[333]:= SolveValues[{p == p4a, r == r4p}, {r, a}] Out[333]= {{1/(-1 + p), (-1 + p)/p}} $\endgroup$ Apr 5, 2023 at 22:46
  • $\begingroup$ Ahh, so I need to specify all unknowns as "vars", not just the variable I'm solving for $\endgroup$ Apr 5, 2023 at 23:02
  • $\begingroup$ No, just the ones you are solving for in this case. There are three pairs, so call SolveValues three different ways. $\endgroup$ Apr 5, 2023 at 23:53
  • $\begingroup$ If I try to solve for a single variable, Solve returns no solutions, so I must specify variables in pairs, that's what confused me $\endgroup$ Apr 6, 2023 at 0:05
  • 2
    $\begingroup$ Generally speaking, n equations requires n variables. Fewer variables than that and it is often generically overdetermined. Empty solution set, unless you give nondefault MaxExtraConditions. $\endgroup$ Apr 6, 2023 at 3:27

1 Answer 1

1
$\begingroup$

As pointed out in comments, I should list all unknown variables as part of Solve "vars" parameter, not just the ones I'm trying to solve for

$\endgroup$
0

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.