From f35ea80659b6a49d1bb2ce1d7d002583f3f40947 Mon Sep 17 00:00:00 2001 From: prashantsinalkar Date: Tue, 10 Oct 2017 12:38:01 +0530 Subject: updated the code --- 60/CH3/EX3.10/ex_10.sce | 2 +- 60/CH3/EX3.2.a/ex_2_a.sce | 50 ++++++++++++++++++++--------------------------- 60/CH4/EX4.21/ex_21.sce | 4 ++-- 60/CH6/EX6.12/ex_12.sce | 14 +++++-------- 4 files changed, 29 insertions(+), 41 deletions(-) (limited to '60') diff --git a/60/CH3/EX3.10/ex_10.sce b/60/CH3/EX3.10/ex_10.sce index 855fd40df..42ccfa1cc 100755 --- a/60/CH3/EX3.10/ex_10.sce +++ b/60/CH3/EX3.10/ex_10.sce @@ -1,6 +1,6 @@ //example(3.10) - c=[-3 1 0 1]] + c=[-3 1 0 1] p3=poly(c,'x','coeff') roots(p3) //here diff --git a/60/CH3/EX3.2.a/ex_2_a.sce b/60/CH3/EX3.2.a/ex_2_a.sce index 684d1b91e..44d062385 100755 --- a/60/CH3/EX3.2.a/ex_2_a.sce +++ b/60/CH3/EX3.2.a/ex_2_a.sce @@ -1,30 +1,22 @@ -//example(3.2a) - - -//bisection method - -deff('[y]=f(x)','y=x^3-x-1') -bisection(1.0,1.5,f) - - -//regula falsi method - -deff('[y]=f(x)','y=x^3-x-1') -regularfalsi(1.0,1.5,f) - -//secant method - -deff('[y]=f(x)','y=x^3-x-1') -secant(1.0,1.5,f) - - +// // Example(3.2a) +// +//// finding roots using bisection method +// +// +// deff('[y]=f(x)','y=x^3-x-1') +// bisection(0,10,f); +// +// +////regula falsi method +// +//deff('[y]=f(x)','y=x^3-x-1') +//regularfalsi(0,10,f); +// +// +// //newton rapson method - - -x=(0.5+1)/2 -deff('[y]=f(x)','y=x^3-x-1') -deff('[y]=g(x)','y=1-0.2*cos(x)') - -newton(x,f,g) - - +// +//x=(0+10)/2 +//deff('[y]=f(x)','x^3-x-1') +//deff ('[y]=g(x)','y=2*x^2 -1') +//x=newton(x,f,g); \ No newline at end of file diff --git a/60/CH4/EX4.21/ex_21.sce b/60/CH4/EX4.21/ex_21.sce index aee0e9737..a1542a30f 100755 --- a/60/CH4/EX4.21/ex_21.sce +++ b/60/CH4/EX4.21/ex_21.sce @@ -4,5 +4,5 @@ B=[1 2 0;2 1 0;0 0 -1] I=[1 0 0;0 1 0;0 0 1] //here we are taking lamda=a //det(B-a)*I=0 is characteristic equation to get lamda -deff('[y]=p(a)','p(a)=det(B-a)*I') -p(a)=0 \ No newline at end of file +deff('[y]=pa','pa=det(B-a)*I') +pa=0 \ No newline at end of file diff --git a/60/CH6/EX6.12/ex_12.sce b/60/CH6/EX6.12/ex_12.sce index 7eaa16436..5020647cb 100755 --- a/60/CH6/EX6.12/ex_12.sce +++ b/60/CH6/EX6.12/ex_12.sce @@ -1,15 +1,12 @@ - - - -/Example 6.12 +//Example 6.12 //Least squares approximation deff('[y]=f(x)','y=10-2*x+((x^2)/10)') -//we seek the polynomial of degree <= 2 which minimizes +//we seek the polynomial of degree <= 2 which minimizes //sum(n=1 to 9)[fn-p(xn)]^2 //we are dealing with scalar product with w(x)=1 -P0(x)=1 +P0x=1 //hence s0=0; B=0; @@ -36,7 +33,7 @@ x=poly(0,"x") y2=((x-B0)^2)-0.1166667 //similarly calculate s2 s2=0.05973332 -//p*(x)=(d0*)*P0(x)+(d1*)*P1(x)+(d2*)*P2(x) +//p*(x)=(d0*)*P0x+(d1*)*P1(x)+(d2*)*P2(x) //d0*=d0,d1*=d1,d2*=d2 are least squares approximation //d0*=d0=sigma(n=1 to 6)[fn/6] where fn=f(xn) @@ -49,5 +46,4 @@ p=d0+d1*(x-B0)+d2*{[(x-B0)^2]-C1} //c1=c1* ,c2=c2*,c3=c3* c1=9.99998 c2=-1.9999998 -c3=0.0999999 - \ No newline at end of file +c3=0.0999999 \ No newline at end of file -- cgit