summaryrefslogtreecommitdiff
path: root/3588/CH5/EX5.2/EX5_2.sce
diff options
context:
space:
mode:
Diffstat (limited to '3588/CH5/EX5.2/EX5_2.sce')
-rw-r--r--3588/CH5/EX5.2/EX5_2.sce37
1 files changed, 37 insertions, 0 deletions
diff --git a/3588/CH5/EX5.2/EX5_2.sce b/3588/CH5/EX5.2/EX5_2.sce
new file mode 100644
index 000000000..1c31c63cf
--- /dev/null
+++ b/3588/CH5/EX5.2/EX5_2.sce
@@ -0,0 +1,37 @@
+//Clearing console
+clc
+clear
+
+x = poly(0,"x")
+
+//Intializing variables
+x0 = 0
+x1 = 1
+
+//Consrtucting K and F matrices to solve the residual equations
+K(1,1:2) = [integrate('x*(x-1)*2','x',x0,x1) integrate('x*(x-1)*2*(3*x-1)','x',x0,x1)]
+K(2,1:2) = [integrate('x^2*(x-1)*2','x',x0,x1) integrate('x^2*(x-1)*2*(3*x-1)','x',x0,x1)]
+
+F = [integrate('x*(x-1)*(10*(x^2)+5)','x',x0,x1); integrate('x^2*(x-1)*(10*(x^2)+5)','x',x0,x1)]
+
+//Solving for constants in assumed solution
+U(1:2,1)=linsolve(K,-F)
+
+S = U(1,1)*x*(x-1)+U(2,1)*x^2*(x-1)
+
+//Calculating solution for given differntial equation
+for t =1:11
+ P(1,t) = (U(1,1)*(t-1)*(t-11)/100)+(U(2,1)*(t-1)^2*(t-11)/1000)
+end
+
+//Constructing x matrix
+k = 0:0.1:1;
+
+//plotting solution
+plot(k,P);
+xtitle('solution','x','y(x)')
+
+printf('\nResults\n')
+printf('\nSolution of the Differential Equation y(x) =')
+disp(S)
+