Chapter 4.1, #5

library(mosaic)
library(mosaicCalc)
D(x^2 + x - 2~x, x = 0)
## function (x = 0) 
## 2 * x + 1
f1 <- function(x)
{x^2 + x - 2}

f2 <- function(x)
  {2*x+1}
x0 <- 0
x1 <- x0-f1(x0)/f2(x0)
x2 <- x1-f1(x1)/f2(x1)
x3 <- x2-f1(x2)/f2(x2)
x4 <- x3-f1(x3)/f2(x3)
x5 <- x4-f1(x4)/f2(x4)
x0
## [1] 0
x1
## [1] 2
x2
## [1] 1.2
x3
## [1] 1.011765
x4
## [1] 1.000046
x5
## [1] 1