Matlab function

2 visualizzazioni (ultimi 30 giorni)
Liber-T
Liber-T il 20 Giu 2011
I need to solve a problem, here are my need:
-To find the zeros of a function
-The function is complex
-The zeros are complex
-The function is nonlinear
-I know the approximate place of the zero I'm searching
-I need to bound the search of the zero.
The function I've tried and does not work:
-fsolve (I can't bound the search and sometimes doesn't give me what I want)
-fzero(doesn't work at all)
-solve(doesn't work at all)
Just write the function I could use to find zeros please.

Risposta accettata

Walter Roberson
Walter Roberson il 20 Giu 2011
Supply it with a vector of length 2, and internally construct x = xin(1) + 1i*xin(2), and calculate the complex result. Output the vector of length 2 which is real() and imag() of that result. The constraints you would supply would be the bounds on the real and imaginary parts (expressed as real numbers.)
  4 Commenti
Matt Fig
Matt Fig il 21 Giu 2011
I see your post of the function in another question, but you haven't told us many of the variables in that function. Why not post the COMPLETE function, with all variables defined, so that we can copy and paste it into MATLAB and it will work? For example, your function has a variable 'y' and a variable 'ne0' in it, which you have not defined. Is e equal to the exp(1)?
Liber-T
Liber-T il 22 Giu 2011
http://www.mathworks.com/matlabcentral/answers/9756-solve-det-and-ode-faster
I've posted everything here.

Accedi per commentare.

Più risposte (2)

the cyclist
the cyclist il 20 Giu 2011
For a complex zero, both the real and imaginary parts must be zero, and you can take advantage of this.
I believe you can use fzero() to do this, by separately solving for the real and imaginary zeros. For example, suppose your function is f(x) = x - i. Then,
fr = @(x) real(x - i)
fi = @(x) imag(x - i)
x0r = fzero(fr,3)
x0i = fzero(fi,3i)
You don't specify the bounds, but you do have the initial guess to get close to the zero. (Here, I just arbitrarily set my initial guess to "3" for both the real and imaginary parts.)
I hope this helps.
  8 Commenti
the cyclist
the cyclist il 21 Giu 2011
Your last statement is true, but it is not what I meant to propose. I did not mean:
real(f(xr))=0 and imag(f(xi))=0,
but rather
real(f(x)) = 0 and imag(f(x))=0.
Note the different arguments. These two statement, taken together, are equivalent to your f(xr+i*xi)=0+0i.
However, I think you are absolutely correct that my proposed solution will not work with the function as you describe it. But will any MATLAB function really handle all the branch cuts, etc, well?
Walter Roberson
Walter Roberson il 22 Giu 2011
I do not know how well MATLAB functions handle branch cuts.
Your sample algorithm solves for real(f(xr))=0 and imag(f(xi))=0. If there are multiple zeros on either the real or imaginary axis (as is likely) then finding the place the zeros coincide would require looping with careful manipulation of the intervals... and some work to generate new intervals as the signs of the function must be different at the two interval endpoints for fzero (it isn't as easy as saying "search 0 to 1; now search 1 to 2".)

Accedi per commentare.


Matt Fig
Matt Fig il 20 Giu 2011
If you have an explicit function of one variable, you might have luck with a Newton's method root finder.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by