How to solve 5 quadratic equations simultaneously

I am wondering if anyone has experience with using Matlab to solve 5 quadratic equations simultaneously – we are trying to model competitive binding with 5 proteins and 1 ligand. The program seems to work fine with up to 4 equations but crashes with 5 equations.
My codes are as follows:
(for 4)
syms LIDtot I1tot kdI1 x I2tot kdI2 y L3tot kdL3 z L4tot kdL4 w
S = solve ([(I1tot-x)*(LIDtot-x-y-z-w)==kdI1*x,(I2tot-y)*(LIDtot-x-y-z-w)==kdI2*y,(L3tot-z)*(LIDtot-x-y-z)==kdL3*z,(L4tot-w)*(LIDtot-x-y-z-w)==kdL4*w], [x,y,z,w])
This works fine.
(for 5)
syms LIDtot I1tot kdI1 x I2tot kdI2 y L3tot kdL3 z L4tot kdL4 w M4tot kdM4 v
S = solve ([(I1tot-x)*(LIDtot-x-y-z-w-v)==kdI1*x,(I2tot-y)*(LIDtot-x-y-z-w-v)==kdI2*y,(L3tot-z)*(LIDtot-x-y-z-w-v)==kdL3*z,(L4tot-w)*(LIDtot-x-y-z-w-v)==kdL4*w,(M4tot-v)*(LIDtot-x-y-z-w-v)==kdM4*v], [x,y,z,w,v])
This crashes.
Any help and advice would be much appreciated. Thanks.

 Accepted Answer

For that particular set of equations you could take steps to make things easier. Introduce a new unknown 't':
t = LIDtot-x-y-z-w-v;
Then each of your five equations can easily be solved for the corresponding x, y, z, w, or v in terms of t. Finally, introducing those expressions into
t = LIDtot-x-y-z-w-v;
will give you a single equation in 't'. I think this equation will simplify to a fifth degree polynomial equation in t, so there may not exist an explicit solution for it, but it presents a direct way of numerically solving your equations using matlab's 'roots' functions in combination with the above expressions for x, y, z, w, and u, for any given numerical values of LIDtot, I1tot, kdI1, etc.
Also this perhaps shows why you succeeded with only four equations and four unknowns since that would have resulted in a quartic equation in t which possesses an explicit solution.

6 Comments

As Walter has pointed out, strictly speaking, the single equation in t will simplify to a sixth degree polynomial, but t is a factor in all its terms, so t = 0 is one of the roots and what is left is a fifth degree polynomial equation with five more roots.
Thanks very much and yes, it would make sense to define t this way. I am wondering if there is a way to obtain an explicit solution for 5th or higher order polynomials, if such a solution exists. This will allow us to use Origin or GraphPadPrism to fit experimental data using the solution. We can use Matlab to do the fitting also but we are very new to Matlab and just starting to explore the different options.
@Ann: I'm afraid your chances are slim of getting a general solution to that quintic polynomial equation. If you read the article in this website:
you will see why. It states that "In algebra, the Abel–Ruffini theorem (also known as Abel's impossibility theorem) states that there is no general algebraic solution—that is, solution in radicals—to polynomial equations of degree five or higher with arbitrary coefficients."
Thanks Roger and I see. We will stick with "root" when we have 5 or more binding partners.
@Ann: I was mistaken in asserting that t=0 is one of the roots of the single equation in t. That is only true if 'LIDtot' is zero. Therefore this equation will in fact reduce to a sixth degree polynomial equation (with the aid of the symbolic toolbox) and will yield six roots numerically using matlab's 'roots' function.
@Roger: Thanks and all good. I was expecting 6 solutions (roots) for 5 competitors as there are generally n+1 solutions where n is the number of competitors. However, only one of these is meaningful in the physical experiment and we simply restrict the root value to be 0 up to LIDtot or one of the other tot (whichever appropriate, the smaller value of the two).

Sign in to comment.

More Answers (1)

Z6 = (kdL4-kdM4)*(kdL3-kdL4)*(kdI2-kdL4)*(kdI1-kdL4);
Z5 = kdL4^5+(L4tot-M4tot+LIDtot-kdI1-kdI2-kdL3-kdM4-I1tot-I2tot-L3tot)*kdL4^4+((-2*kdI1-2*kdI2-2*kdL3-2*kdM4)*L4tot+(M4tot-LIDtot+kdI2+kdL3+kdM4+I2tot+L3tot)*kdI1+(M4tot-LIDtot+kdL3+kdM4+I1tot+L3tot)*kdI2+(M4tot-LIDtot+kdM4+I1tot+I2tot)*kdL3-kdM4*(LIDtot-I1tot-I2tot-L3tot))*kdL4^3+(((3*kdI2+3*kdL3+3*kdM4)*kdI1+(3*kdL3+3*kdM4)*kdI2+3*kdL3*kdM4)*L4tot+((-M4tot+LIDtot-kdL3-kdM4-L3tot)*kdI2+(-M4tot+LIDtot-kdM4-I2tot)*kdL3+kdM4*(LIDtot-I2tot-L3tot))*kdI1+((-M4tot+LIDtot-kdM4-I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)*L3tot)*kdI2-(1/2)*kdL3*(LIDtot-I2tot))*kdI1-(1/2)*kdI2*kdL3*(LIDtot-I1tot))*kdL4+kdI1*kdI2*kdL3*(LIDtot+(2/3)*L4tot)))*L4tot^2*Z^2-4*L4tot^3*((((-(1/4)*LIDtot+(1/4)*kdL3+(1/4)*L3tot)*kdI2-(1/4)*kdL3*(LIDtot-I2tot))*kdI1-(1/4)*kdI2*kdL3*(LIDtot-I1tot))*kdL4+kdI1*kdI2*kdL3*(LIDtot+(1/4)*L4tot))*Z+L4tot^4*LIDtot*kdI1*kdI2*kdL3)/(((kdI1-kdL4)*Z-L4tot*kdI1)*((kdI2-kdL4)*Z-L4tot*kdI2)*((kdL3-kdL4)*Z-L4tot*kdL3)*(-L4tot+Z));
... except that you need to vectorize these, which I have not done in my transcription.
The polynomial turns out to be degree 6.

3 Comments

Thanks very much and I see. Is there a way to easily set up the equations/code so we can easily change between having different number of competitors (from 5 to 10 say, which is what we have experimentally)? For the 1 to 4 case, we can obtain the explicit solution from solve.
It looks to me as if it might be an eigenvalue problem??
Possibly. Unfortunately my maths isn't strong...

Sign in to comment.

Categories

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!