Solutions to Problems in Chapter Five

advertisement
Solutions to Problems in Chapter Five
Test Your Understanding Problems
T5.1-1 The session is
x = [0:.1:35];
y = .4*sqrt(1.8*x);
plot(x,y),xlabel(0Distance (miles)0), ...
ylabel(0Height (miles)0),axis([0 35 0 3.5]),...
title(0Rocket Height as a Function of Downrange Distance0)
The plot is shown in the figure.
Rocket Height as a Function of Downrange Distance
3.5
3
Height (miles)
2.5
2
1.5
1
0.5
0
0
5
10
15
20
Distance (miles)
25
Figure : for Problem T5.1-1.
5-1
30
35
T5.1-2 The session is
x = [0:.01:2*pi];
f = 0 tan(cos(x))-sin(tan(x))0;
fplot(f,[0 2*pi])
[x,y] = fplot(f,[0 2*pi]);
size(x)
ans =
292 1
The plot shown in the figure was generated with the fplot command. It would take 292
values of x to obtain the same plot using the plot command.
2
1.5
1
0.5
0
−0.5
−1
−1.5
−2
0
1
2
3
4
Figure : for Problem T5.1-2.
5-2
5
6
T5.1-3 The session is
z = .2+.8i;
n = [0:.01:20];
plot(z.^n),xlabel(0Real0 ),ylabel(0 Imaginary0),...
title(0Plot of (0.2+0.8i)^n for n = [0,20]0 ),...
axis([-1 1 -1 1])
The plot is shown in the figure.
Plot of (0.2+0.8i)^n for n = [0,20]
1
0.8
0.6
0.4
Imaginary
0.2
0
−0.2
−0.4
−0.6
−0.8
−1
−1
−0.8
−0.6
−0.4
−0.2
0
Real
0.2
0.4
Figure : for Problem T5.1-3.
5-3
0.6
0.8
1
T5.2-1 The session is
t = [0:.01:8];v = [-8:.01:8];
z = exp(-.5*t).*cos(20*t-6);
u = 6*log10(v.^2+20);
subplot(2,1,1)
plot(t,z),xlabel(0t0 ),ylabel(0z0 )
subplot(2,1,2)
plot(v,u),xlabel(0v0 ),ylabel(0u0 )
The plots are shown in the figure.
1
0.5
z
0
−0.5
−1
0
1
2
3
4
t
5
6
7
8
−6
−4
−2
0
v
2
4
6
8
12
11
u
10
9
8
7
−8
Figure : for Problem T5.2-1.
5-4
T5.2-2 The session is
x = [0:5];y1 = [11,13,8,7,5,9];
y2 = [2,4,5,3,2,4];
plot(x,y1,0*0 ,x,y2,0 +0 ,x,y1,x,y2, 0 --0 ),...
xlabel(0x0 ),ylabel(0y1, y20 ),...
legend(0y10 ,0 y20 )
Note that the legend command acts on the first two pairs in the plot command. The plot
is shown in the figure.
14
y1
y2
12
y1, y2
10
8
6
4
2
0
0.5
1
1.5
2
2.5
x
3
3.5
Figure : for Problem T5.2-2.
5-5
4
4.5
5
T5.2-3 The session is
x = [0:.01:2];
y1 = cosh(x);y2 = .5*exp(x);
plot(x,y1,x,y2,0-- 0 ),xlabel(0x0 ),ylabel(0y0 ),...
legend(0cosh(x)0,0 0.5exp(x)0)
The plot is shown in the figure.
4
3.5
3
cosh(x)
0.5exp(x)
y
2.5
2
1.5
1
0.5
0
0.2
0.4
0.6
0.8
1
x
1.2
1.4
1.6
Figure : for Problem T5.2-3.
5-6
1.8
2
T5.2-4 The session is
x = [0:.01:2];
y1 = sinh(x);y2 = .5*exp(x);
plot(x,y1,x,y2),xlabel(0x0 ),ylabel(0y0 ),...
gtext(0sinh(x)0 ),gtext(00.5exp(x)0)
The plot is shown in the figure.
4
3.5
3
y
2.5
2
1.5
1
0.5exp(x)
0.5
0
0
sinh(x)
0.2
0.4
0.6
0.8
1
x
1.2
1.4
1.6
Figure : for Problem T5.2-4.
5-7
1.8
2
T5.2-5 The session is
x = [0:.01:1];
y1 = sin(x);y2 = x-x.^3/3;
plot(x,y1),gtext(0sin(x)0 ),hold,plot(x,y2),xlabel (0 x0 ),ylabel(0y0 ),...
gtext(0x-x^3/30)
The plot is shown in the figure. Note that the order of the gtext commands is important.
The first gtext command should come before the hold command. The second gtext
command must come after the second plot statement.
0.9
0.8
0.7
sin(x)
0.6
x−x^3/3
y
0.5
0.4
0.3
0.2
0.1
0
0
0.1
0.2
0.3
0.4
0.5
x
0.6
0.7
0.8
Figure : for Problem T5.2-5.
5-8
0.9
1
T5.3-1 The session is
x = [0:.01:1.5];
y1 = 2*x.^(-.5);y2 = 10.^(1-x);
subplot(2,2,1)
plot(x,y1,x,y2,0-- 0 ),gtext(0Power0 ),...
gtext(0Exponential0),xlabel(0x0 ), ylabel(0 y0 )
subplot(2,2,2)
semilogy(x,y1,x,y2,0-- 0 ),gtext(0Power0 ),...
gtext(0Exponential0),xlabel(0x0 ), ylabel(0 y0 )
subplot(2,2,3)
loglog(x,y1,x,y2,0-- 0 ),xlabel(0x0 ),ylabel(0y0 ),...
axis([.01 1.5 .1 20]),gtext(0Power0 ),gtext(0Exponential0)
The plot is shown in the text. Note that the order of the gtext commands is important.
With the third plot, the gtext commands should come after the axis command, because
the plot will be resized on the screen when the axis command is executed. If we put
the gtext commands before the axis command, we cannot place the curve labels in their
correct positions.
5-9
T5.3-2 The session is
x = [-1:.01:1];
y =8*x.^3;
plot(x,y),set(gca,0XTick0 ,[-1:.25:1],0YTi ck0 ,[-8:2:8]),...
xlabel(0x0 ),ylabel(0y0 ),title(0y = 8x^30 )
The plot is shown in the figure.
y = 8x^3
8
6
4
y
2
0
−2
−4
−6
−8
−1
−0.75
−0.5
−0.25
0
x
0.25
0.5
Figure : for Problem T5.3-2.
5-10
0.75
1
T5.3-3 The session is
theta = [0:.01:4*pi];
r = 2*theta;
polar(theta,r),title(0Spiral of Archimedes, r = 2*theta0)
The plot is shown in the figure.
Spiral of Archimedes, r = 2*theta
90
30
120
60
20
150
30
10
180
0
330
210
240
300
270
Figure : for Problem T5.3-3.
5-11
T5.6-1 The m-file is
x = [0:5];
y = [0,1,60,40,41,47];
xp = [0:.01:5];
for k = 1:4
polyfit(x,y,k)
yp(k,:) = polyval(polyfit(x,y,k),xp);
J(k) = sum((polyval(polyfit(x,y,k),x)-y).^2);
end
for k = 1:4
subplot(2,2,k)
plot(xp,yp(k,:),x,y,0o0 ),axis([0 5 0 75])
end
J
The coefficients for the first-order polynomial are 9.5714 and 7.5714. The polynomial is
y = 9.5714x + 7.5714. The coefficients for the second-order polynomial are −3.696, 28.0535,
and −4.75. The polynomial is y = −3.6964x2 + 28.053x − 4.75.
The coefficients for the third-order polynomial are 0.3241, −6.127, 32.493, and −5.7222.
The polynomial is y = 0.3241x3 −6.127x2 +32.493x−5.7222. The coefficients for the fourthorder polynomial are 2.5208, −24.8843, 71.2986, −39.5304 and −1.4008. The polynomial is
y = 2.5208x4 − 24.8843x3 + 71.2986x2 − 39.5304x − 1.4008. The J values are 1534.3, 1024.2,
1017.4, and 494.5 respectively. The plots of the polynomials and the data are shown in the
figure.
80
80
60
60
40
40
20
20
0
0
−20
0
1
2
3
4
−20
0
80
80
60
60
40
40
20
20
0
0
−20
0
1
2
3
4
−20
0
5-12
1
2
3
4
1
2
3
4
T5.8-1 The session for the surface plot is
[X,Y] = meshgrid(-5:.5:5);
Z = (X-2).^2+2*X.*Y+Y.^2;
mesh(X,Y,Z),xlabel(0x0 ),ylabel(0y0 ),zlabel(0z0 )
The surface plot is shown in the figure.
150
z
100
50
0
−50
5
5
0
0
y
−5
−5
x
Figure : for Problem T5.8-1.
5-13
To generate the contour plot, replace the last line in the above session with
contour(X,Y,Z),xlabel(0x0 ),ylabel(0y0 ), zlabel(0 z0 )
The contour plot is shown in the figure.
5
4
3
2
y
1
0
−1
−2
−3
−4
−5
−5
−4
−3
−2
−1
0
x
1
2
Figure : for Problem T5.8-1.
5-14
3
4
5
End-of-Chapter Problems
1. A script for this problem is:
Q = [0:200]*1.0e+6;
revenue = .055*Q*1.0e-6;
cost = 3+.025*Q*1.0e-6;
plot(Q*1.0e-6,revenue),gtext(0Revenue0),hold,...
plot(Q*1.0e-6,cost),gtext(0Cost0 ),xlabel(0Q (millions of gallons)0),...
ylabel(0Revenue and Cost (millions of dollars)0),gtext(0Breakeven Point0 )
The plot is shown in the figure. The breakeven point is at Q = 100 million gallons, so
production is profitable for any Q value greater than 100 million gallons. According to the
model presented in this problem, there is no upper limit on the profit.
12
Revenue and Cost (millions of dollars)
10
8
Cost
6
Breakeven Point
4
2
Revenue
0
0
20
40
60
80
100
120
Q (millions of gallons)
140
Figure : for Problem 1.
5-15
160
180
200
2. Solve the price equation for P to obtain P = (6 × 106 − Q)/1.1 × 106 . Thus the revenue
is ((6 × 106 − Q)/1.1 × 106 )Q. A script file to solve this problem is shown in the figure.
Q = [0:.01:8]*1.0e+6;
revenue = ((6e+6-Q)/1.1e+6).*Q;
cost = 2.045e+6+(.62+.24+.16)*Q;
plot(Q*1.0e-6,revenue*1.0e-6),gtext(0Revenue0), hold,...
plot(Q*1.0e-6,cost*1.0e-6),gtext(0Cost0 ),...
xlabel(0Q (millions of gallons)0),...
ylabel(0Revenue and Cost (millions of dollars)0),...
gtext(0Breakeven Point 10 ),...
gtext(0Breakeven Point 20 ),grid
The plot is shown in the figure.
15
Revenue and Cost (millions of dollars)
10
Breakeven Point 2
Cost
5
Breakeven Point 1
0
−5
−10
Revenue
−15
0
1
2
3
4
5
Q (millions of gallons)
6
7
8
Figure : for Problem 2.
The breakeven points are at approximately Q = 0.5 and Q = 4.4 million gallons. Any
value of Q between these values will be profitable. Producing less than 0.5 million gallons
will be unprofitable because of the fixed costs. Producing more than 4.4 million gallons will
be unprofitable because the selling price will drop too much.
5-16
3. Preliminary plots show that the roots are between −1 ≤ x ≤ 5. The final plot is obtained
with the following session.
x = [-1:.01:5];
plot(x,4*x.^5+3*x.^4-95*x.^3 + 5*x.^2-10*x+80),...
xlabel(0x0 ),ylabel(0p(x)0 ),grid
The plot is shown in the figure. The roots read off the plot are approximately x = 1 and
x = 4.5.
3000
2500
2000
1500
p(x)
1000
500
0
−500
−1000
−1500
−1
0
1
2
x
3
Figure : for Problem 3.
5-17
4
5
4. The fplot command was used repeatedly to home in on the roots.The session I used is
shown below.
fplot(0x*tan(x)-70,[0 10])
fplot(0x*tan(x)-70,[1 2])
fplot(0x*tan(x)-70,[1.5 2])
fplot(0x*tan(x)-70,[1.5 1.6])
fplot(0x*tan(x)-70,[4 5])
fplot(0x*tan(x)-70,[4.6 4.8])
fplot(0x*tan(x)-70,[7 8])
fplot(0x*tan(x)-70,[7.8 7.9])
The roots are x = 1.57, 4.71, and 7.85.
5-18
5. The session is shown below.
x = [-20:.01:30];
y = 10*cosh(x/10);
plot(x,y),xlabel(0x (meters)0),ylabel(0y (meters)0)
The plot is shown in the figure. The endpoints read off the plot are approximately 37 meters
above the bottom point on the left (47 meters above the horizontal reference line), and 100
meters on the right (110 meters above the reference line). More precise values can be found
by typing x = -20;10*cosh(x/10) to obtain 37.622 meters above the lowest point, and x
= 30;10*cosh(x/10) to obtain 100.6766 meters above the lowest point.
110
100
90
80
y (meters)
70
60
50
40
30
20
10
−20
−15
−10
−5
0
5
10
x (meters)
15
Figure : for Problem 5.
5-19
20
25
30
6. The initial volume is 1000 million gallons. Use the ginput function to locate the point
where the volume is 500 million gallons. The script file is:
t = [0:0.2:100];
V = (1e+9 + 1e+8*(1-exp(-t/100))-1e+7*t)/(1e+6);
plot(t,V),xlabel(0Time (days)0),...
ylabel(0Water Volume (millions of gallons)0),grid,...
[Time, Volume] = ginput(1)
The answer is 54.4 days.
7. The session is:
A = [0,-8,6;5,-4,3;10,-1,1;
15,1,0;20,2,-1];
plot(A(:,1),A(:,2:3))
plot(A(:,1),A(:,2:3)),xlabel(0Time (seconds)0),ylabel(0Force (Newtons)0),...
gtext(0Column 10 ),gtext(0Column 20 )
The plot is shown in the figure.
6
4
Column 2
Force (Newtons)
2
0
−2
−4
Column 1
−6
−8
0
2
4
6
8
10
12
Time (seconds)
14
Figure : for Problem 7.
5-20
16
18
20
8. The script file is
x = [0:.01:1];
subplot(2,2,1)
plot(x,sin(x),x,x),xlabel(0x (radians)0),ylabel(0x and sin(x)0),...
gtext(0 x0 ),gtext(0sin(x)0)
subplot(2,2,2)
plot(x,sin(x)-x),xlabel(0x (radians)0),ylabel(0Error: sin(x) - x0 )
subplot(2,2,3)
plot(x,100*(sin(x)-x)./sin(x)),xlabel(0x (radians)0),...
ylabel(0Percent Error0 ),grid
The plots are shown in the figure.
1
0
x and sin(x)
0.6
Error: sin(x) − x
x
0.8
sin(x)
0.4
0.2
0
0
0.5
x (radians)
1
0.5
x (radians)
1
−0.05
−0.1
−0.15
−0.2
0
0.5
x (radians)
1
Percent Error
0
−5
−10
−15
−20
0
Figure : for Problem 8.
From the third plot we can see that the approximation sin x ≈ x is accurate to within
5% if |x| ≤ 0.5 radians.
5-21
9. The session is:
x =[0:.01:2*pi];
left = tan(2*x);
right = 2*tan(x)./(1-tan(x).^2);
plot(x,left,x,right),xlabel(0x (radians)0),...
ylabel(0Left and Right Sides0 )
The plot is shown in the figure. The two curves are identical; thus the identity is correct
for 0 ≤ x ≤ 2π.
100
50
Left and Right Sides
0
−50
−100
−150
−200
−250
0
1
2
3
4
5
x (radians)
Figure : for Problem 9.
5-22
6
7
10. If the identity is correct, the real parts of the left and right sides of the equation should
be equal, and the imaginary parts should be equal. The session is:
x =[0:.01:2*pi];
real_left = real(exp(i*x));
real_right = real(cos(x)+i*sin(x));
imag_left = imag(exp(i*x));
imag_right = imag(cos(x)+i*sin(x));
plot(x,real_left,x,real_right,x,imag_left, 0 --0 , x,imag_right,0--0 ),...
xlabel(0x (radians)0),...
gtext(0Real Part0 ),gtext(0Imaginary Part0 )
The plot is shown in the figure. The two curves for the real parts are identical, and the two
curves for the imaginary parts are identical; thus the identity is correct for 0 ≤ x ≤ 2π.
1
0.8
Imaginary Part
0.6
0.4
0.2
0
−0.2
−0.4
−0.6
−0.8
−1
0
Real Part
1
2
3
4
5
x (radians)
Figure : for Problem 10.
5-23
6
7
11. If the identity is correct, the real parts of the left and right sides of the equation should
be equal, and the imaginary parts should be equal. The session is:
x = [0:.01:5];
real_left = real(sin(i*x));
imag_left = imag(sin(i*x));
real_right = real(i*sinh(x));
imag_right = imag(i*sinh(x));
plot(x,real_left,x,real_right,x,imag_left, 0 --0 ,x,imag_right,0-- 0 ),...
xlabel(0x0 ),gtext(0Real Parts0 ),gtext(0Imaginary Parts0 )
The plot is shown in the figure. The two curves for the real parts are identical, and the
two curves for the imaginary parts are identical; thus the identity is correct for 0 ≤ x ≤ 5.
In addition, because the real parts are zero, we can conclude that sin ix and i sinh x are
purely imaginary.
80
70
60
50
40
30
Imaginary Parts
20
10
Real Parts
0
0
0.5
1
1.5
2
2.5
x
3
3.5
Figure : for Problem 11.
5-24
4
4.5
5
12. As t → ∞, e−bt → 0 if b > 0. Thus y(t) → 1 as t → ∞. Solve y(t) = 1 − e−bt for e−bt
to obtain
e−bt = 1 − y(t)
Take the natural log of both sides to obtain
ln e−bt = −bt ln(e) = −bt = ln [1 − y(t)]
using the fact that ln(e) = 1. Thus, when y(t) equals 98% of its final or steady state value
of 1, y = 0.98, and the above equation gives
−bt = ln(1 − 0.98) = ln(0.02) = −3.912
Thus, y(t) reaches 98% of its final value at t = 3.912/b. The following script file produces
the plot shown in the figure, using b = 2, 3, 5, and 10.
b = [2,3,5,10];
plot(t,1-exp(-b(1)*t),t,1-exp(-b(2)*t),0-- 0 ,t,1-exp(-b(3)*t),...
0 -.0 ,t,1- exp(-b(4)*t),0:0 ),...
xlabel(0t0 ),ylabel(0y(t)0 ),...
title(0The function y(t) = 1 - xp(- bt)0 ),...
legend(0b=20 ,0 b=30 ,...
0 b=50 ,0 b=100 )
The plot is shown in the figure.
The function y(t) = 1 − exp(−bt)
1
0.9
0.8
0.7
y(t)
0.6
0.5
b=2
b=3
b=5
b=10
0.4
0.3
0.2
0.1
0
0
0.5
1
1.5
t
2
2.5
Figure : for Problem 12.
5-25
3
13. The functions e−0.5t and e−0.4t will be very small for t > 10, so we can set t = 10
as the upper limit for the plot. The function sin(3t + 2) oscillates with a period equal to
2π/3 = 2.09, and the function cos(5t − 3) oscillates with a period equal to 2π/5 = 1.26. If
we select an increment for t that is very small relative to the smallest period (1.26), the plot
will properly display the oscillations. Thus an increment of 0.02 will be small enough (This
increment will give more than 50 points per period.) The following script file produces the
plot shown in the figure.
t = [0:.02:10];
x = 10*exp(-.5*t).*sin(3*t+2);
y = 7*exp(-.4*t).*cos(5*t-3);
plot(t,x,t,y,0:0 ),xlabel(0t0 ),yla bel(0 x(t), y(t)0 ),legend(0x(t)0 ,0 y(t)0 )
10
8
6
x(t)
y(t)
x(t), y(t)
4
2
0
−2
−4
−6
−8
0
1
2
3
4
5
t
6
7
Figure : for Problem 13.
5-26
8
9
10
14. The script file is
elongation1 = [0:10];
elongation2 = [1:10];
increasing = [0,3500,6300,9200,11500,13000,13500,13900,14100,14300,14500];
decreasing = [0,3000,6000,8800,11100,12300,13500,14000,14300,14500];
plot(elongation1,increasing,elongation2,decreasing),...
xlabel(0Elongation (Thousands of an Inch)0 ),ylabel(0Tension Force (lbs)0 ),...
gtext(0Increasing0), gtext(0 Decreasing0)
The plot is shown in the figure.
15000
Tension Force (lbs)
Increasing
10000
Decreasing
5000
0
0
1
2
3
4
5
6
7
Elongation (Thosands of an Inch)
Figure : for Problem 14.
5-27
8
9
10
15. The session is:
t = [0:.02:20];
y = (1/(64-1))*(cos(8*t)-cos(t));
plot(t,y),xlabel(0t (seconds)0),ylabel(0Displacement y (Inches)0)
The plot is shown in the figure.
0.04
0.03
Displacement y (Inches)
0.02
0.01
0
−0.01
−0.02
−0.03
−0.04
0
2
4
6
8
10
12
t (seconds)
14
Figure : for Problem 15.
5-28
16
18
20
16. The script file for parts (a) and (b) is
g = 9.81;
% Part a
v = 10;A = 35*(pi/180);
t_hit = (2/g)*v*sin(A);
t = [0:t_hit/1000:t_hit];
h = v*t*sin(A)-.5*g*t.^2;
[peak_height,i_peak] = max(h);
t_peak = i_peak*t_hit/1000;
peak_height
distance = v*t_hit*cos(A)
t_hit
% Part b
x=v*t*cos(A);
plot(x,h),xlabel(0Distance (meters)0),ylabel(0Height (meters)0)
When this file is run, it produces
peak_height =
1.6768
distance =
9.5789
t_hit =
1.1694
The plot is shown in the figure.
The script file for part (c) is shown in the figure. Note that t_hit is now a vector. The
matrix X has five columns, one column for each value of A, and represents the horizontal
distance vt cos(A). The matrix R has five columns, and represents 0.5gt2 . The matrix Q
also has five columns, one column for each value of A, and represents vt sin(A). The matrix
R has five columns; each column represents the height as a function of time, for a particular
value of A.
g = 9.81;
v = 10;A = [20,30,45,60,70]*(pi/180);
t_hit = (2/g)*v*sin(A);
t = [0:max(t_hit)/1000:max(t_hit)]0;
sA = sin(A);
cA = cos(A);
r = .5*g*t.^2;
X = v*[t*cA(1),t*cA(2),t*cA(3),t*cA(4),t*cA(5)];
5-29
1.8
1.6
1.4
Height (meters)
1.2
1
0.8
0.6
0.4
0.2
0
0
1
2
3
4
5
6
Distance (meters)
7
8
9
10
Figure : for Problem 16b.
r = .5*g*t.^2;
R = [r,r,r,r,r];
Q = v*[t*sA(1),t*sA(2),t*sA(3),t*sA(4),t*sA(5)];
H = Q-R;
max_x = v*t_hit(3)*cA(3);
plot(X,H),axis([0 max_x 0 max(max(H))]),xlabel(0Distance (m)0 ),...
ylabel(0Height (m)0 ),gtext(0 20 deg0 ),gtext(030 deg0 ),...
gtext(045 deg0 ),gtext(060 deg0 ),gtext(070 deg0 )
The plot is shown in the figure.
4.5
70 deg
4
3.5
60 deg
Height (m)
3
2.5
45 deg
2
1.5
30 deg
1
0.5
0
0
20 deg
1
2
3
4
5
6
Distance (m)
7
8
9
Figure : for Problem 16c.
5-30
10
The script file for part (d) is shown below. It is similar to that for part (c), except the
five columns correspond to the five values of v.
g = 9.81;A = 45*(pi/180);
v = [10:2:18];
t_hit = (2/g)*v*sin(A);
t = [0:max(t_hit)/1000:max(t_hit)]0;
r = .5*g*t.^2;
X = cos(A)*[t*v(1),t*v(2),t*v(3),t*v(4),t*v(5)];
R = [r,r,r,r,r];
Q = sin(A)*[t*v(1),t*v(2),t*v(3),t*v(4),t*v(5)];
H = Q-R;
plot(X,H),axis([0 max(max(X)) 0 max(max(H))]),xlabel(0Distance (m)0 ),...
ylabel(0Height (m)0 ),gtext(0 10 m/s0 ),gtext(012 m/s0 ),...
gtext(014 m/s0 ),gtext(016 m/s0 ),gtext(018 m/s0 )
The plot is shown in the figure.
8
18 m/s
7
6
16 m/s
Height (m)
5
14 m/s
4
3
12 m/s
2
10 m/s
1
0
0
5
10
15
20
Distance (m)
25
30
Figure : for Problem 16d.
5-31
17. The script file is
R = 286.7;T = 293;
m = [1,3,7];
V = [20:1:100];
p = R*T*[m(1)./V;m(2)./V;m(3)./V];
plot(V,p),xlabel(0Volume V (m^3)0 ),ylabel(0Pressure p (N/m^2)0 ),...
gtext(01 kg0 ),gtext(03 kg0 ),...
gtext(07 kg0 )
The plot is shown in the figure.
4
3
x 10
Pressure p (N/m^2)
2.5
2
7 kg
1.5
1
0.5
0
20
3 kg
1 kg
30
40
50
60
70
Volume V (m^3)
80
Figure : for Problem 17.
5-32
90
100
18. The oscillations are essentially finished after t = 4τ , so choose 4τ as the upper limit.
Because 400 points are usually sufficient for plotting, choose the spacing to be no greater
than 4τ /400, or τ /100. The t values must be spaced close enough to capture any oscillations
and rapidly decaying functions. Usually 100 points are sufficient to plot one period of an
oscillation, so choose the spacing to equal (2π/ω)/100 unless this gives a spacing greater
than τ /100.
For part (a), τ = 10 and 2π/ω = 2. A spacing of τ /100 gives 0.1, while a spacing of
(2π/ω)/100 gives 0.02. Choose the smaller value, 0.02.
For part (b), τ = 0.1 and 2π/ω = 0.25. A spacing of τ /100 gives 0.001, while a spacing
of (2π/ω)/100 gives 0.0025. Choose the smaller value, 0.001.
The script file for part (a) is
t = [0:.02:40];
y = exp(-t/10).*sin(pi*t+2);
plot(t,y),xlabel(0t0 ),ylabel(0y0 )
The script file for part (b) is
t = [0:.001:.4];
y = exp(-t/.1).*sin(8*pi*t+2);
plot(t,y),xlabel(0t0 ),ylabel(0y0 )
The plots are shown in the figure.
1
y
0.5
0
−0.5
−1
0
5
10
15
20
t
25
30
35
40
0
0.05
0.1
0.15
0.2
t
0.25
0.3
0.35
0.4
1
0.8
0.6
y
0.4
0.2
0
−0.2
−0.4
Figure : for Problem 18.
5-33
19. The plot of the data shown in the figure is obtained from the following session.
t = [0:8,10];
s = [0,1210,1866,2301,2564,2724,2881,2879,2915,3010];
plot(t,s,0*0 ,t,s,0 -- 0 ),xlabel(0Time (sec)0 ),ylabel(0Speed (rpm)0 )
3500
3000
Speed (rpm)
2500
2000
1500
1000
500
0
0
1
2
3
4
5
Time (sec)
6
7
Figure : for Problem 19.
5-34
8
9
10
As t → ∞, ect → 0 if c < 0. Thus s(t) → b as t → ∞. Examining the data we see that
the speed approaches 3010 rpm. Thus we take b = 3010. Note also that ect < 0.0183 if
t > 4/c. From the plot, we see that this time is approximately 10 seconds. Thus we take
4/c = 10, or c = 0.4. Thus the function is s(t) = 3010(1 − e−0.4t ). This function is plotted
in the figure along with the data. The session to produce this plot is a continuation of the
above session.
s = 3010*(1-exp(-.4*t));
plot(t,s,0*0 ,t,s),xlabel(0Time (sec)0 ),ylabel(0Speed (rpm)0 )
The plot shows that this function describes the data well.
3000
2500
Speed (rpm)
2000
1500
1000
500
0
0
1
2
3
4
5
Time (sec)
6
7
Figure : for Problem 19.
5-35
8
9
10
20. The M-file is:
Year = [1990:1994];
Temp = [18,19,21,17,20];
subplot(2,2,1)
stem(Year,Temp),xlabel(0Year0 ), ylabel(0Temperature (Deg. C)0 )
subplot(2,2,2)
bar(Year,Temp),xlabel(0Year0 ), ylabel(0 Temperature (Deg. C)0 )
subplot(2,2,3)
stairs(Year,Temp),xlabel(0Year0 ),ylabel(0 Temperature (Deg. C)0 )
The plots are shown in the figure. The autoscaling feature chose 1985 for the lower limit of
the bar plot. If you wish to change it, you can replace the line containing the bar command
with the following:
bar(Year,Temp),xlabel(0Year0 ), ylabel(0 Temperature (Deg.
axis([1990 1994 0 25])
25
Temperature (Deg. C)
Temperature (Deg. C)
25
20
15
10
5
0
1990
1991
1992
Year
1993
1994
1991
1992
Year
1993
1994
20
15
10
5
0
1985
1990
Year
Temperature (Deg. C)
21
20
19
18
17
1990
C)0 ),...
Figure : for Problem 20.
5-36
1995
21. The M-file is:
k = [1:10];
Money = 1.0e+4*(1.05).^k;
subplot(2,2,1)
plot(k,Money,0-- 0 ,Year,Money,0*0 ),ylabel(0Dollars 0 ),xlabel(0Year0 )
subplot(2,2,2)
stem(k,Money),ylabel(0Dollars0), xlabel(0Year0 ),ylabel(0Dollars0), xlabel(0Year0 )
subplot(2,2,3)
bar(k,Money),xlabel(0Year0 ), ylabel(0Dollars0), xlabel(0Year0 )
subplot(2,2,4)
stairs(k,Money),xlabel(0Year0 ), ylabel(0Dollars0 ),xlabel(0Year0 )
The plots are shown in the figure.
4
1.8
4
x 10
2
1.5
Dollars
Dollars
1.6
1.4
1.2
1
0.5
1
0
5
Year
0
0
10
4
2
1.8
10
5
Year
10
x 10
Dollars
1.6
1
0.5
0
0
5
Year
4
x 10
1.5
Dollars
x 10
1.4
1.2
5
10
15
1
0
Year
Figure : for Problem 21.
5-37
22. a) Both A and V are power functions of r. Thus they will plot as straight lines on
log-log axes. The script file is:
r = logspace(-1,2,300);
V = (4/3)*pi*r.^3;
A = 4*pi*r.^2;
subplot(2,1,1)
loglog(r,A),xlabel(0Radius r (meters)0),ylabel(0Area A (meters^2)0)
subplot(2,1,2)
loglog(r,V),xlabel(0Radius r (meters)0),ylabel(0Volume (meters^3)0)
The plots are shown in the figure.
6
10
2
Area A (meters )
4
10
2
10
0
10
−2
10
−1
10
0
1
10
10
2
10
Radius r (meters)
10
3
Volume (meters )
10
5
10
0
10
−5
10
−1
10
0
1
10
10
2
10
Radius r (meters)
Figure : for Problem 22a.
p
b) Solve for r as a function of A to obtain: r = A/π/2. Use this solution to solve for
V as a function of A:
" #3
4
1 A 1/2
1
V = π
= √ A3/2
3
2 π
6 π
Thus both r and V are power functions of A, and will plot as straight lines on log-log axes.
The script file is:
5-38
A = logspace(0,4,300);
r = 0.5*sqrt(A/pi);
V = (1/(6*sqrt(pi)))*A.^(3/2);
subplot(2,1,1)
loglog(A,r),xlabel(0Area A (meters^2)0),ylabel(0Radius r (meters)0)
subplot(2,1,2)
loglog(A,V),xlabel(0Area A (meters^2)0),ylabel(0Volume V (meters^3)0)
2
Radius r (meters)
10
1
10
0
10
−1
10
0
10
1
2
10
3
10
10
4
10
Area A (meters2)
6
3
Volume V (meters )
10
4
10
2
10
0
10
−2
10
0
10
1
2
10
3
10
10
4
10
2
Area A (meters )
Figure : for Problem 22b.
23. The session is
f = [0,.47,1.15,1.64];
y = [4.7,7.2,10.6,12.9];
x = y-4.7;
p = polyfit(x,f,1)
p =
0.1999 -0.0147
Thus the least squares straight line is f = 0.1999x − 0.0147, and the spring constant is
approximately k = 0.2. Note that this line does not pass through the origin, as it should in
5-39
order to represent the linear equation f = kx. This illustrates a limitation of the polyfit
command; it cannot fit the line y = mx + b with b set to zero.
24. (a) The script file is
x
y
p
p
= [25:5:45];
= [5, 260, 480, 745, 1100];
= polyfit(x,y,1)
=
1.0e+003 *
0.0535 -1.3545
The function is y = 53.5x − 1354.5.
(b) Only the loglog plot of the data gives something close to a straight line, so the data
is best described by a power function y = bxm . The script file to find the coefficients m and
b is
x
y
p
m
b
=
=
=
=
=
[2.5:.5:6,7:10];
[1500,1220,1050,915,810,745,690,620,520,480,410,390];
polyfit(log10(x),log10(y),1);
p(1)
10^p(2)
The results are m = −0.9764 and b = 3582.1. Thus the power function is y = 3582.1x−0.9764 .
(c) Both the loglog and semilog plot (with the y axis logarithmic) give something close
to a straight line, but the semilog plot gives the straightest line, so the data is best described
by a exponential function y = b(10)mx . The script file to find the coefficients m and b is
x
y
p
m
b
m
= [550:50:750];
=[41.2,18.62,8.62,3.92,1.86];
= polyfit(x,log10(y),1);
= p(1)
= 10^p(2)
=
-0.0067
b =
2.0622e+005
This gives the results m = −0.0067 and b = 2.0622 × 105 . Thus the exponential function is
y = 2.0622 × 105 (10)−0.0067x .
The results for the power function are obtained from
5-40
p = polyfit(log10(x),log10(y),1);
m = p(1)
b = 10^p(2)
This gives the results m = −9.9949 and b = 1.0601 × 102 9. Thus the power function is
y = 1.0601 × 1029 x−9.9949 .
A plot of the data and the two functions shows that both functions describe the data
well, but the exponential curve passes closer to the first data point than the power curve.
In addition, we should be careful about using this power function because its coefficient b
has a very large value. This large coefficient means that any predictions of y values made
with this function will be very prone to error unless we use very precise values of x. Thus
the exponential function is the best choice to describe this data.
25. With this problem, it is best to scale the data by letting x = year − 1990, to avoid
raising large numbers like 1990 to a power. Both the loglog and semilog plot (with the
y axis logarithmic) give something close to a straight line, but the semilog plot gives the
straightest line, so the data is best described by a exponential function y = b(10)mx . The
script file to find the coefficients m and b is
year = [1990:1995];
x = x = year-1990;
pop=[10,10.8,11.7,12.7,13.8,14.9];
p=polyfit(x,log10(pop),1)
p =
0.0349 0.9992
m=p(1);
b=10^p(2)
This gives the results m = 0.0349 and b = 9.9817. Thus the exponential function is
y = 9.9817(10)0.0349x . Set y = 20 to determine how long it will take for the population
to increase from 10 to 20 million. This gives 20 = 9.9817(10)0.0349x . Solve it for x: x =
(log(20) − log(9.9817))/0.0349. In Matlab we can calculate this as follows:
(log10(20)-log10(9.9817))/.0349
The answer is 8.6483 years, which corresponds to 8.6483 years after 1990.
26. (a) If C(t)/C(0) = 0.5 when t = 500 years, then 0.5 = e−5500b , which gives b =
− ln(0.5)/5500. In Matlab this calculation is
b = -log(.5)/5500
The answer is b = 1.2603 × 10−4 .
(b) Solve for t to obtain t = − ln[C(t)/C(0)]/b using C(t)/C(0) = 0.9 and b = 1.2603 ×
10−4 . In Matlab this calculation is
5-41
t = -log(.9)/b
The answer is 836.0170 years. Thus the organism died 836 years ago.
(c) Using b = 1.1(1.2603 × 10−4 ) in t = − ln(0.9)/b gives 760 years. Using b =
0.9(1.2603 × 10−4 ) in t = − ln(0.9)/b gives 928 years.
27. Only the semilog plot of the data gives something close to a straight line, so the data is
best described by an exponential function y = b(10)mx . The script file to find the coefficients
m and b is
time = [0:.1:.6];
temp = [300,150,75,35,12,5,2];
p=polyfit(time,log10(temp),1)
m=p(1)
b=10^p(2)
This gives the results: m = −3.6709 and b = 356.0199. Thus the exponential function is
y = 356.0199(10)−3.6709x , where y is the temperature in degrees C and x is the time in
seconds.
28. Only the semilog plot of the data gives something close to a straight line, so the data is
best described by an exponential function y = b(10)mx . The script file to find the coefficients
m and b is
temp = [100:20:220];
life = [28,21,15,11,8,6,4];
p = polyfit(temp,log10(life),1);
m = p(1)
b = 10^p(2)
This gives the results: m = −0.0070 and b = 141.8603. Thus the exponential function is y =
141.8603(10)−0.0070x , where y is the bearing life thousands of hours and x is the temperature
in degrees F. The bearing life at 150 ◦ F is estimated to be y = 141.8603(10)−0.0070(150) =
12.6433, or 12,643 hours.
29. Only the semilog plot of the data gives something close to a straight line, so the data
is best described by an exponential function y = b(10)mx . The first data point does not lie
close to the straight line on the semilog plot, but a measurement error of ±1 volt would
account for the discrepancy. The script file to find the coefficients m and b is
time = [0:.5:4];
voltage = [100,62,38,21,13,7,4,2,3];
p = polyfit(time,log10(voltage),1);
m=p(1)
b = 10^p(2)
5-42
This gives the results: m = −0.4333 and b = 95.8063. Thus the exponential function is
y = 95.8063(10)−0.4333x , where y is the voltage and x is the time in seconds.
30. A linear relation between the spring force f and the displacement x has the form
f = a0 x + a1 . The following session computes the constants a0 and a1 .
x = [4.7,7.2,10.6,12.9]-4.7;
f = [0,.47,1.15,1.64];
p = polyfit(x,f,1)
p =
0.1999 -0.0147
Thus f = 0.1999x − 0.0147. However, this line does not pass through the origin. If a model
passing through the origin is desired, we use equation (5.6-6). The required session is shown
below.
x = [4.7,7.2,10.6,12.9]-4.7;
f = [0,.47,1.15,1.64];
num = sum(x.*f);
den = sum(x.^2);
k = num/den
k = 0.1977
xp = [0:.01:x(4)];
fp = k*xp;
plot(x,f,0o0 ,xp,fp),xlabel(0x (inches)0 ),ylabel(0f (pounds)0)
Thus the least-squares model that passes through the origin is f = 0.1977x.
31. (a) The m-file is:
x = [0:9];
y = [130,115,110,90,89,89,95,100,110,125];
xp = [0:.01:9];
for k = 1:4
yp(k,:) = polyval(polyfit(x,y,k),xp);
J(k) = sum((polyval(polyfit(x,y,k),x)-y).^2);
end
for k = 1:4
subplot(2,2,k)
plot(xp,yp(k,:),x,y,0o0 ),axis([0 10 0 150])
end
J
mu = mean(y);
5-43
for k = 1:4
S(k) = sum((y-mu).^2);
r2(k) = 1-J(k)/S(k);
end
S
r2
The results are J = 1996.0, 79.3, 78.9, and 68.7 for the first through fourth-order polynomials. In addition, S = 2036.1 and r 2 = 0.0197, 0.9611, 0.9612, and 0.9663. Clearly, the
fourth-order polynomial is the best fit. The polynomials and the data are plotted on the
top of the next page.
150
150
100
100
50
50
0
0
2
4
6
8
10
0
150
150
100
100
50
50
0
0
2
4
6
8
10
0
0
2
4
6
8
10
0
2
4
6
8
10
Figure : for Problem 31a.
(b) Plot the fourth-order polynomial using expanded scales to determine the minimum
point. This plot is shown in the figure and is obtained by typing the following after the
above m-file has been executed.
plot(xp,yp(4,:),x,y,0o0 ),axis([0 10 86 4]),...
grid,xlabel(0A (oz)0 ),ylabel(0T (min)0 )
5-44
From the plot we can see that the minimum point on the fourth-order polynomial occurs
at 4.6 ounces of additive.
94
93
92
T (min)
91
90
89
88
87
86
0
1
2
3
4
5
A (oz)
6
7
Figure : for Problem 31b.
5-45
8
9
10
32. The m-file is
x = [20:10:70];
y = [45,80,130,185,250,330];
xp = [20:.01:70];
p = polyfit(x,y,2)
yp = polyval(p,xp);
J = sum((polyval(polyfit(x,y,2),x)-y).^2);
plot(xp,yp,x,y,0o0 ),axis([20 70 0 350]),ylabel(0d (ft)0 ),xlabel(0v (mph)0 )
J
mu = mean(y);
S = sum((y-mu).^2);
r2 = 1-J/S;
S
r2
When the file is executed, the following results are obtained: p = 0.0509 1.1054 2.3571,
which gives y = 0.0509x2 + 1.1054x + 2.3571. Also, J = 10.1786, S = 5.7550 × 104 , and
r 2 = 0.9998, which indicates a very good fit. The plot of the quadratic curve and the data
is shown in the figure.
350
300
250
d (ft)
200
150
100
50
0
20
25
30
35
40
45
v (mph)
50
55
Figure : for Problem 32.
5-46
60
65
70
33. Note that the equation d = at2 /2 + bt passes through the origin. Thus we need to
constrain the curve by using equations (5.6-7) and (5.6-8). The m-file is
t = [0,1,1.5,2,2.5,3,3.5,4];
d = [0,4,10,11,26,38,51,65];
c1 = sum(t.^4);c2 = sum(t.^3);b1 = sum(d.*t.^2);
c3 = sum(t.^2);b2 = sum(d.*t);
A = [c1,c2;c2,c3];
B = [b1;b2];
x = A\B
The results are x = 4.3739 -0.9759, which give the model d = 4.3739t2 − 0.9759t. So the
acceleration a is found from a/2 = 4.3739, or a = 8.7478 feet/second2 .
34. Follow the procedure outlined by equations (5.6-11) through (5.6-15). The m-file is
d1 = [1,2,3,4];d2 = [1,1,1,1];
x1 = [d1,d1,d1]0;
x2 = [d2,2*d2,3*d2]0;
y = [40, 51, 65, 72, 38, 46, 53, 67, 31, 39, 48, 56]0 ;
X = [ones(size(x1)) x1 x2];
a = X\y
Y = X*a;
MaxErrPerc = 100*max(abs((Y-y)./y))
The results are a = 40.0000 9.6000 -6.7500, and MaxErrPerc = 7.1250, which correspond to the model y = 40 + 9.6x1 − 6.75x2 , with a maximum percent error of 7.125%.
35. a) The script file is:
p = [26.1,27,28.2,29,29.8,30.6,31.1,31.3,31,30.5];
t = [1:10];
tp = [1:0.05:10];
coeff1 = polyfit(t,p,1);
coeff2 = polyfit(t,p,2);
coeff3 = polyfit(t,p,3);
p1 = polyval(coeff1,tp);
p2 = polyval(coeff2,tp);
p3 = polyval(coeff3,tp);
plot(t,p,0o0 ,tp,p1,tp,p2,tp,p3,0--0 ),...
xlabel(0Time (secs)0),ylabel(0Pressure (psi)0 )
The plot is shown in the figure. The first-order fit is the straight line, and the third-order
fit is shown by the dashed line.
5-47
32
31
Pressure (psi)
30
29
28
27
26
25
1
2
3
4
5
6
Time (secs)
7
8
9
10
Figure : for Problem 35a.
b) The quadratic and the cubic polynomials give the best fits, so we plot their residuals.
Comment out the last line in the script file for part (a), and add the following lines.
res2 = p - polyval(coeff2,t);
res3 = p - polyval(coeff3,t);
plot(t,res2,t,res2,0o0 ,t,res3,0--0 ,t,res3,0 o0 ),...
xlabel(0Time (sec)0 ),ylabel(0Residuals (psi)0 ),...
gtext(02nd Order0 ),gtext(03rd Order0 )
mu = mean(p);
S = sum((p-mu).^2);
J2 = sum((polyval(coeff2,t)-p).^2);
J3 = sum((polyval(coeff3,t)-p).^2);
r22 = 1-J2/S
r23 = 1-J3/S
The plot is shown in the figure. The residuals for the cubic polynomial are the smallest.
The coefficients of determination are r22 = 0.9871 for the quadratic, and r23 = 0.9986 for
the cubic. So we choose the cubic as the best fit. To estimate the value of p at t = 11, type
polyval(coeff3,11) to obtain 29.41 psi.
5-48
0.3
0.2
3rd Order
Residuals, (psi)
0.1
0
−0.1
−0.2
2nd Order
−0.3
−0.4
1
2
3
4
5
6
Time (sec)
7
Figure : for Problem 35b.
5-49
8
9
10
36. The script file is:
T = [273:5:298];
P = [4.579,6.543,9.209,12.788,17.535,23.756];
x = 1./T;
logP = log(P);
coeff = polyfit(x,logP,1);
C1 = exp(coeff(2))
C2 = coeff(1)
P1 = C1*exp(C2/285)
P2 = C1*exp(C2/300)
Tplot = [273:.01:298];
Pplot = C1*exp(C2./Tplot);
subplot(2,1,1)
plot(Tplot,Pplot,T,P,0o0 ),xlabel(0Temperature(K)0),...
ylabel(0Pressure (torr)0)
subplot(2,1,2)
semilogy(1./Tplot,Pplot,1./T,P,0o0 ),xlabel(01/Temperature(1/K)0),...
ylabel(0Pressure (torr)0)
The plots of the fit and the data on rectilinear and semi-log axes are shown in the figure.
Clearly, the fit is very good. The coefficients are C1 = 1.5266 × 109 and C2 = −5.3568 × 103 ,
and the equation is P = C1 eC2 /T . The estimated values are P = 10.4925 at T = 285, and
P = 26.8547 at T = 300.
25
Pressure (torr)
20
15
10
5
0
270
275
280
285
Temperature (K)
290
295
300
2
Pressure (torr)
10
1
10
0
10
3.35
3.4
3.45
3.5
3.55
3.6
1/Temperature (1/K)
3.65
Figure : for Problem 36.
5-50
3.7
3.75
−3
x 10
37. The script file is
T = [10:10:90];
S = [35,35.6,36.25,36.9,37.5,38.1,38.8,39.4,40];
coeff = polyfit(T,S,1)
Sest = coeff(1)*25 + coeff(2)
Tplot = [10:.1:90];
Splot = coeff(1)*Tplot+coeff(2);
plot(T,S,0o0 ,Tplot,Splot),xlabel(0T0 ),ylabel(0S0 )
The plot in the figure shows that the striaght line is a good fit. Its coefficents are coeff(1)=
0.0628 and coeff(2) = 34.3639, which give the straight line: S = 0.0628T + 34.3639. This
gives the estimate at T = 25 to be S = 35.9347.
41
40
39
38
37
36
35
34
10
20
30
40
50
60
70
Figure : for Problem 37.
5-51
80
90
38. The script file is:
T = [5:5:45];
S = [1.95,1.7,1.55,1.4,1.3,1.15,1.05,1,0.95];
coeff = polyfit(T,S,3)
Sest1 = polyval(coeff,8)
Sest2 = polyval(coeff,50)
Tplot = [5:.01:55];
Splot = polyval(coeff,Tplot);
plot(T,S,0o0 ,Tplot,Splot,8,Sest1,0*0 ,50,Sest2,0*0 )
The plot in the figure shows that a cubic gives a good fit. Its coefficient vector is coeff
= [−2.3569 × 10−6 , 6.0750 × 10−4 , −4.9761 × 10−2 , 2.1683]. The estimates are S = 1.8078
at T = 8, and S = 0.9044 at T = 50.
2
1.8
S
1.6
1.4
1.2
1
0.8
5
10
15
20
25
30
T
35
40
Figure : for Problem 38.
5-52
45
50
55
39.The script file is:
x = [1:10];
y = [10,14,16,18,19,20,21,22,23,23];
logx = log(x);
coeff = polyfit(logx,y,1)
yest1 = coeff(1)*log(1.5)+coeff(2)
yest2 = coeff(1)*log(11)+coeff(2)
xplot = [1:.01:12];
yplot = coeff(1)*log(xplot)+coeff(2);
plot(xplot,yplot,x,y,0o0 ,1.5,yest1,0*0 ,11,yest2,0*0 ),...
xlabel(0x0 ),ylabel(0y0 )
The first-order fit gives the coefficient vector coeff = [a2 , a1 ] =[5.7518, 9.9123], which corresponds to the equation y = a1 + a2 ln x. The plot in the figure shows that this equation
gives a reasonably good fit. The estimated values from the equation are y = 12.2244 at
x = 1.5, and y = 23.7044 at x = 11.
26
24
22
20
y
18
16
14
12
10
8
0
2
4
6
x
8
Figure : for Problem 39.
5-53
10
12
40. The script file is:
t = [0,3.15,6.2,10,18.3,30.8,43.8];
C = [0.1039,0.0896,0.0776,0.0639,0.0353,0.0207,0.0101];
logC = log(C);
coeff = polyfit(t,logC,1)
tplot = [0:.01:44];
C0 = exp(coeff(2))
k = -coeff(1)
Cplot = C0*exp(-k*tplot);
plot(tplot,Cplot,t,C,0o0 ),xlabel(0t0 ),ylabel(0C0 )
The coefficient vector is coeff = [−5.3709 × 10−2 , −2.2530]. Thus C(0) = 0.1051 and
k = 0.0537. The plot in the figure shows that the fit is reasonably good.
0.12
0.1
C
0.08
0.06
0.04
0.02
0
0
5
10
15
20
25
30
t
Figure : for Problem 40.
5-54
35
40
45
41. The figure shows plots of 1/C and ln C versus t. Only the plot of 1/C is linear.
Therefore the reaction is second-order. To find C(0) and k, we fit a first-order polynomial
to the data (1/C, t). The script file is
t = [0,50,100,200,300];
C = [0.01,0.0079,0.0065,0.0048,0.0038];
y = 1./C;
coeff = polyfit(t,y,1)
C0 = 1/coeff(2)
k = coeff(1)
The results are C(0) = 1.00396 × 10−2 , k = 5.44452 × 10−1 .
300
1/C
250
200
150
100
0
50
100
150
t
200
250
300
0
50
100
150
t
200
250
300
−4.6
−4.8
ln C
−5
−5.2
−5.4
−5.6
Figure : for Problem 41.
5-55
42. The script file is:
t = [5:5:45];
C = [0.3575,0.301,0.2505,0.2095,0.18,0.15,0.1245,0.107,0.0865];
y1 = log(C);
y2 = 1./C;
tt y3 = 1./(2*C.^2);
coeff1 = polyfit(t,y1,1);
C10 = exp(coeff1(2))
k1 = -coeff1(1)
res1 = C10*exp(-k1*t) - C;
coeff2 = polyfit(t,y2,1);
C02 = 1/coeff2(2)
k2 = coeff2(1)
res2 = 1./((1/C02)+k2*t) - C;
coeff3 = polyfit(t,y3,1);
C03 = 1/(2*coeff3(2))
k3 = coeff3(1)
res3 = sqrt(1./((1./C03.^2) + 2*k3*t)) - C;
plot(t,res1,t,res1,0o0 ,t,res2,t,res2,0+0 ,t, res3, t, res3, 0 *0 ),xlabel(0t0 ),...
ylabel(0Residuals0),gtext(01st Order0 ),gtext(02nd Order0 ),gtext(03rd Order0 )
The plot shown in the figure reveals that the first-order model gives the best fit. Its
coefficients are C10 and k1, or C(0) = 0.4264 and k = 0.0350.
0.15
2nd Order
0.1
0.05
1st Order
0
Residuals
−0.05
−0.1
−0.15
3rd Order
−0.2
−0.25
−0.3
−0.35
5
10
15
20
25
t
30
35
40
Figure : for Problem 42.
5-56
45
43. The script file is
t = [0:pi/10:10*pi];
x = cos(t);y = sin(t);
subplot(2,2,1)
plot3(x,y,.1*t),xlabel(0x0 ), ylabel(0y0 ),zlabel(0z0 )
subplot(2,2,2)
plot3(x,y,.2*t),xlabel(0x0 ), ylabel(0y0 ),zlabel(0z0 )
subplot(2,2,3)
plot3(x,y,- .1*t),xlabel(0x0 ),ylabel(0y0 ), zlabel(0z0 )
4
10
2
5
z
z
The plots are shown in the figure. The only difference between the plots for b = 0.1 and
b = −0.1 is that they spiral in opposite directions (one is left handed; one is right handed).
When b = 0.2, the spiral’s coils are farther apart relative to the case for b = 0.1. To see
this, note the different scales on the z axes of the plots for b = 0.1 and b = 0.2.
0
1
1
0
y
0
1
−1 −1
1
0
0
y
x
0
−1 −1
z
0
−2
−4
1
1
0
y
0
−1 −1
x
Figure : for Problem 43.
5-57
x
44. The following script file creates the plot. The start of the path is marked with an
asterisk, and the end is marked with a + sign.
t = [0:.002:.2];
x = (.5+5*t).*sin((2*pi/3)*t).*cos(4*pi*t);
y = (.5+5*t).*sin((2*pi/3)*t).*sin(4*pi*t);
z = (.5+5*t).*cos((2*pi/3)*t);
n = length(t);
plot3(x,y,z),xlabel(0x (meters)0),ylabel(0y (meters)0),...
zlabel(0z (meters)0),grid,hold,...
plot3(x(1),y(1),z(1),0*0 ),plot3(x(n),y(n),z(n), 0 +0 )
The plot is shown in the figure.
1.4
z (meters)
1.2
1
0.8
0.6
0.4
0.4
0.3
0
0.2
−0.2
0.1
y (meters)
0
−0.4
x (meters)
Figure : for Problem 44.
5-58
45. The script file is
[X,Y] = meshgrid(-4:.4:4);
Z = X.^2-2*X.*Y+4*Y.^2;
subplot(2,1,1)
mesh(X,Y,Z),xlabel(0x0 ),ylabel(0y0 ),...
zlabel(0z0 ),grid
subplot(2,1,2)
contour(X,Y,Z),xlabel(0x0 ), ylabel(0y0 )
The plots are shown in the figure.
150
z
100
50
0
4
2
0
−2
−4
0
−2
−4
y
4
2
x
4
y
2
0
−2
−4
−4
−3
−2
−1
0
x
1
2
Figure : for Problem 45.
5-59
3
4
46. The script file is
[X,Y] = meshgrid(-4:.4:4);
Z = -X.^2+2*X.*Y+3*Y.^2;
subplot(2,1,1)
mesh(X,Y,Z),xlabel(0x0 ),ylabel(0y0 ),zlabel(0z0 ),grid
subplot(2,1,2)
contour(X,Y,Z),xlabel(0x0 ), ylabel(0y0 )
The plots are shown in the figure. The contour lines form an “X’ at a saddlepoint .
100
z
50
0
−50
4
2
0
−2
−4
0
−2
−4
y
4
2
x
4
y
2
0
−2
−4
−4
−3
−2
−1
0
x
1
2
Figure : for Problem 46.
5-60
3
4
47. The script file is
[X,Y] = meshgrid(-3:.3:3);
Z = (X-Y.^2).*(X-3*Y.^2);
subplot(2,1,1)
mesh(X,Y,Z),xlabel(0x0 ),ylabel(0y0 ),zlabel(0z0 ),grid
subplot(2,1,2)
contour(X,Y,Z),xlabel(0x0 ), ylabel(0y0 )
The plots are shown in the figure. The contour lines converge near a singular point.
400
z
200
0
−200
4
2
0
−2
−4
−2
−3
y
−1
0
1
3
2
x
2
y
1
0
−1
−2
−3
−3
−2
−1
0
x
1
Figure : for Problem 47.
5-61
2
3
48. The script file is
[X,Y] = meshgrid(0:.1:1);
T = 80*exp(-(X-1).^2).*exp(-3*(Y-1).^2);
subplot(2,1,1)
mesh(X,Y,T),xlabel(0x0 ),ylabel(0y0 ),zlabel(0T0 ),grid
subplot(2,1,2)
contour(X,Y,T),xlabel(0x0 ), ylabel(0y0 )
T(1,1)
The plots are shown in the figure. The temperature at x = 0, y = 0 is the value of T(1,1).
It is 1.4653◦ C.
T
100
50
0
1
0.5
0
0.2
0
y
0.4
0.6
1
0.8
x
1
0.8
y
0.6
0.4
0.2
0
0
0.1
0.2
0.3
0.4
0.5
x
0.6
0.7
Figure : for Problem 48.
5-62
0.8
0.9
1
49. The script file is
[T,TAU] = meshgrid(0:.5:15,.5:.5:10);
Z = exp(-T./TAU).*sin(2*T);
subplot(2,1,1)
mesh(T,TAU,Z),xlabel(0Time t (sec)0 ),ylabel(0Tau (sec)0 ),...
zlabel(0z0 ),grid
subplot(2,1,2)
contour(T,TAU,Z),xlabel(0Time t (sec)0 ),ylabel(0Tau (sec)0 )
The plots are shown in the figure.
1
z
0
−1
10
5
0
5
0
Tau (sec)
15
10
Time t (sec)
10
Tau (sec)
8
6
4
2
0
5
10
Time t (sec)
Figure : for Problem 49.
5-63
15
Download