Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

All published worksheets from http://sagenb.org

Views: 168746
Image: ubuntu2004
#f(x)= (x^2)-ln(1+x)# #fp(x)=derivative(f(x))# #phi1(x)=x-(f(x)/fp(x))#
#méthode de newton def f(x): return ((x**2)-ln(1+x)) def fp(x): return (2*x-1/(x+1)) def phi1(x): #relation de récurence return(x-(f(x)/fp(x))) def newton1(x_start,eps): # eps :epsilon x=x_start x_old=x+10*eps while(abs(x-x_old)>eps): x_old=x x=phi1(x) return(x)
plot(f(x),(x,0,1))
newton1((0.1),(1.e-7))
-5.38956478861568e-17
def fospos(x0,x1,eps): xold=x0 x=x1 while(abs(x-xold)>eps): xold2=xold xold=x x=phifp(x,xold2) return(x)
def phifp(xn,xn1): res=xn-(f(xn)*((xn-xn1)/(f(xn)-f(xn1)))) return(res)
phifp(0.1,2.1)
0.150720874692097
fospos(0.1,2.1,1.e-7)
0.150720874692097 0.218258268955401 -0.0967512581539759 0.0374103980757303 0.00504579648280168 -0.000299464926141325 2.28039407593010e-6 1.02395815757518e-9 -3.59650406559766e-15 -3.59650406559766e-15
fp(x)
2*x - 1/(x + 1)