summaryrefslogtreecommitdiff
path: root/1332/CH5/EX5.35/5_35.sce
blob: 19086449beefc34a910887f54a50017b522ad236 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
//Example 5.35
//Newton Raphson Method
//Page no. 203
clc;clear;close;
deff('x=f(x)','x=x^3-30*x^2+2552')
deff('x=f1(x)','x=3*x^2-60*x')
//newton raphson
printf('n\txn\t\t\f(xn)\t\tf1(xn)\t\tXn+1\t\tError\n')
printf('-----------------------------------------------------------------------------------------------------\n')
x0=10;e=0.00001
for i=1:4
    x1=x0-f(x0)/f1(x0)
    e1=abs(x0-x1)
    printf(' %i\t%.10f\t%.10f\t%.10f\t%.10f\t%.10f\n',i-1,x0,f(x0),f1(x0),x1,e1)
    x0=x1;
    if abs(x0)<e then
        break;
    end
end
printf('\n\nThus the ball is submerged upto height of %.10f cm\n\n\n',x1)