Re: fsolve problems
- From: "John D'Errico" <woodchips@xxxxxxxxxxxxxxxx>
- Date: Mon, 24 Mar 2008 03:07:01 +0000 (UTC)
"Miroslav Balda" <miroslav.nospam@xxxxxxxx> wrote in message
<fs6nsh$hur$1@xxxxxxxxxxxxxxxxxx>...
"Jacob McFarland" <jacob.a.mcfarland@xxxxxxxxx> wrote in
message <fs6egh$98h$1@xxxxxxxxxxxxxxxxxx>...
Hello,
Let me start by saying im a pretty basic user for matlab.
Im no beginer but definately not a professional.
I am trying to solve a nonlinear system of equations for a
combustion problem. I need to know if there is a way to
force fsolve to only look for real roots. It is unable to
find an answer so far but it always moves into complex
numbers. The roots will not be complex or negative if they
actually exist. Can someone tell me if i can limit the
roots it looks for to only real positive numbers?
Also how many itterations should i allow it to use? I am in
the realm of 1e6 for itterations and function evaluations.
This does not take too long on my computer but it doesnt
seem to help it find any better of a solution.
Thanks,
- Jacob
Hi Jacob
I see that nobody, who has the Optimization Toolbox answers.
Remember that this is over a weekend for those
who might respond, a holiday weekend at that.
The reason why your solutions are going complex
is typically due to a problem of domain. For
example, suppose your function has the variable
a. a is unconstrained, but inside the function
you take log(a). Suppose fsolve tries to evaluate
the objective for negative values of a. SURPRISE!
Complex numbers result. They "contaminate" the
arithmetic, and suddenly fsolve is working in the
complex domain.
One solution is to constrain your parameters.
While fsolve will not accept explicit constraints,
you can use a solver like lsqnonlin.
Alternatively, use a transformation of variables.
If you will compute log(a) inside your objective,
then use a transformation of the variable.
b = log(a)
or, more importantly,
a = exp(b)
Whereas a must be non-negative for happy
completion of fsolve, b is unconstrained.
HTH,
John
.
- Follow-Ups:
- Re: fsolve problems
- From: Jacob McFarland
- Re: fsolve problems
- References:
- fsolve problems
- From: Jacob McFarland
- Re: fsolve problems
- From: Miroslav Balda
- fsolve problems
- Prev by Date: Re: Newbie matrix, addressing help..
- Next by Date: Re: function with multiple local minima?
- Previous by thread: Re: fsolve problems
- Next by thread: Re: fsolve problems
- Index(es):
Relevant Pages
|