(************** Content-type: application/mathematica ************** CreatedBy='Mathematica 5.0' Mathematica-Compatible Notebook This notebook can be used with any Mathematica-compatible application, such as Mathematica, MathReader or Publicon. The data for the notebook starts with the line containing stars above. To get the notebook into a Mathematica-compatible application, do one of the following: * Save the data starting with the line of stars above into a file with a name ending in .nb, then open the file inside the application; * Copy the data starting with the line of stars above to the clipboard, then use the Paste menu command inside the application. Data for notebooks contains only printable 7-bit ASCII and can be sent directly in email or through ftp in text mode. Newlines can be CR, LF or CRLF (Unix, Macintosh or MS-DOS style). NOTE: If you modify the data for this notebook not in a Mathematica- compatible application, you must delete the line below containing the word CacheID, otherwise Mathematica-compatible applications may try to use invalid cache data. For more information on notebooks and Mathematica-compatible applications, contact Wolfram Research: web: http://www.wolfram.com email: info@wolfram.com phone: +1-217-398-0700 (U.S.) Notebook reader applications are available free of charge from Wolfram Research. *******************************************************************) (*CacheID: 232*) (*NotebookFileLineBreakTest NotebookFileLineBreakTest*) (*NotebookOptionsPosition[ 231271, 9539]*) (*NotebookOutlinePosition[ 232502, 9576]*) (* CellTagsIndexPosition[ 232458, 9572]*) (*WindowFrame->Normal*) Notebook[{ Cell[CellGroupData[{ Cell["Nonlinear Differential Equations", "Subtitle", TextAlignment->Center, TextJustification->0], Cell["\<\ In this notebook, we solve nonlinear differential equations, \ looking at the time dependence, phase space plots, Poincare sections, and the \ power spectrum. The notebook starts with the Duffing equation. Your job is to modify it to \ the damped, driven pendulum, then to reproduce and extend the results from \ session 9 (which used diffeq_pendulum.cpp).\ \>", "Text"], Cell[CellGroupData[{ Cell["Define the Differential Equation", "Section"], Cell["\<\ Name the equation \"diffeq\". Note the \"==\" in defining the \ equation. \ \>", "Text"], Cell[BoxData[ \(diffeq\ := \ \(x''\)[t] + 2\ \[Gamma]\ \(x'\)[t] + \[Alpha]\ \ x[ t] + \[Beta]\ x[ t]^3 \[Equal] \(\(fext\)\(\ \)\(Cos[\[Omega]ext\ t]\)\(\ \)\)\ \)], "Input", CellLabel->"In[1]:="], Cell["Choose among the parameters:", "Text"], Cell[BoxData[ \(\(p1\ := \ {\[Alpha]\ = \(-1\), \[Beta] = 1, \[Omega]ext = 1, \ \[Gamma] = 0.25, fext = 0.34875};\)\)], "Input", CellLabel->"In[2]:="], Cell[CellGroupData[{ Cell[BoxData[ \(p1\)], "Input", CellLabel->"In[3]:="], Cell[BoxData[ \({\(-1\), 1, 1, 0.25`, 0.34875`}\)], "Output", CellLabel->"Out[3]="] }, Open ]], Cell["Choose among the initial conditions:", "Text"], Cell[BoxData[ \(\(ic1\ := \ {x0 = 1, v0 = 0. };\)\)], "Input", CellLabel->"In[4]:="], Cell[CellGroupData[{ Cell[BoxData[ \(ic1\)], "Input", CellLabel->"In[5]:="], Cell[BoxData[ \({1, 0.`}\)], "Output", CellLabel->"Out[5]="] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["Solve the Differential Equation", "Section"], Cell["\<\ Specify the range in time over which we will solve the differential \ equation. We won't be able to use the solution outside of this range. (I.e., \ we'll have to extend this range if we get an \"outside of range\" error \ later.)\ \>", "Text"], Cell[BoxData[ \(tmin = 0; \ tmax = 1000;\)], "Input", CellLabel->"In[6]:="], Cell["\<\ Numerically solve the differential equaiton using NDSolve, \ specifying the initial conditions. Setting MaxSteps to a large number is \ needed if tmax is large.\ \>", "Text"], Cell[BoxData[ \(\(solution\ = \ NDSolve[{diffeq, x[0] \[Equal] x0, \ \(x'\)[0] \[Equal] v0}, x, {t, tmin, tmax}, MaxSteps \[Rule] 20000];\)\)], "Input", CellLabel->"In[7]:="], Cell["\<\ NDSolve returns an \"interpolating function\", which can be \ evaluated later at any time t in tmin < t < tmax.\ \>", "Text"] }, Open ]], Cell[CellGroupData[{ Cell["Plot the Time Dependence and Phase Space", "Section"], Cell["\<\ We can just use \"Plot\" with Evaluate and the \"interpolating \ function\" defined by \"solution\".\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Plot[Evaluate[x[t] /. solution], {t, 0, 100}]\)], "Input", CellLabel->"In[8]:="], Cell[GraphicsData["PostScript", "\<\ %! %%Creator: Mathematica %%AspectRatio: .61803 MathPictureStart /Mabs { Mgmatrix idtransform Mtmatrix dtransform } bind def /Mabsadd { Mabs 3 -1 roll add 3 1 roll add exch } bind def %% Graphics %%IncludeResource: font Courier %%IncludeFont: Courier /Courier findfont 10 scalefont setfont % Scaling calculations 0.0238095 0.00952381 0.0147151 0.418578 [ [.21429 .00222 -6 -9 ] [.21429 .00222 6 0 ] [.40476 .00222 -6 -9 ] [.40476 .00222 6 0 ] [.59524 .00222 -6 -9 ] [.59524 .00222 6 0 ] [.78571 .00222 -6 -9 ] [.78571 .00222 6 0 ] [.97619 .00222 -9 -9 ] [.97619 .00222 9 0 ] [.01131 .09843 -18 -4.5 ] [.01131 .09843 0 4.5 ] [.01131 .18215 -18 -4.5 ] [.01131 .18215 0 4.5 ] [.01131 .26586 -18 -4.5 ] [.01131 .26586 0 4.5 ] [.01131 .34958 -18 -4.5 ] [.01131 .34958 0 4.5 ] [.01131 .43329 -6 -4.5 ] [.01131 .43329 0 4.5 ] [.01131 .51701 -18 -4.5 ] [.01131 .51701 0 4.5 ] [.01131 .60072 -18 -4.5 ] [.01131 .60072 0 4.5 ] [ 0 0 0 0 ] [ 1 .61803 0 0 ] ] MathScale % Start of Graphics 1 setlinecap 1 setlinejoin newpath 0 g .25 Mabswid [ ] 0 setdash .21429 .01472 m .21429 .02097 L s [(20)] .21429 .00222 0 1 Mshowa .40476 .01472 m .40476 .02097 L s [(40)] .40476 .00222 0 1 Mshowa .59524 .01472 m .59524 .02097 L s [(60)] .59524 .00222 0 1 Mshowa .78571 .01472 m .78571 .02097 L s [(80)] .78571 .00222 0 1 Mshowa .97619 .01472 m .97619 .02097 L s [(100)] .97619 .00222 0 1 Mshowa .125 Mabswid .07143 .01472 m .07143 .01847 L s .11905 .01472 m .11905 .01847 L s .16667 .01472 m .16667 .01847 L s .2619 .01472 m .2619 .01847 L s .30952 .01472 m .30952 .01847 L s .35714 .01472 m .35714 .01847 L s .45238 .01472 m .45238 .01847 L s .5 .01472 m .5 .01847 L s .54762 .01472 m .54762 .01847 L s .64286 .01472 m .64286 .01847 L s .69048 .01472 m .69048 .01847 L s .7381 .01472 m .7381 .01847 L s .83333 .01472 m .83333 .01847 L s .88095 .01472 m .88095 .01847 L s .92857 .01472 m .92857 .01847 L s .25 Mabswid 0 .01472 m 1 .01472 L s .02381 .09843 m .03006 .09843 L s [(0.2)] .01131 .09843 1 0 Mshowa .02381 .18215 m .03006 .18215 L s [(0.4)] .01131 .18215 1 0 Mshowa .02381 .26586 m .03006 .26586 L s [(0.6)] .01131 .26586 1 0 Mshowa .02381 .34958 m .03006 .34958 L s [(0.8)] .01131 .34958 1 0 Mshowa .02381 .43329 m .03006 .43329 L s [(1)] .01131 .43329 1 0 Mshowa .02381 .51701 m .03006 .51701 L s [(1.2)] .01131 .51701 1 0 Mshowa .02381 .60072 m .03006 .60072 L s [(1.4)] .01131 .60072 1 0 Mshowa .125 Mabswid .02381 .03564 m .02756 .03564 L s .02381 .05657 m .02756 .05657 L s .02381 .0775 m .02756 .0775 L s .02381 .11936 m .02756 .11936 L s .02381 .14029 m .02756 .14029 L s .02381 .16122 m .02756 .16122 L s .02381 .20308 m .02756 .20308 L s .02381 .224 m .02756 .224 L s .02381 .24493 m .02756 .24493 L s .02381 .28679 m .02756 .28679 L s .02381 .30772 m .02756 .30772 L s .02381 .32865 m .02756 .32865 L s .02381 .37051 m .02756 .37051 L s .02381 .39144 m .02756 .39144 L s .02381 .41236 m .02756 .41236 L s .02381 .45422 m .02756 .45422 L s .02381 .47515 m .02756 .47515 L s .02381 .49608 m .02756 .49608 L s .02381 .53794 m .02756 .53794 L s .02381 .55887 m .02756 .55887 L s .02381 .5798 m .02756 .5798 L s .25 Mabswid .02381 0 m .02381 .61803 L s 0 0 m 1 0 L 1 .61803 L 0 .61803 L closepath clip newpath .5 Mabswid .02381 .43329 m .02499 .43438 L .02605 .43714 L .02729 .44217 L .02846 .44839 L .03279 .47698 L .03398 .4842 L .03524 .49053 L .03631 .49447 L .0375 .49693 L .03877 .49709 L .03949 .49599 L .04014 .49421 L .04141 .48869 L .04262 .48101 L .045 .4598 L .04753 .43058 L .0521 .37073 L .05472 .33718 L .05749 .30538 L .06005 .28086 L .06244 .26343 L .0637 .25675 L .06441 .25383 L .06505 .25172 L .06575 .25004 L .06652 .249 L .06724 .24879 L .06791 .2493 L .06861 .2506 L .06927 .25256 L .07 .25555 L .07078 .2598 L .07237 .27188 L .07382 .28714 L .07632 .32275 L .07905 .37453 L .08193 .43959 L .08454 .50015 L .08578 .52617 L .08712 .55044 L .08839 .56826 L .08956 .57935 L .0908 .58492 L .09151 .58515 L .09217 .58347 L .09286 .57977 L .09349 .57476 L .09423 .5672 L .09492 .55844 L Mistroke .09954 .47563 L .10458 .37862 L .10991 .29949 L .11252 .26984 L .11492 .24694 L .11707 .2296 L .11943 .21398 L .12179 .20217 L .12309 .19761 L .12429 .19474 L .1256 .1933 L .12634 .19334 L .12702 .19396 L .12827 .19669 L .1289 .1989 L .1296 .20203 L .1308 .20922 L .13209 .2197 L .13443 .24649 L .13575 .26634 L .13719 .29203 L .14009 .35581 L .14528 .49282 L .14782 .55205 L .14852 .56495 L .14926 .57651 L .15058 .59114 L .15181 .5971 L .15296 .59576 L .15422 .58696 L .15493 .57898 L .15558 .57001 L .15788 .52808 L .16038 .47258 L .16493 .37301 L .1702 .28326 L .17287 .24864 L .17581 .21692 L .17831 .19458 L .18101 .17503 L .18225 .16776 L .18355 .1614 L .18467 .15713 L .18589 .15382 L .18721 .15204 L .18842 .1522 L .18905 .15305 L .18975 .15463 L .19048 .15703 L .19117 .16002 L Mistroke .19242 .16751 L .19357 .17677 L .19489 .19053 L .19615 .20685 L .19846 .24559 L .20061 .29182 L .20548 .42651 L .20822 .50681 L .20956 .5415 L .2108 .56811 L .21192 .58654 L .21311 .5989 L .21431 .60332 L .21562 .59888 L .21634 .59247 L .21703 .58404 L .21831 .56287 L .2212 .49795 L .22642 .36812 L .2314 .2678 L .23608 .19806 L .24096 .14372 L .24355 .12149 L .245 .11123 L .24634 .10322 L .24752 .09756 L .24858 .09359 L .24977 .0906 L .25103 .08923 L .25225 .08984 L .25356 .09283 L .25481 .09808 L .25596 .10517 L .25701 .11369 L .258 .1235 L .26024 .15291 L .26242 .1916 L .26477 .2445 L .26968 .38798 L .27238 .47357 L .27491 .54279 L .27636 .57149 L .27717 .58294 L .27792 .59011 L .27855 .59356 L .27925 .59455 L .27997 .59251 L .28064 .58786 L .28134 .58052 L .28199 .57136 L Mistroke .28321 .54921 L .28596 .48308 L .291 .34792 L .29572 .24236 L .30064 .16098 L .30325 .12813 L .30607 .10028 L .3073 .09055 L .30862 .08197 L .30938 .07791 L .31007 .0748 L .31076 .07223 L .31141 .0704 L .31266 .06837 L .31333 .06817 L .31402 .06863 L .3152 .07103 L .31649 .07614 L .31773 .08367 L .31887 .09288 L .32142 .12226 L .32379 .16084 L .32603 .20786 L .33479 .46341 L .33719 .52762 L .33785 .5418 L .33854 .55465 L .33978 .57162 L .34094 .5798 L .34202 .58044 L .3432 .57358 L .34447 .55828 L .34571 .53641 L .34707 .50694 L .34952 .44466 L .35411 .32637 L .3567 .26891 L .35945 .2179 L .36182 .18196 L .36437 .15153 L .36558 .14002 L .36673 .13089 L .36786 .12375 L .3689 .11871 L .36988 .1154 L .37092 .1135 L .37208 .11341 L .37314 .11527 L .37438 .11998 L .37552 .12682 L Mistroke .37678 .13724 L .37811 .15172 L .38034 .18454 L .38278 .23316 L .3876 .36421 L .39013 .44419 L .39282 .52316 L .39395 .55042 L .39517 .57365 L .39587 .58355 L .39651 .59023 L .39776 .59631 L .39882 .59411 L .39998 .58433 L .4012 .56681 L .40232 .54504 L .40762 .40865 L .41327 .27202 L .4185 .17926 L .42325 .11904 L .42556 .09711 L .42811 .07893 L .42939 .07234 L .4301 .06949 L .43077 .06734 L .43206 .06474 L .43325 .0643 L .43436 .06566 L .43554 .06911 L .43655 .07378 L .43766 .08087 L .43885 .09081 L .44014 .1044 L .44246 .13698 L .44498 .18439 L .44774 .25076 L .45331 .41821 L .4558 .49229 L .45717 .52671 L .45847 .55256 L .45967 .56933 L .46098 .57847 L .46217 .57825 L .46327 .57104 L .47306 .35073 L .47564 .29049 L .47846 .23473 L .48115 .19163 L .48359 .16099 L .48609 .13792 L Mistroke .48746 .12891 L .48875 .1229 L .48995 .11956 L .49105 .11848 L .49226 .11962 L .49353 .12358 L .49462 .12929 L .49578 .13791 L .49687 .14852 L .49787 .16038 L .50031 .19855 L .50263 .24696 L .50716 .37265 L .51142 .50384 L .51356 .55688 L .51476 .57829 L .51586 .59117 L .517 .59704 L .51824 .59457 L .51955 .5826 L .52076 .56395 L .52209 .53673 L .52335 .50647 L .52571 .44391 L .531 .30895 L .53554 .21813 L .53792 .17998 L .54047 .14511 L .54303 .11597 L .54536 .09439 L .54649 .0858 L .54771 .07785 L .54886 .07181 L .54994 .06746 L .5506 .06547 L .55131 .06391 L .55256 .06276 L .55326 .06303 L .55401 .06408 L .55465 .06562 L .55534 .06801 L .5566 .07422 L .5573 .07882 L .55794 .08374 L .56035 .10893 L .56166 .12713 L .56305 .15008 L .56554 .20092 L .57117 .357 L .57391 .44274 L Mistroke .57525 .48247 L .57651 .5155 L .57773 .54244 L .57885 .56108 L .58008 .57421 L .5814 .57871 L .58261 .57415 L .58372 .56308 L .58494 .54432 L .58624 .51848 L .5908 .40327 L .59603 .27787 L .59858 .22909 L .60091 .19244 L .60293 .16672 L .60512 .14496 L .60632 .13583 L .60744 .12921 L .6085 .12459 L .60963 .12157 L .61076 .12059 L .61198 .12193 L .61313 .12558 L .61418 .13107 L .61535 .13966 L .61663 .15223 L .61921 .18817 L .62174 .23781 L .62449 .30725 L .62947 .45974 L .63183 .52741 L .63312 .55745 L .63432 .57886 L .63535 .59099 L .63645 .59716 L .63768 .59548 L .6388 .58642 L .64009 .56807 L .64147 .54099 L .64394 .47993 L .64954 .3331 L .65489 .22236 L .65974 .14937 L .66227 .11987 L .66463 .09733 L .66709 .07925 L .66839 .07212 L .66911 .06895 L .66978 .06654 L .67097 .0636 L Mistroke .67226 .06242 L .6734 .06325 L .67461 .06617 L .67569 .07067 L .6767 .07658 L .67781 .08506 L .67901 .09661 L .68154 .1298 L .68431 .18042 L .6872 .2494 L .68988 .32644 L .6924 .40518 L .69506 .48545 L .69616 .51425 L .69734 .54048 L .69863 .56216 L .69984 .57452 L .70049 .57777 L .7012 .57854 L .70248 .57272 L .70374 .55876 L .7049 .53959 L .70755 .4801 L .71038 .40638 L .7155 .28264 L .71801 .23386 L .72032 .19674 L .72256 .16762 L .72501 .14353 L .72629 .13428 L .72748 .12778 L .72873 .1232 L .72944 .1217 L .73008 .12103 L .73121 .12151 L .73226 .12391 L .7334 .12883 L .73462 .13676 L .73567 .14602 L .73666 .15678 L .73891 .18912 L .74387 .29988 L .74929 .46475 L .75177 .53454 L .75315 .56493 L .7544 .58463 L .75558 .59514 L .75685 .59727 L .75805 .59056 L .75915 .57753 L Mistroke .76023 .55949 L .76138 .53543 L .76345 .48391 L .76816 .35869 L .77278 .25538 L .77768 .17286 L .78019 .13972 L .78296 .10951 L .78548 .08789 L .78661 .08014 L .78785 .07313 L .7892 .06736 L .78994 .0651 L .79063 .06359 L .79186 .06238 L .79317 .06335 L .79392 .06499 L .79472 .0677 L .79548 .07119 L .79618 .07523 L .79751 .08514 L .79891 .09902 L .8013 .13099 L .80386 .17779 L .8085 .29459 L .81114 .37563 L .81396 .46304 L .81533 .50139 L .81663 .53231 L .81778 .55428 L .81903 .57052 L .82026 .57802 L .82096 .57844 L .8216 .57637 L .82291 .56529 L .82365 .55542 L .82431 .54442 L .82681 .4907 L .82916 .42998 L .8349 .28859 L .83742 .23864 L .84021 .19377 L .84262 .16337 L .84488 .14204 L .84613 .13332 L .84727 .12731 L .84852 .12295 L .84984 .12103 L .85109 .12186 L .8518 .12351 L Mistroke .85243 .12578 L .85367 .13236 L .85484 .14129 L .85621 .15525 L .85747 .1716 L .86031 .2214 L .86937 .47715 L .87062 .5132 L .87199 .54741 L .87327 .57284 L .87446 .5889 L .87553 .59642 L .87671 .59678 L .87795 .5885 L .8791 .57343 L .88041 .54947 L .88178 .51824 L .88424 .45406 L .88978 .31206 L .89454 .21708 L .89976 .14107 L .90229 .113 L .90503 .08887 L .90629 .08016 L .90762 .07267 L .90876 .0678 L .91001 .06416 L .91123 .0625 L .91233 .06268 L .91361 .06504 L .91483 .06956 L .91595 .07579 L .91699 .08344 L .91934 .10785 L .92066 .12601 L .92208 .14944 L .92466 .20223 L .92948 .33367 L .93218 .41822 L .93507 .50273 L .93647 .53576 L .93716 .54908 L .93779 .55938 L .93899 .57291 L .94028 .57857 L .94127 .57642 L .9422 .56951 L .94322 .55696 L .94432 .53841 L .94861 .43616 L Mistroke .95297 .3249 L .95545 .27049 L .95775 .22734 L .9602 .18931 L .96244 .16187 L .96482 .14003 L .96613 .13141 L .96737 .12557 L .96844 .1224 L .96957 .12101 L .97054 .1215 L .9716 .12391 L .97275 .12878 L .97397 .13677 L .97513 .14705 L .97619 .15888 L Mfstroke % End of Graphics MathPictureEnd \ \>"], "Graphics", CellLabel->"From In[8]:=", ImageSize->{288, 177.938}, ImageMargins->{{0, 0}, {0, 0}}, ImageRegion->{{0, 1}, {0, 1}}, ImageCacheValid->False, ImageRangeCache->{{{109, 396}, {285.938, 109}} -> {-50.8007, 0.847879, \ 0.389667, 0.008866}}], Cell[BoxData[ TagBox[\(\[SkeletonIndicator] Graphics \[SkeletonIndicator]\), False, Editable->False]], "Output", CellLabel->"Out[8]="] }, Open ]], Cell["\<\ Or we can do a parametric plot (\"ParametricPlot\") with the same \ solution. We've added various options here to (try to) make a nicer \ plot.\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(ParametricPlot[ Evaluate[{t, x[t]} /. solution], {t, 0, 100}, \[IndentingNewLine]PlotStyle \[Rule] Hue[ .6], \[IndentingNewLine]TextStyle \[Rule] {FontFamily -> \ "\", FontSize \[Rule] 14}, ImageSize \[Rule] {350, 200}, PlotLabel \[Rule] StyleForm["\