Muller
Find a zero crossing of a real or complex function using Muller's method
John D'Errico
Let me expand on my comments. The ability of muller to work in the complex domain is both a blessing and a curse. If your function has complex root, this code will find it nicely, whereas fzero should fail. But if you absolutely need to stay on the real line, then beware, as muller will happily try to test your function away from the real line.
So muller deserves its place as an alternative to fzero. But I'll repeat - always know your problem. Understand your objectives and the abilities of the tools you will use.
Comment only
06 Mar 2008
Muller
Find a zero crossing of a real or complex function using Muller's method
John D'Errico
My thanks for cleaning up this tool. Its now a useful alternative to something like fzero. Note that if no real root exists, this will find a complex one. For example,
x = muller(@(x) x^2+1,[1 2 3])
x =
0 + 1i
This ability to look in the complex plane will be useful to some. Of course, its always important to be careful with any numerical tool. Understand the properties of your tools. For example, this next function clearly has a real root at x == 4. But higher order roots are difficult to resolve, so the default tolerance misses the root by a bit.
x = muller(@(x) (x-4).^3,[1 2 3])
x =
4.0131 + 0.013627i
If we now crank the tolerance down fairly small, we see a better result.
x = muller(@(x) (x-4).^3,[1 2 3],[],eps,eps,'both')
x =
4 - 4.7346e-16i
So a user should always understand how their tools will behave.
Comment only