diff options
author | priyanka | 2015-06-24 15:03:17 +0530 |
---|---|---|
committer | priyanka | 2015-06-24 15:03:17 +0530 |
commit | b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b (patch) | |
tree | ab291cffc65280e58ac82470ba63fbcca7805165 /243/CH4/EX4.21 | |
download | Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.tar.gz Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.tar.bz2 Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.zip |
initial commit / add all books
Diffstat (limited to '243/CH4/EX4.21')
-rwxr-xr-x | 243/CH4/EX4.21/4_21.sce | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/243/CH4/EX4.21/4_21.sce b/243/CH4/EX4.21/4_21.sce new file mode 100755 index 000000000..7933b6738 --- /dev/null +++ b/243/CH4/EX4.21/4_21.sce @@ -0,0 +1,17 @@ +//Example 4_21
+//Pg No. 85
+clear ; close ; clc ;
+
+x = -10
+T_act(1) = 1
+T_trc(1) = 1
+e_x_cal = 1
+for i = 1:100
+ T_act(i+1) = T_act(i)*x/i
+ T_trc(i+1) = floor(T_act(i+1)*10^5)/10^5
+ TE(i) = abs(T_act(i+1)-T_trc(i+1))
+ e_x_cal = e_x_cal + T_trc(i+1)
+end
+e_x_act = exp(-10)
+disp(e_x_act,'actual e^x = ',e_x_cal,'calculated e^x using roundoff = ',sum(TE),'Truncation Error = ')
+disp('Here we can see the difference between calculated e^x and actual e^x this is due to trucation error (which is greater than final value of e^x ), so the roundoff error totally dominates the solution')
\ No newline at end of file |