On 18 October 2012 14:20, Joza <[hidden email]> wrote:
> Using fzero, how does one find the root of a function that is always
> positive, or zero, but never negative? For instance, an absolute value:
> f(x) = abs(x - 2)
Am 18.10.2012 20:20, schrieb Joza:
> But fzero fails if I pass these values as an initial bracket, and passing
> only one of them fails also. Is it impossible to solve such functions using
Same answer as in the other thread: Use fsolve instead of fzero.
Help-octave mailing list
[hidden email] https://mailman.cae.wisc.edu/listinfo/help-octave
Thanks for all the input guys, I've been thinking about it all!!! :-)
As regards the fsolve function, is it possible to specify the x-convergence test for EACH ITERATION? I know can input the absolute convergence error for "TolX", but I would rather test each iteration, which will depend on the value obtained in the previous iteration. Is that possible?
I'm also curious, does it happen often that simple self-made algorithms can provide better answers than Octave's built-in functions?
On 10/18/2012 05:16 PM, Joza wrote:
> As regards the fsolve function, is it possible to specify the x-convergence
> test for EACH ITERATION? I know can input the absolute convergence error for
> "TolX", but I would rather test each iteration, which will depend on the
> value obtained in the previous iteration. Is that possible?
You can very simply modify almost all(*) Octave built-in functions,
because they are often implemented in Octave/Matlab language. If you
'type fzero', you'll see the implementation of the function 'fzero'; you
can edit it to do what you want and redefine fzero() or create my_fzero().
> I'm also curious, does it happen often that simple self-made algorithms can
> provide better answers than Octave's built-in functions?
For a specific case, yes, of course---the Octave built-ins are by design
handling a general case, so if you can figure out a shortcut that works
better for your specific case, it'll beat the built-in.
I don't know whether it 'happens often', but new algorithms do appear
even though a lot of smart people worked for a long time to implement
Octave's built-ins. If you can think of a self-made algorithm that's
better than the current one, please contribute it---that's the beauty of