newton(1,2,2)
newton(1,3,2)
newton(1,4,2)
newton(1,5,2)

def newton(x0,k,N):
    "function to calculate the root of a given number,"
    "x0=initial approximation, k= power or desired root,N=given number"
    
    h(x)=((k-1)*(x)+N/x**(k-1))/k #Iteration Scheme by the newton raphson method
    h(x0)
    for i in range (10):
        xn=h(x0)
        x0=xn
        o=float(h(x0))  
    print o

SageDays/Kreyszig-17.2-12 (last edited 2010-08-15 09:44:40 by PraveenKumar)