Pu(t) = Pu, maxe^-kut + Pu, min
while the suburban population is growing , as in
Ps(t) = Ps, max/ 1+ [Ps, max/Po - 1] * e^-kst
where Pu, max, ku, Ps, max, Po, and ks = empirically derived parameters. Determine the time and corresponding values of Pu(t) and Ps(t) when the suburbs are 20% larger than the city. the parameter values are Pu,max = 75,000, ku = 0.45/yr, Pu, min = 100,000 people, Ps, max = 300,000 people, Po = 10000 people, ks = .08/yr. To obtain your solution,use (a) graphical, (b) false-position, and (c) modified secant methods.
Matlab Code:
Pumax = 75000;
ku = 0.045;
Pumin = 100000;
Psmax = 300000;
Po = 10000;
ks = .08;
t = 0:100;
pu = @(t) Pumax * exp(-ku * t) + Pumin;%city
ps = @(t) Psmax ./ ( 1 + (Psmax /Po - 1) * exp(-ks * t));%suburbs
p = @(t) 1.2 * pu(t) - ps(t); %find zero of this to find intersection of pu and ps
%(a)graphically
hold on
plot(t,pu(t));
plot(t, ps(t) , 'r');
plot(t,p(t),'g');
%(b)false-position
t_l = 40;
t_u = 20;
for i = 1:1:8
% if f(x_l) * f(x_u) < 0 the signs should be opposite
t_r = t_u - ((p(t_u) * (t_l - t_u)) / (p(t_l) - p(t_u))); % x_r is our estimated root
if (p(t_l) * p(t_r) < 0)
t_u = t_r;
else
%(p(t_l) * p(t_r) > 0)
t_l = t_r;
%(p(t_l) * p(t_r) == 0)
end
plot(t_r ,p(t_r),'y*')
end
%(c)
t = 40;
delta = .01;
%Modified secant method
for i = 1:23
t_new = t - (delta * t * p(t)) ./ (p(t + delta*t) - p(t));
t = t_new;
plot(t,p(t), 'k*')
end
hold off
The red line shows the suburbs, the blue shows the city, and the green line is the equation we came up with to find the desired intersection(where the suburbs are 20% larger than the city). This graph looks to be giving an answer of about 40 years. It's hard to see the results of the other two methods, so we'll zoom in a bit.
The yellow dot is the result of the false position method, and the black is the result of the modified secant method both approximating the zero. The results of these two methods are as follows, t being the modified secant and t_r being the false position
EDU>> t
t =
39.606797739143595
EDU>> t_r
t_r =
39.606797739143595
EDU>> p(t)
ans =
-2.910383045673370e-11
EDU>> p(t_r)
ans =
-2.910383045673370e-11
They are identical results to the degree of accuracy matlab will display, and when plugged back in to the equation, they are negligibly far from 0, thus they confirm each other quite well
No comments:
Post a Comment