Fsolve giving incorrect answers
Mostra commenti meno recenti
Hello
I'm trying to solve this system:
x = a + e(c - e*x/((x^2+y^2)^(3/2))), y = b + c(d - e*y/((x^2+y^2)^(3/2)))
I'm using Fsolve, but not matter what i put in as the startpoints for the iteration i get the answer as the startpoints.
close all, clear all, clc
a = 1;
b = 2;
c = 3;
d = 4;
e = 5;
fsolve(@u1FsolveFUNC,[1,2])
Function:
function outvar = u1FsolveFUNC(invar)
global a b c d e
outvar = [-invar(1) + a + e*(c - e*(invar(1) / ((invar(1)^2 + invar(2)^2)^(3/2)))) ; -invar(2) + b + e*(d - e*(invar(2) / ((invar(1)^2 + invar(2)^2)^(3/2))))]
end
I could try with [1,2] as invariables, and it will say that that is a root to the equation, alltough the correct answer for [1,2] is [12.76,15.52]
Ideas?
2 Commenti
SdiM
il 10 Giu 2013
Roger Stafford
il 11 Giu 2013
I would like to point out that if the equations you have shown being entered into 'fsolve' are what you intended, then 'fsolve' is not actually needed. Those equations can be solved using 'roots'.
If r is any positive real root of
r^6-((a+e*c)^2+(b+e*d)^2)*r^4+2*e^2*r^3+e^4 = 0
then
x = (a+e*c)/(1+e^2/r^3)
y = (b+e*d)/(1+e^2/r^3)
are solutions and r = sqrt(x^2+y^2). For the values of a,b,c,d,e you have given, there are two solutions:
(15.98007976343752,21.97260967472658)
and
(0.57425274904229,0.78959752993316)
However there is a disparity between these equations and those you originally stated. The two respective sets are:
x = a+e*(c-e*x/(x^2+y^2)^(3/2)), y = b+c*(d-e*y/(x^2+y^2)^(3/2))
x = a+e*(c-e*x/(x^2+y^2)^(3/2)), y = b+e*(d-e*y/(x^2+y^2)^(3/2))
differing by one parameter: c versus e. It isn't clear which one you intended to use and which was a typographical error.
Risposte (0)
Categorie
Scopri di più su Matrix Decomposition in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!