I want to solve 2 equations with 2 variables but it cant be solved and the command window shows fsolve stopped because the last step was ineffective

3 views (last 30 days)
function main1
p=.153;
x0 = [-3000, -3000];
options = optimoptions('fsolve','display', 'iter');
[sol,fval,exitflag, output] = fsolve(@(x)fun(x,p),x0, options);
if exitflag <= 0
return
end
end
function xres = fun(x,p)
k0 = 2.536;
k1 = 1.354;
k2 = -4.775;
k3 = -2.772;
k4 = -0.235;
gsN = 10.567;
gzN = -0.467;
f_pi = 93.3;
d = 0.064;
X0 = 409.769;
f_k = 122.143;
m_pi = 139;
m_k = 498;
k = (3 * p* pi^2)^(1/3);
gsN = 10.567;
gzN = -0.467;
m1 = -(gsN*x(1) + gzN*x(2));
E = sqrt(k^2 +m1^2);
rho_s = (m1/pi^2)* (k*E- m1^2 * log((k+E)/m1));
F(1) = (k0*x(1)*X0^2)-(4*k1*x(1)*(x(1)^2 + x(2)^2))-(2*k2*x(1)^3)-(2*k3*X0*x(1)*x(2))-(2*d*X0^4/(3*x(1)))+(m_pi^2*f_pi) - (gsN*rho_s);
F(2) = (k0*x(2)*X0^2)-(4*k1*x(2)*(x(1)^2 + x(2)^2))-(2*k2*x(2)^3)-(k3*X0*x(1)^2)-(d*X0^4/(3*x(2)))+((sqrt(2)*m_k^2*f_k)-(f_pi*m_pi^2/sqrt(2))) - (gzN*rho_s);
xres = F;
end
* here i want to solve x(1) and x(2)
command window
No solution found.
fsolve stopped because the last step was ineffective. However, the vector of function
values is not near zero, as measured by the value of the function tolerance.
<stopping criteria details>
fsolve stopped because the sum of squared function values, r, changed by 9.991357e-14
relative to its initial value; this is less than max(options.FunctionTolerance^2,eps) = 1.000000e-12.
However, r = 2.189392e+13, exceeds sqrt(options.FunctionTolerance) = 1.000000e-03.
  2 Comments
Pritha
Pritha on 8 Jul 2021
Thanks for your reply. But it shows problrm in 5th line. It will be helpful for me if you elaborate the process.

Sign in to comment.

Answers (2)

Alex Sha
Alex Sha on 3 Jul 2021
Hi, the result below should be one solution
x1: -52.5485799573576
x2: 12.1032014174617
  1 Comment
Pritha
Pritha on 8 Jul 2021
I have got another set of aswers like,
x1: 18.2653
x2: -98.5331 , for different initial condition.
so how can i conclude that which answer is correct? please help me. also for diffent p value answers are not changing. Can you please give me hint to handle this?

Sign in to comment.


Pritha
Pritha on 8 Jul 2021
I have got another set of aswers like,
x1: 18.2653
x2: -98.5331 , for different initial condition.
so how can i conclude that which answer is correct? please help me. also for diffent p value answers are not changing. Can you please help me out?
  2 Comments
Pritha
Pritha on 8 Jul 2021
Thanks sir for your answer. I understand. But in the matlab command window alongwith the answers,
"Equation solved, solver stalled.
fsolve stopped because the relative size of the current step is less than the
value of the step size tolerance squared and the vector of function values
is near zero as measured by the value of the function tolerance. fsolve stopped because the relative norm of the current step, 8.122955e-17, is less than
max(options.StepTolerance^2,eps) = 2.220446e-16. The sum of squared function values,
r = 5.297954e-16, is less than sqrt(options.FunctionTolerance) = 1.000000e-15." is coming.
so what does it mean?
and also if i change the input p the result should change but it is not happening here. please help sir.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!