diff options
Diffstat (limited to '413/CH9')
-rw-r--r-- | 413/CH9/EX9.1/Example_9_1.sce | 16 | ||||
-rw-r--r-- | 413/CH9/EX9.2/Example_9_2.sce | 16 | ||||
-rw-r--r-- | 413/CH9/EX9.3/Example_9_3.sce | 16 | ||||
-rw-r--r-- | 413/CH9/EX9.4/Example_9_4.sce | 40 | ||||
-rw-r--r-- | 413/CH9/EX9.5/Example_9_5.sce | 35 | ||||
-rw-r--r-- | 413/CH9/EX9.6/Example_9_6.sce | 19 |
6 files changed, 142 insertions, 0 deletions
diff --git a/413/CH9/EX9.1/Example_9_1.sce b/413/CH9/EX9.1/Example_9_1.sce new file mode 100644 index 000000000..e14a16fe9 --- /dev/null +++ b/413/CH9/EX9.1/Example_9_1.sce @@ -0,0 +1,16 @@ +clc
+clear
+printf('Solve the equation y''+y=3X^2, with boundary points (0,0) and (2, 3.5)')
+printf('\nCompare computed value form Rayleigh-Ritz Method vs Analytic result')
+P=0
+X(1,1)=0
+for i=1:20
+ X(1,i+1)=0.1+P
+ P=X(1,i+1)
+end
+for i=1:21
+ A(1,i)=(119/152).*X(1,i).*X(1,i).*X(1,i)-(46/57)*X(1,i).*X(1,i)+(53/228)*X(1,i)
+B(1,i)=6*cos(X(1,i))+3*(X(1,i).*X(1,i)-2)
+T=[X(1,i), B(1,i), A(1,i), B(1,i)-A(1,i)]
+disp(T)
+end
\ No newline at end of file diff --git a/413/CH9/EX9.2/Example_9_2.sce b/413/CH9/EX9.2/Example_9_2.sce new file mode 100644 index 000000000..81bbf701d --- /dev/null +++ b/413/CH9/EX9.2/Example_9_2.sce @@ -0,0 +1,16 @@ +clc
+clear
+printf('Solve the equation y''+y=3X^2, with boundary points (0,0) and (2, 3.5)')
+printf('\nCompare computed value form Collocation Method vs Analytic result')
+P=0
+X(1,1)=0
+for i=1:20
+ X(1,i+1)=0.1+P
+ P=X(1,i+1)
+end
+for i=1:21
+ A(1,i)=(425/509).*X(1,i).*X(1,i).*X(1,i)-(61607/55481)*X(1,i).*X(1,i)+(140023/221924)*X(1,i)
+B(1,i)=6*cos(X(1,i))+3*(X(1,i).*X(1,i)-2)
+T=[X(1,i), B(1,i), A(1,i), B(1,i)-A(1,i)]
+disp(T)
+end
\ No newline at end of file diff --git a/413/CH9/EX9.3/Example_9_3.sce b/413/CH9/EX9.3/Example_9_3.sce new file mode 100644 index 000000000..0137d961b --- /dev/null +++ b/413/CH9/EX9.3/Example_9_3.sce @@ -0,0 +1,16 @@ +clc
+clear
+printf('Solve the equation y''+y=3X^2, with boundary points (0,0) and (2, 3.5)')
+printf('\nCompare computed value form The Galerkin Method vs Analytic result')
+P=0
+X(1,1)=0
+for i=1:20
+ X(1,i+1)=0.1+P
+ P=X(1,i+1)
+end
+for i=1:21
+ A(1,i)=(101/152).*X(1,i).*X(1,i).*X(1,i)-(103/228)*X(1,i).*X(1,i)+(1/228)*X(1,i)
+B(1,i)=6*cos(X(1,i))+3*(X(1,i).*X(1,i)-2)
+T=[X(1,i), B(1,i), A(1,i), B(1,i)-A(1,i)]
+disp(T)
+end
\ No newline at end of file diff --git a/413/CH9/EX9.4/Example_9_4.sce b/413/CH9/EX9.4/Example_9_4.sce new file mode 100644 index 000000000..d3aea38b8 --- /dev/null +++ b/413/CH9/EX9.4/Example_9_4.sce @@ -0,0 +1,40 @@ +clc
+clear
+printf('Solve the equation y''+y=3X^2, with boundary points (0,0) and (2, 3.5)')
+printf('\n Subdivide into seven elements that join at x=0.4, 0.7, 1.1, 1.3 and 1.6')
+printf('\n Augmented matrix')
+P=[2.367 -2.567 0 0 0 0 0 0 -0.024
+-2.567 5.6 -3.383 0 0 0 0 0 -0.160
+0 -3.383 8.167 -5.033 0 0 0 0 -0.328
+0 0 -5.033 9.867 -5.033 0 0 0 -0.492
+0 0 0 -5.033 9.867 -5.033 0 0 -0.732
+0 0 0 0 -5.033 8.167 -3.383 0 -1.378
+0 0 0 0 0 -3.383 5.600 -2.567 -2.89
+0 0 0 0 0 0 -2.567 2.367 -1.944]
+disp(P)
+printf('Matrix after ajjusting boundary condition')
+T=[ 5.6 -3.383 0 0 0 0 -0.160
+ -3.383 8.167 -5.033 0 0 0 -0.328
+ 0 -5.033 9.867 -5.033 0 0 -0.492
+ 0 0 -5.033 9.867 -5.033 0 -0.732
+ 0 0 0 -5.033 8.167 -3.383 -1.378
+ 0 0 0 0 -3.383 5.600 6.094]
+ disp(T)
+ A=[ 5.6 -3.383 0 0 0 0
+ -3.383 8.167 -5.033 0 0 0
+ 0 -5.033 9.867 -5.033 0 0
+ 0 0 -5.033 9.867 -5.033 0
+ 0 0 0 -5.033 8.167 -3.383
+ 0 0 0 0 -3.383 5.600 ]
+
+ B=[-0.160 -0.328 -0.492 -0.732 -1.378 6.094]'
+ S=A\B
+printf('The table showing the analytical solution and the errors of our computation')
+
+ X=[0.4 0.7 0.9 1.1 1.3 1.6]
+ for i=1:6
+ B(1,i)=6*cos(X(1,i))+3*(X(1,i).*X(1,i)-2)
+ T=[X(1,i), S(i,1), B(1,i), B(1,i)-S(i,1)]
+disp(T)
+ end
+
\ No newline at end of file diff --git a/413/CH9/EX9.5/Example_9_5.sce b/413/CH9/EX9.5/Example_9_5.sce new file mode 100644 index 000000000..41801f555 --- /dev/null +++ b/413/CH9/EX9.5/Example_9_5.sce @@ -0,0 +1,35 @@ +clc
+clear
+//printf('(Solve the equation y''-(x+1)y=e^-x(X^2-x+2), with Neumann boundary conditions y'(2)=0, y'(4)=-0.036631)')
+
+printf('\n Augmented matrix')
+P=[2.542 -1.729 0 0 0 0.127
+-1.729 5.167 -1.688 0 0 0.236
+0 -1.688 5.333 -1.646 0 0.199
+0 0 -1.646 5.5 -1.604 0.163
+0 0 0 -1.604 2.792 0.072 ]
+disp(P)
+printf('Matrix after ajjusting boundary condition')
+T=[ 2.542 -1.729 0 0 0 0.127
+-1.729 5.167 -1.688 0 0 0.236
+0 -1.688 5.333 -1.646 0 0.199
+0 0 -1.646 5.5 -1.604 0.163
+0 0 0 -1.604 2.792 0.036 ]
+ disp(T)
+ A=[ 2.542 -1.729 0 0 0
+-1.729 5.167 -1.688 0 0
+0 -1.688 5.333 -1.646 0
+0 0 -1.646 5.5 -1.604
+0 0 0 -1.604 2.792 ]
+
+ B=[0.127 0.236 0.199 0.163 0.036]'
+ S=A\B
+printf('The table showing the analytical solution and the errors of our computation')
+
+ X=[2.0 2.5 3.0 3.5 4]
+ for i=1:5
+ B(1,i)=exp(-X(1,i))*(X(1,i)-1)
+ T=[X(1,i), S(i,1), B(1,i), B(1,i)-S(i,1)]
+disp(T)
+ end
+
\ No newline at end of file diff --git a/413/CH9/EX9.6/Example_9_6.sce b/413/CH9/EX9.6/Example_9_6.sce new file mode 100644 index 000000000..4e747c85f --- /dev/null +++ b/413/CH9/EX9.6/Example_9_6.sce @@ -0,0 +1,19 @@ +clc
+clear
+printf('For the triangular element with nodes r s and t Find {a} {N} and v(0.8, 0.4)')
+M=[1 0 0; 1 2 0; 1 0 1]
+printf('\n M=')
+disp(M)
+Minv=inv(M)
+printf('\n inverse of M')
+disp(Minv)
+C=[ 100 200 300]'
+printf('\n C')
+disp(C)
+a=Minv*C
+printf('\n {a}=Inverse of M* C')
+printf('\n {a}=')
+disp(a)
+v=a(1,1)+a(2,1)*0.8+a(3,1)*0.4
+printf('v(0.8,0.4)=')
+disp(v)
\ No newline at end of file |