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 --- 964/CH23/EX23.1/23_1.sce | 20 ++++++++++++++++++++ 964/CH23/EX23.2/23_2.sce | 23 +++++++++++++++++++++++ 964/CH23/EX23.3/23_3.sce | 16 ++++++++++++++++ 964/CH23/EX23.4/23_4.sce | 16 ++++++++++++++++ 964/CH23/EX23.5/23_5.sce | 11 +++++++++++ 5 files changed, 86 insertions(+) create mode 100755 964/CH23/EX23.1/23_1.sce create mode 100755 964/CH23/EX23.2/23_2.sce create mode 100755 964/CH23/EX23.3/23_3.sce create mode 100755 964/CH23/EX23.4/23_4.sce create mode 100755 964/CH23/EX23.5/23_5.sce (limited to '964/CH23') diff --git a/964/CH23/EX23.1/23_1.sce b/964/CH23/EX23.1/23_1.sce new file mode 100755 index 000000000..4dffa8fe5 --- /dev/null +++ b/964/CH23/EX23.1/23_1.sce @@ -0,0 +1,20 @@ +//clc() +//f(x) = -0.1*x^4 - 0.15*x^3 - 0.5 * x^2 - 0.25 *x + 1.2 +h = 0.25; +t = -0.9125; +x = 0:h:1; +disp(x,"x = ") +fx = -0.1*x^4 - 0.15*x^3 - 0.5 * x^2 - 0.25 *x + 1.2; +disp(fx,"f(x) = ") +fd = (- fx(5) + 4*fx(4) - 3 * fx(3))/(2 * h); +efd = (t - fd) * 100 / t; +disp(fd,"by forward difference") +disp("%",efd,"error in forward difference method = ") +bd = (3 * fx(3) - 4 * fx(2) + fx(1))/ (2*h); +ebd = (t - bd) * 100 / t; +disp(bd,"by backward difference") +disp("%",ebd,"error in backward difference method = ") +cdm = (-fx(5) + 8*(fx(4)) -8*fx(2) + fx(1) ) / (12*h); +ecdm = (t - cdm) * 100 / t; +disp(cdm,"by central difference") +disp("%",ecdm,"error in central difference method = ") diff --git a/964/CH23/EX23.2/23_2.sce b/964/CH23/EX23.2/23_2.sce new file mode 100755 index 000000000..79ef27ace --- /dev/null +++ b/964/CH23/EX23.2/23_2.sce @@ -0,0 +1,23 @@ +//clc() +//f(x) = -0.1*x^4 - 0.15*x^3 - 0.5 * x^2 - 0.25 *x + 1.2 +h = 0.5; +t = -0.9125; +x = 0:h:1; +disp(x,"x with h = 0.5 is") +fx = -0.1*x^4 - 0.15*x^3 - 0.5 * x^2 - 0.25 *x + 1.2; +disp(fx,"f(x) with h = 0.5 is") +cdm = (fx(3) - fx(1))/ 1; +ecdm = (t - cdm) * 100 / t; +disp(cdm,"by central difference ( h = 0.5 ) ") +disp("%",ecdm,"error in central difference method ( h = 0.5 ) = ") +h1 = 0.25; +x1 = 0:h1:1; +disp(x1,"x with h = 0.25 is") +fx1 = -0.1*x1^4 - 0.15*x1^3 - 0.5 * x1^2 - 0.25 *x1 + 1.2; +disp(fx1,"fx with h = 0.25 is") +cdm1 = (fx1(4) - fx1(2))/ (2*h1); +ecdm1 = (t - cdm1) * 100 / t; +disp(cdm1,"by central difference ( h = 0.25 ) ") +disp("%",ecdm1,"error in central difference method ( h = 0.25 ) = ") +D = 4 * cdm1 /3 - cdm / 3; +disp(D,"improved estimate =") diff --git a/964/CH23/EX23.3/23_3.sce b/964/CH23/EX23.3/23_3.sce new file mode 100755 index 000000000..0a8a054e3 --- /dev/null +++ b/964/CH23/EX23.3/23_3.sce @@ -0,0 +1,16 @@ +//clc() +//q(z = 0) = -k*p*C*(dT/dz)/(z = 0) +k = 3.5 * 10^ - 7;//m^2/s +p = 1800;//kg/m^3 +C = 840; //(J/(kg.C)) +x = 0; +fx0 = 13.5; +fx1 = 12; +fx2 = 10; +x0 = 0; +x1 = 1.25; +x2 = 3.75; +dfx = fx0 *(2*x - x1 - x2)/((x0 - x1)*(x0 - x2)) + fx1 *(2*x - x0 - x2)/((x1 - x0)*(x1 - x2)) + fx2 *(2*x - x1 - x0)/((x2 - x1)*(x2 - x0)); +disp("C/cm",dfx,"(dT/dz) = ") +q = - k * p *C * dfx*100; +disp("W/m^2",q,"q(z = 0) =") diff --git a/964/CH23/EX23.4/23_4.sce b/964/CH23/EX23.4/23_4.sce new file mode 100755 index 000000000..6f58bba83 --- /dev/null +++ b/964/CH23/EX23.4/23_4.sce @@ -0,0 +1,16 @@ +clc; +clear; +function y=f(x) + y=0.2+25*x-200*x^2+675*x^3-900*x^4+400*x^5 +endfunction +a=0; +b=0.8; +Q=intg(0,0.8,f); +disp(Q,"Q=") +x=[0 0.12 0.22 0.32 0.36 0.4 0.44 0.54 0.64 0.7 0.8]; +y=f(x); +integral=inttrap(x,y) +disp(integral,"intergral=") +disp(diff(x),"diff(x)=") +d=diff(y)./diff(x); +disp(d,"d=") diff --git a/964/CH23/EX23.5/23_5.sce b/964/CH23/EX23.5/23_5.sce new file mode 100755 index 000000000..cc5f2987d --- /dev/null +++ b/964/CH23/EX23.5/23_5.sce @@ -0,0 +1,11 @@ +clc; +clear; +function y=f(x) + y=0.2+25*x-200*x^2+675*x^3-900*x^4+400*x^5 +endfunction +a=0; +b=0.8; +Qt=1.640533; +Q=intg(0,0.8,f); +disp(Q,"Computed=") +disp(abs(Q-Qt)*100/Qt,"Error estimate=") -- cgit