I need to solve the following system of equations for $x_1,x_2,x_3,x_4,x_5,x_6$ $$x_1= 0.64\times x_2 + 0.64\times x_3$$ $$x_5\times (x_2)^2= 0.392 - 1.25\times x_4 \times (x_1)^2$$ $$x_5\times(x_2)^2= 0.588 - 2.5\times x_6\times (x_3)^2$$ $$1/\sqrt x_4= -2\times log_{10}\left (\frac {3.15E-5}{x_1\times \sqrt x_4} \right)$$ $$1/\sqrt x_5= -2\times log_{10}\left (\frac {2.52E-5}{x_2\times \sqrt x_5}\right)$$ $$1/\sqrt x_6= -2\times log_{10}\left (\frac {3.15E-5}{x_3\times\sqrt x_6}\right)$$

I know Matlab has some commands like fsolve but I'm not sure if it applies in this case, and if it doesn't I want to know which numerical method works best to solve the system numerically

note: $x_1,x_2,x_3,x_4,x_5,x_6$ are float numbers and i'm interested in the solutions in which at least $x_4,x_5,x_6$ are positive real numbers (and $x_1,x_2,x_3$ are real)


  • $\begingroup$ Are these all float numbers? $\endgroup$ – Dr. Sonnhard Graubner May 8 '19 at 14:30
  • $\begingroup$ Are you interested in all solutions? $\endgroup$ – Dr. Sonnhard Graubner May 8 '19 at 14:30
  • $\begingroup$ Yes! these variables are float. x1,x2,x3 stand for velocity and x4,x5,x6 are friction factors $\endgroup$ – Violeta Ayon May 8 '19 at 14:30
  • $\begingroup$ And my second question? $\endgroup$ – Dr. Sonnhard Graubner May 8 '19 at 14:31
  • 1
    $\begingroup$ Wow, my program has found the solutions, where should i post them? $\endgroup$ – Dr. Sonnhard Graubner May 8 '19 at 15:08

You can clarify the system by a change of variable $y_k=x_k^2x_{k+3}$ for $k=1,2,3$ and $y_k=1/\sqrt{x_k}$ for $k=4,5,6$.

$$\begin{cases}y_4\sqrt{y_1}&= 0.64 y_5\sqrt{y_2} + 0.64 y_6\sqrt{y_3}, \\y_2&= 0.392 - 1.25y_1, \\y_2&= 0.588 - 2.5y_3, \\y_4&= a+\log_{10}y_1, \\y_5&= b+\log_{10}y_2, \\y_6&= c+\log_{10}y_3. \end{cases}$$

Then if you express all unknowns in terms of $y_2$, you get a single equation in a single unknown

$$\left(a+\log_{10}\frac{0.392-y_2}{1.25}\right)\sqrt{\frac{0.392-y_2}{1.25}}= \\ 0.64\left(b+\log_{10}y_2\right)\sqrt{y_2} + 0.64\left(c+\log_{10}\frac{0.588-y_2}{2.5}\right)\sqrt{\frac{0.588-y_2}{2.5}}.$$

Plot the function to check the number of solutions, then use a 1D solver. From $y_2$ you draw all $y$, then all $x$ in a straightforward way.


  • $\begingroup$ What is nice with your solution is that, starting at $y_2=0.196$, your function is almost a straight line and Newton method converges very fast to the solution. $\endgroup$ – Claude Leibovici May 9 '19 at 7:46
  • $\begingroup$ This really helped me out, thank you for your time! $\endgroup$ – Violeta Ayon May 10 '19 at 1:48
  • $\begingroup$ If we compute the values of the function at $y_2=0$ and $y_2=0.392$ and draw a straight line, the intercept is at $y_2=0.12$ !!! $\endgroup$ – Claude Leibovici May 10 '19 at 4:11

This system of equations can easily be reduced to two equations for two unknowns $x_2$ and $x_3$.

Fist, let $x_i=\frac 1 {y_i^2}$ for $i=4,5,6$ and $k_4=k_6=3.15 \times 10^{-5}$, $k_5=2.52 \times 10^{-5}$.

Using the last three equations, we then have $$y_4=\frac{2 W\left(\frac{x_1 \log (10)}{2 k_4}\right)}{\log (10)}\qquad y_5=\frac{2 W\left(\frac{x_2 \log (10)}{2 k_5}\right)}{\log (10)}\qquad y_6=\frac{2 W\left(\frac{x_3 \log (10)}{2 k_6}\right)}{\log (10)}$$ where appears Lambert functions. The first equation gives $x_1=0.64(x_2+x_3)$.

All of the above makes that remain the second and third equations which, using your numbers and whole numbers everywhere, write $$\frac{125 x_2^2}{W\left(\frac{1250000\log (10)}{63} x_2\right)^2}+\frac{64 (x_2+x_3)^2}{W\left(\frac{640000 \log (10)}{63} (x_2+x_3)\right)^2}=\frac{196}{\log ^2(10)}$$ $$ \frac{2 x_2^2}{W\left(\frac{1250000\log (10)}{63} x_2 \right)^2}+\frac{5 x_3^2}{W\left(\frac{1000000\log (10)}{63} x_3\right)^2}=\frac{588}{125 \log ^2(10)} $$ which do not seem to be possibly simplified.

Using Newton-Raphson method (initial guesses $x_2^{(0)}=x_3^{(0)}=1$), the calculations converge without any trouble to the solutions $$x_2=2.6346572 \qquad \text{and} \qquad x_3=3.6519568$$ from which $$x_1=4.0234330\qquad x_4=0.0142830\qquad x_5=0.0148360\qquad x_6=0.0145467$$

  • $\begingroup$ Our solutions seem to match ($x_2^2x_5\approx 0.10$). $\endgroup$ – Yves Daoust May 9 '19 at 6:44
  • 1
    $\begingroup$ @YvesDaoust. I was not able to reduce to a single variable ! It is good that you made it. I think that my initial mistake was to focus on Lambert. $\to +1$ for sure. $\endgroup$ – Claude Leibovici May 9 '19 at 6:52
  • 1
    $\begingroup$ I know that Lambert is your good friend. By an old superstition, I would prefer not to use it inside an equation, as the solver will "emulate it" anyway. I was successful by observing the symmetries in the equations, and being obsessed to simplify ;-) $\endgroup$ – Yves Daoust May 9 '19 at 7:02
  • $\begingroup$ Thanks so much for the help! I'm going ahead and solve those equations numerically. Also, the values you got by Newton-Raphson make sense physically for the problem I'm solving. $\endgroup$ – Violeta Ayon May 10 '19 at 2:56

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.