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 --- 122/CH2/EX2.b.14/excB_2_14.sce | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 122/CH2/EX2.b.14/excB_2_14.sce (limited to '122/CH2/EX2.b.14/excB_2_14.sce') diff --git a/122/CH2/EX2.b.14/excB_2_14.sce b/122/CH2/EX2.b.14/excB_2_14.sce new file mode 100755 index 000000000..1fb9b25d4 --- /dev/null +++ b/122/CH2/EX2.b.14/excB_2_14.sce @@ -0,0 +1,31 @@ +// Exercise B-2-14 + +// An illustration on Linearization +// Linearize the function y = f(x) = 0.2*x^3 at x=2 +// SOLUTION : y = 2.4*x - 3.2 + +// Let us observe graphically the linear approximation +// and the error, and percentage error + +clear; clc; xdel(winsid()); + +x = 0.05:0.05:5; +y = 0.2 * x .^ 3; + +yl = 2.4 * x - 3.2 ; // this is not a linear system! +err = abs(y - yl); //Error in approximation +errpc = err ./ y * 100; //Percentage error + +subplot(2,1,1); +plot2d(x,y,style=2); +plot2d(x,yl,style=3,leg="linearized system"); +xtitle('Original and linearized system','x','y'); + +subplot(2,1,2); +plot2d(x,err,style=5); +xtitle('Error','x','error'); + +scf(); +plot2d(x,errpc,style=5,rect=[1 0 3 100]); +plot2d(x, 10 * ones(1,length(x)) ,style=2,leg="10% error margin" ); +xtitle('Percentage Error','x','% error'); -- cgit