From b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b Mon Sep 17 00:00:00 2001 From: priyanka Date: Wed, 24 Jun 2015 15:03:17 +0530 Subject: initial commit / add all books --- 1673/CH3/EX3.18/3_18.sce | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 1673/CH3/EX3.18/3_18.sce (limited to '1673/CH3/EX3.18') diff --git a/1673/CH3/EX3.18/3_18.sce b/1673/CH3/EX3.18/3_18.sce new file mode 100755 index 000000000..4c185f6a3 --- /dev/null +++ b/1673/CH3/EX3.18/3_18.sce @@ -0,0 +1,23 @@ +//error in lagrange's interpolation formula +//example 3.18 +//page 107 +clc;clear;close; +x=[2 2.5 3.0]; +y=[0.69315 0.91629 1.09861]; +deff('y=l0(x)','y=(x-2.5)*(x-3.0)/(-0.5)*(-1.0)') +x=poly(0,'x'); +disp(l0(x),'l0(x)='); +deff('y=l1(x)','y=((x-2.0)*(x-3.0))/((0.5)*(-0.5))') +x=poly(0,'x'); +disp(l1(x),'l1(x)='); +deff('y=l2(x)','y=((x-2.0)*(x-2.5))/((1.0)*(0.5))') +x=poly(0,'x'); +disp(l2(x),'l2(x)='); +f_x=l0(2.7)*y(1)+l1(2.7)*y(2)+l2(2.7)*y(3); +printf(' the calculated value is %f:',f_x); +err=abs(f_x-log(2.7)); +deff('y=R_n(x)','y=(((x-2)*(x-2.5)*(x-3))/6)'); +est_err=abs(R_n(2.7)*(2/8)) +if est_err>err then + printf('\n\n the error agrees with the actual error') +end \ No newline at end of file -- cgit