Re: fsolve - nonlinear equations
- From: Vivas <gusvivas@xxxxxxxxxx>
- Date: Tue, 14 Mar 2006 15:27:17 -0500
Thank you for responding.
Actually, x(2) ranges from 0 to 1 (depending on the variable 'A'. For
that 'A' I have mentioned, x(2) = 1). And x(1) can be any other real
number (Most of cases more than x(2), but not ever).
Making a summary, both numbers depends on the 'A'.
So, what do you suggest for x0 and options-optimset (or even for the
used fuction)?
Marcelo Marazzi wrote:
.
Try tightening the stopping tolerances
TolX and TolF, but if the sum of squares
has more than one minimizer, in general,
fsolve will converge to a minimizer (a stationary
point, strictly speaking) in a vicinity of x0.
A common approach in this case is to run the
solver from multiple starting points.
As to the constraints you mention in your ps,
it looks like they can be represented as
inequalities:
1-tol <= x(2) <= 1+tol (1)
x(1) >= x(2) (2)
You can try solving your problem as a nonlinear
least squares problem via lsqnonlin. This function
takes bounds on the variables to enforce (1).
If you need to enforce (2) explicitly, you may
want to consider using fmincon, where you can
also enforce (2) via linear constraints. The sum
of squares would be the objective.
-marcelo
Vivas wrote:
Hi,unity
I am trying to solve a system of nonlinear equations using
fsolve but I couldn't do it, I mean, the results seems to be
incorrect for me and/or dependent of 'x0'.
Somebody could help me? My program is copied below.
Thank you,
Vivas
ps: Using 'A' as described below, we hope to find x(2) near to
and x(1) more than x(2).(gamma(x(1))
======================================
% PART OF MY PROGRAM
sigma = 1;
A = raylrnd(sigma,256,256);
A = sort(A(:));
x0 = [-1; -1]; %??? WHAT SHOULD I GUESS HERE ???
options = optimset('Display','iter');
[x,fval] = fsolve(@myfun,x0,options,A);
--------------------------------------
% MYFUN FUNCTION
function F = myfun(x,A)
F = [ mean(A) - (((gamma(x(1)+0.5) * gamma(x(2)+0.5)) /
* gamma(x(2)))) * (2/(sqrt((4*x(1)*x(2))/mean(A.^2)))));
mean(sqrt(A)) - ((gamma(x(1)+0.25) * gamma(x(2)+0.25)) /
(gamma(x(1)) * gamma(x((2)))) *
sqrt(2/(sqrt((4*x(1)*x(2))/mean(A.^2))))) ];
return
=======================================
- References:
- fsolve - nonlinear equations
- From: Vivas
- Re: fsolve - nonlinear equations
- From: Marcelo Marazzi
- fsolve - nonlinear equations
- Prev by Date: Resolve 3 equation non linear
- Next by Date: Re: robust multivariate linear regression?
- Previous by thread: Re: fsolve - nonlinear equations
- Next by thread: needing your help,I have no way to solve this question,thank you so much!
- Index(es):
Relevant Pages
|