Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

tangent

Tangent lines


Description

Find the tangent line to a polynomial at one or more x-points

Usage

tangent(p, x0)

Arguments

p

A polynomial object

x0

A numeric vector of values at which the tangent line(s) are required

Value

A linear polynomial giving the tangent line, or a list of such polynomials

Examples

p <- poly_from_zeros(c(0, 0:5, 4))
plot(p, xlab = expression(italic(x)), ylab = expression(italic(P(x))),
  main = parse(text = paste("italic(P(x) ==",
                             as.character(p, decreasing = TRUE),")")))
x0 <- solve(deriv(p))        ## stationary points
lines(tangent(p, x0), col = "dark green", lty = "solid",
      limits = cbind(x0-1/4, x0+1/4))
points(x0, p(x0), col = "dark green")

x0 <- solve(deriv(deriv(p))) ## points of inflexion
lines(tangent(p, x0), col = "red", lty = "solid", lwd = 2,
      limits = cbind(x0-1/4, x0+1/4))
points(x0, p(x0), col = "red")
legend("bottomleft", c("Stationary points", "Points of inflexion"),
       pch = 19, col = c("dark green", "red"), lty = "solid",
       cex = 0.7, bg = "beige", box.lwd = 0.25)

PolynomF

Polynomials in R

v2.0-3
GPL-2
Authors
Bill Venables, with contribution by Kurt Hornik and Georgi Boshnakov
Initial release
2020-02-04

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.