Discussion

Using R, provide the solution for any exercise in either Chapter 4 or Chapter 7 of the calculus textbook. If you are unsure of your solution, post your concerns.

Chapter 4 Exercises 4.1

In Exercises 8 - 11, use Newton’s Method to approximate all roots of the given functions accurate to 3 places after the decimal. If an interval is given, find only the roots that lie in that interval. Use technology to obtain good initial approximations.

Using Newton’s method

\(f(x) = 0\)

\(f(x) = x^3 + 5x^2 - x - 1 = 0\)

First derivative of the equation is

\(f'(x) = 3x^2 + 10x - 1\)

Approximation \(X_{n+1} = X_n - \frac{f(X_n)}{f'(X_n)}\)

library(ggplot2)
library(knitr)

xvalues=c()
xresult=c()
x = -2
loop = T
i = 1
while (loop)
{
  eq <- (x^3) + 5*(x)^2 - x - 1
  eqf <- 3*(x^2) + 10*(x) - 1
  result <- x - (eq / eqf)
  xvalues[i] <- x
  xresult[i] <- result
  if (round(x,3) == round(result,3))
  {
    loop = F
  }
  else
  {
    if (x>0)
    {
      x = result
    }
    else
    {
      x <- x + 1
    }
  }
  i<- i+1
}

output <- data.frame(round(xvalues,3), round(xresult,3))
colnames(output)<- c("x","f(x)")

kable(output, align='l', caption = "Output values for x and f(x)")
Output values for x and f(x)
x f(x)
-2.000 -0.556
-1.000 -0.500
0.000 -1.000
1.000 0.667
0.667 0.545
0.545 0.526
0.526 0.525
0.525 0.525

After running eight iterations of Newton’s Method, \(X_8\) is accurate to more than just 3 decimal places.

qplot(xvalues,xresult, geom='smooth', span =0.5) + labs(x="x", y="f(x)", title = "x vs. f(x)")