# Find the chemical composition of a compound solving a system of equations?

Posted 1 year ago
1878 Views
|
8 Replies
|
3 Total Likes
|
 Hi to all,This is the first time I'm using Mathematica. I'm trying to analyze data from elemental analysis experiments on a compound in order to find its chemical composition, so I've typed a six equation system with five variables (please find attached the file containing the system if you want to have a look). However, I'm not sure about the command I should use. Solve gives me a result (which does not match the expected composition, but this is another question), but previosuly writes this error message: Solve was unable to solve the system with inexact coefficients. The answer was obtained by solving a corresponding exact system and numericizing the result. What are inexact coefficients and why does the program tell me this?When I use FindInstance command, the program gives me the same result, but no error message is printed this time. Why?Finally, when I use Reduce command (I want to know all the possible solutions for my system), the program again prints an error message (Reduce was unable to solve the system with inexact coefficients. The answer was obtained by solving a corresponding exact system and numericizing the result) and the result is False. Why? I expected the program to give me at least the same solution that Solve and FindInstante did.Could anyone tell me if there is an evident mistake in the code I typed that I'm seeing?Thank you very much in advance!Regards! Attachments:
8 Replies
Sort By:
Posted 1 year ago
 May be wrong here, but there are 6 equations and 5 unknowns, if you remove eqn 6 or 5 it solves to same results, if you also stipulate in findinstance, 2, i.e. at end of the line before last bracket put ,2 it only finds one solution, so there are no more possible solutions to find. Also if you want exact results replace all the decimal numbers with an equivalent fraction, so c1 would be 12011/1000 etc, the results are then {n -> 173215706769233171913184126360/3881732658541918082745706259, m -> 2011250091823242432811209994438/3881732658541918082745706259, x -> 57903752528057699427340882944/3881732658541918082745706259, y -> 132095/89712, z -> 64378109342715479415997877210/3881732658541918082745706259} 
Posted 1 year ago
 The system is overdetermined (as others have noted). All the same it appears NSolve can handle it. eqns = {-1201.1 (1479.5354631799682 + 4 n + 14 x + 94.35073779795688 z) + 42.82 (61.948 x + 63.546 x y + 14.007 (n + 5 x + 4 z) + 15.999 (1233.94621931664 + m + n + 9 x + 45.67536889897844 z) + 12.011 (1479.5354631799682 + 4 n + 14 x + 94.35073779795688 z) + 1.008 (2467.89243863328 + 2 m + 3 n + x (25 - y) + 184.70147559591376 z)) == 0, -100.8 (2467.89243863328 + 2 m + 3 n + x (25 - y) + 184.70147559591376 z) + 7.385 (61.948 x + 63.546 x y + 14.007 (n + 5 x + 4 z) + 15.999 (1233.94621931664 + m + n + 9 x + 45.67536889897844 z) + 12.011 (1479.5354631799682 + 4 n + 14 x + 94.35073779795688 z) + 1.008 (2467.89243863328 + 2 m + 3 n + x (25 - y) + 184.70147559591376 z)) == 0, -1599.9 (1233.94621931664 + m + n + 9 x + 45.67536889897844 z) + 44.685 (61.948 x + 63.546 x y + 14.007 (n + 5 x + 4 z) + 15.999 (1233.94621931664 + m + n + 9 x + 45.67536889897844 z) + 12.011 (1479.5354631799682 + 4 n + 14 x + 94.35073779795688 z) + 1.008 (2467.89243863328 + 2 m + 3 n + x (25 - y) + 184.70147559591376 z)) == 0, -1400.7 (n + 5 x + 4 z) + 2.7 (61.948 x + 63.546 x y + 14.007 (n + 5 x + 4 z) + 15.999 (1233.94621931664 + m + n + 9 x + 45.67536889897844 z) + 12.011 (1479.5354631799682 + 4 n + 14 x + 94.35073779795688 z) + 1.008 (2467.89243863328 + 2 m + 3 n + x (25 - y) + 184.70147559591376 z)) == 0, -6194.8 x + 0.96 (61.948 x + 63.546 x y + 14.007 (n + 5 x + 4 z) + 15.999 (1233.94621931664 + m + n + 9 x + 45.67536889897844 z) + 12.011 (1479.5354631799682 + 4 n + 14 x + 94.35073779795688 z) + 1.008 (2467.89243863328 + 2 m + 3 n + x (25 - y) + 184.70147559591376 z)) == 0, -6354.6 x y + 1.45 (61.948 x + 63.546 x y + 14.007 (n + 5 x + 4 z) + 15.999 (1233.94621931664 + m + n + 9 x + 45.67536889897844 z) + 12.011 (1479.5354631799682 + 4 n + 14 x + 94.35073779795688 z) + 1.008 (2467.89243863328 + 2 m + 3 n + x (25 - y) + 184.70147559591376 z)) == 0}; polys = Apply[Subtract, eqns, {1}]; Solve and check residuals. NSolve[polys, {n, m, x, y, z}] polys /. approxSol (* Out[8]= {{n -> 44.6232963489, m -> 518.132047914, x -> 14.9169862073, y -> 1.47243401106, z -> 16.5848900493}} Out[9]= {{-9.31322574615*10^-10, 3.49245965481*10^-10, 3.72529029846*10^-9, -1.57160684466*10^-9, 1.30967237055*10^-10, -2.91038304567*10^-11}} *) 
Posted 1 year ago
 Juan,If this is a chemical stoichiometry problem where atoms combine to make reactants and reactants combine in reactions then it is a homological algebra problem. The atoms are the boundary of the reactants and the reactants are the boundary of the reactions. The boundary of a boundary is zero, which is the requirement that reactions are balanced. This can be expanded into finding various possible sets of reactants and reactions for a chemical system.I've been working with John Browne on applications of Grassmann algebra and this is one of them, on which I have a fairly extensive notebook. If this sounds appropriate to your problem you could contact me at my profile email.
Posted 1 year ago
 Solve and Reduce are symbolic solvers, designed to work with infinite precision inputs.
Posted 1 year ago
 Thank you for your response, but I'm afraid that I still don't understand why my system has inexact coefficients or why Reduce is not able to find at least the same solution as Solve.
Posted 1 year ago
 Thank you very much for your answers. Using fractions instead of decimal numbers worked, as no error messages appeared and Reduce and Solve commands gave the same results. Now it is clear to me that there are no other exact solutions for the system. As this solution is not physically aceptable because n+x+z should be around 50, I've been adviced to introduce a pertubation in the system for finding an approximate solution that fulfil this condition. But I have no idea about how to do it. Could you recommend me any text where I could learn to program this?Thank you again!