solving Z + 2 simultaneous nonlinear equations numerically (Newton) with sum

Hello ,
I am trying to solve Z + 2 simultaneous nonlinear System but i have problems with that because of the sum . I do not know how to deal with that in Matlab
I have 3 Equations with 3 Unknowns the equations as follows
The Unknowns are
, and
Thank you very much for any Help

Risposte (1)

You can solve the system of equations using "fsolve". Implement a function that takes the Z+2 dimensional unknowns as input and returns Z+2 dimensional vector with the values of LHS of the Z+2 equations. Then pass this function with an initial guess to "fsolve". The documentation for "fsolve" is as follows.

3 Commenti

Thank you for your answer .
I know the function and i have created also Code to lose with Newton-Raphson
But still my Problem with Sum how to express it in the right way , because the sum here is for the indices
Here is it my code but always error with sum
I have created for loop inside the function to take every Value of Vartheta because it is array with the number of Z = 14
But still the error and the problem with the applying of the sum
fun=@root3d;
xo=[0.0001,0.0001,40*pi/180];
x = fsolve(fun,xo,foptions);
function F = root3d(x)
F_A=500;F_R=1000;alpha_o=40*pi/180;n=3/2;Z=14;
for g=1:Z
Vartheta(g)=(2*pi/Z)*(g-1);
end
for h=1:Z
Geo.Dw=11.86;
K=3.583822434736866;
E=1.019359284554166;
t=0.111984000000000;
dm=59.959999999999994;
Geo.fi=0.520236087689713;
Geo.fo=0.532883642495784;
gamma = (Geo.Dw*cos(x(3)))/dm;
A = (Geo.fi + Geo.fo-1)*Geo.Dw;
F_i = ((1/Geo.fi)+((2*gamma)/(1-gamma)))/(4-(1/Geo.fi)+ ((2*gamma)/(1-gamma)));
F_o = ((1/Geo.fo)-((2*gamma)/(1+gamma)))/(4-(1/Geo.fo)- ((2*gamma)/(1+gamma)));
a_st = ((K-E)/((pi/4)*(1-t^2)*(1-F_i)))^(1/3);
b_st = ((t*E - K*t^3)/((pi/4)*(1-t^2)*(1+F_i)))^(1/3);
Geo.roi = (1/Geo.Dw)*(4-(1/Geo.fi)+ ((2*gamma)/(1-gamma)));
Geo.roo = (1/Geo.Dw)*(4-(1/Geo.fo)- ((2*gamma)/(1+gamma)));
Cdi = 2.79 * 10^(-4)*(2*K/(pi*a_st))*(Geo.Dw*Geo.roi)^(1/3);
Cdo = 2.79 * 10^(-4)*(2*K/(pi*a_st))*(Geo.Dw*Geo.roo)^(1/3);
Cd = Geo.Dw^(1/2)/(Cdi + Cdo)^(3/2);
F(1)=x(1)-x(2)*tan(x(3))*cos(Vartheta(h))-A*sin(x(3)-alpha_o)/cos(x(3));
F(2)=F_A-symsum(Cd*sin(x(3)(h))*(A*((cos(alpha_o)/cos(x(3)(h)))-1)+(x(2)(h)*cos(Vartheta)/cos(x(3)))).^n,h,1,Z);
F(3)=F_R-symsum(Cd*cos(x(3)(h))*cos(Vartheta)*(A*((cos(alpha_o)/cos(x(3)(h)))-1)+(x(2)(h)*cos(Vartheta)/cos(x(3)))).^n,h,1,Z);
end
end
How many equations and variables do you have? Your original post mentions Z+2 but the function only has 3 equations and 3 unknowns.
As per your original post, your function input "x" needs to be Z+2 dimensional. For example, you can represent your unknowns as follows.
x(1) =
x(2) =
x(3:end) = vector
which can be mapped to
F(1:Z) = The first equation (which is collection of Z equations)
F(Z+1) = 2nd eqn, F(Z+2) = 3rd eqn.
For summation, just keep adding values to F(Z+1) and F(Z+2) in the loop, as follows.
% Inside the loop
F(Z+1)=F(Z+1) + <summation term>;
F(Z+2)=F(Z+2) + <summation term>;
You don't need symsum for this.
Thank you for your explaination , And sorry for the Late answer which was because of strong reasons .
My Z in my Case is 14 and every one of the 14 has , and , and from the first equation shows that and are dependent on the angle
that is mean
x(1)=
x(2)= and so on till Z=14
i have not understood well what do you mean with this F(1:Z) = The first equation (which is collection of Z equations)
F(Z+1) = 2nd eqn, F(Z+2) = 3rd eqn. ?
here is it the code that i have created , if you can see and suggest me if it is wrong or better
for g=1:Z
Vartheta(g)=(2*pi/Z)*(g-1);
end
xo=[0.0001,0.0001,40*pi/180];
[x,fval] = fsolve(@(x)root3d(x,F_R_A(v),F_A_A(v),Varth,Vartheta,h,Result,K,E,t,ChRing),xo);
Result(h, :) = abs(x);
function [F] = root3d(x,F_R,F_A,Varth)
alpha_o=40*pi/180;n=3/2;Z=14;
Cd = Geo.Dw^(1/2)/(Cdi + Cdo)^(3/2);
F(1)=x(1)-x(2)*tan(x(3))*cos(Varth(1))-A*sin(x(3)-alpha_o)/cos(x(3));
F(2)=x(4)-x(5)*tan(x(6))*cos(Varth(2))-A*sin(x(6)-alpha_o)/cos(x(6));
F(3)=x(7)-x(8)*tan(x(9))*cos(Varth(3))-A*sin(x(9)-alpha_o)/cos(x(9));
F(4)=x(10)-x(11)*tan(x(12))*cos(Varth(4))-A*sin(x(12)-alpha_o)/cos(x(12));
F(5)=x(13)-x(14)*tan(x(15))*cos(Varth(5))-A*sin(x(15)-alpha_o)/cos(x(15));
F(6)=x(16)-x(17)*tan(x(18))*cos(Varth(6))-A*sin(x(18)-alpha_o)/cos(x(18));
F(7)=x(19)-x(20)*tan(x(21))*cos(Varth(7))-A*sin(x(21)-alpha_o)/cos(x(21));
F(8)=x(22)-x(23)*tan(x(24))*cos(Varth(8))-A*sin(x(24)-alpha_o)/cos(x(24));
F(9)=x(25)-x(26)*tan(x(27))*cos(Varth(9))-A*sin(x(27)-alpha_o)/cos(x(27));
F(10)=x(28)-x(29)*tan(x(30))*cos(Varth(10))-A*sin(x(30)-alpha_o)/cos(x(30));
F(11)=x(31)-x(32)*tan(x(33))*cos(Varth(11))-A*sin(x(33)-alpha_o)/cos(x(33));
F(12)=x(34)-x(35)*tan(x(36))*cos(Varth(12))-A*sin(x(36)-alpha_o)/cos(x(36));
F(13)=x(37)-x(38)*tan(x(39))*cos(Varth(13))-A*sin(x(39)-alpha_o)/cos(x(39));
F(14)=x(40)-x(41)*tan(x(42))*cos(Varth(14))-A*sin(x(42)-alpha_o)/cos(x(42));
F_2sum=0;
F_3sum=0;
F_1sum=0;
for m=1:Z
F_2= Cd*sin(x(m))*(A*((cos(alpha_o)/cos(x(m)))-1)+(x(m)*cos(Vartheta(m))/cos(x(m))))^n;
F_3=Cd*cos(x(m))*cos(Vartheta(m))*(A*((cos(alpha_o)/cos(x(m)))-1)+(x(m)*cos(Vartheta(m))/cos(x(m))))^n;
F_2sum=F_2sum+F_2;
F_3sum=F_3sum+F_3;
end
F(15)=F_A-real(F_2sum);
F(16)=F_R-real(F_3sum);
end
Theoritically the start Value for all , and are the same for all
thank you in advance

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by