M & M Homework WK3

Callahan:
    2.2 - 1, 2, 3, 8, 9, 10, 11, 14,
    2.3 - 6, 7, 8, 9, 10, 11

[Graphics:Images/MM wk 3_gr_1.gif]

    1)  Modify SIRVALUE and SIRPLOT to analyze the population of poland.  We assume the population P(t) satisfies the conditions:

[Graphics:Images/MM wk 3_gr_2.gif]
[Graphics:Images/MM wk 3_gr_3.gif]

    where [Graphics:Images/MM wk 3_gr_4.gif] is years since 1985.  We want to know P 100 years into the future; you can assume that P does not exceed 100,000,000.

    a)  Estimate the population in 2085:

[Graphics:Images/MM wk 3_gr_5.gif]
[Graphics:Images/MM wk 3_gr_6.gif]

    So the population after 100 years is about 92 million.

from visual.graph import*
tinitial = 0
tfinal = 100

graph = gdisplay()

t = tinitial
p = 37500000
numberofsteps = 150
deltat = (tfinal - tinitial)/float(numberofsteps)
pcurve = gcurve(color = (1, 0, 0))
print t, p
pcurve.plot(pos = (t, p))
    
for k in range(1,numberofsteps+1) :
        pprime = (0.009)*p
        deltay = pprime*deltat
        t = t + deltat
        p = p + deltay
        print t, p
        pcurve.plot(pos = (t, p))


    b)  Sketch the graph that describes this population growth:

[Graphics:Images/MM wk 3_gr_7.gif]

[Graphics:Images/MM wk 3_gr_8.gif]

[Graphics:Images/MM wk 3_gr_9.gif]
[Graphics:Images/MM wk 3_gr_10.gif]
[Graphics:Images/MM wk 3_gr_11.gif]

    2)  By modifying SIRVALUE in the way we modified SIRPLOT to get SEQUENCE, obtain a sequence of estimates for y(37) that allow you to specify the exact value of y(37) to two decimal places accuracy.

[Graphics:Images/MM wk 3_gr_12.gif]

    So the value is [Graphics:Images/MM wk 3_gr_13.gif].

tinitial = 0
tfinal = 37
t = tinitial
p = 100


inc = 0

for inc in range(1,11):
    print t, p
    t = tinitial
    p = 100
    numberofsteps = 100000*inc
    deltat = (tfinal - tinitial)/float(numberofsteps)
    print deltat
    
    for k in range(1,numberofsteps+1) :
        pprime = (0.1)*p*(1-(p/1000))
        deltay = pprime*deltat
        t = t + deltat
        p = p + deltay  

[Graphics:Images/MM wk 3_gr_14.gif]

    3)

    a)  Referring to the graph of y(t) obtained in the text on page 70, what can you say about the behavior of y as t gets large?

    It looks like the as t gets large y will approach 1000.

    b)  Suppose we had started with y(0)=1000.  How would the population have changed over time?  Why?

[Graphics:Images/MM wk 3_gr_15.gif]
[Graphics:Images/MM wk 3_gr_16.gif]

    The y value would just stay at 1000 because the rate of change would be zero..

    c)  Suppose we had started with y(0)=1500.  How would the population have changed over time?  Why?

[Graphics:Images/MM wk 3_gr_17.gif]
[Graphics:Images/MM wk 3_gr_18.gif]

    The y value would decrease until it reached 1000 because the rate of change is negative and will increase until it reaches zero at large t.

    d)  Suppose we had started with y(0)=0.  How would the population have changed over time?  Why?

[Graphics:Images/MM wk 3_gr_19.gif]
[Graphics:Images/MM wk 3_gr_20.gif]

    The y value would stay at 0 because the rate of change is zero. This behavior corresponds to an initial population of 0, so there can be no population growth.

    e)  The number 100 in the denominator of the rate equation is called the carrying capacity of the system.  Can you give a physical interpretation of this number?

[Graphics:Images/MM wk 3_gr_21.gif]

    The carrying capacity is the sustainable population that the habitat can support.  If the population is above this then it will die back until it reaches the carrying capacity.  Similarly, if the population starts bellow the carrying capacity then it will increase until it reaches it.

[Graphics:Images/MM wk 3_gr_22.gif]

    8) Each Euler approximation is made up of a certain number of straight line segments.  What instruction in the program SEQUENCE determines the number of segments in a particular approximation?

[Graphics:Images/MM wk 3_gr_23.gif]

    The first graph drawn has only a single segment.  How many does the fifth have?  How many does the fourteenth have?

    The fifth has [Graphics:Images/MM wk 3_gr_24.gif] segments, and the fourteenth has [Graphics:Images/MM wk 3_gr_25.gif] segments.

[Graphics:Images/MM wk 3_gr_26.gif]

    9) What is the slope of the first graph?

[Graphics:Images/MM wk 3_gr_27.gif]

    So we just use the logistics equation to find the slope:

[Graphics:Images/MM wk 3_gr_28.gif]
[Graphics:Images/MM wk 3_gr_29.gif]

    And so the slope is 9.

    What are the slopes of the two parts of the second graph?

[Graphics:Images/MM wk 3_gr_30.gif]
[Graphics:Images/MM wk 3_gr_31.gif]

    The slope of the first section is 9.

[Graphics:Images/MM wk 3_gr_32.gif]
[Graphics:Images/MM wk 3_gr_33.gif]
[Graphics:Images/MM wk 3_gr_34.gif]
[Graphics:Images/MM wk 3_gr_35.gif]

    The slope of the second section is about 24.61.

[Graphics:Images/MM wk 3_gr_36.gif]

    10) Modify the line in the program SEQUENCE which determines the number of steps by having it read:

[Graphics:Images/MM wk 3_gr_37.gif]

    Again we are getting a sequence of approximations, with the number of steps increasing each time, but the approximations don't seem to be getting all that close to anything.  Explain why this modified program isn't as effective for our purposes as the original.

    The modified program isn't as effective for our purposes as the original because the number of steps is not increasing as fast.  The old program had the number of steps growing exponentially while this program only has them growing linearly..

[Graphics:Images/MM wk 3_gr_38.gif]

    11) Modify SEQUENCE to produce a sequence of Euler approximations to the function [Graphics:Images/MM wk 3_gr_39.gif] that satisfies the conditions:

[Graphics:Images/MM wk 3_gr_40.gif]

from visual.graph import *
graph = gdisplay()

y = 1

for j in range(1,15):
    print j, y
    tinitial = 0
    tfinal = 10
    t = tinitial
    y = 1
    numberofsteps = 2**(j-1)
    deltat = (tfinal - tinitial) / float(numberofsteps)
    
    curve = gcurve()
    curve.plot(pos=(t,y))

    for k in xrange(numberofsteps):
        yprime = (0.2)*5*y*(1-y/5)
        deltay = yprime * deltat
        t = t + deltat
        y = y + deltay
        curve.plot(pos=(t,y))

    a) What is [Graphics:Images/MM wk 3_gr_41.gif]?

[Graphics:Images/MM wk 3_gr_42.gif]

    So is [Graphics:Images/MM wk 3_gr_43.gif].

    b) Sketch the graph that is the limit of these approximations.  The right half of the limit graph has a distinctive feature; what is it?

[Graphics:Images/MM wk 3_gr_44.gif]

    The right half of the limit graph approaches [Graphics:Images/MM wk 3_gr_45.gif].

    c) Without doing any calculations, can you estimate the value of [Graphics:Images/MM wk 3_gr_46.gif]?

    You can see from the graph and from the equation that the carrying capacity is 5.  So at any time greater than [Graphics:Images/MM wk 3_gr_47.gif] the graph will just get closer to [Graphics:Images/MM wk 3_gr_48.gif].

    d) Change the initial conditions from y(0)=1 to y(0)=9,  Construct the sequence of Euler approximations beginning with number of steps equal to 1, and sketch the limit graph.  What is y(10) now?

...
y = 9
for j in range(1,15):
    ...
    y = 9
    numberofsteps = 2**(j+2)
    ...

    So is [Graphics:Images/MM wk 3_gr_49.gif].

[Graphics:Images/MM wk 3_gr_50.gif]

    Explain why the first several approximations look so strange.

[Graphics:Images/MM wk 3_gr_51.gif]

    The slope of the limit graph is initially large and negative, so when there are few steps then the Euler approximation oscillates wildly because [Graphics:Images/MM wk 3_gr_52.gif] is large.

[Graphics:Images/MM wk 3_gr_53.gif]

    14) Construct a sequence of Euler approximations to the function [Graphics:Images/MM wk 3_gr_54.gif] that satisfies:

[Graphics:Images/MM wk 3_gr_55.gif]

    Estimate [Graphics:Images/MM wk 3_gr_56.gif].  How accurate is your estimate?  (the answer is [Graphics:Images/MM wk 3_gr_57.gif])

[Graphics:Images/MM wk 3_gr_58.gif]

    So it looks like my estimate for [Graphics:Images/MM wk 3_gr_59.gif] is accurate to the third decimal place.

[Graphics:Images/MM wk 3_gr_60.gif]

2.3 - 6, 7, 8, 9, 10, 11

    6) Modify the program so that it uses 20 segments to estimate the length of the parabola.  What is the estimated length value?

from math import sqrt

def fnf(x) :
    return x ** 2

xinitial = 0
xfinal = 1
numberofsteps = 20
deltax = (xfinal - xinitial) / float(numberofsteps)
total = 0
for k in range(numberofsteps) :
    xl  = xinitial + k*deltax
    xr = xinitial + (k + 1)*deltax
    yl = fnf(xl)
    yr = fnf(xr)
    segment = sqrt((xr - xl) ** 2 + (yr - yl) ** 2)
    total = total + segment
    print k, segment

print numberofsteps, total

    The estimated length value is:

[Graphics:Images/MM wk 3_gr_61.gif]
[Graphics:Images/MM wk 3_gr_62.gif]

    7) Modify the program so that it estimates the length of the parabola using 200, 2000, 20000, 200000, and 2000000 segments.

[Graphics:Images/MM wk 3_gr_63.gif]

from math import sqrt

def fnf(x) :
    return x ** 2

for j in range(1,6):
    xinitial = 0
    xfinal = 1
    numberofsteps = 20*(10**j)
    deltax = (xfinal - xinitial) / float(numberofsteps)
    total = 0

    for k in range(numberofsteps) :
        xl  = xinitial + k*deltax
        xr = xinitial + (k + 1)*deltax
        yl = fnf(xl)
        yr = fnf(xr)
        segment = sqrt((xr - xl) ** 2 + (yr - yl) ** 2)
        total = total + segment

    print numberofsteps, total

[Graphics:Images/MM wk 3_gr_64.gif]

    8) What is the length of the parabola [Graphics:Images/MM wk 3_gr_65.gif] over the interval [Graphics:Images/MM wk 3_gr_66.gif], correct to 8 decimal places?  What is the length correct to 12 decimal places?

    How about just 11 decimal places:

[Graphics:Images/MM wk 3_gr_67.gif]
[Graphics:Images/MM wk 3_gr_68.gif]

    9) Starting at the origin, and moving along the parabola [Graphics:Images/MM wk 3_gr_69.gif], where are you when you've gone a total distance of 10?

[Graphics:Images/MM wk 3_gr_70.gif]

from math import sqrt

def fnf(x) :
    return x ** 2

xinitial = 0
xfinal = 5
numberofsteps = 20*(10**5)
deltax = (xfinal - xinitial) / float(numberofsteps)
total = 0

for k in range(numberofsteps) :
    xl  = xinitial + k*deltax
    xr = xinitial + (k + 1)*deltax
    yl = fnf(xl)
    yr = fnf(xr)
    segment = sqrt((xr - xl) ** 2 + (yr - yl) ** 2)
    total = total + segment
    if total >= 10:
        print total, 'x = ', xr, 'y = ',yr
        break

[Graphics:Images/MM wk 3_gr_71.gif]

    10) Modify the program to find the length of the curve [Graphics:Images/MM wk 3_gr_72.gif] over the interval [Graphics:Images/MM wk 3_gr_73.gif].  Find a value that is correct to 8 decimal places.

[Graphics:Images/MM wk 3_gr_74.gif]

    Looks like I got it to 11 decimal places.

from math import sqrt

def fnf(x) :
    return x ** 3

for j in range(1,8):
    xinitial = 0
    xfinal = 1
    numberofsteps = 2*(10**(j-1))
    deltax = (xfinal - xinitial) / float(numberofsteps)
    total = 0

    for k in range(numberofsteps) :
        xl  = xinitial + k*deltax
        xr = xinitial + (k + 1)*deltax
        yl = fnf(xl)
        yr = fnf(xr)
        segment = sqrt((xr - xl) ** 2 + (yr - yl) ** 2)
        total = total + segment

    print numberofsteps, total

[Graphics:Images/MM wk 3_gr_75.gif]

    11) Consider the unit circle centered at the origin.  The Pythagorean theorem shows that a point [Graphics:Images/MM wk 3_gr_76.gif] is on the circle if and only if [Graphics:Images/MM wk 3_gr_77.gif].  If we solve this for [Graphics:Images/MM wk 3_gr_78.gif] in terms of [Graphics:Images/MM wk 3_gr_79.gif], we get [Graphics:Images/MM wk 3_gr_80.gif], where the plus sign gives us the upper half, and the minus sign gives us the lower half.  This suggests that we look at the function [Graphics:Images/MM wk 3_gr_81.gif].  The arclength of [Graphics:Images/MM wk 3_gr_82.gif] over the interval [Graphics:Images/MM wk 3_gr_83.gif] should then be exactly [Graphics:Images/MM wk 3_gr_84.gif].

    a)  Divide the interval into 100 pieces and find the corresponding length:

[Graphics:Images/MM wk 3_gr_85.gif]

from math import sqrt

def fnf(x) :
    return sqrt(1-(x**2))

xinitial = 0
xfinal = 1
numberofsteps = 50
deltax = (xfinal - xinitial) / float(numberofsteps)
print deltax
total = 0

for k in range(numberofsteps) :
    xl = xinitial + k*deltax
    xr = xinitial + (k+1)*deltax
    yl = fnf(xl)
    yr = fnf(xr)
    segment = sqrt((xr - xl) ** 2 + (yr - yl) ** 2)
    total = total + segment
    print total, yl, yr, xl, xr

print 2*numberofsteps, 2*total

    b)  How many pieces do you have to divide the interval into to get an accuracy equal to that of Archimedes?

[Graphics:Images/MM wk 3_gr_86.gif]

    So, it looks like 65 pieces gives me 2 decimal points of accuracy.

    c)  Find the length of the curve to 8 decimal places of accuracy.

[Graphics:Images/MM wk 3_gr_87.gif]
[Graphics:Images/MM wk 3_gr_88.gif]

from math import sqrt

def fnf(x) :
    return sqrt(1-(x**2))

for j in range(1,9):
    xinitial = 0
    xfinal = 1
    numberofsteps = 2*(10**(j-1))
    deltax = (xfinal - xinitial) / float(numberofsteps)
    total = 0

    for k in range(numberofsteps) :
        xl  = xinitial + k*deltax
        xr = xinitial + (k + 1)*deltax
        yl = fnf(xl)
        yr = fnf(xr)
        segment = sqrt((xr - xl) ** 2 + (yr - yl) ** 2)
        total = total + segment

    print 2*numberofsteps, 2*total


Converted by Mathematica      February 4, 2004