Message Boards Message Boards

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

GROUPS:

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!

Answer
1 month ago

Solve and Reduce are symbolic solvers, designed to work with infinite precision inputs.

POSTED BY: Frank Kampas
Answer
1 month 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.

Answer
1 month 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 BY: Paul Cleary
Answer
1 month 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 BY: Daniel Lichtblau
Answer
1 month 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!

Answer
1 month 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 BY: David J M Park Jr
Answer
1 month ago

Thanks for your answer, David. This is not a reaction balancing problem but the analysis of the compositional data of a compound to find out its chemical structure. The compound is a oligomer (aprox. DP = 246) on which we have attached a number of three different types of substituents, one of them being also another oligomer (aprox. DP = 45). We expected that the algebraic analysis of the data from elemental analysis (for C, H and N) and ICP-MS (for P, Cu, Li and Na) could give as an average number of each motif present on the final structure. However, we obtained some results with no physical sense (negative numbers, a number of anchoring points too large, etc). I'm not familiar with Grassmann algebra, so I cannot tell wether it may be able to manage this problem or not. What's your opinion? Thank you again for your time.

Answer
25 days ago

Juan, I'm not completely certain what I'm suggesting will help you, but there is a chance. If what I write is all nonsense then ignore it. You haven't specified to me everything clearly enough, but I would say that if you are adding one chemical unit to another, or substituting one unit for another unit then there are at least implied chemical reactions. And if you don't know how many units of some monomer or oligomer were added then it is partly a manner of balancing the equation. Conversely, to the extent that the reactions are known then this would restrict the reactants that could be present. I use the term "moiety" to stand for any chemical element that reacts as a unit and is never broken down by the reactions. Then the stoichiometric analysis might give you the chemical reactants that can occur in terms of moieties and atoms. Analyzing the moieties into their atoms you would have an atomic abundance for each possible reactant, which you might try to match with data.

I've added a PDF file of most of the notebook I did on chemical systems. It shows some of the things that one can do with the Grassmann algebra, homological algebra approach. There are many approaches depending on which things are parameters and which things are fixed.

POSTED BY: David J M Park Jr
Answer
25 days ago

Group Abstract Group Abstract