Newton Raphson method in Rstudio

I want to solve the following equation for θ by using Newton Raphson method in Rstudio


can someone help me for that.

Newton Raphson is a numerical method for solving real valued functions.
I'm not seeing a real valued function here.

Here is a Newton-Raphson example. It is not generalized: you need to choose the plot limits and initial value, and you need to calculate the derivative.

Newton-Raphson: x_(n+1) = x_n - f(x_n) / f ' (x_n)

f(x) = x^3 - x - 1

f ' (x) = 3*x^2 - 1

quick plot to choose initial value

x<- seq(from=-5, to=5, .001)
y <- x^3 - x - 1

x <- vector()
f <- vector()

x_new <- 1.5
for (n in 1:10){
x[n] <- x_new
f[n] <- (x[n])^3 - x[n] - 1
fprime <- 3 * (x[n])^2 - 1
x_new <- x[n] - f[n]/fprime
if ( (abs(x[n] - x_new)/x[n]) < .00005 ){break}

df <- data.frame(cbind(x,f))

paste0("Solution is ", round(x[n],6))

Thank you for your help.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.