System of Nonlinear Equations exceeds function evaluation limit
이전 댓글 표시
Attempting to solve a system of three nonlinear equaitons
g = 9.81;
Az_mech = 0.028*g;
Az_dyn = 0.5*g;
Ax_mech = 0.092*g;
Ax_dyn = 2*g;
m=4;
mu = 0.2;
f = @(x) [70*(-m*g+m*(Az_mech+Az_dyn))+55*m*(Ax_mech+Ax_dyn)+140*(x(2)*cos(x(3))+mu*x(2)*sin(x(3)));
-mu*x(1)*cos(x(3))+x(1)*sin(x(3))+m*(Ax_mech+Ax_dyn)-x(2)*sin(x(3))+mu*x(2)*cos(x(3));
x(1)*cos(x(3))+mu*x(1)*sin(x(3))+x(2)*cos(x(3))+mu*x(2)*sin(x(3))+m*(Az_mech+Az_dyn)-m*g];
options = optimoptions(@fsolve, 'MaxFunctionEvaluations', 10000, 'MaxIterations', 10000);
x1 = fsolve(f, [10 10 0])
f(x1)
x2 = fsolve(f, [5 5 0])
f(x2)
x3 = fsolve(f, [0 0 0])
f(x3)
The outputs are:
Solver stopped prematurely.
fsolve stopped because it exceeded the function evaluation limit,
options.MaxFunctionEvaluations = 300 (the default value).
x1 =
9.9967 19.7237 -3.0559
ans =
420.0052
80.9845
-48.6414
Solver stopped prematurely.
fsolve stopped because it exceeded the function evaluation limit,
options.MaxFunctionEvaluations = 300 (the default value).
x2 =
4.9978 17.7964 -2.8936
ans =
680.8757
82.7503
-41.7372
Solver stopped prematurely.
fsolve stopped because it exceeded the function evaluation limit,
options.MaxFunctionEvaluations = 300 (the default value).
x3 =
0.0024 -17.9956 0.3792
ans =
691.5529
85.4092
-36.5683
I try a few different starting points and each gives different solutions. When I try to input the solution into the original function, the result is not zero, as I would expect for a correct solution.
There is no noticable different in runtime, even if i increase the max iterations and evaluations to 1000000 from 300.
채택된 답변
추가 답변 (1개)
Substitute
a = x(2)*cos(x(3)), b = x(2)*sin(x(3)), c= x(1)*cos(x(3)), d=x(1)*sin(x(3))
in your equations.
You get an underdetermined linear system of equations.
The general solution is
v = lambda*n + sol
with a parameter lambda, n the nullspace of the system matrix and sol a special solution.
Incorporating the condition b/a = d/c gives
lambda = vpasolve(v(2)/v(1)-v(4)/v(3)==0);
Now
x3 = atan(v(2)/v(1))
x2 = v(1)/cos(x3)
x1 = v(3)/cos(x3)
follow.
The calculation of x3 gives you degrees of freedom for the solution because x3 + n*pi will also satisfy the equation. But it turns out that - although there are infinitely many solutions - none of them satisfies that x1, x2 and x3 are simultaneously positive.
Code is as follows:
g = 9.81;
Az_mech = 0.028*g;
Az_dyn = 0.5*g;
Ax_mech = 0.092*g;
Ax_dyn = 2*g;
m=4;
mu = 0.2;
M = [140 140*mu 0 0; mu -1 -mu 1; 1 mu 1 mu];
n = null(M)
rhs = [-55*m*(Ax_mech+Ax_dyn)-70*(-m*g+m*(Az_mech+Az_dyn));-m*(Ax_mech+Ax_dyn);-m*(Az_mech+Az_dyn)+m*g];
sol = M\rhs;
syms lambda
v = lambda*n + sol;
s = vpasolve(v(2)/v(1)-v(4)/v(3)==0);
v = double(subs(v,lambda,s));
x3 = atan(v(2)/v(1))
x3s = atan(v(4)/v(3))
x1 = v(4)/sin(x3)
x1s = v(3)/cos(x3)
x2 = v(1)/cos(x3)
x2s = v(2)/sin(x3)
카테고리
도움말 센터 및 File Exchange에서 Systems of Nonlinear Equations에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!