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 --- 1670/CH6/EX6.7/6_7.sce | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 1670/CH6/EX6.7/6_7.sce (limited to '1670/CH6/EX6.7/6_7.sce') diff --git a/1670/CH6/EX6.7/6_7.sce b/1670/CH6/EX6.7/6_7.sce new file mode 100755 index 000000000..09b803d1c --- /dev/null +++ b/1670/CH6/EX6.7/6_7.sce @@ -0,0 +1,29 @@ +//Example 6.7 +//Parabola Best Fit +//Page no. 222 +clc;close;clear; + +x=[0,1,2,3,4] +y=[-2.1,-0.4,2.1,3.6,9.9] +n=1; +printf('\t\t 2\t 3\t 4\t\t\t 2\n n\tx\tx\tx\tx\ty\txy\tx y\n----------------------------------------------------------------\n') +x1=0;x2=0;x3=0;x4=0;x5=0;x6=0;x7=0;x8=0; +for i=1:5 + printf(' %g\t%g\t%g\t%g\t%g\t%g\t%g\t%g\n',n,x(i),x(i)^2,x(i)^3,x(i)^4,y(i),y(i)*x(i),x(i)^2*y(i)) + x1=x1+n; + x2=x2+x(i); + x3=x3+x(i)^2; + x4=x4+x(i)^3; + x5=x5+x(i)^4; + x6=x6+y(i); + x7=x7+y(i)*x(i); + x8=x8+x(i)^2*y(i) +end +printf('----------------------------------------------------------------\n %g\t%g\t%g\t%g\t%g\t%g\t%g\t%g\n',x1,x2,x3,x4,x5,x6,x7,x8) +A=[x1,x2,x3;x2,x3,x4;x3,x4,x5] +B=[x6;x7;x8] +C=inv(A)*B; +disp(C) +x=poly(0,'x') +y=C(1)+C(2)*x+C(3)*x^2 +disp(y,'y =') \ No newline at end of file -- cgit