Problem 4.1.14

Use Newton’s Method to approximate when the given functions are equal, accurate to 3 places after the decimal. Use technology to obtain good initial approximations.

\(f(x) = e^{x^{2}} , g(x) = cox(x)\)

Plot

The graph shows that the lines cross multiple times. For the initial variable I’m going to use X = -1.5 because that’s where the y values are almost equal.

df <- data.frame(
  x_list <- seq(from = -5, to = 5, by = .1),
  f = exp(x_list)^2,
  g = cos(x_list)
)

#Red is e^x^2
#Blue is cos(x)

ggplot(df, aes(x_list)) +
  ylim(-5,5) +
  geom_line(aes(y = f), colour = "red") +
  geom_line(aes(y = g), colour = "blue") +
  ylab("Y") +
  xlab("X")

Calculate root

x <- -1.5
i <- 1


while(i <= 10){
  
  top <- exp(x)^2 - cos(x)
  bottom <- (2*x*exp(x)^2) + sin(x)
  
  func <- x - (top/bottom)
  x <- func
  print(paste0("x", i, " is " ,func))
  i <- i + 1
}
## [1] "x1 is -1.51826744578032"
## [1] "x2 is -1.52220303393655"
## [1] "x3 is -1.52303322716685"
## [1] "x4 is -1.52320754198415"
## [1] "x5 is -1.52324410673332"
## [1] "x6 is -1.52325177507027"
## [1] "x7 is -1.52325338319954"
## [1] "x8 is -1.52325372043775"
## [1] "x9 is -1.5232537911593"
## [1] "x10 is -1.52325380599017"

The approximation for the root is -1.52325