Solving 4 nonlinear equation for 4 unknowns numerical - doesn't find an answer [0×1 sym]
1 次查看(过去 30 天)
显示 更早的评论
Hello,
I am attempting to solve a system of nonlinear equations, but unfortunately, vpasolve couldn't find any solutions.
Here is my code:
% ------------ Parameters --------------------
a = 0.9;
beta_10 = 3.5668;
k0 = 4.9907;
K2 = 480;
% ------------ Required Functions --------------------
syms g(x) h1(y) h2(y) v(x)
g(x) = 1.177.*sin((pi.*x)./a).^2;
h1(y) = 1-275.*(y-1).^2;
h2(y) = -14.*(y-1);
h(y) = h1(y) + 1i*h2(y);
v(x) = 1.517+1.833.*x.^2;
% ------------ Equation Functions --------------------
syms x1 x2 y1 y2
Fn1 = ((cos((beta_10/k0)*y1*v(x1))-cos(y1*v(x1)))/sin(y1*v(x1)))*(sin(pi*x1)/a);
Fn2 = ((cos((beta_10/k0)*y2*v(x2))-cos(y2*v(x2)))/sin(y2*v(x2)))*(sin(pi*x2)/a);
Ya1_G0 = (K2*Fn1^2) / (((K2*Fn1^2)/(g(x1)*h(y1)))+(3.0691-13.7872i));
Ya2_G0 = (K2*Fn2^2) / (((K2*Fn2^2)/(g(x2)*h(y2)))+(-1.9145-11.3728i));
% ------------ Equations --------------------
E1 = imag((K2*Fn1^2)/(g(x1)*h(y1))) == 13.7872;
E2 = imag((K2*Fn2^2)/(g(x2)*h(y2))) == 11.3728;
E3 = Ya2_G0/Fn2 == -2 * (Ya1_G0/Fn1);
E4 = Ya1_G0 + Ya2_G0 == 0.5;
E = [E1,E2,E3,E4];
S = vpasolve(E,[x1,x2,y1,y2],[-a/4 a/4;-a/4 a/4;0.98 1.02;0.98 1.02])
Before asking, YES, there are solutions. The desired answers are (x1 = 0.086, y1 = 1.0125) and (x2 = -0.176, y2 = 1.0099), or anything close to that, like (x1 = 0.085, y1 = 1.0126) and (x2 = -0.175, y2 = 1.0097).
How can I find a solution? I appreciate your assistance in advance.
0 个评论
采纳的回答
Sam Chak
2023-11-29
Hi @Faraz j
Fixing the vpasolve() syntax does return some complex-valued solutions, with their real parts close to the values of your user-supplied solutions: (, ) and (, ). Also, check if E1 = 13.7872 and E2 = 11.3728 are rounded to 6 digits of precision. If you use the true values, perhaps you can obtain the real-valued solutions.
% ------------ Parameters --------------------
a = 0.9;
beta_10 = 3.5668;
k0 = 4.9907;
K2 = 480;
% ------------ Required Functions --------------------
syms g(x) h1(y) h2(y) v(x)
g(x) = 1.177.*sin((pi.*x)./a).^2;
h1(y) = 1-275.*(y-1).^2;
h2(y) = -14.*(y-1);
h(y) = h1(y) + 1i*h2(y);
v(x) = 1.517+1.833.*x.^2;
% ------------ Equation Functions --------------------
syms x1 x2 y1 y2
Fn1 = ((cos((beta_10/k0)*y1*v(x1))-cos(y1*v(x1)))/sin(y1*v(x1)))*(sin(pi*x1)/a);
Fn2 = ((cos((beta_10/k0)*y2*v(x2))-cos(y2*v(x2)))/sin(y2*v(x2)))*(sin(pi*x2)/a);
Ya1_G0 = (K2*Fn1^2) / (((K2*Fn1^2)/(g(x1)*h(y1)))+(3.0691-13.7872i));
Ya2_G0 = (K2*Fn2^2) / (((K2*Fn2^2)/(g(x2)*h(y2)))+(-1.9145-11.3728i));
% ------------ Equations --------------------
E1 = imag((K2*Fn1^2)/(g(x1)*h(y1))) == 13.7872;
E2 = imag((K2*Fn2^2)/(g(x2)*h(y2))) == 11.3728;
E3 = Ya2_G0/Fn2 == - 2*(Ya1_G0/Fn1);
E4 = Ya1_G0 + Ya2_G0 == 0.5;
E = [E1,E2,E3,E4];
S = vpasolve(E, [x1,x2,y1,y2], [a/4 -a/4 0.98 1.02])
3 个评论
更多回答(1 个)
Torsten
2023-11-29
Try
S = vpasolve(E,[x1,x2,y1,y2],[0.086 -0.176 1.0125 1.0099])
But the solution is complex-valued since your function h is complex-valued.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!