Re: [R] Newton-RaphsonMethod

2019-02-24 Thread Daniel Nordlund
On 2/24/2019 5:25 AM, malika yassa via R-help wrote: HELLOplease I want to approximate the solution of the equation f(x)=x*(x-2)+log(x)=0 for that i did this program f <- function(x){x*(x-2)+log(x)} x <- c(1 : 2) f(x) h <- 1e-7 df.dx <- function(x){(f(x + h) - f(x)) / h} df.dx(3/2);df.dx(2)  n

Re: [R] Newton-RaphsonMethod

2019-02-24 Thread Bert Gunter
This list has a no homework policy. Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Sun, Feb 24, 2019 at 9:22 AM malika yassa via R-help < r-help@r-project.org>

[R] Newton-RaphsonMethod

2019-02-24 Thread malika yassa via R-help
HELLOplease I want to approximate the solution of the equation f(x)=x*(x-2)+log(x)=0 for that i did this program f <- function(x){x*(x-2)+log(x)} x <- c(1 : 2) f(x) h <- 1e-7 df.dx <- function(x){(f(x + h) - f(x)) / h} df.dx(3/2);df.dx(2)  newton <- function(f, tol = 1e-7, x0 = 3/2, N = 100){  h