1.9.EXERCISES 11
0.166187 0.
0.540418 0.
0.968629 0.
0.118509 0.
Withverysimilarstartingvalues,theoutputsstaysimilarfora fewiterations,butthendiffermarkedly. By
aboutthefifthiteration,therenolongerseemstobeany relationshipbetweenthetwo models.
Thesetwo featuresofourchaosprogram,apparentunpredictabilityandextremesensitivitytoinitial
values,arethehallmarksofchaoticbehavior. Chaoshasimportantimplicationsforcomputerscience.It
turnsoutthatmany phenomenaintherealworldthatwemightlike tomodelandpredictwithourcomputers
exhibitjustthiskindofchaoticbehavior. Youmayhave heardoftheso-calledbutterflyeffect. Computer
modelsthatareusedtosimulateandpredictweatherpatternsaresosensitive thattheeffectofa single
butterflyflappingitswingsinNewJersey mightmake thedifferenceofwhetherornotrainis predictedin
Peoria.
It’s verypossiblethatevenwithperfectcomputermodeling,wemightneverbeabletomeasureexisting
weatherconditionsaccuratelyenoughto predictweathermorethana few daysin advance.Themeasurements
simplycan’t bepreciseenoughtomake thepredictionsaccurateover a longertimeframe.
Asyoucansee,thissmallprogramhasa valuablelessontoteachusersofcomputers. Asamazingas
computersare,theresultsthatthey give usareonlyasusefulasthemathematicalmodelsonwhichthe
programsarebased. Computerscangive incorrectresultsbecauseoferrorsinprograms,butevencorrect
programsmayproduceerroneousresultsif themodelsarewrongortheinitialinputsarenotaccurateenough.
1.9 Exercises
- Compareandcontrastthefollowingpairsofconceptsfromthechapter.
(a)Hardwarevs.Software
(b)Algorithmvs.Program
(c)ProgrammingLanguagevs.NaturalLanguage
(d)High-Level Languagevs.MachineLanguage
(e)Interpretervs.Compiler
(f)Syntaxvs.Semantics
- Listandexplaininyourownwordstheroleofeachofthefive basicfunctionalunitsofa computer
depictedinFigure1.1. - Writea detailedalgorithmformakinga peanutbutterandjellysandwich(orsomeothersimpleevery-
dayactivity). - Asyouwilllearnina laterchapter, many ofthenumbersstoredina computerarenotexactvalues,but
rathercloseapproximations.Forexample,thevalue0.1,mightbestoredas0.10000000000000000555.
Usually, suchsmalldifferencesarenota problem;however, givenwhatyouhave learnedaboutchaotic
behaviorinChapter1,youshouldrealizetheneedforcautionincertainsituations.Canyouthinkof
exampleswherethismightbea problem?Explain. - TracethroughtheChaosprogramfromSection1.6byhandusing 0 15 astheinputvalue.Showthe
sequenceofoutputthatresults. - EnterandruntheChaosprogramfromSection1.6usingwhateverPythonimplementationyouhave
available.Tryit outwithvariousvaluesofinputtoseethatit functionsasdescribedinthechapter. - ModifytheChaosprogramfromSection1.6using2.0inplaceof3.9asthemultiplierinthelogistic
function.Yourmodifiedlineofcodeshouldlooklike this: