summaryrefslogtreecommitdiff
path: root/413/CH5
diff options
context:
space:
mode:
Diffstat (limited to '413/CH5')
-rw-r--r--413/CH5/EX5.1/Example_5_1.sce11
-rw-r--r--413/CH5/EX5.2/Example_5_2.sce56
-rw-r--r--413/CH5/EX5.3/Example_5_3.sce25
-rw-r--r--413/CH5/EX5.4/Example_5_4.sce69
-rw-r--r--413/CH5/EX5.5/Example_5_5.sce62
-rw-r--r--413/CH5/EX5.6/Table_5_1.sce14
-rw-r--r--413/CH5/EX5.7/Table_5_2.sce14
-rw-r--r--413/CH5/EX5.8/Table_5_3.sce42
-rw-r--r--413/CH5/EX5.9/Table_5_4.sce40
9 files changed, 333 insertions, 0 deletions
diff --git a/413/CH5/EX5.1/Example_5_1.sce b/413/CH5/EX5.1/Example_5_1.sce
new file mode 100644
index 000000000..1756bc344
--- /dev/null
+++ b/413/CH5/EX5.1/Example_5_1.sce
@@ -0,0 +1,11 @@
+clc
+clear
+x=[1.6 1.8 2 2.2 2.4 2.6 2.8 3 3.2 3.4 3.6 3.8];
+F=[4.953 6.05 7.389 9.025 11.023 13.464 16.445 20.086 24.533 29.964 36.594 44.701]
+for i=1:12
+X=[x(1,i), F(1,i)]
+disp(X)
+end
+A=(0.2/2)*[(6.05+29.964)+2*(7.389+9.025+11.023+13.464+16.445+20.086+24.533)]
+printf('Answer by Trapezoidal Rule to estimate the integral from x=1.8 to x=3.4')
+disp(A) \ No newline at end of file
diff --git a/413/CH5/EX5.2/Example_5_2.sce b/413/CH5/EX5.2/Example_5_2.sce
new file mode 100644
index 000000000..44202a68e
--- /dev/null
+++ b/413/CH5/EX5.2/Example_5_2.sce
@@ -0,0 +1,56 @@
+clc
+clear
+sumR2=0
+sumR3=0
+sumR4=0
+function a=fun(x)
+ a=exp(-x.*x)
+endfunction
+A=[0.2 1.5]
+M=(A(1,1)+A(1,2))/2
+
+h=M-0.2
+R1=(h)/2 *[fun(0.2)+fun(1.5)+2*fun(M)]
+
+h1=h/2
+for i=1:3
+ B(1,i)=0.2+i*h1
+ sumR2=fun(B(1,i))+sumR2
+ end
+R2=h1/2 *[fun(0.2)+fun(1.5)+2*sumR2]
+
+h2=h1/2
+for i=1:7
+ C(1,i)=0.2+i*h2
+ sumR3=fun(C(1,i))+sumR3
+ end
+R3=h2/2 *[fun(0.2)+fun(1.5)+2*sumR3]
+
+h3=h2/2
+for i=1:15
+ D(1,i)=0.2+i*h3
+ sumR4=fun(D(1,i))+sumR4
+ end
+R4=h3/2 *[fun(0.2)+fun(1.5)+2*sumR4]
+
+
+R5=R2+1/3*(R2-R1)
+
+R6=R3+1/3*(R3-R2)
+
+R7=R4+1/3*(R4-R3)
+
+R8=R6+1/3*(R6-R5)
+
+R9=R7+1/3*(R7-R6)
+
+R10=R9+1/3*(R9-R8)
+
+T1=[R1]
+T2=[R2, R5]
+T3=[R3, R6, R8]
+T4=[R4,R7,R9,R10]
+disp(T1)
+disp(T2)
+disp(T3)
+disp(T4)
diff --git a/413/CH5/EX5.3/Example_5_3.sce b/413/CH5/EX5.3/Example_5_3.sce
new file mode 100644
index 000000000..c6a9bc6ad
--- /dev/null
+++ b/413/CH5/EX5.3/Example_5_3.sce
@@ -0,0 +1,25 @@
+clc
+clear
+x=[1.6 1.8 2 2.2 2.4 2.6 2.8 3 3.2 3.4 3.6 3.8];
+F=[4.953 6.05 7.389 9.025 11.023 13.464 16.445 20.086 24.533 29.964 36.594 44.701]
+for i=1:12
+X=[x(1,i), F(1,i)]
+end
+A1=(0.2/2)*[(6.05+29.964)+2*(7.389+9.025+11.023+13.464+16.445+20.086+24.533)]
+printf('Answer by Trapezoidal Rule to estimate the integral from x=1.8 to x=3.4 taking h=0.2')
+disp(A1)
+A2=(0.4/2)*[(6.05+29.964)+2*(9.025+13.464+20.086)]
+printf('Answer by Trapezoidal Rule to estimate the integral from x=1.8 to x=3.4 taking h =0.4')
+disp(A2)
+A3=(0.8/2)*[(6.05+29.964)+2*(13.464)]
+printf('Answer by Trapezoidal Rule to estimate the integral from x=1.8 to x=3.4 taking h=0.8')
+disp(A3)
+A4=A1+(A1-A2)/3
+A5=A2+(A2-A3)/3
+A6=A4+(A4-A5)/3
+T1=[0.2 A1 A4 A6]
+T2=[0.4 A2 A5]
+T3=[0.8 A3]
+disp(T1)
+disp(T2)
+disp(T3) \ No newline at end of file
diff --git a/413/CH5/EX5.4/Example_5_4.sce b/413/CH5/EX5.4/Example_5_4.sce
new file mode 100644
index 000000000..bbe9a229c
--- /dev/null
+++ b/413/CH5/EX5.4/Example_5_4.sce
@@ -0,0 +1,69 @@
+clc
+clear
+a=0.2
+b=2.6
+function p=f(c)
+ p=exp(-c.^2)
+endfunction
+
+for n=6:6:24
+a=0.2
+ST=0
+h=(b-a)/n
+for i=1:n+1
+ T=[a,f(a)]
+ A(1,i)=a
+ a=a+h
+end
+for i=2:n
+ ST=ST+2*f(A(1,i))
+end
+TZ(1,n)=(h/2)*(f(0.2)+f(2.6)+ST)
+end
+for n=6:6:24
+a=0.2
+ST1=0
+ST2=0
+h=(b-a)/n
+for i=1:n+1
+ A(1,i)=a
+ a=a+h
+
+end
+
+for i=2:2:n-2
+ ST1=ST1+2*f(A(1,i+1))
+ ST2=ST2+4*f(A(1,i))
+end
+ ST2=ST2+4*f(A(1,n))
+
+TS3(1,n)=(h/3)*(f(0.2)+f(2.6)+ST1+ST2)
+
+end
+for n=6:6:24
+a=0.2
+ST1=0
+ST2=0
+ST3=0
+h=(b-a)/n
+for i=1:n+1
+ A(1,i)=a
+ a=a+h
+end
+for i=2:3:n-3
+ ST1=ST1+3*f(A(1,i))
+ ST2=ST2+3*f(A(1,i+1))
+ ST3=ST3+2*f(A(1,i+2))
+end
+ ST2=ST2+3*f(A(1,n))
+ ST1=ST1+3*f(A(1,n-1))
+
+TS38(1,n)=(h*3/8)*(f(0.2)+f(2.6)+ST1+ST2+ST3)
+end
+for i=1:4
+ n=i*6
+ R=[n, TZ(1,n), 0.6886527145-TZ(1,n),TS3(1,n),0.6886527145-TS3(1,n),TS38(1,n),0.6886527145-TS38(1,n)]
+ disp(R)
+end
+
+
diff --git a/413/CH5/EX5.5/Example_5_5.sce b/413/CH5/EX5.5/Example_5_5.sce
new file mode 100644
index 000000000..15d85a86b
--- /dev/null
+++ b/413/CH5/EX5.5/Example_5_5.sce
@@ -0,0 +1,62 @@
+clc
+clear
+a=0
+b=2
+function p=fA(c,n)
+ p=c*cos((n*c*%pi)/2)
+endfunction
+function q=fB(c,n)
+ q=c*sin((n*c*%pi)/2)
+endfunction
+for n=1:5
+for t=20:180:200
+a=0
+ST=0
+ST1=0
+h=(b-a)/t
+for i=1:t+1
+ A(1,i)=a
+ a=a+h
+end
+for i=2:t
+ ST=ST+2*fA(A(1,i),n)
+ ST1=ST1+2*fB(A(1,i),n)
+end
+TZA(t,n)=(h/2)*(fA((0),n)+fA((2),n)+ST)
+TZB(t,n)=(h/2)*(fB((0),n)+fB((2),n)+ST1)
+end
+end
+for t=20:180:200
+
+for n=1:5
+a=0
+ST1=0
+ST2=0
+ST3=0
+ST4=0
+h=(b-a)/t
+for i=1:t+1
+ A(1,i)=a
+ a=a+h
+end
+for i=2:2:t-2
+ ST1=ST1+2*fA(A(1,i+1),n)
+ ST2=ST2+4*fA(A(1,i),n)
+ ST3=ST3+2*fB(A(1,i+1),n)
+ ST4=ST4+4*fB(A(1,i),n)
+end
+ ST2=ST2+4*fA(A(1,t),n)
+ ST4=ST4+4*fB(A(1,t),n)
+TSA3(t,n)=(h/3)*(fA(0,n)+fA(2,n)+ST1+ST2)
+
+TSB3(t,n)=(h/3)*(fB(0,n)+fB(2,n)+ST3+ST4)
+
+end
+end
+for t=20:180:200
+ printf('Comparison of numerical integration of %f subdivisions of [0 2]',t)
+for n=1:5
+ T=[n,TZA(t,n),TZB(t,n),TSA3(t,n),TSB3(t,n)]
+ disp(T)
+end
+end
diff --git a/413/CH5/EX5.6/Table_5_1.sce b/413/CH5/EX5.6/Table_5_1.sce
new file mode 100644
index 000000000..33d26119e
--- /dev/null
+++ b/413/CH5/EX5.6/Table_5_1.sce
@@ -0,0 +1,14 @@
+clc
+clear
+x=1.9;
+function a=expsin(y)
+ a=(exp(x+y).*sin(x+y)-exp(x).*sin(x))/y
+endfunction
+function out=tab5(y)
+out=[y,expsin(y)]
+endfunction
+y=0.05
+for i=0:1:10
+disp(tab5(y))
+y=y.*0.5
+end \ No newline at end of file
diff --git a/413/CH5/EX5.7/Table_5_2.sce b/413/CH5/EX5.7/Table_5_2.sce
new file mode 100644
index 000000000..159debee2
--- /dev/null
+++ b/413/CH5/EX5.7/Table_5_2.sce
@@ -0,0 +1,14 @@
+clc
+clear
+x=1.9;
+function a=expsin(y)
+ a=(exp(x+y).*sin(x+y)-exp(x-y).*sin(x-y))/(2*y)
+endfunction
+function out=tab5(y)
+out=[y,expsin(y)]
+endfunction
+y=0.05
+for i=0:1:6
+disp(tab5(y))
+y=y.*0.5
+end \ No newline at end of file
diff --git a/413/CH5/EX5.8/Table_5_3.sce b/413/CH5/EX5.8/Table_5_3.sce
new file mode 100644
index 000000000..5964235bf
--- /dev/null
+++ b/413/CH5/EX5.8/Table_5_3.sce
@@ -0,0 +1,42 @@
+clc
+clear
+clc
+clear
+x=[1.7 1.8 2 2.35 2.50];
+function a=expsin(x)
+ a=exp(x).*sin(x)
+endfunction
+for i=1:1:4
+function b=firstdivdiff(x)
+b=(expsin(x(1,i+1))-expsin(x(1,i)))/(x(1,i+1)-x(1,i))
+endfunction
+A(1,i)=firstdivdiff(x)
+end
+for i=1:1:3
+function b=Secdivdiff(x)
+b=(A(1,i+1)-A(1,i))/(x(1,i+2)-x(1,i))
+endfunction
+B(1,i)=Secdivdiff(x)
+end
+for i=1:1:2
+function b=thdivdiff(x)
+b=(B(1,i+1)-B(1,i))/(x(1,i+3)-x(1,i))
+endfunction
+C(1,i)=thdivdiff(x)
+end
+for i=1:1:1
+function b=fodivdiff(x)
+b=(C(1,i+1)-C(1,i))/(x(1,i+4)-x(1,i))
+endfunction
+D(1,i)=fodivdiff(x)
+end
+out=[0,x(1,1),expsin(x(1,1)) ]
+disp(out)
+out1=[1,x(1,2),expsin(x(1,2)), A(1,1) ]
+disp(out1)
+out2=[2,x(1,3),expsin(x(1,3)), A(1,2), B(1,1) ]
+disp(out2)
+out3=[3,x(1,4),expsin(x(1,4)), A(1,3), B(1,2),C(1,1),D(1,1) ]
+disp(out3)
+out4=[4,x(1,5),expsin(x(1,5)), A(1,4), B(1,3),C(1,2) ]
+disp(out4) \ No newline at end of file
diff --git a/413/CH5/EX5.9/Table_5_4.sce b/413/CH5/EX5.9/Table_5_4.sce
new file mode 100644
index 000000000..c5e16db7f
--- /dev/null
+++ b/413/CH5/EX5.9/Table_5_4.sce
@@ -0,0 +1,40 @@
+clc
+clear
+x=[1.7 1.9 2.1 2.3 2.50];
+function a=expsin(x)
+ a=exp(x).*sin(x)
+endfunction
+for i=1:1:4
+function b=firstdivdiff(x)
+b=(expsin(x(1,i+1))-expsin(x(1,i)))
+endfunction
+A(1,i)=firstdivdiff(x)
+end
+for i=1:1:3
+function b=Secdivdiff(x)
+b=(A(1,i+1)-A(1,i))
+endfunction
+B(1,i)=Secdivdiff(x)
+end
+for i=1:1:2
+function b=thdivdiff(x)
+b=(B(1,i+1)-B(1,i))
+endfunction
+C(1,i)=thdivdiff(x)
+end
+for i=1:1:1
+function b=fodivdiff(x)
+b=(C(1,i+1)-C(1,i))
+endfunction
+D(1,i)=fodivdiff(x)
+end
+out=[0,x(1,1),expsin(x(1,1)) ]
+disp(out)
+out1=[1,x(1,2),expsin(x(1,2)), A(1,1) ]
+disp(out1)
+out2=[2,x(1,3),expsin(x(1,3)), A(1,2), B(1,1) ]
+disp(out2)
+out3=[3,x(1,4),expsin(x(1,4)), A(1,3), B(1,2),C(1,1),D(1,1) ]
+disp(out3)
+out4=[4,x(1,5),expsin(x(1,5)), A(1,4), B(1,3),C(1,2) ]
+disp(out4) \ No newline at end of file