Mathematica Asked on April 19, 2021
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)} *)
Correct answer by Bob Hanlon on April 19, 2021
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)}} *)
Answered by Daniel Huber on April 19, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP