Solving for a single variable across multiple equations

I have these three equations here:

Log10[f/(1 - f)] == pH - pKa + F Vs/(2.3 R T)
σM == cF VF
Ee - Epzc == VF + Vs


and I would like to have Mathematica put σM in terms of f. The obvious thing for a human to do would be to solve equation 1 for Vs, put that solution for Vs into equation 3 and solve for VF, and then finally put that solution for VF into equation 2. Is there a command or code snippet that would do this for me?

• Please do not use E as a variable, as that is reserved for $e=2.71828\dots$ in Mathematica. Anyway, look up Eliminate[]. Aug 8 '17 at 15:33
• Good point, I'll change that to avoid confusion. That isn't exactly my code that I used, I had just edited it to look more presentable.
– ham
Aug 8 '17 at 15:34
• Try Solve[{Log10[f/(1 - f)] == pH - pKa + F Vs/(2.3 R T), σM == cF VF, Ee - Epzc == VF + Vs}, σM, {Vs, VF}] Aug 8 '17 at 15:42
• Amazing, that's exactly it. What's the logic for putting {Vs, VF} there at the end? I see that the third parameter for Solve is a domain, but I'm not sure how {Vs,VF} can be the domain. Thanks for your help by the way.
– ham
Aug 8 '17 at 15:48
• By the way: "I'll change that to avoid confusion"? Really, you should change that to avoid being wrong, because Mathematica is going to interpret that as the number $e$ no matter what. Aug 8 '17 at 16:15

Once upon a time, Solve[] had the following documented syntax:

Solve[eqns, vars, elims] attempts to solve the equations for vars, eliminating the variables elims.

Altho this syntax has been superseded by the third argument now being a domain specification, this older syntax seems to have been retained for backwards compatibility. Thus, to solve for σM in your system of equations, while getting rid of the intermediate variables Vs and VF, you can do this:

Solve[{Log10[f/(1 - f)] == pH - pKa + F Vs/(2.3 R T), σM == cF VF,
Ee - Epzc == VF + Vs}, σM, {Vs, VF}]
{{σM -> (1.*cF*(1.*Ee*F - 1.*Epzc*F + 2.3*pH*R*T - 2.3*pKa*R*T -
0.998877*R*T*Log[f/(1. - 1.*f)]))/F}}


(I do not make any guarantees on whether this deprecated syntax will remain in future versions, however.)

• Thanks for the clear and thorough explanation. If I wanted to do this again in 5 years when that syntax has finally been removed, would the equivalent be: Solve[Eliminate[equations, {Vs, VF}], σM]?
– ham
Aug 8 '17 at 16:55
• That would be the somewhat circuitous route, yes. Aug 8 '17 at 17:04

I like the deprecated syntax; it's conceptually clearer and, if you only want to solve for a limited no. of variables, makes for a cleaner output. However, I've found that same functionality (the ability to eliminate designated unknowns) is found in the current syntax (at least in v 11.2).

Specifically, I've found that, if you have an underdetermined system, (i.e., n independent equations with at least n+1 unknowns), and specify exactly n of the unknowns in the list of variables, then Solve will attempt to solve for those n variables while simultaneously eliminating them from all of the resulting expressions. I.e., If Solve provides an output, it will express those variables as dependent only. For example, the following gives expressions for x, y, and c as functions of some or all of the remaining unknowns (d, z, and b) only:

Solve[x + 2 y + 3 z == 4 b c && 3 x + 4 y + 5 z == 6 &&
6 x + 7 y + 8 z + d == 9, {x, y, c}]


Likewise, considering your problem, the following gives expressions for σM, Vs, and VF as functions of some or all of the remaining unknowns only:

Solve[Log10[f/(1 - f)] == pH - pKa + F Vs/(2.3 R T) && σM ==
cF VF && Ee - Epzc == VF + Vs, {σM, Vs, VF}]


This obviates the need for Solve[Eliminate[equations, {Vs, VF}], σM].

We can compare the expression the current syntax gives for σM with that from the deprecated syntax; you can see they're identical (I replaced 2.3 with 23/10 to give cleaner output and thus facilitate the comparison):

Solve[
Log10[f/(1 - f)] == pH - pKa + F Vs/(23/10 R T) && σM ==
cF VF && Ee - Epzc == VF + Vs, {σM, Vs, VF}]//Simplify

Solve[
Log10[f/(1 - f)] == pH - pKa + F Vs/(23/10 R T) && σM ==
cF VF && Ee - Epzc == VF + Vs, {σM}, {Vs, VF}]//Simplify


What I've described above (for the current syntax) works for all examples I've tested. However, I don't know if this behavior holds generally. Perhaps someone with deeper knowledge of MMA's underlying structure than I have can comment.