0
votes

I'm having some problems with my mathematica code, I think I'm overlooking something simple. I get valid solutions for u0 thru u4, but it doesnt generate any plot at all. Also, I'd really like to plot in terms of ph, not ohc, and have given the relationships as well.

Solve[{u0 + u1 + u2 + u4 == 1,
  k1 == u1/(u0*ohc),
  k2 == u2/(u0*ohc^2),
  k4 == u4/(u0*ohc^4)},
 {u0, u1, u2, u4}]

Solve[Log[10, k1] == 9.5, k1]
Solve[Log[10, k2] == 22.8, k2]
Solve[Log[10, k4] == 32.4, k4]

ph == 14 - poh;
poh == -log[ohc];

Plot[{u1, u2, u3, u4}, {ohc, 0, 1}]
1

1 Answers

1
votes

Fix u0 and u3 typos, make a few adjustments for the way Mathematica does things and this should help.

Clear[u0, u1, u2, u4, k1, k2, k4];
{u0, u1, u2, u4} = {u0, u1, u2, u4} /. 
  First[Solve[{u0 + u1 + u2 + u4 == 1, k1 == u1/(u0*ohc), 
     k2 == u2/(u0*ohc^2), k4 == u4/(u0*ohc^4)}, {u0, u1, u2, u4}]]
k1 = k1 /. First[Solve[Log[10, k1] == 9.5, k1]]
k2 = k2 /. First[Solve[Log[10, k2] == 22.8, k2]]
k4 = k4 /. First[Solve[Log[10, k4] == 32.4, k4]]
ph == 14 - poh;
poh == -log[ohc];
Plot[{u0, u1, u2, u4}, {ohc, 0, 1}]
Table[{u0, u1, u2, u4}, {ohc, 0, 1, 1/10}]

and that Table might help explain why the Plot looks the way it does.