How to improve accuracy in fsolve?
Mostrar comentarios más antiguos
Hello to everyone,
I am unfamiliar with MATLAB software and I am trying to solve some nonlinear equations. The problem that I have is that the results are not accurate enough. I don't have any initial guess, but I know that the results must be between 0 and pi/2 rads. Any idees?
f=@(a) [(4/pi)*(1-2*cos(a(1))+2*cos(a(2))-2*cos(a(3))+2*cos(a(4)))-0.5;
(4/(5*pi))*(1-2*cos(5*a(1))+2*cos(5*a(2))-2*cos(5*a(3))+2*cos(5*a(4)));
(4/(7*pi))*(1-2*cos(7*a(1))+2*cos(7*a(2))-2*cos(7*a(3))+2*cos(7*a(4)));
(4/(17*pi))*(1-2*cos(17*a(1))+2*cos(17*a(2))-2*cos(17*a(3))+2*cos(17*a(4)))];
[r]=fsolve(f,[1 1 1 1])
(4/pi)*(1-2*cos(r(1))+2*cos(r(2))-2*cos(r(3))+2*cos(r(4)))-0.5
(4/(5*pi))*(1-2*cos(5*r(1))+2*cos(5*r(2))-2*cos(5*r(3))+2*cos(5*r(4)))
(4/(7*pi))*(1-2*cos(7*r(1))+2*cos(7*r(2))-2*cos(7*r(3))+2*cos(7*r(4)))
(4/(17*pi))*(1-2*cos(17*r(1))+2*cos(17*r(2))-2*cos(17*r(3))+2*cos(17*r(4)))
1 comentario
Walter Roberson
el 4 de Abr. de 2020
The equations in f cannot distinguish between a(1) and a(3), or between a(2) and a(4) .
Respuesta aceptada
Más respuestas (1)
Alex Sha
el 4 de Abr. de 2020
There are multi-solutions with high enough accurancy, even given the range limition in [0, pi/2]:
1:
a1: 0.996298496311242
a2: 0.956610794085768
a3: 1.12078428609661
a4: 1.47219048531321
feval:
-1.58206781009085E-14
1.27222187258541E-15
-4.64461953483561E-15
-1.99564215307515E-16
2:
a1: 0.423201820072776
a2: 1.45258039750964
a3: 1.15702893242895
a4: 0.468494500989183
feval:
2.22044604925031E-15
-4.63654193564459E-15
7.59294323955735E-15
7.45663375320891E-15
3:
a1: 1.15702893242895
a2: 0.468494500989183
a3: 0.423201820072776
a4: 1.45258039750964
feval:
2.22044604925031E-15
-4.69308512998172E-15
7.59294323955735E-15
7.46702772275618E-15
4 comentarios
Walter Roberson
el 4 de Abr. de 2020
Also
A1 = .78451894548220254322e-1
A2 = .93410371642501077229
A3 = 1.5575352805569076563
A4 = 1.4585657816429797632
dimocritos
el 4 de Abr. de 2020
Walter Roberson
el 4 de Abr. de 2020
Alex used a commercial package to find the roots. I do not know what algorithm it is using, but it does find good solutions quickly.
For this list of A1, A2, A3, A4 values, I used the approach I described above in https://www.mathworks.com/matlabcentral/answers/515215-how-to-improve-accuracy-in-fsolve#comment_820992 to find EQ4 in two variables, and then I found a numeric solution for A3 and A4, and then back substituted to find A1 and A2 and then cross-checked. I did the work in Maplesoft's Maple software, but I think you might be able to do the same thing in MATLAB (not sure; MATLAB gives up on roots of symbolic nonlinear equations relatively easily.)
dimocritos
el 5 de Abr. de 2020
Categorías
Más información sobre Choose a Solver en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!