bracket_and_solve_root "rising" option

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

bracket_and_solve_root "rising" option

Boost - Users mailing list
Hi,

I would like a way to bracket the root without having to compute or specify the "rising" flag to "bracket_and_solve_root". Is there a way to edit the bracketing implementation so the user need not specify that option? Thanks,

saurabh
_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: bracket_and_solve_root "rising" option

Boost - Users mailing list


> -----Original Message-----
> From: Boost-users <[hidden email]> On Behalf Of Saurabh T
> via Boost-users
> Sent: 7 November 2019 12:51
> To: [hidden email]
> Cc: Saurabh T <[hidden email]>
> Subject: [Boost-users] bracket_and_solve_root "rising" option
>
> Hi,
>
> I would like a way to bracket the root without having to compute or specify the
> "rising" flag to "bracket_and_solve_root". Is there a way to edit the bracketing
> implementation so the user need not specify that option? Thanks,

You could just assume is_rising ==true and see if it converges by testing if iterations >= max_iterations

Setting max_iterations to a sensible value (<50) will avoid a long wait 😉

If it doesn't converge, try is_rising = false.  Crude and slow?

Or you could compute the bounds yourself and use TOMS748

boost/libs/math/doc/html/math_toolkit/roots_noderiv/TOMS748.html

but that means more work.

Or you could use Brent's algorithm  \math\example\brent_minimise_example.cpp, but you still need to provide bracket values, and choosing -infinity and +infinity will not be fast.
(Again limiting the number of iterations is wise if you fear a long wait).

Fundamentally it is important to provide the algorithm with as much info as possible as a guess, bracket limits, and is rising or falling in order that it works efficiently, or indeed at all.

I suspect you do know more really?

HTH

Paul




_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: bracket_and_solve_root "rising" option

Boost - Users mailing list
In reply to this post by Boost - Users mailing list
On 07/11/2019 12:51, Saurabh T via Boost-users wrote:
> Hi,
>
> I would like a way to bracket the root without having to compute or specify the "rising" flag to "bracket_and_solve_root". Is there a way to edit the bracketing implementation so the user need not specify that option? Thanks,

Not easily, do you really not know whether the function is rising or
falling, and if not how do you know there is a root nearby?

But what I suggest you do is:

Let

f1 = f(guess)

f2 = f(2*guess)

if(f1*f2 < 0) then we have brackets, so call toms748_solve(f, guess,
2*guess...).

if(f1 >0 && f1>f2) then function is falling and guess*2 is better than
guess.  try bracket_and_solve_root with 4*guess as the start point.

if(f1 >0 && f1 < f2) then function is falling and "guess" is better, try
bracket_and_solve_root with guess/2 as the start point.

if(f1 < 0 && f1>f2) then the function is falling and "guess" is better,
try bracket_and_solve_root at guess/2.

otherwise f1 < 0 and f1<f2, then the function is rising and guess*2 is
better, try bracket_and_solve_root at guess*4.

~~~~~~~~~~~~~~~~~~~~~~~

Important: bracket_and_solve_root is a useful shortcut, but it
absolutely will not work if the function is not uniformly rising or
falling.  If the function is oscillatory, or has minima or other problem
issues, then you will need to bracket the root by some other means and
call toms748_solveyourself.

HTH, John.

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: bracket_and_solve_root "rising" option

Boost - Users mailing list
In reply to this post by Boost - Users mailing list

> Or you could use Brent's algorithm
No!! That's not a root finding algorithm, it's function minimization. 
See
https://www.boost.org/doc/libs/1_71_0/libs/math/doc/html/math_toolkit/roots_noderiv/brent.html

> \math\example\brent_minimise_example.cpp, but you still need to provide bracket values, and choosing -infinity and +infinity will not be fast.
> (Again limiting the number of iterations is wise if you fear a long wait).
>
> Fundamentally it is important to provide the algorithm with as much info as possible as a guess, bracket limits, and is rising or falling in order that it works efficiently, or indeed at all.
>
> I suspect you do know more really?
>
> HTH
>
> Paul
>
>
>
>
> _______________________________________________
> Boost-users mailing list
> [hidden email]
> https://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users