[CSC 335] Fixed Point Exercise From Class

Andrew J. Pounds pounds_aj at mercer.edu
Fri Sep 22 09:53:32 EDT 2017


So the "point" of the fixed point exercise yesterday was to demonstrate 
that you don't always have to *add* the argument of the function to both 
sides of the equation to come up with a fixed point method.  In the 
problem yesterday you were asked to solve

$s(t)=s_0-\frac{mg}{k}t+\frac{m^2g}{k^2}\left(1-e^{-kt/m}\right)$

The solution to the problem is obviously when the burger hits the 
ground, or $s(t)=0$.  Noting that fact, lets move the linear term in $t$ 
to the other side of the equation.

$s_0+\frac{m^2g}{k^2}\left(1-e^{-kt/m}\right)=\frac{mg}{k}t$

and then divide the left side of the equation by the coefficients on the 
right....

$\frac{s_0+\frac{m^2g}{k^2}\left(1-e^{-kt/m}\right)}{\frac{mg}{k}}=t$

That should set up a fixed point algorithm for testing in python which, 
starting at 0, converges to better than IEEE single-precision tolerance 
in 10 iterations.

from math import exp

def s(t):
   m = 0.25
   k = 0.1
   s0 = 300.0
   g = 32.17
   denom =  m*g/k
   coeff = m**2*g/k**2
   exparg = k/m
   return (s0+ coeff*(1-exp(-exparg*t)))/denom

t=0
for i in range(1,15):
   print i, s(t)
   t=s(t)


here is the output...

*rufus:/tmp %*python burger.py
1 3.73018340068
2 5.6679187484
3 5.97117033386
4 6.00075801098
5 6.00345727224
6 6.00370193736
7 6.00372410112
8 6.00372610878
9 6.00372629064
10 6.00372630712
11 6.00372630861
12 6.00372630875
13 6.00372630876
14 6.00372630876
15 6.00372630876

Congratulations to Bret Wilson who sent the correct code in just before 
class ended.  Literally minutes behind Bret were Emily Herron and Hannah 
Gulle who also both submitted correct code and answers.  Nicely done.



-- 
Andrew J. Pounds, Ph.D.  (pounds_aj at mercer.edu)
Professor of Chemistry and Computer Science
Mercer University,  Macon, GA 31207   (478) 301-5627
http://faculty.mercer.edu/pounds_aj

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://theochem.mercer.edu/pipermail/csc335/attachments/20170922/cd1396b8/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dbbjconakmlalgpj.png
Type: image/png
Size: 1996 bytes
Desc: not available
URL: <http://theochem.mercer.edu/pipermail/csc335/attachments/20170922/cd1396b8/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ecpgkhhhpbgfkkco.png
Type: image/png
Size: 816 bytes
Desc: not available
URL: <http://theochem.mercer.edu/pipermail/csc335/attachments/20170922/cd1396b8/attachment-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: koajppdadlldjgpo.png
Type: image/png
Size: 476 bytes
Desc: not available
URL: <http://theochem.mercer.edu/pipermail/csc335/attachments/20170922/cd1396b8/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fnghogakhjpgohjf.png
Type: image/png
Size: 1791 bytes
Desc: not available
URL: <http://theochem.mercer.edu/pipermail/csc335/attachments/20170922/cd1396b8/attachment-0003.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mfligbimjmdnihig.png
Type: image/png
Size: 1594 bytes
Desc: not available
URL: <http://theochem.mercer.edu/pipermail/csc335/attachments/20170922/cd1396b8/attachment-0004.png>


More information about the csc335 mailing list