3
$\begingroup$

I need to solve a nonlinear system of equations that looks like this

$$\frac{1}{n_4}(\frac{c_4}{b_4R}-\ln(1-x_1-x_2-x_3))=\frac{1}{n_3}(\frac{c_3}{b_3R}-\ln(x_3))=\frac{1}{n_2}(\frac{c_2}{b_2R}-\ln(x_2))=\frac{1}{n_1}(\frac{c_1}{b_1R}-\ln(x_1)) $$

The numerical equivalent of what i'm trying to solve right now is

$$\frac{4100}{4100/297-1.987\ln(x_1)}=\frac{6200}{6200/303-1.987\ln(x_2)}=\frac{7000}{7000/327.5-1.987\ln(x_3)}=\frac{4100}{4100/404-1.987\ln(1-x_1-x_2-x_3)} $$

What algorithm should i use to solve this? If anyone can solve this, could you post how you did it? I tried using a multivariable newton's algorithm but my jacobian exploded

$\endgroup$
4
$\begingroup$

Hint

I think that you could reduce your problem to a single equation of a single variable.

Suppose that you define $$A=\frac{1}{n_4}(\frac{c_4}{b_4R}-ln(1-x_1-x_2-x_3))$$ So, you have $$A=\frac{1}{n_3}(\frac{c_3}{b_3R}-ln(x_3))=\frac{1}{n_2}(\frac{c_2}{b_2R}-ln(x_2))=\frac{1}{n_1}(\frac{c_1}{b_1R}-ln(x_1))$$ So $x_1,x_2,x_3$ can be expressed as a function of $A$ $$x_i(A)=\exp({\frac{c_i}{b_i~ R}-A~ n_i})$$ and you end with a single nonlinear equation $A=f(A)$ where only $A$ appears. $$A=\frac{1}{n_4}(\frac{c_4}{b_4R}-ln(1-x_1(A)-x_2(A)-x_3(A)))$$

You could notice that your equation in $A$ also write $$F(A)=\sum _{i=1}^{i=4} \exp({\frac{c_i}{b_i~ R}-A~ n_i})=1$$ which, more than likely, would much better conditionned if written $$G(A)=\log \Big(\sum _{i=1}^{i=4} \exp({\frac{c_i}{b_i~ R}-A~ n_i}) \Big )=0$$ Assuming all $n_i>0$, this shows that an upper bound of $A$ corresponds to the maximum,over $i$, of the $(\frac {c_i}{n_i~b_i~R})$ terms. This gives a starting value for unknown $A$.

Solve it for $A$ (Newton method seems to be very appropriate) and go backwards to get $x_1,x_2,x_3$.

In such a manner, you could notice that you could have as many equations as you could wish and apply the same procedure.

Using the data from your problem, we can easily find that the solution is $A=271.069$ from which we get $x_1=0.514479,x_2=0.297290,x_3=0.106527$ which are your answers.

$\endgroup$
3
$\begingroup$

Ok i actually found the answer and i'm just gonna share it since no one has posted yet

$x_1=.514, x_2=.297, x_3=.107$

Rearrange the equation for easier Jacobian

$$\frac{4100/(1.987*297)-ln(x_1)}{4100/1.987}=\frac{6200/(1.987*303)-ln(x_2)}{6200/1.987}=\frac{7000/(1.987*327.5)-ln(x_3)}{7000/1.987}=\frac{4100/(1.987*404)-ln(1-x_1-x_2-x_3)}{4100/1.987} $$

Construct a system of equations in the form of $f_i(x_1,x_2,x_3)=0$ for $i=1,2,3$

$$f_1(x_1,x_2,x_3)=\frac{4100/(1.987*297)-ln(x_1)}{4100/1.987}-\frac{4100/(1.987*404)-ln(1-x_1-x_2-x_3)}{4100/1.987} $$ $$ f_2(x_1,x_2,x_3)=\frac{6200/(1.987*303)-ln(x_2)}{6200/1.987}-\frac{4100/(1.987*404)-ln(1-x_1-x_2-x_3)}{4100/1.987} $$ $$ f_3(x_1,x_2,x_3)=\frac{7000/(1.987*327.5)-ln(x_3)}{7000/1.987}-\frac{4100/(1.987*404)-ln(1-x_1-x_2-x_3)}{4100/1.987} $$

$$F(X)=[f_1(x_1,x_2,x_3),f_2(x_1,x_2,x_3),f_3(x_1,x_2,x_3)]^T $$ $$X=[x_1,x_2,x_3]^T $$

Construct Jacobian for the system

$$ F'(X)=[\frac{\partial f_1}{\partial x_1},\frac{\partial f_1}{\partial x_2},\frac{\partial f_1}{\partial x_3};\frac{\partial f_2}{\partial x_1},\frac{\partial f_2}{\partial x_2},\frac{\partial f_2}{\partial x_3};\frac{\partial f_3}{\partial x_1},\frac{\partial f_3}{\partial x_2},\frac{\partial f_3}{\partial x_3}] $$

Solve $F(X)=-F'(X)H$ for $H$ using Gaussian elimination

Update $X$ by using $X^{(k+1)}=X^{(k)}+H^{(k)}$, in this case using $X=[.01,.01,.01]^T$

Repeat until reached acceptable error bound

My jacobian exploded because i didn't give a good initial guess, but then i guessed slightly lower and everything worked.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.