summaryrefslogtreecommitdiff
path: root/964/CH5/EX5.5/5_5.sce
blob: dab166f1f17be67f7b6e02106a493ea7ecb8568e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
clc;
clear;
m=68.1;//kg
v=40;//m/s
t=10;//s
g=9.8;//m/s^2
function y=f(c)
    y=g*m*(1-exp(-c*t/m))/c - v;
endfunction
x1=12;
x2=16;
xt=14.7802;//true value
e=input("enter the tolerable true percent error=")
xr=x1-(f(x1)*(x2-x1))/(f(x2)-f(x1));
etemp=abs(xr-xt)/xt*100;//error
while etemp>e
    if f(x1)*f(xr)>0 then 
        x1=xr;
        xr=x1-(f(x1)*(x2-x1))/(f(x2)-f(x1));
        etemp=abs(xr-xt)/xt*100;
    end
    if f(x1)*f(xr)<0 then
            x2=xr;
            xr=x1-(f(x1)*(x2-x1))/(f(x2)-f(x1));
            etemp=abs(xr-xt)/xt*100;
    end
    if f(x1)*f(xr)==0 then break;
    end
end
disp(xr,"The result is=")