[R] How to find a uniroot of a deriv function

Patrick Wang pwang at berkeley.edu
Sat Apr 14 04:03:43 CEST 2007

Hi, All

Assume I have function x^2-1, I tried to find the root of its derivative
2*x = 0.

I run the command below but it return 1, root of the original function.
Does anyone know how to get the root of the derived function?

func = deriv(parse(text="x^2-1"), "x", func=TRUE)
uniroot(func, interval=(-0.1,1.1), tol=1e-6)
[1] 1

[1] -1.709702e-07
[1,] 2

More information about the R-help mailing list