Re: fsolve - nonlinear equations



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,

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
unity
and x(1) more than x(2).

======================================
% 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(1))
* 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
=======================================

.



Relevant Pages

  • Re: Fitting a rational function for a set of data in two column
    ... >I need to analyse the data, and fit a rational function. ... where I deliberately have normalized the denominator to have no zero at x=0. ... you can transform this into a linear least squares problem by ...
    (sci.math.num-analysis)
  • Re: solving two of nonlinear equations and two unknwons.
    ... I have a problem about solving two of nonlinear equations. ... I cannot have anallytic Jacobian. ... Solves a nonlinear least squares problem subject to bounds on the ... you are using codes which try to approximate derivatives (Jacobians) ...
    (sci.math.num-analysis)
  • Re: Minimizing the Frobenius norm
    ... the frobenius norm squared is the sum of the squares of the elements of the ... hence you have here a typical "least squares" problem. ... should each of the elements of these matrices be an affine linear ... Otherwise you have a nonlinear least squares problem and need a corresponding ...
    (sci.math.num-analysis)
  • Re: Vandermonde Solution for Least Squares
    ... is it possible to find a least squares parabolic fit for a redundant ... this is a linear least squares problem: ... and in some programming language using one of the many linear least squares ...
    (sci.math.num-analysis)
  • Least squares
    ... To solve a least squares problem, ... this means that the magnitude of the residue is ...
    (sci.math)