On Aug 11, 2010, at 9:21 PM, TGS wrote:

How would I numerically find the x value where the derivative of the function below is zero?

x <- seq(1,2, by = .01)
y <- 5*cos(2*x)-2*x*sin(2*x)
plot(x,abs(y), type = "l", ylab = "|y|")

Two ideas:
---minimize abs(diff(y))

abline(v=x[which.min(abs( diff(y) )) ])

---Or maximize the second derivative

plot(x[-(1:2)],diff(diff(y)), type = "l", ylab = "|y|")
abline(v=x[which.max(diff(diff(y)))])



______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

David Winsemius, MD
West Hartford, CT

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to