Math Mavens - Hopefully Easy Algebra Query

I’m having a difficult time re-arranging this equation to solve for V. My HP-48 claims it is impossible. I think it lies, but I can’t solve it either.

The equation:

P = (R*T/(V-B)) - (A/V[sup]2[/sup])

How can I solve this for V?

If you want an exact solution, the only way I know of would be to rewrite the equation as a cubic polynomial in V, then use the cubic equation. There may be simpler ways for particular values of P, R, T, B, and A that cause things to work out nicely.

Alternately, you could again write the equation as a cubic polynomial in V, then use a numerical method such as Newton’s method to get an approximation to a solution of the equation.

I can manipulate that to PV[sup]3[/sup] + (-PB -RT)V[sup]2[/sup] + AV - B = 0 (I think. I may have made an error here). This is a cubic, and there does exist an analytic solution to a general cubic equation, but I’m not sure what it is. Note that there are three solutions, but two of them are probably complex. At least one is real, and I presume that’s the one you want.

Can you tell us anything else about the values of P, R, T, A, and B? If they stand for what I think they do, then P, R, and T must all be positive, at least (as must V), but I’m not sure what A and B are.

Ah, PV = RT, huh?

I think that you will have to rearrange until V = an expression which also contains V. Then trial and error will solve it. I get:

V = ((V * R * T )/P * ( V - B)) - ( A / P * V)

Hmm…well, if you get a common denominator on the RHS you can get a trinomial in V, but I don’t know if that’s solvable. I get:

PV[sup]3[/sup]-(PB+RT)V[sup]2[/sup]+AV-A*B=0

Maybe your calculator/computer can solve from there.

Okay, got Mathematica working, finally (^#%&@ SysAdmins breaking things…); solving the above equation gives one real and two complex, all rather ugly, solutions. If you don’t get it and no one posts something better in the near future, I’ll try to clean up the command-line output and put it here.

Now, Anthracite, it’s a feather in your cap to think of 4 of us churning for 45 minutes to produce an answer within the same three minutes, ain’t it? :stuck_out_tongue:

Cubic, not trinomial. Stinkin’ math terms.

Are you trying to get a function V in terms of the other variables? Am I reading the OP right?

IOW you want V=…?

I have a different answer, but it’s probably wrong, since it’s so different. It’s been a long time since i did real math. It seems to work out ok in my head, but I may be misunderstanding something:
( multiply both fractions by 1 (V+B)/(V+B) and (1-B^2)/(1-B^2) )
P = ((RT)(V+B))/((V-B)(V+B)) - (A(1-B^2))/((V^2)(1-B^2))

(now we have common denom. V^2-B^2)
P = ( (RT)(V+B) - (A(1-B^2)) )/(V^2-B^2)

(mult both sides by V^2-B^2)
PV^2 - PB^2 = (RT)(V+B)-(A(1-B^2))

(distribute)
PV^2 - PB^2 = RTV + RTB - A + AB^2

(set eq = 0)
PV^2 - PB^2 - RTV - RTB + A - AB^2 =0

which is:

PV^2 - RTV - RTB + A - PB^2 - AB^2 = 0

which you can apply to the quadratic formula, setting a=P, b=-RT and c=(A-PB^2-AB^2)

never mind. It is wrong.

V^2 ( 1- B^2) is V^2 - (V^2) (B^2)

duh.

It is a cubic equation, so no quadratic solution will work.

I also vote for Newton’s method, rather than trying to use the cubic solution. It’s just easier that way.

If I’m not mistaken, it looks a hell of a lot like the Van der Waals equation for the behavior of gasses, which is just the Ideal Gas Law with a few adjustments to take into account intermolecular attraction and the volume of the molecules. The general form is:

P = (nRT)/(V-nb) - (an^2)/(V^2)

Where n is the number of moles of gas particles, a is a constant relating to the intermolecular attractions, and b is a constant that accounts for the non-zero volumes of the molecules. The values of a and b will depend on the gas in question, and are determined empirically. I’m assuming that since Anthracite’s equation didn’t include n, that this has been combined with a and b to create the constants A and B. Also, R is the gas constant, so you might as well combine that into the constants, too.

Not much to contribute to the math, but I just couldn’t resist the temptation to answer a question of Chronos’s. :slight_smile:

Yes, I would want the real one.

This is van der Waals equation, and I am trying to solve it in terms of V so I can use it in my freeware science tool to calculate density of gases.

P is pressure, R is the gas constant, T is absolute temperature, and A and B are the “a” and “b” van der Waals constants, respectively. AFAIK, all terms must always be positive.

I thank everyone for trying to hard to help me with this. I think I need to read over your answers and see if I understand it properly. I would really like an analytical solution please (as it would be easier to code) rather than a numerical iterative one.

Some days I just feel dumb. I used to know this stuff. :frowning:

Almost - I tried to simply it by assuming that everything is on a “1 mole” basis, and thus the n has dropped out.

Anthracite: I had a similar question about a week ago wherein I asked how to algebraically solve a 4th order polynomial. I found the solution in the CRC Standard Mathematical Tables handbook. It worked.

Do you have access to the CRC book? Because in it contains the algebraic solution to the cubic equation. As stated by Chronos, there are three solutions. I suspect you already have an idea of what the solution looks like, so it will just be a matter of picking the right solution. (There are three possibilities: a) One real root and two conjugate imaginary roots, b) three real roots of which at least two are equal, c) three real and unequal roots.) If you don’t have access to the book, I will go ahead and post the solution.

The cubic equation solution can be found here:

http://mathworld.wolfram.com/CubicEquation.html

BTW: I came up with the same solution as Chronos. To arrive at this solution,

  1. Multiply both sides by (V-B)
  2. Condense, rearrange, etc. You will notice one of the terms has a V[sup]2[/sup] in the denominator, therefore
  3. Multiply both sides by V[sup]2[/sup]
  4. Condense, rearrange, etc.

After you do the above you should come up with the following:

PV[sup]3[/sup] + (-PB-RT)V[sup]2[/sup] + AV + (-AB) = 0

You’ll want to make the coefficient for V[sup]3[/sup] = 1, so you need to divide both sides by P:

V[sup]3[/sup] + ((-PB-RT)/P)*V[sup]2[/sup] + (A/P)V + (-AB/P) = 0

What the hell, I’ll just crank out the solution using the CRC handbook…

Let’s assign each coefficient as follows:

p = (-PB-RT)/P
q = A/P
r = -A*B/P

So that we now have

V[sup]3[/sup] + pV[sup]2[/sup] + qV + r = 0

Next compute the following:

a = (1/3)(3q - p[sup]2[/sup])
b = (1/27)(2p[sup]3[/sup] – 9pq + 27*r)
A = ((-b/2)+sqrt(((b[sup]2[/sup])/4)+((a[sup]3[/sup])/27)))^(1/3)
B = ((-b/2)-sqrt(((b[sup]2[/sup])/4)+((a[sup]3[/sup])/27)))^(1/3)

Solution 1: (A+B)-(p/3)
Solution 2: ((-(A+B)/2) + ((A-B)/2)(sqrt(-3)))-(p/3)
Solution 3: ((-(A+B)/2) - ((A-B)/2)
(sqrt(-3)))-(p/3)

Note that sqrt(-3) = i*sqrt(3), where i = sqrt(-1). In other words, there may be some complex mathematics involved.

By the power of Maple, I was able to get one real solution for V in explicit form. It was, however, stupidly long (i.e., three screen widths). So I had Maple convert it into a Fortran procedure:



      t1 = 1/P
      t3 = P**2
      t5 = A*P
      t6 = R*T
      t8 = t3*P
      t9 = B**2
      t10 = t9*B
      t12 = t3*t9
      t14 = P*B
      t15 = R**2
      t16 = T**2
      t17 = t15*t16
      t19 = t15*R
      t20 = t16*T
      t25 = t9**2
      t27 = A**2
      t46 = (72*A*B*t3-36*t5*t6+8*t8*t10+24*t12*t6+24*t14*t17+8*t19*t20+
     #12*sqrt(3.E0)*sqrt(A*(8*A*t3*t9+4*t8*t25+4*t27*P-20*t5*B*R*T-A*t15
     #*t16+12*t3*t10*t6+12*P*t9*t17+4*B*t19*t20))*P)**(1.E0/3.E0)
      t55 = t1*t46/6+2.E0/3.E0*(-3*t5+t12+2*t14*t6+t17)*t1/t46+(t14+t6)*
     #t1/3


(t55 is the solution to V.)

Hopefully this gives the same result as Crafter_Man’s solution, but I ain’t gonna check that.

Caveat: this is one real solution. There may be up to two others. Do you need all of the real solutions, or just one?

Wow.

I had no idea that such a simple-seeming equation held such atrocities of mathematics in re-arranging the variables. :eek:

I only need one real solution - the computer doesn’t really care about slightly different optimal solutions.

Thanks guys. I need to look at this, and give it a test or two tomorrow. :slight_smile:

I’m afraid you can’t count on “slightly different” solutions. For instance, (A, B, P, R, T) = (2, 0, 1, 1, 3) gives you the following equation:

1 = 3 / V - 2 / V[sup]2[/sup]

This has solutions at V = 1 and V = 2, different by a factor of 2.