Easy and reliable method for solving four nonlinear equations

2.2k Views Asked by At

I have the following four equations with their four variables:

$$4.5*10^{-4}x=yz$$

$$z=\frac{10^{-14}}{t}$$ $$y=0.02-x$$ $$z=t+y$$

I'm going to be solving a lot of equations in a similar manner (with similar structures) so I would like a reliable method of solving them. It's from a acid-base reaction. Thanks in advance.

3

There are 3 best solutions below

1
On

we have from the first equation $$x=\frac{yz}{4.5\cdot 10^{-4}}$$ and with the third equation we get $$y+\frac{yz}{4.5\cdot 10^{-4}}=0.02$$ with $$(t+y)t=10^{-14}$$ we have $$y=\frac{10^{-14}}{t}-t$$ Setting this in the equation above we get an equation for $t$. Can you finish now? i mean this equation $$y+\frac{y(t+y)}{4.5\cdot 10^{-4}}=0.02$$

2
On

Since you wrote that you will need to solve similar equations, let us write them as $$a x=y\,z \tag 1$$ $$z=\frac b t\tag 2$$ $$y=c-x\tag 3$$ $$z=t+y\tag 4$$ We shall express everything as functions of $x$.

$y$ being given by $(3)$, plug it is $(1)$ to get $$z=\frac{a x}{c-x}\tag 5$$ Plug the result in $(2)$ to get $$t=\frac{b (c-x)}{a x}\tag 6$$ Plug all of the above in $(4)$ to get $$-\frac{b(c-x)}{ax}+\frac{a x}{c-x}-c+x=0\tag 7$$ Multiply everything by $ax(c-x)$ and group terms $$b c^2+x \left(a c^2-2 b c\right)+x^2 \left(-a^2-2 a c+b\right)+a x^3=0\tag 8$$ So, you have a cubic equation in $x$ for which you need to take the only real positive solution smaller than $c$.

When $x$ has been found, go back to $(2)$ to get $y$, to $(5)$ to get $z$, to $(6)$ to get $t$ and you are done.

If you don not want to solve the cubic equation, you can use a bisection method since $0 < x < c$. Considering the function $$F(x)=b c^2+x \left(a c^2-2 b c\right)+x^2 \left(-a^2-2 a c+b\right)+a x^3$$ you can verify that $$F(0)=b c^2\qquad \text{and}\qquad F(c)=-a^2c^2$$

What is funny is that, if we apply Newton method using $x_0=c$, the first iterate is $x_1=\frac c2$ and the second is $$x_2=c\frac{ a (a+c)+3 b}{4 \left(a^2+b\right)+a c}$$ Using your numbers, $x_2\approx 0.0187615$ while the exact solution is $x\approx 0.0172166$. I then suppose that a couple of Newton iterations will be sufficient.

To prove it, using your numbers, I give you below the successive iterates of Newton method for a very high accuracy. $$\left( \begin{array}{cc} n & x_n \\ 0 & 0.020000000000000000000 \\ 1 & 0.010000000000000000000 \\ 2 & 0.018761467874570977066 \\ 3 & 0.016664938725946721169 \\ 4 & 0.017189865745350019144 \\ 5 & 0.017216498016031164645 \\ 6 & 0.017216574333012570662 \\ 7 & 0.017216574333642261984 \end{array} \right)$$

Edit

Equation $(8)$ will always show three distinct real roots. Computing the discriminant of the cubic equation and simplifying, we have $$\Delta=a^2 c^2 \left(4 a^3 c^3+a^2 c^2 \left(a^2+12 b\right)+4 a b c \left(5 a^2+3 b\right)+4 b \left(a^2-b\right)^2\right) $$ which is always positive since all parameters $a,b,c,d$ are positive.

4
On

There are two equations involving just two unknows and you can eliminate two of them to get a system of two equations in two unknowns.

Substituting

$$z=\frac bt,y=c-x,$$

we have

$$\begin{cases}ax=b\dfrac{c-x}{t},\\ \dfrac bt=t+c-x.\end{cases}$$ or

$$\begin{cases}axt=bc-bx,\\ b=t^2+ct-xt.\end{cases}$$

These represent two conics (hyperbolas if I am right) so that there can be up to four solutions. There is a general method to address the problem of the intersection of two conics: https://en.wikipedia.org/wiki/Conic_section#Intersecting_two_conics. It takes the resolution of a cubic equation.

In this particular case, this cubic can be obtained forthright by eliminating one of the unknowns:

$$axt=bc-bx=a(t^2+ct-b),\\ bx=bc-a(t^2+ct-b),\\ \color{blue}{b=t^2+ct-\frac ab(t^2+ct-b)t}.$$

This is solved by means of Cardano's formulas, or numerically.


I anticipate that for other chemical formulas, the equations will be of two types

  • the product of some concentrations raised to integer powers is constant,

  • the sum of some concentrations is constant.

If this is true, it is possible to eliminate some of the unknowns by solving the indeterminate linear subsystem. Then plugging the expressions in the nonlinear equations, you will end-up looking for the intersection of several algebraic curves of some degree.

In general, this is a difficult problem. In principle, you can reduce it to a single algebraic equation in a single unknown, the degree of which can be huge.