summaryrefslogtreecommitdiff
path: root/845/CH6/EX6.15/Ex6_15.sce
diff options
context:
space:
mode:
Diffstat (limited to '845/CH6/EX6.15/Ex6_15.sce')
-rwxr-xr-x845/CH6/EX6.15/Ex6_15.sce23
1 files changed, 23 insertions, 0 deletions
diff --git a/845/CH6/EX6.15/Ex6_15.sce b/845/CH6/EX6.15/Ex6_15.sce
new file mode 100755
index 000000000..05dca459d
--- /dev/null
+++ b/845/CH6/EX6.15/Ex6_15.sce
@@ -0,0 +1,23 @@
+//Example 6.15
+
+clc
+clear
+
+x = [1 2 5];
+y = [1 4 10];
+
+n = length(x);
+Y = 0;
+X = poly(0, "X");
+//X = 5;
+for i = 1:n
+ t = x;
+ t(i) = [];
+ p = 1;
+ for j = 1:length(t)
+ p = p * (X-t(j))/(x(i)-t(j));
+ end
+ Y = Y + p*y(i);
+end
+Y5 = horner(Y,3);
+disp(Y5,"f(3) = ")