I want to find the five unknown of a system of five nonlinear equations. Thank you !

1 view (last 30 days)
Here the code:
clc;
clear;
close all;
clearvars;
syms ET i1 i2 i3 i4 i5 x1 x2 x3 x4 x5 % constants defined below
syms k1 k2 k3 k4 k7 % unknown variables
ET=1
i1=0.2
i2=0.32
i3=0.43
i4=0.3
i5=0.15
x1=100
x2=200
x3=400
x4=600
x5=800
eq1 = 0==-i1+k7*k3/(k4+k7)*(-(k2+k1*x1-k7*k3/(k4+k7)*ET)+sqrt((k2+k1*x1-k7*k3/(k4+k7)*ET)^2+4*k2*ET*(2*k1*k3/(k4+k7)*x1+k7*k3/(k4+k7))))/(2*k3/(k4+k7)*(k7+2*k1*x1))*(ET-(-(k2+k1*x1-k7*k3/(k4+k7)*ET)+sqrt((k2+k1*x1-k7*k3/(k4+k7)*ET)^2+4*k2*ET*(2*k1*k3/(k4+k7)*x1+k7*k3/(k4+k7))))/(2*k3/(k4+k7)*(k7+2*k1*x1)))/(1+2*k3/(k4+k7)*(-(k2+k1*x1-k7*k3/(k4+k7)*ET)+sqrt((k2+k1*x1-k7*k3/(k4+k7)*ET)^2+4*k2*ET*(2*k1*k3/(k4+k7)*x1+k7*k3/(k4+k7))))/(2*k3/(k4+k7)*(k7+2*k1*x1)));
eq2 = 0==-i2+k7*k3/(k4+k7)*(-(k2+k1*x2-k7*k3/(k4+k7)*ET)+sqrt((k2+k1*x2-k7*k3/(k4+k7)*ET)^2+4*k2*ET*(2*k1*k3/(k4+k7)*x2+k7*k3/(k4+k7))))/(2*k3/(k4+k7)*(k7+2*k1*x2))*(ET-(-(k2+k1*x2-k7*k3/(k4+k7)*ET)+sqrt((k2+k1*x2-k7*k3/(k4+k7)*ET)^2+4*k2*ET*(2*k1*k3/(k4+k7)*x2+k7*k3/(k4+k7))))/(2*k3/(k4+k7)*(k7+2*k1*x2)))/(1+2*k3/(k4+k7)*(-(k2+k1*x2-k7*k3/(k4+k7)*ET)+sqrt((k2+k1*x2-k7*k3/(k4+k7)*ET)^2+4*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+sqrt((k2+k1*x5-k7*k3/(k4+k7)*ET)^2+4*k2*ET*(2*k1*k3/(k4+k7)*x5+k7*k3/(k4+k7))))/(2*k3/(k4+k7)*(k7+2*k1*x5))*(ET-(-(k2+k1*x5-k7*k3/(k4+k7)*ET)+sqrt((k2+k1*x5-k7*k3/(k4+k7)*ET)^2+4*k2*ET*(2*k1*k3/(k4+k7)*x5+k7*k3/(k4+k7))))/(2*k3/(k4+k7)*(k7+2*k1*x5)))/(1+2*k3/(k4+k7)*(-(k2+k1*x5-k7*k3/(k4+k7)*ET)+sqrt((k2+k1*x5-k7*k3/(k4+k7)*ET)^2+4*k2*ET*(2*k1*k3/(k4+k7)*x5+k7*k3/(k4+k7))))/(2*k3/(k4+k7)*(k7+2*k1*x5)));
eq1=subs(eq1); eq2=subs(eq2); eq3=subs(eq3); eq4=subs(eq4); eq5=subs(eq5);
[k1,k2,k3,k4,k7]=fsolve( [eq1, eq2, eq3, eq4, eq5], [k1,k2,k3,k4,k7])

Answers (1)

Torsten
Torsten on 13 Jan 2022
Edited: Torsten on 13 Jan 2022
function main
x0 = rand(5,1);
x = fsolve(@fun,x0)
end
function res = fun(x)
k1 = x(1);
k2 = x(2);
k3 = x(3);
k4 = x(4);
k7 = x(5);
ET=1;
i1=0.2;
i2=0.32;
i3=0.43;
i4=0.3;
i5=0.15;
x1=100;
x2=200;
x3=400;
x4=600;
x5=800;
res(1) = -i1+k7*k3/(k4+k7)*(-(k2+k1*x1-k7*k3/(k4+k7)*ET)+sqrt((k2+k1*x1-k7*k3/(k4+k7)*ET)^2+4*k2*ET*(2*k1*k3 /(k4+k7)*x1+k7*k3/(k4+k7))))/(2*k3/(k4+k7)*(k7+2*k1*x1))*(ET-(-(k2+k1*x1-k7*k3/(k4+k7)*ET)+sqrt((k2+k1*x1-k7*k3/(k4+k7)*ET)^2+4*k2*ET*(2*k1*k3/(k4+k7)*x1+k7*k3/(k4+k7))))/(2*k3/(k4+k7)*(k7+2*k1*x1)))/(1+2*k3/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k7+2*k1*x3)));
res(4) = -i4+k7*k3/(k4+k7)*(-(k2+k1*x4-k7*k3/(k4+k7)*ET)+sqrt((k2+k1*x4-k7*k3/(k4+k7)*ET)^2+4*k2*ET*(2*k1*k3/(k4+k7)*x4+k7*k3/(k4+k7))))/(2*k3/(k4+k7)*(k7+2*k1*x4))*(ET-(-(k2+k1*x4-k7*k3/(k4+k7)*ET)+sqrt((k2+k1*x4-k7*k3/(k4+k7)*ET)^2+4*k2*ET*(2*k1*k3/(k4+k7)*x4+k7*k3/(k4+k7))))/(2*k3/(k4+k7)*(k7+2*k1*x4)))/(1+2*k3/(k4+k7)*(-(k2+k1*x4-k7*k3/(k4+k7)*ET)+sqrt((k2+k1*x4-k7*k3/(k4+k7)*ET)^2+4*k2*ET*(2*k1*k3/(k4+k7)*x4+k7*k3/(k4+k7))))/(2*k3/(k4+k7)*(k7+2*k1*x4)));
res(5) = -i5+k7*k3/(k4+k7)*(-(k2+k1*x5-k7*k3/(k4+k7)*ET)+sqrt((k2+k1*x5-k7*k3/(k4+k7)*ET)^2+4*k2*ET*(2*k1*k3/(k4+k7)*x5+k7*k3/(k4+k7))))/(2*k3/(k4+k7)*(k7+2*k1*x5))*(ET-(-(k2+k1*x5-k7*k3/(k4+k7)*ET)+sqrt((k2+k1*x5-k7*k3/(k4+k7)*ET)^2+4*k2*ET*(2*k1*k3/(k4+k7)*x5+k7*k3/(k4+k7))))/(2*k3/(k4+k7)*(k7+2*k1*x5)))/(1+2*k3/(k4+k7)*(-(k2+k1*x5-k7*k3/(k4+k7)*ET)+sqrt((k2+k1*x5-k7*k3/(k4+k7)*ET)^2+4*k2*ET*(2*k1*k3/(k4+k7)*x5+k7*k3/(k4+k7))))/(2*k3/(k4+k7)*(k7+2*k1*x5)));
end
  10 Comments
Thierry Rebetez
Thierry Rebetez on 15 Jan 2022
Do you want that I give you my email so we could talk more easily and I could send then my study and the way I come to these equations? I think they are correct however. Thank you for replying!
Thierry Rebetez
Thierry Rebetez on 16 Jan 2022
Hi Torsten
I think it is better to continue to chat on this platform if you want :) I think indeed that these equations are correct. The complete equation we have tried to solve is a combination of these three equations here:
h1 = (-(k2+k1.*x-k7.*K1.*ET)+sqrt((k2+k1.*x-k7.*K1.*ET).^2+4.*k2.*ET.*(2.*k1.*K1.*x+k7.*K1)))./(2.*K1.*(k7+2.*k1.*x));
i1=k7.*K1.*h1.*(ET-h1)./(1+2.*K1.*h1);
K1 = k3./(k4+k7);
with all k's positive or null.
I've tried with other values of ET, i1 to i5 and x1 to x5. It gives the following result:
ET =
0.0100
Equation solved, inaccuracy possible.
The vector of function values is near zero, as measured by the default value
of the function tolerance. However, the last step was ineffective.
<stopping criteria details>
x =
4.8110
1.9126
136.9516
-0.0000
43.0017
ET =
0.0100
res =
-0.0058 0.0065 -0.0034 0.0014 -0.0003
It is better but not perfect. What do you think about it?
Another question: the x which are given above (x =4.8110...) must be squared to get the k's, right?
Thank you very much for your help!

Sign in to comment.

Products


Release

R2018a

Community Treasure Hunt

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

Start Hunting!