Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

This is sort of embarrassing. I'm working on a document to extol the virtues of Mathematica, and I can't get it to solve a relatively simple system of equations involving units. In this code, when I use <<<1 atm>>> I mean I'm using the ctrl-= method of adding units.

Keq = <<<3 /atm^2>>>
P0N2 = <<<10 atm>>>
POH2 = <<<20 atm>>>

Now I define the equations I want to solve, a straightforward equilibrium system:

eq1 = PN2 == P0N2 - z
eq2 = PH2 == P0H2 - 3*z
eq3 = PNH3 == 2*z
eq4 = PNH3^2 / (PN2*PH2^3) == Keq

Now, I want to solve these equations, knowing about where the solutions lie:

FindRoot[{eq1, eq2, eq3, eq4}, {{z, <<<6 atm>>>}, {PN2, <<<11 atm>>>}, {PH2, <<<4 atm>>>}, {PNH3, <<<2 atm>>>}}]

I get:

FindRoot:nlu: -- Message text not found -- ({6. atm, 11. atm, 4. atm, 2. atm})({z, PN2, PH2, PNH3})({7. atm, 2. atm, -10. atm, -2.99432/atm^2})({4})(Removed[$$Failure])

FindRoot[{eq1, eq2, eq3, eq4}, {{z, 6 atm}, {PN2, 11 atm}, {PH2, 4 atm}, {PNH3, 2 atm}}]

I am really at a loss for that error. Any ideas about what Mathematica wants?

Cheers, Charles.

share|improve this question
3  
The implementation of units is very buggy... probably not the best choice of functionality if you want to extol the virtues of Mathematica :) –  rm -rf Apr 8 at 17:44

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.