Solve for two variables but output second variable in terms of first variable

Here are some equations for illustration:

Format[Solve[{4*r1^3 == r2^2*(3*h),
t*r2^2*(h - d) == r2^2*(h + d)}, #] & /@ {{h, d}}, InputForm]

Here is their solution:

{{{h -> (4*r1^3)/(3*r2^2), d -> (4*r1^3*(-1 + t))/(3*r2^2*(1 + t))}}}

It is obvious that d -> h*(t - 1)/(t + 1) in above equation.

Is there any way to force Mathematica to output the results as:

{{{h -> (4*r1^3)/(3*r2^2), d -> h*(-1 + t))/(1 + t)}}}

This was a simple example but sometimes equations become too complicated and run for multiple lines. Figuring out a way to express one variable in terms of another will simplify them a lot.

Thanks. :)

(solh = Solve[{4*r1^3 == r2^2*(h - d + h + h + d),
t*r2^2*(h - d) == r2^2*(h + d)}, h, {d}]) // InputForm

(* {{h -> (4*r1^3)/(3*r2^2)}} *)

(sold = Solve[{4*r1^3 == r2^2*(h - d + h + h + d),
t*r2^2*(h - d) == r2^2*(h + d)}, d, MaxExtraConditions -> All] //
Quiet) // InputForm

(* {{d -> ConditionalExpression[
(h*(-1 + t))/(1 + t),
(r2 == 0 && r1 == 0 && 1 + t != 0) ||
(r2 != 0 && h == (4*r1^3)/(3*r2^2) &&
1 + t != 0)]}} *)

sol = {solh, sold}[[All, 1, 1]] // Normal

(* {h -> (4 r1^3)/(3 r2^2), d -> (h (-1 + t))/(1 + t)} *)
• Thanks @Bob. :) Dec 14 '20 at 6:29
• Hi @Bob. I noticed that changing the order of variables I am trying to find changes the final result as well. For example, h, {d}] and d to d, {h}] and h results in completely different outputs. Why does this happen? Dec 14 '20 at 6:37
• Solve[ ..., h, {d}] means solve for h while eliminating d. Solve[ ..., d, {h}] means solve for d while eliminating h. Solve[ ..., d, h] means solve for d and constrain it to the domain h. Since h is not a domain, you get a warning and it uses h as a variable to be eliminated, i.e., it interprets the statement as if you had entered Solve[ ..., d, {h}]. The elimination variable(s) even when just one are in List brackets to avoid initially being interpreted as a domain. Dec 14 '20 at 12:27

As r2 does not appear in your thought for solution, you could first eliminate r2 and then solve for d:

Solve[Eliminate[{4*r1^3 == r2^2*(3*h), t*r2^2*(h - d) == r2^2*(h + d)}, r2], d] // InputForm

(* {{d -> (-h + h*t)/(1 + t)}} *)