# Handling multi-part equations

How are multi-part equations best handled? For example, take the torsion equation:

We could express part of this equation like this:

torque := stress * moment / radius;


but then we could not re-define "torque" to mean something different in terms of G because it is already defined.

Ideally, we would like to represent the whole expression somehow and then solve for the term wanted depending on the situation. Is there any way to do this?

• what do you want to do with such relation? Is something like a == b == c what you are looking for (note the double = signs, which represent Equal as opposed to Set or SetDelayed)? – glS Oct 17 '16 at 13:14
• @glS You tell me. The equation shown is right out of a physics textbook. The question is how to manage this relation in Mathematica efficiently assuming that we want to compute different parts of it at different times. For example, at one time, we might want to compute torque in terms of stress, at other times torque in terms of twist angle, at other times we might want to compute stress in terms in twist angle. What is the most flexible way to compute ANY of the terms wanted in terms of any of the others. – Tyler Durden Oct 17 '16 at 13:32
• @glS What I am trying to avoid here is having multiple equations. For example, there are 7 different terms here and 3 different subexpressions. So, you could write this as 16 different separate equations. I do NOT want to write 16 different separate equations all with different variable names. I want to use a single equation and manipulate to determine the value wanted. – Tyler Durden Oct 17 '16 at 13:35

One way to approach this is to define a compound equation such as:

eqn = a/b == c/d || a/b == e/f || c/d == e/f


Now you can solve for any of the variables in terms of the others, for instance:

Solve[eqn, c]


or

Solve[eqn, d]


You can plug in values directly:

Solve[eqn /. {b -> 2, c -> 1, d -> 3}, a]

• That seems like an excellent approach; I will give it a try. – Tyler Durden Oct 17 '16 at 15:18
• Generating all pairs from equation "sides": Or @@ Equal @@@ Subsets[{a/b, c/d, e/f}, {2}]. – BoLe Oct 17 '16 at 18:09

You can represent the whole equation just as it is in the textbook

eqn = tork/moment == smax/radius == modulus θ/length;


Then, you can specify which to variables to eliminate and which to solve for

Assuming[{moment > 0, radius > 0, length > 0}, {
Solve[Eliminate[eqn, length], tork],
Solve[Eliminate[eqn, tork], θ]
}] // Flatten


To get expressions like this

$\left\{\text{length}\to \frac{\theta \text{ modulus } \text{moment}}{\text{tork}},\text{tork}\to \frac{\text{ moment } \text{smax}}{\text{radius}},\theta \to \frac{\text{length} \text{ smax }}{\text{modulus} \text{ radius}}\right\}$

How about defining all "sides", and then picking two.

{s1, s2, s3} = {torque/moment, stress/radius, bigG/bigL};


This way you do not have to specify all ${n} \choose {2}$ equation pairs; bill s' solution, although neat, doesn't allow solving c in terms of e & co. for example.