[R] what is the purpose of an error message in uniroot?

rolf at math.unb.ca rolf at math.unb.ca
Wed Jan 31 23:05:38 CET 2007

mckellercran at gmail.com wrote:

> This is probably a blindingly obvious question:

        Yes, it is.

> Why does it matter in the uniroot function whether the f() values at
> the end points that you supply are of the same sign?

        Plot some graphs.

        Think about the *name* of the function --- *uni*root.

        Does that ring any bells?

        And how do you know there *is* a root in the interval
        in question?  Try your ``uniroot2'' on f(x) = 1+x^2
        and the interval [-5,5].

        To belabour the point --- if the f() values are of the
        same sign, then there are 0, or 2, or 4, or ....
        roots in the interval in question.

        The ***only chance*** you have of there being a unique
        root is if the f() values are of opposite sign.

        The algorithm used and the precision estimates returned
        presumably depend on the change of sign.  You can get
        answers --- sometimes --- if the change of sign is not
        present, but the results could be seriously misleading.

        Without the opposite sign requirement the user will often
        wind up trying to do something impossible or getting
        results about which he/she is deluded.


                                        Rolf Turner
                                        rolf at math.unb.ca

P. S.  If the f() values are of the same sign, uniroot() DOES
NOT give a warning!  It gives an error.

                                        R. T.

More information about the R-help mailing list