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.

 채택된 답변

Walter Roberson
Walter Roberson 2011년 6월 20일

1 개 추천

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

Walter Roberson
Walter Roberson 2011년 6월 21일
Thinking again you probably want to output something like the magnitude of the complex result, since fmincon is a minimizer instead of a zero finder.
Liber-T
Liber-T 2011년 6월 21일
I used abs on my function.
But finally there is still a problem with fmincon, since it is much slower than fsolve and still innacurate. It has find the way to give me answer out of bound.
Matt Fig
Matt Fig 2011년 6월 21일
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 2011년 6월 22일
http://www.mathworks.com/matlabcentral/answers/9756-solve-det-and-ode-faster
I've posted everything here.

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

the cyclist
the cyclist 2011년 6월 20일

1 개 추천

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

Liber-T
Liber-T 2011년 6월 20일
This is a really good idea but, I already tried to separate the function with real and imag, but fzero still didn't work as solve.
the cyclist
the cyclist 2011년 6월 20일
Maybe you could post some code? As you can see from my simple example, the method can work in some cases.
Walter Roberson
Walter Roberson 2011년 6월 20일
Liber-T's function is not separable: it involves complex integrals.
Liber-T
Liber-T 2011년 6월 20일
I have post my function at other place, but here I just want to know every possible thing I could use, everything known.
the cyclist
the cyclist 2011년 6월 21일
Walter, I'm curious why the function needs to be separable (assuming you mean analytically so). Since it's all presumably numerical in the end, why wouldn't my method work?
Walter Roberson
Walter Roberson 2011년 6월 21일
The function involves terms that are work differently for complex arguments -- e.g., branch cuts, path of integration becomes important for complex integrals, complex number to a power might end up at a very different angle on the plane than if one considered the real and imaginary parts separately.
Besides, finding an xr at which real(f(xr)) is 0, and an xi at which imag(f(xi)) is 0, is very different than saying f(xr+i*xi) will be 0 + 0i .
the cyclist
the cyclist 2011년 6월 21일
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 2011년 6월 22일
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".)

댓글을 달려면 로그인하십시오.

Matt Fig
Matt Fig 2011년 6월 20일

1 개 추천

If you have an explicit function of one variable, you might have luck with a Newton's method root finder.

카테고리

도움말 센터File Exchange에서 Function Creation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by