MATLAB: How to solve 5 quadratic equations simultaneously

quadratic equations

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.

Best 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.