Lissajous

This NoteBook is unevaluated to save space.
The Initialization will evaluate a sample.  You can also use <Evaluate NoteBook> form the Action Menu.

The program below will take solutions generated by the bddSolnRK package for the spring pendulum equation and graph the path of the bob on the end of the spring.
	
	The cell below contains test data of the form that the bddSolnRK package generates.

Sample data

solution = {{0., 2.5, 0., 0.05, 0.}, 
  {0.1, 2.490502, -0.1886912, 0.04902048, -0.01958747}, 
  {0.2, 2.46276, -0.3624795, 0.04608376, -0.03912984}, 
  {0.3, 2.418965, -0.5076404, 0.04120072, -0.05847202}, 
  {0.4, 2.362576, -0.6127168, 0.03440791, -0.07723776}, 
  {0.5, 2.298043, -0.6694406, 0.025795, -0.09472549}, 
  {0.6, 2.230457, -0.6734123, 0.01554127, -0.1098385}, 
  {0.7, 2.165136, -0.624478, 0.00395532, -0.1211004}, 
  {0.8, 2.107199, -0.5267554, -0.008493646, -0.1268177}, 
  {0.9, 2.061153, -0.3882842, -0.02117, -0.1254266}, 
  {1., 2.030533, -0.2203135, -0.03330806, -0.1159725}, 
  {1.1, 2.01763, -0.03629295, -0.04409647, -0.09855325}, 
  {1.2, 2.023329, 0.1493063, -0.05279531, -0.07449635}, 
  {1.3, 2.047066, 0.3221858, -0.05885087, -0.04612658}, 
  {1.4, 2.086903, 0.4692996, -0.06196887, -0.01620057}, 
  {1.5, 2.139697, 0.579752, -0.06212504, 0.01273509}, 
  {1.6, 2.201354, 0.6454996, -0.05951906, 0.03879817}, 
  {1.7, 2.267141, 0.6618601, -0.05449808, 0.0609224}, 
  {1.8, 2.332036, 0.6278169, -0.04747865, 0.07875548}, 
  {1.9, 2.391104, 0.5460899, -0.03888622, 0.09243035}, 
  {2., 2.439864, 0.4229504, -0.02911892, 0.1023231}, 
  {2.1, 2.474619, 0.2677709, -0.01853351, 0.1088589}, 
  {2.2, 2.492737, 0.09233504, -0.00744739, 0.1123823}, 
  {2.3, 2.492851, -0.09004622, 0.003849093, 0.1130819}, 
  {2.4, 2.474958, -0.2655414, 0.01507511, 0.1109563}, 
  {2.5, 2.440419, -0.4208484, 0.0259399, 0.1058098}, 
  {2.6, 2.391859, -0.5442005, 0.03612443, 0.09728058}, 
  {2.7, 2.332963, -0.6262483, 0.04526776, 0.08490771}, 
  {2.8, 2.268203, -0.6607458, 0.05296281, 0.06825518}, 
  {2.9, 2.202499, -0.644993, 0.05876782, 0.0471022}, 
  {3., 2.140856, -0.5800119, 0.06223985, 0.02168889}, 
  {3.1, 2.087993, -0.4704623, 0.06299346, -0.007040447}, 
  {3.2, 2.047992, -0.3243261, 0.06077913, -0.03730763}, 
  {3.3, 2.023994, -0.1523947, 0.05556335, -0.06661593}, 
  {3.4, 2.017947, 0.03242304, 0.04758165, -0.09217327}, 
  {3.5, 2.030438, 0.215973, 0.03733735, -0.1115262}, 
  {3.6, 2.06062, 0.3839009, 0.0255365, -0.1231505}, 
  {3.7, 2.106247, 0.5228149, 0.01297763, -0.126733}, 
  {3.8, 2.163832, 0.6214489, 0.0004338373, -0.1230461}, 
  {3.9, 2.228913, 0.6716741, -0.01143669, -0.1135352}, 
  {4., 2.2964, 0.6692302, -0.0221338, -0.09984328}, 
  {4.1, 2.360991, 0.6140995, -0.03131566, -0.08344872}, 
  {4.2, 2.417594, 0.5105051, -0.03877163, -0.06548021}, 
  {4.3, 2.461737, 0.3665556, -0.04438453, -0.04668137}, 
  {4.4, 2.48993, 0.1935802, -0.04809441, -0.02746647}, 
  {4.5, 2.499936, 0.00521906, -0.04987019, -0.00801638}, 
  {4.6, 2.490954, -0.1836609, -0.04969166, 0.01161427}, 
  {4.7, 2.463685, -0.3581399, -0.04754232, 0.03138854}, 
  {4.8, 2.420271, -0.5044235, -0.04341305, 0.05117663}, 
  {4.9, 2.364133, -0.6109378, -0.03731712, 0.07064129}, 
  {5., 2.2997, -0.6692607, -0.02931666, 0.08912637}, 
  {5.1, 2.232051, -0.6748163, -0.01955902, 0.1055737}, 
  {5.2, 2.166518, -0.627271, -0.008318222, 0.1185184}, 
  {5.3, 2.108247, -0.5305851, 0.003969966, 0.1262284}, 
  {5.4, 2.061785, -0.3926891, 0.01669613, 0.1270325}, 
  {5.5, 2.030716, -0.2247929, 0.02910652, 0.1198}, 
  {5.6, 2.017381, -0.04038489, 0.04038174, 0.1044122}, 
  {5.7, 2.022705, 0.1459583, 0.04975221, 0.08198985}, 
  {5.8, 2.046154, 0.3197952, 0.05661662, 0.05471346}, 
  {5.9, 2.085803, 0.4679345, 0.06062319, 0.02528775}, 
  {6., 2.138511, 0.5793617, 0.06168954, -0.003704296}, 
  {6.1, 2.200173, 0.6459552, 0.05996409, -0.03028503}, 
  {6.2, 2.26604, 0.6629954, 0.05575375, -0.05327005}, 
  {6.3, 2.331075, 0.6294591, 0.04944647, -0.07219535}, 
  {6.4, 2.390327, 0.5480805, 0.04144922, -0.08710461}, 
  {6.5, 2.439297, 0.4251541, 0.03214925, -0.09831171}, 
  {6.6, 2.474278, 0.2700784, 0.02189739, -0.1062043}, 
  {6.7, 2.492629, 0.0946602, 0.01100788, -0.1111077}, 
  {6.8, 2.492973, -0.08777194, -0.0002308171, -0.1132031}, 
  {6.9, 2.475302, -0.2633767, -0.01153929, -0.1124859}, 
  {7., 2.440972, -0.4188507, -0.02262779, -0.1087546}, 
  {7.1, 2.392601, -0.5424359, -0.03317731, -0.1016317}, 
  {7.2, 2.333867, -0.6247995, -0.04282451, -0.0906228}, 
  {7.3, 2.269232, -0.6597183, -0.05115543, -0.07523426}, 
  {7.4, 2.203604, -0.6445152, -0.05771422, -0.05515893}, 
  {7.5, 2.141975, -0.5802255, -0.06203387, -0.03052437}, 
  {7.6, 2.08905, -0.4714991, -0.06369277, -0.002149301}, 
  {7.7, 2.048901, -0.3262726, -0.06239312, 0.02830012}, 
  {7.8, 2.024662, -0.155249, -0.05804403, 0.05838969}, 
  {7.9, 2.018289, 0.02878887, -0.05082137, 0.08530781}, 
  {8., 2.030389, 0.2118281, -0.04117542, 0.1064878}, 
  {8.1, 2.060146, 0.3796372, -0.02977449, 0.1202193}, 
  {8.2, 2.10536, 0.5188967, -0.01739972, 0.1259769}, 
  {8.3, 2.162591, 0.6183413, -0.004827128, 0.1243458}, 
  {8.4, 2.227418, 0.6697707, 0.007266204, 0.1166436}, 
  {8.5, 2.294787, 0.6687954, 0.01835179, 0.1044514}, 
  {8.6, 2.359413, 0.6152338, 0.02805616, 0.08923997}, 
  {8.7, 2.416205, 0.5131345, 0.03613811, 0.07216328}, 
  {8.8, 2.460677, 0.3704424, 0.04245321, 0.05400316}, 
  {8.9, 2.489305, 0.1983516, 0.04691805, 0.03521049}, 
  {9., 2.499813, 0.01040649, 0.04948133, 0.01599208}, 
  {9.1, 2.49135, -0.1785727, 0.05010447, -0.003586932}, 
  {9.2, 2.464563, -0.3536607, 0.04875273, -0.02349665}, 
  {9.3, 2.421548, -0.5010051, 0.0453972, -0.04363185}, 
  {9.4, 2.365684, -0.6089253, 0.04002812, -0.063695}, 
  {9.5, 2.301372, -0.6688515, 0.03268006, -0.08307825}, 
  {9.6, 2.233683, -0.6760324, 0.02346812, -0.1007678}, 
  {9.7, 2.167953, -0.6299504, 0.01263056, -0.1153195}, 
  {9.8, 2.109353, -0.534397, 0.0005675258, -0.1249742}, 
  {9.9, 2.062472, -0.397177, -0.01214113, -0.1279645}, 
  {10., 2.030943, -0.229442, -0.02475797, -0.1229915}, 
  {10.1, 2.017156, -0.04470176, -0.03646028, -0.10972}, 
  {10.2, 2.022082, 0.1423727, -0.04645317, -0.08905548}, 
  {10.3, 2.04522, 0.317198, -0.05409087, -0.0630199}, 
  {10.4, 2.084664, 0.4664297, -0.05896574, -0.03424988}, 
  {10.5, 2.137275, 0.5789195, -0.06093733, -0.005351077}, 
  {10.6, 2.198941, 0.6464506, -0.06010177, 0.02161258}, 
  {10.7, 2.264897, 0.6642495, -0.05672392, 0.04534319}, 
  {10.8, 2.330087, 0.6312747, -0.05116112, 0.0652662}, 
  {10.9, 2.38954, 0.5502672, -0.04379985, 0.08133514}, 
  {11., 2.438741, 0.4275433, -0.03501457, 0.09379998}, 
  {11.1, 2.473965, 0.2725306, -0.02514845, 0.1030089}, 
  {11.2, 2.49256, 0.09706644, -0.01451102, 0.1092668}, 
  {11.3, 2.493139, -0.08549301, -0.003387426, 0.1127467}, 
  {11.4, 2.475687, -0.2612847, 0.007945767, 0.1134409}, 
  {11.5, 2.441554, -0.4169923, 0.01920132, 0.1111433}, 
  {11.6, 2.393355, -0.5408549, 0.03006184, 0.1054623}, 
  {11.7, 2.334763, -0.6235486, 0.04016345, 0.09587264}, 
  {11.8, 2.270234, -0.6588687, 0.04908738, 0.08182516}, 
  {11.9, 2.204668, -0.644162, 0.05636597, 0.06292815}, 
  {12., 2.143044, -0.580484, 0.0615105, 0.03919655}, 
  {12.1, 2.090058, -0.4724879, 0.06406547, 0.0113205}, 
  {12.2, 2.049769, -0.3280821, 0.06368645, -0.01915316}, 
  {12.3, 2.025307, -0.157899, 0.06022603, -0.04986465}, 
  {12.4, 2.018631, 0.0253896, 0.05379975, -0.07799808}, 
  {12.5, 2.030361, 0.2079046, 0.04480268, -0.1008891}, 
  {12.6, 2.059714, 0.3755403, 0.03386182, -0.1166528}, 
  {12.7, 2.104528, 0.5150604, 0.02173651, -0.124556}, 
  {12.8, 2.161407, 0.6152173, 0.009201272, -0.1249939}, 
  {12.9, 2.225975, 0.6677577, -0.00305179, -0.1191471}, 
  {13., 2.29321, 0.6681784, -0.01446873, -0.1085249}, 
  {13.1, 2.35785, 0.6161441, -0.02464629, -0.09458072}, 
  {13.2, 2.414809, 0.5155341, -0.03331367, -0.07848652}, 
  {13.3, 2.459587, 0.374129, -0.04029961, -0.06105809}, 
  {13.4, 2.488635, 0.2029818, -0.0454974, -0.04278095}, 
  {13.5, 2.499635, 0.01553288, -0.0488355, -0.02388771}, 
  {13.6, 2.491689, -0.1734561, -0.050257, -0.004454849}, 
  {13.7, 2.465391, -0.3490672, -0.04970912, 0.01549357}, 
  {13.8, 2.422789, -0.4974023, -0.04714342, 0.03587611}, 
  {13.9, 2.36722, -0.6066849, -0.04252739, 0.05643523}, 
  {14., 2.303054, -0.6682055, -0.03586825, 0.07661372}, 
  {14.1, 2.235346, -0.6770412, -0.02724861, 0.09544749}, 
  {14.2, 2.169437, -0.6324874, -0.01687009, 0.111522}, 
  {14.3, 2.110519, -0.5381579, -0.00509528, 0.1230625}, 
  {14.4, 2.063219, -0.4017163, 0.007528714, 0.1282178}, 
  {14.5, 2.031219, -0.2342366, 0.02028496, 0.1255294}, 
  {14.6, 2.016961, -0.04923141, 0.03235228, 0.1144473}, 
  {14.7, 2.021467, 0.1385471, 0.04291496, 0.09565507}, 
  {14.8, 2.044271, 0.3143782, 0.0512863, 0.07100211}, 
  {14.9, 2.083489, 0.4647586, 0.05700466, 0.04304078}, 
  {15., 2.135991, 0.5783936, 0.05987193, 0.0143851}}

The cell below conatains the lissajous package.

lissajous package

BeginPackage["Lissajous`"]

Begin["`Private`"]

xypoint[{l_, theta_}] := {l Sin[theta], -l Cos[theta]} 

lissajous[solution_List, opns___Rule] :=
	Block[ {sols, lthetas, path},
		sols = Transpose[solution] ;
		lthetas = Transpose[{sols[[2]], sols[[4]]}] ;
		path = Map[ xypoint[#]&, lthetas ] ;
		Show[ Graphics[ Line[path] ], opns, Axes -> Automatic ]
	]
		
End[]

Protect[lissajous]

EndPackage[]

Once you have solved the spring pendulum equations with the Runge-Kutta package, you can pass these solutions to the lissajous package.  You can also pass Graphics options, like PlotRange.
	
		The test data above is called solution.  The call below generates the lissajous.

lissajous[ solution, PlotRange -> {{-0.2, 0.2}, {-2.6, -1}} ]