5
1.5 a The first two steps are
BqL 8
. 9
1 .
10 2
. 10
1 .
= −
= c
BqL 604
. 9
1 .
8 .
9 2
. 8
. 9
2 .
= −
= c
The process can be continued to yield
t c dcdt 0 10.0000
-2.0000 0.1 9.8000
-1.9600 0.2 9.6040
-1.9208 0.3 9.4119
-1.8824 0.4 9.2237
-1.8447 0.5 9.0392
-1.8078 0.6 8.8584
-1.7717 0.7 8.6813
-1.7363 0.8 8.5076
-1.7015 0.9 8.3375
-1.6675 1 8.1707
-1.6341
b
The results when plotted on a semi-log plot yields a straight line
2 2.1
2.2 2.3
2.4
0.2 0.4
0.6 0.8
1
The slope of this line can be estimated as
20203 .
1 10
ln 1707
. 8
ln −
= −
Thus, the slope is approximately equal to the negative of the decay rate.
1.6 The first two steps yield
[ ]
16667 .
5 .
33333 .
5 .
1200 400
sin 1200
400 3
5 .
2
− =
− +
= ⎥⎦
⎤ ⎢⎣
⎡ −
+ =
y
[ ]
21841 .
5 .
333333 .
5 .
sin 16667
. 1
2
− =
− +
− =
y
6 The process can be continued to give
t y 0 0
0.5 -0.16667 1 -0.21841
1.5 -0.03104 2 0.299793
2.5 0.546537 3 0.558955
3.5 0.402245 4 0.297103
4.5 0.416811 5 0.727927
-0.4 0.4
0.8
1 2
3 4
5 y
1.7
1
t m
c
e c
gm t
v
⎟ ⎠
⎞ ⎜
⎝ ⎛
−
− =
jumper 1: s
m e
t v
87 .
44 1
5 .
12 1
. 68
8 .
9
10 1
. 68
5 .
12
= −
=
⎟ ⎠
⎞ ⎜
⎝ ⎛
−
jumper 2: 1
14 75
8 .
9 87
. 44
75 14
t
e
⎟ ⎠
⎞ ⎜
⎝ ⎛
−
− =
t
e
18666 .
5 .
52 5
. 52
87 .
44
−
− =
t
e
18666 .
14533 .
−
=
t
e
18666 .
ln 14533
. ln
−
=
t = 10.33 sec 1.8
Q
in
= Q
out
Q
1
= Q
2
+ Q
3
7 30 = 20 + vA
3
10 = 5 A
3
A
3
= 2 m
2
1.9
= ∑
− ∑
out in
M M
[ ] [
]
350 200
1400 200
400 50
MP 1200
1000 =
+ +
+ +
− +
+ +
Metabolic production = 300 grams
1.10
∑
= 60 t
body weigh
60 5
. 1
5 .
4 12
5 .
4 5
. 4
= +
+ +
+ +
IW
Intracellular water body weight = 33
60 5
. 1
5 .
4 12
5 .
4 5
. 4
= +
+ +
+ +
IW
∑
= 100 body water
100 55
5 .
7 20
5 .
7 5
. 7
= +
+ +
+ +
TW
Transcellular water of body water = 2.5
8
CHAPTER 2
2.1
q0 = 10;R = 50;L = 5;C = 1e-4; t = linspace0,.5;
q = q0exp-Rt2L.cossqrt1LC-R2L2t; plott,q
2.2
z = linspace-3,3; f = 1sqrt2piexp-z.22;
plotz,f xlabelz
ylabelfrequency
2.3 a
t = linspace5,30,6
9
t = 5 10 15 20 25 30
b x = linspace-3,3,7
x = -3 -2 -1 0 1 2 3
2.4 a
v = -2:.75:1 v =
-2.0000 -1.2500 -0.5000 0.2500 1.0000
b r = 6:-1:0
r = 6 5 4 3 2 1 0
2.5
F = [10 12 15 9 12 16]; x = [0.013 0.020 0.009 0.010 0.012 0.010];
k = F.x k =
1.0e+003 0.7692 0.6000 1.6667 0.9000 1.0000 1.6000
U = .5k.x.2 U =
0.0650 0.1200 0.0675 0.0450 0.0720 0.0800 maxU
ans = 0.1200
2.6
TF = 32:3.6:93.2; TC = 59TF-32;
rho = 5.5289e-8TC.3-8.5016e-6TC.2+6.5622e-5TC+0.99987; plotTC,rho
10
2.7
A = [.035 .0001 10 2; .02 .0002 8 1;
.015 .001 20 1.5; .03 .0007 24 3;
.022 .0003 15 2.5] A =
0.0350 0.0001 10.0000 2.0000 0.0200 0.0002 8.0000 1.0000
0.0150 0.0010 20.0000 1.5000 0.0300 0.0007 24.0000 3.0000
0.0220 0.0003 15.0000 2.5000 U = sqrtA:,2.A:,1.A:,3.A:,4.A:,3+2A:,4.23
U = 0.3624
0.6094 2.5167
1.5809 1.1971
2.8
t = 10:10:60; c = [3.4 2.6 1.6 1.3 1.0 0.5];
tf = 0:70; cf = 4.84exp-0.034tf;
plott,c,s,tf,cf,--
11
2.9
t = 10:10:60; c = [3.4 2.6 1.6 1.3 1.0 0.5];
tf = 0:70; cf = 4.84exp-0.034tf;
semilogyt,c,s,tf,cf,--
2.10
v = 10:10:80; F = [25 70 380 550 610 1220 830 1450];
vf = 0:100; Ff = 0.2741vf.1.9842;
plotv,F,d,vf,Ff,:
12
2.11
v = 10:10:80; F = [25 70 380 550 610 1220 830 1450];
vf = 0:100; Ff = 0.2741vf.1.9842;
loglogv,F,d,vf,Ff,:
2.12
x = linspace0,3pi2; c = cosx;
cf = 1-x.22+x.4factorial4-x.6factorial6; plotx,c,x,cf,--
13
14
CHAPTER 3
3.1
The M-file can be written as
function sincompx,n i = 1;
tru = sinx; ser = 0;
fprintf\n; fprintforder true value approximation error\n;
while 1 if i n, break, end
ser = ser + -1i - 1 x2i-1 factorial2i-1; er = tru - ser tru 100;
fprintf3d 14.10f 14.10f 12.8f\n,i,tru,ser,er; i = i + 1;
end
This function can be used to evaluate the test case,
sincomp1.5,8 order true value approximation error
1 0.9974949866 1.5000000000 -50.37669564 2 0.9974949866 0.9375000000 6.01456523
3 0.9974949866 1.0007812500 -0.32945162 4 0.9974949866 0.9973911830 0.01040643
5 0.9974949866 0.9974971226 -0.00021414 6 0.9974949866 0.9974949557 0.00000310
7 0.9974949866 0.9974949869 -0.00000003 8 0.9974949866 0.9974949866 0.00000000
3.2
The M-file can be written as
function futureworthP, i, n nn = 0:n;
F = P1+i.nn; y = [nn;F];
fprintf\n year future worth\n; fprintf5d 14.2f\n,y;
This function can be used to evaluate the test case,
futureworth100000,0.08,8 year future worth
0 100000.00 1 108000.00
2 116640.00 3 125971.20
4 136048.90 5 146932.81
6 158687.43 7 171382.43
8 185093.02
15
3.3
The M-file can be written as
function annualpaymentP, i, n nn = 1:n;
A = Pi1+i.nn.1+i.nn-1; y = [nn;A];
fprintf\n year annualpayment\n; fprintf5d 14.2f\n,y;
This function can be used to evaluate the test case,
annualpayment35000,.076,5 year annualpayment
1 37660.00 2 19519.34
3 13483.26 4 10473.30
5 8673.76
3.4
The M-file can be written as
function Tavg = avgtempTmean, Tpeak, tstart, tend omega = 2pi365;
t = tstart:tend; Te = Tmean + Tpeak-Tmeancosomegat-205;
Tavg = meanTe;
This function can be used to evaluate the test cases,
avgtemp5.2,22.1,0,59 ans =
-10.8418 avgtemp23.1,33.6,180,242
ans = 33.0398
3.5
The M-file can be written as
function vol = tankvolR, d if d R
vol = pi d 3 3; elseif d = 3 R
v1 = pi R 3 3; v2 = pi R 2 d - R;
vol = v1 + v2; else
errorovertop end
This function can be used to evaluate the test cases,
16
tankvol1,0.5 ans =
0.1309 tankvol1,1.2
ans = 1.6755
tankvol1,3.0 ans =
7.3304 tankvol1,3.1
??? Error using == tankvol overtop
3.6
The M-file can be written as
function [r, th] = polarx, y r = sqrtx . 2 + y . 2;
if x 0 if y 0
th = atany x + pi; elseif y 0
th = atany x - pi; else
th = pi; end
else if y 0
th = pi 2; elseif y 0
th = -pi 2; else
th = 0; end
end th = th 180 pi;
This function can be used to evaluate the test cases. For example, for the first case,
[r,th]=polar1,1 r =
1.4142 th =
90
The remaining cases are
17 x y r
θ 1
1 1.4142 90
1
−
1 1.4142
−
90 1
0 1.0000 0
−
1 1 1.4142 135
−
1
−
1 1.4142
−
135
−
1 0 1.0000 180
1 1.0000 90
−
1 1.0000
−
90 0 0.0000 0
3.7
The M-file can be written as
function polar2x, y r = sqrtx . 2 + y . 2;
n = lengthx; for i = 1:n
if xi 0 if yi 0
thi = atanyi xi + pi; elseif yi 0
thi = atanyi xi - pi; else
thi = pi; end
else if yi 0
thi = pi 2; elseif yi 0
thi = -pi 2; else
thi = 0; end
end thi = thi 180 pi;
end ou = [x;y;r;th];
fprintf\n x y radius angle\n; fprintf8.2f 8.2f 10.4f 10.4f\n,ou;
This function can be used to evaluate the test cases and display the results in tabular form,
polar2x,y x y radius angle
1.00 1.00 1.4142 90.0000 1.00 -1.00 1.4142 -90.0000
1.00 0.00 1.0000 0.0000 -1.00 1.00 1.4142 135.0000
-1.00 -1.00 1.4142 -135.0000 -1.00 0.00 1.0000 180.0000
0.00 1.00 1.0000 90.0000 0.00 -1.00 1.0000 -90.0000
0.00 0.00 0.0000 0.0000
18
3.8
The M-file can be written as
function grade = lettergradescore if score = 90
grade = A; elseif score = 80
grade = B; elseif score = 70
grade = C; elseif score = 60
grade = D; else
grade = F; end
This function can be tested with a few cases,
lettergrade95 ans =
A lettergrade45
ans = F
lettergrade80 ans =
B
3.9
The M-file can be written as
function ManningA A:,5 = sqrtA:,2.A:,1.A:,3.A:,4.A:,3+2A:,4.23;
fprintf\n n S B H U\n; fprintf8.3f 8.4f 10.2f 10.2f 10.4f\n,A;
This function can be run to create the table,
ManningA n S B H U
0.035 0.0001 10.00 2.00 0.3624 0.020 0.0002 8.00 1.00 0.6094
0.015 0.0010 20.00 1.50 2.5167 0.030 0.0007 24.00 3.00 1.5809
0.022 0.0003 15.00 2.50 1.1971
19
3.10
The M-file can be written as
function beamx xx = linspace0,x;
n=lengthxx; for i=1:n
uyi = -56.singxxi,0,4-singxxi,5,4; uyi = uyi + 156.singxxi,8,3 + 75singxxi,7,2;
uyi = uyi + 576.xxi3 - 238.25.xxi; end
plotxx,uy function s = singxxx,a,n
if xxx a s = xxx - a.n;
else s=0;
end
This function can be run to create the plot,
beam10
3.11
The M-file can be written as
function cylinderr, L h = linspace0,2r;
V = r2acosr-h.r-r-h.sqrt2rh-h.2L; ploth, V
This function can be run to the plot,
cylinder2,5
20
21
CHAPTER 4
4.1
The true value can be computed as 911
, 352
, 2
577 .
3 1
577 .
6 22
. 1
2 2
= ×
− =
f Using 3-digits with chopping
004 .
3 1
996 .
3 332
. 332929
. 577
. 46
. 3
462 .
3 577
. 6
6
2 2
chopping 2
chopping
= −
= ⎯
⎯ ⎯
→ ⎯
= =
⎯ ⎯
⎯ →
⎯ =
=
x x
x x
x
250 ,
216 004
. 46
. 3
996 .
1 46
. 3
577 .
2 2
= =
− =
f This represents a percent relative error of
8 .
90 911
, 352
, 2
250 ,
216 911
, 352
, 2
= −
=
t
ε
Using 4-digits with chopping
0013 .
3 1
9987 .
3 3329
. 332929
. 577
. 462
. 3
462 .
3 577
. 6
6
2 2
chopping 2
chopping
= −
= ⎯
⎯ ⎯
→ ⎯
= =
⎯ ⎯
⎯ →
⎯ =
=
x x
x x
x
521 ,
048 ,
2 0013
. 462
. 3
9987 .
1 462
. 3
577 .
2 2
= =
− =
f This represents a percent relative error of
9 .
12 911
, 352
, 2
521 ,
048 ,
2 911
, 352
, 2
= −
=
t
ε
Although using more significant digits improves the estimate, the error is still considerable. The problem stems primarily from the fact that we are subtracting two nearly equal numbers
in the denominator. Such subtractive cancellation is worsened by the fact that the denominator is squared.
4.2
First, the correct result can be calculated as 043053
. 35
. 37
. 1
8 37
. 1
7 37
. 1
2 3
= −
+ −
= y
22
a
Using 3-digits with chopping 1.37
3
→ 2.571353 → 2.57
–71.37
2
→ –71.87 → –13.0 81.37
→ 10.96 →
10.9 –
0.35 –0.12
This represents an error of
7 .
178 043053
. 12
. 043053
. =
− =
t
ε
b
Using 3-digits with chopping 35
. 37
. 1
8 37
. 1
7 37
. 1
− +
− =
y 35
. 37
. 1
8 37
. 1
63 .
5 −
+ ×
− =
y 35
. 37
. 1
8 71
. 7
− +
− =
y 35
. 37
. 1
29 .
− ×
= y
35 .
397 .
− =
y 047
. =
y This represents an error of
2 .
9 043053
. 47
. 043053
. =
− =
t
ε
Hence, the second form is superior because it tends to minimize round-off error.
4.3 a For this case, x