summaryrefslogtreecommitdiff
path: root/191/CH5/EX5.12
diff options
context:
space:
mode:
authorpriyanka2015-06-24 15:03:17 +0530
committerpriyanka2015-06-24 15:03:17 +0530
commitb1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b (patch)
treeab291cffc65280e58ac82470ba63fbcca7805165 /191/CH5/EX5.12
downloadScilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.tar.gz
Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.tar.bz2
Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.zip
initial commit / add all books
Diffstat (limited to '191/CH5/EX5.12')
-rwxr-xr-x191/CH5/EX5.12/Example5_12.sce38
-rwxr-xr-x191/CH5/EX5.12/Result5_12.txt6
2 files changed, 44 insertions, 0 deletions
diff --git a/191/CH5/EX5.12/Example5_12.sce b/191/CH5/EX5.12/Example5_12.sce
new file mode 100755
index 000000000..8309f0111
--- /dev/null
+++ b/191/CH5/EX5.12/Example5_12.sce
@@ -0,0 +1,38 @@
+//Alternating way of constructing cubic splines
+clc;
+clear;
+close();
+//from example 5.11
+xi = [0 1 3 3.5 5];
+yi = [1.00000 0.54030 -0.98999 -0.93646 0.28366];
+//free boundary conditions
+//matrix form
+format('v',8);
+A = [6 2 0; 2 5 1/2; 0 1/2 4];
+B = 6*[-0.30545 ; 0.87221 ; 0.70635];
+C = inv(A)*B;
+c1 = C(1);
+c2 = C(2);
+c3 = C(3);
+x = poly(0,'x');
+s2x = c2*(3.5-x)*(3.5-x)*(3.5-x)/(6*0.5) + c3*(x-3)*(x-3)*(x-3)/(6*0.5) + {yi(3)/0.5+0.5*c2/6}*(3.5-x) + {yi(4)/0.5 + 0.5*c3/6}*(x-3);
+x = 3.14159;
+val = horner(s2x,x)*(-1.00271)/(-0.90705);
+disp(val , 'value of s2x at 3.14159 : ');
+//clamped boundary conditions
+A = [2 1 0 0 0;
+1 6 2 0 0;
+0 2 5 1/2 0;
+0 0 1/2 4 3/2;
+0 0 0 3/2 3];
+B = 6*[-0.45970; -0.30545 ; 0.87221 ; 0.70635; 0.14551];
+C = inv(A)*B;
+c0 = C(1);
+c1 = C(2);
+c2 = C(3);
+c3 = C(4);
+c4 = C(5);
+s2x = c2*(3.5-x)*(3.5-x)*(3.5-x)/(6*0.5) + c3*(x-3)*(x-3)*(x-3)/(6*0.5) + {yi(3)/0.5+0.5*c2/6}*(3.5-x) + {yi(4)/0.5 + 0.5*c3/6}*(x-3);
+x = 3.14159;
+val = horner(s2x,x)*(-1.00227)/(-0.91030);
+disp(val , 'value of s2x at 3.14159 : '); \ No newline at end of file
diff --git a/191/CH5/EX5.12/Result5_12.txt b/191/CH5/EX5.12/Result5_12.txt
new file mode 100755
index 000000000..271eebdcb
--- /dev/null
+++ b/191/CH5/EX5.12/Result5_12.txt
@@ -0,0 +1,6 @@
+ value of s2x at 3.14159 :
+
+ - 1.00271
+ value of s2x at 3.14159 :
+
+ - 1.00227 \ No newline at end of file