File: auto.tex

package info (click to toggle)
auto-07p 0.9.1%2Bdfsg-7
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 16,200 kB
  • sloc: fortran: 22,644; f90: 19,340; python: 19,045; ansic: 11,116; sh: 1,079; makefile: 618; perl: 339
file content (13727 lines) | stat: -rw-r--r-- 584,522 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
6573
6574
6575
6576
6577
6578
6579
6580
6581
6582
6583
6584
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687
6688
6689
6690
6691
6692
6693
6694
6695
6696
6697
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708
6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769
6770
6771
6772
6773
6774
6775
6776
6777
6778
6779
6780
6781
6782
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792
6793
6794
6795
6796
6797
6798
6799
6800
6801
6802
6803
6804
6805
6806
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
6851
6852
6853
6854
6855
6856
6857
6858
6859
6860
6861
6862
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
6876
6877
6878
6879
6880
6881
6882
6883
6884
6885
6886
6887
6888
6889
6890
6891
6892
6893
6894
6895
6896
6897
6898
6899
6900
6901
6902
6903
6904
6905
6906
6907
6908
6909
6910
6911
6912
6913
6914
6915
6916
6917
6918
6919
6920
6921
6922
6923
6924
6925
6926
6927
6928
6929
6930
6931
6932
6933
6934
6935
6936
6937
6938
6939
6940
6941
6942
6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
6955
6956
6957
6958
6959
6960
6961
6962
6963
6964
6965
6966
6967
6968
6969
6970
6971
6972
6973
6974
6975
6976
6977
6978
6979
6980
6981
6982
6983
6984
6985
6986
6987
6988
6989
6990
6991
6992
6993
6994
6995
6996
6997
6998
6999
7000
7001
7002
7003
7004
7005
7006
7007
7008
7009
7010
7011
7012
7013
7014
7015
7016
7017
7018
7019
7020
7021
7022
7023
7024
7025
7026
7027
7028
7029
7030
7031
7032
7033
7034
7035
7036
7037
7038
7039
7040
7041
7042
7043
7044
7045
7046
7047
7048
7049
7050
7051
7052
7053
7054
7055
7056
7057
7058
7059
7060
7061
7062
7063
7064
7065
7066
7067
7068
7069
7070
7071
7072
7073
7074
7075
7076
7077
7078
7079
7080
7081
7082
7083
7084
7085
7086
7087
7088
7089
7090
7091
7092
7093
7094
7095
7096
7097
7098
7099
7100
7101
7102
7103
7104
7105
7106
7107
7108
7109
7110
7111
7112
7113
7114
7115
7116
7117
7118
7119
7120
7121
7122
7123
7124
7125
7126
7127
7128
7129
7130
7131
7132
7133
7134
7135
7136
7137
7138
7139
7140
7141
7142
7143
7144
7145
7146
7147
7148
7149
7150
7151
7152
7153
7154
7155
7156
7157
7158
7159
7160
7161
7162
7163
7164
7165
7166
7167
7168
7169
7170
7171
7172
7173
7174
7175
7176
7177
7178
7179
7180
7181
7182
7183
7184
7185
7186
7187
7188
7189
7190
7191
7192
7193
7194
7195
7196
7197
7198
7199
7200
7201
7202
7203
7204
7205
7206
7207
7208
7209
7210
7211
7212
7213
7214
7215
7216
7217
7218
7219
7220
7221
7222
7223
7224
7225
7226
7227
7228
7229
7230
7231
7232
7233
7234
7235
7236
7237
7238
7239
7240
7241
7242
7243
7244
7245
7246
7247
7248
7249
7250
7251
7252
7253
7254
7255
7256
7257
7258
7259
7260
7261
7262
7263
7264
7265
7266
7267
7268
7269
7270
7271
7272
7273
7274
7275
7276
7277
7278
7279
7280
7281
7282
7283
7284
7285
7286
7287
7288
7289
7290
7291
7292
7293
7294
7295
7296
7297
7298
7299
7300
7301
7302
7303
7304
7305
7306
7307
7308
7309
7310
7311
7312
7313
7314
7315
7316
7317
7318
7319
7320
7321
7322
7323
7324
7325
7326
7327
7328
7329
7330
7331
7332
7333
7334
7335
7336
7337
7338
7339
7340
7341
7342
7343
7344
7345
7346
7347
7348
7349
7350
7351
7352
7353
7354
7355
7356
7357
7358
7359
7360
7361
7362
7363
7364
7365
7366
7367
7368
7369
7370
7371
7372
7373
7374
7375
7376
7377
7378
7379
7380
7381
7382
7383
7384
7385
7386
7387
7388
7389
7390
7391
7392
7393
7394
7395
7396
7397
7398
7399
7400
7401
7402
7403
7404
7405
7406
7407
7408
7409
7410
7411
7412
7413
7414
7415
7416
7417
7418
7419
7420
7421
7422
7423
7424
7425
7426
7427
7428
7429
7430
7431
7432
7433
7434
7435
7436
7437
7438
7439
7440
7441
7442
7443
7444
7445
7446
7447
7448
7449
7450
7451
7452
7453
7454
7455
7456
7457
7458
7459
7460
7461
7462
7463
7464
7465
7466
7467
7468
7469
7470
7471
7472
7473
7474
7475
7476
7477
7478
7479
7480
7481
7482
7483
7484
7485
7486
7487
7488
7489
7490
7491
7492
7493
7494
7495
7496
7497
7498
7499
7500
7501
7502
7503
7504
7505
7506
7507
7508
7509
7510
7511
7512
7513
7514
7515
7516
7517
7518
7519
7520
7521
7522
7523
7524
7525
7526
7527
7528
7529
7530
7531
7532
7533
7534
7535
7536
7537
7538
7539
7540
7541
7542
7543
7544
7545
7546
7547
7548
7549
7550
7551
7552
7553
7554
7555
7556
7557
7558
7559
7560
7561
7562
7563
7564
7565
7566
7567
7568
7569
7570
7571
7572
7573
7574
7575
7576
7577
7578
7579
7580
7581
7582
7583
7584
7585
7586
7587
7588
7589
7590
7591
7592
7593
7594
7595
7596
7597
7598
7599
7600
7601
7602
7603
7604
7605
7606
7607
7608
7609
7610
7611
7612
7613
7614
7615
7616
7617
7618
7619
7620
7621
7622
7623
7624
7625
7626
7627
7628
7629
7630
7631
7632
7633
7634
7635
7636
7637
7638
7639
7640
7641
7642
7643
7644
7645
7646
7647
7648
7649
7650
7651
7652
7653
7654
7655
7656
7657
7658
7659
7660
7661
7662
7663
7664
7665
7666
7667
7668
7669
7670
7671
7672
7673
7674
7675
7676
7677
7678
7679
7680
7681
7682
7683
7684
7685
7686
7687
7688
7689
7690
7691
7692
7693
7694
7695
7696
7697
7698
7699
7700
7701
7702
7703
7704
7705
7706
7707
7708
7709
7710
7711
7712
7713
7714
7715
7716
7717
7718
7719
7720
7721
7722
7723
7724
7725
7726
7727
7728
7729
7730
7731
7732
7733
7734
7735
7736
7737
7738
7739
7740
7741
7742
7743
7744
7745
7746
7747
7748
7749
7750
7751
7752
7753
7754
7755
7756
7757
7758
7759
7760
7761
7762
7763
7764
7765
7766
7767
7768
7769
7770
7771
7772
7773
7774
7775
7776
7777
7778
7779
7780
7781
7782
7783
7784
7785
7786
7787
7788
7789
7790
7791
7792
7793
7794
7795
7796
7797
7798
7799
7800
7801
7802
7803
7804
7805
7806
7807
7808
7809
7810
7811
7812
7813
7814
7815
7816
7817
7818
7819
7820
7821
7822
7823
7824
7825
7826
7827
7828
7829
7830
7831
7832
7833
7834
7835
7836
7837
7838
7839
7840
7841
7842
7843
7844
7845
7846
7847
7848
7849
7850
7851
7852
7853
7854
7855
7856
7857
7858
7859
7860
7861
7862
7863
7864
7865
7866
7867
7868
7869
7870
7871
7872
7873
7874
7875
7876
7877
7878
7879
7880
7881
7882
7883
7884
7885
7886
7887
7888
7889
7890
7891
7892
7893
7894
7895
7896
7897
7898
7899
7900
7901
7902
7903
7904
7905
7906
7907
7908
7909
7910
7911
7912
7913
7914
7915
7916
7917
7918
7919
7920
7921
7922
7923
7924
7925
7926
7927
7928
7929
7930
7931
7932
7933
7934
7935
7936
7937
7938
7939
7940
7941
7942
7943
7944
7945
7946
7947
7948
7949
7950
7951
7952
7953
7954
7955
7956
7957
7958
7959
7960
7961
7962
7963
7964
7965
7966
7967
7968
7969
7970
7971
7972
7973
7974
7975
7976
7977
7978
7979
7980
7981
7982
7983
7984
7985
7986
7987
7988
7989
7990
7991
7992
7993
7994
7995
7996
7997
7998
7999
8000
8001
8002
8003
8004
8005
8006
8007
8008
8009
8010
8011
8012
8013
8014
8015
8016
8017
8018
8019
8020
8021
8022
8023
8024
8025
8026
8027
8028
8029
8030
8031
8032
8033
8034
8035
8036
8037
8038
8039
8040
8041
8042
8043
8044
8045
8046
8047
8048
8049
8050
8051
8052
8053
8054
8055
8056
8057
8058
8059
8060
8061
8062
8063
8064
8065
8066
8067
8068
8069
8070
8071
8072
8073
8074
8075
8076
8077
8078
8079
8080
8081
8082
8083
8084
8085
8086
8087
8088
8089
8090
8091
8092
8093
8094
8095
8096
8097
8098
8099
8100
8101
8102
8103
8104
8105
8106
8107
8108
8109
8110
8111
8112
8113
8114
8115
8116
8117
8118
8119
8120
8121
8122
8123
8124
8125
8126
8127
8128
8129
8130
8131
8132
8133
8134
8135
8136
8137
8138
8139
8140
8141
8142
8143
8144
8145
8146
8147
8148
8149
8150
8151
8152
8153
8154
8155
8156
8157
8158
8159
8160
8161
8162
8163
8164
8165
8166
8167
8168
8169
8170
8171
8172
8173
8174
8175
8176
8177
8178
8179
8180
8181
8182
8183
8184
8185
8186
8187
8188
8189
8190
8191
8192
8193
8194
8195
8196
8197
8198
8199
8200
8201
8202
8203
8204
8205
8206
8207
8208
8209
8210
8211
8212
8213
8214
8215
8216
8217
8218
8219
8220
8221
8222
8223
8224
8225
8226
8227
8228
8229
8230
8231
8232
8233
8234
8235
8236
8237
8238
8239
8240
8241
8242
8243
8244
8245
8246
8247
8248
8249
8250
8251
8252
8253
8254
8255
8256
8257
8258
8259
8260
8261
8262
8263
8264
8265
8266
8267
8268
8269
8270
8271
8272
8273
8274
8275
8276
8277
8278
8279
8280
8281
8282
8283
8284
8285
8286
8287
8288
8289
8290
8291
8292
8293
8294
8295
8296
8297
8298
8299
8300
8301
8302
8303
8304
8305
8306
8307
8308
8309
8310
8311
8312
8313
8314
8315
8316
8317
8318
8319
8320
8321
8322
8323
8324
8325
8326
8327
8328
8329
8330
8331
8332
8333
8334
8335
8336
8337
8338
8339
8340
8341
8342
8343
8344
8345
8346
8347
8348
8349
8350
8351
8352
8353
8354
8355
8356
8357
8358
8359
8360
8361
8362
8363
8364
8365
8366
8367
8368
8369
8370
8371
8372
8373
8374
8375
8376
8377
8378
8379
8380
8381
8382
8383
8384
8385
8386
8387
8388
8389
8390
8391
8392
8393
8394
8395
8396
8397
8398
8399
8400
8401
8402
8403
8404
8405
8406
8407
8408
8409
8410
8411
8412
8413
8414
8415
8416
8417
8418
8419
8420
8421
8422
8423
8424
8425
8426
8427
8428
8429
8430
8431
8432
8433
8434
8435
8436
8437
8438
8439
8440
8441
8442
8443
8444
8445
8446
8447
8448
8449
8450
8451
8452
8453
8454
8455
8456
8457
8458
8459
8460
8461
8462
8463
8464
8465
8466
8467
8468
8469
8470
8471
8472
8473
8474
8475
8476
8477
8478
8479
8480
8481
8482
8483
8484
8485
8486
8487
8488
8489
8490
8491
8492
8493
8494
8495
8496
8497
8498
8499
8500
8501
8502
8503
8504
8505
8506
8507
8508
8509
8510
8511
8512
8513
8514
8515
8516
8517
8518
8519
8520
8521
8522
8523
8524
8525
8526
8527
8528
8529
8530
8531
8532
8533
8534
8535
8536
8537
8538
8539
8540
8541
8542
8543
8544
8545
8546
8547
8548
8549
8550
8551
8552
8553
8554
8555
8556
8557
8558
8559
8560
8561
8562
8563
8564
8565
8566
8567
8568
8569
8570
8571
8572
8573
8574
8575
8576
8577
8578
8579
8580
8581
8582
8583
8584
8585
8586
8587
8588
8589
8590
8591
8592
8593
8594
8595
8596
8597
8598
8599
8600
8601
8602
8603
8604
8605
8606
8607
8608
8609
8610
8611
8612
8613
8614
8615
8616
8617
8618
8619
8620
8621
8622
8623
8624
8625
8626
8627
8628
8629
8630
8631
8632
8633
8634
8635
8636
8637
8638
8639
8640
8641
8642
8643
8644
8645
8646
8647
8648
8649
8650
8651
8652
8653
8654
8655
8656
8657
8658
8659
8660
8661
8662
8663
8664
8665
8666
8667
8668
8669
8670
8671
8672
8673
8674
8675
8676
8677
8678
8679
8680
8681
8682
8683
8684
8685
8686
8687
8688
8689
8690
8691
8692
8693
8694
8695
8696
8697
8698
8699
8700
8701
8702
8703
8704
8705
8706
8707
8708
8709
8710
8711
8712
8713
8714
8715
8716
8717
8718
8719
8720
8721
8722
8723
8724
8725
8726
8727
8728
8729
8730
8731
8732
8733
8734
8735
8736
8737
8738
8739
8740
8741
8742
8743
8744
8745
8746
8747
8748
8749
8750
8751
8752
8753
8754
8755
8756
8757
8758
8759
8760
8761
8762
8763
8764
8765
8766
8767
8768
8769
8770
8771
8772
8773
8774
8775
8776
8777
8778
8779
8780
8781
8782
8783
8784
8785
8786
8787
8788
8789
8790
8791
8792
8793
8794
8795
8796
8797
8798
8799
8800
8801
8802
8803
8804
8805
8806
8807
8808
8809
8810
8811
8812
8813
8814
8815
8816
8817
8818
8819
8820
8821
8822
8823
8824
8825
8826
8827
8828
8829
8830
8831
8832
8833
8834
8835
8836
8837
8838
8839
8840
8841
8842
8843
8844
8845
8846
8847
8848
8849
8850
8851
8852
8853
8854
8855
8856
8857
8858
8859
8860
8861
8862
8863
8864
8865
8866
8867
8868
8869
8870
8871
8872
8873
8874
8875
8876
8877
8878
8879
8880
8881
8882
8883
8884
8885
8886
8887
8888
8889
8890
8891
8892
8893
8894
8895
8896
8897
8898
8899
8900
8901
8902
8903
8904
8905
8906
8907
8908
8909
8910
8911
8912
8913
8914
8915
8916
8917
8918
8919
8920
8921
8922
8923
8924
8925
8926
8927
8928
8929
8930
8931
8932
8933
8934
8935
8936
8937
8938
8939
8940
8941
8942
8943
8944
8945
8946
8947
8948
8949
8950
8951
8952
8953
8954
8955
8956
8957
8958
8959
8960
8961
8962
8963
8964
8965
8966
8967
8968
8969
8970
8971
8972
8973
8974
8975
8976
8977
8978
8979
8980
8981
8982
8983
8984
8985
8986
8987
8988
8989
8990
8991
8992
8993
8994
8995
8996
8997
8998
8999
9000
9001
9002
9003
9004
9005
9006
9007
9008
9009
9010
9011
9012
9013
9014
9015
9016
9017
9018
9019
9020
9021
9022
9023
9024
9025
9026
9027
9028
9029
9030
9031
9032
9033
9034
9035
9036
9037
9038
9039
9040
9041
9042
9043
9044
9045
9046
9047
9048
9049
9050
9051
9052
9053
9054
9055
9056
9057
9058
9059
9060
9061
9062
9063
9064
9065
9066
9067
9068
9069
9070
9071
9072
9073
9074
9075
9076
9077
9078
9079
9080
9081
9082
9083
9084
9085
9086
9087
9088
9089
9090
9091
9092
9093
9094
9095
9096
9097
9098
9099
9100
9101
9102
9103
9104
9105
9106
9107
9108
9109
9110
9111
9112
9113
9114
9115
9116
9117
9118
9119
9120
9121
9122
9123
9124
9125
9126
9127
9128
9129
9130
9131
9132
9133
9134
9135
9136
9137
9138
9139
9140
9141
9142
9143
9144
9145
9146
9147
9148
9149
9150
9151
9152
9153
9154
9155
9156
9157
9158
9159
9160
9161
9162
9163
9164
9165
9166
9167
9168
9169
9170
9171
9172
9173
9174
9175
9176
9177
9178
9179
9180
9181
9182
9183
9184
9185
9186
9187
9188
9189
9190
9191
9192
9193
9194
9195
9196
9197
9198
9199
9200
9201
9202
9203
9204
9205
9206
9207
9208
9209
9210
9211
9212
9213
9214
9215
9216
9217
9218
9219
9220
9221
9222
9223
9224
9225
9226
9227
9228
9229
9230
9231
9232
9233
9234
9235
9236
9237
9238
9239
9240
9241
9242
9243
9244
9245
9246
9247
9248
9249
9250
9251
9252
9253
9254
9255
9256
9257
9258
9259
9260
9261
9262
9263
9264
9265
9266
9267
9268
9269
9270
9271
9272
9273
9274
9275
9276
9277
9278
9279
9280
9281
9282
9283
9284
9285
9286
9287
9288
9289
9290
9291
9292
9293
9294
9295
9296
9297
9298
9299
9300
9301
9302
9303
9304
9305
9306
9307
9308
9309
9310
9311
9312
9313
9314
9315
9316
9317
9318
9319
9320
9321
9322
9323
9324
9325
9326
9327
9328
9329
9330
9331
9332
9333
9334
9335
9336
9337
9338
9339
9340
9341
9342
9343
9344
9345
9346
9347
9348
9349
9350
9351
9352
9353
9354
9355
9356
9357
9358
9359
9360
9361
9362
9363
9364
9365
9366
9367
9368
9369
9370
9371
9372
9373
9374
9375
9376
9377
9378
9379
9380
9381
9382
9383
9384
9385
9386
9387
9388
9389
9390
9391
9392
9393
9394
9395
9396
9397
9398
9399
9400
9401
9402
9403
9404
9405
9406
9407
9408
9409
9410
9411
9412
9413
9414
9415
9416
9417
9418
9419
9420
9421
9422
9423
9424
9425
9426
9427
9428
9429
9430
9431
9432
9433
9434
9435
9436
9437
9438
9439
9440
9441
9442
9443
9444
9445
9446
9447
9448
9449
9450
9451
9452
9453
9454
9455
9456
9457
9458
9459
9460
9461
9462
9463
9464
9465
9466
9467
9468
9469
9470
9471
9472
9473
9474
9475
9476
9477
9478
9479
9480
9481
9482
9483
9484
9485
9486
9487
9488
9489
9490
9491
9492
9493
9494
9495
9496
9497
9498
9499
9500
9501
9502
9503
9504
9505
9506
9507
9508
9509
9510
9511
9512
9513
9514
9515
9516
9517
9518
9519
9520
9521
9522
9523
9524
9525
9526
9527
9528
9529
9530
9531
9532
9533
9534
9535
9536
9537
9538
9539
9540
9541
9542
9543
9544
9545
9546
9547
9548
9549
9550
9551
9552
9553
9554
9555
9556
9557
9558
9559
9560
9561
9562
9563
9564
9565
9566
9567
9568
9569
9570
9571
9572
9573
9574
9575
9576
9577
9578
9579
9580
9581
9582
9583
9584
9585
9586
9587
9588
9589
9590
9591
9592
9593
9594
9595
9596
9597
9598
9599
9600
9601
9602
9603
9604
9605
9606
9607
9608
9609
9610
9611
9612
9613
9614
9615
9616
9617
9618
9619
9620
9621
9622
9623
9624
9625
9626
9627
9628
9629
9630
9631
9632
9633
9634
9635
9636
9637
9638
9639
9640
9641
9642
9643
9644
9645
9646
9647
9648
9649
9650
9651
9652
9653
9654
9655
9656
9657
9658
9659
9660
9661
9662
9663
9664
9665
9666
9667
9668
9669
9670
9671
9672
9673
9674
9675
9676
9677
9678
9679
9680
9681
9682
9683
9684
9685
9686
9687
9688
9689
9690
9691
9692
9693
9694
9695
9696
9697
9698
9699
9700
9701
9702
9703
9704
9705
9706
9707
9708
9709
9710
9711
9712
9713
9714
9715
9716
9717
9718
9719
9720
9721
9722
9723
9724
9725
9726
9727
9728
9729
9730
9731
9732
9733
9734
9735
9736
9737
9738
9739
9740
9741
9742
9743
9744
9745
9746
9747
9748
9749
9750
9751
9752
9753
9754
9755
9756
9757
9758
9759
9760
9761
9762
9763
9764
9765
9766
9767
9768
9769
9770
9771
9772
9773
9774
9775
9776
9777
9778
9779
9780
9781
9782
9783
9784
9785
9786
9787
9788
9789
9790
9791
9792
9793
9794
9795
9796
9797
9798
9799
9800
9801
9802
9803
9804
9805
9806
9807
9808
9809
9810
9811
9812
9813
9814
9815
9816
9817
9818
9819
9820
9821
9822
9823
9824
9825
9826
9827
9828
9829
9830
9831
9832
9833
9834
9835
9836
9837
9838
9839
9840
9841
9842
9843
9844
9845
9846
9847
9848
9849
9850
9851
9852
9853
9854
9855
9856
9857
9858
9859
9860
9861
9862
9863
9864
9865
9866
9867
9868
9869
9870
9871
9872
9873
9874
9875
9876
9877
9878
9879
9880
9881
9882
9883
9884
9885
9886
9887
9888
9889
9890
9891
9892
9893
9894
9895
9896
9897
9898
9899
9900
9901
9902
9903
9904
9905
9906
9907
9908
9909
9910
9911
9912
9913
9914
9915
9916
9917
9918
9919
9920
9921
9922
9923
9924
9925
9926
9927
9928
9929
9930
9931
9932
9933
9934
9935
9936
9937
9938
9939
9940
9941
9942
9943
9944
9945
9946
9947
9948
9949
9950
9951
9952
9953
9954
9955
9956
9957
9958
9959
9960
9961
9962
9963
9964
9965
9966
9967
9968
9969
9970
9971
9972
9973
9974
9975
9976
9977
9978
9979
9980
9981
9982
9983
9984
9985
9986
9987
9988
9989
9990
9991
9992
9993
9994
9995
9996
9997
9998
9999
10000
10001
10002
10003
10004
10005
10006
10007
10008
10009
10010
10011
10012
10013
10014
10015
10016
10017
10018
10019
10020
10021
10022
10023
10024
10025
10026
10027
10028
10029
10030
10031
10032
10033
10034
10035
10036
10037
10038
10039
10040
10041
10042
10043
10044
10045
10046
10047
10048
10049
10050
10051
10052
10053
10054
10055
10056
10057
10058
10059
10060
10061
10062
10063
10064
10065
10066
10067
10068
10069
10070
10071
10072
10073
10074
10075
10076
10077
10078
10079
10080
10081
10082
10083
10084
10085
10086
10087
10088
10089
10090
10091
10092
10093
10094
10095
10096
10097
10098
10099
10100
10101
10102
10103
10104
10105
10106
10107
10108
10109
10110
10111
10112
10113
10114
10115
10116
10117
10118
10119
10120
10121
10122
10123
10124
10125
10126
10127
10128
10129
10130
10131
10132
10133
10134
10135
10136
10137
10138
10139
10140
10141
10142
10143
10144
10145
10146
10147
10148
10149
10150
10151
10152
10153
10154
10155
10156
10157
10158
10159
10160
10161
10162
10163
10164
10165
10166
10167
10168
10169
10170
10171
10172
10173
10174
10175
10176
10177
10178
10179
10180
10181
10182
10183
10184
10185
10186
10187
10188
10189
10190
10191
10192
10193
10194
10195
10196
10197
10198
10199
10200
10201
10202
10203
10204
10205
10206
10207
10208
10209
10210
10211
10212
10213
10214
10215
10216
10217
10218
10219
10220
10221
10222
10223
10224
10225
10226
10227
10228
10229
10230
10231
10232
10233
10234
10235
10236
10237
10238
10239
10240
10241
10242
10243
10244
10245
10246
10247
10248
10249
10250
10251
10252
10253
10254
10255
10256
10257
10258
10259
10260
10261
10262
10263
10264
10265
10266
10267
10268
10269
10270
10271
10272
10273
10274
10275
10276
10277
10278
10279
10280
10281
10282
10283
10284
10285
10286
10287
10288
10289
10290
10291
10292
10293
10294
10295
10296
10297
10298
10299
10300
10301
10302
10303
10304
10305
10306
10307
10308
10309
10310
10311
10312
10313
10314
10315
10316
10317
10318
10319
10320
10321
10322
10323
10324
10325
10326
10327
10328
10329
10330
10331
10332
10333
10334
10335
10336
10337
10338
10339
10340
10341
10342
10343
10344
10345
10346
10347
10348
10349
10350
10351
10352
10353
10354
10355
10356
10357
10358
10359
10360
10361
10362
10363
10364
10365
10366
10367
10368
10369
10370
10371
10372
10373
10374
10375
10376
10377
10378
10379
10380
10381
10382
10383
10384
10385
10386
10387
10388
10389
10390
10391
10392
10393
10394
10395
10396
10397
10398
10399
10400
10401
10402
10403
10404
10405
10406
10407
10408
10409
10410
10411
10412
10413
10414
10415
10416
10417
10418
10419
10420
10421
10422
10423
10424
10425
10426
10427
10428
10429
10430
10431
10432
10433
10434
10435
10436
10437
10438
10439
10440
10441
10442
10443
10444
10445
10446
10447
10448
10449
10450
10451
10452
10453
10454
10455
10456
10457
10458
10459
10460
10461
10462
10463
10464
10465
10466
10467
10468
10469
10470
10471
10472
10473
10474
10475
10476
10477
10478
10479
10480
10481
10482
10483
10484
10485
10486
10487
10488
10489
10490
10491
10492
10493
10494
10495
10496
10497
10498
10499
10500
10501
10502
10503
10504
10505
10506
10507
10508
10509
10510
10511
10512
10513
10514
10515
10516
10517
10518
10519
10520
10521
10522
10523
10524
10525
10526
10527
10528
10529
10530
10531
10532
10533
10534
10535
10536
10537
10538
10539
10540
10541
10542
10543
10544
10545
10546
10547
10548
10549
10550
10551
10552
10553
10554
10555
10556
10557
10558
10559
10560
10561
10562
10563
10564
10565
10566
10567
10568
10569
10570
10571
10572
10573
10574
10575
10576
10577
10578
10579
10580
10581
10582
10583
10584
10585
10586
10587
10588
10589
10590
10591
10592
10593
10594
10595
10596
10597
10598
10599
10600
10601
10602
10603
10604
10605
10606
10607
10608
10609
10610
10611
10612
10613
10614
10615
10616
10617
10618
10619
10620
10621
10622
10623
10624
10625
10626
10627
10628
10629
10630
10631
10632
10633
10634
10635
10636
10637
10638
10639
10640
10641
10642
10643
10644
10645
10646
10647
10648
10649
10650
10651
10652
10653
10654
10655
10656
10657
10658
10659
10660
10661
10662
10663
10664
10665
10666
10667
10668
10669
10670
10671
10672
10673
10674
10675
10676
10677
10678
10679
10680
10681
10682
10683
10684
10685
10686
10687
10688
10689
10690
10691
10692
10693
10694
10695
10696
10697
10698
10699
10700
10701
10702
10703
10704
10705
10706
10707
10708
10709
10710
10711
10712
10713
10714
10715
10716
10717
10718
10719
10720
10721
10722
10723
10724
10725
10726
10727
10728
10729
10730
10731
10732
10733
10734
10735
10736
10737
10738
10739
10740
10741
10742
10743
10744
10745
10746
10747
10748
10749
10750
10751
10752
10753
10754
10755
10756
10757
10758
10759
10760
10761
10762
10763
10764
10765
10766
10767
10768
10769
10770
10771
10772
10773
10774
10775
10776
10777
10778
10779
10780
10781
10782
10783
10784
10785
10786
10787
10788
10789
10790
10791
10792
10793
10794
10795
10796
10797
10798
10799
10800
10801
10802
10803
10804
10805
10806
10807
10808
10809
10810
10811
10812
10813
10814
10815
10816
10817
10818
10819
10820
10821
10822
10823
10824
10825
10826
10827
10828
10829
10830
10831
10832
10833
10834
10835
10836
10837
10838
10839
10840
10841
10842
10843
10844
10845
10846
10847
10848
10849
10850
10851
10852
10853
10854
10855
10856
10857
10858
10859
10860
10861
10862
10863
10864
10865
10866
10867
10868
10869
10870
10871
10872
10873
10874
10875
10876
10877
10878
10879
10880
10881
10882
10883
10884
10885
10886
10887
10888
10889
10890
10891
10892
10893
10894
10895
10896
10897
10898
10899
10900
10901
10902
10903
10904
10905
10906
10907
10908
10909
10910
10911
10912
10913
10914
10915
10916
10917
10918
10919
10920
10921
10922
10923
10924
10925
10926
10927
10928
10929
10930
10931
10932
10933
10934
10935
10936
10937
10938
10939
10940
10941
10942
10943
10944
10945
10946
10947
10948
10949
10950
10951
10952
10953
10954
10955
10956
10957
10958
10959
10960
10961
10962
10963
10964
10965
10966
10967
10968
10969
10970
10971
10972
10973
10974
10975
10976
10977
10978
10979
10980
10981
10982
10983
10984
10985
10986
10987
10988
10989
10990
10991
10992
10993
10994
10995
10996
10997
10998
10999
11000
11001
11002
11003
11004
11005
11006
11007
11008
11009
11010
11011
11012
11013
11014
11015
11016
11017
11018
11019
11020
11021
11022
11023
11024
11025
11026
11027
11028
11029
11030
11031
11032
11033
11034
11035
11036
11037
11038
11039
11040
11041
11042
11043
11044
11045
11046
11047
11048
11049
11050
11051
11052
11053
11054
11055
11056
11057
11058
11059
11060
11061
11062
11063
11064
11065
11066
11067
11068
11069
11070
11071
11072
11073
11074
11075
11076
11077
11078
11079
11080
11081
11082
11083
11084
11085
11086
11087
11088
11089
11090
11091
11092
11093
11094
11095
11096
11097
11098
11099
11100
11101
11102
11103
11104
11105
11106
11107
11108
11109
11110
11111
11112
11113
11114
11115
11116
11117
11118
11119
11120
11121
11122
11123
11124
11125
11126
11127
11128
11129
11130
11131
11132
11133
11134
11135
11136
11137
11138
11139
11140
11141
11142
11143
11144
11145
11146
11147
11148
11149
11150
11151
11152
11153
11154
11155
11156
11157
11158
11159
11160
11161
11162
11163
11164
11165
11166
11167
11168
11169
11170
11171
11172
11173
11174
11175
11176
11177
11178
11179
11180
11181
11182
11183
11184
11185
11186
11187
11188
11189
11190
11191
11192
11193
11194
11195
11196
11197
11198
11199
11200
11201
11202
11203
11204
11205
11206
11207
11208
11209
11210
11211
11212
11213
11214
11215
11216
11217
11218
11219
11220
11221
11222
11223
11224
11225
11226
11227
11228
11229
11230
11231
11232
11233
11234
11235
11236
11237
11238
11239
11240
11241
11242
11243
11244
11245
11246
11247
11248
11249
11250
11251
11252
11253
11254
11255
11256
11257
11258
11259
11260
11261
11262
11263
11264
11265
11266
11267
11268
11269
11270
11271
11272
11273
11274
11275
11276
11277
11278
11279
11280
11281
11282
11283
11284
11285
11286
11287
11288
11289
11290
11291
11292
11293
11294
11295
11296
11297
11298
11299
11300
11301
11302
11303
11304
11305
11306
11307
11308
11309
11310
11311
11312
11313
11314
11315
11316
11317
11318
11319
11320
11321
11322
11323
11324
11325
11326
11327
11328
11329
11330
11331
11332
11333
11334
11335
11336
11337
11338
11339
11340
11341
11342
11343
11344
11345
11346
11347
11348
11349
11350
11351
11352
11353
11354
11355
11356
11357
11358
11359
11360
11361
11362
11363
11364
11365
11366
11367
11368
11369
11370
11371
11372
11373
11374
11375
11376
11377
11378
11379
11380
11381
11382
11383
11384
11385
11386
11387
11388
11389
11390
11391
11392
11393
11394
11395
11396
11397
11398
11399
11400
11401
11402
11403
11404
11405
11406
11407
11408
11409
11410
11411
11412
11413
11414
11415
11416
11417
11418
11419
11420
11421
11422
11423
11424
11425
11426
11427
11428
11429
11430
11431
11432
11433
11434
11435
11436
11437
11438
11439
11440
11441
11442
11443
11444
11445
11446
11447
11448
11449
11450
11451
11452
11453
11454
11455
11456
11457
11458
11459
11460
11461
11462
11463
11464
11465
11466
11467
11468
11469
11470
11471
11472
11473
11474
11475
11476
11477
11478
11479
11480
11481
11482
11483
11484
11485
11486
11487
11488
11489
11490
11491
11492
11493
11494
11495
11496
11497
11498
11499
11500
11501
11502
11503
11504
11505
11506
11507
11508
11509
11510
11511
11512
11513
11514
11515
11516
11517
11518
11519
11520
11521
11522
11523
11524
11525
11526
11527
11528
11529
11530
11531
11532
11533
11534
11535
11536
11537
11538
11539
11540
11541
11542
11543
11544
11545
11546
11547
11548
11549
11550
11551
11552
11553
11554
11555
11556
11557
11558
11559
11560
11561
11562
11563
11564
11565
11566
11567
11568
11569
11570
11571
11572
11573
11574
11575
11576
11577
11578
11579
11580
11581
11582
11583
11584
11585
11586
11587
11588
11589
11590
11591
11592
11593
11594
11595
11596
11597
11598
11599
11600
11601
11602
11603
11604
11605
11606
11607
11608
11609
11610
11611
11612
11613
11614
11615
11616
11617
11618
11619
11620
11621
11622
11623
11624
11625
11626
11627
11628
11629
11630
11631
11632
11633
11634
11635
11636
11637
11638
11639
11640
11641
11642
11643
11644
11645
11646
11647
11648
11649
11650
11651
11652
11653
11654
11655
11656
11657
11658
11659
11660
11661
11662
11663
11664
11665
11666
11667
11668
11669
11670
11671
11672
11673
11674
11675
11676
11677
11678
11679
11680
11681
11682
11683
11684
11685
11686
11687
11688
11689
11690
11691
11692
11693
11694
11695
11696
11697
11698
11699
11700
11701
11702
11703
11704
11705
11706
11707
11708
11709
11710
11711
11712
11713
11714
11715
11716
11717
11718
11719
11720
11721
11722
11723
11724
11725
11726
11727
11728
11729
11730
11731
11732
11733
11734
11735
11736
11737
11738
11739
11740
11741
11742
11743
11744
11745
11746
11747
11748
11749
11750
11751
11752
11753
11754
11755
11756
11757
11758
11759
11760
11761
11762
11763
11764
11765
11766
11767
11768
11769
11770
11771
11772
11773
11774
11775
11776
11777
11778
11779
11780
11781
11782
11783
11784
11785
11786
11787
11788
11789
11790
11791
11792
11793
11794
11795
11796
11797
11798
11799
11800
11801
11802
11803
11804
11805
11806
11807
11808
11809
11810
11811
11812
11813
11814
11815
11816
11817
11818
11819
11820
11821
11822
11823
11824
11825
11826
11827
11828
11829
11830
11831
11832
11833
11834
11835
11836
11837
11838
11839
11840
11841
11842
11843
11844
11845
11846
11847
11848
11849
11850
11851
11852
11853
11854
11855
11856
11857
11858
11859
11860
11861
11862
11863
11864
11865
11866
11867
11868
11869
11870
11871
11872
11873
11874
11875
11876
11877
11878
11879
11880
11881
11882
11883
11884
11885
11886
11887
11888
11889
11890
11891
11892
11893
11894
11895
11896
11897
11898
11899
11900
11901
11902
11903
11904
11905
11906
11907
11908
11909
11910
11911
11912
11913
11914
11915
11916
11917
11918
11919
11920
11921
11922
11923
11924
11925
11926
11927
11928
11929
11930
11931
11932
11933
11934
11935
11936
11937
11938
11939
11940
11941
11942
11943
11944
11945
11946
11947
11948
11949
11950
11951
11952
11953
11954
11955
11956
11957
11958
11959
11960
11961
11962
11963
11964
11965
11966
11967
11968
11969
11970
11971
11972
11973
11974
11975
11976
11977
11978
11979
11980
11981
11982
11983
11984
11985
11986
11987
11988
11989
11990
11991
11992
11993
11994
11995
11996
11997
11998
11999
12000
12001
12002
12003
12004
12005
12006
12007
12008
12009
12010
12011
12012
12013
12014
12015
12016
12017
12018
12019
12020
12021
12022
12023
12024
12025
12026
12027
12028
12029
12030
12031
12032
12033
12034
12035
12036
12037
12038
12039
12040
12041
12042
12043
12044
12045
12046
12047
12048
12049
12050
12051
12052
12053
12054
12055
12056
12057
12058
12059
12060
12061
12062
12063
12064
12065
12066
12067
12068
12069
12070
12071
12072
12073
12074
12075
12076
12077
12078
12079
12080
12081
12082
12083
12084
12085
12086
12087
12088
12089
12090
12091
12092
12093
12094
12095
12096
12097
12098
12099
12100
12101
12102
12103
12104
12105
12106
12107
12108
12109
12110
12111
12112
12113
12114
12115
12116
12117
12118
12119
12120
12121
12122
12123
12124
12125
12126
12127
12128
12129
12130
12131
12132
12133
12134
12135
12136
12137
12138
12139
12140
12141
12142
12143
12144
12145
12146
12147
12148
12149
12150
12151
12152
12153
12154
12155
12156
12157
12158
12159
12160
12161
12162
12163
12164
12165
12166
12167
12168
12169
12170
12171
12172
12173
12174
12175
12176
12177
12178
12179
12180
12181
12182
12183
12184
12185
12186
12187
12188
12189
12190
12191
12192
12193
12194
12195
12196
12197
12198
12199
12200
12201
12202
12203
12204
12205
12206
12207
12208
12209
12210
12211
12212
12213
12214
12215
12216
12217
12218
12219
12220
12221
12222
12223
12224
12225
12226
12227
12228
12229
12230
12231
12232
12233
12234
12235
12236
12237
12238
12239
12240
12241
12242
12243
12244
12245
12246
12247
12248
12249
12250
12251
12252
12253
12254
12255
12256
12257
12258
12259
12260
12261
12262
12263
12264
12265
12266
12267
12268
12269
12270
12271
12272
12273
12274
12275
12276
12277
12278
12279
12280
12281
12282
12283
12284
12285
12286
12287
12288
12289
12290
12291
12292
12293
12294
12295
12296
12297
12298
12299
12300
12301
12302
12303
12304
12305
12306
12307
12308
12309
12310
12311
12312
12313
12314
12315
12316
12317
12318
12319
12320
12321
12322
12323
12324
12325
12326
12327
12328
12329
12330
12331
12332
12333
12334
12335
12336
12337
12338
12339
12340
12341
12342
12343
12344
12345
12346
12347
12348
12349
12350
12351
12352
12353
12354
12355
12356
12357
12358
12359
12360
12361
12362
12363
12364
12365
12366
12367
12368
12369
12370
12371
12372
12373
12374
12375
12376
12377
12378
12379
12380
12381
12382
12383
12384
12385
12386
12387
12388
12389
12390
12391
12392
12393
12394
12395
12396
12397
12398
12399
12400
12401
12402
12403
12404
12405
12406
12407
12408
12409
12410
12411
12412
12413
12414
12415
12416
12417
12418
12419
12420
12421
12422
12423
12424
12425
12426
12427
12428
12429
12430
12431
12432
12433
12434
12435
12436
12437
12438
12439
12440
12441
12442
12443
12444
12445
12446
12447
12448
12449
12450
12451
12452
12453
12454
12455
12456
12457
12458
12459
12460
12461
12462
12463
12464
12465
12466
12467
12468
12469
12470
12471
12472
12473
12474
12475
12476
12477
12478
12479
12480
12481
12482
12483
12484
12485
12486
12487
12488
12489
12490
12491
12492
12493
12494
12495
12496
12497
12498
12499
12500
12501
12502
12503
12504
12505
12506
12507
12508
12509
12510
12511
12512
12513
12514
12515
12516
12517
12518
12519
12520
12521
12522
12523
12524
12525
12526
12527
12528
12529
12530
12531
12532
12533
12534
12535
12536
12537
12538
12539
12540
12541
12542
12543
12544
12545
12546
12547
12548
12549
12550
12551
12552
12553
12554
12555
12556
12557
12558
12559
12560
12561
12562
12563
12564
12565
12566
12567
12568
12569
12570
12571
12572
12573
12574
12575
12576
12577
12578
12579
12580
12581
12582
12583
12584
12585
12586
12587
12588
12589
12590
12591
12592
12593
12594
12595
12596
12597
12598
12599
12600
12601
12602
12603
12604
12605
12606
12607
12608
12609
12610
12611
12612
12613
12614
12615
12616
12617
12618
12619
12620
12621
12622
12623
12624
12625
12626
12627
12628
12629
12630
12631
12632
12633
12634
12635
12636
12637
12638
12639
12640
12641
12642
12643
12644
12645
12646
12647
12648
12649
12650
12651
12652
12653
12654
12655
12656
12657
12658
12659
12660
12661
12662
12663
12664
12665
12666
12667
12668
12669
12670
12671
12672
12673
12674
12675
12676
12677
12678
12679
12680
12681
12682
12683
12684
12685
12686
12687
12688
12689
12690
12691
12692
12693
12694
12695
12696
12697
12698
12699
12700
12701
12702
12703
12704
12705
12706
12707
12708
12709
12710
12711
12712
12713
12714
12715
12716
12717
12718
12719
12720
12721
12722
12723
12724
12725
12726
12727
12728
12729
12730
12731
12732
12733
12734
12735
12736
12737
12738
12739
12740
12741
12742
12743
12744
12745
12746
12747
12748
12749
12750
12751
12752
12753
12754
12755
12756
12757
12758
12759
12760
12761
12762
12763
12764
12765
12766
12767
12768
12769
12770
12771
12772
12773
12774
12775
12776
12777
12778
12779
12780
12781
12782
12783
12784
12785
12786
12787
12788
12789
12790
12791
12792
12793
12794
12795
12796
12797
12798
12799
12800
12801
12802
12803
12804
12805
12806
12807
12808
12809
12810
12811
12812
12813
12814
12815
12816
12817
12818
12819
12820
12821
12822
12823
12824
12825
12826
12827
12828
12829
12830
12831
12832
12833
12834
12835
12836
12837
12838
12839
12840
12841
12842
12843
12844
12845
12846
12847
12848
12849
12850
12851
12852
12853
12854
12855
12856
12857
12858
12859
12860
12861
12862
12863
12864
12865
12866
12867
12868
12869
12870
12871
12872
12873
12874
12875
12876
12877
12878
12879
12880
12881
12882
12883
12884
12885
12886
12887
12888
12889
12890
12891
12892
12893
12894
12895
12896
12897
12898
12899
12900
12901
12902
12903
12904
12905
12906
12907
12908
12909
12910
12911
12912
12913
12914
12915
12916
12917
12918
12919
12920
12921
12922
12923
12924
12925
12926
12927
12928
12929
12930
12931
12932
12933
12934
12935
12936
12937
12938
12939
12940
12941
12942
12943
12944
12945
12946
12947
12948
12949
12950
12951
12952
12953
12954
12955
12956
12957
12958
12959
12960
12961
12962
12963
12964
12965
12966
12967
12968
12969
12970
12971
12972
12973
12974
12975
12976
12977
12978
12979
12980
12981
12982
12983
12984
12985
12986
12987
12988
12989
12990
12991
12992
12993
12994
12995
12996
12997
12998
12999
13000
13001
13002
13003
13004
13005
13006
13007
13008
13009
13010
13011
13012
13013
13014
13015
13016
13017
13018
13019
13020
13021
13022
13023
13024
13025
13026
13027
13028
13029
13030
13031
13032
13033
13034
13035
13036
13037
13038
13039
13040
13041
13042
13043
13044
13045
13046
13047
13048
13049
13050
13051
13052
13053
13054
13055
13056
13057
13058
13059
13060
13061
13062
13063
13064
13065
13066
13067
13068
13069
13070
13071
13072
13073
13074
13075
13076
13077
13078
13079
13080
13081
13082
13083
13084
13085
13086
13087
13088
13089
13090
13091
13092
13093
13094
13095
13096
13097
13098
13099
13100
13101
13102
13103
13104
13105
13106
13107
13108
13109
13110
13111
13112
13113
13114
13115
13116
13117
13118
13119
13120
13121
13122
13123
13124
13125
13126
13127
13128
13129
13130
13131
13132
13133
13134
13135
13136
13137
13138
13139
13140
13141
13142
13143
13144
13145
13146
13147
13148
13149
13150
13151
13152
13153
13154
13155
13156
13157
13158
13159
13160
13161
13162
13163
13164
13165
13166
13167
13168
13169
13170
13171
13172
13173
13174
13175
13176
13177
13178
13179
13180
13181
13182
13183
13184
13185
13186
13187
13188
13189
13190
13191
13192
13193
13194
13195
13196
13197
13198
13199
13200
13201
13202
13203
13204
13205
13206
13207
13208
13209
13210
13211
13212
13213
13214
13215
13216
13217
13218
13219
13220
13221
13222
13223
13224
13225
13226
13227
13228
13229
13230
13231
13232
13233
13234
13235
13236
13237
13238
13239
13240
13241
13242
13243
13244
13245
13246
13247
13248
13249
13250
13251
13252
13253
13254
13255
13256
13257
13258
13259
13260
13261
13262
13263
13264
13265
13266
13267
13268
13269
13270
13271
13272
13273
13274
13275
13276
13277
13278
13279
13280
13281
13282
13283
13284
13285
13286
13287
13288
13289
13290
13291
13292
13293
13294
13295
13296
13297
13298
13299
13300
13301
13302
13303
13304
13305
13306
13307
13308
13309
13310
13311
13312
13313
13314
13315
13316
13317
13318
13319
13320
13321
13322
13323
13324
13325
13326
13327
13328
13329
13330
13331
13332
13333
13334
13335
13336
13337
13338
13339
13340
13341
13342
13343
13344
13345
13346
13347
13348
13349
13350
13351
13352
13353
13354
13355
13356
13357
13358
13359
13360
13361
13362
13363
13364
13365
13366
13367
13368
13369
13370
13371
13372
13373
13374
13375
13376
13377
13378
13379
13380
13381
13382
13383
13384
13385
13386
13387
13388
13389
13390
13391
13392
13393
13394
13395
13396
13397
13398
13399
13400
13401
13402
13403
13404
13405
13406
13407
13408
13409
13410
13411
13412
13413
13414
13415
13416
13417
13418
13419
13420
13421
13422
13423
13424
13425
13426
13427
13428
13429
13430
13431
13432
13433
13434
13435
13436
13437
13438
13439
13440
13441
13442
13443
13444
13445
13446
13447
13448
13449
13450
13451
13452
13453
13454
13455
13456
13457
13458
13459
13460
13461
13462
13463
13464
13465
13466
13467
13468
13469
13470
13471
13472
13473
13474
13475
13476
13477
13478
13479
13480
13481
13482
13483
13484
13485
13486
13487
13488
13489
13490
13491
13492
13493
13494
13495
13496
13497
13498
13499
13500
13501
13502
13503
13504
13505
13506
13507
13508
13509
13510
13511
13512
13513
13514
13515
13516
13517
13518
13519
13520
13521
13522
13523
13524
13525
13526
13527
13528
13529
13530
13531
13532
13533
13534
13535
13536
13537
13538
13539
13540
13541
13542
13543
13544
13545
13546
13547
13548
13549
13550
13551
13552
13553
13554
13555
13556
13557
13558
13559
13560
13561
13562
13563
13564
13565
13566
13567
13568
13569
13570
13571
13572
13573
13574
13575
13576
13577
13578
13579
13580
13581
13582
13583
13584
13585
13586
13587
13588
13589
13590
13591
13592
13593
13594
13595
13596
13597
13598
13599
13600
13601
13602
13603
13604
13605
13606
13607
13608
13609
13610
13611
13612
13613
13614
13615
13616
13617
13618
13619
13620
13621
13622
13623
13624
13625
13626
13627
13628
13629
13630
13631
13632
13633
13634
13635
13636
13637
13638
13639
13640
13641
13642
13643
13644
13645
13646
13647
13648
13649
13650
13651
13652
13653
13654
13655
13656
13657
13658
13659
13660
13661
13662
13663
13664
13665
13666
13667
13668
13669
13670
13671
13672
13673
13674
13675
13676
13677
13678
13679
13680
13681
13682
13683
13684
13685
13686
13687
13688
13689
13690
13691
13692
13693
13694
13695
13696
13697
13698
13699
13700
13701
13702
13703
13704
13705
13706
13707
13708
13709
13710
13711
13712
13713
13714
13715
13716
13717
13718
13719
13720
13721
13722
13723
13724
13725
13726
13727
%==============================================================================
%==============================================================================
\documentclass[12pt]{report}
\usepackage{epsfig}
\usepackage{hyperref}
\usepackage{graphicx}
\usepackage{include/harvard}
\usepackage{alltt}
\usepackage{longtable}
\usepackage{moreverb}
\usepackage{amsmath,amssymb}
\usepackage{url}
\usepackage{subfigure}
\usepackage{xspace}
\pagestyle{plain}
\topmargin=0pt
\textwidth=6.75in
\textheight=9in
\evensidemargin=-15pt
\oddsidemargin=-15pt
%==============================================================================
\input{macros}
%==============================================================================
\def\norm#1{\parallel#1\parallel}
\def\abs#1{\mid#1\mid}
\def\eps{\epsilon}
\def\R{{\rm R}}
\def\Rn{{\rm R}^n}
%==============================================================================
%==============================================================================
\begin{document}
\bibliographystyle{include/agsm} 
%
\title{
\LARGE {\cal AUTO}-07P :\\ 
\Large CONTINUATION AND BIFURCATION SOFTWARE \\
\Large FOR ORDINARY DIFFERENTIAL EQUATIONS\\ 
\author{
\Large Eusebius J. Doedel and Bart E. Oldeman\\
\Large Concordia University\\
\Large Montreal, Canada\\
\\
with major contributions by\\
\\
Alan R. Champneys (Bristol),
Fabio Dercole (Milano),
Thomas Fairgrieve (Toronto),
\\
Yuri Kuznetsov (Utrecht),
Randy Paffenroth (Pasadena),
\\
Bj\"orn Sandstede (Brown),
Xianjun Wang,
and
Chenghai Zhang.\\
}}
\date{January 2012}
\pagenumbering{alph}
\maketitle
\pagenumbering{arabic}
\setcounter{page}{1}
\tableofcontents
%
%
\newpage
~
\vskip.50truein
\subsection*{Preface}
This is a guide to the software package {\cal AUTO}
for continuation and bifurcation problems in ordinary differential 
equations.
Earlier versions of {\cal AUTO} were described in 
\citename{Do:81} \citeyear{Do:81},
\citename{DoKe:86} \citeyear{DoKe:86},
\citename{DoWa:95a} \citeyear{DoWa:95a},
\citename{WaDo:95b} \citeyear{WaDo:95b},
\citename{AUTO:97} \citeyear{AUTO:97},
\citename{AUTO:2000} \citeyear{AUTO:2000}.
For a description of the basic algorithms see
\citename{DoKeKe:91a} \citeyear{DoKeKe:91a},
\citename{DoKeKe:91b} \citeyear{DoKeKe:91b}.
{\cal AUTO} incorporates the {\cal HomCont} algorithms of
\citename{ChKu:94} \citeyear{ChKu:94},
\citename{ChKuSa:95} \citeyear{ChKuSa:95}
for the bifurcation analysis of homoclinic orbits, and
the BPcont algorithms of \citename{DercoleSMSC:08}
\citeyear{DercoleSMSC:08} for the continuation of
branch points in both symmetric and non-symmetric problems.
The Floquet multiplier algorithms were written by
\citename{Fa:94} \citeyear{Fa:94},
\citename{FaJe:91} \citeyear{FaJe:91}.
A GUI was written by
\citename{XJW:94} \citeyear{XJW:94}.
The Python CLUI is the work of Randy Paffenroth.

\vskip1.00truein
\subsection*{Acknowledgments}
The first author is much indebted to H.~B.~Keller 
of the California Institute of Technology for his inspiration,
encouragement and support.
He is also thankful to {\cal AUTO} users and research collaborators who have 
directly or indirectly contributed to its development,
in particular, 
Jean Pierre Kern\'evez, UTC, Compi\`egne, France;
Don Aronson, University of Minnesota, Minneapolis;
Hans Othmer, University of Utah; and
Frank Schilder, University of Surrey.
Some material in this document related to the computation of connecting orbits
was developed with Mark Friedman, University of Alabama, Huntsville.
Also acknowledged is the work of Nguyen Thanh Long,
Concordia University, Montreal, on the graphics program {\cal PLAUT}.
Special thanks are due to Sheila Shull, California Institute of Technology,
for her cheerful assistance in the distribution of {\cal AUTO} over a long period
of time.
Over the years, the development of {\cal AUTO} has been supported by
various agencies through the California Institute of Technology, and
by research grants from NSERC (Canada).

The development of {\cal HomCont} has benefitted from help and advice from, 
among others, 
W.-J. Beyn, Universit\"{a}t Bielefeld,
M.~J. Friedman, University of Alabama,
A. Rucklidge, University of Cambridge, 
M. Koper, University of Utrecht,
C.~J. Budd, University of Bath, and
Financial support for this collaboration was also received from the U.K.
Engineering and Physical Science Research Council and the Nuffield Foundation.

\newpage
~
\subsection*{License}
{\cal AUTO} is available under the terms of the BSD license:\\
\begin{footnotesize}
~\\
Copyright \copyright~1979--2007, E.~J.~Doedel, California Institute of
Technology, and Concordia University.  All rights reserved.\\
~\\
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
\begin{itemize}
\item Redistributions of source code must retain the above copyright
  notice, this list of conditions and the following disclaimer. 
  
\item Redistributions in binary form must reproduce the above copyright
  notice, this list of conditions and the following disclaimer listed
  in this license in the documentation and/or other materials
  provided with the distribution.
  
\item Neither the name of the copyright holders nor the names of its
  contributors may be used to endorse or promote products derived from
  this software without specific prior written permission.
\end{itemize}
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT  
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT  
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
\end{footnotesize}

Note that the three-dimensional plotting tool {\cal PLAUT04} optionally
depends on libraries that are covered by the GNU General Public
License (GPL), in particular, Coin, SoQt and Qt. In that case the
{\cal PLAUT04} binaries are also covered by the GPL.

%==============================================================================
%==============================================================================
\chapter{Installing {\cal AUTO}.} \label{ch:Installing_AUTO}
%==============================================================================
%==============================================================================
\section{ Installation.} \label{sec:Installation}
%The {\cal AUTO} files {\filef auto.ps.gz, auto.tar.gz} and {\filef README} 
%are available via FTP from 
%directory {\filef pub/doedel/auto} at \url{ftp.cs.concordia.ca}.
The {\cal AUTO} file \filef{auto07p-0.9.1.tar.gz} is
available via \url{http://cmvl.cs.concordia.ca/auto}.
%The {\filef README} file contains the instructions for printing this manual.
Here it is assumed that you are using the Unix (e.g. \emph{bash}) shell 
and that the file \filef{auto07p-0.9.1.tar.gz} is in your main
directory. See below for OS-specific notes.

While in your main directory, enter the commands
\commandf{gunzip auto07p-0.9.1.tar.gz},
followed by \commandf{tar xvfo auto07p-0.9.1.tar}.
This will result in a directory \filef{auto}, 
with one subdirectory, \filef{auto/07p}. 
Type \commandf{cd auto/07p}
to change directory to \filef{auto/07p}.
Then type
\commandf{./configure}~,
to check your system for required compilers and libraries.
Once the \filef{configure} script has finished you 
may then type \commandf{make} to compile \AUTO
and its ancillary software.
The \filef{configure} script is designed to detect the details
of your system which \AUTO requires to compile successfully.
If either the \filef{configure} script or the \filef{make} command
should fail, you may assist the \filef{configure} script by giving
it various command line options.  Please type \commandf{./configure --help}
for more details.
Upon compilation, you may type 
\commandf{make clean}  
to remove unnecessary files.

To run \AUTO you need to set your environment variables correctly.
Assuming \AUTO is installed in your home directory, the following
commands set your environment variables so that you will be able to
run the \AUTO commands, and may be placed into your \filef{.login},
\filef{.profile}, or \filef{.cshrc} file, as appropriate.  If you are
using a \commandf{sh} compatible shell, such as \commandf{sh},
\commandf{bash}, \commandf{ksh}, or \commandf{ash} enter the command
\commandf{source~ {\rm \$}HOME/auto/07p/cmds/auto.env.sh}.  On the
other hand, if you are using a \commandf{csh} compatible shell, such
as \commandf{csh} or \commandf{tcsh}, enter the command \commandf{
source~ {\rm \$}HOME/auto/07p/cmds/auto.env}.

The Graphical User Interface (GUI94) requires the {\cal X-Window} system
and {\cal Motif} or {\cal LessTif}.
Note that the GUI is not strictly necessary, since {\cal AUTO} can be
run very effectively using the Unix Command Language User Interface (CLUI).
Moreover, long or complicated sequences of {\cal AUTO} calculations can
be programmed using the alternative Python CLUI. 
The GUI is not compiled by default. To compile
\AUTO with the GUI, type \commandf{./configure --enable-gui}
and then \commandf{make} in the directory \filef{auto/07p}.

To use the Python CLUI and the ``@pp'' {\cal PyPLAUT} plotter it
is strongly recommended to install NumPy
(\url{http://numpy.scipy.org}), TkInter, and
Matplotlib (\url{http://matplotlib.sourceforge.net/}).
Note that Matplotlib 0.99 or higher is recommended because it supports
3D plotting in addition to 2D plotting.
Python itself needs to be at least version 2.3 or higher, but 2.4 or
higher is strongly recommended and required for NumPy and Matplotlib.
As of this writing Python 3.x is not yet supported by
Matplotlib, and therefore not recommended.
For enhanced interactive use of the Python CLUI it is also worth
installing IPython (\url{http://ipython.scipy.org}).

The graphic tool for 3D \AUTO data visualization, {\cal PLAUT04}, is
compiled by default, but depends on a few libraries that may not be
in a standard installation of a typical Unix-like
system. These libraries may be available as optional packages,
though. In order of preference these are:
\begin{enumerate}
\item
Coin3D (version 2.2 or higher), SoQt (1.1.0 or higher), and simage
(1.6 or higher). With SoQt 1.5.0 or higher, simage is no longer required.
\item
Coin3D with the SoXt library, which interfaces with (Open)Motif or
LessTif (version 2.0 or higher) instead of Qt. The user interface has
a few problems with LessTif though, in particular it is likely to
crash on 64-bit machines, so the Qt version or (Open)Motif is
recommended.
\item
One can download SGI's implementation of the
Open Inventor libraries from:
\url{ftp://oss.sgi.com/projects/inventor/download/}
Because SGI's implementation for Linux cannot show text correctly, 
we recommend that Coin is used instead of SGI's implementation. 
\end{enumerate}

The \filef{configure} script checks
for these libraries and outputs a warning if any of these libraries
cannot be found. It first checks for SoQt, and then for SoXt, unless
you pass \texttt{\hyphenchar\font45\relax --disable-plaut04-qt}
as an option to \filef{configure}.
If the libraries are not available you can still compile
all other components of \AUTO using \filef{make}.

The Fortran code uses several routines that were not standardardized
prior to the Fortran 2003 standard, for timing, flushing output, and
accessing command-line arguments. The \filef{configure} script first looks if
the F2003 routines are supported (\filef{src/f2003.f90}), then checks
for a set of routines that are widely implemented across Unix
compilers (\filef{src/unix.f90}), and if that fails too, uses a set of
dummy replacement routines (\filef{src/compat.f90}), which could be
edited for some obscure installations.

The PostScript conversion command \commandf{@ps} is compiled by
default. Alternatively you can type \commandf{make} in the directory
\filef{auto/07p/tek2ps}.
To generate the on-line manual, type \commandf{make} in
\filef{auto/07p/doc}, which depends on the presence of xfig's
(transfig) fig2dev utility.

To prepare {\cal AUTO} for transfer to another machine,
type \commandf{make superclean}
in the directory \filef{auto/07p} before creating the \filef{tar}-file. 
This will remove all executable, object, and other non-essential files, and
thereby reduce the size of the package.

Some {\cal LAPACK} routines used by {\cal AUTO} for computing eigenvalues and
Floquet multipliers are included in the package
(\citename{LAPACK:99} \citeyear{LAPACK:99}).
The Python CLUI includes a slightly modified version of the Pointset
and Point classes from PyDSTool by R.~Clewley, M.D.~LaMar, and E.~Sherwood
(\url{http://pydstool.sourceforge.net})

\subsection{Installation on Linux/Unix}
A free Fortran 95 compiler, Gfortran, is shipped with most recent
Linux distributions, or can be obtained at 
\url{http://gcc.gnu.org/wiki/Gfortran}.
The following packages (and their dependencies) are recommended for
Fedora:
\begin{itemize}
\item Python: \filef{python-matplotlib-tk} and \filef{ipython}.
\item {\cal PLAUT04}: \filef{SoQt-devel}. For SoQt versions older than
1.5.0, to see pictures of stars, the earth
and the moon instead of white blobs, compile simage from
source (see \url{www.coin3d.org}; needs \filef{libjpeg-devel}).
\item {\cal PLAUT}: \filef{xterm}.
\item GUI94: \filef{lesstif-devel} or \filef{openmotif-devel}.
\item manual: \LaTeX (\filef{tetex} or \filef{texlive}) and \filef{transfig}.
\end{itemize}
and the following for Ubuntu and Debian:
\begin{itemize}
\item Python: \filef{python-matplotlib} and \filef{ipython}.
\item {\cal PLAUT04}: SoQt (\filef{libsoqt-dev} or \filef{libsoqt4-dev}) and
\filef{libsimage-dev}.
\item {\cal PLAUT}: \filef{xterm}
\item GUI94: \filef{lesstif2-dev} or \filef{libmotif-dev}.
\item manual: \LaTeX (\filef{tetex} or \filef{texlive}) and \filef{transfig}.
\end{itemize}
Other distributions may have packages with similar names.

If you need to compile and install one of the above {\cal PLAUT04} libraries
from the source code available at the above web site, and you
find that, after that, {\cal PLAUT04} still does not work then you might need to
adjust the environment variable {\tt LD\_LIBRARY\_PATH} to include
the location of these libraries, for instance {\tt /usr/local/lib}.

\subsection{Installation on Mac OS X}
\AUTO runs on Mac OS X using the above instructions provided that
you have the development tools
installed (see the Mac OS X Install DVD, Optional Installs, Xcode).
You do not need to start an X server to run AUTO.
Furthermore, the following packages are recommended:
\begin{itemize}
\item Gfortran: See \url{http://gcc.gnu.org/wiki/GFortranBinaries}.
Alternatively, see \url{hpc.sourceforge.net} or \url{r.research.att.com/tools/}.
At the time of writing the first of these is recommended to be able
to benefit from parallelization.
\item Python: you can install \textbf{32-bit} Python 2.7, NumPy, and
Matplotlib \filef{.dmg} files
from \url{www.python.org}, \url{numpy.scipy.org},
and \url{matplotlib.sf.net}, respectively.\\
For example, download from\\
\url{http://www.python.org/ftp/python/2.7.2/python-2.7.2-macosx10.3.dmg},\\
\url{http://sourceforge.net/projects/numpy/files/NumPy/1.6.1/numpy-1.6.1-py2.7-python.org-macosx10.3.dmg/download},\\
and 
\url{http://sourceforge.net/projects/matplotlib/files/matplotlib/matplotlib-1.1.0/matplotlib-1.1.0-py2.7-python.org-macosx10.3.dmg/download}

The default system Python in Mac OS X is usable, but may be too old for
Matplotlib and NumPy.
There are other alternatives, for instance the Enthought Python
Distribution at \url{www.enthought.com}. Fink should work but native
graphics provided by the previous alternatives seem to work better.\\
To be able to plot in the Python CLUI in some versions of OS X,
\AUTO uses \filef{pythonw} instead of \filef{python}.
This should happen automatically.
\item {\cal PLAUT04}: Get a Qt \filef{.dmg} from\\
\url{http://qt.nokia.com/downloads/qt-for-open-source-cpp-development-on-mac-os-x}.
Similarly, you can get a binary Coin package from \url{coin3d.org}.
After that you can compile SoQt (at least version 1.5.0)
from the source code at \url{coin3d.org}.
For example, download
\url{http://ftp.coin3d.org/coin/bin/macosx/all/Coin-3.1.3-gcc4.dmg},
\url{http://get.qt.nokia.com/qt/source/qt-mac-opensource-4.8.0.dmg}, and
\url{http://ftp.coin3d.org/coin/src/all/SoQt-1.5.0.tar.gz}.

Try to make sure that the native (Aqua) Qt
is used by setting {\tt \$QTDIR}, if you also have fink installed.
\item {\cal PLAUT}: In pre-Leopard OS X it appears that you do not see
fonts. To solve this issue you need to obtain a different
version of xterm; see
\url{http://sourceforge.net/project/showfiles.php?group_id=21781}.
\item GUI94: Perhaps possible using Fink but not attempted.
\item manual: \LaTeX\xspace and transfig (comes with xfig).
\end{itemize}

Notes for 64-bit Snow Leopard to be able to compile PLAUT04:
\begin{itemize}
\item
To compile and install SoQt, after installing Qt and Coin3D, run
\begin{verbatim}
./configure CFLAGS="-m32" CXXFLAGS="-m32" LDFLAGS="-m32" FFLAGS="-m32"
make
sudo make install
\end{verbatim}
\item
Then, in the AUTO-07p folder configure and compile AUTO as described above.
\end{itemize}

\subsection{Installation on Windows}
A native, light-weight solution for running AUTO on Windows is
to use GFortran, MSYS 1.0.11 or higher (see \url{http://www.mingw.org}),
combined with a native Win32 version of Python,
obtained at \url{http://www.python.org}. To install this setup:
\begin{itemize}
\item
Install Python (as of this writing, preferably version 2.7, not 3.2!)
from \url{www.python.org}, NumPy from \url{numpy.scipy.org},
and Matplotlib from \url{matplotlib.sf.net}, which all come
with installers.
\item
Install MinGW (make sure to include msys-base, gcc and fortran)
using the MinGW Graphical Installer at \url{http://www.mingw.org}.
\item
Start MSYS using the Start menu (Start $>$ All Programs $\to$ MinGW
$\to$ MinGW Shell) or by clicking on its desktop icon, which
puts you in a home directory, where you can unpack
\AUTO using \filef{gunzip} and \filef{tar}, as described above.
\item
Make sure that the {\tt gfortran} and {\tt python} binaries
are in your {\tt PATH}, and that their directories are at the front of it.
You can do this, for instance, using the shell command
\commandf{export PATH="/c/Python27:/bin:/c/Program Files/gfortran/bin:\$PATH" }.
You can also inspect, edit and then source the file
\filef{auto/07p/cmds/auto.env.sh} to achieve this.
\item
Now you should be able to run configure and make to compile \AUTO
as shown above.
\end{itemize}

You can use \AUTO using shell commands from the default MSYS shell
environment. You can also start the CLUI by double clicking on the file
\filef{auto.py} in the \filef{python} folder of \AUTO in Windows Explorer,
or by creating a shortcut to it.

Alternatively, \AUTO runs on Windows as above using the Unix-like
environment Cygwin (see \url{http://www.cygwin.com}), but the
non-Cygwin setup is more responsive and is much easier to setup for
Matplotlib. You can however use its X server and lesstif to compile
and run the old {\cal PLAUT} and GUI94, if you so desire.

With some effort it is possible to compile {\cal PLAUT04}
on Windows (without an X server) using Coin, SoQt, and Qt. You can
also find precompiled {\cal PLAUT04} binaries at
\url{http://sourceforge.net/projects/auto-07p/files}.

\section{ Restrictions on Problem Size.} \label{sec:Restrictions}
There are no size restrictions in the file \filef{
  auto/07p/include/auto.h} any more. This file now contains the
default effective number of equation parameters {\tt NPAR}, set to 36
upon installation. It can be overridden in constant files.
See also Section~\ref{sec:Restrictions_on_PAR}.
The default can be changed by editing {\tt auto.h}.
This must be followed by recompilation by typing \commandf{make} 
in the directory {\tt auto/07p/src}.

Note that in certain cases the {\it effective dimension} may be greater
than the user dimension.
For example, for the continuation of folds,
the effective dimension is 2{\tt NDIM}+1 for algebraic equations,
and 2{\tt NDIM} for ordinary differential equations, respectively.
Similarly, for the continuation of Hopf bifurcations,
the effective dimension is 3{\tt NDIM}+2.
 
 
\section{ Compatibility with Earlier Versions.} \label{sec:Compatibility}
Unlike earlier versions, \AUTO can no longer be compiled using a pure
Fortran 77 compiler, but you need at least a Fortran 90 compiler.
A free Fortran 95 compiler, GFortran, is shipped with most recent
Linux distributions, or can be obtained at
\url{http://gcc.gnu.org/wiki/GFortran}, which contains binaries for
Linux, Mac OS X and Windows. \AUTO was also tested with the free
compiler {\tt g95}, and there exist various commercial Fortran
9x compilers as well.

The {\cal AUTO} input files are now called 
{\tt c.xxx} (the constants file),
and
{\tt h.xxx} (the {\cal HomCont} constants file, only used with {\cal HomCont});
the output files are called
{\tt b.xxx} (the bifurcation-diagram-file),
{\tt s.xxx} (the solution-file),
and
{\tt d.xxx} (the diagnostics-file).
The command \commandf{@rn} can be used to rename all these files from
their old names.
There are also minor changes in the formatting of these files 
compared to recent versions of {\cal AUTO}, such as {\cal AUTO97} 
and {\cal AUTO2000}.
The main change compared to {\cal AUTO97} is that there is now a
programmable Python CLUI. The constants file can be written using
a completely new, more flexible syntax, but the old syntax is
still accepted, and files can be converted using the command
\commandf{@cnvc} (see Section~\ref{sec:command_mode}).

Due to the replacement of EISPACK routines by LAPACK routines for the
computation of eigenvalues and eigenvectors, the sign of the
eigenvectors may have flipped sometimes with respect to earlier
versions. This affects the sign of some {\cal HomCont}
test functions and the initial direction when using the homotopy
method (you may have to flip the sign of the starting distance
in the routine STPNT). Eigenvectors are now normalized to avoid
future problems and improve consistency.

Parameter derivatives in {\tt DFDP} are now significant when using {\cal
HomCont}. If only the derivatives with respect to phase space variables
are specified in {\tt DFDU}, please use the setting \parf{JAC=-1}.

When upgrading from {\cal AUTO2000}, you can continue to use
equations-files written in C. However, there is now a strict
difference between indexing of the array {\tt par[]} in the
C file and the references to it using {\tt PAR()} in constants
files and output, using {\tt par[i]=PAR(I+1)}. In practise this
means that you do not have to change the C file, but need to
add 1 to all parameter indices in the constant files, namely
{\tt ICP}, {\tt THL}, and {\tt UZR}. For example,
the period is referenced by {\tt par[10]} in the C file,
but by {\tt PAR(11)} in the constants file. Equation files
written in C are used in the homoclinic branch switching
demo in Chapter~\ref{ch:HomCont_hbs}.
 
A detailed list of user-visible changes can be found in the file
\filef{\$AUTO\_DIR/CHANGELOG}.

\section{ Parallel Version.} \label{sec:Parallel}
\AUTO contains code which allows
it to run in on parallel computers.  Namely,
it can use either OpenMP to run most of its code in parallel
on shared-memory multi-processors, or the MPI message passing
library.
When the \filef{configure} script is run it will try to
detect if the Fortran compiler supports OpenMP; examples
are Gfortran 4.2 or later and the Intel Fortran Compiler.
If it is successful the necessary compiler flags are used
to enable OpenMP in \AUTO.
To force the \filef{configure} script not to use OpenMP,
one may type \commandf{./configure --without-openmp},
and then type \commandf{make}.
On the other hand, unless there is some
particular difficulty, we recommend that that the 
\filef{configure} script be used without arguments, since the
parallel version of \AUTO may easily be controlled,
and even run in a serial mode,  
through the use of the environment variable {\tt OMP\_NUM\_THREADS}.

For example, to run the \AUTO executable \filef{auto.exe}
in serial mode you just type \commandf{export OMP\_NUM\_THREADS=1}.
To run the same command in parallel on 4 processors you type 
\commandf{export OMP\_NUM\_THREADS=4}. Without any {\tt OMP\_NUM\_THREADS}
set the number of processors that \AUTO will use can be equal to the
actual number of processors on the system, or can be equal to one;
this is system-dependent.

The MPI message passing library is not used by default. You can enable it
by typing  \commandf{./configure --with-mpi}. If OpenMP and MPI are
both used then \AUTO uses mixed mode, with MPI parallelisation
occurring at the top level.

Running the MPI version is somewhat more complex because of the fact
that MPI normally uses some external program for starting the
computational processes.  The exact name and command line options of
this external program depends on your MPI installation.  A common name
for this MPI external program is \filef{mpirun}, and a common command
line option which defines the number of computational processes is \filef{
-np}.  Accordingly, if you wanted to run the MPI version of \AUTO
on four processors, with the above external program, you would
type \filef{mpirun -np 4 file.exe}.  Please see your local MPI
documentation for more detail.

Both the Python CLUI and the commands in the \filef{ auto/07p/cmds}
directory described in Chapter~\ref{sec:command_mode} may be used with the
MPI version as well, by setting the \commandf{ AUTO\_COMMAND\_PREFIX}
environment variable.  For example, to run \AUTO in parallel using
the MPI library on 4 processors just type
\commandf{export AUTO\_COMMAND\_PREFIX='mpirun -np 4'}
before you run the Python CLUI \commandf{auto} or
the commands in \filef{ auto/07p/cmds} normally. 
The previous example
assumed you are using the \commandf{sh} shell or the \commandf{bash} shell; for
other shells you should modify the commands appropriately,
for example \commandf{setenv AUTO\_COMMAND\_PREFIX 'mpirun -np 4'}
for the \commandf{csh} and \commandf{tcsh} shells. Alternatively,
inside the Python
CLUI and scripts you can use \commandf{import os} followed by
\commandf{os.environ["AUTO\_COMMAND\_PREFIX"]="mpirun -np 4"}.

%==============================================================================
%==============================================================================
\chapter{ Overview of Capabilities.} \label{ch:Overview}
%==============================================================================
%==============================================================================
\section{ Summary.} \label{sec:Summary}
{\cal AUTO} can do a limited bifurcation analysis of algebraic systems
\begin{equation} \label{1} 
  f( u , p ) = 0 ,  \qquad  f(\cdot,\cdot) , u \in \Rn.
\end{equation}
The main algorithms in {\cal AUTO}, however, are aimed at the continuation
of solutions of systems of ordinary differential equation (ODEs) of the form
\begin{equation} \label{2} 
 u'(t) = f\bigl( u(t) , p \bigr) , 
  \qquad  f(\cdot,\cdot) , u(\cdot) \in \Rn,
\end{equation}
subject to boundary (including initial) conditions and integral constraints.
Above, $p$ denotes one or more free parameters.

These boundary value algorithms also allow {\cal AUTO} to do certain stationary 
solution and wave calculations for the partial differential equation (PDE)
\begin{equation} \label{3} 
  u_t = D u_{xx} + f( u , p ), 
  \qquad  f(\cdot,\cdot) , u(\cdot) \in \Rn,
\end{equation}
where $D$ denotes a diagonal matrix of diffusion constants.

The basic algorithms used in {\cal AUTO},
as well as related algorithms, can be found in 
\citename{HBK:77} \citeyear{HBK:77},
\citename{HBK:86} \citeyear{HBK:86},
\citename{DoKeKe:91a} \citeyear{DoKeKe:91a},
\citename{DoKeKe:91b} \citeyear{DoKeKe:91b}.

Below, the basic capabilities of {\cal AUTO} are specified in more detail.
Some representative demos are also indicated.
 
\section{ Algebraic Systems.} \label{sec:algebraic_systems}
Specifically, for (\ref{1}) {\cal AUTO} can~:~
 
\begin{itemize}
\item[-]
  Compute solution families.\\  (Demo {\tt ab}; Run~2.) 
\item[-]
  Locate branch points, continue these in two or three parameters,
  and automatically compute
  bifurcating families. \\ (Demos {\tt pp2}; Run~1, and {\tt apbp}.)
\item[-]
  Locate Hopf bifurcation points, continue these in two
  parameters, detect whether the Hopf bifurcation is sub- or
  supercritical, and detect zero-Hopf, Bogdanov-Takens, and 
  generalized Hopf (Bautin) bifurcations.\\ (Demos {\tt pp3} and
  {\tt ppp}.)
\item[-]
  Locate folds (limit points), continue these 
  in two parameters, and detect cusp, zero-Hopf, and Bogdanov-Takens
  bifurcations. \\
\item[-]
  Locate branch points, folds, period-doubling, and torus
  (Neimark-Sacker) bifurcations, continue these in two or three
  parameters, and switch branches at branch points and
  period-doubling bifurcations
  for fixed points of the discrete dynamical system
  $u^{(k+1)}= f( u^{(k)}, p )$ \\ (Demo {\tt dd2}.)
\item[-]
  Find extrema of an objective function along solution families
  and successively continue such extrema in more parameters.
  \\ (Demo {\tt opt}.)
\end{itemize}


\section{ Ordinary Differential Equations.} \label{sec:ODEs}
For the ODE (\ref{2}) the program can~:~
 
\begin{itemize}
\item[-]
  Compute families of stable and unstable periodic
  solutions and
  compute the Floquet multipliers, that determine stability, along
  these families.
  Starting data for the computation of periodic orbits are
  generated automatically at Hopf bifurcation points. \\
  (Demo {\tt ab}; Run~2.)
\item[-]
  Locate folds, branch points, period doubling bifurcations,
  and bifurcations to tori, along families of periodic solutions. 
  Branch switching is possible at branch points and at period 
  doubling bifurcations.  \\
  (Demos {\tt tor}, {\tt lor}.)
\item[-]  Continue folds, period-doubling bifurcations,
  and bifurcations to tori, in two parameters, detecting
  1:1, 1:2, 1:3 and 1:4 resonances. \\
  (Demos {\tt plp}, {\tt pp3}, {\tt tor}.)

  The continuation of orbits of fixed period is also
  possible. This is the simplest way to compute curves of
  homoclinic orbits, if the period is sufficiently large. \\
  (Demo {\tt pp2}.)

  The continuation of branch points in two parameters is only possible
  in non-generic problems, characterized by problem-specific symmetries.\\
  (Demo {\tt lcbp}, Run~2.)

  Generically, in non-symmetric problems, branch points are continued
  in three parameters.\\
  (Demos {\tt lcbp}, Run~3, and {\tt abcb}.)

\item[-]  Do each of the above for {\it rotations}, i.e., when some of the
  solution components are periodic modulo a phase gain of a
  multiple of $2 \pi$. \\
  (Demo {\tt pen}.)
\item[-]  Follow curves of homoclinic orbits and detect and continue
  various codimension-2 bifurcations, using the {\cal HomCont} algorithms of 
  \citename{ChKu:94} \citeyear{ChKu:94},
  \citename{ChKuSa:95} \citeyear{ChKuSa:95}.\\
  (Demos  {\tt san}, {\tt mnt}, {\tt kpr}, {\tt cir},
  {\tt she}, {\tt rev}.)
\item[-]  Locate extrema of an integral objective functional along a family 
  of periodic solutions and successively continue such extrema 
  in more parameters. \\
  (Demo {\tt ops}.)
\item[-]
  Compute curves of solutions to (\ref{2}) on $[0,1]$, subject to general
  nonlinear boundary and integral conditions.
  The boundary conditions need not be separated, i.e., they may
  involve both $u(0)$ and $u(1)$ simultaneously.
  The side conditions may also depend on parameters.
  The number of boundary conditions plus the number of integral
  conditions need not equal the dimension of the ODE, 
  provided there is a corresponding number of additional
  parameter variables. \\
  (Demos {\tt exp}, {\tt int}.)
\item[-]
  Determine folds and branch points along
  solution families to the above boundary value problem.
  Branch switching is possible at branch points.
  Curves of folds and branch points can be computed.\\
  (Demos {\tt bvp}, {\tt int}, {\tt sspg}.)
\end{itemize}
 


\section{ Parabolic PDEs.} \label{sec:Parabolic_PDEs}
For (\ref{3}) the program can~:~
 
\begin{itemize}
\item[-]
  Trace out families of spatially homogeneous solutions.
  This amounts to a bifurcation analysis of the algebraic
  system (\ref{1}). However, {\cal AUTO} uses a related system instead,
  in order to enable the detection of bifurcations to wave train
  solutions of given wave speed. More precisely, bifurcations
  to wave trains are detected as Hopf bifurcations along fixed
  point families of the related ODE
  \begin{equation} \label{4} \begin{array}{cl}
  & u'(z) = v(z) ,\\
  & v'(z) =-D^{-1}  \bigl[ c~v(z) + f\bigl( u(z) , p \bigr) \bigr], \\
  \end{array} \end{equation}
  where $z = x - ct$ , with the wave speed $c$ specified by the user.\\
  (Demo {\tt wav}; Run~2.) 
\item[-]
  Trace out families of periodic wave solutions to (\ref{3}) that emanate
  from a Hopf bifurcation point of Equation~\ref{4}.
  The wave speed $c$ is  fixed along such a family, but
  the wave length $L$, i.e., the period of periodic solutions 
  to (\ref{4}),
  will normally vary. If the wave length $L$ becomes large,
  i.e., if a homoclinic orbit of Equation~\ref{4} is approached,
  then the wave tends to a solitary wave solution of (\ref{3}). \\
  (Demo {\tt wav}; Run~3.) 
\item[-]
  Trace out families of waves of fixed wave length $L$ in two parameters. 
  The wave speed $c$ may be chosen as one of these parameters.
  If $L$ is large then such a continuation gives a family
  of approximate solitary wave solutions to (\ref{3}).\\
  (Demo {\tt wav}; Run~4.) 
\item[-]
  Do time evolution calculations for (\ref{3}), given periodic
  initial data on the interval $[0,L]$.
  The initial data must be specified on $[0,1]$ and
  $L$ must be set separately because of internal scaling.
  The initial data may be given analytically or
  obtained from a previous computation of wave trains, solitary
  waves, or from a previous evolution calculation.
  Conversely, if an evolution calculation results in a
  stationary wave then this wave can be used as starting data
  for a wave continuation calculation.\\
  (Demo {\tt wav}; Run~5.)
\item[-]
  Do time evolution calculations for (\ref{3}) subject to user-specified
  boundary conditions.
  As above, the initial data must be specified on $[0,1]$ and the space
  interval length $L$ must be specified separately.
  Time evolution computations of (\ref{3}) are adaptive in space and
  in time. Discretization in time is not very accurate~: only
  implicit Euler. Indeed, time integration of (\ref{3}) has only been
  included as a convenience and it is not very efficient.
  (Demos {\tt pd1}, {\tt pd2}.)
\item[-]
  Compute curves of stationary solutions to (\ref{3}) subject to user-specified
  boundary conditions.
  The initial data may be given analytically, obtained from a previous 
  stationary solution computation, or from a time evolution calculation.\\
  (Demos {\tt pd1}, {\tt pd2}.)
\end{itemize}
 
In connection with periodic waves,
note that (\ref{4}) is just a special case of (\ref{2}) and
that its fixed point analysis is a special case of (\ref{1}).
One advantage of the built-in capacity of {\cal AUTO} to deal with
problem (\ref{3}) is that the user need only specify $f$, $D$, and $c$.
Another advantage is the compatibility of output data for
restart purposes. This allows switching back and forth between
evolution calculations and wave computations.

\section{ Discretization.} \label{sec:Discretization}
  {\cal AUTO} discretizes ODE boundary value problems
  (which includes periodic solutions) by the method of orthogonal 
  collocation using piecewise polynomials with 2-7 collocation points 
  per mesh interval (\citename{dBSw:73} \citeyear{dBSw:73}).
  The mesh automatically adapts to the solution to equidistribute
  the local discretization error (\citename{RuCr:78} \citeyear{RuCr:78}).
  The number of mesh intervals and the number of collocation points
  remain constant during any given run, although they may be changed 
  at restart points.
  The implementation is {\cal AUTO}-specific. In particular, the choice of
  local polynomial basis
  and the algorithm for solving the linearized collocation systems
  were specifically designed for use in numerical bifurcation analysis.
  
%==============================================================================
%==============================================================================
\chapter{ User-Supplied Files.} \label{ch:User_supplied_files}
%==============================================================================
%==============================================================================
The user must prepare the two files described below.
This can be done with the GUI described in Chapter~\ref{ch:GUI}, 
or independently.

\section{ The Equations-File \texttt{xxx.f90}, or \texttt{xxx.f}, or \texttt{xxx.c}} 
A source file {\tt xxx.f90} containing the Fortran routines
{\tt FUNC}, {\tt STPNT}, {\tt BCND}, {\tt ICND}, {\tt FOPT}, and {\tt PVLS}.
Here {\tt xxx} stands for a user-selected name. 
If any of these routines is irrelevant 
to the problem then its body need not be completed.
Examples are in {\tt auto/07p/demos}, where, e.g.,
the file {\tt ab/ab.f90} defines a two-dimensional dynamical system,
and the file {\tt exp/exp.f90} defines a boundary value problem.
The simplest way to create a new equations-file is to copy 
an appropriate demo file.
For a fully documented equations-file see
{\tt auto/07p/demos/cusp/cusp.f90} or {\tt auto/07p/gui/aut.f90}.
In GUI mode, this file can be directly loaded with the GUI-button 
{\it Equations/New}; see Section~\ref{sec:GUI_Menu_bar}.
 
The equations-file can either be written in fixed-form (old-style)
Fortran (.f), free-form Fortran (.f90) or in C (.c).

\section{ The Constants-File \texttt{c.xxx}} 
{\cal AUTO}-constants for {\tt xxx.\{f,f90,c\}} are normally expected 
in a corresponding file {\tt c.xxx}.
Specific examples include {\tt ab/c.ab}
and {\tt exp/c.exp} in {\tt auto/07p/demos}.
See Chapter~\ref{ch:AUTO_constants}
for the significance of each constant.

\newpage
\section{ User-Supplied Routines.} \label{sec: User_supplied_routines}
The purpose of each of the user-supplied routines in
the file {\tt xxx.\{f90,f\}} is described below.
  
\begin{itemize}
\item[-] {\tt FUNC}~:~
  defines the function $f(u,p)$ in (\ref{1}), (\ref{2}), or (\ref{3}).
\item[-] {\tt STPNT}~:~
  This routine is called only if {\tt IRS}=0 
(see Section~\ref{sec:IRS} for {\tt IRS}),
  which typically is the case for the first run, or when a system
  is manually extended. A system is extended if {\tt NDIM} (see
  Section~\ref{sec:NDIM}) increases between runs.
  It defines a starting solution $(u,p)$ of (\ref{1}) or (\ref{2}).
  The starting solution should not be a branch point.\\
  (Demos {\tt ab}, {\tt exp}, {\tt frc}, {\tt lor}.)\\
  It extends an existing solution into higher dimensions in the demos
  {\tt p2c} and {\tt c2c}.
\item[-] {\tt BCND}~:~ 
  A routine {\tt BCND} that defines the boundary conditions. \\
  (Demo {\tt exp}, {\tt kar}.)
\item[-] {\tt ICND}~:~ 
  A routine {\tt ICND} that defines the integral conditions. \\ 
  (Demos {\tt int}, {\tt lin}.)  
\item[-] {\tt FOPT}~:~ 
  A routine {\tt FOPT} that defines the objective functional. \\ 
  (Demos {\tt opt}, {\tt ops}.)  
\item[-] {\tt PVLS}~:~
  A routine {\tt PVLS} for defining ``solution measures''.
  This routine, using a ``\texttt{LOGICAL, SAVE :: first = .TRUE.}''
  variable can also be used for initialization, as it is called
  first. \\
  (Demo {\tt pvl}.)
\end{itemize}

In a C language equation file, these routines are written using
lowercase letters; with Fortran you can use any case.
 
\section{ User-Supplied Derivatives.} \label{sec:derivatives}
If {\cal AUTO}-constant {\tt JAC} equals 0 
then derivatives need not be specified in 
{\tt FUNC}, {\tt BCND}, {\tt ICND}, and {\tt FOPT}; see Section~\ref{sec:JAC}.
If {\tt JAC=1} then derivatives must be given.
If {\tt JAC=-1} then the parameter derivatives may be omitted in 
{\tt FUNC}.
This may be necessary for sensitive 
problems, and is recommended for computations in which {\cal AUTO} 
generates an extended system.
Derivatives are specified as follows, where zero entries may be
omitted:
\begin{itemize}
\item[{\tt FUNC}]
\begin{itemize}
\item
 Derivatives with respect to phase space variables
  are specified in {\tt DFDU(1:NDIM, 1:NDIM)}.
\item
 Parameter derivatives go into {\tt DFDP(1:NDIM, 1:NPAR)}.
\end{itemize}
\item[{\tt BCND}]
\begin{itemize}
\item
Derivatives with respect to the two boundary conditions
are specified in {\tt DBC(1:NBC, 1:NBC)} and {\tt DBC(1:NBC, NBC+1:2*NBC)},
respectively.
\item
Parameter derivatives go into {\tt DBC(1:NBC, 2*NBC+1:2*NBC+NPAR)}.
\end{itemize}
\item[{\tt ICND}]
\begin{itemize}
\item
Derivatives with respect to the integral conditions
are specified in {\tt DINT(1:NINT, 1:NINT)}.
\item
Parameter derivatives go into {\tt DINT(1:NINT, NINT+1:NINT+NPAR)}.
\end{itemize}
\end{itemize}
Examples of user-supplied derivatives can be found in
demos  {\tt dd2}, {\tt int}, {\tt plp}, {\tt opt}, and {\tt ops}.

%==============================================================================
%==============================================================================
\chapter{ Running {\cal AUTO} using Python Commands.} \label{ch:python_mode}
%==============================================================================
%==============================================================================

 \section{ Typographical Conventions }
 This chapter uses the following conventions.
 All code examples will be in in the following font.

 {\small \begin{center} \begin{boxedverbatim}
 AUTO> copydemo("ab")
 Copying demo ab ... done 
 \end{boxedverbatim} 
 \end{center}
 }

 To distinguish commands which are typed to the Unix
 shell from those which are typed to the \AUTO
 command line user interface (CLUI) we will use the
 following two prompts.

 \begin{tabular}{|l|l|}
 \hline 
 \verb!>! & Commands which follow this prompt are for the Unix shell. \\ \hline
 \verb!AUTO>!   & Commands which follow this prompt are for the \AUTO CLUI. \\ \hline
 \end{tabular}

 \section{ General Overview.} \label{sec:CLUI_Overview}
 The \AUTO command line user interface (CLUI) is similar
 to the command language described in Section~\ref{sec:command_mode}
 in that it facilitates the interactive creating and editing of 
 equations-files and constants-files.
 It differs from the other command language in that it is based 
 on the object-oriented scripting language \python (see \citename{Lut:96} \citeyear{Lut:96})
 and provides extensive programming capabilities.
 This chapter will provide documentation for the \AUTO CLUI commands,
 but is not intended as a tutorial for the \python language.
 We will attempt to make this chapter self contained by describing
 all \python constructs that we use in the examples, but
 for more extensive documentation on the \python language,
 including tutorials and pointers to further documentation,
 please see \citename{Lut:96} \citeyear{Lut:96} or the
 web page \url{http://www.python.org} which contains
 an excellent tutorial at 
 \url{http://www.python.org/doc/current/tut/tut.html}.

 To use the CLUI for a new equation, change to an empty directory.
 For an existing equations-file, change to its directory.
 (\emp{Do not activate the CLUI in the directory \filef{auto/07p} 
 or in any of its subdirectories.})
 Then type 

 \centerline {\commandf{auto}.}

 If your command search path has been correctly set (see
 Section~\ref{sec:Installation}), this command will start the \AUTO CLUI
 interactive interpretor and provide you with the \AUTO CLUI prompt.

 \begin{figure}[htbp]
 {\small 
 \begin{center} \begin{boxedverbatim}
 > auto
 Python 2.5.2 (r252:60911, Nov 14 2008, 19:46:32) 
 [GCC 4.3.2] on linux2
 Type "help", "copyright", "credits" or "license" for more information.
 (AUTOInteractiveConsole)
 AUTO>
 \end{boxedverbatim}
 \end{center}
 }
 \caption[Starting the \AUTO CLUI.]
 {Typing \commandf{auto} at the Unix shell prompt starts the
 \AUTO CLUI.  }
 \label{exa:clui_starting}
 \end{figure}

 If you have IPython installed (\url{http://ipython.scipy.org}), then
 you can get a friendlier interface using the command
 \commandf{auto -i}, enabling TAB completion, persistent command-line
 history and other features.

 In addition to the examples in the following sections there are
 several example scripts which can be found in
 \filef{auto/07p/demos/python} and are listed in
 Table~\ref{tbl:demo_scripts}.  These scripts are fully annotated and
 provide good examples of how \AUTO CLUI scripts are written.  The
 scripts in \filef{auto/07p/demos/python/n-body} are especially lucid
 examples and perform various related parts of a calculation involving
 the gravitational N-body problem.  
 Scripts which end in the
 suffix \filef{.auto} are called ``basic'' scripts and can
 be run by typing \commandf{auto scriptname.auto}.
 The scripts shown in Section~\ref{sec:clui_first_example}
 and Section~\ref{sec:clui_complex_example} are examples
 of basic scripts.
 Scripts which end in the
 suffix \filef{.xauto} are called ``expert'' scripts and can
 be run by typing \commandf{autox scriptname.xauto}.
 More information on expert scripts can be 
 found in Section~\ref{sec:clui_extending}.
 See the \filef{README} file in that
 directory for more information.

 \begin{table}[htbp]
 \begin{center}
 \begin{tabular}{| l | l |}
 \hline
 Script & Description \\
 \hline
 demo1.auto & \begin{minipage}{3in}\smallskip The demo script from Section~\ref{sec:clui_first_example}.\smallskip\end{minipage} \\
 \hline
 demo2.auto, demo3.auto, and demo4.auto & \begin{minipage}{3in}\smallskip The demo scripts from Section~\ref{sec:clui_complex_example}.\smallskip\end{minipage} \\
 \hline
 userScript.xauto & \begin{minipage}{3in}\smallskip The expert demo script from Figure~\ref{exa:clui_complex_function}.\smallskip\end{minipage} \\
 \hline
 userScript.py & \begin{minipage}{3in}\smallskip The loadable expert demo script from Figure~\ref{exa:clui_complex_interactive}.\smallskip\end{minipage} \\
 \hline
 branches.auto & \begin{minipage}{3in}\smallskip The branch
   manipulating script from Figure~\ref{exa:clui branch management}.\smallskip\end{minipage}\\
 \hline
 fullTest.auto & \begin{minipage}{3in}\smallskip A script which uses the entire \AUTO command set, except for the plotting commands.\smallskip\end{minipage} \\
 \hline
 plotter.auto & \begin{minipage}{3in}\smallskip A demonstration of some of the plotting capabilities of \AUTO. \smallskip\end{minipage}\\
 \hline
 tutorial.auto & \begin{minipage}{3in}\smallskip A script which implements the tutorial from Section~\ref{sec:Demos_ab}. \smallskip\end{minipage}\\

 \hline n-body/compute\_lagrange\_points\_family.auto 
 & \begin{minipage}{3in}\smallskip A basic script which computes and plots all of the
 ``Lagrange points'' as a function of the ratio of the masses of
 the two planets.\smallskip\end{minipage}\\

 \hline n-body/compute\_lagrange\_points\_0.5.auto
 & \begin{minipage}{3in}\smallskip A basic script which computes all of the ``Lagrange
 points'' for the case where the masses of the two planets are
 equal, and saves the data.
 \smallskip\end{minipage}\\

 \hline n-body/compute\_periodic\_family.xauto
 & \begin{minipage}{3in}\smallskip An expert script which starts at a ``Lagrange
 point'' computed by compute\_lagrange\_points\_0.5.auto
 and continues in the ratio of the masses until
 a specified mass ratio is reached.  It then computes
 a family of periodic orbits for each pair of
 purely complex eigenvalues.
 \smallskip\end{minipage}\\

 \hline n-body/to\_matlab.xauto
 & \begin{minipage}{3in}\smallskip A script which takes a set of \AUTO data files and creates
 a set of files formatted for importing into Matlab
 for either plotting or further calculations.
 \smallskip\end{minipage}\\
 \hline
 \end{tabular}
 \caption[Available demo scripts.]
 {The various demonstration scripts for the \AUTO CLUI.}
 \label{tbl:demo_scripts}
 \end{center}
 \end{table}

 \section{ First Example } \label{sec:clui_first_example}

 We begin with a simple example of the \AUTO CLUI.  In this example we
 copy the \filef{ab} demo from the \AUTO installation directory and
 run it.  For more information on the \filef{ab} demo see
 Section~\ref{sec:Demos_ab}.
 The commands listed in Table~\ref{tbl:example_clui_1}
 will copy the demo files to your work directory and run
 the first part of the demo.
 The results of running these commands are shown in
 Figure~\ref{exa:clui_first_example}.


 \begin{table}[htbp]
 \begin{center}
 \begin{tabular}{| l | l |}
 \hline
   {\cal Unix}-COMMAND  & ACTION \\
 \hline
 %==============================================================================
   \commandf{auto}  & start the \AUTO CLUI\\ 
 \hline
   \AUTO CLUI COMMAND  & ACTION \\
 \hline
   \commandf{demo('ab')}  & copy the demo files to the work directory\\
   \commandf{ab = load(equation='ab')}  & load the filename \filef{ab.f90} into the variable ab\\
   \commandf{ab = load(ab, constants='ab.1')}  & load the contents of
   the file \filef{c.ab.1} into the variable ab\\
   \commandf{run(ab)}  & run \AUTO with the current set of files\\
 \hline
 %==============================================================================
 \end{tabular}
 \caption[Running the demo \filef{ab} files.]
 {Running the demo \filef{ab} files.}
 \label{tbl:example_clui_1}
 \end{center}
 \end{table}

 \begin{figure}[htbp]
 {\small \begin{center} \begin{boxedverbatim}
 > auto
 Python 2.5.2 (r252:60911, Nov 14 2008, 19:46:32) 
 [GCC 4.3.2] on linux2
 Type "help", "copyright", "credits" or "license" for more information.
 (AUTOInteractiveConsole)
 AUTO> demo('ab')
 Copying demo ab ... done
 Runner configured
 AUTO> ab = load(equation='ab')
 Runner configured
 AUTO> ab = load(ab,constants='ab.1')
 Runner configured
 AUTO> run(ab)
 gfortran -fopenmp -O -c ab.f90 -o ab.o
 gfortran -fopenmp -O ab.o -o ab.exe /home/bart/auto/07p/lib/*.o
 Starting ab ...
 
   BR    PT  TY  LAB    PAR(2)        L2-NORM         U(1)          U(2)     
    1     1  EP    1   8.00000E+00   0.00000E+00   0.00000E+00   0.00000E+00
    1    31  UZ    2   1.40000E+01   0.00000E+00   0.00000E+00   0.00000E+00
    1    36  UZ    3   1.50000E+01   0.00000E+00   0.00000E+00   0.00000E+00
    1    41  UZ    4   1.60000E+01   0.00000E+00   0.00000E+00   0.00000E+00
    1    46  UZ    5   1.70000E+01   0.00000E+00   0.00000E+00   0.00000E+00
    1    51  UZ    6   1.80000E+01   0.00000E+00   0.00000E+00   0.00000E+00

  Total Time    0.181E-01
 ab ... done
 <_=bifDiag instance at 0x0972198c>
 AUTO>
 \end{boxedverbatim}
 \end{center} 
 }
 \caption[The first example of the \AUTO CLUI.]
 {Typing \commandf{auto} at the Unix shell prompt starts the
 \AUTO CLUI.  The rest of the commands are interpreted by
 the \AUTO CLUI.}
 \label{exa:clui_first_example}
 \end{figure}


 Let us examine more closely what action each of the commands 
 performs.  First, \commandf{demo('ab')} 
 (Section~\ref{sec:clui_ref_demo} in the reference) copies the files in 
 \filef{\$AUTO\_DIR/demo/ab} into the work directory.  

 Next, \commandf{ab = load(equation='ab')} 
 (Section~\ref{sec:clui_ref_basic} in the reference)
 informs the \AUTO CLUI that the name of
 the user defined function file is \filef{ab.f90}.  The commands
 \commandf{load}, and the closely related \commandf{run}, are
 two of the most commonly used commands in the
 \AUTO CLUI, since they read and parse the user files which are
 manipulated by other commands.  The \AUTO CLUI stores this setting in
 the variable {\tt ab} until it is changed by a command,
 such as another \commandf{load}
 command.  The idea of storing information is one of the ideas that
 sets the CLUI apart from the command language described in
 Section~\ref{sec:command_mode}.

 Next, \commandf{ab = load(ab, constants='ab.1')} parses the \AUTO
 constants file \filef{c.ab.1} and reads it into memory.  Note that
 \emp{changes to the file \filef{c.ab.1} after it has been loaded in
 will not be used by \AUTO unless it is loaded in again after the
 changes are made}.  

 Finally, \commandf{run(ab)} 
 (Section~\ref{sec:clui_ref_basic} in the reference)
 uses the user defined functions loaded
 by the \commandf{load(equation='ab')} command, and the \AUTO constants
 loaded by the \commandf{load(ab, constants = 'ab.1')} to run \AUTO.

 The \commandf{run} command returns a bifurcation diagram structure. It can
 be referenced using the special \commandf{\_} variable in interactive
 sessions, or assigned as \commandf{result=run(ab)}. The result
 can then be referred to in further calculations, plotted, and saved.

 Figure~\ref{exa:clui_first_example} showed two of 
 the file types that the 
 \commandf{load} command can read into memory, namely 
 the user defined function file and the \AUTO constants
 file (Section~\ref{ch:User_supplied_files}).  
 There are two other files types that can be read
 in using the \commandf{load} command, and they are
 the restart solution file (Section~\ref{ch:Output_files})
 and the {\cal HomCont} parameter
 file (Section~\ref{sec:HomCont_files}). The \commandf{load} command
 can also directly load AUTO constants.

 Note that the name given to the load
 command is not the same as the filename which is read
 in, for example \commandf{load(constants='ab.1')} reads in 
 the file \filef{c.ab.1}.  This difference is 
 a result of the automatic transformation of the
 filenames by the 
 \AUTO CLUI into the
 standard names used by \AUTO.  
 The standard filename
 transformations are shown in Table~\ref{tbl:clui_filename_translation}. 

 \begin{table}[htbp]
 \begin{center}
 \begin{tabular}{| l | l | l | l |}
 \hline
 Long name & Short name & Name entered & Transformed file name \\
 \hline
 equation  & e          & foo          &foo.f90/foo.f/foo.c \\
 \hline
 constants  & c          & foo          & c.foo \\
 \hline
 solution  & s          & foo          & s.foo \\
 \hline
 bifurcationDiagram  & b          & foo          &b.foo \\
 \hline
 diagnostics  & d          & foo          &d.foo \\
 \hline
 homcont  & h          & foo          &h.foo \\
 \hline
 \end{tabular}
 \caption[Standard \AUTO CLUI filename translations.]
 {This table shows the standard \AUTO CLUI filename
 translations.  In \filef{load} and \filef{run}
 commands either the long name or the short name may be
 used for loading the appropriate files.}
 \label{tbl:clui_filename_translation}
 \end{center}
 \end{table}

 Since the \commandf{load} command is so common, there are
 various shorthand versions of it.  First, there are short versions
 of the various arguments as shown in Table~\ref{tbl:clui_filename_translation}.
 For example, the command \commandf{load(constants='ab.1')} can 
 be shortened to \commandf{load(c='ab.1')}.
 Next, several different
 files may be loaded at once using the same \commandf{load} command.
 For example, the two commands in Figure~\ref{exa:clui_two_command}
 have the same effect as the single command in 
 Figure~\ref{exa:clui_one_command}.
 Last, you can bypass the \commandf{load} command, unless the
 intermediate result is needed, and use the \commandf{run} command
 directly on the \commandf{load} arguments, as in
 Figure~\ref{exa:clui_one_run_command}.

 \begin{figure}[htbp]
 {\small \begin{center} \begin{boxedverbatim}
 AUTO> ab = load(e='ab')
 Runner configured
 AUTO> ab = load(ab,c='ab.1)
 Runner configured
 \end{boxedverbatim}
 \end{center} 
 }
 \caption[Loading two files individually]
 {Loading two files individually.}
 \label{exa:clui_two_command}
 \end{figure}

 \begin{figure}[htbp]
 {\small \begin{center} \begin{boxedverbatim}
 AUTO> ab = load(e='ab',c='ab.1')
 Runner configured
 \end{boxedverbatim}
 \end{center} 
 }
 \caption[Loading two files at the same time]
 {Loading two files at the same time.}
 \label{exa:clui_one_command}
 \end{figure}

 \begin{figure}[htbp]
 {\small \begin{center} \begin{boxedverbatim}
 AUTO> runab1 = run(e='ab',c='ab.1')
 Runner configured
 \end{boxedverbatim}
 \end{center} 
 }
 \caption[Loading two files at the same time and running]
 {Loading two files at the same time and run using them.}
 \label{exa:clui_one_run_command}
 \end{figure}

 Also, since it is common that several files will be loaded that
 have the same base name \commandf{load('ab')} performs the same 
 action as \commandf{load(e='ab', c='ab', s='ab', h='ab')}. 
 Note, for the command \commandf{load('ab')} it is not required that all
 of the files exist. Information from all existing files is used only
 if they exist, and no error message will be given for non-existing
 files. However, later \commandf{run} commands may cause \AUTO to err
 with incomplete information.

 \section{ Scripting }

 Section~\ref{sec:clui_first_example} showed commands
 being interactively entered at the \AUTO CLUI
 prompt, but since the \AUTO CLUI is based 
 on \python one has the ability to write
 scripts for performing sequences of commands
 automatically.  A \python script is very similar
 to the interactive mode shown in Section~\ref{sec:clui_first_example}
 except that the commands are placed in a file and
 read all at once.  For example, if the
 commands from Figure~\ref{exa:clui_first_example} where placed 
 into the file \filef{demo1.auto}, in the format shown in 
 Figure~\ref{exa:clui_first_script}, then the commands
 could be run all at once by typing \commandf{auto demo1.auto}.
 See Figure~\ref{exa:clui_run_first_script} for the
 full output.

 \begin{figure}[htb]
 {\small \begin{center} \begin{boxedverbatim}
 demo('ab')
 ab = load(equation='ab')
 ab = load(ab, constants='ab.1')
 run(ab)
 \end{boxedverbatim}
 \end{center} 
 }
 \caption[First example of a \AUTO CLUI script.]
 {The commands from Figure~\ref{exa:clui_first_example}
 and they would appear in a \AUTO CLUI script file.
 The source for this script can be found in \filef{\$AUTO\_DIR/demos/python/demo1.auto}.
 }
 \label{exa:clui_first_script}
 \end{figure}

 \begin{figure}[htb]
 {\small \begin{center} \begin{boxedverbatim}
 > cat demo1.auto
 demo('ab')
 ab = load(equation='ab')
 ab = load(ab, constants='ab.1')
 run(ab)

 > auto demo1.auto 
 Copying demo ab ... done
 Runner configured
 Runner configured
 Runner configured
 gfortran -fopenmp -O -c ab.f90 -o ab.o
 gfortran -fopenmp -O ab.o -o ab.exe /home/bart/auto/07p/lib/*.o
 Starting ab ...

   BR    PT  TY  LAB    PAR(2)        L2-NORM         U(1)          U(2)     
    1     1  EP    1   8.00000E+00   0.00000E+00   0.00000E+00   0.00000E+00
    1    31  UZ    2   1.40000E+01   0.00000E+00   0.00000E+00   0.00000E+00
    1    36  UZ    3   1.50000E+01   0.00000E+00   0.00000E+00   0.00000E+00
    1    41  UZ    4   1.60000E+01   0.00000E+00   0.00000E+00   0.00000E+00
    1    46  UZ    5   1.70000E+01   0.00000E+00   0.00000E+00   0.00000E+00
    1    51  EP    6   1.80000E+01   0.00000E+00   0.00000E+00   0.00000E+00

  Total Time    0.193E-01
 ab ... done
 > 
 \end{boxedverbatim}
 \end{center} 
 }
 \caption[Figure of running a simple \AUTO CLUI script.]
 {This Figure starts by listing the contents
 of the \filef{demo1.auto} file using the Unix
 \commandf{cat} command.  The file is then run through
 the \AUTO CLUI by typing {auto demo1.auto} 
 and the output is shown.}
 \label{exa:clui_run_first_script}
 \end{figure}


 \section{ Second Example } \label{sec:clui_complex_example}

 In Section~\ref{sec:clui_first_example} we showed a very simple
 \AUTO CLUI script, in this Section we will describe a more
 complex example, which introduces several new \AUTO CLUI
 commands as well as a basic \python construct for looping.
 We will not provide an exhaustive reference for
 the \python language, but only 
 the very basics.  For more extensive documentation we refer the
 reader to \citename{Lut:96} \citeyear{Lut:96} or the
 web page \url{http://www.python.org}.
 In this section we will describe each line of the script
 in detail, and the full text of the script is in
 Figure~\ref{exa:clui_complex_script}.

 \begin{figure}[htbp]
 {\small \begin{center} \begin{boxedverbatim}
 demo('bvp')

 bvp = run('bvp')
 branchpoints = bvp("BP")
 for solution in branchpoints:
     bp = load(solution, ISW=-1, NTST=50)
     # Compute forwards
     print "Solution label", bp["LAB"], "forwards"
     fw = run(bp)
     # Compute backwards
     print "Solution label", bp["LAB"], "backwards"
     bw = run(bp,DS='-')
     both = fw + bw
     merged = merge(both)
     bvp = bvp + merged

 bvp=relabel(bvp)
 save(bvp, 'bvp')
 plot(bvp)
 wait()
 \end{boxedverbatim}
 \end{center} 
 }
 \caption[A complex example of a \AUTO CLUI script.]
 {This Figure shows a more complex \AUTO CLUI script.
 The source for this script can be found in \filef{\$AUTO\_DIR/demos/python/demo2.auto}.
 }
 \label{exa:clui_complex_script}
 \end{figure}

 The script begins with a section, extracted into 
 Figure~\ref{exa:clui_complex_first}, which performs a task 
 identical to that shown in Figure~\ref{exa:clui_first_example}
 except that the shorthand discussed in 
 Section~\ref{sec:clui_first_example} is used for the 
 \commandf{run} command.

 \begin{figure}[htbp]
 {\small \begin{center} \begin{boxedverbatim}
 demo('bvp')

 bvp = run('bvp')
 \end{boxedverbatim}
 \end{center} 
 }
 \caption[The first part of the  complex \AUTO CLUI script.]
 {The first part of the  complex \AUTO CLUI script.}
 \label{exa:clui_complex_first}
 \end{figure}

 Up to this point all of the commands presented have had
 analogs in the command language discussed in 
 Section~\ref{sec:command_mode}, and the \AUTO CLUI has
 been designed in this way to make it easy for users to
 migrate from the old command language to the
 \AUTO CLUI.  The next section of the script extracted into
 Figure~\ref{exa:clui_complex_first}, introduces a new
 command, namely \commandf{branchpoints = bvp("BP")},
 which is the first command which has no analog in the 
 old command language.
 The command \commandf{bvp("BP")}, given the output variable \commandf{bvp}
 from the first run, returns a \python object which represents a list
 of all branchpoint solutions.
 Accordingly, this list is stored in the \python
 variable \commandf{branchpoints}.
 Note, variables in \python are different from those in languages
 such as {\cal C} in that their type does not have to be
 declared before they are created.

 \begin{figure}[htbp]
 {\small \begin{center} \begin{boxedverbatim}
 branchpoints = bvp("BP")
 for solution in branchpoints:
     bp = load(solution, ISW=-1, NTST=50)
     # Compute forwards
     print "Solution label", bp["LAB"], "forwards"
     fw = run(bp)
     # Compute backwards
     print "Solution label", bp["LAB"], "backwards"
     bw = run(bp,DS='-')
     both = fw + bw
     merged = merge(both)
     bvp = bvp + merged
 \end{boxedverbatim}
 \end{center} 
 }
 \caption[The second part of the  complex \AUTO CLUI script.]
 {The second part of the  complex \AUTO CLUI script.}
 \label{exa:clui_complex_second}
 \end{figure}

 The next command, \commandf{for solution in branchpoints:} is
 the \python syntax for loops.  The \commandf{branchpoints} object
 is a list of the branch point solutions from the first run.
 The command 
 \commandf{for solution in branchpoints:} is used to loop
 over all solutions in the branchpoints variable by 
 setting the variable \commandf{solution} to
 be one of the solutions in \commandf{branchpoints}
 and then calling the rest of the code in the
 block.  

 \python differs from most other computer languages in that
 blocks of code are not defined by some delimiter, such
 as \commandf{END DO} in {\cal Fortran}, but by indentation.  
 In Figure~\ref{exa:clui_complex_script} the commands starting with
 \commandf{bvp=relabel(bvp)} are not
 part of the loop, because they are indented 
 differently.  This can be confusing first time users of \python,
 but it has the advantage that the code
 is forced to have a consistent indentation style.

 The next command in the script,
 \commandf{bp = load(solution, ISW=-1, NTST=50)}
 loads a solution with modified AUTO constants. All other constants are
 the same as they were in the first run.
 The \parf{ISW} value is changed to \parf{-1} (see
 Section~\ref{sec:ISW}), so that a branch switch is performed, and
 the \parf{NTST} value is changed to \parf{50} (see
 Section~\ref{sec:NTST}).
 Only ``in memory'' versions of the \AUTO constants are modified;
 the original file \filef{c.bvp} is \emp{not} modified.

 Some diagnostics are then printed to the screen using a standard \python
 \commandf{print} command: the label number of the branch point that
 we switch at can be found by using \commandf{bp["LAB"]}.
 In addition, as can be seen in Figure~\ref{exa:clui_complex_second},
 the \commandf{\#} character is the \python comment character.
 When the \python interpretor encounters a \commandf{\#} character
 it ignores everything from that character to the end of the line.

 We then use a \commandf{fw=run(bp)} command to perform the
 calculation of the bifurcating branch from solution \commandf{bp}.
 We print additional information and use the command
  \commandf{bw = run(bp,DS='-')} to change the
 \AUTO initial step size from positive to negative, which causes
 \AUTO to compute the bifurcating branch in the other direction
 (see Section~\ref{sec:DS}).
 This output is appended to the existing output in the
 \python variable \commandf{bvp} after some more processing.
 First the command
 \commandf{both = fw + bw} concatenates, using standard Python list
 syntax, the forwards and backwards branches. Subsequently
 \commandf{merged = merge(both)} merges the two branches into one
 continuous branch where the backwards branch is flipped.
 Finally, the command \commandf{bvp = bvp + merged} appends the
 merged branch to the existing results.

 \begin{figure}[htbp]
 {\small \begin{center} \begin{boxedverbatim}
 bvp=relabel(bvp)
 save(bvp, 'bvp')
 plot(bvp)
 wait()
 \end{boxedverbatim}
 \end{center} 
 }
 \caption[The third part of the  complex \AUTO CLUI script.]
 {The third part of the  complex \AUTO CLUI script.}
 \label{exa:clui_complex_third}
 \end{figure}

 The last section of the script, extracted into 
 Figure~\ref{exa:clui_complex_third}, 
 does some postprocessing and
 plotting. First, the command \commandf{bvp=relabel(bvp)} relabels
 so all solutions in the \commandf{bvp} object have unique labels
 starting at 1. The command \commandf{save(bvp,'bvp')}
 (Section~\ref{sec:clui_ref_basic} in the reference)
 saves the results of the \AUTO runs into files using
 the base name \filef{bvp} and the filename extensions in
 Table~\ref{tbl:clui_filename_translation}.  For example,
 in this case the bifurcation diagram will be saved as \filef{b.bvp}, 
 the solution will be saved as \filef{s.bvp}, and  
 the diagnostics will be saved as \filef{d.bvp}.

 Now that the section of script shown in 
 Figure~\ref{exa:clui_complex_third} has finished computing the
 bifurcation diagram, the command \commandf{plot(bvp)}
 brings up a plotting window 
 (Section~\ref{sec:clui_ref_plot} in the reference),
 and the command \commandf{wait()} causes the \AUTO CLUI
 to wait for input.  You may now exit the \AUTO CLUI
 by pressing any key in the window in which you started
 the \AUTO CLUI.

 For convenience, some of these commands have shorter forms.
 For instance, the \commandf{load}, \commandf{run}, \commandf{merge},
 \commandf{relabel}, \commandf{save}, and \commandf{plot} commands
 have the shorter forms \commandf{ld}, \commandf{r}, \commandf{mb},
 \commandf{rl}, \commandf{sv}, and \commandf{pl}, respectively.
 All algebraic and functional expressions can be combined in the
 usual way. Combining these techniques, a shorter version of the complex \AUTO
  CLUI script is given in Figure~\ref{exa:clui_complex_fourth}.

 \begin{figure}[htbp]
 {\small \begin{center} \begin{boxedverbatim}
 demo('bvp')

 bvp=r('bvp')
 for solution in bvp('BP'):
     bp = ld(solution,NTST=50,ISW=-1)
     # Compute forwards and backwards
     bvp = bvp + mb(r(bp)+r(bp,DS='-'))

 bvp=rl(bvp)
 pl(bvp)
 sv(bvp,'bvp')
 wait()
 \end{boxedverbatim}
 \end{center} 
 }
 \caption[A complex example of a \AUTO CLUI script.]
 {This Figure shows a shorter version of the more complex \AUTO CLUI
   script given above.
 The source for this script can be found in \filef{\$AUTO\_DIR/demos/python/demo3.auto}.
 }
 \label{exa:clui_complex_fourth}
 \end{figure}

 Even shorter forms are possible to save you typing using features
 borrowed from ipython, both in \commandf{auto -i} and in plain
 \commandf{auto}. Those forms use auto-parentheses and auto-quotes:
 for a command that does not assign to a variable you can skip the
 parentheses, and by using a ``,'' on the first character of a line
 you force all parameters to be quoted. For example, you can just
 type \commandf{pl bvp} to plot the bifurcation diagram and solutions
 in the object \commandf{bvp}.
 Beware that these extra short forms are only possible in
 normal auto scripts and at the AUTO CLUI prompt, and only if they
 start in the first column, but not in the
 ``expert'' scripts described in the next section.
 The even shorter version of the complex \AUTO
 CLUI script is given in Figure~\ref{exa:clui_complex_fifth}.
 It should be clear that these super-short forms save you typing
 at the command prompt but do not help readability in scripts.
 \begin{figure}[htbp]
 {\small \begin{center} \begin{boxedverbatim}
 ,demo bvp

 bvp=r('bvp')
 for solution in bvp('BP'):
     bp = ld(solution,NTST=50,ISW=-1)
     # Compute forwards and backwards
     bvp = bvp + mb(r(bp)+r(bp,DS='-'))

 bvp=rl(bvp)
 pl bvp
 sv bvp, 'bvp'
 wait
 \end{boxedverbatim}
 \end{center} 
 }
 \caption[Another complex example of a \AUTO CLUI script.]
 {This Figure shows an even shorter version of the more complex \AUTO CLUI
   script given above.
 The source for this script can be found in \filef{\$AUTO\_DIR/demos/python/demo4.auto}.
 }
 \label{exa:clui_complex_fifth}
 \end{figure}



 \section{ Extending the \AUTO CLUI } \label{sec:clui_extending}

 The code in Figure~\ref{exa:clui_complex_script}
 performed a very useful and common procedure, it started an \AUTO
 calculation and performed additional continuations
 at every point which \AUTO detected as a bifurcation.
 Unfortunately, the script as written can only be used
 for the \filef{bvp} demo.  In this section we will 
 generalize the script in Figure~\ref{exa:clui_complex_script}
 for use with any demo, and demonstrate how it
 can be imported back into the interactive
 mode to create a new command
 for the \AUTO CLUI.  Several examples of such
 ``expert'' scripts can be found in \filef{auto/07p/demos/python/n-body}.

 Just as loops and conditionals can be used in \python,
 one can also define functions.  For example,
 Figure~\ref{exa:clui_complex_function} is a
 functional version of script from 
 Figure~\ref{exa:clui_complex_script}.
 The changes are actually quite minor.  
 The first line, \commandf{from auto import *},
 includes the definitions of the \AUTO CLUI commands,
 and must be included in all \AUTO CLUI scripts
 which define functions.
 The next line, 
 \commandf{def myRun(demoname):},
 begins the function definition, and 
 creates a function named \commandf{myRun} which
 takes one argument \commandf{demoname}.  The
 rest of the script is the same except that it
 has been indented to indicate that it is
 part of the function definition, all occurrences
 of string \commandf{'bvp'} have been replaced
 with the variable \commandf{demoname}, and the variable
 \commandf{bvp} was replaced by the variable \commandf{r}.
 Finally we have added a line \commandf{myRun('bvp')}
 which actually calls the function we have 
 created and runs the same computation as
 the original script.

 \begin{figure}[htbp]
 {\small \begin{center} \begin{boxedverbatim}
 from auto import *

 def myRun(demoname):

     demo(demoname)

     r = run(demoname)
     branchpoints = r("BP")
     for solution in branchpoints:
         bp = load(solution, ISW=-1, NTST=50)
         # Compute forwards
         print "Solution label", bp["LAB"], "forwards"
         fw = run(bp)
         # Compute backwards
         print "Solution label", bp["LAB"], "backwards"
         bw = run(bp,DS='-')
         both = fw + bw
         merged = merge(both)
         r = r + merged

     r=relabel(r)
     save(r, demoname)
     plot(r)
     wait()

 myRun('bvp')

 \end{boxedverbatim}
 \end{center} 
 }
 \caption[A complex \AUTO CLUI script as a function.]
 {This Figure shows a complex \AUTO CLUI script
 written as a function.
 The source for this script can be found in \filef{\$AUTO\_DIR/demos/python/userScript.xauto}.
 }
 \label{exa:clui_complex_function}
 \end{figure}

 While the script in Figure~\ref{exa:clui_complex_function} is 
 only slightly different then the one showed in 
 Figure~\ref{exa:clui_complex_script} it is much more powerful.
 Not only can it be used as a script for running any demo
 by modifying the last line, it can be read back into
 the interactive mode of the \AUTO CLUI and
 used to create a new command, 
 as in Figure~\ref{exa:clui_complex_interactive}.
 First, we create a file called \filef{userScript.py}
 which contains the script from 
 Figure~\ref{exa:clui_complex_function}, with
 one minor modification.  We want the function only
 to run when we use it interactively, not when
 the file \filef{userScript.py} is read in, so we
 remove the last line where the function is called.
 We start the \AUTO CLUI with the Unix command
 \commandf{auto}, and once the \AUTO CLUI is running
 we use the command \commandf{from userScript import *},
 to import the file \filef{userScript.py} into the
 \AUTO CLUI.  The \commandf{import} command makes
 all functions in that file available for
 our use (in this case \commandf{myRun} is the only 
 one).  It is important to note that 
 \commandf{from userScript import *} does \emp{not}
 use the \filef{.py} extension on the file name. 
 After importing our new function, we may use it
 just like any other function in the \AUTO
 CLUI, for example by typing \commandf{myRun('bvp')}.

 \begin{figure}[htbp]
 {\small \begin{center} \begin{boxedverbatim}
 > cp \$AUTO\_DIR/python/demo/userScript.py .
 > ls
 userScript.py
 > cat userScript.py
 # This is an example script for the AUTO07p command line user
 # interface.  See the "Command Line User Interface" chapter in the
 # manual for more details.
 from auto import *

 def myRun(demoname):

     demo(demoname)

     r = run(demoname)
     branchpoints = r("BP")
     for solution in branchpoints:
         bp = load(solution, ISW=-1, NTST=50)
         # Compute forwards
         print "Solution label", bp["LAB"], "forwards"
         fw = run(bp)
         # Compute backwards
         print "Solution label", bp["LAB"], "backwards"
         bw = run(bp,DS='-')
         both = fw + bw
         merged = merge(both)
         r = r + merged

     r=relabel(r)
     save(r, demoname)
     plot(r)
     wait()

 > auto
 Python 2.5.2 (r252:60911, Nov 14 2008, 19:46:32) 
 [GCC 4.3.2] on linux2
 Type "help", "copyright", "credits" or "license" for more information.
 (AUTOInteractiveConsole)
 AUTO> from userScript import *
 AUTO> myRun('bvp')
 ...
 \end{boxedverbatim}
 \end{center} 
 }
 \caption[An example of using a user created function interactively.]
 {This Figure shows the functional version of the
  \AUTO CLUI from Figure~\ref{exa:clui_complex_function} being 
 used as an extension to the \AUTO CLUI.  The source
 code for this script can be found in 
 \filef{\$AUTO\_DIR/python/demo/userScript.py }}
 \label{exa:clui_complex_interactive}
 \end{figure}

 \section{ Bifurcation Diagram Objects}
 The \commandf{run} and \commandf{loadbd} commands (see
 Section~\ref{sec:clui_ref_basic} in the reference for details)
 return a ~\python structure which we refer to as a \emph{bifurcation
 diagram object}. It represents the information that is also stored
 in \AUTO's output files (\filef{fort.7}, \filef{fort.8},
 and \filef{fort.9}, or \filef{b.*}, \filef{s.*}, and \filef{d.*}),
 and in \AUTO's constant files.
 For example, the command \commandf{loadbd('ab')}
 returns an object corresponding to the files \filef{b.ab},
 \filef{s.ab}, and \filef{d.ab}.
 (if you are using the standard
 filename translations from Table~\ref{tbl:clui_filename_translation}).
 The command \commandf{run('ab')} returns
 an object corresponding to the output of the run.

 The bifurcation diagram object encapsulates all this information in
 an easy to use form.
 This object is a list of all of the branches in the appropriate
 bifurcation diagram file, and each branch behaves like an array
 (a PyDSTool Pointset subclass, to be precise). This array can be
 viewed as a list of all of the points in the appropriate
 bifurcation diagram file, and each point is a \python
 dictionary with entries for each piece of data for the point.
 For example, the sequence of commands
 in Figure~\ref{exa:clui parse diagram}, prints out the
 label of the first point of a branch in a bifurcation diagram.
 The query-able parts of the object are listed in
 Table~\ref{tbl:clui parse diagram}.

 The individual elements of the array may be accessed 
 in a number of ways: by index of the point using the
 \commandf{[]} syntax, a column using \commandf{['columnname']} syntax,
 or by label number or type name plus one-based index using the
 \commandf{()} syntax.  For example, assume that the parsed object is contained
 in a variable \commandf{data}, and the first branch is in a variable
 \commandf{br=data[0]}.
 The first point may then be accessed 
 using the command \commandf{br[0]}, while the column
 with label \parf{PAR(1)} may be accessed using the command
 \commandf{br['PAR(1)']}.
 The point with label \commandf{57} may be accessed using the command
 \commandf{br(57)}, and the second Hopf bifurcation point using
 the command \commandf{br('HB2')}
 Using the \commandf{()} syntax you can also obtain new lists of
 points: \commandf{br('HB')} gives a list of all Hopf bifurcation
 points, \commandf{br([1,4])} gives the points with labels 1 and 4,
 and \commandf{br(['UZ',4])} gives all user defined points and label
 4.
 
 The \commandf{['columnname']} syntax is especially useful for
 plotting, as is illustrated in Figure~\ref{exa:bdplot}. Here the
 \python package matplotlib is directly used to plot a branch.
 Of course, the command \commandf{plot} may also be used, but
 sometimes more control may be needed.

 \begin{figure}[htbp]
 {\small \begin{center} \begin{boxedverbatim}
 AUTO> demo('lrz')
 Copying demo lrz ... done
 Runner configured
 AUTO> data=run('lrz')
 gfortran -fopenmp -O -c lrz.f -o lrz.o
 gfortran -fopenmp -O lrz.o -o lrz.exe /home/bart/auto/07p/lib/*.o
 Starting lrz ...
(...)
lrz ... done
 AUTO> print data

  BR    PT  TY  LAB    PAR(1)        L2-NORM         U(1)          U(2)          U(3)     
   1     1  EP    1   0.00000E+00   0.00000E+00   0.00000E+00   0.00000E+00   0.00000E+00
   1     5  BP    2   1.00000E+00   0.00000E+00   0.00000E+00   0.00000E+00   0.00000E+00
   1    13  EP    3   3.16000E+01   0.00000E+00   0.00000E+00   0.00000E+00   0.00000E+00

  BR    PT  TY  LAB    PAR(1)        L2-NORM         U(1)          U(2)          U(3)     
   2    42  HB    4   2.47368E+01   2.62685E+01   7.95602E+00   7.95602E+00   2.37368E+01
   2    45  EP    5   3.26008E+01   3.41635E+01   9.17980E+00   9.17980E+00   3.16008E+01

  BR    PT  TY  LAB    PAR(1)        L2-NORM         U(1)          U(2)          U(3)     
   2    42  HB    6   2.47368E+01   2.62685E+01  -7.95602E+00  -7.95602E+00   2.37368E+01
   2    45  EP    7   3.26008E+01   3.41635E+01  -9.17980E+00  -9.17980E+00   3.16008E+01

 AUTO> br=data[1]
 AUTO> print br
  BR    PT  TY  LAB    PAR(1)        L2-NORM         U(1)          U(2)          U(3)     
   2    42  HB    4   2.47368E+01   2.62685E+01   7.95602E+00   7.95602E+00   2.37368E+01
   2    45  EP    5   3.26008E+01   3.41635E+01   9.17980E+00   9.17980E+00   3.16008E+01
 AUTO> print br[0]
 {'TY number': 0, 'PT': -1, 'index': 0, 'section': 0, 'LAB': 0, 'BR': 2,
  'data': [0.99999994000000003, 0.0, 0.0, 0.0, 0.0], 'TY name': 'No Label'}
 AUTO> print br['PAR(1)']
 [  0.99999994   1.001875     1.00747645   1.01786791   1.03426011
    1.05801491   1.08738983   1.12195713   1.16544975   1.21923418
(...)
   13.69994168  15.15715248  16.76398367  18.53533839  20.48761501
   22.63885621  24.73684367  27.10974373  29.72303281  32.60076345]
 AUTO> print br(4)
 {'TY number': 3, 'PT': 42, 'index': 41, 'section': 0, 'LAB': 4, 'BR': 2, 
  'data': [24.736843667999999, 26.268502943000001, 7.9560197197999996,
   7.9560197197999996, 23.736843667999999], 'TY name': 'HB'}
 \end{boxedverbatim}
 \end{center} 
 }
 \caption[An example of processing a bifurcation diagram of a run.]
 {This figure shows an example of parsing a bifurcation diagram.
 First the demo involving the Lorenz equations named 'lrz' is copied
 and we perform its first run. We then print
 the result, its second branch, the first point on this branch,
 the column corresponding to 'PAR(1)', and the point with
 label 4 on this branch.
 }
 \label{exa:clui parse diagram}
 \end{figure}

 \begin{figure}[htbp]
 {\small \begin{center} \begin{boxedverbatim}
 AUTO> import pylab
 AUTO> pylab.plot(br['PAR(1)'],br['U(1)'])
 [<matplotlib.lines.Line2D object at 0x9b1356c>]
 AUTO> pylab.show()
 \end{boxedverbatim}
 \end{center} 
 }
 \caption{Following the example in Figure~\ref{exa:clui parse diagram} 
  we can plot a subset of the bifurcation diagram, that is, the second
  branch, directly using matplotlib.}
 \label{exa:bdplot}
 \end{figure}

 \begin{table}[htbp]
 \begin{center}
 \begin{tabular}{| l | l |}
 \hline
 Query string & Meaning \\
 \hline
 TY name &  The short name for the solution type (see Table~\ref{tbl:clui type translation}). \\
 \hline
 TY number &  The number of the solution type (see Table~\ref{tbl:clui type translation}). \\
 \hline
 BR  &  The branch number. \\
 \hline
 PT  &  The point number. \\
 \hline
 LAB  &  The solution label, if any. \\
 \hline
 section  &  A unique identifier for each branch in a file with multiple branches. \\
 \hline
 data  &  An array which contains the \AUTO output. \\
 \hline
 \end{tabular}
 \caption[Contents of a bifurcation diagram object.]
 {This table shows the strings that can be used to
 query a bifurcation diagram object and their
 meanings.}
 \label{tbl:clui parse diagram}
 \end{center}
 \end{table}

 \begin{table}[htbp]
 \begin{center}
 \begin{tabular}{| l | l | l |}
 \hline
 Type & Short Name & Number \\
 \hline
 No Label & No Label &  \\
 \hline
 Branch point (algebraic problem) & BP & 1 \\
 \hline
 Fold (algebraic problem) & LP & 2 \\
 \hline
 Hopf bifurcation (algebraic problem) & HB & 3 \\
 \hline
 Regular point (every NPR steps) & RG & 4 \\
 \hline
 User requested point & UZ & -4 \\
 \hline
 Fold (ODE) & LP & 5 \\
 \hline
 Bifurcation point (ODE) & BP & 6 \\
 \hline
 Period doubling bifurcation (ODE) & PD & 7 \\
 \hline
 Bifurcation to invariant torus (ODE) & TR & 8 \\
 \hline
 Normal begin or end & EP & 9 \\
 \hline
 Abnormal termination & MX & -9 \\
 \hline
 \end{tabular}
 \caption[Type translations.]
 {This table shows the various types of points
 that can be in solution and bifurcation diagram
 files, with their short names and numbers.}
 \label{tbl:clui type translation}
 \end{center}
 \end{table}

 \begin{table}[htbp]
 \begin{center}
 \begin{tabular}{| l | l | l |}
 \hline
 Type & Short Name & Number \\
\hline
 Bogdanov-Takens bifurcation (algebraic problem) & BT & -21, -31 \\
 \hline
 Cusp (algebraic problem) & CP & -22 \\
\hline
 Generalized Hopf bifurcation (algebraic problem) & GH & -32 \\
\hline
 Zero-Hopf bifurcation (algebraic problem) & ZH & -13, -23, -33 \\
\hline
 1:1 Resonance bifurcation (ODE, maps) & R1 & -25, -55, -85 \\
\hline
 1:2 Resonance bifurcation (ODE, maps) & R2 & -76, -86 \\
\hline
 1:3 Resonance bifurcation (ODE, maps) & R3 & -87 \\
\hline
 1:4 Resonance bifurcation (ODE, maps) & R4 & -88 \\
\hline
 Fold-flip bifurcation (maps) & LPD & 28, 78 \\
\hline
 Fold-torus bifurcation (maps) & LTR & 23, 83 \\
\hline
 Flip-torus bifurcation (maps) & PTR & 77, 87 \\
\hline
 Torus-torus bifurcation (maps) & TTR & 88 \\
\hline
 \end{tabular}
 \caption[Codimension-two type translations.]
 {This table shows the various types of codimension-two points
 as in Table~\ref{tbl:clui type translation}. The absolute value
 of the number divided by 10 gives the type of the branch on which
 the codimension-two bifurcation occurs.}
 \label{tbl:clui codim2 type translation}
 \end{center}
 \end{table}

 Additionally three special keys can be used to query a branch: use
 \commandf{br['BR']} to obtain the branch number, \commandf{br['TY']}
 for the branch type, and \commandf{br['TY number']} for the
 corresponding number. These keys are also useful to change
 bifurcation diagram files, as is illustrated in
 Figure~\ref{exa:clui branch management}. Note that you can
 interactively change branch numbers, solution numbers and delete
 branches and solutions using the \commandf{@lb} command
 (see Chapter~\ref{sec:command_mode}).

 \begin{figure}[htbp]
 {\small \begin{center} \begin{boxedverbatim}
 # get and run the ab demo
 demo('ab')
 auto('ab.auto')
 # load data from b.ab, s.ab, and d.ab
 ab = loadbd('ab')
 # change the branch number to either 1 or 2 depending on IPS
 for branch in ab:
     branch['BR'] = branch.c['IPS']
 # delete the last branch
 del ab[-1]
 # subtract the first branch from all other branches with respect to PAR(1)
 ab = subtract(ab, ab, 'PAR(1)')
 # plot the branches, coloring by branch number
 plot(ab, coloring_method='branch', color_list='black red')
 wait()
 # save data to b.abnew, s.abnew, and d.abnew
 save(ab, 'abnew')
 \end{boxedverbatim}
 \end{center} 
 }
 \caption{This example shows how to change branch numbers and delete a
 branch in the 'ab' demo output file. Using
 the \parf{coloring\_method='branch'} setting you can then give one
 color to all branches of fixed points and one other color to all
 branches of periodic orbits.
 The source for this script can be found in
 \filef{\$AUTO\_DIR/demos/python/branches.auto}.}
 \label{exa:clui branch management}
 \end{figure}

 \subsection{ Solutions}
 You can also obtain solutions from a bifurcation diagram structure,
 by using the \commandf{()} syntax directly on the diagram instead of
 on individual branches.
 For example, in the above example the command
 \commandf{s=data()}
 returns an object which encapsulates
 all solutions in a easy to use form.

 The object returned in this way
 is a list of all of the solutions in the appropriate
 bifurcation solution file, and each solution is a Python
 dictionary with entries for each  piece of
 data for the solution.  For example, the sequence of commands
 in Figure~\ref{exa:clui parse solution}, prints out the
 label of the first solution in a bifurcation solution.
 The query-able parts of the object are listed in
 Table~\ref{tbl:clui parse solution}.

 \begin{figure}[htbp]
 {\small \begin{center} \begin{boxedverbatim}
 AUTO> s=data()
 AUTO> sol=s[3] #or s(4), data(4), s('HB1'), or data('HB1')
 AUTO> print sol 
   BR    PT  TY  LAB ISW NTST NCOL NDIM IPS IPRIV
    2    42  HB    4   1    1    0    3   1     0
 Pointset lrz (parameterized)
 Independent variable:
 t:  [ 0.]
 Coordinates:
 U(1):  [ 7.95601972]
 U(2):  [ 7.95601972]
 U(3):  [ 23.73684367]
 Labels by index: Empty
 Active ICP: [1]
 rldot: [0.69738311435]
 udotps: Pointset lrz (non-parameterized)
 Coordinates:
 UDOT(1):  [ 0.11686228]
 UDOT(2):  [ 0.11686228]
 UDOT(3):  [ 0.69738311]
 Labels by index: Empty
 PAR(1:5):      2.4736843668E+01   2.6666666667E+00   1.0000000000E+01   0   0
 PAR(6:10):     0.0000000000E+00   0.0000000000E+00   0.0000000000E+00   0   0
 PAR(11:11):    6.5283032822E-01
 AUTO> print sol['LAB']
 4
 AUTO> print sol['L2-NORM'] # or sol.b['L2-NORM']
 26.268502943
 AUTO> sol[0]
 {'u': [7.9560197197999996, 7.9560197197999996, 23.736843667999999],
   't': 0.0, 'u dot': [0.11686227712, 0.11686227712, 0.69738311435]}
 AUTO> sol['t']
 array([ 0.])
 AUTO> sol['U(1)']
 array([ 7.95601972])
 AUTO> sol.PAR(1) # or sol['PAR(1)']
 24.736843667999999
 AUTO> pylab.plot(sol['U(1)'],sol['U(2)'],'+')
 [<matplotlib.lines.Line2D object at 0x9c3348c>]
 AUTO> pylab.show()
 \end{boxedverbatim}
 \end{center} 
 }
 \caption[An example of parsing solutions.]
 {This figure shows an example of parsing solutions.
 The first command, \commandf{s=data()}, extracts a list of all solutions
 stored in the bifurcation diagram object \commandf{data} from the
 'lrz' demo in Figure~\ref{exa:clui parse diagram}
 and puts it into the variable \commandf{s}.
 The command \commandf{sol=s[3]} obtains the fourth solution.
 Next, \commandf{print sol} displays it.
 The last commands illustrate how to extract components from
 this fourth solution: its label, its first point, its time array, its first
 coordinate array, its first parameter, and a plot of the first two
 coordinates.
 }
 \label{exa:clui parse solution}
 \end{figure}

 \begin{table}[htbp]
 \begin{center}
 \begin{tabular}{| l | l |}
 \hline
 Query string & Meaning \\
 \hline
 data  & \begin{minipage}{4in} \smallskip An array which contains the
 \AUTO output. Each array entry is a Python dictionary with a scalar
 entry 't' denoting time,
 and sub-arrays for the solution vector 'u' and the solution
 direction vector 'u dot'.\\
 Other syntax: \commandf{s[0]}, \commandf{s['t']}, \commandf{s['U(1)']}.
  \smallskip \end{minipage} \\
 \hline
 BR & \begin{minipage}{4in} \smallskip The number of the branch to which the solution belongs. \smallskip \end{minipage} \\ 
 \hline
 IPRIV & \begin{minipage}{4in} \smallskip A private field for use by
   toolboxes. \smallskip \end{minipage} \\ 
 \hline
 IPS & \begin{minipage}{4in} \smallskip The user-specified problem type.  See Section~\ref{sec:IPS}. \smallskip \end{minipage} \\ 
 \hline
 ISW & \begin{minipage}{4in} \smallskip  The ISW value used to start the calculation.  See Section~\ref{sec:ISW}. \smallskip \end{minipage} \\ 
 \hline
 LAB & \begin{minipage}{4in} \smallskip The label of the solution.   \smallskip \end{minipage} \\ 
 \hline
 NCOL & \begin{minipage}{4in} \smallskip The number of collocation points used to compute the solution.  See Section~\ref{sec:NCOL}. \smallskip \end{minipage} \\ 
 \hline
 NDIM & \begin{minipage}{4in} \smallskip The user-specified number of dimensions. See Section~\ref{sec:NDIM}. \smallskip \end{minipage} \\ 
 \hline
 NTST & \begin{minipage}{4in} \smallskip The number of mesh intervals used to compute the solution.  See Section~\ref{sec:NTST}. \smallskip \end{minipage} \\ 
 \hline
 Parameters & \begin{minipage}{4in} \smallskip The value of all of the parameters for the solution. \smallskip \end{minipage} \\ 
 parameters & \begin{minipage}{4in} \smallskip 'p' and 'parameters' are aliases.\end{minipage} \\ 
 p & \begin{minipage}{4in} \smallskip Other syntax: \commandf{s.PAR(1)}, \commandf{s['PAR(1)']} \smallskip \end{minipage} \\ 
 \hline
 PT & \begin{minipage}{4in} \smallskip The number of the point in the given branch.  \smallskip \end{minipage} \\  
 \hline
 TY & \begin{minipage}{4in} \smallskip A short string which describes the type of the solution (see Table~\ref{tbl:clui type translation}). \smallskip \end{minipage} \\  
 \hline
 TY number & \begin{minipage}{4in} \smallskip A number which describes the type of the solution (see Table~\ref{tbl:clui type translation}).  \smallskip \end{minipage} \\  
 \hline
 Active ICP & \begin{minipage}{4in} \smallskip
 The values of the (one-based) indices of the free parameters.
 \smallskip \end{minipage} \\  
 \hline
 rldot & \begin{minipage}{4in} \smallskip The values
 of the parameter direction vector.\smallskip \end{minipage} \\  
 \hline
 \end{tabular}
 \caption[Contents of a solution object.]
 {This table shows the strings that can be used to
 query a solution object and their
 meanings.}
 \label{tbl:clui parse solution}
 \end{center}
 \end{table}

 The individual elements of the list may, again, be accessed 
 in two ways, either by the index of the solution using the
 \commandf{[]} syntax or by label number or type name using the
 \commandf{()} syntax.  For example, assume that the parsed object is contained
 in a variable \commandf{s=data()}.
 The first solution may be accessed 
 using the command \commandf{s[0]}, while the solution with
 label \commandf{57} may be accessed using the command \commandf{s(57)}.

 Individual solutions can be also be obtained directly from the
 bifurcation diagram object \commandf{data} in the same way as for
 individual points above, by using \commandf{s=data(label)}.
 For example, the solution with label \commandf{57} may be accessed
 using the command
 \commandf{data(57)}, and the second Hopf bifurcation solution using
 the command \commandf{data('HB2')}.
 All individual solutions can then be used as a starting point for a new run.

 Similarly, using the \commandf{()} syntax you can also obtain new lists of
 solutions: \commandf{data('HB')} gives a list of all Hopf bifurcation
 solutions, \commandf{data([1,4])} gives the solutions with labels 1 and 4,
 and \commandf{data(['UZ',4])} gives all user defined solutions and
 label 4. A for loop can then iterate through the list and provide new
 starting solutions.

 Solutions can be deleted using the commands \commandf{dlb},
 \commandf{dsp}, \commandf{klb}, and \commandf{ksp}, described in
 the reference, Section~\ref{sec:clui_ref_filemaint}. The command
 \commandf{relabel}, as described before, gives each solution a unique
 label starting at 1. Finally, you can change individual solution
 labels using the \commandf{relabel} \emph{method}:
 \commandf{data.relabel(9, 57)} relabels label 9 to label 57, making
 sure that the label changes both in the bifurcation diagram and in
 the solution.

 \subsection{Summary and reference}
 We have defined the following objects:
 \begin{description}
   \item[Bifurcation diagram object]:
    \commandf{bd=run(...)}, \commandf{bd=loadbd(...)}.
   \item[Branch]:
    \commandf{bd[0], bd[1], bd[2], ...}.
   \item[Branch AUTO constants]:
    \commandf{bd[0].c, bd[1].c, bd[2].c, ...}.\\
    \commandf{bd.c} refers to \commandf{bd[0].c}.
   \item[Branch column]:
    \commandf{bd['PAR(1')], bd[0]['PAR(1)'], bd[1]['L2-NORM'], ...}.\\
    Here \commandf{bd['PAR(1)']} is a shortcut for \commandf{bd[0]['PAR(1)']}.
   \item[Point]:
    \commandf{bd[0][0], bd[1](5), bd[1]('UZ1'), bd(1).b, bd('UZ1').b, ...}.
   \item[Point list]:
    \commandf{bd[0]('UZ'), bd[0]([1,2]), bd[0](['UZ','HB1',7]), ...}.
   \item[Solution]:
    \commandf{bd(5), bd('UZ1'), bd()[0], ...}.
   \item[Solution list]:
    \commandf{s=bd(), s('UZ'), bd('UZ'), bd([1,2]), bd(['UZ','HB1',7]), ...}.
   \item[Solution column]:
    \commandf{bd('UZ1')['t'], bd('UZ1')['U(1)'], ...}.
   \item[Solution measures]:
    \commandf{bd('UZ1')['L2-NORM'], ...}.\\
    This example is a shortcut for \commandf{bd('UZ1').b['L2-NORM']}: here you
    can use any column name from the bifurcation diagram.
   \item[Solution point]:
    \commandf{bd('UZ1')(0), bd('UZ1')[0], ...}.\\
    Here the \commandf{bd('UZ1')(t)} notation gives the point at
    time \commandf{t}.
   \item[Solution AUTO constants]:
    \commandf{bd(5).c, bd('UZ1').c, bd()[0].c, ...}.\\
    These constants are copied from the corresponding branch
    constants, removing the constants \parf{IRS}, \parf{PAR}, \parf{U},
    \parf{sv}, \parf{s}, and \parf{dat}, because those constants need
    to change between runs. The AUTO constant
    \parf{IRS} is automatically set to the solution label.
 \end{description}

 \section{ Importing data from Python or external tools.} \label{sec:clui_importing}
 A solution can be created from a Python list or Numerical Python
 array using the \commandf{load} command. The syntax is slightly
 different depending on whether you create a point or an orbit.

 Use \commandf{ s = load(u,PAR=p)} where \commandf{u} is a Python list
 or a numpy array representing a solution. For a point
 such an array is just the point itself, for example,
 \commandf{u = [x, y, z]} or
 \commandf{u = [0, 0, 0]}. For an orbit such an array must be given
 column-wise, as \commandf{u = [[t0, ..., tn], [x0, ..., xn], [y0,
   ..., yn], ...]}.
 The \commandf{PAR=p} keyword argument takes a dictionary \commandf{p}
 as described in Section~\ref{sec:PAR}, for instance, \commandf{PAR=\{1:5.0,
 2:0.0\}} to set \parf{PAR(1)=5.0} and \parf{PAR(2)=0.0}.

 You can check your new solution using the command \commandf{print s}.

 An external orbit from an ASCII file can be directly imported by
 AUTO via the \parf{dat} AUTO constant, see Section~\ref{sec:dat}.

 \section{ Exporting output data for use by Python or external
   visualization tools.} \label{sec:clui_exporting}

 The bifurcation and solution file classes have three methods that are 
 particularily useful for creating data which can be used in other
 programs.  First, there is a method called \commandf{toArray} which
 takes a bifurcation diagram or solution and
 returns a Python array (a list of lists). Second, the method
 \commandf{toarray} returns a Numerical Python (numpy) array,
 which works for
 branches, points and solutions (but not for lists of branches).
 Third, there is a method called
 \commandf{writeRawFilename} which will create a standard ASCII file
 which contains the bifurcation diagram or the solution. 
 In the solution ASCII file, the first element of each row will be
 the 't' value and the following elements will be the
 values of the components at that 't' value. Such ASCII files
 can be readily parsed and plotted by external tools such as
 Gnuplot and MATLAB.

 For example, we assume
 that a bifurcation diagram object is contained in a variable
 \commandf{bd}, for instance, using \commandf{bd=loadbd('ab')}.  If
 one wanted to have the bifurcation diagram returned as a Python list
 one would type \commandf{bd.toArray()}.  Similarily, if one wanted
 to write out the bifurcation diagram to the file \commandf{outputfile}
 one would type \commandf{bd.writeRawFilename('outputfile')}.

 To get the solution with label \commandf{57} returned as a numpy
 array one would type \commandf{bd(57).toarray()}.
 Similarily, if one wanted to write out the solution
 to the file \commandf{outputfile} one would type
 \commandf{bd(57).writeRawFilename('outputfile')}.

 \section{ The \filef{.autorc} or \filef{autorc} File }

 Much of the default behavior of the \AUTO CLUI
 can be controlled by the \filef{.autorc} file.
 The \filef{.autorc} file can exist in
 either the main \AUTO directory, the users
 home directory, or the current directory. In the current directory
 it can also have the name \filef{autorc}, that is, without the dot.
 For any
 option which is defined in more then one file, 
 the \filef{.autorc} file
 in the current directory (if it exists) takes precedence, 
 followed by the \filef{.autorc} file
 in the users home directory (if it exists), and then the
 \filef{.autorc} file in the main \AUTO directory.  Hence, 
 options may be defined on either a per directory, per
 user, or global basis.  

 The first section of the \filef{.autorc} file
 begins with the line \commandf{[AUTO\_command\_aliases]}
 and this section defines short names, or aliases,
 for the \AUTO CLUI commands.  
 Each line thereafter is a definition of
 a command, similiar to 
 \commandf{branchPoint     =commandQueryBranchPoint}.
 The right hand side of the assignment
 is the internal \AUTO CLUI name for the command,
 while the left hand side is the desired alias.  
 Aliases and
 internal names may be used interchangably, but the
 intention is that the aliases will be more commonly
 used.  A default set of aliases is provided, and
 these aliases will be used in the examples in the
 rest of this Chapter.  The default aliases
 are listed in the reference in Section~\ref{sec:clui reference}.

 %FIXME:  Fix the documentation here
 {\em NOTE:  Defaults for the plotting tool may be included in
 the .autorc file as well.}

 \section{ Plotting Tool}\label{clui:plotting}

 The plotting tool can be run by using the command
 \commandf{plot(bd)} to plot a bifurcation diagram object \parf{bd}
 after a calculation has been run, or using the command
 \commandf{plot()} to plot the files \filef{fort.7} and \filef{fort.8},
 or using the command \commandf{plot('foo')} to plote the data in the
 files \filef{s.foo} and \filef{b.foo}.  

 The menu bar provides two buttons.  The \commandf{File}
 button brings up a menu which allows the user to save
 the current plot as a Postscript file or
 to quit the plotting tool.
 The \commandf{Options} button allows the plotter
 configuration options to be modified.
 The available options are decribed in
 Table~\ref{tbl:clui plotter specific options}.  In addition, the options can 
 be set and figures can be saved from within the CLUI.  For example,
 the set of commands in Figure~\ref{exa:plotter_example} shows how to
 create a plot, change its background color to black, and save it.  The
 demo script \filef{auto/07p/demo/python/plotter.py} contains several
 examples of changing options in plotters. 
 The special argument 
 \commandf{hide=True} to \commandf{plot} does not produce an on-screen
 plot, which is useful for quick automatic generation of saved figure files.

 If you are using matplotlib, then you will find seven icons that allow
 you to use various zoom functions: a home button to go back to the
 original plot, back and forward buttons to go back and forwards
 between zooms, a button to select pan/zoom mode, a button to select
 rectangular zoom mode, a button to which brings up sliders that
 adjust margins, and a floppy disk button that you can use
 to save the plot to a file. 
 In ``zoom to rect'' mode, the left mouse button may be held down to create
 a box in the plot.  When the left button is released the plot will
 zoom to the selected portion of the diagram. Similarly, the right
 mouse button can be used to zoom out. In ``pan/zoom'' mode, dragging
 with the left mouse button pressed pans (shifts) the graph, whereas
 dragging with the right mouse button zooms in and out.

 If you are \emph{not} using matplotlib, then
 pressing the right mouse button in the plotting window brings
 up a menu of buttons which control several aspects
 of the plotting window.  The top two toggle buttons
 control what function the left button performs.  
 The \commandf{print value} button causes the
 left button to print out the numerical value underneath
 the pointer when it is clicked.
 When \commandf{zoom} button is checked the left
 mouse button may be held down to create
 a box in the plot.  When the left button
 is released the plot will zoom to the selected
 portion of the diagram.
 The \commandf{unzoom} button returns the
 diagram to the default zoom. 
 The \commandf{Postscript} button allows the user
 to save the plot as a Postscript file.
 The \commandf{Configure...} button brings up
 the dialog for setting configuration options.

 \begin{figure}[htbp]
 {\small \begin{center} \begin{boxedverbatim} 
 AUTO> p=plot()
 Created plot
 AUTO> p.config(bg="black")
 AUTO> p.savefig("black.eps")
 AUTO> p=plot(hide=True)
 Created plot
 AUTO> p.savefig("white.eps")
 \end{boxedverbatim}
 \end{center} 
 }
 \caption[Configuring a plotter.]
 {This example shows how a plotter is created,
 how the background color may be changed to black,
 how a figure is saved, and how an invisible plot is
 saved to a file.
 All other configuration options are set similarily.
 Note, the above commands assume that the files
 fort.7 and fort.8 exist in the current directory.
 }
 \label{exa:plotter_example}
 \end{figure}

 \begin{longtable}{| l | l |}
 \hline
 Query string & Meaning \\
 \hline
 1\_1\_resonance\_symbol & The symbol to use for 1:1 resonance points. \\
 \hline
 1\_2\_resonance\_symbol & The symbol to use for 1:2 resonance points. \\
 \hline
 1\_3\_resonance\_symbol & The symbol to use for 1:3 resonance points. \\
 \hline
 1\_4\_resonance\_symbol & The symbol to use for 1:4 resonance points. \\
 \hline
 azimuth  &  Azimuth of the axes in 3D plots. \\
 \hline
 background  &  The background color of the plot. \\
 \hline
 bifurcation\_column\_defaults  & A set of bifurcation columns the user is likely to use. \\
 \hline
 bifurcation\_coordnames & Names to use instead of PAR(1),... for bifurcation diagrams. \\
 \hline
 bifurcation\_diagram  &  A parsed bifurcation diagram file to plot. \\
 \hline
 bifurcation\_diagram\_filename  & The filename of the bifurcation diagram to plot. \\
 \hline
 bifurcation\_symbol  &  The symbol to use for bifurcation points. \\ 
 \hline
 bifurcation\_x  & The column to plot along the X-axis for bifurcation diagrams. \\
 \hline
 bifurcation\_y  & The column to plot along the Y-axis for bifurcation diagrams. \\
 \hline
 bifurcation\_z  & The column to plot along the Z-axis for bifurcation diagrams. \\
 \hline
 bogdanov\_takens\_symbol & The symbol to use for Bogdanov-Takens points. \\
 \hline
 bottom\_margin  & The margin between the graph and the bottom edge. \\
 \hline
 color\_list  &  A list of colors to use for multiple plots. \\
 \hline
 coloring\_method  & color\_list index: 'branch' (BR), 'type' (TY), or 'curve' (seq.). \\
 \hline
 cusp\_symbol & The symbol to use for Cusp points. \\
 \hline
 d0, d1, d2, d3, d4 & Redefine d0, d1, d2, etc. setting to use with
 {\cal PyPLAUT} (\commandf{@pp}). \\
 \hline
 dashes  &    List of dash, no-dash lengths for dashed lines. \\ 
 \hline
 decorations  & Turn on or off the axis, tick marks, etc. \\
 \hline
 default\_option & Default d0, d1, d2, etc. setting to use with {\cal
   PyPLAUT} (\commandf{@pp}). \\
 \hline
 elevation &  Elevation of the axes in 3D plots. \\
 \hline
 error\_symbol  &    The symbol to use for error points. \\ 
 \hline
 even\_tick\_length  & The length of the even tick marks. \\
 \hline
 flip\_torus\_symbol & The symbol to use for flip-torus points. \\
 \hline
 fold\_flip\_symbol & The symbol to use for fold-flip points. \\
 \hline
 fold\_torus\_symbol & The symbol to use for fold-torus points. \\
 \hline
 foreground  &  The background color of the plot. \\
 \hline
 generalized\_hopf\_symbol & The symbol to use for Generalized Hopf points. \\
 \hline
 grid  &  Turn on or off the grid. \\
 \hline
 height  & Height of the graph. \\
 \hline
 hopf\_symbol  &    The symbol to use for Hopf bifurcation points. \\ 
 \hline
 index  & An array of indices to plot.\\
 \hline
 label  & An array of labels to plot, or 'all' for all labels.\\
 \hline
 labelnames  & A dictionary mapping names in \filef{fort.7} to axis labels.\\
 \hline
 label\_defaults  & A set of labels that the user is likely to use. \\
 \hline
 left\_margin  & The margin between the graph and the left edge. \\
 \hline
 letter\_symbols  & Whether to use letter (True) or symbols (False) for special points. \\
 \hline
 limit\_point\_symbol  &    The symbol to use for limit points. \\ 
 \hline
 line\_width & Width to use for lines and curves. \\
 \hline
 mark\_t  &  The t value to marker with a small ball. \\      
 \hline
 maxx  & The upper bound for the x-axis of the plot. \\
 \hline
 maxy  & The upper bound for the y-axis of the plot. \\
 \hline
 maxz  & The upper bound for the z-axis of the plot. \\
 \hline
 minx  &  The lower bound for the x-axis of the plot. \\
 \hline
 miny  & The lower bound for the y-axis of the plot. \\
 \hline
 minz  & The lower bound for the z-axis of the plot. \\
 \hline
 odd\_tick\_length  & The length of the odd tick marks. \\
 \hline
 period\_doubling\_symbol  &   The symbol to use for period doubling bifurcation points. \\ 
 \hline
 ps\_colormode  & The PostScript output mode: 'color', 'gray' or 'monochrome'. \\ 
 \hline
 right\_margin  & The margin between the graph and the left edge. \\
 \hline
 runner  &  The runner object from which to get data. \\       
 \hline
 smart\_label  & Whether to use a smart but slower label placement algorithm. \\ 
 \hline
 special\_point\_colors  &    An array of colors used to mark special points. \\ 
 \hline
 special\_point\_radius  &    The radius of the spheres used to mark special points. \\ 
 \hline
 solution  &  A parsed solution file to plot. \\
 \hline
 solution\_column\_defaults  & A set of solution columns the user is likely to use.\\
 \hline
 solution\_coordnames & Variable names to use instead of U(1),... for solutions. \\
 \hline
 solution\_filename  & The filename of the solution to plot. \\
 \hline
 solution\_indepvarname & Variable name to use instead of 't' for solutions. \\
 \hline
 solution\_x  &  The column to plot along the X-axis for solutions. \\
 \hline
 solution\_y  & The column to plot along the Y-axis for solutions. \\
 \hline
 solution\_z  & The column to plot along the Z-axis for solutions. \\
 \hline
 stability  & Turn on or off stability information using dashed curves. \\
 \hline
 symbol\_font  &  The font to use for marker symbols. \\
 \hline
 symbol\_color  & The color to use for the marker symbols. \\
 \hline
 tick\_label\_template  & A string which defines the format of the tick labels. \\
 \hline
 tick\_length  &  The length of the tick marks. \\
 \hline
 top\_margin  & The margin between the graph and the top edge. \\
 \hline
 top\_title  &    The label for the top title. \\ 
 \hline
 top\_title\_fontsize  & The font size for the top title. \\ 
 \hline
 torus\_symbol  &    The symbol to use for torus bifurcation points. \\ 
 \hline
 torus\_torus\_symbol & The symbol to use for torus-torus points. \\
 \hline
 type  & The type of the plot, either ``solution'' or ``bifurcation''. \\  
 \hline
 use\_labels &   Whether or not to display label numbers in the graph. \\ 
 \hline
 use\_symbols  & Whether or not to display bifurcation symbols in the graph. \\
 \hline
 user\_point\_symbol  &   The symbol to use for user defined output points. \\ 
 \hline
 width  & Width of the graph. \\
 \hline
 xlabel  & The label for the x-axis. \\
 \hline
 xlabel\_fontsize  & The font size for the x-axis label. \\
 \hline
 xticks  & The number of ticks on the x-axis. \\
 \hline
 ylabel  & The label for the y-axis. \\
 \hline
 ylabel\_fontsize  & The font size for the y-axis label. \\
 \hline
 yticks  & The number of ticks on the y-axis. \\
 \hline
 zero\_hopf\_symbol & The symbol to use for zero-Hopf points. \\
 \hline
 zlabel  & The label for the z-axis. \\
 \hline
 zlabel\_fontsize  & The font size for the z-axis label. \\
 \hline
 zticks  & The number of ticks on the z-axis. \\
 \hline
 \caption[The options for the PyPLAUT plotting window.]
 {This table shows the options that
 can be set for the PyPLAUT plotting window and their meanings.}
 \label{tbl:clui plotter specific options}
 \end{longtable}

 \section{ The Plotting Tool PLAUT04}

 The \AUTO plotting tool {\cal PLAUT04} as described
 in Chapter~\ref{ch:PLAUT04}, can be run from the Python CLUI
 using the command
 \commandf{plot3} or \commandf{commandPlotter3D}, in a similar
 fashion to \commandf{plot}. It does not use the options that
 are used for the plotting window produced by \commandf{plot}.

 \section{ Quick Reference } \label{sec:clui quick reference}

 In this section we have created a table of all of the \AUTO CLUI
 commands, their abbreviations, and a one line description of what
 function they perform.  Each command may be entered using 
 its full name or any of its aliases.

\begin{longtable}{|p{1.1in}|l|p{2.5in}|}
\hline 
Command, Aliases & Long name & Description\\ \hline 
append ap & commandAppend & Append data files.\\ \hline 
cat & commandCat & Print the contents of a file\\ \hline 
cd & commandCd & Change directories.\\ \hline 
clean cl & commandClean & Clean the current directory.\\ \hline 
demo dm & commandCopyAndLoadDemo & Copy a demo into the current directory and load it.\\ \hline 
copy cp & commandCopyDataFiles & Copy data files.\\ \hline 
copydemo & commandCopyDemo & Copy a demo into the current directory.\\ \hline 
save sv & commandCopyFortFiles & Save data files.\\ \hline 
gui & commandCreateGUI & Show AUTOs graphical user interface.\\ \hline 
delete, dl & commandDeleteDataFiles & Delete data files.\\ \hline 
df deletefort & commandDeleteFortFiles & Clear the current directory of fort files.\\ \hline 
dlb & commandDeleteLabels & Delete special labels.\\ \hline 
dsp & commandDeleteSpecialPoints & Delete special points.\\ \hline 
double & commandDouble & Double a solution.\\ \hline 
man & commandInteractiveHelp & Get help on the AUTO commands.\\ \hline 
klb & commandKeepLabels & Keep special labels.\\ \hline 
ksp & commandKeepSpecialPoints & Keep special points.\\ \hline 
ls & commandLs & List the current directory.\\ \hline 
merge mb & commandMergeBranches & Merge branches in data files. \\ \hline
move mv & commandMoveFiles & Move data-files to a new name.\\ \hline 
cn constantsget & commandParseConstantsFile & Get the current continuation constants.\\ \hline 
bt diagramandsolutionget & commandParseDiagramAndSolutionFile & Parse both bifurcation diagram and solution.\\ \hline 
dg diagramget & commandParseDiagramFile & Parse a bifurcation diagram.\\ \hline 
sl solutionget & commandParseSolutionFile & Parse solution file:\\ \hline 
plot p2 pl & commandPlotter & plotting of data.\\ \hline 
plot3 p3 & commandPlotter3D & PLAUT04 plotting of data.\\ \hline 
branchpoint br bp & commandQueryBranchPoint & Print the ``branch-point function''.\\ \hline 
eigenvalue ev eg & commandQueryEigenvalue & Print eigenvalues of Jacobian (algebraic case).\\ \hline 
floquet fl & commandQueryFloquet & Print the Floquet multipliers.\\ \hline 
hopf hb hp & commandQueryHopf & Print the value of the ``Hopf function''.\\ \hline 
iterations it & commandQueryIterations & Print the number of Newton interations.\\ \hline 
limitpoint lm lp & commandQueryLimitpoint & Print the value of the ``limit point function''.\\ \hline 
note nt & commandQueryNote & Print notes in info file.\\ \hline 
secondaryperiod sc sp & commandQuerySecondaryPeriod & Print value of ``secondary-periodic bif. fcn''.\\ \hline 
stepsize ss st & commandQueryStepsize & Print continuation step sizes.\\ \hline 
quit q & commandQuit & Quit the AUTO CLUI.\\ \hline 
relabel rl & commandRelabel & Relabel data files.\\ \hline
run r rn & commandRun & Run AUTO.\\ \hline 
ch changeconstant cc & commandRunnerConfigFort2 & Modify continuation constants.\\ \hline 
hch & commandRunnerConfigFort12 & Modify HomCont continuation constants.\\ \hline 
load ld & commandRunnerLoadName & Load files into the AUTO runner.\\ \hline 
printconstant pc pr & commandRunnerPrintFort2 & Print continuation parameters.\\ \hline 
hpr & commandRunnerPrintFort12 & Print HomCont continuation parameters.\\ \hline 
shell & commandShell & Run a shell command.\\ \hline 
splabs & commandSpecialPointLabels & Return special labels.\\ \hline
subtract sb & commandSubtractBranches & Subtract branches in data files.\\ \hline
triple tr & commandTriple & Triple a solution.\\ \hline 
us userdata & commandUserData & Covert user-supplied data files.\\ \hline 
wait & commandWait & Wait for the user to enter a key.\\ \hline 
auto execfile ex & & Execute an AUTO CLUI script.\\ \hline
demofile dmf & & Execute an AUTO CLUI script, line by line (demo
mode). \\ \hline
\end{longtable}
For convenience, you can use ``!'' to run a shell command. Moreover
the common shell commands \commandf{clear}, \commandf{less},
\commandf{mkdir}, \commandf{rmdir},
\commandf{cp}, \commandf{mv}, \commandf{rm}, \commandf{ls},
\commandf{cd}, and \commandf{cat}, and all \AUTO Unix commands that are described
in Chapter~\ref{sec:command_mode} and start with an ``@''-sign can be
entered directly, without the ``!''.
\pagebreak
\section{ Reference }  \label{sec:clui reference}
\subsection{Basic commands.} \label{sec:clui_ref_basic}
\begin{description}
\item[run]
Run \AUTO.

    Type \commandf{r=run([data],[options])} to run \AUTO from solution data with the given
    \AUTO constants or file keyword options.
    
    The results are stored in the bifurcation diagram r which you can
    later print with \commandf{print r}, obtain branches from via r[0], r[1], ...,
    and obtain solutions from via r(3), r(5), r('LP2'), where 3 and 5
    are label numbers, and 'LP2' refers to the second LP label.

    \commandf{run(data)} runs \AUTO in the following way for different types of \parf{data}:
    \begin{itemize}
    \item
      A solution: \AUTO starts from solution \parf{data}, with \AUTO constants \parf{data.c}.
    \item
      A bifurcation diagram: \AUTO start from the solution specified by
      the \AUTO constant \parf{IRS}, or if \parf{IRS} is not specified, the last solution
      in \parf{data}, \parf{data()[-1]}, with \AUTO constants \parf{data()[-1].c}.
    \item
      A string: \AUTO uses the solution in the file \filef{s.data} together with the
      constants in the files \filef{c.data}, and \filef{h.data}. Not all of these
      files need to be present.
    \end{itemize}

    If no solution \parf{data} is specified, then the global values from the
    \commandf{load} command (below) are used instead, where
    options which are not explicitly set retain their previous value.

    Keyword argument options can be \AUTO constants, such as \parf{DS=0.05},
    or \parf{ISW=-1}, or specify a constant or solution file. These override
    the constants in \filef{s.c}, where applicable. See \commandf{load}:\\
    \commandf{run(s,options)} is equivalent to \commandf{run(load(s,options))}

    Example: given a bifurcation diagram bd, with a branch point
    solution, switch branches and stop at the first Hopf bifurcation:\\
    \commandf{hb = run(bd('BP1'),ISW=-1,STOP='HB1')}
    
    Special keyword arguments are \parf{sv} and \parf{ap}; \parf{sv} is also an \AUTO
    constant:\\
    \commandf{run(bd('BP1'),ISW=-1,STOP='HB1',sv='hb',ap='all')}\\
    saves to the files \filef{b.hb}, \filef{s.hb} and \filef{d.hb},
    and appends to \filef{b.all}, \filef{s.all}, and \filef{d.all}.

    \textbf{Aliases:} r rn commandRun

\item[load]
Load files into the \AUTO runner or return modified solution data.

    Type \commandf{result=load([options])} to modify the \AUTO runner.\\
    Type \commandf{result=load(data,[options])} to return possibly
    modified solution data.\\

    The type of the result is a solution object.

    \commandf{load(data,[options])} returns a solution in the following way for
    different types of data:
    \begin{itemize}
    \item
      A solution: load returns the solution data, with \AUTO constants
      modified by options.
    \item
      A bifurcation diagram or a solution list:
      returns the solution specified by
      the \AUTO constant \parf{IRS}, or if \parf{IRS} is not specified, the last solution
      in \parf{s}.
    \item
      A string: \AUTO uses the solution in the file 's.s' together with the
      constants in the files 'c.s', and 'h.s'. Not all of these
      files need to be present.
    \item
      A Python list array or a numpy array representing a solution,
      returns a solution with the given contents. Such an array must be given
      column-wise, as [[t0, ..., tn], [x0, ..., xn], [y0, ..., yn],
      ...], or for a point solution as [x, y, z, ...].
    \end{itemize}

    There are many possible options:
    \begin{verbatim}
    Long name   Short name    Description
    -------------------------------------------
    equation    e             The equations file
    constants   c             The AUTO constants file
    homcont     h             The Homcont parameter file
    solution    s             The restart solution file
                NDIM,IPS,etc  AUTO constants.
                BR,PT,TY,LAB  Solution constants.
    \end{verbatim}
    If data is not specified or data is a string then options which
    are not explicitly set retain their previous value.
    For example one may type: \commandf{s=load(e='ab',c='ab.1')} to
    use \filef{ab.f90}, \filef{ab.f}, or \filef{ab.c} as
    the equations file and \filef{c.ab.1} as the constants file.

    Type \commandf{s=load('name')} to load all files with base 'name'.
    This does the same thing as running
    \commandf{s=load(e='name',c='name,h='name',s='name')}.
 
    You can also specify \AUTO Constants, e.g., \parf{DS=0.05}, or \parf{IRS=2}.
    Special values for \parf{DS} are \parf{'+'} (forwards) and \parf{'-'} (backwards).\\
    Example: \commandf{s = load(s,DS='-')} changes \parf{s.c['DS']} to \parf{-s.c['DS']}.

    \textbf{Aliases:} ld commandRunnerLoadName

\item[loadbd]
    Load bifurcation diagram files.

    Type \commandf{b=loadbd([options])} to load output files or output data.
    There are three possible options:
    \begin{verbatim}
    Long name   Short name    Description
    -------------------------------------------
    bifurcationdiagram   b    The bifurcation diagram file
    solution    s             The solution file or list of solutions
    diagnostics d             The diagnostics file
    \end{verbatim}

    Type \commandf{loadbd('name')} to load all files with base 'name'.
    This does the same thing as running\\
    \commandf{loadbd(b='name',s='name,d='name')}.\\
    \commandf{plot(b)} will then plot the 'b' and 's' components.

    Returns a bifurcation diagram object representing the files in b.

    \textbf{Aliases:} bd commandParseOutputFiles

\item[save]
Save data files.

    Type \commandf{save(x,'xxx')} to save bifurcation diagram \parf{x}
    to the files \filef{b.xxx}, \filef{s.xxx}, \filef{d.xxx}. 
    Existing files with these names will be overwritten.
    If \parf{x} is a solution, a list of solutions, or does not contain any
    bifurcation diagram or diagnostics data, then only the file \filef{s.xxx}
    is saved to.

    Type \commandf{save('xxx')} to save the output-files \filef{fort.7},
    \filef{fort.8}, \filef{fort.9}, to \filef{b.xxx}, \filef{s.xxx},
    \filef{d.xxx}. Existing files with these names will be overwritten.

\textbf{Aliases:} commandCopyFortFiles

\item[append]

Append data files.

    Type \commandf{append(x,'xxx')} to append bifurcation diagram x
    to the data-files \filef{b.xxx}, \filef{s.xxx}, and \filef{d.xxx}. This is equivalent to
    the command\\
    \commandf{save(x+load('xxx'),'xxx')}

    Type \commandf{append('xxx',xxx)} to append existing data-files \filef{s.xxx}, \filef{b.xxx},
    and \filef{d.xxx} to bifurcation diagram x. This is equivalent to
    the command\\
    \commandf{x=load('xxx')+x}

    Type \commandf{append('xxx')} to append the output-files \filef{fort.7}, \filef{fort.8},
    \filef{fort.9}, to existing data-files \filef{s.xxx}, \filef{b.xxx}, and \filef{d.xxx}.

    Type \commandf{append('xxx','yyy')} to append existing data-files \filef{s.xxx}, \filef{b.xxx},
    and \filef{d.xxx} to data-files \filef{s.yyy}, \filef{b.yyy}, and
    \filef{d.yyy}.

    \textbf{Aliases:} ap commandAppend
\end{description}

\subsection{Plotting commands.} \label{sec:clui_ref_plot}

\begin{description}
\item[plot]
Plotting of data.

    Type \commandf{plot(x)} to run the graphics program PyPLAUT for the graphical
    inspection of bifurcation diagram or solution data in x.

    Type \commandf{plot('xxx')} to run the graphics program PyPLAUT for the graphical
    inspection of the data-files \filef{b.xxx} and \filef{s.xxx}.

    Type \commandf{plot()} to run the graphics program for the graphical
    inspection of the output-files \filef{fort.7} and \filef{fort.8}.

    Values also present in the file \filef{autorc}, such as
    \commandf{color\_list = "black green red blue orange"} can be provided as
    keyword arguments, as well as \commandf{hide=True} which hides the
    on-screen plot.

    The return value, for instance, \commandf{p} for
    \commandf{p=plot(x)} will be the handle for the graphics window.
    It has p.config() and p.savefig() methods that allow you to configure
    and save the plot. When plotting, see \commandf{help(p.config)}
    and \commandf{help(p.savefig)} for details.

\textbf{Aliases:} p2 pl commandPlotter

\item[plot3]
Plotting of data using PLAUT04.

    Type \commandf{plot3(x)} to run the graphics program PLAUT04 for the graphical
    inspection of bifurcation diagram or solution data in x.

    Type \commandf{plot3('xxx')} to run the graphics program PLAUT04 for the graphical
    inspection of the data-files \filef{b.xxx} and \filef{s.xxx}.

    Type \commandf{plot3()} to run the graphics program PLAUT04 for the graphical
    inspection of the output-files \filef{fort.7} and \filef{fort.8}.

    Type \commandf{plot3(...,r3b=True)} to run PLAUT04 in restricted three body
    problem mode.
    
\textbf{Aliases:} p3 commandPlotter3D
\end{description}

\subsection{File-manipulation.} \label{sec:clui_ref_files}
\begin{description}
\item[copy]
Copy data files.

    Type \commandf{copy(name1, name2)}, or \commandf{copy(name1,
      name2, name3)}, or  \commandf{copy(name1, name2, name3, name4)} to
    copy the data-files \filef{dir1/c.xxx}, \filef{dir1/b.xxx},
    \filef{dir1/s.xxx}, and \filef{dir1/d.xxx}, to \filef{dir2/c.yyy},
    \filef{dir2/b.yyy}, \filef{dir2/s.yyy}, and \filef{dir2/d.yyy}.

    Type \commandf{copy('xxx','yyy')} to copy the data-files \filef{c.xxx},
    \filef{d.xxx}, \filef{b.xxx}, and \filef{h.xxx} to \filef{c.yyy},
    \filef{d.yyy}, \filef{b.yyy}, and \filef{h.yyy}.
    
    The values of \filef{dir1/?.xxx} and \filef{dir2/?.yyy} are as
    follows, depending on whether \filef{name1} is a directory or
    \filef{name2} is a directory:

    \commandf{copy(name1, name2)}\\
    no directory names: \filef{./?.name1} and \filef{./?.name2}\\
    \filef{name1} is a directory: \filef{name1/?.name2} and \filef{./?.name2}\\
    \filef{name2} is a directory: \filef{./?.name1} and \filef{name2/?.name1}

    \commandf{copy(name1, name2, name3)}\\
    \filef{name1} is a directory: \filef{name1/?.name2} and \filef{./?.name3}\\
    \filef{name2} is a directory: \filef{./?.name1} and \filef{name2/?.name3}

    \commandf{copy(name1, name2, name3, name4)}\\
    \filef{name1/?.name2} and \filef{name3/?.name4}

\textbf{Aliases:} cp commandCopyDataFiles

\item[move]
Move data-files to a new name.

    Type \commandf{move(name1, name2)}, or \commandf{move(name1,
      name2, name3)}, or  \commandf{move(name1, name2, name3, name4)} to
    move the data-files \filef{dir1/b.xxx}, \filef{dir1/s.xxx}, and
    \filef{dir1/d.xxx}, to \filef{dir2/b.yyy}, \filef{dir2/s.yyy}, and
    \filef{dir2/d.yyy}, and copy the constants
    file \filef{dir1/c.xxx} to \filef{dir2/c.yyy}.

    The values of \filef{dir1/?.xxx} and \filef{dir2/?.yyy} are determined
    in the same way as for \commandf{copy} above.

\textbf{Aliases:} mv commandMoveFiles

\item[df]
Clear the current directory of fort files.

    Type \commandf{df()} to clean the current directory.  This command will
    delete all files of the form \filef{fort.*}.
    
\textbf{Aliases:} deletefort commandDeleteFortFiles

\item[clean]
Clean the current directory.

    Type \commandf{clean()} to clean the current directory.  This command will
    delete all files of the form \filef{fort.*}, \filef{*.*\~{}},
    \filef{*.o}, and \filef{*.exe}.
    
\textbf{Aliases:}
cl commandClean

\item[delete]
Delete data files.

    Type \commandf{delete('xxx')} to delete the data-files \filef{d.xxx},
    \filef{b.xxx}, and \filef{s.xxx} (if you are using the default
    filename templates).
    
\textbf{Aliases:} dl commandDeleteDataFiles
\end{description}

\subsection{Diagnostics.} \label{sec:clui_ref_diagnostics}

\begin{description}
\item[limitpoint]
Print the value of the ``limit point function''.

    Type \commandf{limitpoint(x)} to list the value of the ``limit point function'' 
    in the diagnostics of the bifurcation diagram object \parf{x}.
    This function vanishes at a limit point (fold).

    Type \commandf{limitpoint()} to list the value of the ``limit point function'' 
    in the output-file \filef{fort.9}.

    Type \commandf{limitpoint('xxx')} to list the value of the ``limit point function'' 
    in the info file \filef{d.xxx}.
    
\textbf{Aliases:} lm lp commandQueryLimitpoint

\item[branchpoint]
Print the ``branch-point function''.
    
    Type \commandf{branchpoint(x)} to list the value of the ``branch-point function'' 
    in the diagnostics of the bifurcation diagram object \parf{x}.
    This function vanishes at a branch point.

    Type \commandf{branchpoint()} to list the value of the ``branch-point function'' 
    in the output-file \filef{fort.9}.
    
    Type \commandf{branchpoint('xxx')} to list the value of the ``branch-point function''
    in the info file \filef{d.xxx}.
    
\textbf{Aliases:} br bp commandQueryBranchPoint

\item[hopf]
Print the value of the ``Hopf function''.

    Type \commandf{hopf(x)} to list the value of the ``Hopf function'' 
    in the diagnostics of the bifurcation diagram object \parf{x}.
    This function vanishes at a Hopf bifurcation point.

    Type \commandf{hopf()} to list the value of the ``Hopf function'' 
    in the output-file \filef{fort.9}.

    Type \commandf{hopf('xxx')} to list the value of the ``Hopf function''
    in the info file \filef{d.xxx}.
    
\textbf{Aliases:} hb hp commandQueryHopf

\item[secondaryperiod]
Print value of ``secondary-periodic bif. fcn''.

    Type \commandf{secondaryperiod(x)} to list the value of the
    ``secondary-periodic bifurcation function'' 
    in the diagnostics of the bifurcation diagram object \parf{x}.
    This function vanishes at period-doubling and torus bifurcations.

    Type \commandf{secondaryperiod()}  to list the value of the
    ``secondary-periodic bifurcation function'' 
    in the output-file \filef{fort.9}.

    Type \commandf{secondaryperiod('xxx')} to list the value of the
    ``secondary-periodic bifurcation function''
    in the info file \filef{d.xxx}.
    
\textbf{Aliases:} sc sp commandQuerySecondaryPeriod

\item[iterations]
Print the number of Newton interations.

    Type \commandf{iterations(x)} to list the number of Newton iterations per
    continuation step in the diagnostics of the bifurcation diagram
    object \parf{x}.

    Type \commandf{iterations()} to list the number of Newton iterations per
    continuation step in \filef{fort.9}. 

    Type \commandf{iterations('xxx')} to list the number of Newton iterations per
    continuation step in the info file \filef{d.xxx}.
    
\textbf{Aliases:} it commandQueryIterations

\item[note]
Print notes in info file.

    Type \commandf{note(x)} to show any notes 
    in the diagnostics of the bifurcation diagram
    object \parf{x}.

    Type \commandf{note()} to show any notes in the output-file \filef{fort.9}.

    Type \commandf{note('xxx')} to show any notes  in the info file \filef{d.xxx}.
    
\textbf{Aliases:} nt commandQueryNote

\item[stepsize]
Print continuation step sizes.

    Type \commandf{stepsize(x)} to list the continuation step size for each
    continuation step in the diagnostics of the bifurcation diagram
    object \parf{x}.

    Type \commandf{stepsize()} to list the continuation step size for each
    continuation step in  \filef{fort.9}. 

    Type \commandf{stepsize('xxx')} to list the continuation step size for each
    continuation step in the info file \filef{d.xxx}.
    
\textbf{Aliases:} ss st commandQueryStepsize

\item[eigenvalue]
Print eigenvalues of Jacobian (algebraic case).

    Type \commandf{eigenvalue(x)} to list the eigenvalues of the Jacobian 
    in the diagnostics of the bifurcation diagram object \parf{x}.
    (Algebraic problems.)

    Type \commandf{eigenvalue()} to list the eigenvalues of the Jacobian 
    in \filef{fort.9}. 

    Type \commandf{eigenvalue('xxx')} to list the eigenvalues of the Jacobian 
    in the info file \filef{d.xxx}.
    
\textbf{Aliases:} ev eg commandQueryEigenvalue

\item[floquet]
Print the Floquet multipliers.

    Type \commandf{floquet(x)} to list the Floquet multipliers
    in the diagnostics of the bifurcation diagram object \parf{x}.
    (Differential equations.)

    Type \commandf{floquet()} to list the 
    in the output-file \filef{fort.9}. 

    Type \commandf{floquet('xxx')} to list the Floquet multipliers 
    in the info file \filef{d.xxx}.
    
\textbf{Aliases:} fl commandQueryFloquet
\end{description}

\subsection{File-maintenance.} \label{sec:clui_ref_filemaint}

\begin{description}
\item[relabel]
Relabel data files.

    Type \commandf{y=relabel(x)} to return the python object x, with the solution
    labels sequentially relabelled starting at 1, as a new object y.

    Type \commandf{relabel('xxx')} to relabel \filef{s.xxx} and
    \filef{b.xxx}. Backups of the
    original files are saved.

    Type \commandf{relabel('xxx','yyy')} to relabel the existing data-files
    \filef{s.xxx} and \filef{b.xxx} and save then to \filef{s.yyy} and
    \filef{b.yyy}; \filef{d.xxx} is copied to \filef{d.yyy}.

\textbf{Aliases:} rl commandRelabel

\item[double]
Double a solution.

    Type \commandf{double()} to double the solution in \filef{fort.8}.

    Type \commandf{double('xxx')} to double the solution in
    \filef{s.xxx}.
    
\textbf{Aliases:} db commandDouble

\item[triple]
Triple a solution.

    Type \commandf{triple()} to triple the solution in \filef{fort.8}.

    Type \commandf{triple('xxx')} to triple the solution in
    \filef{s.xxx}.
    
\textbf{Aliases:} tr commandTriple

\item[us]
Convert user-supplied data files.

    Type \commandf{us('xxx')} to convert a user-supplied data file 'xxx.dat' to
    \AUTO format. The converted file is called 's.dat'.  The original
    file is left unchanged.  \AUTO automatically sets the period in
    {\tt PAR(11)}.  Other parameter values must be set in 'STPNT'. (When
    necessary, {\tt PAR(11)} may also be redefined there.)  The
    constants-file file 'c.xxx' must be present, as the \AUTO-constants
    'NTST' and 'NCOL' are used to define the new mesh.

    Note: this technique has been obsoleted by the 'dat' \AUTO constant
    in Section~\ref{sec:dat}.
    
\textbf{Aliases:} userdata commandUserData

\item[dlb]
Delete special labels.

    Type \commandf{dlb(x,list)} to delete the special points in list from
    the Python object x, which must be a solution list or a bifurcation diagram.

    Type \commandf{dlb(list,'xxx')} to delete from the data-files 
    \filef{b.xxx} and \filef{s.xxx}.\\
    Type \commandf{dlb(list,'xxx','yyy')} to save to \filef{b.yyy} and
      \filef{s.yyy} instead of \filef{?.xxx}.\\
    Type \commandf{dlb(list)} to delete from \filef{fort.7} and \filef{fort.8}.

    \commandf{list} is a label number or type name code, or a list of those,
    such as 1, or [2, 3], or 'UZ' or ['BP', 'LP'], or it can be None or
    omitted to mean the special points ['BP', 'LP', 'HB', 'PD', 'TR',
    'EP', 'MX']

    Alternatively a boolean user-defined function \commandf{f} that
    takes a solution can be specified for \commandf{list}, such as
\begin{verbatim}
        def f(s):
            return s["PAR(9)"]<0
\end{verbatim}
    where all solutions are deleted that satisfy the given condition, or
\begin{verbatim}
        def f(s1,s2):
            return abs(s1["L2-NORM"] - s2["L2-NORM"]) < 1e-4
\end{verbatim}
    where all solutions are compared with each other and \commandf{s2}
    is deleted if the given condition is satisfied, which causes
    pruning of solutions that are close to each other.

    Type information is kept in the bifurcation diagram for plotting.

\textbf{Alias:} commandDeleteLabels

\item[klb]
Keep special labels.

    Type \commandf{klb(x,list)} to only keep the special points in list in
    the Python object x, which must be a solution list or a bifurcation diagram.

    Type \commandf{klb(list,'xxx')} to keep them in the data-files
    \filef{b.xxx} and \filef{s.xxx}.\\
    Type \commandf{klb(list,'xxx','yyy')} to save to \filef{b.yyy} and
      \filef{s.yyy} instead of \filef{?.xxx}.\\
    Type \commandf{klb(list)} to keep them in \filef{fort.7} and \filef{fort.8}.

    \commandf{list} is a label number or type name code, or a list of those,
    such as 1, or [2, 3], or 'UZ' or ['BP', 'LP'], or it can be None or
    omitted to mean ['BP', 'LP', 'HB', 'PD', 'TR', 'EP', 'MX'], deleting 'UZ' and
    regular points.

    Alternatively a boolean user-defined function \commandf{f} that
    takes a solution can be specified for \commandf{list}, such as
\begin{verbatim}
        def f(s):
            return s["PAR(9)"]<0
\end{verbatim}
    where only solutions are kept that satisfy the given condition.

    Type information is kept in the bifurcation diagram for plotting.

\textbf{Alias:} commandKeepLabels

\item[dsp]
Delete special points.

    Type \commandf{dsp(x,list)} to delete the special points in list from
    the Python object x, which must be a solution list or a bifurcation diagram.

    Type \commandf{dsp(list,'xxx')} to delete from the data-files
    \filef{b.xxx}, and \filef{s.xxx}.\\
    Type \commandf{dsp(list,'xxx','yyy')} to save to \filef{b.yyy} and
    \filef{s.yyy} instead of \filef{?.xxx}.\\
    Type \commandf{dsp(list)} to delete from \filef{fort.7} and \filef{fort.8}.

    \commandf{list} is a label number or type name code, or a list of those,
    such as 1, or [2, 3], or 'UZ' or ['BP', 'LP'], or it can be None or
    omitted to mean the special points ['BP', 'LP', 'HB', 'PD', 'TR', 'EP',
    'MX']\\
    Alternatively a boolean user-defined function \commandf{f} that
    takes a solution can be specified for \commandf{list}, such as
\begin{verbatim}
        def f(s):
            return s["PAR(9)"]<0
\end{verbatim}
    where all solutions are deleted that satisfy the given condition, or
\begin{verbatim}
        def f(s1,s2):
            return abs(s1["L2-NORM"] - s2["L2-NORM"]) < 1e-4
\end{verbatim}
    where all solutions are compared with each other and \commandf{s2}
    is deleted if the given condition is satisfied, which causes
    pruning of solutions that are close to each other.

    Type information is \emph{not} kept in the bifurcation diagram.

\textbf{Alias:} commandDeleteSpecialPoints

\item[ksp]
Keep special points.

    Type \commandf{ksp(x,list)} to only keep the special points in list in
    the Python object x, which must be a solution list or a bifurcation diagram.

    Type \commandf{ksp(list,'xxx')} to keep them in the data-files
    \filef{b.xxx}, and \filef{s.xxx}.\\
    Type \commandf{ksp(list,'xxx','yyy')} to save to \filef{b.yyy} and
    \filef{s.yyy} instead of \filef{?.xxx}.\\
    Type \commandf{ksp(list)} to keep them in \filef{fort.7} and \filef{fort.8}.

    \commandf{list} is a label number or type name code, or a list of those,
    such as 1, or [2, 3], or 'UZ' or ['BP', 'LP'], or it can be None or
    omitted to mean ['BP', 'LP', 'HB', 'PD', 'TR', 'EP', 'MX'], deleting 'UZ' and
    regular points.\\
    Alternatively a boolean user-defined function \commandf{f} that
    takes a solution can be specified for \commandf{list}, such as
\begin{verbatim}
        def f(s):
            return s["PAR(9)"]<0
\end{verbatim}
    where only solutions are kept that satisfy the given condition.

    Type information is \emph{not} kept in the bifurcation diagram.

\textbf{Alias:} commandKeepSpecialPoints

\item[merge]
Merge branches in data files.

    Type \commandf{y=merge(x)} to return the python object x, with its branches
    merged into continuous curves, as a new object y.

    Type \commandf{merge('xxx')} to merge branches in \filef{s.xxx},
    \filef{b.xxx}, and \filef{d.xxx}.  Backups of the
    original files are saved.

    Type \commandf{merge('xxx','yyy')} to merge branches in the existing data-files
    \filef{s.xxx}, \filef{b.xxx}, and \filef{d.xxx} and save them to 
    \filef{s.yyy}, \filef{b.yyy}, and \filef{d.yyy}.

\textbf{Aliases:} mb commandMergeBranches

\item[subtract]
Subtract branches in data files.

    Type \commandf{z=subtract(x,y,ref)} to return the python object x, where,
    using interpolation, the first branch in y is subtracted from all
    branches in x, as a new object z.
    Use 'ref' (e.g., 'PAR(1)')  as the reference column in y
    (only the first monotonically increasing or decreasing part is used).

    Type \commandf{subtract('xxx','yyy','ref')} to subtract, using interpolation, the first
    branch in \filef{b.yyy} from all branches in \filef{b.xxx},
    and save the result in \filef{b.xxx}.
    A Backup of the original file is saved.

    Use optional arguments branch=m, and point=n, to denote the branch and
    first point on that branch within y or \filef{b.yyy}, where m,n are in
    {1,2,3,...}.

\textbf{Aliases:} sb commandSubtractBranches

\end{description}

\subsection{Copying a demo.}
\label{sec:clui_ref_demo}
\begin{description}
\item[demo]
Copy a demo into the current directory and load it.

    Type \commandf{demo('xxx')} to copy all files from auto/07p/demos/xxx to the
    current user directory.  Here 'xxx' denotes a demo name; e.g.,
    'abc'.  To avoid the overwriting of existing files, always run
    demos in a clean work directory.  NOTE: This command automatically
    performs the \commandf{load} command as well.
    
\textbf{Aliases:} dm commandCopyAndLoadDemo

\item[copydemo]
Copy a demo into the current directory.

    Type \commandf{copydemo('xxx')} to copy all files from auto/07p/demos/xxx to the
    current user directory.  Here 'xxx' denotes a demo name; e.g.,
    'abc'.  To avoid the overwriting of existing
    files, always run demos in a clean work directory.
    
\textbf{Aliases:} copydemo commandCopyDemo
\end{description}

\subsection{Python data structure manipulation functions.}
\label{sec:clui_ref_python}
All commands here, except for 'man', 'gui', and 'wait' are only
provided for backwards compatibility. Alternatives are given.
\begin{description}
\item[man]
Get help on the \AUTO commands.
    
    Type \commandf{man} to list all commands with a online help.
    Type \commandf{man xxx} or \commandf{help xxx} to get help for command \commandf{xxx}.

\textbf{Aliases:} commandInteractiveHelp

\item[cn]
Get the current continuation constants.

    Type \commandf{cn('xxx')} to get a parsed version of the constants file
    \filef{c.xxx}. This is equivalent to the command\\
    \commandf{loadbd('xxx').c}
    
\textbf{Aliases:} constantsget commandParseConstantsFile

\item[dg]
Parse a bifurcation diagram.

    Type \commandf{dg('xxx')} to get a parsed version of the diagram file \filef{b.xxx}.
    This is equivalent to the command \commandf{loadbd('xxx')} but without the
    solutions in \filef{s.xxx} and without the diagnostics in \filef{d.xxx}.
    
\textbf{Aliases:} diagramget commandParseDiagramFile

\item[sl]
Parse solution file:

    Type \commandf{sl('xxx')} to get a parsed version of the solution file
    \filef{s.xxx}. This is equivalent to the command\\
    \commandf{loadbd('xxx')()}
    
\textbf{Aliases:} solutionget commandParseSolutionFile

\item[bt]
Parse both bifurcation diagram and solution.

    Type \commandf{bt('xxx')} to get a parsed version of the diagram file \filef{b.xxx}
    and solution file \filef{s.xxx}.
    This is equivalent to the command \commandf{loadbd('xxx')} but without the
    diagnostics in \filef{d.xxx}.
    
\textbf{Aliases:} diagramandsolutionget commandParseDiagramAndSolutionFile

\item[ch]
Modify continuation constants.

    Type \commandf{ch('xxx',yyy)} to change the constant \parf{'xxx'} to have
    value \parf{yyy}.
    This is equivalent to the command\\
    \commandf{s=load(s,xxx=yyy)}\\
    where \parf{s} is a solution.

\textbf{Aliases:} changeconstant cc commandRunnerConfigFort2

\item[hch]
Modify HomCont continuation constants.

    Type \commandf{hch('xxx',yyy)} to change the HomCont constant \parf{'xxx'} to have
    value \parf{yyy}.
    This is equivalent to the command\\
    \commandf{s=load(s,xxx=yyy)}\\
    where \parf{s} is a solution.
    
\textbf{Aliases:} commandRunnerConfigFort12

\item[pr]
Print continuation parameters.

    Type \commandf{pr()} to print all the parameters.
    Type \commandf{pr('xxx')} to return the parameter 'xxx'.
    These commands are equivalent to the commands\\
    \commandf{print s.c}\\
    \commandf{print s.c['xxx']}\\
    where \parf{s} is a solution.
    
\textbf{Aliases:} pc pr printconstant commandRunnerPrintFort2

\item[hpr]
Print HomCont continuation parameters.

    Type \commandf{hpr()} to print all the HomCont parameters.
    Type \commandf{hpr('xxx')} to return the HomCont parameter 'xxx'.
    These commands are equivalent to the commands\\
    \commandf{print s.c}\\
    \commandf{print s.c['xxx']}\\
    where \parf{s} is a solution.
    
\textbf{Aliases:} commandRunnerPrintFort12

\item[splabs]
Return special labels.
        
    Type \commandf{splabs('xxx',typename)} to get a list of labels with the specified
    typename, where typename can be one of
    'EP', 'MX', 'BP', 'LP', 'UZ', 'HB', 'PD', 'TR', or 'RG'.
    This is equivalent to the command\\
    \commandf{load('xxx')(typename)}\\
    which gives a list of the solutions themselves;
    \commandf{load('xxx')(typename).getLabels()}\\
    returns the list of labels.

    Or use \commandf{splabs(s,typename)} where \parf{s} is a parsed
    solution from \commandf{sl()}.
    This is equivalent to the command\\
    \commandf{s(typename).getLabels()}

\textbf{Aliases:} commandSpecialPointLabels

\item[wait]
Wait for the user to enter a key.

    Type \commandf{wait()} to have the \AUTO interface wait
    until the user hits any key (mainly used in scripts).

\textbf{Aliases:} commandWait

\item[quit]
Quits the \AUTO CLUI

\textbf{Aliases:} q commandQuit

\item[gui]
Show \AUTO's graphical user interface.

    Type \commandf{gui()} to start \AUTO's graphical user interface.
    
    NOTE: This command is not implemented yet.
    
\textbf{Aliases:} commandCreateGUI

\end{description}

\subsection{Shell Commands.} \label{sec:clui_ref_shell}

\begin{description}
\item[cat]
Print the contents of a file

    Type \commandf{cat xxx} to list the contents of the file \filef{xxx}.
    
\textbf{Aliases:} commandCat

\item[cd]
Change directories.
    
    Type \commandf{cd xxx} to change to the directory \filef{xxx}.  This command
    understands both shell variables and home directory expansion.
    
\textbf{Aliases:} commandCd 

\item[ls]
List the current directory.
    
    Type \commandf{ls} to run the system \commandf{ls} command in the
    current directory.
    This command will accept whatever arguments are accepted by the Unix command
    \commandf{ls}.
    
\textbf{Aliases:} commandLs

\item[shell]
Run a shell command.
        
    Type \commandf{shell('xxx')} to run the command \commandf{xxx}
    in the Unix shell and display
    the results in the \AUTO command line user interface.
    
\textbf{Aliases:} commandShell
\end{description}


%==============================================================================
%==============================================================================
\chapter{ Running {\cal AUTO} using Unix Commands.} \label{sec:command_mode}
%==============================================================================
%==============================================================================
Apart from the Python commands described in the previous chapter,
{\cal AUTO} can also be run with the GUI described in Chapter~\ref{ch:GUI},
or using the Unix commands described below. These Unix commands run both
directly in the shell and at the {\tt AUTO} Python prompt.
The {\cal AUTO} aliases must have been activated; see Section~\ref{sec:Installation}; 
and an equations-file {\tt xxx.f90} 
and a corresponding constants-file {\tt c.xxx} 
(see Section~\ref{ch:User_supplied_files})
must be in the current user directory.
\\
{\it Do not run {\cal AUTO} in the directory {\tt auto/07p} 
or in any of its subdirectories.}

Most commands only need a plain Unix shell but some use \python: the
commands that depend on \python are \commandf{@cnvc},
\commandf{@dlb}, \commandf{@dsp}, \commandf{@klb}, \commandf{@ksp},
\commandf{@lbf}, \commandf{@ll}, \commandf{@ls}, \commandf{@mb},
\commandf{@pp}, and \commandf{@sb}.

\section{ Basic commands.} 

\begin{itemize}
\item[\tt @r]:
  Type \commandf{@r xxx} to run {\cal AUTO}.
  Restart data, if needed, are expected in {\tt s.xxx},
  and {\cal AUTO}-constants in {\tt c.xxx}.
  This is the simplest way to run {\cal AUTO}.
\item[-]
  Type \commandf{@r xxx yyy} to run {\cal AUTO}
  with equations-file {\tt xxx.f90} and restart data-file {\tt s.yyy}.
  {\cal AUTO}-constants must be in {\tt c.xxx}.
\item[-]
  Type \commandf{@r xxx yyy zzz} to run {\cal AUTO}
  with equations-file {\tt xxx.f90}, restart data-file {\tt s.yyy}
  and constants-file {\tt c.zzz}.

\item[\tt @R]~:
  The command \commandf{@R xxx} is equivalent to the command \commandf{@r xxx} above.
\item[-]
  Type \commandf{@R xxx i}  to run {\cal AUTO} with equations-file {\tt xxx.f90},
  constants-file {\tt c.xxx.i}
  and, if needed, restart data-file {\tt s.xxx}. 
\item[-]
  Type \commandf{@R xxx i yyy} to run {\cal AUTO}
  with equations-file {\tt xxx.f90}, 
  constants-file {\tt c.xxx.i}
  and restart data-file {\tt s.yyy}.
\item[-]
  Use \commandf{@@R} on case-insensitive file systems.

\item[\tt @sv]~:
  Type \commandf{@sv xxx} to save the output-files 
  {\tt fort.7}, {\tt fort.8}, {\tt fort.9},
  as {\tt b.xxx}, {\tt s.xxx}, {\tt d.xxx}, respectively.
  Existing files by these names will be deleted.

\item[\tt @ap]~:
  Type \commandf{@ap xxx} to append the output-files 
  {\tt fort.7}, {\tt fort.8}, {\tt fort.9}, 
  to existing data-files 
  {\tt b.xxx}, {\tt s.xxx}, {\tt d.xxx}, resp.
\item[-]
  Type \commandf{@ap xxx yyy} 
  to append 
  {\tt b.xxx}, {\tt s.xxx}, {\tt d.xxx}, to
  {\tt b.yyy}, {\tt s.yyy}, {\tt d.yyy}, resp.

\item[\tt @ll]~:
  Type \commandf{@ll} to list all solutions in \filef{fort.8}.\\
  Type \commandf{@ll xxx} to list all solutions in \filef{s.xxx}.

\item[\tt @ls]~:
  Type \commandf{@ls} to list the abbreviated contents of \filef{fort.7}.\\
  Type \commandf{@ls xxx} to list the abbreviated contents of \filef{b.xxx}.\\
  The contents are shown in a similar format as the screen output of
  AUTO runs.

\item[\tt @lbf]~:
  Type \commandf{@lbf} to list the contents of \filef{fort.7}.\\
  Type \commandf{@lbf xxx} to list the contents of \filef{b.xxx}.\\
  The contents are shown with less accuracy (6 instead of 11
  significant figures) than in the actual file for easier viewing.


\end{itemize}

\section{ Plotting commands.} 

\begin{itemize}

\item[\tt @pp]~:
  Type \commandf{@pp xxx} to run the graphics program {\cal PyPLAUT}
  (See Chapter~\ref{ch:PLAUT})
  for the graphical inspection of the data-files 
  {\tt b.xxx} and {\tt s.xxx}. 
\item[-]
  Type \commandf{@pp} to run the graphics program {\cal PyPLAUT}
  for the graphical inspection of the output-files 
  {\tt fort.7} and {\tt fort.8}.

\item[\tt @pl]~:
  The command \commandf{@pl} is equivalent to {\tt @pp} but runs
  the graphics program {\cal PLAUT04} instead.
  (See Chapter~\ref{ch:PLAUT04})

\item[\tt @r3b]~:
  The command \commandf{@r3b} is equivalent to {\tt @pp} but runs
  the graphics program {\cal PLAUT04} instead in R3B mode.
  (See Chapter~\ref{ch:PLAUT04})

\item[\tt @p]~:
  The command \commandf{@p} is equivalent to {\tt @pp} but runs
  the graphics program {\cal PLAUT} instead.
  (See Chapter~\ref{ch:PLAUT})

\item[\tt @ps]~:
  Type \commandf{@ps fig.x} to convert a saved {\cal PLAUT} figure {\tt fig.x}
  from compact {\cal PLOT10} format to {\cal PostScript} format.
  The converted file is called {\tt fig.x.ps}. 
  The original file is left unchanged.

\end{itemize}

\section{ File-manipulation.} 

\begin{itemize}

\item[\tt @cp]~:
  Type \commandf{@cp name1 name2}, or \commandf{@cp name1
   name2 name3}, or  \commandf{@cp name1 name2 name3 name4} to
  copy the data-files \filef{dir1/c.xxx}, \filef{dir1/b.xxx},
  \filef{dir1/s.xxx}, and \filef{dir1/d.xxx}, to \filef{dir2/c.yyy},
  \filef{dir2/b.yyy}, \filef{dir2/s.yyy}, and \filef{dir2/d.yyy}.

  The values of \filef{dir1/?.xxx} and \filef{dir2/?.yyy} are as
  follows, depending on whether \filef{name1} is a directory or
  \filef{name2} is a directory:

  \commandf{@cp name1 name2}\\
  no directory names: \filef{./?.name1} and \filef{./?.name2}\\
  \filef{name1} is a directory: \filef{name1/?.name2} and \filef{./?.name2}\\
  \filef{name2} is a directory: \filef{./?.name1} and \filef{name2/?.name1}

  \commandf{@cp name1 name2 name3}\\
  \filef{name1} is a directory: \filef{name1/?.name2} and \filef{./?.name3}\\
  \filef{name2} is a directory: \filef{./?.name1} and \filef{name2/?.name3}

  \commandf{@cp name1 name2 name3 name4}\\
  \filef{name1/?.name2} and \filef{name3/?.name4}

\item[\tt @mv]~:
   Type \commandf{@mv name1 name2}, or \commandf{@mv name1 name2
     name3)}, or  \commandf{@mv name1 name2 name3 name4} to
   move the data-files \filef{dir1/b.xxx}, \filef{dir1/s.xxx}, and
   \filef{dir1/d.xxx}, to \filef{dir2/b.yyy}, \filef{dir2/s.yyy}, and
   \filef{dir2/d.yyy}, and copy the constants
   file \filef{dir1/c.xxx} to \filef{dir2/c.yyy}.

   The values of \filef{dir1/?.xxx} and \filef{dir2/?.yyy} are determined
   in the same way as for \commandf{@cp} above.

\item[\tt @df]~:
  Type \commandf{@df} 
  to delete the output-files 
  {\tt fort.7}, {\tt fort.8}, {\tt fort.9}.

\item[\tt @cl]~:
  Type \commandf{@cl} 
  to clean the current directory.
  This command will delete  all files of the form
  {\tt fort.*}, {\tt *.o}, {\tt *.*\~{}}, and {\tt *.exe}.

\item[\tt @dl]~:
  Type \commandf{@dl xxx} 
 to delete the data-files 
  {\tt b.xxx}, {\tt s.xxx}, {\tt d.xxx}.

\item[\tt @cnvc]~:
  Type \commandf{@cnvc xxx yyy} to convert old-format constants files
\filef{c.xxx} and \filef{h.xxx} to a new-format constant file
\filef{c.yyy}.\\
  The command \commandf{@cnvc xxx} overwrites the file \filef{c.xxx}
  with the new style file and deletes \filef{h.xxx} if it exists.

\item[\tt @rn]~:
  Type \commandf{@rn} to rename, within the current directory, all
  old-named constants, HomCont, bifurcation
  diagram, and solution files starting with \filef{r.}, \filef{s.},
  \filef{p.}, and \filef{q.} to files with the new prefixes
  \filef{c.}, \filef{h.}, \filef{b.}, and \filef{s.}.

\item[\tt @rc]~:
  Type \commandf{@rc} to do a recovery by swapping the backup files
  \filef{fort.7\~{}} and \filef{fort.8\~{}} with the files
  \filef{fort.7} and \filef{fort.8}.\\
  Type \commandf{@rc xxx} to do a recovery by swapping the backup files
  \filef{b.xxx} and \filef{s.xxx} with the files
  \filef{b.xxx\~{}} and \filef{s.xxx\~{}}.

\item[\tt @gz]~:
  Type \commandf{@gz} to compress, using \commandf{gzip} all output
  files in the current directory.

\item[\tt @uz]~:
  Type \commandf{@uz} to decompress, using \commandf{unzip} all output
  files in the current directory.

\item[\tt @sr]~:
  Type \commandf{@sr xxx y} to copy \filef{c.xxx} to \filef{c.xxx.y}.

\end{itemize}

\section{ Diagnostics.} 

\begin{itemize}
\item[\tt @lp]~:
  Type \commandf{@lp} to list the value of the ``limit point function'' 
  in the output-file {\tt fort.9}. This function
  vanishes at a limit point (fold).
  \item[-]
  Type \commandf{@lp xxx} to list the value of the ``limit point function'' 
  in the data-file {\tt d.xxx}. This function
  vanishes at a limit point (fold).
\item[\tt @bp]~:
  Type \commandf{@bp} to list the value of the ``branch-point function'' 
  in the output-file {\tt fort.9}. This function
  vanishes at a branch point.
  \item[-]
  Type \commandf{@bp xxx} to list the value of the ``branch-point function''
  in the data-file {\tt d.xxx}. This function
  vanishes at a branch point.
\item[\tt @hb]~:
  Type \commandf{@hb} to list the value of the ``Hopf function'' 
  in the output-file {\tt fort.9}. This function
  vanishes at a Hopf bifurcation point.
  \item[-]
  Type \commandf{@hb xxx} to list the value of the ``Hopf function''
  in the data-file {\tt d.xxx}. This function
  vanishes at a  Hopf bifurcation point.
\item[\tt @ho]~:
  The command \commandf{@ho} is an alias to \commandf{@hb} above.
\item[\tt @sp]~:
  Type \commandf{@sp} to list the value of the 
  ``secondary-periodic bifurcation function'' 
  in the output-file {\tt fort.9}. This function
  vanishes at period-doubling and torus bifurcations.
  \item[-]
  Type \commandf{@sp xxx} to list the value of the
   ``secondary-periodic bifurcation function''
  in the data-file {\tt d.xxx}. This function
  vanishes at period-doubling and torus bifurcations.
\item[\tt @it]~:
  Type \commandf{@it} to list the number of Newton iterations per
  continuation step in {\tt fort.9}. 
  \item[-]
   Type \commandf{@it xxx} to list the number of Newton iterations per
  continuation step in {\tt d.xxx}. 
\item[\tt @st]~:
  Type \commandf{@st} to list the number of stable eigenvalues or stable
  Floquet multipliers per continuation step in  {\tt fort.9}. 
\item[\tt @ss]~:
  Type \commandf{@st} to list the continuation step size for each
  continuation step in  {\tt fort.9}. 
  \item[-]
   Type \commandf{@st xxx} to list the continuation step size for each
  continuation step in {\tt d.xxx}. 
\item[\tt @ev]~:
  Type \commandf{@ev} to list the eigenvalues of the Jacobian 
  in {\tt fort.9}. 
  (Algebraic problems.)
  \item[-]
   Type \commandf{@ev xxx} to list the eigenvalues of the Jacobian 
  in {\tt d.xxx}. 
  (Algebraic problems.)
\item[\tt @fl]~:
  Type \commandf{@fl} to list the Floquet multipliers
  in the output-file {\tt fort.9}. 
  (Differential equations.)
  \item[-]
   Type \commandf{@fl xxx} to list the Floquet multipliers 
  in the data-file {\tt d.xxx}. 
  (Differential equations.)
\item[\tt @no]~:
  Type \commandf{@no} to show any notes in {\tt fort.9}.
  \item[-]
  Type \commandf{@no xxx} to show any notes in {\tt d.xxx}.
\end{itemize}

\section{ File-editing.} 

\begin{itemize}

\item[\tt @e7]~:
  To use the vi editor to edit the output-file {\tt fort.7}.
\item[\tt @e8]~:
  To use the vi editor to edit the output-file {\tt fort.8}.
\item[\tt @e9]~:
  To use the vi editor to edit the output-file {\tt fort.9}.
\item[\tt @j7]~:
  To use the SGI jot editor to edit the output-file {\tt fort.7}.
\item[\tt @j8]~:
  To use the SGI jot editor to edit the output-file {\tt fort.8}.
\item[\tt @j9]~:
  To use the SGI jot editor to edit the output-file {\tt fort.9}.
  
\end{itemize}

\section{ File-maintenance.} 

\begin{itemize}
\item[\tt @rl]~:
  Type \commandf{@rl} to sequentially relabel solutions with the numbers $1,2,3,\ldots$
  in the output-files {\tt fort.7} and {\tt fort.8}.
  The original files are backed up as
{\tt fort.7$\sim$} and {\tt fort.8$\sim$}. 
  \item[-]
  Type \commandf{@rl xxx} to relabel solutions
  in the data-files {\tt b.xxx} and {\tt s.xxx}.
  The original files are backed up as {\tt b.xxx$\sim$} and {\tt s.xxx$\sim$}. 
\item[-]
  Type \commandf{@rl xxx yyy} to relabel solutions
  in the data-files {\tt b.xxx} and {\tt s.xxx}.
  The modified files are written as {\tt b.yyy} and {\tt s.yyy}. 

\item[\tt @lb]~:
  Type \commandf{@lb} to run an interactive utility program
  for listing, deleting and relabeling solutions and branches
  in the output-files {\tt fort.7} and {\tt fort.8}.
  The original files are backed up as
{\tt fort.7$\sim$} and {\tt fort.8$\sim$}. 
  \item[-]
  Type \commandf{@lb xxx} to list, delete and relabel solutions and branches
  in the data-files {\tt b.xxx} and {\tt s.xxx}.
  The original files are backed up as {\tt b.xxx$\sim$} and {\tt s.xxx$\sim$}. 
\item[-]
  Type \commandf{@lb xxx yyy} to list, delete and relabel solutions
  in the data-files {\tt b.xxx} and {\tt s.xxx}.
  The modified files are written as {\tt b.yyy} and {\tt s.yyy}. 

\item[\tt @LB]~:
  Type \commandf{@LB} or \commandf{@@LB} on case-insensitive file
  systems is equivalent to \commandf{@lb} above but moves instead of
  copies files so that it is much quicker but interrupts may be harmful.

\item[\tt @fc]~:
  Type \commandf{@fc xxx} to convert a user-supplied data file {\tt xxx.dat}
  to {\cal AUTO} format. The converted file is called {\tt s.dat}.
  The original file is left unchanged.
  {\cal AUTO} automatically sets the period in {\tt PAR(11)}.
  Other parameter values must be set in {\tt STPNT}. (When necessary,
  {\tt PAR(11)} may also be redefined there.) 
  The constants-file file {\tt c.xxx} must be present, as the 
  {\cal AUTO}-constants {\tt NTST} and {\tt NCOL} 
  (Sections~\ref{sec:NTST} and \ref{sec:NCOL}) are used to define the new mesh.
  
  Note: this technique has been obsoleted by the 'dat' AUTO constant
  in Section~\ref{sec:dat}.

\item[\tt @db]~:
  Type \commandf{@db} to double the solution in \filef{fort.8}.
  Type \commandf{@db xxx} to double the solution in \filef{s.xxx}.

\item[\tt @tr]~:
  Type \commandf{@tr} to triple the solution in \filef{fort.8}.
  Type \commandf{@tr xxx} to triple the solution in \filef{s.xxx}.

\item[\tt @dlb]~:
  Type \commandf{@dlb} to delete all special labels in \filef{fort.7} and
  \filef{fort.8}. Backups are made.\\
  Type \commandf{@dlb xxx} to delete all special labels in \filef{b.xxx} and
  \filef{s.xxx}. Backups are made.\\
  Type \commandf{@dlb xxx yyy} to delete all special labels in \filef{b.xxx} and
  \filef{s.xxx}. The output is written to \filef{b.yyy} and
  \filef{s.yyy}.\\
  Optionally, give an argument of the form
  \commandf{-UZ}, \commandf{-HB}, \commandf{-LP}, \commandf{-EP}, \commandf{-PD},
  \commandf{-TR}, \commandf{-BP}, \commandf{-MX}, or \commandf{-RG} to
  remove all labels with the given type, as in
  \commandf{@dlb -UZ xxx}; otherwise only labels with type UZ and
  regular labels are kept.\\
  Type information is kept in the bifurcation diagram for plotting.

\item[\tt @klb]~:
  Type \commandf{@klb} to keep all special labels in \filef{fort.7} and
  \filef{fort.8}. Backups are made.\\
  Type \commandf{@klb xxx} to keep all special labels in \filef{b.xxx} and
  \filef{s.xxx}. Backups are made.\\
  Type \commandf{@klb xxx yyy} to keep all special labels in \filef{b.xxx} and
  \filef{s.xxx}. The output is written to \filef{b.yyy} and
  \filef{s.yyy}.\\
  Optionally, give an argument of the form
  \commandf{-UZ}, \commandf{-HB}, \commandf{-LP}, \commandf{-EP}, \commandf{-PD},
  \commandf{-TR}, \commandf{-BP}, \commandf{-MX}, or \commandf{-RG} to
  keep all labels with the given type, as in
  \commandf{@klb -UZ xxx} and remove all others;
  otherwise all labels are kept except for labels with type UZ and regular labels.\\
  Type information is kept in the bifurcation diagram for plotting.

\item[\tt @dsp]~:
  The command \commandf{@dsp} is equivalent to the command \commandf{@dlb}
  above, except that
  type information is \emph{not} kept in the bifurcation diagram for plotting.

\item[\tt @ksp]~:
  The command \commandf{@ksp} is equivalent to the command \commandf{@klb}
  above, except that
  type information is \emph{not} kept in the bifurcation diagram for plotting.

\item[\tt @dlp]~:
  The command \commandf{@dlp} is equivalent to the command \commandf{@dsp -LP}
  above.

\item[\tt @kbp]~:
  The command \commandf{@kbp} is equivalent to the command \commandf{@ksp -BP}
  above.

\item[\tt @klp]~:
  The command \commandf{@klp} is equivalent to the command \commandf{@ksp -LP}
  above.

\item[\tt @kuz]~:
  The command \commandf{@kuz} is equivalent to the command \commandf{@ksp -UZ}
  above.

\item[\tt @rd]~:
  Type \commandf{@rd} to reduce the solution in \filef{fort.7}
  and \filef{fort.8}.\\
  Type \commandf{@rd xxx} to reduce the solution in \filef{b.xxx} and
  \filef{s.xxx}.\\
  Reducing means that all even regular point solutions
  (from \parf{NPR}: the 2nd, 4th, 6th,  etc.) are deleted from the files.

\item[\tt @RD]~:
  The commands \commandf{@RD} and \commandf{@@RD} (for
  case-insensitive file systems) are equivalent to \commandf{@rd}
  above but are faster, though not reliable when interrupting,
  by using moves instead of copies.

\item[\tt @mb]~:
  Type \commandf{@mb} to merge branches into continuous curves
  in \filef{fort.7}, \filef{fort.8}, and \filef{fort.9}.  Backups of the
  original files are saved.\\
  Type \commandf{@mb xxx} to merge branches in \filef{s.xxx},
  \filef{b.xxx}, and \filef{d.xxx}.  Backups of the
  original files are saved.\\
  Type \commandf{@mb xxx yyy} to merge branches in \filef{s.xxx},
  \filef{b.xxx}, and \filef{d.xxx},
  and save them to \filef{s.yyy}, \filef{b.yyy}, and \filef{d.yyy}.

\item[\tt @sb]~:
  Type \commandf{@sb xxx yyy ref} to subtract, using interpolation, the first
  branch in \filef{b.yyy} from all branches in \filef{b.xxx},
  and save the result in \filef{b.xxx}.
  Use \commandf{ref} (e.g., \commandf{PAR(1)}) as the reference
  column in \filef{b.yyy}.
  (only the first monotonically increasing or decreasing part is used).
  A Backup of the original file is saved.

  Use optional fourth and fifth arguments \commandf{m}, and
  \commandf{n}, to denote the
  branch $m$ and first point $n$ on that branch within \filef{b.yyy},
  where $m,n$ are in $\{1,2,3,\ldots\}$.

\item[\tt @zr]~:
  Type \commandf{@zr xxx} to zero all small numbers, with absolute
  value less than $10^{-16}$ in \filef{s.xxx}. A backup file is made.

\end{itemize}

\section{ HomCont commands.} 

Note that the \commandf{@h} and \commandf{@H} are obsolete with
new-style constants files, where HomCont constants can be included in
the main constant file with a {\tt c.} prefix.
\begin{itemize}
\item[\tt @h]~:
  Use {\tt @h} instead of {\tt @r} when using {\cal HomCont}, i.e., when {\tt IPS}=9
  (see Chapter~\ref{ch:HomCont}).
  Type \commandf{@h xxx} to run {\cal AUTO}/{\cal HomCont}.
  Restart data, if needed, are expected in {\tt s.xxx},
  {\cal AUTO}-constants in {\tt c.xxx} and {\cal HomCont}-constants in {\tt h.xxx}.
\item[-]
  Type \commandf{@h xxx yyy} to run {\cal AUTO}/{\cal HomCont}
  with equations-file {\tt xxx.f90} and restart data-file {\tt s.yyy}.
  {\cal AUTO}-constants must be in {\tt c.xxx} and {\cal HomCont}-constants in {\tt h.xxx}.
\item[-]
  Type \commandf{@h xxx yyy zzz} to run {\cal AUTO}/{\cal HomCont}
  with equations-file {\tt xxx.f90}, restart data-file {\tt s.yyy}
  and constants-files {\tt c.zzz} and {\tt h.zzz}.

\item[\tt @H]~:
  The command \commandf{@H xxx} is equivalent to the command \commandf{@h xxx} above.
\item[-]
  Type \commandf{@H xxx i} to run {\cal AUTO}/{\cal HomCont} with equations-file {\tt xxx.f90}
  and constants-files {\tt c.xxx.i} and {\tt h.xxx.i}
  and, if needed, restart data-file {\tt s.xxx}. 
\item[-]
  Type \commandf{@H xxx i yyy} to run {\cal AUTO}/{\cal HomCont}
  with equations-file {\tt xxx.f90}, 
  constants-files {\tt c.xxx.i} and {\tt h.xxx.i},
  and restart data-file {\tt s.yyy}.
\item[-]
  Use \commandf{@@H} on case-insensitive file systems.
\end{itemize}

\section{ Copying a demo.} 

\begin{itemize}

\item[\tt @dm]~:
  Type \commandf{@dm xxx} 
  to copy all files 
  from {\tt auto/07p/demos/xxx}
  to the current user directory.
  Here {\tt xxx} denotes a demo name; e.g., {\tt abc}.
  Note that the \commandf{@dm} command also copies \filef{.auto} files
  to the current user directory. To avoid the overwriting of
  existing files, always run demos in a clean work directory.
\end{itemize}

\section{ Viewing the manual.} 

\begin{itemize}

\item[\tt @mn]~: Use {\cal gv} or {\cal evince} to view the PDF version of this manual.
\end{itemize}

\newpage

%==============================================================================
%==============================================================================
\chapter{ Output Files.} \label{ch:Output_files}
%==============================================================================
%==============================================================================
{\cal AUTO} writes to standard output and three output-files~:
\begin{itemize}
\item[-] standard output:~
  A summary of the computation is written to standard output, which usually
  corresponds to the window in which {\cal AUTO} is run. 
  Only special, labeled solution points are noted, namely those listed
  in Tables~\ref{tbl:Solution_Types} and \ref{tbl:Codim2_Solution_Types}
  The letter codes in the Table are used in the screen output.
  The numerical codes are used internally and in
  the {\tt fort.7} and {\tt fort.8} output-files described below.

\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | r | l |}
\hline
 BP & (1)  & Branch point (algebraic systems) \\
\hline
 LP & (2)  & Fold (algebraic systems) \\
\hline
 HB & (3)  & Hopf bifurcation \\
\hline
  & (4)  & User-specified regular output point \\
\hline
 UZ & (-4)  & Output at user-specified parameter value \\
\hline
 LP & (5)  & Fold (differential equations) \\
\hline
 BP & (6)  & Branch point (differential equations) \\
\hline
 PD & (7)  & Period doubling bifurcation \\
\hline
 TR & (8)  & Torus bifurcation \\
\hline
 EP & (9)  & End point of family; normal termination \\
\hline
 MX & (-9)  & Abnormal termination; no convergence \\
\hline
\end{tabular}
\caption{Solution Types.}
\label{tbl:Solution_Types}
\end{center}
\end{table}
 
\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | r | l |}
\hline
 BT & (-21) & Bogdanov-Takens bifurcation on fold curve (algebraic systems)\\
\hline
 BT & (-31) & Bogdanov-Takens bifurcation on Hopf curve \\
\hline
 CP & (-22) & Cusp bifurcation on fold curve (algebraic systems)\\
\hline
 GH & (-32) & Generalized Hopf bifurcation on Hopf curve \\
\hline
 ZH & (-13) & Zero-Hopf on BP curve (algebraic systems)\\
\hline
 ZH & (-23) & Zero-Hopf on Fold curve (algebraic systems)\\
\hline
 ZH & (-33) & Zero-Hopf on Hopf curve \\
\hline
 R1 & (-25) & 1:1 resonance on Fold (maps) \\
\hline
 R1 & (-55) & 1:1 resonance on Fold (periodic solutions) \\
\hline
 R1 & (-85) & 1:1 resonance on Torus (periodic solutions, maps) \\
\hline
 R2 & (-76) & 1:2 resonance on PD (periodic solutions, maps) \\
\hline
 R2 & (-86) & 1:2 resonance on Torus (periodic solutions, maps) \\
\hline
 R3 & (-87) & 1:3 resonance on Torus (periodic solutions, maps) \\
\hline
 R4 & (-88) & 1:4 resonance on Torus (periodic solutions, maps) \\
\hline
 LPD & (28) & Fold-flip bifurcation on Fold (maps) \\
\hline
 LPD & (78) & Fold-flip bifurcation on PD (maps) \\
\hline
 LTR & (23) & Fold-torus bifurcation on Fold (maps) \\
\hline
 LTR & (83) & Fold-torus bifurcation on Torus (maps) \\
\hline
 PTR & (77) & Flip-torus bifurcation on PD (maps) \\
\hline
 PTR & (87) & Flip-torus bifurcation on Torus (maps) \\
\hline
 TTR & (88) & Torus-torus bifurcation on Torus (maps) \\
\hline
\end{tabular}
\caption{Codimension-two solution types.
Note that the absolute value of the numerical code divided by 10
gives the type of the curve on which the special point occurs.}
\label{tbl:Codim2_Solution_Types}
\end{center}
\end{table}

\item[-] {\tt fort.7}~:~ 
  The {\tt fort.7} output-file contains the bifurcation diagram.
  Its format is the same as the {\tt fort.6} (screen) output, 
  but the {\tt fort.7} output is more extensive, as every solution point has 
  an output line printed.
\item[-] {\tt fort.8}~:~ 
  The {\tt fort.8} output-file contains complete graphics and restart data
  for selected, labeled solutions. 
  The information per solution is generally much more extensive than
  that in {\tt fort.7}. 
  The {\tt fort.8} output should normally be kept to a minimum.
\item[-] {\tt fort.9}~:~
  Diagnostic messages, convergence history, eigenvalues, and 
  Floquet multipliers are written in {\tt fort.9}.
  It is strongly recommended that this output be habitually inspected.
  The amount of diagnostic data can be controlled via the {\cal AUTO}-constant {\tt IID};
  see Section~\ref{sec:IID}.
\end{itemize}

The user has some control over the {\tt fort.6} (screen) and {\tt fort.7} output 
via the {\cal AUTO}-constant {\tt IPLT} (Section~\ref{sec:IPLT}).
Furthermore, the routine {\tt PVLS} can be used to define ``solution measures''
which can then be printed by ``parameter overspecification'';
see Section~\ref{sec:Parameter_over_specification}.
For an example see demo {\tt pvl}.

The {\cal AUTO}-commands \commandf{@sv}(\commandf{sv}), \commandf{@ap}(\commandf{ap}),
 and \commandf{@df}(\commandf{df}) can be used 
to manipulate  the output-files {\tt fort.7}, {\tt fort.8},
and {\tt fort.9}.
Furthermore, the {\cal AUTO}-command \commandf{@lb}(\commandf{rl}) can be
used to delete and
relabel solutions and branches simultaneously in {\tt fort.7} and {\tt fort.8}.
For details see Section~\ref{sec:command_mode}.

The graphics programs {\cal PLAUT}, {\cal PLAUT04}, and the Python
CLUI command \commandf{plot} can be used to graphically inspect 
the data in {\tt fort.7} and {\tt fort.8}; see Chapters~\ref{ch:PLAUT},
~\ref{ch:PLAUT04}, and ~\ref{ch:python_mode}.
 
%==============================================================================
%==============================================================================
\chapter{ The Graphics Programs PLAUT and PyPLAUT.} \label{ch:PLAUT}
%==============================================================================
%==============================================================================
{\cal PLAUT} and {\cal PyPLAUT} can be used to extract graphical
information from the {\cal AUTO} output-files {\tt fort.7} and {\tt fort.8},
or from the corresponding data-files {\tt b.xxx} and {\tt s.xxx}.
To invoke {\cal PLAUT}, use the \commandf{@p} command defined in 
Section~\ref{sec:command_mode}.
The {\cal PLAUT} window (a Tektronix window) will appear, in which {\cal PLAUT}
commands can be entered.
To invoke {\cal PyPLAUT}, use the \commandf{@pp} command. The same
plotting window as you get by using \commandf{plot} in the \python interface
appears (see Section~\ref{clui:plotting}), 
but you can also manipulate it by typing {\cal PLAUT}
commands in the terminal in which you typed \commandf{@pp}.
For examples of using {\cal PLAUT} and {\cal PyPLAUT} see the tutorial demos {\tt pp2}
and {\tt pp3} in sections~\ref{sec:Demos_pp2} and \ref{sec:Demos_pp3},
respectively.

The files \filef{.autorc} and \filef{autorc}, as explained in
Section~\ref{clui:plotting}, can be used to customize
{\cal PyPLAUT}'s behaviour and appearance.

\section{ Basic {\cal PLAUT}-Commands.} \label{sec:main_PLAUT_commands}
The principal {\cal PLAUT}-commands are 
\begin{itemize}
\item[\tt bd0]~:
  This command is useful for an initial overview of the bifurcation
  diagram as stored in {\tt fort.7}.
  If you have not previously selected one of the default options 
  {\it d0, d1, d2, d3}, or {\it d4} described below then you will be asked
  whether you want solution labels, grid lines, titles, or labeled axes.

\item[\tt bd]~:
  This command is the same as the {\it bd0} command, except that you will be
  asked to enter the minimum and the maximum of the horizontal and 
  vertical axes.
  This is useful for blowing up portions of a previously displayed
  bifurcation diagram.

\item[\tt ax]~:
  With the {\it ax} command you can select any pair of columns of real
  numbers from {\tt fort.7} as horizontal and vertical axis in the
  bifurcation diagram. (The default is columns 1 and 2).
  To determine what these columns represent, one can look at the
  screen ouput of the corresponding {\cal AUTO} run, or one can inspect the
  column headings in {\tt fort.7}.
  
\item[\tt 2d]~:
  Upon entering the {\it 2d} command, the labels of all solutions stored 
  in {\tt fort.8} will be listed and you can select one or more of these 
  for display. The number of solution components is also listed
  and you will be prompted to select two of these as horizontal and
  vertical axis in the display.
  Note that the first component is typically the independent 
  time or space variable scaled to the interval [0,1].

\item[\tt sav]~:
  To save the displayed plot in a file. You will be asked to enter
  a file name. Each plot must be stored in a separate new file.
  The plot is stored in compact {\cal PLOT10} format, which can be converted to 
  {\cal PostScript} format with the {\cal AUTO}-commands {\tt @ps};
  see Section~\ref{sec:Printing_PLAUT_files}.

\item[\tt cl]~:  To clear the graphics window.

\item[\tt lab]~:
  To list the labels of all solutions stored in {\tt fort.8}.
  Note that {\cal PLAUT} requires all labels to be distinct.
  In case of multiple labels you can use the {\cal AUTO}
  command \commandf{@lb} to relabel solutions in
  {\tt fort.7} and {\tt fort.8}.

\item[\tt end]~:  To end execution of {\cal PLAUT}.
\end{itemize}


\section{ Default Options.} \label{sec:PLAUT_default}
After entering the commands {\it bd0, bd}, or {\it 2d}, you will be asked whether you 
want solution labels, grid lines, titles, or axes labels.
For quick plotting it is convenient to bypass these selections.
This can be done by the default commands {\it d0, d1, d2, d3}, or {\it d4} below.
These can be entered as a single command 
or they can be entered as prefixes in the {\it bd0} and {\it bd} commands. 
Thus, for example, one can enter the command {\it d1bd0}.  

\begin{itemize}
\item[\tt d0]~:  Use solid curves, showing symbols, but no solution labels. 
\item[\tt d1]~:  Use solid curves, except use dashed curves for unstable
  solutions and for solutions of unknown stability.
  Show solution labels and symbols.
\item[\tt d2]~:  As {\it d1}, but without solution labels.
\item[\tt d3]~:  As {\it d1}, but with grid lines.
\item[\tt d4]~:  As {\it d2}, but with grid lines.
\end{itemize}

If no default option {\it d0, d1, d2, d3}, or {\it d4} has been selected 
or if you want to override a default feature,
then the following commands can be used.
These can be entered as individual commands or as prefixes.
For example, one can enter the command {\it sydpbd0}.

\begin{itemize}
\item[\tt sy]~:  Use symbols for special solution points, for example,
  open square = branch point,
  solid square = Hopf bifurcation.
\item[\tt dp]~:  ``Differential Plot'', i.e., show stability of the 
  solutions. Solid curves represent stable solutions.
  Dashed curves are used for unstable
  solutions and for solutions of unknown stability.
  For periodic solutions use solid/open circles
  to indicate stability/instability (or unknown
  stability).
\item[\tt st]~:  Set up titles and axes labels. 
\item[\tt nu]~:  Normal usage (reset special options). 
\end{itemize}


\section{ Other {\cal PLAUT}-Commands.} \label{sec:Other_PLAUT_commands}
The full {\cal PLAUT} program has several other capabilities, for example,

\begin{itemize}
\item[\tt scr]~:  To change the diagram size.
\item[\tt rss]~:  To change the size of special solution point symbols.
\end{itemize}

These commands are not available in {\cal PyPLAUT}.

\section{ Printing {\cal PLAUT} Files.} \label{sec:Printing_PLAUT_files}
\begin{itemize}
\item[\tt @ps]~:
  Type \commandf{@ps fig.1} to convert a saved {\cal PLAUT} file {\tt fig.1} 
  to {\cal PostScript} format
  in {\tt fig.1.ps}.

\item[\tt @eps]~:
  Type \commandf{@eps fig.1} to convert a saved {\cal PLAUT} file {\tt fig.1} 
  to encapsulated {\cal PostScript} format
  in {\tt fig.1.eps}.
\end{itemize}
In {\cal PyPLAUT} you can directly save to a variety of file
formats, including \filef{.eps} and \filef{.png}.

 
%==============================================================================
%==============================================================================
\chapter{ The Graphics Program PLAUT04.} \label{ch:PLAUT04}
%==============================================================================
%==============================================================================

% This tex file is also used by the stand-alone user guide you get
% when you ask for help in PLAUT04
\newcommand{\PLAUT} {\textsc{Plaut04}}
\newcommand{\ETC} {\textit{etc.}}
\input{plaut04_user_guide.tex}

%==============================================================================
%==============================================================================
\chapter{ The Graphical User Interface GUI94.} \label{ch:GUI}
%==============================================================================
%==============================================================================
\section{ General Overview.} \label{sec:GUI_Overview}
The {\cal AUTO} graphical user interface (GUI) is a tool
for creating and editing equations-files and constants-files;
see Section~\ref{ch:User_supplied_files}
 for a description of these files.
The GUI can also be used to run {\cal AUTO} and to manipulate and plot
output-files and data-files; 
see Section~\ref{sec:command_mode} for corresponding commands.
To use the GUI for a new equation, change to an empty work directory.
For an existing equations-file, change to its directory.
({\it Do not activate the GUI in the directory {\tt auto/07p} 
or in any of its subdirectories.})
Then type 

\centerline { @{\it auto}, }

or its abbreviation @{\it a}.
Here we assume that the {\cal AUTO} aliases have been activated; 
see Section~\ref{sec:Installation}.
The GUI includes a window for editing the equations-file,
and four groups of buttons, namely,
the {\it Menu Bar} at the top of the GUI,
the {\it Define Constants}-buttons at the center-left,
the {\it Load Constants}-buttons at the lower left,
and the {\it Stop- and Exit}-buttons.

{\bf Note :}~
Most GUI buttons are activated by point-and-click action with 
the {\it left} mouse button. 
If a beep sound results then the {\it right} mouse button must be used. 

\subsection{ The Menu bar.}
It contains the main buttons for running {\cal AUTO}
and for manipulating the equations-file, the constants-file,
the output-files, and the data-files.
In a typical application, these buttons are used from left to right.
First the {\it Equations} are defined and, if necessary, {\it Edited},
before being {\it Written}.
Then the {\cal AUTO}-constants are {\it Defined}.
This is followed by the actual {\it Run} of {\cal AUTO}.
The resulting output-files can be {\it Saved} as data-files,
or they can be {\it Appended} to existing data-files.
Data-files can be {\it Plotted} with the graphics program {\cal PLAUT},
and various file operations can be done with the {\it Files}-button.
Auxiliary functions are provided by the {\it Demos-}, {\it Misc-},
and {\it Help}-buttons.
The Menu Bar buttons are described in more detail 
in Section~\ref{sec:GUI_Menu_bar}.


\subsection{ The Define-Constants-buttons.}
These have the same function as
the {\it Define}-button on the  Menu Bar, namely to set and change
{\cal AUTO}-constants.
However, 
for the {\it Define}-button all constants appear in one panel, 
while 
for the Define Constants-buttons they
are grouped by function, 
as in Chapter~\ref{ch:AUTO_constants}, namely
{\it Problem} definition constants,
{\it Discretization} constants,
convergence {\it Tolerances},
continuation {\it Step Size},
diagram {\it Limits},
designation of free {\it Parameters},
constants defining the {\it Computation},
and
constants that specify {\it Output} options.


\subsection{ The Load-Constants-buttons.}
The {\it Previous}-button can be used to load an existing {\cal AUTO}-constants file.
Such a file is also loaded, if it exists,
by the {\it Equations}-button on the {\it Menu Bar}.
The {\it Default}-button can be used
to load  default values of all {\cal AUTO}-constants. 
Custom editing is normally necessary.


\subsection{ The Stop- and Exit-buttons.}
The {\it Stop}-button can be used to abort execution of an {\cal AUTO}-run.
This should be done only in exceptional circumstances.
Output-files, if any, will normally be incomplete and should be deleted.
Use the {\it Exit}-button to end a session.


\section{ The Menu Bar.} \label{sec:GUI_Menu_bar}
\subsection{ Equations-button.}
This pull-down menu contains the items
{\it Old}, to load an existing equations-file,
{\it New}, to load a model equations-file,
and
{\it Demo}, to load a selected demo equations-file.
Equations-file names are of the form {\tt xxx.f90}.
The corresponding constants-file {\tt c.xxx} is also loaded if it exists.
The equation name {\tt xxx} remains active until redefined.

\subsection{ Edit-button.}
This pull-down menu contains the items
{\it Cut} and {\it Copy}, 
to be performed on text in the GUI window
highlighted by click-and-drag action of the mouse,
and the item {\it Paste}, which places editor buffer text at the
location of the cursor.



\subsection{ Write-button.}
This pull-down menu contains the item
{\it Write},
to write the loaded files {\tt xxx.f90} and {\tt c.xxx},
by the active equation name,
and the item
{\it Write As}
to write these files by a selected new name, which then becomes the active name.


\subsection{ Define-button.}
Clicking this button will display the full {\cal AUTO}-constants panel.
Most of its text fields can be edited,
but some have restricted input values that can be selected with
the right mouse button.
Some text fields will display a subpanel for entering data.
To actually apply changes made in the panel, click the
{\it OK-} or {\it Apply}-button at the bottom of the panel.



\subsection{ Run-button.}
Clicking this button will write the constants-file {\tt c.xxx} and run {\cal AUTO}.
If the equations-file has been edited then it should first be rewritten 
with the {\it Write}-button. 


\subsection{ Save-button.}
This pull-down menu contains the item
{\it Save},
to save the output-files {\tt fort.7}, {\tt fort.8}, {\tt fort.9},
as {\tt b.xxx}, {\tt s.xxx}, {\tt d.xxx}, respectively.
Here {\tt xxx} is the active equation name.
It also contains the item
{\it Save As}, 
to save the output-files under another name. 
Existing data-files with the selected name, if any, will be overwritten.


\subsection{ Append-button.}
This pull-down menu contains the item
{\it Append},
to append the output-files {\tt fort.7}, {\tt fort.8}, {\tt fort.9},
to existing data-files {\tt b.xxx}, {\tt s.xxx}, {\tt d.xxx}, respectively.
Here {\tt xxx} is the active equation name.
It also contains the item
{\it Append To}, 
to append the output-files to other existing data-files.

\subsection{ Plot-button.}
This pull-down menu contains the items
{\it Plot},
to run the plotting program {\cal PLAUT} for the data-files 
{\tt b.xxx} and {\tt s.xxx},
where {\tt xxx} is the active equation name,
and the item
{\it Name}, 
to run {\cal PLAUT} with other data-files.


\subsection{ Files-button.}
This pull-down menu contains 
the item 
{\it Restart}, to redefine the restart file.
Normally, when restarting from a previously computed solution,
the restart data is expected in the file {\tt s.xxx},
where {\tt xxx} is the active equation name.
Use the {\it Restart}-button to read the restart data from another data-file
in the immediately following run.  
The pull-down menu also contains the following items~:
\begin{itemize}
\item[-]{\it Copy},~ to copy  
  {\tt b.xxx}, {\tt s.xxx}, {\tt d.xxx}, {\tt c.xxx},
  to
  {\tt b.yyy}, {\tt s.yyy}, {\tt d.yyy}, {\tt c.yyy}, resp.;

\item[-]{\it Append},~ to append data-files
  {\tt b.xxx}, {\tt s.xxx}, {\tt d.xxx},
  to
  {\tt b.yyy}, {\tt s.yyy}, {\tt d.yyy}, resp.;

\item[-]{\it Move},~ to move 
  {\tt b.xxx}, {\tt s.xxx}, {\tt d.xxx}, {\tt c.xxx},
  to
  {\tt b.yyy}, {\tt s.yyy}, {\tt d.yyy}, {\tt c.yyy}, resp.;

\item[-]{\it Delete},~ to delete data-files
  {\tt b.xxx}, {\tt s.xxx}, {\tt d.xxx};  

\item[-]{\it Clean}, to delete all files of the form 
  {\tt fort.*}, {\tt *.o}, and {\tt *.exe}.  
\end{itemize}


\subsection{ Demos-button.}
This pulldown menu contains the items
{\it Select},
to view and run a selected {\cal AUTO} demo in the demo directory,
and
{\it Reset},
to restore the demo directory to its original state.
Note that demo files can be copied to the user work directory
with the {\it Equations/Demo}-button.


\subsection{ Misc.-button.}
This pulldown menu contains the items
{\it Tek Window}
and
{\it VT102 Window},
for opening windows;
{\it Emacs}
and
{\it Xedit},
for editing files,
and
{\it Print}, for printing the active equations-file {\tt xxx.f90}.


\subsection{ Help-button.}
This pulldown menu contains the items
{\it {\cal AUTO}-constants}, for help on {\cal AUTO}-constants,
and
{\it User Manual}, for viewing the user manual; i.e., this document.


\section{ Using the GUI.} \label{sec:Using_the_GUI}
{\cal AUTO}-commands are described in Section~\ref{sec:command_mode} and
illustrated in the demos.
In Table~\ref{tbl:CM_GUI} we list the main {\cal AUTO}-commands 
together with the corresponding GUI button.

\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | l |}
\hline
\commandf{@r }  & {\it Run} \\  
\hline
\commandf{@sv }  & {\it Save}  \\ 
\hline
\commandf{@ap }  & {\it Append} \\ 
\hline
\commandf{@p }  & {\it Plot}  \\ 
\hline
\commandf{@cp }  & {\it Files/Copy}  \\ 
\hline
\commandf{@mv }  & {\it Files/Move}  \\ 
\hline
\commandf{@cl }  & {\it Files/Clean} \\ 
\hline
\commandf{@dl }  & {\it Files/Delete} \\  
\hline
\commandf{@dm }  & {\it Equations/Demo} \\  
\hline
\end{tabular}
\caption{Command Mode - GUI correspondences.}
\label{tbl:CM_GUI}
\end{center}
\end{table}


The {\cal AUTO}-command \commandf{@r xxx yyy} is given in the GUI as follows~:
click {\it Files/Restart} and enter {\it yyy} as data.
Then click {\it Run}.
As noted in Section~\ref{sec:command_mode}, 
this will run {\cal AUTO} with the current equations-file
{\tt xxx.f90} and the current constants-file {\tt c.xxx}, 
while expecting restart data in {\tt s.yyy}.
The {\cal AUTO}-command \commandf{@ap xxx yyy} is given in the GUI by
clicking {\it Files/Append}.

\section{ Customizing the GUI.} \label{sec:Customizing_the_GUI}
\subsection{ Print-button.}
The {\it Misc/Print}-button on the Menu Bar can be customized 
by editing the file {\tt GuiConsts.h} in directory {\tt auto/07p/include}.

\subsection{ GUI colors.}
GUI colors can be customized by creating an X resource file.
Two model files can be found in directory {\tt auto/07p/gui}, namely,
{\tt Xdefaults.1} and {\tt Xdefaults.2}.
To become effective, edit one of these, if desired,
and copy it to {\tt .Xdefaults} in your home directory.
Color names can often be found in the system file {\tt /usr/lib/X11/rgb.txt}.

\subsection{ On-line help.}
The file {\tt auto/07p/include/GuiGlobal.h}
contains on-line help on {\cal AUTO}-constants and demos.
The text can be updated, subject to a modifiable maximum length.
On SGI machines this is 10240 bytes,
which can be increased, for example, to 20480 bytes, 
by replacing the line
{\it CC = cc -Wf, -XNl10240 -O}
in {\tt auto/07p/gui/Makefile} by
{\it CC = cc -Wf, -XNl20480 -O}
On other machines, the maximum message length is the system defined maximum
string literal length.


%==============================================================================
%==============================================================================
\chapter{ Description of {\cal AUTO}-Constants.} \label{ch:AUTO_constants}
%==============================================================================
%==============================================================================
\section{ The {\cal AUTO}-Constants File.} \label{sec:The_AUTO_constants_file}
As described in Section~\ref{ch:User_supplied_files}, 
if the equations-file is {\tt xxx.f90} 
then the constants that define the computation 
are normally expected in the file  {\tt c.xxx}.
The format of this file is free, with constant=value pairs separated
by commas or spaces. Comments start with one of the characters  ``\#''
and ``!'', and run to the end of a line.
An example, with default values, is listed below. In real constant
files you only need to specify those values that are different from
these, but listing all of them allows for easier editing.

Note that this file is not strictly necessary when using the \python
interface: you can define all constants inside the scripts if you so wish.

\begin{verbatim}
# Default AUTO Constants file
e = '', s='', dat='', sv=''
unames = {}, parnames = {}
U = {}, PAR = {}
NDIM=   2, IPS =   1, IRS =   0, ILP =   1
ICP =  [1]
NTST=  20, NCOL=   4, IAD =   3, ISP =   2, ISW = 1, IPLT= 0, NBC= 0, NINT= 0
NMX=    0, NPR=    0, MXBF=  10, IID =   2, ITMX= 9, ITNW= 5, NWTN= 3, JAC= 0
EPSL= 1e-07, EPSU = 1e-07, EPSS = 1e-05
DS  =  0.01, DSMIN= 0.005, DSMAX=   0.1, IADS=   1
NPAR=  36, THL =  {}, THU =  {}
RL0=-1.7976e+308, RL1=1.7976e+308, A0=-1.7976e+308, A1=1.7976e+308,
UZR = {}, UZSTOP = {}, SP = [], STOP = []
IIS = 3, IBR=0, LAB=0, TY=''
NUNSTAB = -1, NSTAB = -1, IEQUIB = 1, ITWIST = 0, ISTART = 5
IREV = [], IFIXED = [], IPSI = []
\end{verbatim}

The significance of the {\cal AUTO}-constants, grouped by function, is 
described in the sections below. The HomCont constants \texttt{NUNSTAB},
\texttt{NSTAB}, \texttt{IEQUIB}, \texttt{ITWIST}, \texttt{ISTART},
\texttt{IREV}, \texttt{IFIXED}, and \texttt{IPSI} are explained in
Chapter~\ref{ch:HomCont}.
Representative demos that illustrate use of the {\cal AUTO}-constants
are also mentioned.

%=====================================================================
\section{ Problem Constants.} \label{sec:Problem_constants}
\subsection{\texttt{NDIM}} \label{sec:NDIM}
 Dimension of the system of equations as specified in the user-supplied
 routine {\tt FUNC}.

\subsection{\texttt{NBC}}  \label{sec:NBC}
 The number of boundary conditions as specified in the user-supplied
 routine {\tt BCND}. \\
(Demos {\tt exp}, {\tt kar}.)

\subsection{\texttt{NINT}}  \label{sec:NINT}
 The number of integral conditions as specified in the user-supplied
 routine {\tt ICND}. \\ 
(Demos {\tt int}, {\tt lin}, {\tt obv}.)

\subsection{\texttt{NPAR}} \label{sec:NPAR}
 Maximum parameter number that can be used in all user-supplied
 routines.

\subsection{\texttt{JAC}}  \label{sec:JAC}
 Used to indicate whether derivatives are supplied by the user
 or to be obtained by differencing~:
\begin{itemize}
\item[-] {\tt JAC=0}~: 
  No derivatives are given by the user. (Most demos use {\tt JAC}=0.)
\item[-] {\tt JAC=1}~:  
  Derivatives with respect to state- and problem-parameters are given 
  in the user-supplied routines 
  {\tt FUNC}, {\tt BCND}, {\tt ICND} and {\tt FOPT}, where 
  applicable.  This may be necessary for sensitive problems. 
  It is also recommended for computations in which {\cal AUTO} generates 
  an extended system, for example, when {\tt ISW}=2.
  (For {\tt ISW} see Section~\ref{sec:ISW}.) \\
(Demos {\tt int}, {\tt dd2}, {\tt obt}, {\tt plp}, {\tt ops}.)
\item[-] {\tt JAC=-1}~:
  As for {\tt JAC=1}, but derivatives with respect to
  problem-parameters may be omitted in {\tt FUNC}. \\
(Demo {\tt san}.)
\end{itemize}
%=====================================================================
\section{ Discretization Constants.} \label{sec:Discretization_constants}
\subsection{\texttt{NTST}}  \label{sec:NTST}
 The number of mesh intervals used for discretization.
 {\tt NTST} remains fixed during any particular run, but can be changed
 when restarting. 
 (For mesh adaption see {\tt IAD} in Section~\ref{sec:IAD}.)
 Recommended value of {\tt NTST} : As small as possible to maintain convergence. \\ 
 (Demos {\tt exp}, {\tt ab}, {\tt spb}.)


\subsection{\texttt{NCOL}}  \label{sec:NCOL}
 The number of Gauss collocation points per mesh interval,
 (2 $\le$ {\tt NCOL} $\le$ 7).
 {\tt NCOL} remains fixed during any given run, but can be changed
 when restarting at a previously computed solution.
 The choice {\tt NCOL}=4, used in most demos, is recommended.
 If {\tt NDIM} is ``large'' and the solutions ``very smooth'' then
 {\tt NCOL}=2 may be appropriate.

\subsection{\texttt{IAD}} \label{sec:IAD}
This constant controls the mesh adaption~: 
\begin{itemize}
\item[-] {\tt IAD=0}~:
  Fixed mesh. Normally, this choice should never be used, as it may result
  in spurious solutions. (Demo {\tt ext}.)
\item[-] {\tt IAD$>$0}~:  
  Adapt the mesh every {\tt IAD} steps along the family.
  Most demos use {\tt IAD=3}, which is the strongly recommended value.
\end{itemize}

When computing  ``trivial'' solutions to a boundary value problem,
for example, when all solution components are constant, then the
mesh adaption may fail under certain circumstances, and overflow may
occur. In such case, try recomputing the solution family with a fixed
mesh {\tt (IAD=0)}. Be sure to set  {\tt IAD} back to {\tt IAD=3} 
for computing eventual non-trivial bifurcating solution families.
%=====================================================================
\section{ Tolerances.} \label{sec:Tolerances}
\subsection{\texttt{EPSL}}  \label{sec:EPSL}
 Relative convergence criterion for equation parameters in the Newton/Chord 
 method. Most demos use {\tt EPSL}=$10^{-6}$ or {\tt EPSL}=$10^{-7}$,
 which is the recommended value range.

\subsection{\texttt{EPSU}}  \label{sec:EPSU}
 Relative convergence criterion for solution components in the Newton/Chord 
 method. Most demos use {\tt EPSU}=$10^{-6}$ or {\tt EPSU}=$10^{-7}$,
 which is the recommended value range.

\subsection{\texttt{EPSS}}  \label{sec:EPSS}
 Relative arclength convergence criterion for the detection of special solutions. 
 Most demos use {\tt EPSS}=$10^{-4}$ or  {\tt EPSS}=$10^{-5}$,
 which is the recommended value range.
 Generally, {\tt EPSS} should be approximately 100 to 1000 times the value
 of {\tt EPSL}, {\tt EPSU}.
 
\subsection{\texttt{ITMX}}  \label{sec:ITMX}
 The maximum number of iterations allowed in the accurate
 location of special solutions, such as bifurcations, folds, 
 and user output points, by M\"uller's method with bracketing.
 The recommended value is {\tt ITMX}=8, used in most demos.

\subsection{\texttt{NWTN}}  \label{sec:NWTN}
 After {\tt NWTN} Newton iterations the Jacobian is frozen, i.e.,
 {\cal AUTO} uses full Newton for the first {\tt NWTN} iterations
 and the Chord method for iterations {\tt NWTN}+1 to {\tt ITNW}.
 The choice {\tt NWTN}=3 is strongly recommended and used in most demos.
 Note that this constant is only effective for ODEs, i.e., for solving
 the piecewise polynomial collocation equations.
 For algebraic systems {\cal AUTO} always uses full Newton.

\subsection{\texttt{ITNW}}  \label{sec:ITNW}
 The maximum number of combined Newton-Chord iterations.
 When this maximum is reached, the step will be retried with 
 half the stepsize.
 This is repeated until convergence, or until the minimum
 stepsize is reached. In the latter case the computation of
 the family is discontinued and a message printed in {\tt fort.9}.
 The recommended value is {\tt ITNW}=5, but {\tt ITNW}=7 may be used for 
 ``difficult'' problems, for example, 
 demos {\tt spb}, {\tt chu}, {\tt plp}, etc.

%=====================================================================
\section{ Continuation Step Size.} \label{sec:step_size}
\subsection{\texttt{DS}}  \label{sec:DS}
 {\cal AUTO} uses pseudo-arclength continuation for following solution families.
 The pseudo-arclength stepsize is the distance between
 the current solution and the next solution on a family.
 By default, this distance includes all state variables
 (or state functions) and all free parameters.
 The constant {\tt DS} defines the pseudo-arclength stepsize to be used for the
 first attempted step along any family. 
 (Note that if {\tt IADS}$>$0 then {\tt DS} will automatically be adapted
 for subsequent steps and for failed steps.)
 {\tt DS} may be chosen positive or negative; changing its sign 
 reverses the direction of computation.
 The relation {\tt DSMIN} $\le$ $\abs {\tt DS}$ $\le$ {\tt DSMAX} must be satisfied.
 The precise choice of {\tt DS} is problem-dependent; the demos use a value 
 that was found appropriate after some experimentation.
 

\subsection{\texttt{DSMIN}}  \label{sec:DSMIN}
 This is minimum allowable absolute value of the pseudo-arclength 
 stepsize. {\tt DSMIN} must be positive.
 It is only effective if the pseudo-arclength step is adaptive,
 i.e., if {\tt IADS}$>$0.
 The choice of {\tt DSMIN} is highly problem-dependent;
 most demos use a value that was found appropriate after some
 experimentation.
 See also the discussion in Section~\ref{sec:Efficiency}.

\subsection{\texttt{DSMAX}}  \label{sec:DSMAX}
 The maximum allowable absolute value of the pseudo-arclength stepsize.
 {\tt DSMAX} must be positive.
 It is only effective if the pseudo-arclength step is adaptive,
 i.e., if {\tt IADS}$>$0.
 The choice of {\tt DSMAX} is highly problem-dependent; 
 most demos use a value that was found appropriate after some
 experimentation.
 See also the discussion in Section~\ref{sec:Efficiency}.

\subsection{\texttt{IADS}}  \label{sec:IADS}
This constant controls the frequency of adaption of the 
pseudo-arclength stepsize.
\begin{itemize}
\item[-] {\tt IADS=0}~: 
  Use fixed pseudo-arclength stepsize, i.e., the stepsize will
  be equal to the specified value of {\tt DS} for every step.
  The computation of a family will be discontinued as soon as
  the maximum number of iterations {\tt ITNW} is reached.
  This choice is not recommended. \\(Demo {\tt tim}.)
\item[-] {\tt IADS$>$0}~:  
 Adapt the pseudo-arclength stepsize after every {\tt IADS} steps.
  If the Newton/Chord iteration converges rapidly then 
  $\abs{\tt DS}$ will be increased, but never beyond {\tt DSMAX}.
  If a step fails then it will be retried with half
  the stepsize. This will be done repeatedly until the
  step is successful or until $\abs{\tt DS}$ reaches {\tt DSMIN}. 
  In the latter case nonconvergence will be signalled.
  The strongly recommended value is {\tt IADS}=1, which is used in 
  almost all demos.
\end{itemize}
  
\subsection{\texttt{THL}}  \label{sec:THL}
By default, the pseudo-arclength stepsize includes all state variables
(or state functions) and all free parameters.
Under certain circumstances one may want to modify the weight accorded 
to individual parameters in the definition of stepsize.
For this purpose, {\tt THL} defines the parameters whose weight 
is to be modified.
If {\tt THL=\{\}} then all weights will have default value 1.0,
else one must enter pairs,
             ~\{{\it Parameter Index} : {\it Weight}, ...\}~.

For example, for the computation of periodic solutions it is 
recommended that the period not be included in the pseudo-arclength 
continuation stepsize, in order to avoid period-induced limitations 
on the stepsize near orbits of infinite period. 
This exclusion can be accomplished by setting {\tt THL=\{11:0.0\}}.
If {\tt THL} is not specified this is the default for computing
periodic solutions ({\tt IPS=2}).
Most demos that compute periodic solutions use this option;
see for example demo {\tt ab}.

\subsection{\texttt{THU}}  \label{sec:THU}
Under certain circumstances one may want to modify the weight accorded 
to individual state variables (or state functions) in the definition 
of stepsize.
For this purpose, {\tt THU} defines the number of states whose weight 
is to be modified.
If {\tt THU}=\{\} then all weights will have default value 1.0,
else one must enter pairs,
             ~\{{\it State Index} : {\it Weight}, ...\}~.
At present none of the demos use this option.
%=====================================================================
\section{ Diagram Limits.} \label{sec:Diagram_limits}

There are five ways to limit the computation of a family~:

\begin{itemize}
\item[-]
By specifying a stopping condition in the list associated 
with the constant {\tt STOP}; see Section~\ref{sec:STOP}. 

\item[-]
By specifying parameters and parameter values in the list associated 
with the constant {\tt UZSTOP}; see Section~\ref{sec:UZSTOP}.

\item[-]
By specifying the maximum number of steps, {\tt NMX}.

\item[-]
By specifying a negative parameter index in the list associated 
with the constant {\tt UZR}; see Section~\ref{sec:UZR}. 

\item[-]
By appropriate choice of the computational window 
defined by the constants {\tt RL0}, {\tt RL1}, {\tt A0}, and {\tt A1}.
One should always check that the starting solution lies within
this computational window, otherwise the computation will stop immediately
at the starting point. Most demos do not specify these constants, and
use an unbounded window.
\end{itemize}

\subsection{\texttt{STOP}}  \label{sec:STOP}
This constant adds stopping conditions. It is specified as a list of
bifurcation type strings followed by a number $n$ greater than zero.
These strings specify that the contination should stop as soon as the $n$th
bifurcation of the associated type has been reached.
Example:\\
\begin{description}
\item[\parf{STOP=['HB3','UZ3']}]
Stop at the third Hopf bifurcation or third user defined point (see
Section~\ref{sec:UZR}), whichever comes first.
\end{description}

\subsection{\texttt{NMX}} \label{sec:NMX}
The maximum number of steps to be taken along any family.

\subsection{\texttt{RL0}}  \label{sec:RL0}
 The lower bound on the principal continuation parameter.
 (This is the parameter which appears first in the {\tt ICP} list;
 see Section~\ref{sec:ICP}.). 

\subsection{\texttt{RL1}}  \label{sec:RL1}
 The upper bound on the principal continuation parameter. 

\subsection{\texttt{A0}}  \label{sec:A0}
 The lower bound on the principal solution measure.
 (By default, if {\tt IPLT}=0, the principal solution measure
 is the $L_2$-norm of the state vector or state vector function.
 See the {\cal AUTO}-constant {\tt IPLT} in Section~\ref{sec:IPLT} 
 for choosing another principal solution measure.)

\subsection{\texttt{A1}}  \label{sec:A1}
 The upper bound on the principal solution measure.

%=====================================================================
%=====================================================================
\section{ Free Parameters.} \label{sec:Free_parameters}


\subsection{\texttt{ICP}}  \label{sec:ICP}
For each equation type and for each continuation calculation there is
a typical (``generic'') number of problem parameters that must be 
allowed to vary, in order for the calculations to be properly posed.
The array {\tt ICP} designates these free parameters.
The parameter that appears first in the {\tt ICP} list is called the 
``principal continuation parameter''.
Specific examples and special cases are described below.

%=====================================================================
\subsection{ Fixed points.}
The simplest case is the continuation of a solution family to the system
$ f( u , p ) = 0$,  where $f(\cdot,\cdot), u \in \Rn$, cf. Equation~(\ref{1}).
Such a system arises in the continuation of ODE stationary solutions and 
in the continuation of fixed points of discrete dynamical systems.
There is only one free parameter here.

As a concrete example, consider Run~1 of demo {\tt ab},
where {\tt ICP=[1]}. 
Thus, in this run {\tt PAR(1)} is designated as the free parameter.

%=====================================================================
\subsection{ Periodic solutions and rotations.}
The continuation of periodic solutions and rotations generically requires 
two parameters, namely, one problem parameter and the period.
For example, in Run~2 of demo {\tt ab} we have {\tt ICP=[1,11]}.
Thus, in this run, the free parameters are {\tt PAR(1)} and {\tt PAR(11)}.
(Note that {\cal AUTO} reserves {\tt PAR(11)} for the period.)

Actually, for periodic solutions, it is sufficient to only specify 
the index of the free problem parameter, as {\cal AUTO} will automatically 
add {\tt PAR(11)}.
However, in this case the period will not appear in the screen output 
and in the {\tt fort.7} output-file. 

For fixed period orbits one must specify two free problem 
parameters.
For example, in Run~7 of demo {\tt pp2}, we have {\tt ICP=[1,2]}, with 
{\tt PAR(1)} and {\tt PAR(2)}
specified as free problem parameters.
The period {\tt PAR(11)} is fixed in this run.
If the period is large then such a continuation provides a simple and 
effective method for computing a locus of homoclinic orbits.
%=====================================================================
\subsection{ Folds and Hopf bifurcations.}
The continuation of folds for algebraic problems and the continuation of
Hopf bifurcations requires two free problem parameters.
For example, to continue a fold in Run~3 of demo {\tt ab}, we have {\tt ICP=[1,3]}, 
with {\tt PAR(1)} and {\tt PAR(3)} specified as free parameters.
Note that one must set {\tt ISW}=2 for computing such loci of special solutions.
Also note that in the continuation of folds the principal continuation parameter
must be the one with respect to which the fold was located.

%=====================================================================
\subsection{ Folds and period-doublings.}
The continuation of folds, for periodic orbits and rotations,
and the continuation of period-doubling and torus bifurcations require two free 
problem parameters plus the free period. Thus, one would normally
specify three parameters.
For example, in Run~6 of demo {\tt pen}, where a locus of period-doubling
bifurcations is computed for rotations, we have {\tt ICP=[2,3,11]}, 
with {\tt PAR(2)}, {\tt PAR(3)}, and {\tt PAR(11)} specified as free parameters. 
Note that one must set {\tt ISW}=2 for computing such loci of special solutions.
Also note that in the continuation of folds the principal continuation parameter
must be the one with respect to which the fold was located.

Actually, one may only specify the problem parameters,
as {\cal AUTO} will automatically add the period.
For example, in Run~3 of demo {\tt plp}, where a locus of folds is computed 
for periodic orbits, we have {\tt ICP=[4,1]}, with {\tt PAR(4)} and {\tt PAR(1)} specified
as free parameters. 
However, in this case the period will not appear in the screen output 
and in the {\tt fort.7} output-file. 

To continue a locus of folds, period-doubling or torus bifurcations
with fixed period, simply
specify three problem parameters, not including {\tt PAR(11)}.
For torus bifurcations it is also possible to specify
four problem parameters (possibly including {\tt PAR(11)}). In that
case the angle of the torus ({\tt PAR(12)}) stays fixed.

%=====================================================================
\subsection{ Boundary value problems.}
The simplest case is that of boundary value problems where 
{\tt NDIM}={\tt NBC} 
and where {\tt NINT}=0.
Then, generically, one free problem parameter is required for computing 
a solution family.
For example, in demo {\tt exp}, we have {\tt NDIM}={\tt NBC}=2, {\tt NINT}=0. 
Thus, in this demo one free parameter is designated,
namely {\tt PAR(1)}.

More generally, for boundary value problems with integral constraints,
the generic number of free parameters is {\tt NBC} + {\tt NINT}$-${\tt NDIM} +1.
For example, in demo {\tt lin}, we have {\tt NDIM}=2, {\tt NBC}=2, and {\tt NINT}=1.
Thus {\tt ICP=[1,3]}. 
Indeed, in this demo two free parameters are designated,
namely {\tt PAR(1)} and {\tt PAR(3)}.

%=====================================================================
\subsection{ Boundary value folds.}
To continue a locus of folds for a general boundary value problem
with integral constraints, set {\tt \#ICP}={\tt NBC}+{\tt NINT}$-${\tt NDIM}+2, 
and specify this number of parameter indices to designate the free parameters.

%=====================================================================
\subsection{ Optimization problems.}
In algebraic optimization problems one must set {\tt ICP}(1)=10, 
as {\cal AUTO} uses {\tt PAR(10)} as principal continuation parameter
to monitor the value of the objective function.
Furthermore, one must designate one free equation parameter in {\tt ICP}(2). 
Thus, {\tt ICP=[10,2]} in the first run.

Folds with respect to {\tt PAR(10)} correspond to extrema of the objective function.
In a second run one can restart at such a fold, with an additional
free equation parameter specified in {\tt ICP}(3).
Thus, {\tt ICP=[10,2,3]} in the second run.

The above procedure can be repeated.
For example, folds from the second run can be continued in a third run
with three equation parameters specified in addition to {\tt PAR(10)}.
Thus, {\tt \#ICP=4} in the third run.

For a simple example see demo {\tt opt}, where a four-parameter extremum
is located.
Note that {\tt \#ICP=5} in each of the four constants-files of this demo, 
with the indices of {\tt PAR(10)} and {\tt PAR(1)-PAR(4)} specified in {\tt ICP}.
Thus, in the first three runs, there are overspecified parameters.
However, {\cal AUTO} will always use the correct number of parameters.
Although the overspecified parameters will be printed, their values will
remain fixed. 

%=====================================================================
\subsection{ Internal free parameters.}
The actual continuation scheme in {\cal AUTO} may use additional free
parameters that are automatically added.
The simplest example is the computation of periodic solutions and rotations,
where {\cal AUTO} automatically puts the period, if not specified, in
\parf{PAR(11)}.
The computation of loci of folds, Hopf bifurcations, and period-doublings
also requires additional internal continuation parameters.
These will be automatically added, and their indices will be greater
than \parf{NPAR}.
Other use depends on \parf{IPS}: see Section~\ref{sec:Restrictions_on_PAR}.

%=====================================================================
\subsection{ Parameter overspecification.} \label{sec:Parameter_over_specification}
The number of specified parameter indices is allowed to be be greater 
than the generic number.
In such case there will be ``overspecified'' parameters, whose values
will appear in the screen and {\tt fort.7} output, but which are not
part of the continuation process.
A simple example is provided by demo {\tt opt}, where the first three runs
have overspecified parameters whose values, although constant, are printed.

There is, however, a more useful application of parameter overspecification.
In the user-supplied routine {\tt PVLS} one can define solution measures
and assign these to otherwise unused parameters.
Such parameters can then be overspecified, in order to print them
on the screen and in the {\tt fort.7} output.
It is important to note that such overspecified parameters must appear
at the end of the {\tt ICP} list, as they cannot be used as true continuation
parameters.

For an example of using parameter overspecification for printing user-defined
solution measures, see demo {\tt pvl}.
This is a boundary value problem (Bratu's equation) which has
only one true continuation parameter, namely {\tt PAR(1)}.
Three solution measures are defined in the routine {\tt PVLS}, namely,
the $L_2$-norm of the first solution component,
the minimum of the second component, and
the left boundary value of the second component.
These solution measures are assigned to {\tt PAR(2), PAR(3), PAR(4)},
and {\tt PAR(5)}, respectively.
In the constants-file {\tt c.pvl} we have {\tt \#ICP=5},
with {\tt PAR(1)-PAR(5)} specified as parameters.
Thus, in this example, {\tt PAR(2)-PAR(5)} are overspecified.
Note that {\tt PAR(1)} must appear first in the {\tt ICP} list;
the other parameters cannot be used as true continuation parameters.
%=====================================================================
%=====================================================================
\section{ Computation Constants.} \label{sec:Computation_constants}
\subsection{\texttt{ILP}}  \label{sec:ILP}
\begin{itemize}
\item[-] {\tt ILP=0}~: 
  No detection of folds. This choice is recommended.
\item[-] {\tt ILP=1}~: 
  Detection of folds. To be used if subsequent fold continuation is intended.
\end{itemize}

\subsection{\texttt{SP}}  \label{sec:SP}
This constant controls the detection of bifurcations and adds stopping
conditions. It is specified as a list of bifurcation type strings
followed by an optional number. If this number is 0, then the detection
of this bifurcation is turned off, and if it is missing
then the detection is turned on. A number $n$ greater than zero
specifies that the contination should stop as soon as the $n$th
bifurcation of this type has been reached.
Examples:\\
\begin{itemize}
\item[-] {\tt SP=['LP0']}\\
turn off detection of folds.
\item[-] {\tt SP=['LP','HB3','BP0','UZ3']}\\
turn on the detection of folds and Hopf bifurcations,
turn off detection of branch points and stop at the third Hopf
bifurcation or third user defined point, whichever comes first.
\end{itemize}
 
\subsection{\texttt{ISP}}  \label{sec:ISP}
This constant controls the detection of Hopf bifurcations,
branch points, period-doubling bifurcations, and torus bifurcations. 
\begin{itemize}
\item[-] {\tt ISP=0}~:  
  This setting disables the detection of Hopf bifurcations,
  branch points, period-doubling 
  bifurcations, and torus bifurcations and the computation of 
  Floquet multipliers.
\item[-] {\tt ISP=1}~:  
  Branch points and Hopf bifurcations are detected for algebraic
  equations. Branch points, period-doubling bifurcations and torus
  bifurcations are not detected for periodic solutions and boundary
  value problems. However, Floquet multipliers are computed.
\item[-] {\tt ISP=2}~: This setting enables the detection of all special 
 solutions.
 For periodic solutions and rotations, the choice {\tt ISP}=2 should be used with
 care, due to potential inaccuracy in the computation of the
 linearized Poincar\'e map and possible rapid variation of the
 Floquet multipliers.
 The linearized Poincar\'e map always has a multiplier $z=1$.
 If this multiplier becomes inaccurate
 then the automatic detection of secondary periodic
 bifurcations will be discontinued and a
 warning message will be printed in {\tt fort.9}.
 See also Section~\ref{sec:Bifurcations}.
\item[-] {\tt ISP=3}~:  
  Hopf bifurcations will not be detected. 
  Branch points will be detected, and {\cal AUTO} will monitor the 
  Floquet multipliers. Period-doubling and torus bifurcations will go undetected. 
  This option is useful for certain problems with non-generic Floquet behavior.
\item[-] {\tt ISP=4}~:  
  Branch points and Hopf bifurcations are detected for algebraic
  equations. Branch points are not detected for
  periodic solutions and boundary value problems.
  {\cal AUTO} will monitor the Floquet multipliers, and period-doubling
  and torus bifurcations will be detected.
\end{itemize}

\subsection{\texttt{ISW}}  \label{sec:ISW}
 This constant controls branch switching at branch points for the case
 of differential equations.
 Note that branch switching is automatic for algebraic equations.
\begin{itemize}
\item[-] {\tt ISW=1}~: This is the normal value of {\tt ISW}.
\item[-] {\tt ISW=$-$1}~:
  If {\tt IRS} is the label of a branch point or a period-doubling
  bifurcation then branch switching will be done.
  For period doubling bifurcations it is recommended that {\tt NTST} be increased.
  For examples see Run~2 and Run~3 of demo {\tt lor}, where branch switching
  is done at period-doubling bifurcations, and Run~2 and Run~3 of demo {\tt bvp},
  where branch switching is done at a transcritical branch point.
\item[-] {\tt ISW=2}~:
  If {\tt IRS} is the label of a fold, a Hopf bifurcation point, 
  a period-doubling, a torus bifurcation, or, in a non-generic
  (symmetric) system, a branch point then a locus of such points will be
  computed. An additional free parameter must be specified for such 
  continuations; see also Section~\ref{sec:Free_parameters}.
\item[-] {\tt ISW=3}~:
  If {\tt IRS} is the label of a branch point in a generic
  (non-symmetric) system then a locus of such points will be
  computed. Two additional free parameters must be specified for such 
  continuations; see also Section~\ref{sec:Free_parameters}.
\end{itemize}

\subsection{\texttt{MXBF}}  \label{sec:MXBF}
 This constant, which is effective for algebraic problems only,
 sets the maximum number of bifurcations to be treated.
 Additional branch points will be noted, but the corresponding bifurcating
 families will not be computed.
 If {\tt MXBF} is positive then the bifurcating families of the first {\tt MXBF}
  branch points will be traced out in both directions.
 If {\tt MXBF} is negative then the bifurcating families of the first 
 $\abs{{\tt MXBF}}$ branch points will be traced out in only one direction. 

\subsection{\texttt{s}}  \label{sec:s}
This constant sets the name of the solution file from which the computation
is to be restarted, instead of \filef{fort.3}: if {\tt s='xxx'} then the
name of the restart file is \filef{s.xxx}.

\subsection{\texttt{dat}}  \label{sec:dat}
This constant, where {\tt dat='xxx'}, sets the name of a user-supplied ASCII
data file {\tt xxx.dat}, from which the contination is to be restarted.
{\cal AUTO} automatically sets the period in {\tt PAR(11)}.
Other parameter values must be set in {\tt STPNT}. (When necessary,
{\tt PAR(11)} may also be redefined there.) 

The first column in the data file denotes the time, which does
\emph{not} need to be rescaled to the interval $[0,1]$, and further
columns the coordinates of the solution. The constant {\tt IRS} must
be set to 0.

(Demos {\tt lor}, {\tt pen}.)

\subsection{\texttt{U}}  \label{sec:U}
This constant, where {\tt U=\{i1:x1,i2:x2\}}, changes the value of
{\tt U(i1)} to {\tt x1}, {\tt U(i2)} to {\tt x2}, and so on,
with respect to the solution to start from. This is only
valid for restarting from algebraic problems or a constant-in-time
solution.

\subsection{\texttt{PAR}}  \label{sec:PAR}
This constant, where {\tt PAR=\{i1:x1,i2:x2\}}, changes the value of
{\tt PAR(i1)}  to {\tt x1}, {\tt PAR(i2)} to
{\tt x2}, and so on, with respect to the solution to start from.

\subsection{\texttt{IRS}}  \label{sec:IRS}
This constant sets the label of the solution where the computation
is to be restarted.
\begin{itemize}
\item[-] {\tt IRS=0}~:  
  This setting is typically used in the first run of a new problem.
  In this case a starting solution must be defined in the user-supplied
  routine {\tt STPNT}.
  For representative examples of analytical starting solutions 
  see demos {\tt ab} and {\tt frc}.
  For starting from unlabeled numerical data see the {\tt dat} command
  above, and demos {\tt lor} and {\tt pen}.
  
\item[-] {\tt IRS$>$0}~: 
  Restart the computation at the previously computed solution with label {\tt IRS}. 
  This solution is normally expected to be in the current data-file 
 {\tt s.xxx}; see also the \commandf{@r} and \commandf{@R} commands in 
 Section~\ref{sec:command_mode}.
 Various {\cal AUTO}-constants can be modified when restarting.

\item[-] {\tt IRS$<$0}~:
  Restart the computation at the -IRSth computed solution in the
  restart file. This is especially useful if you do not want to look
  up label numbers and know for sure that the solution to continue
  from is at a fixed position.
\item[-] {\tt IRS='XYn'}~:
  Restart the computation at the nth label of type XY in the
  restart file, for instance 'HB12' to restart at the twelfth Hopf
  bifurcation.
\end{itemize}

\subsection{\texttt{TY}} \label{sec:TY} 
 This constant modifies the type from the restart solution.
 This is sometimes useful in conservative or extended systems,
 declaring a regular point to be a Hopf bifurcation point ({\tt TY='HB'}) or a
 branch point ({\tt TY='BP'}). Use {\tt TY='HB4'} to copy the period
 of the emanating periodic orbit from {\tt PAR(4)} (for example set in
 the routine {\tt PVLS} in the equations file) to {\tt PAR(11)}.
 (Demo {\tt r3b}.)

\subsection{\texttt{IPS}}  \label{sec:IPS}
This constant defines the problem type~:
\begin{itemize}
%=====================================================================
\item[-] {\tt IPS=0}~: 
  An algebraic bifurcation problem.
  Hopf bifurcations will not be detected and stability
  properties will not be indicated in the {\tt fort.7} output-file.
%=====================================================================
\item[-] {\tt IPS=1}~: 
  Stationary solutions of ODEs with detection of Hopf bifurcations.
  The sign of PT, the point number, in {\tt fort.7} is used 
  to indicate stability~: $-$ is stable , + is unstable.\\
 (Demo {\tt ab}.)
%=====================================================================
\item[-] {\tt IPS=$-$1}~:  
  Fixed points of the discrete dynamical system
  $u^{(k+1)}=f(u^{(k)},p ),$ with detection of Hopf bifurcations.
  The sign of PT in {\tt fort.7} indicates stability~: 
  $-$ is stable , + is unstable.  
 (Demo {\tt dd2}.)
%=====================================================================
\item[-] {\tt IPS=$-$2}~: 
  Time integration using implicit Euler. 
  The {\cal AUTO}-constants {\tt DS}, {\tt DSMIN}, {\tt DSMAX}, and {\tt ITNW}, {\tt NWTN} control 
  the stepsize.
  In fact, pseudo-arclength is used for ``continuation in time''. 
  Note that the time discretization is only first order accurate, 
  so that results should be carefully interpreted. 
  Indeed, this option has been included primarily for the detection 
  of stationary solutions, which can then be entered in the user-supplied
  routine {\tt STPNT}.  \\  
 (Demo {\tt ivp}.)
%=====================================================================
\item[-]  {\tt IPS=2}~:
  Computation of periodic solutions. Starting data can be
  a Hopf bifurcation point (Run~2 of demo {\tt ab}),
  a periodic orbit from a previous run (Run~4 of demo {\tt pp2}),
  an analytically known periodic orbit (Run~1 of demo {\tt frc}),
  or a numerically known periodic orbit (Demo {\tt lor}).
  The sign of PT in {\tt fort.7} is used to indicate
  stability~: $-$ is stable , + is unstable or unknown.
%=====================================================================
\item[-] {\tt IPS=4}~: 
  A boundary value problem. Boundary conditions must be
  specified in the user-supplied routine {\tt BCND}
  and integral constraints in {\tt ICND}. The {\cal AUTO}-constants
  {\tt NBC} and {\tt NINT} must be given correct values.
 (Demos {\tt exp}, {\tt int}, {\tt kar}.)
%=====================================================================
\item[-] {\tt IPS=5}~:
  Algebraic optimization problems. The objective function
  must be specified in the user-supplied routine {\tt FOPT}. 
 (Demo {\tt opt}.)
%=====================================================================
\item[-] {\tt IPS=7}~:
  A boundary value problem with computation of Floquet multipliers. 
  This is a very special option; for most boundary value problems 
  one should use {\tt IPS=4}.
  Boundary conditions must be
  specified in the user-supplied routine {\tt BCND}
  and integral constraints in {\tt ICND}. The {\cal AUTO}-constants
  {\tt NBC} and {\tt NINT} must be given correct values.
%=====================================================================
\item[-] {\tt IPS=9}~:
  This option is used in connection with the {\cal HomCont} algorithms
  described in 
  Chapters~\ref{ch:HomCont}-\ref{ch:HomCont_rev}
  for the  detection and continuation of homoclinic bifurcations.\\  
 (Demos {\tt san}, {\tt mtn}, {\tt kpr}, {\tt cir}, {\tt she},
  {\tt rev}.)
%=====================================================================
\item[-] {\tt IPS=11}~: 
  Spatially uniform solutions of a system of parabolic PDEs,
  with detection of traveling wave bifurcations.
  The user need only define the nonlinearity (in routine {\tt FUNC}),
  initialize the wave speed in {\tt PAR(10)}, initialize the diffusion 
  constants in {\tt PAR(15,16,$\cdots$)}, and set a free equation parameter 
  in {\tt ICP}(1).
  (Run~2 of demo {\tt wav}.)
%=====================================================================
\item[-] {\tt IPS=12}~: 
  Continuation of traveling wave solutions to a system of parabolic PDEs.
  Starting data can be a Hopf bifurcation point from a previous run 
  with {\tt IPS}=11, or a traveling wave from a previous run with {\tt IPS}=12.
  (Run~3  and Run~4 of demo {\tt wav}.)
%=====================================================================
\item[-] {\tt IPS=14}~:  
  Time evolution for a system of parabolic PDEs subject to periodic 
  boundary conditions. 
  Starting data may be solutions from a previous run with {\tt IPS}=12 or 14. 
  Starting data can also be specified in {\tt STPNT}, in which case
  the wave length must be specified in {\tt PAR(11)}, and the diffusion
  constants in {\tt PAR(15,16,$\cdots$)}.
  {\cal AUTO} uses {\tt PAR(14)} for the time variable.
  {\tt DS}, {\tt DSMIN}, and {\tt DSMAX} govern the pseudo-arclength continuation 
  in the space-time variables.
  Note that the time discretization is only first order accurate, 
  so that results should be carefully interpreted. 
  Indeed, this option is mainly intended for the detection of stationary 
  waves.
  (Run~5 of demo {\tt wav}.)
%=====================================================================
\item[-] {\tt IPS=15}~:   
  Optimization of periodic solutions. The integrand of the
  objective functional must be specified in the user supplied
  routine {\tt FOPT}. Only {\tt PAR(1-9)} should be used for
  problem parameters. {\tt PAR(10)} is the value of the objective
  functional, {\tt PAR(11)} the period, {\tt PAR(12)} the norm of the
  adjoint variables, {\tt PAR(14)} and {\tt PAR(15)} are internal optimality
  variables. {\tt PAR(21-29)} and {\tt PAR(31)} are used to monitor the 
  optimality functionals associated with the problem parameters 
  and the period. 
  Computations can be started at a solution computed with {\tt IPS}=2
  or {\tt IPS}=15.
  For a detailed example see demo {\tt ops}.
%=====================================================================
\item[-] {\tt IPS=16}~:
  This option is similar to {\tt IPS}=14, except that the user supplies the
  boundary conditions. Thus this option can be used for 
  time-integration of parabolic systems subject to 
  user-defined boundary conditions. For examples see the first runs
  of demos {\tt pd1}, {\tt pd2}, and {\tt bru}. Note that
  the space-derivatives of the initial conditions must
  also be supplied in the user supplied routine {\tt STPNT}. 
  The initial conditions must satisfy the boundary conditions.
  This option is mainly intended for the detecting stationary solutions.
%=====================================================================
 \item[-] {\tt IPS=17}~: 
  This option can be used to continue stationary solutions
  of parabolic systems obtained from an evolution run with {\tt IPS}=16.
  For examples see the second runs of demos {\tt pd1} and {\tt pd2}.
\end{itemize}
%=====================================================================


\section{ Output Control.} \label{sec:Output_control}
\subsection{\texttt{unames}}  \label{sec:unames}
This constant, where {\tt unames=\{i1:s1,i2:s2\}}, changes the names in all
output from {\tt U(i1)} to {\tt s1}, from {\tt U(i2)} to {\tt s2}, and so on.
You can also refer to these strings, instead of the corresponding indices,
in the constants \texttt{U} and \texttt{THU}.

\subsection{\texttt{parnames}}  \label{sec:parnames}
This constant, where {\tt parnames=\{i1:s1,i2:s2\}}, changes the names in all
output from {\tt PAR(i1)} to {\tt s1}, from {\tt PAR(i2)} to {\tt s2},
and so on.
You can also refer to these strings, instead of the corresponding indices,
in the constants \texttt{ICP}, \texttt{THL}, and \texttt{UZR}.

\subsection{\texttt{e}}  \label{sec:e}
This constant, where {\tt e='xxx'}, is only for use by post-processors:
it denotes the name of the equations file and is stored
in the bifurcation diagram file (\filef{fort.7}), so restarts in the
Python interface are possible without needing to specify the equations
file.

\subsection{\texttt{sv}} \label{sec:sv}
This constant specifies a string to write the output to instead of
{\tt fort.7}, {\tt fort.8}, and {\tt fort.9}: if {\tt sv='xxx'}, then
the output files are
{\tt b.xxx}, {\tt s.xxx}, and {\tt d.xxx}.

\subsection{\texttt{NPR}}  \label{sec:NPR}
 This constant can be used to regularly write {\tt fort.8} plotting and restart 
 data.  
 IF {\tt NPR}$>$0 then such output is written every {\tt NPR} steps.
 IF {\tt NPR}$=$0 or if {\tt NPR}$\ge${\tt NMX} then no such output is written.
 Note that special solutions, such as branch points, folds, end points, etc., 
 are always written in {\tt fort.8}.
 Furthermore, one can specify parameter values where plotting and restart 
 data is to be written; see Section~\ref{sec:UZR}.
 For these reasons, and to limit the output volume, it is recommended that
 {\tt NPR} output be kept to a minimum.

\subsection{\texttt{IBR}} \label{sec:IBR} 
 This constant specifies the initial branch number {\tt BR} that is
 used. The default {\tt IBR=0} means that that this number is
 determined automatically.

\subsection{\texttt{LAB}} \label{sec:LAB} 
 This constant specifies the initial label number {\tt LAB} that is
 used. The default {\tt LAB=0} means that that this number is
 determined automatically. Using {\tt LAB=1} means you do not need
 to relabel after a non-appended continuation if this is desired.

\subsection{\texttt{IIS}} \label{sec:IIS} 
 This constant controls the amount of information printed in {\tt fort.8}~:
 the greater {\tt IIS} the more solutions contain the corresponding
 vector giving the direction of the branch. The direction of the
 branch is necessary for restart points when switching branches, but
 make the solution file almost two times bigger than necessary when
 switching branches is never performed from solutions in this file.

\begin{itemize}
\item[-] {\tt IIS=0}~:
  The direction of the branch is never provided.
\item[-] {\tt IIS=1}~:
  The direction of the branch is only provided at special points from
  which branch switching can be performed (types LP (boundary value
  problems only), BP, PD, TR).
\item[-] {\tt IIS=2}~:
  The direction of the branch is provided at all special points but
  not at regular points without a type label.
\item[-] {\tt IIS=3}~:
  The direction of the branch is always provided. This is the default
  setting.
\end{itemize}

\subsection{\texttt{IID}} \label{sec:IID} 
 This constant controls the amount of diagnostic output printed in {\tt fort.9}~:
 the greater {\tt IID} the more detailed the diagnostic output.
\begin{itemize}
\item[-] {\tt IID=0}~:  
  No diagnostic output.
\item[-] {\tt IID=1}~:  
  Minimal diagnostic output. This setting is not recommended.
\item[-] {\tt IID=2}~: 
  Regular diagnostic output. This is the recommended value of {\tt IID}.
\item[-] {\tt IID=3}~: 
  This setting gives additional diagnostic output for algebraic equations,
  namely the Jacobian and the residual vector at the starting point.
  This information, which is printed at the beginning of {\tt fort.9},
  is useful for verifying whether the starting solution in {\tt STPNT} is indeed 
  a solution.
\item[-] {\tt IID=4}~: 
  This setting gives additional diagnostic output for differential equations,
  namely the reduced system and the associated residual vector. 
  This information is printed for every step and for every Newton iteration,
  and should normally be suppressed.
  In particular it can be used to verify whether the starting solution
  is indeed a solution. For this purpose, the stepsize {\tt DS} should
  be small, and one should look at the residuals printed in the {\tt fort.9}
  output-file. (Note that the first residual vector printed in {\tt fort.9} may
  be identically zero, as it may correspond to the computation of the starting
  direction. Look at the second residual vector in such case.)
  This residual vector has dimension 
  {\tt NDIM}+{\tt NBC}+{\tt NINT}+1, which accounts for the {\tt NDIM}
  differential equations, the {\tt NBC} boundary conditions, the {\tt NINT} user-defined
  integral constraints, and the pseudo-arclength equation.
  For proper interpretations of these data one may want to refer to the solution
  algorithm for solving the collocation system, as described in
  \citename{DoKeKe:91b} \citeyear{DoKeKe:91b}.
\item[-] {\tt IID=5}~:
  This setting gives very extensive diagnostic output for differential equations,
  namely, debug output from the linear equation solver.
  This setting should not normally be used as it may result
  in a huge {\tt fort.9} file. It gives incomplete results when
  used in combination with MPI parallellization.
\end{itemize}

\subsection{\texttt{IPLT}}  \label{sec:IPLT}
 This constant allows redefinition of the principal solution measure, which is
 printed as the second (real) column in the screen output and in the {\tt fort.7}
 output-file~:
 
\begin{itemize}
\item[-]
  If {\tt IPLT} = 0 then the $L_2$-norm is printed. Most demos use this setting.
  For algebraic problems, the standard definition of $L_2$-norm is used.
  For differential equations, the $L_2$-norm is defined as 
  $$ \sqrt{ \int_0^1 \sum_{k=1}^{NDIM} U_k(x)^2 ~ dx}~.$$
  Note that the interval of integration is $[0,1]$, the standard interval
 used by AUTO. For periodic solutions the independent variable is transformed
 to range from 0 to 1, before the norm is computed. The AUTO-constants THL(*) 
 and THU(*) (see Section~\ref{sec:THL} and Section~\ref{sec:THU})
 affect the definition of the $L_2$-norm.
\item[-]
  If 0 $<$ {\tt IPLT} $\le$ {\tt NDIM} then the maximum of the {\tt IPLT}'th solution component 
  is printed.
\item[-]
  If $-${\tt NDIM} $\le$ {\tt IPLT} $<$0 then the minimum of the {\tt IPLT}'th solution component
  is printed.  (Demo {\tt fsh}.)
\item[-]
  If {\tt NDIM} $<$ {\tt IPLT} $\le$ 2*{\tt NDIM} then the integral 
  of the ({\tt IPLT}$-${\tt NDIM})'th 
  solution component is printed. (Demos {\tt exp}, {\tt lor}.)
\item[-]
  If 2*{\tt NDIM} $<$ {\tt IPLT} $\le$ 3*{\tt NDIM} 
  then the $L_2$-norm of the ({\tt IPLT}$-${\tt NDIM})'th 
  solution component is printed. (Demo {\tt frc}.)
\end{itemize}

Note that for algebraic problems the maximum and the minimum are identical.
Also, for ODEs the maximum and the minimum of a solution component are generally
much less accurate than the $L_2$-norm and component integrals.
Note also that the routine {\tt PVLS} provides a second, more general way
of defining solution measures; see Section~\ref{sec:Parameter_over_specification}.


\subsection{\texttt{UZR}} \label{sec:UZR} 
 This constant allows the setting of parameter values at which labeled plotting 
 and restart information is to be written in the {\tt fort.8} output-file.
 Optionally, it also allows the computation to terminate at such a point.

\begin{itemize}
\item[-]
 Set {\tt UZR=\{\}} if no such output is needed. Many demos use this setting.
\item[-]
 Else one must enter pairs,
            ~\{{\it Parameter-Index} : {\it Parameter-Value}, ...\}~,\\
 or indices with lists of values,
            ~\{{\it Parameter-Index} : \[{\it Parameter-Value}, ...\], ...\}~,
 to designate the parameters and the parameter
 values at which output is to be written.
 For examples see demos {\tt exp}, {\tt int}, and {\tt fsh}.
\item[-]
 If such a parameter index is preceded by a minus sign then the computation will
 terminate at such a solution point. See also \texttt{STOP} in
 Section~\ref{sec:STOP} above and \texttt{UZSTOP} in
 Section~\ref{sec:UZSTOP} below for alternative termination methods.
 (Demos {\tt pen} and {\tt bru}.)
\end{itemize}

Note that {\tt fort.8} output can also be written at selected values of 
overspecified parameters. For an example see demo {\tt pvl}.
For details on overspecified parameters see 
Section~\ref{sec:Parameter_over_specification}.

\subsection{\texttt{UZSTOP}} \label{sec:UZSTOP}
 This constant specifies parameter values in the same way as
 \texttt{UZR} in Section~\ref{sec:UZR} above, but the computation
 will always terminate if any solution point that is specified is
 encountered.

%=====================================================================

\section{ Quick reference}
\vspace{-2.5mm}
\begin{tabular}{|l|l|}
\hline
{\tt e}, {\tt s}, {\tt dat}, {\tt sv} & Define file names: equation
prefix (.f,.f90,.c), restart solution suffix (s.), \\
& user data prefix (.dat), output suffix (b.,s.,d.)\\
\hline
{\tt unames}, {\tt parnames} & Dictionary (mapping) of U(*) and PAR(*)
to user-defined names\\
\hline
{\tt NDIM} & Problem dimension \\
{\tt IPS}  & Problem type; 0=AE, 1=FP(ODEs), -1=FP(maps), 2=PO,
           -2=IVP,\\
           & 4=BVP, 7=BVP with Floquet multipliers, 5=algebraic
           optimization \\
 	   & problem, 15=optimization of periodic solutions \\
{\tt IRS}, {\tt TY}  & Start solution label, start solution type\\
{\tt ILP}  & Fold detection; 1=on, 0=off \\
\hline
{\tt ICP}  & Continuation parameters \\
\hline
{\tt NTST} & \# mesh intervals \\
{\tt NCOL} & \# collocation points \\
{\tt IAD} & Mesh adaption every IAD steps; 0=off \\
{\tt ISP} & Bifurcation detection; 0=off, 1=BP(FP), 3=BP(PO,BVP), 2=all \\
{\tt ISW} & Branch switching; 1=normal, -1=switch branch (BP, HB, PD),\\
          & 2=switch to two-parameter continuation (LP, BP, HB, TR) \\
          & 3=switch to three-parameter continuation (BP) \\
{\tt IPLT} & Select principal solution measure \\
{\tt NBC} & \# boundary conditions \\
{\tt NINT} & \# integral conditions \\
\hline
{\tt NMX} & Maximum number of steps \\
{\tt RL0, RL1} & Parameter interval $ RL0 \leq \lambda \leq RL1$ \\
{\tt A0, A1} & Interval of principal solution measure $ A0 \leq
\Vert\cdot\Vert \leq A1$ \\
\hline
{\tt NPR} & Print and save restart data every NPR steps \\
{\tt MXBF} & Automatic branch switching for the first MXBF bifurcation \\
 	  & points if IPS=0, 1 	 \\
{\tt IBR}, {\tt LAB} & Set initial branch and label number; 0=automatic \\
{\tt IIS} & Control solution output of branch direction vector; 0=never, 3=always \\
{\tt IID} & Control diagnostic output; 0=none, 1=little, 2=normal, 4=extensive \\
{\tt ITMX} & Maximum \# of iterations for locating special solutions/points \\
{\tt ITNW} & Maximum \# of correction steps \\
{\tt NWTN} & Corrector uses full newton for NWTN steps \\
{\tt JAC}  & User defines derivatives; 0=no, 1=yes \\
\hline
{\tt EPSL}, {\tt EPSU}, {\tt EPSS} & Convergence criterion:
parameters, solution components, special points\\
\hline
{\tt DS}  & Start step size \\
{\tt DSMIN, DSMAX} & Step size interval $\mathtt{DSMIN} \leq h \leq \mathtt{DSMAX}$ \\
{\tt IADS} & Step size adaption every IADS steps; 0=off \\
\hline
{\tt NPAR} & Maximum number of parameters \\
{\tt THL, THU} & list of parameter and solution weights \\
\hline
{\tt UZR}, {\tt UZSTOP} & list of values for user defined output\\
{\tt SP}, {\tt STOP} & list of bifurcations to check and bifurcation stop
conditions\\
\hline
{\tt NUNSTAB}, {\tt NSTAB} & HomCont: unstable and stable manifold dimensions\\
{\tt IEQUIB}, {\tt ITWIST}, {\tt ISTART} & HomCont: control solution types
adjoint, starting\\
{\tt IREV}, {\tt IFIXED}, {\tt IPSI} & HomCont: control reversibility, fixed
parameters, test functions\\
\hline
\end{tabular}

 

%==============================================================================
%==============================================================================
\chapter{ Notes on Using {\cal AUTO}.}  \label{ch:Notes_on_Using_AUTO}
%==============================================================================
%==============================================================================
\section{ Restrictions on the Use of \texttt{PAR}.} \label{sec:Restrictions_on_PAR}
The array {\tt PAR} in the user-supplied routines is available
for equation parameters that the user wants to vary at some point
in the computations.
In any particular computation the free parameter(s) must be designated
in {\tt ICP}; see Section~\ref{sec:Free_parameters}.
The following restrictions apply~:

\begin{itemize}
\item[-]
  The default maximum number of parameters, \parf{NPAR} has a
  pre-defined value in \filef{auto/07p/ include/auto.h},
  of \parf{NPARX}=36.
  Any change \parf{NPARX} must be followed by recompilation of {\cal AUTO}.
\item[-]
  Generally one should avoid certain parameters for equation parameters,
  as {\cal AUTO} may need those internally, as follows:
\begin{description}
\item[\parf{IPS}=0,4:]
  No additional parameters with indices less than or equal
  to \parf{NPAR} are reserved.
\item[\parf{IPS}=$-$1,1,2,7:]
  \AUTO reserves \parf{PAR(11)} to store the period for stationary
  solutions at Hopf bifurcations only and continuously for periodic
  orbits. For \parf{IPS}=2 and \parf{IPS}=7, \AUTO also
  reserves \parf{PAR(12)} to store the angle of the torus
  at torus bifurcations.
\item[\parf{IPS}=$-$2:]
  The integration time is stored in \parf{PAR(14)}.
\item[\parf{IPS}=5:]
  The value of the objective functional is stored in \parf{PAR(10)}.
\item[\parf{IPS}=9:]
  The length in time of the truncated homoclinic or heteroclinic orbit
  is stored in \parf{PAR(11)}. For the adjoint variational equations,
  \parf{PAR(10)} is used. The equilibria are stored
  in \parf{PAR(11)} to \parf{PAR(11+NDIM-1)}/\parf{PAR(11+2*NDIM-1)}
  (homoclinic/heteroclinic). Test function values may be stored in
  \parf{PAR(21)} to \parf{PAR(36)}. Homoclinic branch switching uses
  \parf{PAR(20)} and higher to store time intervals and gap sizes.
\item[\parf{IPS}=11,12:]
  The wave speed is in \parf{PAR(10)}, and the diffusion 
  constants in \parf{PAR(15,16,$\cdots$)}. The period (for periodic
  solutions and at Hopf bifurcations) is stored in \parf{PAR(11)}.
\item[\parf{IPS}=14,16:]
  \AUTO uses \parf{PAR(14)} for the time variable, and the diffusion 
  constants are in \parf{PAR(15,16,$\cdots$)}. The period is stored in
  \parf{PAR(11)}. The previous time for each step is stored in \parf{PAR(12)}.
\item[\parf{IPS}=17:]
  The diffusion constants are in \parf{PAR(15,16,$\cdots$)}.
  The period is stored in \parf{PAR(11)}.
\item[\parf{IPS}=15:]
  Only \parf{PAR(1-9)} should be used for problem parameters.
  \parf{PAR(10)} is the value of the objective
  functional, \parf{PAR(11)} the period, \parf{PAR(12)} the norm of the
  adjoint variables, \parf{PAR(14)} and \parf{PAR(15)} are internal optimality
  variables. \parf{PAR(21-29)} and \parf{PAR(31)} are used to monitor the 
  optimality functionals associated with the problem parameters and
  the period.
\end{description}
\end{itemize}

\section{ Efficiency.} \label{sec:Efficiency}
In {\cal AUTO}, efficiency has at times been sacrificed for generality of programming.
This applies in particular to computations in which {\cal AUTO} generates
an extended system, for example, computations with {\tt ISW}=2.
However, the user has significant control over computational efficiency,
in particular through judicious choice of the {\cal AUTO}-constants  
{\tt DS}, {\tt DSMIN}, and {\tt DSMAX}, and, for ODEs, {\tt NTST} and {\tt NCOL}.
Initial experimentation normally suggests appropriate values.

Slowly varying solutions to ODEs can often 
be computed with remarkably small values of {\tt NTST} and {\tt NCOL}, 
for example, {\tt NTST}=5,  {\tt NCOL}=2.
Generally, however, it is recommended to set {\tt NCOL}=4,
and then to use the ``smallest'' value of {\tt NTST} that maintains convergence.

The choice of the pseudo-arclength stepsize parameters
{\tt DS}, {\tt DSMIN}, and {\tt DSMAX}
is highly problem dependent.
Generally, {\tt DSMIN} should not be taken too small,
in order to prevent excessive step refinement in case of non-convergence.
It should also not be too large, in order to avoid instant non-convergence.
{\tt DSMAX} should be sufficiently large, in order to reduce computation time
and amount of output data.
On the other hand, it should be sufficiently small, in order to prevent
stepping over bifurcations without detecting them.
For a given equation, appropriate values of these constants 
can normally be found after some initial experimentation.

The constants {\tt ITNW}, {\tt NWTN}, {\tt THL}, {\tt EPSU}, {\tt EPSL}, {\tt EPSS} 
also affect efficiency.
Understanding their significance is therefore useful; 
see Section~\ref{sec:Tolerances} and Section~\ref{sec:step_size}.
Finally, it is recommended that initial computations be done with 
{\tt ILP=0}; no fold detection;
and {\tt ISP}=1; no bifurcation detection for ODEs.
 
\section{ Correctness of Results.} \label{sec:Correctness}
{\cal AUTO}-computed solutions to ODEs are almost always structurally correct,
because the mesh adaption strategy, if {\tt IAD}$>$0, safeguards to some extent
against spurious solutions.
If these do occur, possibly near infinite-period orbits,
the unusual appearance of the solution family typically serves as a warning.
Repeating the computation with increased {\tt NTST} is then recommended.

\section{ Bifurcation Points and Folds.} \label{sec:Bifurcations}
It is recommended that the detection of folds 
and bifurcation points be initially disabled.
For example, if an equation has a ``vertical'' solution family
then {\cal AUTO} may try to locate one fold after another.

Generally, degenerate bifurcations cannot be detected.
Furthermore, bifurcations that are close to each other may not
be noticed when the pseudo-arclength step size is not sufficiently small.
Hopf bifurcation points may go unnoticed if no clear crossing of
the imaginary axis takes place. This may happen when there are other
real or complex eigenvalues near the imaginary axis and when 
the pseudo-arclength step is large compared to the rate
of change of the critical eigenvalue pair.
A typical  case is a Hopf bifurcation close to a fold.
Similarly, Hopf bifurcations may go undetected if switching from
real to complex conjugate, followed by crossing of the imaginary
axis, occurs rapidly with respect to the pseudo-arclength step size.
Secondary periodic bifurcations may not be detected for similar reasons.
In case of doubt, carefully inspect the contents of the diagnostics file
{\tt fort.9}.
 
\section{ Floquet Multipliers.} \label{sec:Floquet_multipliers}

{\cal AUTO} extracts an approximation to the linearized Poincar\'e map from 
the Jacobian of the linearized collocation system that arises in Newton's method.
This procedure is very efficient; the map is computed at negligible extra cost.
The linear equations solver of {\cal AUTO} is described in 
\citename{DoKeKe:91b} \citeyear{DoKeKe:91b}.
The actual Floquet multiplier solver was written by
\citename{Fa:94} \citeyear{Fa:94}.
For a detailed description of the algorithm see 
\citename{FaJe:91} \citeyear{FaJe:91}.

For periodic solutions, the exact linearized Poincar\'e map always has 
a multiplier $z=1$.
A good accuracy check is to inspect this 
multiplier in the diagnostics output-file {\tt fort.9}.
If this multiplier becomes inaccurate then the automatic detection 
of potential secondary periodic bifurcations (if {\tt ISP}=2) is discontinued 
and a warning is printed in {\tt fort.9}.
It is strongly recommended that the contents of this file be
habitually inspected,
in particular to verify whether solutions labeled as BP or TR 
(cf.~Table~\ref{tbl:Solution_Types}) have indeed  been correctly classified.
 
\section{ Memory Requirements.} \label{sec:Memory_requirements}
The run-time memory requirements depend on the values the user set in
the constants file and are roughly proportional to the value
${\tt NTST}\times({\tt NDIM}\times({\tt NCOL}+1)+{\tt NBC})\times
({\tt NDIM}\times{\tt NCOL}+{\tt NINT}+1)$.

%==============================================================================
%==============================================================================
\chapter{ \AUTO Demos : Tutorial.} \label{ch:Demos:_Tutorial}
%==============================================================================
%==============================================================================
\newpage
\section{ Introduction.} \label{sec:Tutorial_Introduction}
The directory {\tt auto/07p/demos} has a large number of subdirectories,
for example {\tt ab}, {\tt pp2}, {\tt exp}, etc.,
each containing all necessary files for certain illustrative calculations.
Each subdirectory, say {\tt xxx}, corresponds to a particular equation
and contains one equations-file \filef{xxx.\{f90,f,c\}}
and one or more constants-files \filef{c.xxx.i}, 
one for each successive run of the demo.
You also find \python script files \filef{xxx.auto} and
\filef{clean.auto}: the command \filef{auto xxx.auto} runs the demo,
and the command \filef{auto clean.auto} deletes all generated files.
To see how the equations have been programmed, inspect the equations-file. 
To understand in detail how {\cal AUTO} is instructed to carry out a 
particular task, inspect the appropriate constants-file and \python
script.
In this chapter we describe the tutorial demo {\tt cusp} in detail.
A brief description of other demos is given in later chapters.


\section{ cusp : A Tutorial Demo.} \label{sec:Demos_cusp}
This demo illustrates the computation of 
stationary solutions, locating saddle-node bifurcations of these
solutions, and the continuation of a saddle-node bifurcation in two
parameters.\\
The cusp normal form equation is given by
\begin{equation}
  \dot x = \mu + \lambda x - x^3.
\end{equation}

\section{ Copying the Demo Files.}  \label{sec:Tutorial_copying}
The commands listed in Table~\ref{tbl:demo_cusp_1}
will copy the demo files to your work directory.

\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | l |}
\hline
  {\cal Unix}-COMMAND  & ACTION \\
\hline
%==============================================================================
  \commandf{auto}  & start the AUTO-07p Command Line User Interface\\ 
\hline
  \AUTO-COMMAND  & ACTION \\
\hline
  \commandf{cd } & go to main directory (or other directory).\\
  \commandf{mkdir cusp}  & \parbox[t]{3in}{create an empty work directory.  
                            Note:  the '!' is used to signify a command 
                            which is sent to the shell.\vspace{0.2cm}}\\ 
  \commandf{cd cusp}  & change to the work directory.\\

  \commandf{demo('cusp')}  & copy the demo files to the work directory.\\
\hline
%==============================================================================
\end{tabular}
\caption{Copying the demo \filef{cusp} files.}
\label{tbl:demo_cusp_1}
\end{center}
\end{table}

Typing \commandf{ls} reveals the existence of 5 files:
\begin{enumerate}
\item
\commandf{cusp.f90}: This file contains the differential equations
and the initial values. If you inspect it, you will see that only two
routines are used. The subroutine {\tt FUNC} specifies the actual
differential equation. The routine {\tt STPNT} gives {\cal AUTO}
the initial values of {\tt PAR(1)}$=\lambda$ and
{\tt PAR(2)}$=\mu$, which
are $1.0$ and $0.0$, and the initial value of $x$, which is $0$.
For your own models you would generally copy another equation file
and then only change the pieces that actually define the equation.

\item
\commandf{c.cusp}: The initial computational constants are stored
in this file. Most importantly, you see that the dimension of the
problem (\parf{NDIM}) is set to 1, and the problem type \parf{IPS}
is set to 1 to specify continuation of a stationary solution.
The constants given by \parf{ICP} specify the parameters that are
used for the continuation. In this case these are 'mu' for $\mu$ and
'lambda' for $\lambda$, which correspond to the indices 2 and 1,
respectively, using the constant \parf{parnames}.
Since initially we only really continue in one parameter ($\mu$),
the second parameter $\lambda$ is \emph{overspecified}.
Another important constant is the initial step size {\tt DS}: as it is
positive, we initally continue in the positive $\mu$ direction.

\item
\commandf{cusp.auto}: A script with Python CLUI commands that steer
the calculation.

\item
\commandf{clean.auto}: A script that cleans the directory of all
generated files.

\item
\commandf{autorc}: A file that contains default settings for
the 2-dimensional plotting tool {\cal PyPLAUT}.

\item
\commandf{plaut04.rc}: A file that contains default settings for
the 3-dimensional plotting tool {\cal PLAUT04}.

\end{enumerate}

\section{ Executing all Runs Automatically.} \label{sec:Tutorial_all_runs}
To execute all prepared runs of demo \filef{cusp},
simply type the command given in Table~\ref{tbl:demo_cusp_2}.

\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | l |}
\hline
  \AUTO-COMMAND  & ACTION \\
\hline
%==============================================================================
  \commandf{demofile('cusp.auto')}  & \parbox[t]{3in}{execute all runs of demo \filef{cusp} interactively\vspace{0.2cm}}\\ 
\hline
%==============================================================================
\end{tabular}
\caption{Executing all runs of demo \filef{cusp}.}
\label{tbl:demo_cusp_2}
\end{center}
\end{table}

The command in Table~\ref{tbl:demo_cusp_2} begins
a tutorial which will proceed one step each time
the user presses a key.  Each step consists of a
single \AUTO command preceded by instructions as
to what action the command performs.
The tutorial script \filef{cusp.auto} performs the
demo by reading in a single \AUTO constants file
and then interactively modifying it to perform
each of the demo. The essential commands in \filef{cusp.auto}
are given in Table~\ref{tbl:demo_cusp_4a}.

Note that there are four separate runs, where each \commandf{run}
command performs a run.
In the first run, a branch of stationary solutions is traced out.
Along it, one fold (LP) (limit point, or in this case, a saddle-node
bifurcation) is located. The free parameter is $\mu$.
The other parameter $\lambda$ remains fixed in this run.
Note also that only special, labeled solution points are printed on the screen.
Detailed results are saved in the \python variable \parf{mu}.

The second run does the same thing but now in the negative direction
of $\mu$, i.e., backwards instead of forwards. The backwards
continuation is appended to the forwards continuation in the
data-files. Afterwards we perform a relabelling to make sure that we have
unique labels for each special solution. Next the relabelled result is saved
to the data-files \filef{b.mu}, \filef{s.mu}, and \filef{d.mu}.

The results are then plotted on the screen. Pressing the enter key
at the command line causes an automatic $\mu$ vs. $x$ display that
shows the two fold points at labels 2 and 7.

In the third run, the fold detected in the first run is followed in
the two parameters $\mu$ and $\lambda$.
We know that label 2, with solution \parf{mu(2)} is the right
solution to start from. However, we did not know this number in
advance, and moreover, in sensitive cases, it can be different on
different computer types. Another way to specify the starting label
is to use the notation \parf{mu('LP1')}: this specifies the first
LP-labelled solution of all solutions in \parf{mu}.

Furthermore the command that accomplishes
this must change the constant {\tt ISW} of the constants file: 
it must be set to 2 to cause a two-parameter continuation.

The fourth run continues this branch in opposite direction.
The detailed results of these continuations are saved
in the data-files \filef{b.cusp}, \filef{s.cusp}, and \filef{
d.cusp}. Finally, a plot of the cusp is produced.

The numerical results are given below
in somewhat abbreviated form.
Some differences in output are to be expected on different machines.
This does not mean that the results have different accuracy, but simply
that arithmetic differences have accumulated from step to step, possibly
leading to different step size decisions.

Next, reset the work directory, by typing the command given
in Table~\ref{tbl:demo_cusp_3}.

\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | l |}
\hline
  \AUTO-COMMAND  & ACTION \\
\hline
%==============================================================================
  \commandf{clean()}  & remove temporary files of demo \filef{cusp} \\ 
  \commandf{delete('mu')}  & remove 'mu' data-files of demo \filef{cusp} \\ 
  \commandf{delete('cusp')}  & remove 'cusp' data-files of demo \filef{cusp} \\ 
\hline
%==============================================================================
\end{tabular}
\caption{Cleaning the demo \filef{cusp} work directory.}
\label{tbl:demo_cusp_3}
\end{center}
\end{table}

\begin{center}
\vspace{-0.2in}
\begin{verbatim}
# Run forwards
 
  BR    PT  TY  LAB       mu         L2-NORM          x           lambda    
   1     1  EP    1   0.00000E+00   0.00000E+00   0.00000E+00   1.00000E+00
   1    14  LP    2   3.84900E-01   5.77360E-01  -5.77360E-01   1.00000E+00
   1    20        3   1.26582E-01   9.29410E-01  -9.29410E-01   1.00000E+00
   1    40        4  -1.38347E+00   1.40803E+00  -1.40803E+00   1.00000E+00
   1    47  UZ    5  -1.99999E+00   1.52138E+00  -1.52138E+00   1.00000E+00

# Run backwards
 
  BR    PT  TY  LAB       mu         L2-NORM          x           lambda    
   1     1  EP    1   0.00000E+00   0.00000E+00   0.00000E+00   1.00000E+00
   1    14  LP    2  -3.84900E-01   5.77360E-01   5.77360E-01   1.00000E+00
   1    20        3  -1.26582E-01   9.29410E-01   9.29410E-01   1.00000E+00
   1    40        4   1.38347E+00   1.40803E+00   1.40803E+00   1.00000E+00
   1    47  UZ    5   1.99999E+00   1.52138E+00   1.52138E+00   1.00000E+00

# Forward continuation of the first fold in two parameters
 
  BR    PT  TY  LAB       mu         L2-NORM          x           lambda    
   2    20       11   1.09209E+00   8.17354E-01  -8.17354E-01   2.00420E+00
   2    34  UZ   12   1.99995E+00   9.99991E-01  -9.99991E-01   2.99995E+00

# Backward continuation of the fold in two parameters

  BR    PT  TY  LAB       mu         L2-NORM          x           lambda    
   2    20       11   5.42543E-02   3.00470E-01  -3.00470E-01   2.70847E-01
   2    29  CP   12  -2.02768E-12   1.00472E-04   1.00472E-04   3.02837E-08
   2    40       13  -9.09414E-02   3.56925E-01   3.56925E-01   3.82187E-01
   2    60       14  -5.73716E-01   6.59512E-01   6.59512E-01   1.30487E+00
   2    80       15  -1.68023E+00   9.43582E-01   9.43582E-01   2.67104E+00
   2    85  UZ   16  -1.99995E+00   9.99992E-01   9.99992E-01   2.99995E+00

\end{verbatim}
\end{center}

The CLUI was used to generate the constants
file at runtime.  In the example below, the constant file \filef{c.cusp}
will be read in, and the CLUI will be used to make the appropriate
changes to perform the calculation.

\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | l |}
\hline
  \AUTO-COMMAND  & ACTION \\
\hline
%==============================================================================
  \commandf{cusp = load('cusp')}  & load the problem definition  \filef{cusp} \\ 
  \commandf{mu = run(cusp)}  & execute the run \\
  \commandf{mu = mu + run(cusp,DS='-')}  & execute the run backwards and \\
    & append the results to \parf{mu}\\ 
  \commandf{mu = rl(mu) } & relabel solutions in mu \\
  \commandf{save(mu, 'mu')} & save the results
                   in the files \filef{b.mu}, \filef{s.mu}, and \filef{d.mu}\\ 
  \commandf{lp1 = load(mu('LP1'), ISW=2)} & use the first fold (LP) in
    \parf{mu} as the restart solution,\\
  & and change ISW to 2.\\
  \commandf{cusp = run(lp1) } & execute the third run of demo \filef{cusp} \\ 
  \commandf{cusp = cusp + run(lp1,DS='-') } & execute the fourth run
  of demo \filef{cusp} \\ 
  \commandf{save(cusp,'cusp')} & save the results
                   in the files \filef{b.cusp}, \filef{s.cusp}, and \filef{d.cusp}\\ 
\hline
%==============================================================================
\end{tabular}
\caption{Selected runs of demo \filef{cusp}.}
\label{tbl:demo_cusp_4a}
\end{center}
\end{table}

\section{ Plotting the Results with \AUTO.} \label{sec:Tutorial_plotting}
The bifurcation diagram computed in the runs above
was stored in the files \filef{b.mu} and \filef{b.cusp},
while each labeled solution is fully stored in \filef{s.mu} and
\filef{s.cusp}.
To use \AUTO to graphically inspect these data-files.
type the \AUTO-command given in Table~\ref{tbl:demo_cusp_7}.
The saved plots are shown in Figure~\ref{fig:cusp_1}
and in Figure~\ref{fig:cusp_2}.

Figure~\ref{fig:cusp_1} shows the bifurcation diagrams for the first
run, and Figure~\ref{fig:cusp_2} for the second run.

The plotting window consists of a menubar at the top, a plotting area,
and a control panel with four control widgets at the bottom.  By
default the first two columns in the bifurcation diagram output
are plotted against each other. To obtain a $\mu$ versus $x$
bifurcation diagram you need to plot column 'mu' versus column 'x'.
You can do that by changing the ``Y'' box to say ``[x]'', either by
typing it there, by using the menu obtained by clicking the
downwards facing triangle or by using a scripted command as used
in \filef{cusp.auto}.
You can also change the mode of
the plotting tool from ``bifurcation'' to ``solution''.  This is
accomplished by clicking on the widget marked ``Type'' on the bottom
control panel and setting it from ``bifurcation'' to ``solution''.  In
the plotting window will appear a plot of the first labeled solution,
in this case just a point. You can plot all points by changing
the ``Label'' to ``[1,2,3,4,5,6,7,8,9,10]''.

The plotting tool can also be used to create Postscript files from
plots by selecting the ``File'' on the menubar and then selecting the
``Save Postscript...'' from the drop down menu.
This will bring up
a dialog into which the user can enter the filename of the postscript
file to save the plot in.  
When using matplotlib
you can also click on the floppy disk icon to save using a variety of
file formats.
Further information on the plotting tool can be found in
Section~\ref{clui:plotting}.

\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | l |}
\hline
  \AUTO-COMMAND  & ACTION \\
\hline
%==============================================================================
  \commandf{plot(mu)} & run \AUTO to graph the contents of \parf{mu}\\
  \commandf{plot("mu")} & run \AUTO to graph the contents of
  \filef{b.mu} and \filef{s.mu}; \\  
  & (this is the same as \commandf{plot(loadbd("mu"))})\\
%==============================================================================
\hline
\end{tabular}
\caption{Commands for plotting 
   or the bifurcation diagram and solutions of the \python variable \parf{mu},
and the files \filef{b.mu} and \filef{s.mu}}
\label{tbl:demo_cusp_7}
\end{center}
\end{table}

\begin{figure}[p]
\epsfysize 9.0cm
\centerline{\epsffile{include/cusp1}}
\caption{The first bifurcation diagram of demo \filef{cusp}.}
\label{fig:cusp_1}
\end{figure}
\begin{figure}[p]
\epsfysize 9.0cm
\centerline{\epsffile{include/cusp2}}
\caption{The second bifurcation diagram of demo \filef{cusp}.}
\label{fig:cusp_2}
\end{figure}

\section{ Plotting the Results with \AUTO in 3D.}
Whilst not very useful for this simple example, you can also plot
your results in 3D, using the \commandf{plot3} command ({\cal PLAUT04}), for example
\commandf{plot3('mu')}. Unlike the PyPLAUT tool by default, this shows
the stable and unstable parts: blue is stable, and red is unstable. You can also
spin the bifurcation diagram around and zoom in using the mouse.

\section{ Exporting the Results for different plotters.}
It is often useful to use other plotting programs or general-purpose
tools to work with AUTO's data. The ``writeRawFilename'' method (see
also Section~\ref{sec:clui_exporting}) can be used for this.
In this tutorial we can for
instance export the bifurcation diagram using\\
\commandf{cusp.writeRawFilename('cusp.dat') }, and then use
the command \commandf{plot 'cusp.dat' using 1:4 wi li } to plot
the bifurcation diagram in GNUPlot.

\newpage
\section{ ab : A Programmed Demo.} \label{sec:Demos_ab}
%==============================================================================
%DEMO=ab=======================================================================
%==============================================================================
This demo illustrates the computation of 
stationary solutions,
Hopf bifurcations and 
periodic solutions.
The equations, that model an A $\to$ B  reaction, are those from
\citename{URP:74} \citeyear{URP:74}, namely
\begin{equation} \begin{array}{cl}
  u_1 ' &=  -u_1 + p_1 (1-u_1) e^{u_2}, \\
  u_2 ' &=  -u_2 +  p_1 p_2 ( 1-u_1) e^{u_2} - p_3 u_2.\\
\end{array} \end{equation}
This demo is fully scripted, see Table~\ref{tbl:demo_ab}.

\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | l |}
\hline
  \AUTO-COMMAND  & ACTION \\
\hline
%==============================================================================
  \commandf{mkdir ab} & create an empty work directory \\ 
  \commandf{cd ab} & change directory \\
  \commandf{demo('ab')} & copy the demo files to the work directory \\
\hline
%==============================================================================
  \commandf{auto('ab.auto')} & run the demo \\
\hline
\end{tabular}
\caption{Commands for running demo \filef{ab}.}
\label{tbl:demo_ab}
\end{center}
\end{table}

If you look at the file \filef{ab.auto } you see that the script
computes a stationary solution family for certain values of $p_2$,
and that a periodic orbit family is computed for each Hopf bifurcation
that was found in the stationary solution families.

%==============================================================================
%==============================================================================
\chapter{ \AUTO Demos : Fixed points.} \label{ch:Demos_Fixed_points}
%==============================================================================
%==============================================================================

%==============================================================================
%DEMO=enz======================================================================
%==============================================================================
\section{ enz : Stationary Solutions of an Enzyme Model.} \label{sec:Demos_enz}
The equations, that model a two-compartment enzyme system 
(\citename{JPK:80} \citeyear{JPK:80}),
are given by
\begin{equation} \label{2'} \begin{array}{cl}
 s_1 '&=
 (s_0 - s_1) + (s_2 - s_1) - \rho R (s_1), \\
 s_2 '&=
 (s_0 +\mu - s_2) + (s_1 - s_2) - \rho R (s_2), \\\end{array} \end{equation}
where
$$ R (s)=\frac{s}{1+s+ \kappa s^{2} }.$$
The free parameter is $s_0$. Other parameters are fixed.
This equation is also considered in 
\citename{DoKeKe:91a} \citeyear{DoKeKe:91a}.

\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | l |}
\hline
  \AUTO-COMMAND  & ACTION \\
\hline
%==============================================================================
  \commandf{mkdir enz} & create an empty work directory \\ 
  \commandf{cd enz} & change directory \\
  \commandf{demo('enz')} & copy the demo files to the work directory \\
\hline
%==============================================================================
  \commandf{run('enz')} & compute stationary solution families \\ 
  \commandf{save('enz')} & save output-files as \filef{b.enz, s.enz, d.enz} \\ 
\hline
\end{tabular}
\caption{Python commands for running demo \filef{enz}.}
\label{tbl:demo_enz}
\end{center}
\end{table}

\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | l |}
\hline
  \AUTO-COMMAND  & ACTION \\
\hline
%==============================================================================
  \commandf{mkdir enz} & create an empty work directory \\ 
  \commandf{cd enz} & change directory \\
  \commandf{@dm enz} & copy the demo files to the work directory \\
\hline
%==============================================================================
  \commandf{@r enz} & compute stationary solution families \\ 
  \commandf{@sv enz} & save output-files as \filef{b.enz, s.enz, d.enz} \\ 
\hline
\end{tabular}
\caption{Shell commands for running demo \filef{enz}.}
\label{tbl:demo_enz2}
\end{center}
\end{table}

\newpage
%==============================================================================
%DEMO=dd2======================================================================
%==============================================================================
\section{ dd2 : Fixed Points of a Discrete Dynamical System.} \label{sec:Demos_dd2}
This demo illustrates the computation of a solution family and
its bifurcating families for a discrete dynamical system.
Also illustrated are the continuation of 
period-doubling bifurcations, and branch switching at such
points.
The equations, a discrete predator-prey system, are
\begin{equation} \begin{array}{cl}
 u_1^{k+1} &=p_1
 u_1^{k}(1-u_1^{k})-p_2u_1^{k} u_2^{k},\\
 u_2^{k+1}&=(1-p_3)u_2^{k}+p_2u_1^{k}u_2^{k}.\\
\end{array} \end{equation}
In the first, third, and fourth run $p_1$ is free.
In the second run, both $p_1$ and $p_2$ are free.
The remaining equation parameter, $p_3$, is fixed in both runs.

\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | l |}
\hline
  \AUTO-COMMAND  & ACTION \\
\hline
%==============================================================================
  \commandf{mkdir dd2 } & create an empty work directory \\ 
  \commandf{cd dd2 } & change directory \\
  \commandf{demo('dd2') } & copy the demo files to the work directory \\
\hline
%==============================================================================
 
  \commandf{r1=run(e='dd2',c='dd2')} & 1st run; fixed point solution branches \\ 
  \commandf{save('dd2')} & save output-files as \filef{b.dd2, s.dd2, d.dd2} \\ 
\hline
%==============================================================================
  \commandf{run(r1("PD1"),ICP=["p1","p2"],ISW=2)} & \parbox[t]{3in}{2nd run; a locus of period-doubling bifurcations.  \vspace{0.2cm}}\\ 
  \commandf{save('pd')} & save output-files as \filef{b.pd, s.pd, d.pd} \\ 
\hline
%==============================================================================
  \commandf{r3=run(r1("PD1"),ISW=-1)} & \parbox[t]{3in}{3rd run;
    the bifurcating period-2 orbit.  \vspace{0.2cm}}\\ 
  \commandf{append('dd2')} & append output-files to \filef{b.dd2, s.dd2, d.dd2} \\ 
\hline
%==============================================================================
  \commandf{run(r3("PD1"))} & \parbox[t]{3in}{4th run; the
    bifurcation period-4 orbit.  \vspace{0.2cm}}\\ 
  \commandf{append('dd2')} & append output-files to \filef{b.dd2, s.dd2, d.dd2} \\ 
\hline
\end{tabular}
\caption{Commands for running demo \filef{dd2}.}
\label{tbl:demo_dd2}
\end{center}
\end{table}

\newpage
%==============================================================================
%DEMO=log======================================================================
%==============================================================================
\section{ log : The Logistic Map.} \label{sec:Demos_log}
This demo shows 5 subsequent periodic doublings in the logistic map
\begin{equation} \begin{array}{cl}
 x^{k+1} &= \mu x (1-x),\\
\end{array} \end{equation}
and approximates the Feigenbaum constant. The script
\filef{log.auto} shows a Python loop in which values
of $\mu$ for subsequent period-doubling bifurcations are compared.

\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | l |}
\hline
  \AUTO-COMMAND  & ACTION \\
\hline
%==============================================================================
  \commandf{mkdir log } & create an empty work directory \\ 
  \commandf{cd log } & change directory \\
  \commandf{demo('log') } & copy the demo files to the work directory \\
  \commandf{auto('log.auto') } & run the script log.auto \\
  \commandf{plot('log') } & plot the bifurcation diagram \\
\hline
\end{tabular}
\caption{Commands for running demo \filef{log}.}
\label{tbl:demo_log}
\end{center}
\end{table}

\newpage
%==============================================================================
%DEMO=hen======================================================================
%==============================================================================
\section{ hen: The H\'enon Map.} \label{sec:Demos_hen}
In this demo, a two-parameter bifurcation analysis of the H\'enon map
\begin{equation} \begin{array}{cl}
 x^{k+1} &= y,\\
 y^{k+1} &= \alpha-\beta x - y^2,\\
\end{array} \end{equation}
is performed. This demo features the detection and continuation
of Naimark-Sacker, period-doubling, and fold bifurcations in two
parameters. On these codimension-one bifurcation curves
certain codimension-two bifurcations are detected:
the 1:1 (R1), 1:2 (R2), 1:3 (R3), and 1:4 (R4) resonance and fold-flip (LPD)
bifurcation points. After running the script \filef{hen.auto}, the
results can be plotted using \commandf{plot('hen')} or \commandf{@pp hen}.

\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | l |}
\hline
  \AUTO-COMMAND  & ACTION \\
\hline
%==============================================================================
  \commandf{mkdir hen } & create an empty work directory \\ 
  \commandf{cd hen } & change directory \\
  \commandf{demo('hen') } & copy the demo files to the work directory \\
  \commandf{r1 = run('hen')} & \parbox[t]{3in}{
    fixed point solution branch for $\beta$
    ($\alpha=1$) (detects a period-doubling (PD)
    and a Naimark-Sacker (TR) bifurcation)\vspace{0.1cm}} \\
  \commandf{save('beta')} & save output-files as \filef{b.beta, s.beta,
      d.beta} \\
\hline
\parbox[t]{3in}{
  \commandf{run(r1("TR1"),ICP=['alpha','beta'], ISW=2,ILP=0,STOP=['R11','R21'])}\vspace{0.1cm}}&
\parbox[t]{3in}{
  continue the TR bifurcation in two parameters until a 1:1 or 1:2
  resonance is found\vspace{0.1cm}}\\
  \commandf{save('hen')} & save output-files as \filef{b.hen, s.hen, d.hen} \\
  \commandf{run(DS='-')} & compute last continuation the opposite way\\
  \commandf{append('hen')} & append output-files to \filef{b.hen, s.hen, d.hen} \\
\hline
\parbox[t]{3in}{
  \commandf{run(r1("PD1"),ICP=['alpha','beta'], ISW=2,ILP=0)}\vspace{0.1cm}}&
\parbox[t]{3in}{
  continue the PD bifurcation in two parameters\vspace{0.1cm}}\\
  \commandf{append('hen')} & append output-files as \filef{b.hen, s.hen, d.hen} \\
  \commandf{run(DS='-')} & compute last continuation the opposite way\\
  \commandf{append('hen')} & append output-files to \filef{b.hen, s.hen, d.hen} \\
\hline
\parbox[t]{3in}{
  \commandf{r4=run(c='hen',ICP=['alpha'], DS='-',STOP=['LP1'])}\vspace{0.1cm}}&
  \parbox[t]{3in}{
    fixed point solution branch for $\alpha$
    ($\beta=1$) (detects and stops at a fold (LP))\vspace{0.1cm}} \\
  \commandf{save('alpha')} & save output-files as \filef{b.alpha, s.alpha,
      d.alpha} \\
\hline
\parbox[t]{3in}{
  \commandf{run(r4("LP1"),ICP=['alpha','beta'], ISW=2,ILP=0)}\vspace{0.1cm}}&
\parbox[t]{3in}{
  continue the LP bifurcation in two parameters}\\
  \commandf{append('hen')} & append output-files as \filef{b.hen, s.hen, d.hen} \\
  \commandf{run(DS='-')} & compute last continuation the opposite way\\
  \commandf{append('hen')} & append output-files to \filef{b.hen, s.hen, d.hen} \\
\hline
\commandf{merge('hen')} & 
\parbox[t]{3in}{
join all forward and backward branches into
single branches\vspace{0.1cm}}\\
\commandf{relabel('hen')} & make all labels unique\\
\hline
\end{tabular}
\caption{Commands for running demo \filef{hen}.}
\label{tbl:demo_hen}
\end{center}
\end{table}

%merge('hen')
%relabel('hen')



%==============================================================================
%==============================================================================
\chapter{ {\cal AUTO} Demos : Periodic solutions.} \label{ch:Demos_Periodic}
%==============================================================================
%==============================================================================

%==============================================================================
%DEMO=lrz======================================================================
%==============================================================================
\newpage
\section{ lrz : The Lorenz Equations.} \label{sec:Demos_lrz}
This demo computes two symmetric homoclinic orbits in the Lorenz equations
\begin{equation} \begin{array}{cl}
  x' &=  \sigma (y - x), \\
  y' &=  \rho x - y - x z,  \\
  z' &=  x y - \beta z. \\ \end{array} \end{equation}
Here $\rho$ is the free parameter, and $\beta=8/3$, $\sigma=10$.
The two homoclinic orbits correspond to the final, large period orbits 
on the two periodic solution families.

\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | l |}
\hline
  \AUTO-COMMAND  & ACTION \\
\hline
%==============================================================================

  \commandf{mkdir lrz} & create an empty work directory \\ 
  \commandf{cd lrz} & change directory \\
  \commandf{demo('lrz')} & copy the demo files to the work directory \\
\hline
%==============================================================================
  \commandf{lrz=run(e='lrz',c='lrz')} & compute stationary solutions \\ 
  \commandf{save('lrz')} & save all output to \filef{b.lrz, s.lrz, d.lrz} \\ \hline
%==============================================================================
\parbox[t]{3in}{
  \commandf{run(lrz('HB1'),IPS=2,ICP=['rho',
    'PERIOD'],NMX=35,NPR=2,DS=0.5)}\vspace{0.2cm}}
& \parbox[t]{3in}{
 compute periodic solutions; the final orbit is near-homoclinic.
 \vspace{0.2cm}}\\
 \commandf{append('lrz')} & append all output to \filef{b.lrz, s.lrz, d.lrz} \\ 
\hline
%==============================================================================
\parbox[t]{3in}{
  \commandf{run(lrz('HB2'),IPS=2,ICP=['rho',
    'PERIOD'],NMX=35,NPR=2,DS=0.5)}
\vspace{0.2cm}} & compute the symmetric periodic solution family \\ 
  \commandf{append('lrz')} & append all output to \filef{b.lrz, s.lrz, d.lrz} \\ 
\hline
\end{tabular}
\caption{Commands for running demo \filef{lrz}.}
\label{tbl:demo_lrz}
\end{center}
\end{table}

\newpage
%==============================================================================
%DEMO=abc======================================================================
%==============================================================================
\section{ abc : The A \texorpdfstring{$\to$}{to} B 
\texorpdfstring{$\to$}{to} C Reaction.} \label{sec:Demos_abc}
This demo illustrates the computation of 
stationary solutions,
Hopf bifurcations 
and
periodic solutions
in the A $\to$ B $\to$ C reaction 
(\citename{DoHe:83} \citeyear{DoHe:83}).
\begin{equation} \begin{array}{cl}
  u_1 ' &=  -u_1 + p_1 (1-u_1) e^{u_3}, \\
  u_2 ' &=  -u_2 +  p_1 e^{u_3} ( 1-u_1 - p_5 u_2 ),\\
  u_3 ' &=  -u_3 - p_3 u_3 + p_1 p_4 e^{u_3}  
  ( 1-u_1 + p_2 p_5 u_2 ),\\ \end{array} \end{equation}
with $p_2=1$, $p_3=1.55$, $p_4=8$, and $p_5=0.04$. 
The free parameter is $p_1$.

The equations, as programmed in the equations-file {\tt abc.f90},
appear in Table~\ref{tbl:demo_abcE1}.
The starting point, an equilibrium of the equations,
is also defined in  the equations-file {\tt abc.f90},
as shown in  Table~\ref{tbl:demo_abcE2}.
(The equations-file {\tt abc.f90} also contains the skeletons
of some other routines, which must be supplied, but which 
are not used in this application.)

A more advanced version, that continues branch points in three
parameters is provided by the demo {\tt abcb}.

In the constants-file ({\tt c.abc.1}) for the first run, as shown in 
Table~\ref{tbl:demo_abcC1}, we note the following:

\begin{itemize}
\item[-] {\tt IPS=1}~: a family of stationary solutions is computed.

\item[-] {\tt IRS=0}~: the starting point defined in {\tt STPNT} 
	 is to be used (see  Table~\ref{tbl:demo_abcE2}). 

\item[-] {\tt ICP=[1]}~: the continuation parameter is PAR(1) 

\item[-] {\tt UZR=\{-1:0.4\}}~: there is one user output point, namely at
	 {\tt PAR(1)=0.4}. Moreover, since the index ("{\tt -1}") in
	 the last line of the constants-file {\tt c.abc.1} is negative, 
	 the calculation will terminate when the calculation reaches
	 the value {\tt PAR(1)=0.4}..
\end{itemize}

In the constants-file ({\tt c.abc.2}) for the second run, as shown in 
Table~\ref{tbl:demo_abcC2}, we note that:

\begin{itemize}
\item[-] {\tt IPS=2}~: a family of periodic solutions is computed.

\item[-] {\tt IRS=2}~: the starting point is the solution with label 2,
         (a Hopf bifurcation point), to be read from the solutions-file 
	 (here {\tt s.abc}).

\item[-] {\tt ICP=[1,11]}~: there are two continuation parameters
	 (namely {\tt PAR(1)}, and the period, {\tt PAR(11)}). 

\item[-] {\tt UZR=\{-1:0.25\}}~: there is one user output point, now at
	 {\tt PAR(1)=0.25}, where the calculation is to terminate,
	 since the index ("{\tt -1}") is negative.
\end{itemize}

%------------------------------------------------------
\begin{table}[htbp]
{\small
\begin{center}
\begin{boxedverbatim}
      SUBROUTINE FUNC(NDIM,U,ICP,PAR,IJAC,F,DFDU,DFDP) 
!     ---------- ---- 

      IMPLICIT NONE
      INTEGER, INTENT(IN) :: NDIM, ICP(*), IJAC
      DOUBLE PRECISION, INTENT(IN) :: U(NDIM), PAR(*)
      DOUBLE PRECISION, INTENT(OUT) :: F(NDIM)
      DOUBLE PRECISION, INTENT(INOUT) :: DFDU(NDIM,NDIM), DFDP(NDIM,*)

      DOUBLE PRECISION X1,X2,X3,D,ALPHA,BETA,B,S,E,X1C

       X1=U(1)
       X2=U(2)
       X3=U(3)

       D=PAR(1)
       ALPHA=PAR(2)
       BETA=PAR(3)
       B=PAR(4)
       S=PAR(5)

       E=DEXP(X3)
       X1C=1-X1

       F(1)=-X1 + D*X1C*E
       F(2)=-X2 + D*E*(X1C - S*X2)
       F(3)=-X3 - BETA*X3 + D*B*E*(X1C + ALPHA*S*X2)

      END SUBROUTINE FUNC
\end{boxedverbatim}
\end{center}
}
\caption{The equations for demo {\tt abc}, 
as defined in the equations-file {\tt abc.f90}.}
\label{tbl:demo_abcE1}
\end{table}
%------------------------------------------------------


%------------------------------------------------------
\begin{table}[htbp]
{\small
\begin{center}
\begin{boxedverbatim}
      SUBROUTINE STPNT(NDIM,U,PAR,T) 
!     ---------- ----- 

      IMPLICIT NONE
      INTEGER, INTENT(IN) :: NDIM
      DOUBLE PRECISION, INTENT(INOUT) :: U(NDIM),PAR(*)
      DOUBLE PRECISION, INTENT(IN) :: T

       PAR(1)=0.0
       PAR(2)=1.0
       PAR(3)=1.55
       PAR(4)=8.
       PAR(5)=0.04

       U(1)=0.
       U(2)=0.
       U(3)=0.

      END SUBROUTINE STPNT
\end{boxedverbatim}
\end{center}
}
\caption{The starting solution for demo {\tt abc}, 
as defined in the equations-file {\tt abc.f90}.}
\label{tbl:demo_abcE2}
\end{table}
%------------------------------------------------------

%------------------------------------------------------
\begin{table}[htbp]
{\small
\begin{center}
\begin{boxedverbatim}
NDIM=   3, IPS =   1, IRS =   0, ILP =   1
ICP =  [1]
NTST=  15, NCOL=   4, IAD =   3, ISP =   1, ISW = 1, IPLT= 0, NBC= 0, NINT= 0
NMX=  130, NPR=  200, MXBF=  10, IID =   2, ITMX= 8, ITNW= 5, NWTN= 3, JAC= 0
EPSL= 1e-07, EPSU = 1e-07, EPSS =0.0001
DS  =  0.02, DSMIN= 0.001, DSMAX=   0.1, IADS=   1
NPAR = 5, THL =  {11: 0.0}, THU =  {}
UZR =  {1: 0.4}, STOP = ['UZ1']
\end{boxedverbatim}
\end{center}
}
\caption{The constants-file {\tt c.abc.1} for Run 1 (stationary solutions)
of demo {\tt abc}.}
\label{tbl:demo_abcC1}
\end{table}
%------------------------------------------------------


%------------------------------------------------------
\begin{table}[htbp]
{\small
\begin{center}
\begin{boxedverbatim}
NDIM=   3, IPS =   2, IRS =   2, ILP =   1
ICP =  [1, 11]
NTST=  25, NCOL=   4, IAD =   3, ISP =   1, ISW = 1, IPLT= 0, NBC= 0, NINT= 0
NMX=  200, NPR=  200, MXBF=  10, IID =   2, ITMX= 8, ITNW= 5, NWTN= 3, JAC= 0
EPSL= 1e-07, EPSU = 1e-07, EPSS =0.0001
DS  =  0.02, DSMIN= 0.001, DSMAX=   0.1, IADS=   1
NPAR = 5, THL =  {11: 0.0}, THU =  {}
UZR =  {1: 0.25}, STOP = ['UZ1']
\end{boxedverbatim}
\end{center}
}
\caption{The constants-file {\tt c.abc.2} for Run 2 (periodic orbits) 
of demo {\tt abc}.}
\label{tbl:demo_abcC2}
\end{table}
%------------------------------------------------------


\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | l |}
\hline
  COMMAND  & ACTION \\ 
\hline
%==============================================================================
  \commandf{mkdir abc} & create an empty work directory \\ 
  \commandf{cd abc} & change directory \\
  \commandf{@dm abc} & copy the demo files to the work directory \\
\hline
%==============================================================================
  \commandf{@R abc 1} & compute the stationary solution family 
						with four Hopf bifurcations \\ 
  \commandf{@sv abc} & save output-files as {\tt b.abc, s.abc, d.abc} \\ 
\hline
%==============================================================================
  \commandf{@R abc 2} & compute a family of periodic solutions from the first Hopf point \\ 
  \commandf{@ap abc} & append the output-files to {\tt b.abc, s.abc, d.abc} \\ 
\hline
%==============================================================================
  \commandf{@R abc 3} & compute a family of periodic solutions from the second Hopf point \\ 
  \commandf{@ap abc} & append the output-files to {\tt b.abc, s.abc, d.abc} \\ 
\hline
%==============================================================================
  \commandf{@R abc 4} & compute a family of periodic solutions from the third Hopf point \\ 
  \commandf{@ap abc} & append the output-files to {\tt b.abc, s.abc, d.abc} \\ 
\hline
%==============================================================================
  \commandf{@R abc 5} & compute a family of periodic solutions from the fourth Hopf point \\ 
  \commandf{@ap abc} & append the output-files to {\tt b.abc, s.abc, d.abc} \\ 
\hline
%==============================================================================
\end{tabular}
\caption{Unix Commands for running demo {\tt abc}.}
\label{tbl:demo_abcL}
\end{center}
\end{table}

%------------------------------------------------------
\begin{table}[htbp]
{\small 
\begin{center} 
\begin{boxedverbatim}
abc=run(e='abc',c='abc.1')
abc=abc+run(abc('HB1'),c='abc.2')
abc=abc+run(abc('HB2'),c='abc.3')
abc=abc+run(abc('HB3'),c='abc.4')
abc=abc+run(abc('HB4'),c='abc.5')
save(abc,'abc')
\end{boxedverbatim}
\end{center}
}
\caption{Python Commands for running demo {\tt abc}.}
\label{tbl:demo_abcP1}
\end{table}
%------------------------------------------------------

%------------------------------------------------------
\begin{table}[htbp]
{\small
\begin{center}
\begin{boxedverbatim}
abc=run(e='abc',c='abc.1')
for solution in abc('HB'):
    abc=abc+run(solution,c='abc.2')
abc=rl(abc)
save(abc,'abc')
\end{boxedverbatim}
\end{center}
}
\caption{Python Program for running demo {\tt abc}.}
\label{tbl:demo_abcP2}
\end{table}
%------------------------------------------------------


\newpage
%==============================================================================
%DEMO=pp2======================================================================
%==============================================================================
\section{ pp2 : A 2D Predator-Prey Model.} \label{sec:Demos_pp2}
This demo illustrates the computation of families of stationary
solutions, including bifurcating stationary families, as well as
the detection of a Hopf bifurcation.
The first run computes the families of stationary solutions, bounded
by $0\le p_1\le 1$ and $u_1 \ge -0.25$. Then the script \filef{pp2.auto}
scans the first run for Hopf bifurcations, finds one, and computes
the family of periodic solutions that emanates
from the Hopf bifurcation. This family terminates in
a heteroclinic orbit. The continuation is configured to stop if the period
\parf{PAR(11)}$=36$, when the heteroclinic orbit is very close.

The equations, which model a predator-prey system with harvesting, are
\begin{equation} \begin{array}{cl}
  u_1 ' &= p_2 u_1 (1 - u_1 ) - u_1 u_2 - p_1 (1-e^{-p_3 u_1}) ,\\
  u_2 ' &= -u_2  + p_4 u_1 u_2  .\end{array} \end{equation}
Here $p_1$ (quota) is the principal continuation parameter,
while $p_2=p_4=3$ and $p_3=5$, are fixed. The variables $u_1$ and
$u_2$ denote prey and predator, for instance fish and sharks.
The use of {\cal PLAUT} is also illustrated. The saved plots are shown
in Figure~\ref{fig:pp2_1} and  Figure~\ref{fig:pp2_2}.
You can obtain similar figures using the Python CLUI's plot
command and using {\cal PLAUT04}.
\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | l |}
\hline
  COMMAND  & ACTION \\
\hline
%==============================================================================
  \commandf{mkdir pp2} & create an empty work directory \\ 
  \commandf{cd pp2} & change directory \\ 
  \commandf{@dm pp2} & copy the demo files to the work directory \\ 
\hline
%============================================================================== 
  \commandf{auto pp2.auto } or & Run the script pp2.auto\\
  \commandf{auto('pp2.auto') } & \\
\hline
%==============================================================================
\end{tabular}
\caption{Commands for running demo {\tt pp2}.}
\label{tbl:demo_pp2_1}
\end{center}
\end{table}

\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | l |}
\hline
  {\cal AUTO}-COMMAND  & ACTION \\
\hline
  \commandf{@p pp2} or \commandf{@pp pp2} & 
  \begin{minipage}{10cm}~\\
  run {\cal PLAUT} or {\cal
    PyPLAUT} to graph the contents of {\tt b.pp2} and {\tt s.pp2};\\
  \end{minipage}
  \\ 
\hline
  {\cal PLAUT/PyPLAUT}-COMMAND  & ACTION \\
\hline
  \commandf{d2}  & set convenient defaults\\ 
  \commandf{ax}  & select axes \\ 
  \commandf{1 3}  & select real columns 1 and 3 in {\tt b.pp2} \\ 
  \commandf{bd0}  & plot the bifurcation diagram; $max~u_1$ versus $p_1$ \\
\hline
  \commandf{d1}  & choose other default settings \\ 
  \commandf{bd}  & get blow-up of current bifurcation diagram \\ 
  \commandf{0~ 1 ~-0.25~ 1} & enter diagram limits  \\
  \commandf{sav}  & save plot (see Figure~\ref{fig:pp2_1})\\
  \commandf{fig.1} or \commandf{fig1.eps} & upon prompt, enter a new
  file name, e.g., {\tt fig.1} or {\tt fig.eps}\\
  \commandf{cl}  & clear the screen  \\
\hline
  \commandf{2d}  & enter 2D mode, for plotting labeled solutions\\ 
  \commandf{11 15 19 23}  & select these labeled orbits in {\tt s.pp2}\\ 
  \commandf{d}  & default orbit display; $u_1$ versus time\\
\hline
  \commandf{1 3}  & select columns 1 and 3 in {\tt s.pp2} \\
  \commandf{d}  & display the orbits; $u_2$ versus time\\
\hline
  \commandf{2 3}  & select columns 2 and 3 in {\tt s.pp2} \\
  \commandf{d}  & phase plane display; $u_2$ versus $u_1$\\
  \commandf{sav}  & save plot  (see Figure~\ref{fig:pp2_2})\\
  \commandf{fig.2} or \commandf{fig2.eps} & upon prompt, enter a new file name \\
  \commandf{ex}  & exit from 2D mode  \\
\hline
  \commandf{end}  & exit from {\cal PLAUT/PyPLAUT} \\
\hline
%==============================================================================
\end{tabular}
\caption{Plotting commands for demo {\tt pp2}.}
\label{tbl:demo_pp2_2}
\end{center}
\end{table}

%------------------------------------------------------
\begin{figure}[p]
\epsfysize 9.0cm
\centerline{\epsffile{include/pp21}}
\caption{The bifurcation diagram of demo {\tt pp2}.}
\label{fig:pp2_1}
\end{figure}
%------------------------------------------------------

%------------------------------------------------------
\begin{figure}[p]
\epsfysize 9.0cm
\centerline{\epsffile{include/pp22}}
\caption{The phase plot of solutions 11, 15, 19, and 23 in demo {\tt pp2}.}
\label{fig:pp2_2}
\end{figure}
%------------------------------------------------------


\newpage
%==============================================================================
%DEMO=lor======================================================================
%==============================================================================
\section{ lor : Starting an Orbit from Numerical Data.} \label{sec:Demos_lor}
This demo illustrates how to start the computation of a family of
periodic solutions from numerical data obtained, for example, from an
initial value solver.
As an illustrative application we consider the Lorenz equations
\begin{equation} \begin{array}{cl}
  x' &=  \sigma (y - x), \\
  y' &=  \rho x - y - x z,  \\
  z' &=  x y - \beta z. \\\end{array} \end{equation}
Numerical simulations with a simple initial value solver show the
existence of a stable periodic orbit when $\rho=280$, $\beta=8/3$, $\sigma=10$.
Numerical data representing one complete periodic oscillation are
contained in the file \filef{lor.dat}. 
Each row in \filef{lor.dat} contains four real numbers, namely,
the time variable $t$, $x$, $y$ and $z$.
The correponding parameter values are defined in the user-supplied subroutine
\filef{STPNT}.
The \AUTO constant \parf{dat='lor'} then allows for using
the data in \filef{lor.dat} where we also specify \parf{IRS=0}.
The mesh will be suitably adapted to the solution, using the number of
mesh intervals \parf{NTST} and the number of collocation point per mesh
interval \parf{NCOL} specified in the constants-file \filef{c.lor.1}.

\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | l |}
\hline
  \AUTO-COMMAND  & ACTION \\
\hline
%==============================================================================
  \commandf{mkdir lor} & create an empty work directory \\ 
  \commandf{cd lor} & change directory \\
  \commandf{demo('lor')} & copy the demo files to the work directory \\
\hline
%==============================================================================
  \commandf{lor=run('lor',c='lor.1')} & compute a solution family, restart from \filef{lor.dat} \\ 
  & save to bifurcation diagram object \parf{lor} \\ 
\hline
%==============================================================================
  \commandf{pd=run(lor('PD1'),c='lor.2')} & \parbox[t]{3in}{ switch branches at a period-doubling detected in the first run.  Constants changed : {\tt IRS, ISW, NTST} \vspace{0.2cm}} \\ 
  \commandf{save(lor+pd,'lor')} & save the two runs to \filef{b.lor, s.lor, d.lor} \\ 
\hline
%==============================================================================
\end{tabular}
\caption{Commands for running demo \filef{lor}.}
\label{tbl:demo_lor}
\end{center}
\end{table}

\newpage
%==============================================================================
%DEMO=frc======================================================================
%==============================================================================
\section{ frc : A Periodically Forced System.} \label{sec:Demos_frc}
This demo illustrates the computation of periodic solutions
to a periodically forced system.
In \AUTO this can be done by adding a nonlinear oscillator with
the desired periodic forcing as one of the solution components.
An example of such an oscillator is
\begin{equation} \begin{array}{cl}
 x'&=x + \beta y - x (x^{2} + y^{2}),  \\
 y'&=-\beta x + y - y (x^{2} + y^{2}), \\\end{array} \end{equation}
which has the asymptotically stable solution $x=sin (\beta t)$,
$y=cos (\beta t)$.
We couple this oscillator to the Fitzhugh-Nagumo equations~:
\begin{equation} \begin{array}{cl}
 v'&=\bigl( F(v) - w \bigr) / \eps,  \\
 w'&=v - dw - \bigl( b + r \sin(\beta t) \bigr) ,
\end{array} \end{equation}
by replacing $\sin(\beta t)$ by $x$.
Above, $F(v) = v (v-a) (1-v)$ and $a,b,\eps$ and $d$ are fixed.
The first run is a homotopy from $r=0$, where a solution is known analytically,
to $r=0.2$.
Part of the solution family with $r=0.2$ and varying $\beta$ 
is computed in the second run.
For detailed results see 
\citename{AlDoOt:90} \citeyear{AlDoOt:90}.


\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | l |}
\hline
  \AUTO-COMMAND  & ACTION \\
\hline
%==============================================================================
  \commandf{mkdir frc} & create an empty work directory \\ 
  \commandf{cd frc} & change directory \\
  \commandf{demo('frc')} & copy the demo files to the work directory \\
\hline
%============================================================================== 
  \commandf{r1=run(e='frc',c='frc')} & homotopy to $r=0.2$ \\ 
  \commandf{save(r1,'0')} & save output-files as \filef{b.0, s.0, d.0} \\ 
\hline
%==============================================================================
\parbox[t]{3in}{
  \commandf{r2=run(r1('UZ1'),ICP=[5,11],
    NMX=20,DS=-0.5,DSMAX=5.0)}\vspace{0.2cm}} & 
  \parbox[t]{3in}{ compute solution family; restart from \parf{r1}. \vspace{0.2cm}} \\ 
  \commandf{save(r2,'frc')} & save output-files as \filef{b.frc, s.frc, d.frc} \\ 
\hline
%==============================================================================
\end{tabular}
\caption{Commands for running demo \filef{frc}.}
\label{tbl:demo_frc}
\end{center}
\end{table}

\newpage
%==============================================================================
%DEMO=ppp======================================================================
%==============================================================================
\section{ ppp :  Continuation of Hopf Bifurcations.} \label{sec:Demos_ppp}
This demo illustrates the continuation of Hopf bifurcations in a 3-dimensional 
predator prey model (\citename{Do:84} \citeyear{Do:84}).
This curve contain branch points, where one locus of Hopf points
bifurcates from another locus of Hopf points, and generalized Hopf (Bautin)
bifurcations (GH), where the Hopf bifurcation changes from sub- to
supercritical. The diagnostics file \filef{d.hb} can be inspected to
see where the Hopf bifurcation is subcritical and where it is supercritical.
The equations are
\begin{equation} \begin{array}{cl}
  u_1 ' &= u_1(1-u_1) - p_4 u_1 u_2  ,  \\
  u_2 ' &= -p_2 u_2 + p_4 u_1 u_2 - p_5 u_2 u_3
  -p_1(1-e^{-p_6 u_2}) \\
  u_3 ' &= -p_3 u_3  + p_5 u_2 u_3  .  \\  
\end{array} \end{equation}
Here $p_2=1/4$,  $p_3=1/2$,  $p_4=3$,  $p_5=3$,  $p_6=5$,
and $p_1$ is the free parameter.
In the continuation of Hopf points the parameter $p_4$
is also free.

\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | l |}
\hline
  \AUTO-COMMAND  & ACTION \\
\hline
%==============================================================================
  \commandf{mkdir ppp} & create an empty work directory \\ 
  \commandf{cd ppp} & change directory \\
  \commandf{demo('ppp')} & copy the demo files to the work directory \\
\hline
%==============================================================================
  \commandf{ppp=run(e='ppp',c='ppp')} & 
  \parbox[t]{3in}{
  compute stationary solutions; detect Hopf bifurcations
  \vspace{0.2cm}}\\ 
\hline
%==============================================================================
  \parbox[t]{3.4in}{
    \commandf{ppp=ppp+run(ppp("HB2"),IPS=2,ICP=[1,11],
      ILP=0,NMX=15,NPR=50,DS=0.1,DSMAX=0.5)}\vspace{0.2cm}} & 
  compute a family of periodic solutions\\
  \commandf{save(ppp,'ppp')} & save the output to \filef{b.ppp, s.ppp, d.ppp} \\ 
\hline
%==============================================================================
  \parbox[t]{3.4in}{
  \commandf{hb =
    run(ppp("HB2"),ICP=[1,4],ILP=0,
    ISW=2,NMX=100,RL1=0.58,DSMAX=0.1)\vspace{0.2cm}}} & 
    compute Hopf bifurcation curves \\ 
  \commandf{save(hb,'hb')} & save the output-files as \filef{b.hb, s.hb, d.hb} \\ 
\hline
%==============================================================================
\end{tabular}
\caption{Commands for running demo \filef{ppp}.}
\label{tbl:demo_ppp_1}
\end{center}
\end{table}


\newpage
%==============================================================================
%DEMO=plp======================================================================
%==============================================================================
\section{ plp : Fold Continuation for Periodic Solutions.} \label{sec:Demos_plp}
This demo, which corresponds to computations in 
\citename{DoKeKe:91a} \citeyear{DoKeKe:91a}, shows how one can
continue folds on a family of periodic solutions in two parameters.
The calculation of a locus of Hopf bifurcations is also included.
The equations, that model a one-compartment activator-inhibitor system 
(\citename{JPK:80} \citeyear{JPK:80}),
are given by
\begin{equation} \begin{array}{cl}
 s' &= (s_{0} - s) - \rho R (s,a), \\
 a' &=\alpha (a_{0} - a) - \rho R (s,a), \\
\end{array} \end{equation}
where
$$ R(s,a)=\frac{s a}{1+s+ \kappa s^{2} },
\qquad \kappa  > 0. $$
The free parameter is $\rho$.
In the Hopf and fold continuations the parameter $s_0$ is also free.
The computed loci of Hopf points and folds suggest the existence
of {\it isolas} of periodic solutions. The computation of one such 
isola is also included in this demo. All calculations can be carried 
out by running the Python script \filef{plp.auto} included in the demo.

\newpage
%==============================================================================
%DEMO=ph1======================================================================
%==============================================================================
\section{ ph1 : Phase-Shifting using Continuation.} \label{sec:Demos_ph1}
This demo, which uses the activator-inhibitor model in 
\citename{DoKeKe:91a} \citeyear{DoKeKe:91a}, shows how one can
phase-shift a periodic solution. This can be useful in applications, for example 
when one wants a component of a periodic solution to have a specific value at 
time $0$.
The equations are given by
\begin{equation} \begin{array}{cl}
 s' &= (s_{0} - s) - \rho R (s,a)~, \\
 a' &=\alpha (a_{0} - a) - \rho R (s,a)~, \\
\end{array} \end{equation}
where
$$ R(s,a)=\frac{s a}{1+s+ \kappa s^{2} }~.$$
The first two runs compute a family
of stationary solutions and a bifurcating family of periodic solutions.
The free problem parameter in these runs is $\rho$.
The results are saved in the files \filef{b.sa}, \filef{s.sa}, and \filef{d.sa}.
The third run starts at a specified
periodic solution in \filef{s.sa}, namely, the solution with label $6$, and
phase-shifts this solution in time until $s(0)=30$. The above sequence of 
calculations can be carried out by running the Python script \filef{ph1.auto} 
included in the demo.

The basic idea for doing the phase shift in the third run is to drop the integral 
phase condition, which is automatically added when the {\cal AUTO}-constant \parf{IPS}
has value $2$. For this purpose the third run uses the value $4$ for \parf{IPS},
as specified in \filef{c.ph1}, in which case the periodicity conditions must be
specified explicitly in the subroutine {\tt BCND} in the equations-file \filef{ph1.f90}. 
Also, the interval of periodicity must be scaled explicitly to the interval $[0,1]$, 
which introduces the period $T$ as an explicit parameter in the differential equations.
Note that no integral phase condition is specified in {\tt ICND}. 
The problem formulation in \filef{ph1.f90} is therefore

\begin{equation} \begin{array}{cl}
 s' &= T[(s_{0} - s) - \rho R (s,a)]~, \\
 a' &= T[\alpha (a_{0} - a) - \rho R (s,a)]~, \\
\end{array} \end{equation}
\\
with boundary conditions
\\
\begin{equation} \begin{array}{cl}
 s(0) - s(1) &= 0~, \\
 a(0) - a(1) &= 0~. \\
\end{array} \end{equation}

Note that the \AUTO parameter {\tt PAR(9)}, defined in the subroutine
{\tt PVLS} in \filef{ph1.f90}, is used to monitor the value of $s(0)$.
Since there are two constraints, the third run requires only one free 
parameter, namely $T$ ({\tt PAR(11)}). Note that, to numerical accuracy, 
$T$ does not change during this run.
Alternatively one can use the free parameter $\rho$ ({\tt PAR(4)})
in the third run. In this case, to numerical accuracy, $\rho$ does not 
change during the run.
The third run terminates when {\tt PAR(9)} reached the value $30$, as 
specified in the equations-file \filef{c.ph1}.

\newpage
%==============================================================================
%DEMO=pp3======================================================================
%==============================================================================
\section{ pp3 : Periodic Families and Loci of Hopf Points.} \label{sec:Demos_pp3}
This demo illustrates the computation of stationary solution families
that contain Hopf bifurcations, and the computation of the emanating
families of periodic solutions.  In this example the periodic 
solution families intersect at a secondary bifurcation point 
(a branch point). It it also shown how to compute a locus of Hopf bifurcation
points in two parameters. (In this example the locus contains branch points,
which lead to another locus!)

The equations, which model a 3D predator-prey system with harvesting
(\citename{Do:84} \citeyear{Do:84}), are 
\begin{equation} \begin{array}{cl}
  u_1 ' &= u_1(1-u_1) - p_4 u_1 u_2  ,  \\
  u_2 ' &= -p_2 u_2 + p_4 u_1 u_2 - p_5 u_2 u_3
  -p_1(1-e^{-p_6 u_2}) \\
  u_3 ' &= -p_3 u_3  + p_5 u_2 u_3  .  \\\end{array} \end{equation}
The free parameter is $p_1$, while the other parameters are fixed,
namely $p_2=0.25$, $p_3=0.5$, $p_4=4$, $p_5=3$, and $p_6=5$.
However, both $p_1$ and $p_4$ are free in the computation of loci of Hopf points.

The script in \filef{pp3.auto} first computes the bifurcation diagram
involving the stationary solutions. It finds four Hopf bifurcations.
A periodic orbit family is computed from each of these four Hopf
bifurcations. Then the second Hopf bifurcation from the first run
is continued in two parameters, also producing the other locus.

\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | l |}
\hline
  COMMAND  & ACTION \\
\hline
%==============================================================================
  \commandf{mkdir pp3} & create an empty work directory \\ 
  \commandf{cd pp3} & change directory \\ 
  \commandf{@dm pp3} & copy the demo files to the work directory \\ 
\hline
%============================================================================== 
  \commandf{auto pp3.auto } or & Run the script pp3.auto\\
  \commandf{auto('pp3.auto') } & \\
%==============================================================================
\hline
%==============================================================================
\end{tabular}
\caption{Commands for running demo {\tt pp3}.}
\label{tbl:demo_pp3}
\end{center}
\end{table}

\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | l |}
\hline
  {\cal AUTO}-COMMAND  & ACTION \\
\hline
  \commandf{@p pp3} or \commandf{@pp pp3} & \begin{minipage}{8cm}~\\
      run {\cal PLAUT/PyPLAUT} to graph the contents of {\tt b.pp3} and {\tt
        s.pp3};\\
      \end{minipage} \\ 
\hline
  {\cal PLAUT/PyPLAUT}-COMMAND  & ACTION \\
\hline
  \commandf{d2}  & set convenient defaults\\ 
  \commandf{ax}  & select axes \\ 
  \commandf{1 3}  & select real columns 1 and 3 in {\tt b.pp3} \\ 
  \commandf{bd0}  & plot the bifurcation diagram; $max~u_1$ versus $p_1$ \\
\hline
  \commandf{bd}  & get blow-up of current bifurcation diagram \\ 
  \commandf{0~ 0.6 ~0~ 1.2} & enter diagram limits  \\
\hline
  \commandf{d1}  & choose other default settings (with labels) \\ 
  \commandf{bd}  & another blow-up of the bifurcation diagram \\ 
  \commandf{0~ 0.6 ~0~ 0.75} & enter diagram limits  \\
\hline
  \commandf{d2}  & set defaults\\ 
  \commandf{2d}  & enter 2D mode, for plotting labeled solutions\\ 
  \commandf{13 14 15 }  & select these orbits from {\tt s.pp3}\\ 
  \commandf{d}  & default orbit display; $u_1$ versus time\\
\hline
  \commandf{2 3}  & select columns 2 and 3 in {\tt s.pp3} \\
  \commandf{d}  & display the orbits; $u_2$ versus $u_1$\\
\hline
  \commandf{2d}  & enter 2D mode, for plotting labeled solutions\\ 
  \commandf{16 17 18 19}  & select these orbits\\ 
  \commandf{d}  & default orbit display; $u_1$ versus time\\
\hline
  \commandf{2 3}  & select columns 2 and 3 in {\tt s.pp3} \\
  \commandf{d}  & phase plane display; $u_2$ versus $u_1$\\
\hline
  \commandf{2 4}  & select columns 2 and 4 in {\tt s.pp3} \\
  \commandf{d}  & phase plane display; $u_3$ versus $u_1$\\
  \commandf{ex}  & exit from 2D mode  \\
\hline
  \commandf{end}  & exit from {\cal PLAUT} \\
\hline
%==============================================================================
\end{tabular}
\caption{Plotting commands for demo {\tt pp3}.}
\label{tbl:demo_pp3_2}
\end{center}
\end{table}

\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | l |}
\hline
  {\cal AUTO}-COMMAND  & ACTION \\
\hline
  \commandf{@p hb} or \commandf{@pp hb} & run {\cal PLAUT/PyPLAUT} to
  graph \\
 & the contents of {\tt b.hb} and {\tt s.hb}; \\ 
\hline
  {\cal PLAUT/PyPLAUT}-COMMAND  & ACTION \\
\hline
  \commandf{d0}  & set defaults\\ 
  \commandf{ax}  & select axes \\ 
  \commandf{1 6}  & select real columns 1 and 6 in {\tt b.hb} \\ 
  \commandf{bd0}  & plot the bifurcation diagram; $p_4$ versus $p_1$ \\
\hline
  \commandf{end}  & exit from {\cal PLAUT} \\
\hline
%==============================================================================
\end{tabular}
\caption{Plotting the Hopf loci for demo {\tt pp3}.}
\label{tbl:demo_pp3_3}
\end{center}
\end{table}


\newpage
%==============================================================================
%DEMO=tor======================================================================
%==============================================================================
\section{ tor : Detection of Torus Bifurcations.} \label{sec:Demos_tor}
This demo uses a model in 
\citename{FrRLuGaPo:93} \citeyear{FrRLuGaPo:93}
 to illustrate the detection of a torus bifurcation. 
It also illustrates branch switching at a secondary periodic bifurcation
with double Floquet multiplier at $z=1$.
The computational results also include folds, homoclinic orbits,
and period-doubling bifurcations.
Their continuation is not illustrated here;
see instead the demos \filef{plp}, \filef{pp2}, and \filef{pp3}, respectively.  
The equations are
\begin{equation} \begin{array}{cl}
  x'(t) & = \bigr[ -(\beta+\nu)x + \beta y - a_3 x^3 + b_3 (y-x)^3 \bigr] / r,\\
  y'(t) &= \beta x - (\beta + \gamma) y - z - b_3 (y-x)^3, \\
  z'(t) &= y,\end{array} \end{equation}
where $\gamma=-0.6$, $r=0.6$, $a_3=0.328578$, and $b_3=0.933578$.
Initially $\nu=-0.9$ and $\beta=0.5$.

\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | l |}
\hline
  \AUTO-COMMAND  & ACTION \\
\hline
%==============================================================================
  \commandf{mkdir tor} & create an empty work directory \\ 
  \commandf{cd tor} & change directory \\
  \commandf{demo('tor')} & copy the demo files to the work directory \\
\hline
%==============================================================================
  \commandf{r1=run(e='tor',c='tor')} & 
  \parbox[t]{3in}{
  1st run; compute a stationary solution family with Hopf bifurcation
  \vspace{0.2cm}}\\ 
\hline
%==============================================================================
  \commandf{r2=run(r1("HB1"),IPS=2,ICP=[1,11])} &
  \parbox[t]{3in}{ compute a family of periodic solutions; restart from \parf{r1}. \vspace{0.2cm}} \\ 
\hline
%==============================================================================
  \commandf{r3=run(r2("BP1"),ISW=-1,NMX=90)} & \parbox[t]{3in}{ compute a bifurcating family of periodic solutions; restart from \parf{r2}. \vspace{0.2cm}} \\ 
  \commandf{save(r1+r2+r3,'1')} & save output to \filef{b.1, s.1, d.1} \\ 
\hline
%==============================================================================
\end{tabular}
\caption{Commands for running demo \filef{tor}.}
\label{tbl:demo_tor}
\end{center}
\end{table}

\newpage
%==============================================================================
%DEMO=pen======================================================================
%==============================================================================
\section{ pen : Rotations of Coupled Pendula.} \label{sec:Demos_pen}
This demo illustrates the computation of rotations, i.e., solutions that
are periodic, modulo a phase gain of an even multiple of $\pi$.
\AUTO checks the starting data for components with such a phase gain
and, if present, it will automatically adjust the computations accordingly.
The model equations, a system of two coupled  pendula, 
(\citename{DoArOt:91} \citeyear{DoArOt:91}),
are given by
\begin{equation} \begin{array}{cl}
 & \phi_1'' + \eps \phi_1' + \sin \phi_1 
  = I + \gamma(\phi_2-\phi_1), \\
 & \phi_2'' + \eps \phi_2' + \sin \phi_2 
  = I + \gamma(\phi_1-\phi_2) ,\\
\end{array} \end{equation}
or, in equivalent first order form,
\begin{equation} \begin{array}{cl}
 & \phi_1'  =  \psi_1, \\
 & \phi_2'  =  \psi_2, \\
 & \psi_1'  = - \eps \psi_1 - \sin \phi_1 + I + \gamma(\phi_2-\phi_1), \\
 & \psi_2'  = - \eps \psi_2 - \sin \phi_2 + I + \gamma(\phi_1-\phi_2).\\
\end{array} \end{equation}
Throughout $\gamma=0.175$. Initially, $\eps=0.1$ and $I=0.4$.

Numerical data representing one complete rotation are
contained in the file \filef{pen.dat}. 
Each row in \filef{pen.dat} contains five real numbers, namely,
the time variable $t$, $\phi_1$, $\phi_2$, $\psi_1$ and $\psi_2$.
The correponding parameter values are defined in the user-supplied subroutine
\funcf{ STPNT}.

Actually, in this example, a scaled time variable $t$ is given in \filef{pen.dat}. 
For this reason the period (\parf{PAR(11)}) is also set in \funcf{STPNT}.
Normally \AUTO would automatically set the period according to
the data in \filef{pen.dat}.

The \AUTO-constant \parf{dat='pen'} in \filef{c.pen.1}
causes \AUTO to start from the data in \filef{pen.dat}.
The mesh will be suitably adapted to the solution, using the number of
mesh intervals \parf{NTST} and the number of collocation point per mesh
interval \parf{NCOL} specified in the constants-file \filef{c.pen.1}.

The first run, with $I$ as free problem parameter,
starts from the solution (here \parf{IRS=0}) in \filef{pen.dat}.
A period-doubling bifurcation is located, and the period-doubled family
is computed in the second run.
Two branch points are located, and the bifurcating
families are traced out in the third and fourth run, respectively.
The fifth run generates starting data for the subsequent computation of
a locus of period-doubling bifurcations.
The actual computation is done in the sixth run, with $\eps$ and $I$
as free problem parameters.

\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | l |}
\hline
  \AUTO-COMMAND  & ACTION \\
\hline
%==============================================================================
  \commandf{mkdir pen} & create an empty work directory \\ 
  \commandf{cd pen} & change directory \\
  \commandf{demo('pen')} & copy the demo files to the work directory \\
\hline
%==============================================================================
  \commandf{pen=run('pen',c='pen.1')} & \parbox[t]{3in}{
locate a period doubling bifurcation; restart from \filef{pen.dat}} \\ 
\hline
%==============================================================================
  \commandf{pen=pen+run(pen('PD1'),c='pen.2')} & \parbox[t]{3in}{ a
    family of  period-doubled (and out-of-phase) rotations.
    Constants changed : \parf{IPS, NTST, ISW, NMX} \\
    append output to bifurcation diagram object \filef{pen}} \\
\hline
%============================================================================== 
  \commandf{pen=pen+run(pen('BP1'),c='pen.3')} & \parbox[t]{3in}{  a secondary bifurcating family (without bifurcation detection).  Constants changed : \parf{IRS, ISP} \\ 
  append output to bifurcation diagram object \filef{pen}} \\
\hline
%==============================================================================
  \commandf{pen=pen+run(pen('BP2'),c='pen.4')} & \parbox[t]{3in}{
    another secondary bifurcating family (without bifurcation
    detection).  Constants changed : \parf{IRS}\\
    append output to bifurcation diagram object \filef{pen}
 \vspace{0.2cm}}\\
\commandf{save(pen,'pen')} & save \parf{pen} to output-files \filef{b.pen, s.pen, d.pen} \\ 

\hline
%==============================================================================
  \commandf{t=run(pen('PD1'),c='pen.5')} & \parbox[t]{3in}{  generate starting data for period doubling continuation.  Constants changed : \parf{IRS, ICP, ICP, ISW, NMX} \vspace{0.2cm}} \\ 
\hline
%==============================================================================
  \commandf{pd=run(t,sv='pd')} & \parbox[t]{3in}{  compute a locus of period doubling bifurcations; restart from \parf{t}.  Constants changed : \parf{IRS} \vspace{0.2cm}} \\ 
  & save output-files as \filef{b.pd, s.pd, d.pd} \\ 
%\hline
%==============================================================================
%%  \commandf{@pn pen} & run an animation program to view the solutions in \filef{s.pen} \\ 
%%  & (on SGI machines only; see also the file \filef{auto/07p/pendula/README}).
%  \\ 
\hline
%==============================================================================
\end{tabular}
\caption{Commands for running demo \filef{pen}.}
\label{tbl:demo_pen}
\end{center}
\end{table}

\newpage
%==============================================================================
%DEMO=chu======================================================================
%==============================================================================
\section{ chu :  A Non-Smooth System (Chua's Circuit).} \label{sec:Demos_chu}
Chua's circuit 
is one of the simplest electronic devices to exhibit complex behavior. 
For related calculations see
\citename{KhRoCh:93} \citeyear{KhRoCh:93}.
The equations modeling the circuit are
\begin{equation} \begin{array}{cl}
 u_1' &=  \alpha \bigl[~ u_2 - h(u_1) ~\bigr]~,\\ 
 u_2' &=  u_1 - u_2 + u_3~, \\  
 u_3' &=  - \beta~ u_2~,  
\end{array} \end{equation}
where
$$ h(x) = a_1 x + \frac{1}{2}~ (a_0 - a_1) ~
  \bigl\{ \abs{x+1} -  \abs{x-1} \bigr\}~,$$
and where we take
$\beta = 14.3$, $a_0 = - 1/7$, $a_1 = 2/7$.

Note that $h(x)$ is not a smooth function, and hence the solution 
to the equations  may have non-smooth derivatives.
However, for the orthogonal collocation method to attain its optimal accuracy,
it is necessary that the solution be sufficiently smooth.
Moreover, the adaptive mesh selection strategy will fail
if the solution or one of its lower order derivatives has discontinuities.
For these reasons  we use the smooth approximation
$$ \abs{x} ~\approx~ \frac{2 x}{\pi } ~ {\rm arctan}(Kx),$$
which get better as $K$ increases.
In the numerical calculations below we use $K = 10$.
The free parameter is $\alpha$.


\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | l |}
\hline
  \AUTO-COMMAND  & ACTION \\
\hline
%==============================================================================
  \commandf{mkdir chu} & create an empty work directory \\ 
  \commandf{cd chu} & change directory \\
  \commandf{demo('chu')} & copy the demo files to the work directory \\
\hline
%==============================================================================
  \commandf{r1=run(e='chu',c='chu')} & 1st run; stationary solutions \\ 
\hline
%==============================================================================
  \commandf{r2=run(r1("HB1"),IPS=2,ICP=[1,11])} & \parbox[t]{3in}{ 2nd run; periodic solutions, with detection of period-doubling. \vspace{0.2cm}} \\ 
  \commandf{save(r1+r2,'chu')} & save all output to \filef{b.chu, s.chu, d.chu} \\ 
\hline
%==============================================================================
\end{tabular}
\caption{Commands for running demo \filef{chu}.}
\label{tbl:demo_chu}
\end{center}
\end{table}

\newpage
%==============================================================================
%DEMO=phs======================================================================
%==============================================================================
\section{ phs : Effect of the Phase Condition.} \label{sec:Demos_phs}
This demo illustrates the effect of the phase condition 
on the computation of periodic solutions.
We consider the differential equation
\begin{equation} \begin{array}{cl}
 u_1'&= \lambda u_1 - u_2,  \\
 u_2'&= u_1 (1-u_1) .  \\
\end{array} \end{equation}
This equation has a Hopf bifurcation from the trivial solution at $\lambda=0$. 
The bifurcating family of periodic solutions
is vertical and along it the period increases monotonically.
The family terminates in a homoclinic orbit containing the
saddle point $(u_1,u_2)=(1,0)$.
Graphical inspection of the computed periodic orbits,
for example $u_1$ versus the scaled time variable $t$,
shows how the phase condition has the effect of keeping the ``peak'' 
in the solution in the same location.

\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | l |}
\hline
  \AUTO-COMMAND  & ACTION \\
\hline
%==============================================================================
  \commandf{mkdir phs} & create an empty work directory \\ 
  \commandf{cd phs} & change directory \\
  \commandf{demo('phs')} & copy the demo files to the work directory \\
\hline
%==============================================================================
  \commandf{r1=run(e='phs',c='phs.1')} & detect Hopf bifurcation \\ 
\hline
%==============================================================================
  \commandf{r2=run(r1('HB1'),c='phs.2')} & \parbox[t]{3in}{ compute periodic solutions. Constants changed : \parf{IRS, IPS, NPR} \vspace{0.2cm}} \\ 
  \commandf{save(r1+r2,'phs')} & save output to \filef{b.phs, s.phs, d.phs} \\ 
\hline
%==============================================================================
\end{tabular}
\caption{Commands for running demo \filef{phs}.}
\label{tbl:demo_phs}
\end{center}
\end{table}

\newpage
%==============================================================================
%DEMO=ivp======================================================================
%==============================================================================
\section{ ivp :  Time Integration with Euler's Method.} \label{sec:Demos_ivp}
This demo uses Euler's method to locate a stationary solution of the
following predator-prey system with harvesting~:

\begin{equation} \begin{array}{cl}
  u_1 ' &= p_2 u_1 (1 - u_1 ) - u_1 u_2 - p_1 (1-e^{-p_3 u_1}) ,\\
  u_2 ' &= -u_2  + p_4 u_1 u_2  ,\\\end{array} \end{equation}
where all problem parameters have a fixed value.
The equations are the same as those in demo \filef{pp2}.
The continuation parameter is the independent time variable, namely \parf{PAR(14)}.

Note that Euler time integration is only first order accurate, so that
the time step must be sufficiently small to ensure correct results.
Indeed, this option has been added only as a convenience, and should 
generally be used only to locate stationary states.
Note that the \AUTO-constants \parf{DS}, \parf{DSMIN}, and \parf{DSMAX}
control the step size
in the space consisting of time, here \parf{PAR(14)}, and the state vector,
here $(u_1,u_2)$.

\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | l |}
\hline
  \AUTO-COMMAND  & ACTION \\
\hline
%==============================================================================
  \commandf{mkdir ivp} & create an empty work directory \\ 
  \commandf{cd ivp} & change directory \\
  \commandf{demo('ivp')} & copy the demo files to the work directory \\
\hline
%==============================================================================
  \commandf{r1=run(e='ivp',c='ivp')} & time integration \\ 
  \commandf{save(r1,'ivp')} & save output-files as \filef{b.ivp, s.ivp, d.ivp} \\ 
\hline
%==============================================================================
\end{tabular}
\caption{Commands for running demo \filef{ivp}.}
\label{tbl:demo_ivp}
\end{center}
\end{table}


\newpage
%==============================================================================
%DEMO=r3b======================================================================
%==============================================================================
\section{ r3b : The Circular Restricted 3-Body Problem (CR3BP).} \label{sec:Demo_r3b}

This demo computes periodic solutions and two-dimensional unstable
manifolds of those periodic solutions in the restricted three body
problem:
\begin{align*}
\dot x &= x_p\\
\dot y &= y_p\\
\dot z &= z_p\\
\dot x_p&= 2y_p+x-(1-\mu)\frac{x+\mu}{{d_E}^3}-\mu\frac{x-1+\mu}{{d_M}^3}+lx_p\\
\dot y_p &= -2x_p +y - (1-\mu)\frac{y}{{d_E}^3} - \mu\frac{y}{{d_M}^3} + l y_p\\
\dot z_p &= -(1-\mu)\frac{z}{{d_E}^3} - \mu\frac{z}{{d_M}^3} + l z_p
\end{align*}
where $d_E=\sqrt{(x+\mu)^2+y^2+z^2}$ and $d_M=\sqrt{(x-1+\mu)^2+y^2+z^2}$.
Here $l\ne 0$ breaks the conservativeness of the system. In general,
continuations involve $l$ as a parameter, and $l$ will then
approximately stay at zero.

\subsection{Computation of Periodic Solutions of the CR3BP}

Running the Python script \filef{r3b.auto} will generate the families of periodic 
solutions L1, H1, and V1, for the case of the mass-ratio $\mu=0.063$:
\begin{center}
\begin{tabular}{l | l }
\commandf{auto r3b.auto} & \commandf{auto('r3b.auto')} \\
\end{tabular}
\end{center}
where, as in the following examples, the left hand side command can be used
at the shell prompt, and the right hand side command at the Python CLUI
prompt. Note that the commands starting with @ work in both interfaces,
but cannot be used in the expert scripts with a .py suffix.

For example, the data generated for the Lyapunov family L1 will
consist of
\begin{center}
\begin{tabular}{l l}
\filef{b.L1} & the bifurcation diagram data \\
\filef{s.L1} & a selection of periodic orbits \\
\filef{d.L1} & diagnostic data, including Floquet multipliers \\
\end{tabular}
\end{center}
The necessary labeled starting solutions are first computed and stored
in the file \filef{s.start}.
Each starting solution is an equilibrium (``libration
point''), and its data also contains the period of a bifurcating family of
periodic orbits.

The Table below shows the label of each of the starting solutions in 
s.start, indicating which libration point it corresponds to, and which 
family of periodic orbits it will generate:
\begin{center}
\begin{tabular}{| l | l | l |}
\hline
		Label&	Libration Pt.	&Family \\
\hline
		  1 &	    L1	&	  L1 \\
	  	  2 &       L1	&	  V1 \\
	  	  3 &       L2	&	  L2 \\
	  	  4 &       L2	&	  V2 \\
	  	  5 &       L3	&         L3 \\
	  	  6 &       L3	&	  V3 \\
	  	  7 &       L4	&	  V4 \\
	  	  8 &       L5	&	  V5 \\
\hline
\end{tabular}
\end{center}
Note (by looking at the constant-files \filef{c.r3b.*}) that actually only the 
starting solutions labeled 1 and 2 are used in the current calculations, 
as executed by the Python script.

Starting solution for other values of $\mu$ can be generated using the script
\filef{compute\_lps.py}, for instance by running
\begin{center}
\begin{tabular}{l | l}
\commandf{autox compute\_lps.py 0.05}	& \commandf{import compute\_lps} \\
					& \commandf{compute\_lps.compute(0.05)} \\
\end{tabular}
\end{center}
After that, it is necessary to run \filef{r3b.auto} again to regenerate the
families.

The demos L1a, H1a, H1b, H1c, V1a, V1b can be run subsequent to the r3b
demo to compute 2D unstable manifolds of selected periodic orbits that
belong to the L1, V1, and H1 families.

\subsection{Computing Unstable Manifolds of Periodic Orbits in the CR3BP}

Instructions for computing 2-d unstable manifolds of periodic orbits 
in the Circular Restricted 3-Body Problem (CR3BP) using AUTO-07p. 

\subsubsection{The instructions below are for the Halo family L1 in AUTO demo L1a.}

Instructions for computing 2-d unstable manifolds of other periodic 
orbits in the CR3BP are similar (Demos H1a, H1b, H1c, V1a, V1b), and
are given after these instructions.

Select a labeled solution which has exactly one Floquet multiplier with
absolute value greater than 1. (Floquet multipliers can be found in the file
\filef{d.L1} generated by demo r3b.) Enter the label of the periodic solution
in the file \filef{L1a.auto} at {\tt label=} in \filef{L1a.auto}. Also enter
the size of the
initial step into the direction of the unstable manifold there at {\tt step=}.
Note that representative values of these three quantities have already
been entered there.\\
Now run the Python script \filef{L1a.auto}:
\begin{center}
\begin{tabular}{ l | l }
\commandf{auto L1a.auto} & \commandf{auto('L1a.auto')}
\end{tabular}
\end{center}
This will run \filef{r3b.auto} as above if this was not already done.

Through various computational steps the execution of the Python script
will result in AUTO files \filef{b.L1a}, \filef{s.L1a}, and
\filef{d.L1a}, where the orbits in 
\filef{s.L1a} constitute the manifold, which can be viewed with the graphics 
program \commandf{plaut04} or \commandf{r3bplaut04}:
\begin{center}
\begin{tabular}{ l | l }
\commandf{@pl L1a} or \commandf{@r3b L1a} & \commandf{plot3('L1a',r3b=True)}
\end{tabular}
\end{center}
The various steps executed by the Python commands in the script file
\filef{L1a.auto} are explained below in Tables~\ref{tbl:demo_l1a1} and
\ref{tbl:demo_l1a2}, which also show
the equivalent Unix shell versions of these AUTO commands.

The Python script \filef{L1aX.auto} does the same as
\filef{L1a.auto}, but with
additional calculations that generate additional AUTO data files, e.g., 
to detect heteroclinic connections. Some of these additional runs take 
quite a bit of CPU time and generate big data files.

\begin{table}[htbp]
\begin{center}
\begin{tabular}{|l|l|}
\hline
\commandf{mkdir r3b}	& \commandf{mkdir r3b} \\
\commandf{cd r3b}	& \commandf{cd r3b} \\
\commandf{@dm r3b}	& \commandf{demo('r3b')} \\
\multicolumn{2}{|l|}{Copy the r3b demo to the local directory r3b.}\\
\hline

\commandf{auto r3b.auto} & \commandf{auto('r3b.auto')} \\
\multicolumn{2}{|l|}{Generate the CR3BP AUTO data files.} \\
\hline

\commandf{autox ext.py L1 3 -1e-5} & \commandf{import ext} \\
			& \commandf{sext=ext.get('L1',3,-1e-5)} \\
\multicolumn{2}{|p{7in}|}{
                Convert the data for a selected labeled solution from
                \filef{s.L1}, 
		adding a zero adjoint variable. The solution label is 3,
                and the initial step size into the unstable manifold
                is $-10^{-5}$.
		The \filef{ext.py} script looks for the relevant
                Floquet multiplier in
		\filef{d.L1}. The converted solution will be written in the
                file \filef{s.ext} or stored in \parf{sext}.}\\
\hline

\commandf{@r flq ext}	& \commandf{flq=run(sext,c='flq',e='flq')} \\
\multicolumn{2}{|p{7in}|}{
		Compute the Floquet eigenfunction. Free scalar variables in
		this run (see \filef{c.flq}) are: 

                \begin{tabular}{l@{=}l}
		\parf{PAR(1)} & unfolding parameter \\
		\parf{PAR(4)} & multiplier\\
		\parf{PAR(5)} & norm of eigenfunction\\
                \end{tabular}

		If this run is successful then \filef{PAR(5)}
                should become nonzero,
		in fact, \filef{PAR(5)} should reach the value 1. 
                If the run is not successful then see REMARK 1 below.}\\
\hline

\commandf{@sv flq} & \commandf{save(flq,'flq')} \\
\multicolumn{2}{|l|}{
		Save the results in \filef{b.flq}, \filef{s.flq}, and
                \filef{d.flq}.}\\
\hline

\commandf{autox data.py} & \commandf{import data} \\
			& \commandf{startman=data.get(flq('UZ1'))} \\
\multicolumn{2}{|p{7in}|}{
		Extract data for a selected orbit from \filef{s.flq}.
                These data 
		are for both the orbit and its Floquet eigenfunction. It 
		is assumed that \filef{s.flq}
                contains only one labeled solution, 
		with label 2. If you did the ``optional'' computation (see 
		Remark 2) you may need to change the label of the 
		restart solution:}\\
\commandf{autox data.py flq n} & \commandf{startman=data.get(flq(n))} \\
\multicolumn{2}{|p{7in}|}{
		where $n$ is the different label number.
                The extracted data may be saved in a file called
                \filef{s.startman},
                which contains a new starting solution that can be
                used as a base for the manifold computations.
                The orbit coordinates are at
                ``time zero'', and the Floquet eigenfunction
                are saved at \parf{PAR(25:30)} and \parf{PAR(31:36)},
                respectively.}\\
\hline

\commandf{@R man L1a.0 startman}& \commandf{startL1a = run(startman,e='man',c='man.L1a.0')} \\
\multicolumn{2}{|p{7in}|}{
                This step does a time integration using continuation in the
                ``period'' $T$, i.e., \parf{PAR(11)}, which here is
                the
                ``integration time''.
                The labeled solutions from this run all correspond
                to the same orbit, except that the orbit gets longer and
                longer. The starting point of the orbit is the point on the
                periodic orbit at ``time zero'' plus a small distance
                ($\varepsilon$)
                into the direction of the unstable manifold. In \AUTO,
                $\varepsilon$
                corresponds to
                \parf{PAR(6)}. This parameter $\varepsilon$ is initialized
                via the script \filef{ext.py}.
                (The sign of $\varepsilon$ is significant!)
                The parameters in this run (see \filef{c.man.L1a.0}) are:

                \begin{tabular}{l@{=}lll@{=}l}
                  \parf{PAR(3)}  & energy & &
                  \parf{PAR(21)} & $x$-coordinate at end point\\
                  \parf{PAR(11)} & integration time & &
                  \parf{PAR(22)} & $y$-coordinate at end point\\
                  \parf{PAR(12)} & length of the orbit & &
                  \parf{PAR(23)} & $z$-coordinate at end point
                \end{tabular}
              }\\
\hline

\commandf{@sv startL1a}		& \commandf{save(startL1a,'startL1a')} \\
\multicolumn{2}{|l|}{
Save the results in \filef{b.startL1a}, \filef{s.startL1a}, 
and \filef{d.startL1a}.
}\\
\hline
\end{tabular}
\end{center}
\caption{Detailed AUTO shell and Python commands for the L1a demo
  (part 1).}
\label{tbl:demo_l1a1}
\end{table}


\begin{table}[htbp]
\begin{center}
\begin{tabular}{|l|l|}
\hline
\commandf{@R man L1a.1 startL1a} & \commandf{L1a=run(startL1a,c='man.L1a.1')} \\
\multicolumn{2}{|p{7in}|}{
		Look at \filef{c.man.L1a.1} to see from which label in
                \filef{s.startL1a} this
		run starts. In this run the y-coordinate of the end point 
		(\parf{PAR(22)}) is kept fixed,
                while the ``period'' (\parf{PAR(11)}), 
		i.e., the total integration time, is allowed to vary, as 
		is the value of epsilon, i.e., \parf{PAR(6)}.
                Note that if \parf{PAR(6)}
		becomes ``large'' then the manifold may no longer be accurate.
		The free parameters in this run are:

                \begin{tabular}{l@{=}lll@{=}l}
                  \parf{PAR(3)}  & energy & &
                  \parf{PAR(12)} & length of the orbit \\
                  \parf{PAR(6)}  & ``starting distance'' & &
                  \parf{PAR(21)} & $x$-coordinate at end point \\
                  \parf{PAR(11)} & integration time & &
                  \parf{PAR(23)} & $z$-coordinate at end point
                \end{tabular}
}\\
\hline

\commandf{@sv L1a}			& \commandf{save(L1a,'L1a')} \\

\multicolumn{2}{|l|}{
Save the results in \filef{b.L1a}, \filef{s.L1a}, and \filef{d.L1a}.
}\\
\hline

\commandf{@R man L1a.2 startL1a} &
\commandf{L1a2=run(startL1a,c='man.L1a.2')} \\
\multicolumn{2}{|p{7in}|}{
		Another run, starting from a longer initial orbit, which 
		computes part of the manifold. The free parameters are the 
		same as in the preceding run. This computation results in 
		the orbit winding around the selected periodic L1
                orbit.
}\\
\hline
\commandf{@sv L1a2} & \commandf{save(L1a2,'L1a2')} \\

\multicolumn{2}{|l|}{
		Save the results in \filef{b.L1a2}, \filef{s.L1a2},
                and
                \filef{d.L1a2} .}\\
\hline
\end{tabular}
\end{center}
\caption{Detailed AUTO shell and Python commands for the L1a demo
  (part 2).}
\label{tbl:demo_l1a2}
\end{table}

\noindent Use
\begin{center}
\begin{tabular}{ l | l }
\commandf{auto clean.auto} & \commandf{auto('clean.auto')}\\
\end{tabular}
\end{center}
to remove all generated files.

\noindent\textbf{REMARK 1}\\
If the run to compute the Floquet eigenfunction is not successful, i.e., if 
\parf{PAR(5)} does not become nonzero,
then try to compute the Floquet eigenfunction
in more stages, as in Table~\ref{tbl:demo_r3b_remark1}.

\begin{table}[htbp]
\begin{center}
\begin{tabular}{|l|l|}
\hline
\multicolumn{2}{|p{7in}|}{
		Give the label of the selected solution, and a value that 
		is smaller than the associated Floquet multiplier (magnitude
		greater than 1) .}\\
\commandf{autox ext.py L1 3 -1e-5 2000} & \commandf{import ext} \\
			& \commandf{sext=ext.get('L1',3,-1e-5,2000)} \\
\hline
\commandf{@R flq 2 ext}	& \commandf{flq=run(sext,c='flq.2',e='flq')} \\

\multicolumn{2}{|p{7in}|}{
		Continue the approximate multiplier; If all goes well then 
		the actual multiplier will be detected as a branch point 
		(BP) with Label 2. Free scalar variables in this run are: 

                \begin{tabular}{l@{=}l}
		\parf{PAR(1)} & unfolding parameter \\
		\parf{PAR(4)} & multiplier\\
		\parf{PAR(5)} & norm of eigenfunction
              \end{tabular}}\\
\hline

\commandf{@sv flq} & \commandf{save(flq,'flq')} \\
\hline
\commandf{@R flq 3} & \commandf{flq=run(flq,e='flq',c='flq.3')} \\

\multicolumn{2}{|p{7in}|}{
		Switch branches at the BP, thereby generating the nonzero 
		Floquet eigenfunction. The free scalar variables are : 

                \begin{tabular}{l@{=}l}
		\parf{PAR(1)} & unfolding parameter \\
		\parf{PAR(4)} & multiplier\\
		\parf{PAR(5)} & norm of eigenfunction
                \end{tabular}

		If all goes well then \parf{PAR(5)} should become
                nonzero, and the
		corresponding solution should have Label 4.
}\\
\hline
\commandf{@sv flq} & \commandf{save(flq,'flq')}\\
\hline
\end{tabular}
\end{center}
\caption{Detailed AUTO shell and Python commands for Remark 1.}
\label{tbl:demo_r3b_remark1}
\end{table}

\noindent\textbf{REMARK 2}\\
One can also follow the orbit, its multiplier and eigenfunction, as in
Table~\ref{tbl:demo_r3b_remark2}.

\begin{table}[htbp]
\begin{center}
\begin{tabular}{|l|l|}
\hline
\commandf{@R flq 4} & \commandf{flq=run(flq,e='flq',c='flq.4')}\\
\multicolumn{2}{|p{7in}|}{
		Free scalar variables in this run are

                \begin{tabular}{l@{=}l}
		\parf{PAR(1)}  & unfolding parameter \\
		\parf{PAR(4)}  & multiplier \\
		\parf{PAR(11)} & period \\
                \end{tabular}

		The norm, \parf{PAR(5)}, of the eigenfunction is fixed in
                this run.
}\\
\hline
\commandf{@sv flq} & \commandf{save(flq,'flq')}\\
\hline
\end{tabular}
\end{center}
\caption{Detailed AUTO shell and Python commands for Remark 2.}
\label{tbl:demo_r3b_remark2}
\end{table}

\subsubsection{The instructions below are for the Halo family H1 in AUTO demo H1a.}

Follow the instructions for L1a above, where you replace L by H throughout,
for instance you can run everything in one go using
\begin{center}
\begin{tabular}{l|l}
	\commandf{auto H1a.auto} & \commandf{auto('H1a.auto')} \\
\end{tabular}
\end{center}
or with the extra calculations:
\begin{center}
\begin{tabular}{l|l}
	\commandf{auto H1aX.auto} & \commandf{auto('H1aX.auto')} \\
\end{tabular}
\end{center}
The Floquet eigenfunction is now computed from label 7 with step size
$-10^{-3}$.
The detailed commands are likewise, except for the manifold calculations
in Table~\ref{tbl:demo_l1a2}, and those are given in
Table~\ref{tbl:demo_h1a}.

\begin{table}[htbp]
\begin{center}
\begin{tabular}{|l|l|}
\hline
\commandf{@R man H1a.1 startH1a} &
\commandf{H1a=run(startH1a,e='man',c='man.H1a.1')}\\
\multicolumn{2}{|p{7in}|}{
		Look at c.man.H1a.1 to see from which label in s.startH1a this
		run starts. In this run the x-coordinate of the end point 
		(\parf{PAR(21)}) is kept fixed, while the ``period''
                (\parf{PAR(11)}), 
		i.e., the total integration time, is allowed to vary, as 
		is the value of $\varepsilon$, i.e.,
                \parf{PAR(6)}. Note that if \parf{PAR(6)}
		becomes ``large'' then the manifold may no longer be accurate.
		The free parameters in this run are:

                \begin{tabular}{l@{=}lll@{=}l}
                  \parf{PAR(3)}  & energy & &
                  \parf{PAR(12)} & length of the orbit \\
                  \parf{PAR(6)}  & ``starting distance'' & &
                  \parf{PAR(22)} & $y$-coordinate at end point \\
                  \parf{PAR(11)} & integration time & &
                  \parf{PAR(23)} & $z$-coordinate at end point
                \end{tabular}}\\
\hline
\commandf{@sv H1a} &\commandf{save(H1a,'H1a')}\\

\multicolumn{2}{|l|}{
Save the results in \filef{b.H1a}, \filef{s.H1a}, and \filef{d.H1a}.}\\
\hline

\commandf{@R man H1a.2 startH1a} &
\commandf{hetH1a=run(startH1a,e='man',c='man.H1a.2')}\\

\multicolumn{2}{|p{7in}|}{
  Another run, starting from a longer initial orbit, which 
  computes part of the manifold. The free parameters are the 
  same as in the preceding run. This computation results in 
  the detection of a connecting orbit.
}\\
\hline
\commandf{@sv hetH1a} &\commandf{save(hetH1a,'hetH1a')}\\
\multicolumn{2}{|l|}{
Save the results in \filef{b.hetH1a}, \filef{s.hetH1a}, and \filef{d.hetH1a}.}\\
\hline
\end{tabular}
\end{center}
\caption{Detailed AUTO shell and Python commands for the H1a demo.}
\label{tbl:demo_h1a}
\end{table}

\subsubsection{The instructions below are for the Halo family H1 in AUTO demo H1b.}

Follow the instructions for L1a above, where you replace L by H, and a by b
throughout; for instance you can run everything in one go using
\begin{center}
\begin{tabular}{l|l}
	\commandf{auto H1b.auto} & \commandf{auto('H1b.auto')} \\
\end{tabular}
\end{center}
or with the extra calculations:
\begin{center}
\begin{tabular}{l|l}
	\commandf{auto H1bX.auto} & \commandf{auto('H1bX.auto')} \\
\end{tabular}
\end{center}
The Floquet eigenfunction is now computed from label 3 with step size
$-10^{-5}$.
The detailed commands follow the ones for H1a above, except that there
is one extra run; see Table~\ref{tbl:demo_h1b}.

\begin{table}[htbp]
\begin{center}
\begin{tabular}{|l|l|}
\hline
\commandf{@R man H1b.3 startH1b} &
\commandf{het2H1b=run(startH1b,e='man',c='man.H1b.3')}\\
\multicolumn{2}{|p{7in}|}{
		Another run, starting from a longer initial orbit, which 
		computes part of the manifold. The free parameters are the 
		same as in the preceding run. This computation results in 
		the detection of another connecting orbit.
}\\
\hline
\commandf{@sv het2H1b} & \commandf{save(het2H1b,'het2H1b')}\\
\multicolumn{2}{|l|}{
Save the results in \filef{b.het2H1b}, \filef{s.het2H1b}, and
                \filef{d.het2H1b}.}\\
\hline
\end{tabular}
\end{center}
\caption{Detailed AUTO shell and Python commands for the H1b demo.}
\label{tbl:demo_h1b}
\end{table}

\subsubsection{The instructions below are for the Halo family H1 in AUTO demo H1c.}

Follow the instructions for L1a above, where you replace L by H, and a by c
throughout; for instance you can run everything in one go using
\begin{center}
\begin{tabular}{l|l}
	\commandf{auto H1c.auto} & \commandf{auto('H1c.auto')} \\
\end{tabular}
\end{center}
The Floquet eigenfunction is now computed from label 68 with step size
$-10^{-2}$.

The detailed commands follow the ones for H1a above, except that the last
run is left out, and so the \filef{H1cX.auto} script is not necessary.

\subsubsection{The instructions below are for the Halo family V1 in AUTO demo V1a.}

Follow the instructions for L1a above, where you replace L by V throughout,
for instance you can run everything in one go using
\begin{center}
\begin{tabular}{l|l}
	\commandf{auto V1a.auto} & \commandf{auto('V1a.auto')} \\
\end{tabular}
\end{center}
The Floquet eigenfunction is now computed from label 8 with step size
$-10^{-5}$.
The detailed commands are likewise, except for the manifold calculations
in Table~\ref{tbl:demo_l1a2}, and those are given in
Table~\ref{tbl:demo_v1a}.

\begin{table}[htbp]
\begin{center}
\begin{tabular}{|l|l|}
\hline
\commandf{@R man V1a.1 startV1a} &
\commandf{V1a=run(startV1a,e='man',c='man.V1a.1')}\\

\multicolumn{2}{|p{7in}|}{
		Look at \filef{c.man.V1a.1} to see from which label in
                \filef{s.startV1a} this
		run starts. In this run the $z$-coordinate of the end point 
		(\parf{PAR(23)})
                is kept fixed, while the ``period'' (\parf{PAR(11)}), 
		i.e., the total integration time, is allowed to vary, as 
		is the value of $\varepsilon$, i.e., \parf{PAR(6)}.
                Note that if \parf{PAR(6)}
		becomes ``large'' then the manifold may no longer be accurate.
		The free parameters in this run are:
                \begin{tabular}{l@{=}lll@{=}l}
                  \parf{PAR(3)}  & energy & &
                  \parf{PAR(12)} & length of the orbit \\
                  \parf{PAR(6)}  & ``starting distance'' & &
                  \parf{PAR(21)} & $x$-coordinate at end point \\
                  \parf{PAR(11)} & integration time & &
                  \parf{PAR(22)} & $y$-coordinate at end point
                \end{tabular}
}\\
\hline
\commandf{@sv V1a} & \commandf{save(V1a,'V1a')}\\
\multicolumn{2}{|l|}{
		Save the results in \filef{b.V1a}, \filef{s.V1a}, and
                \filef{d.V1a}.}\\
\hline
\end{tabular}
\end{center}
\caption{Detailed AUTO shell and Python commands for the V1a demo.}
\label{tbl:demo_v1a}
\end{table}

\subsubsection{The instructions below are for the Halo family V1 in AUTO demo V1b.}

Follow the instructions for L1a above, where you replace L by V, and a by b
throughout; for instance you can run everything in one go using
\begin{center}
\begin{tabular}{l|l}
	\commandf{auto V1b.auto} & \commandf{auto('V1b.auto')} \\
\end{tabular}
\end{center}
or with the extra calculations:
\begin{center}
\begin{tabular}{l|l}
	\commandf{auto V1bX.auto} & \commandf{auto('V1bX.auto')} \\
\end{tabular}
\end{center}
The Floquet eigenfunction is now computed from label 12 with step size
$10^{-5}$.

The detailed commands are likewise, except for the manifold calculations
in Table~\ref{tbl:demo_l1a2}, and those are given in
Table~\ref{tbl:demo_v1b}.

\begin{table}[htbp]
\begin{center}
\begin{tabular}{|l|l|}
\hline
\commandf{@R man V1b.1 startV1b} &
\commandf{V1b=run(startV1b,e='man',c='man.V1b.1')}\\
\multicolumn{2}{|p{7in}|}{
		Look at \filef{c.man.V1b.1}
                to see from which label in \filef{s.startV1b} this
		run starts. In this run the $x$-coordinate of the end point 
		(\parf{PAR(21)}) is kept fixed, while the ``period''
                (\parf{PAR(11)}), 
		i.e., the total integration time, is allowed to vary, as 
		is the value of $\varepsilon$, i.e., \parf{PAR(6)}.
                Note that if \parf{PAR(6)}
		becomes ``large'' then the manifold may no longer be accurate.
		The free parameters in this run are:
                \begin{tabular}{l@{=}lll@{=}l}
                  \parf{PAR(3)}  & energy & &
                  \parf{PAR(12)} & length of the orbit \\
                  \parf{PAR(6)}  & ``starting distance'' & &
                  \parf{PAR(22)} & $y$-coordinate at end point \\
                  \parf{PAR(11)} & integration time & &
                  \parf{PAR(23)} & $z$-coordinate at end point
                \end{tabular}}\\
\hline
\commandf{@sv V1b}			& \commandf{save(V1b,'V1b')}\\
\multicolumn{2}{|l|}{
		Save the results in \filef{b.V1b}, \filef{s.V1b}, and
                \filef{d.V1b} .}\\
\hline
\commandf{@R man V1b.2 startV1b} &
\commandf{hetV1b=run(startV1b,e='man',c='man.V1b.2')} \\
\multicolumn{2}{|p{7in}|}{
		Another run, starting from a longer initial orbit, which 
		computes part of the manifold. The free parameters are the 
		same as in the preceding run. This computation results in 
		the detection of a connecting orbit.}\\
\hline

\commandf{@sv hetV1b} & \commandf{save(hetV1b,'hetV1b')}\\
\multicolumn{2}{|l|}{
		Save the results in \filef{b.hetV1b},
                \filef{s.hetV1b}, and \filef{d.hetV1b} .
}\\
\hline
\end{tabular}
\end{center}
\caption{Detailed AUTO shell and Python commands for the V1b demo.}
\label{tbl:demo_v1b}
\end{table}

%==============================================================================
%==============================================================================
\chapter{ \AUTO Demos : BVP.} \label{ch:Demos_BVP}
%==============================================================================
%==============================================================================

%==============================================================================
%DEMO=exp======================================================================
%==============================================================================
\section{ exp : Bratu's Equation.} \label{sec:Demos_exp}
This demo illustrates the computation of a solution family to
the boundary value problem


\begin{equation} \begin{array}{cl}
  u_1 ' &= u_2  ,  \\
  u_2 ' &= -p_1  e^{u_1} , \\
\end{array} \end{equation}
with boundary conditions $ u_1(0)=0 ,  \quad  u_1(1)=0.$
This equation is also considered in 
\citename{DoKeKe:91a} \citeyear{DoKeKe:91a}.
\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | l |}
\hline
  \AUTO-COMMAND  & ACTION \\
\hline
%==============================================================================
  \commandf{mkdir exp} & create an empty work directory \\ 
  \commandf{cd exp} & change directory \\
  \commandf{demo('exp')} & copy the demo files to the work directory \\
\hline
%==============================================================================
  \commandf{r1=run(e='exp',c='exp')} & 1st run; compute solution family containing fold \\ 
\hline
%==============================================================================
  \commandf{r2=run(r1,NTST=20)} & 2nd run; restart at the last labeled solution, using increased accuracy\\ 
  \commandf{save(r1+r2,'exp')} & save output to \filef{b.exp, s.exp, d.exp} \\ 
\hline
%==============================================================================
\end{tabular}
\caption{Commands for running demo \filef{exp}.}
\label{tbl:demo_exp}
\end{center}
\end{table}

\newpage
%==============================================================================
%DEMO=int======================================================================
%==============================================================================
\section{ int : Boundary and Integral Constraints.} \label{sec:Demos_int}
This demo illustrates the computation of a solution family to
the equation

\begin{equation} \begin{array}{cl}
 u_1 ' &= u_2 , \\
  u_2 ' &= -p_1  e^{u_1} , \\\end{array} \end{equation}
with a non-separated boundary condition and an integral constraint:

$$ u_1(0)-u_1(1)-p_2=0 ,\qquad \int_0^{1}u(t)dt-p_3=0 . $$
The solution family contains a fold, which, in the second run, is  
continued in two equation parameters.

\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | l |}
\hline
  \AUTO-COMMAND  & ACTION \\
\hline
%==============================================================================
  \commandf{mkdir int} & create an empty work directory \\ 
  \commandf{cd int} & change directory \\
  \commandf{demo('int')} & copy the demo files to the work directory \\
\hline
%==============================================================================
  \commandf{r1=run(e='int',c='int')} & 1st run; detection of a fold \\ 
  \commandf{save(r1,'int')} & save output-files as \filef{b.int, s.int, d.int} \\ 
\hline
%==============================================================================
  \commandf{r2=run(r1("LP1"),ICP=[1,2],ISW=2)} & 2nd run; generate starting data for a curve of folds.\\ 
\hline
%==============================================================================

  \commandf{r3=run(r2)} & \parbox[t]{3in}{3rd run; compute a curve of
    folds; restart from the last and only label in \parf{r2}. \vspace{0.2cm}}\\ 
  \commandf{save(r3,'lp')} & save the output-files as \filef{b.lp, s.lp, d.lp} \\ 
\hline
%==============================================================================
\end{tabular}
\caption{Commands for running demo \filef{int}.}
\label{tbl:demo_int}
\end{center}
\end{table}

\newpage
%==============================================================================
%DEMO=bvp======================================================================
%==============================================================================
\section{ bvp : A Nonlinear ODE Eigenvalue Problem.} \label{sec:Demos_bvp}
This demo illustrates the location of eigenvalues of a nonlinear ODE
boundary value problem as bifurcations from the trivial solution family.
The families of solutions that bifurcate at all five computed
eigenvalues, that is, the eigenfunctions, are computed in both directions.
The equations are
\begin{equation} \begin{array}{cl}
 u_1 ' &= u_2  ,  \\
  u_2 ' &=-(p_1 \pi)^{2}u_1 + u_1^{2} ,\end{array} \end{equation}
with boundary conditions $ u_1(0)=0 ,  \quad  u_1(1)=0.$~~~
We add the integral constraint
 $$ \int_0^{1} u_1(t) dt - p_2 = 0. $$
Then $p_2$ is simply the average of the first solution component.
The integral constaint gives a measure: the exact same continuations
could be done without any integral conditions in just the
one parameter $p_1$,
however $p_2$ gives us extra possibilities to plot and stop at
desirable solutions.
The values that \filef{bvp.auto} sets in \parf{UZR} make sure that
solutions are given for $p_2=\pm 3,\pm 6,\pm 9$, and the continuation
stops at $p_2=\pm 9$, and also makes sure that $0 \le p_1 \le 5.5$.
\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | l |}
\hline
  \AUTO-COMMAND  & ACTION \\
\hline
%==============================================================================
  \commandf{mkdir bvp} & create an empty work directory \\ 
  \commandf{cd bvp} & change directory \\
  \commandf{@dm bvp } & copy the demo files to the work directory \\
\hline
%==============================================================================
  \commandf{auto bvp.auto } or & Run the script bvp.auto\\
  \commandf{auto('bvp.auto') } & \\
\hline
%==============================================================================
\end{tabular}
\caption{Commands for running demo \filef{bvp}.}
\label{tbl:demo_bvp}
\end{center}
\end{table}

\newpage
%==============================================================================
%DEMO=lin======================================================================
%==============================================================================
\section{ lin : A Linear ODE Eigenvalue Problem.} \label{sec:Demos_lin}
This demo illustrates the location of eigenvalues of a linear ODE
boundary value problem as bifurcations from the trivial solution family.
By means of branch switching an eigenfunction is computed,
as is illustrated for the first eigenvalue. 
This eigenvalue is then continued in two parameters
by fixing the $L_2$-norm of the first solution component.
The eigenvalue problem is given by the equations

\begin{equation} \begin{array}{cl}
  u_1 ' &= u_2  ,  \\
  u_2 ' &= (p_1 \pi)^{2} u_1 , \end{array} \end{equation}
with boundary conditions $ u_1(0)-p_2=0 $ and $  u_1(1)=0.$
We add the integral constraint
 $$ \int_0^{1} u_1(t)^{2} dt - p_3 = 0. $$
Then $p_3$ is simply the $L_2$-norm of the first solution component.
In the first two runs $p_2$ is fixed, while $p_1$ and $p_3$ are free.
In the third run  $p_3$ is fixed, while $p_1$ and $p_2$ are free.

\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | l |}
\hline
  \AUTO-COMMAND  & ACTION \\
\hline
%==============================================================================
  \commandf{mkdir lin} & create an empty work directory \\ 
  \commandf{cd lin} & change directory \\
  \commandf{demo('lin')} & copy the demo files to the work directory \\
\hline
%==============================================================================
  \commandf{r1=run(e='lin',c='lin')} & \parbox[t]{3in}{1st run;
    compute the trivial solution family and locate eigenvalues. \vspace{0.2cm}} \\ 
\hline
%==============================================================================
  \commandf{r2=run(r1('BP1'),NTST=6,ISW=-1,DSMAX=0.5)} & \parbox[t]{3in}{2nd run; compute a few steps along the bifurcating family.  \vspace{0.2cm}}\\ 
  \commandf{save(r1+r2,'lin')} & save all output to \filef{b.lin, s.lin, d.lin} \\ 
\hline
%==============================================================================
  \commandf{r3=run(r2('UZ1'),ICP=[1,2],NTST=5,ISW=1)} & \parbox[t]{3in}{3rd run; compute a two-parameter curve of eigenvalues. \vspace{0.2cm}} \\ 
  \commandf{save(r3,'2p')} & save the output-files as \filef{b.2p, s.2p, d.2p} \\ 
\hline
%==============================================================================
\end{tabular}
\caption{Commands for running demo \filef{lin}.}
\label{tbl:demo_lin}
\end{center}
\end{table}

\newpage
%==============================================================================
%DEMO=non======================================================================
%==============================================================================
\section{ non : A Non-Autonomous BVP.} \label{sec:Demos_non}
This demo illustrates the continuation of solutions to
the non-autonomous boundary value problem

\begin{equation} \begin{array}{cl}
  u_1 ' &= u_2  ,  \\
  u_2 ' &= -p_1  e^{x^3 u_1} , \\\end{array} \end{equation}
with boundary conditions $ u_1(0)=0 ,  \quad  u_1(1)=0.$
Here $x$ is the independent variable.
This system is first converted to the following equivalent
autonomous system~:
\begin{equation} \begin{array}{cl}
  u_1 ' &= u_2  ,  \\
  u_2 ' &= -p_1  e^{u_3^3 u_1} ,  \\  
  u_3 ' &= 1 ,  \\
\end{array} \end{equation}
 with boundary conditions $ u_1(0)=0 ,  \quad  u_1(1)=0, \quad u_3(0)=0.$
(For a periodically forced system see demo \filef{frc}).

\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | l |}
\hline
  \AUTO-COMMAND  & ACTION \\
\hline
%==============================================================================
  \commandf{mkdir non} & create an empty work directory \\ 
  \commandf{cd non} & change directory \\
  \commandf{demo('non')} & copy the demo files to the work directory \\
\hline
%==============================================================================

  \commandf{r1=run(e='non',c='non')} & compute the solution family \\ 
  \commandf{save(r1,'non')} & save output-files as \filef{b.non, s.non, d.non} \\ 
\hline
%==============================================================================
\end{tabular}
\caption{Commands for running demo \filef{non}.}
\label{tbl:demo_non}
\end{center}
\end{table}

\newpage
%==============================================================================
%DEMO=kar======================================================================
%==============================================================================
\section{ kar : The Von Karman Swirling Flows.} \label{sec:Demos_kar}
The steady axi-symmetric flow of a viscous incompressible fluid
above an infinite rotating disk is modeled by the following 
ODE boundary value problem (Equation (11) in
\citename{LeKe:80} \citeyear{LeKe:80}~:
\begin{equation} \begin{array}{cl}
  u_1' &= T u_2,  \\
  u_2' &= T u_3,  \\
  u_3' &= T \bigl[ -2 \gamma u_4 + u_2^2 - 2 u_1 u_3 - u_4^2 \bigr], \\
  u_4' &= T u_5, \\
  u_5' &= T \bigl[ 2 \gamma u_2 + 2 u_2 u_4 - 2 u_1 u_5 \bigr], \\
\end{array} \end{equation}
with left boundary conditions
$$ u_1(0)=0, \qquad u_2(0)=0, \qquad u_4(0)=1-\gamma, $$
and (asymptotic) right boundary conditions
\begin{equation} \begin{array}{cl}
  & \bigl[ f_\infty + a(f_\infty,\gamma) \bigr] ~ u_2(1) + u_3(1)
  - \gamma ~ \frac{ u_4(1) }{ a(f_\infty,\gamma) } = 0,  \\
  & a(f_\infty,\gamma)~ \frac{ b^2(f_\infty,\gamma) }{ \gamma } ~u_2(1)
  + \bigl[ f_\infty + a(f_\infty,\gamma) \bigr] ~u_4(1) 
  + u_5(1) = 0, \\
 & u_1(1) = f_\infty,
 \end{array} \end{equation}
where
\begin{equation} \begin{array}{cl}
 & a(f_\infty,\gamma) = \frac{1 }{ \sqrt{2} }
  \bigl[ (f_\infty^4 + 4 \gamma^2)^{1/2} + f_\infty^2 \bigr]^{1/2}, \\
 & b(f_\infty,\gamma) = \frac{1 }{ \sqrt{2} }
  \bigl[ (f_\infty^4 + 4 \gamma^2)^{1/2} - f_\infty^2 \bigr]^{1/2}.  \\
\end{array} \end{equation}
Note that there are five differential equations and six boundary conditions.
Correspondingly, there are two free parameters in the computation of a 
solution family, namely $\gamma$ and $f_\infty$.
The ``period'' $T$ is fixed; $T=500$.
The starting solution is $u_i=0$, $i=1,\cdots,5$, 
at $\gamma=1$, $f_\infty=0$.

\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | l |}
\hline
  \AUTO-COMMAND  & ACTION \\
\hline
%==============================================================================
  \commandf{mkdir kar} & create an empty work directory \\ 
  \commandf{cd kar} & change directory \\
  \commandf{demo('kar')} & copy the demo files to the work directory \\
\hline
%==============================================================================
  \commandf{r1=run(e='kar',c='kar')} & computation of the solution family \\ 
  \commandf{save(r1,'kar')} & save output-files as \filef{b.kar, s.kar, d.kar} \\ 
\hline
%==============================================================================
\end{tabular}
\caption{Commands for running demo \filef{kar}.}
\label{tbl:demo_kar}
\end{center}
\end{table}

\newpage
%==============================================================================
%DEMO=spb======================================================================
%==============================================================================
\section{ spb : A Singularly-Perturbed BVP.} \label{sec:Demos_spb}
This demo illustrates the use of continuation to compute 
solutions to the singularly perturbed boundary value problem
\begin{equation} \begin{array}{cl}
  u_1 ' &= u_2  ,  \\
  u_2 ' &= \frac{\lambda }{ \eps} \bigl(
  u_1 u_2 (u_1^2 - 1) + u_1
  \bigr)  , \\ \end{array} \end{equation}
with boundary conditions $u_1(0)=3/2$,  $u_1(1)=\gamma.$
The parameter $\lambda$ has been introduced into the equations in order
to allow a homotopy from a simple equation with known exact solution
to the actual equation. This is done in the first run.
In the second run $\eps$ is decreased by continuation.
In the third run $\eps$ is fixed at $\eps=.001$ and the solution is continued 
in $\gamma$.
This run takes more than 1500 continuation steps.
For a detailed analysis of the solution behavior see 
\citename{JL:82} \citeyear{JL:82}.
\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | l |}
\hline
  \AUTO-COMMAND  & ACTION \\
\hline
%==============================================================================
  \commandf{mkdir spb} & create an empty work directory \\ 
  \commandf{cd spb} & change directory \\
  \commandf{demo('spb')} & copy the demo files to the work directory \\
\hline
%==============================================================================

  \commandf{r1=run(e='spb',c='spb.0')} & 1st run; homotopy from $\lambda=0$ to $\lambda=1$ \\ 
  \commandf{save(r1,'0')} & save output-files as \filef{b.0, s.0, d.0} \\ 
\hline
%==============================================================================
  \commandf{r2=run(r1,c='spb.1')} & \parbox[t]{3in}{2nd run; let
    $\eps$ tend to zero; restart from the last label of \parf{r0}.
    constants changed : \parf{IRS, ICP(1), NTST, DS, UZR, STOP} \vspace{0.2cm}}\\ 
  \commandf{save(r2,'1')} & save the output-files as \filef{b.1, s.1, d.1} \\ 
\hline
%==============================================================================
  \commandf{r3=run(r2('UZ2'),c='spb.3')} & \parbox[t]{3in}{3rd run;
    continuation in $\gamma$; $\eps=0.001$; restart from 2nd UZ label
    of \parf{r2}.  Constants changed : \parf{IRS, ICP(1), ITNW, EPSL, EPSU, UZR} \vspace{0.2cm}} \\ 
  \commandf{save(r3,'2')} & save the output-files as \filef{b.2, s.2, d.2} \\ 
\hline
%==============================================================================
\end{tabular}
\caption{Commands for running demo \filef{spb}.}
\label{tbl:demo_spb}
\end{center}
\end{table}

\newpage
%==============================================================================
%DEMO=ezp======================================================================
%==============================================================================
\section{ ezp : Complex Bifurcation in a BVP.} \label{sec:Demos_ezp}
This demo illustrates the computation of a solution family to
the complex boundary value problem

\begin{equation} \begin{array}{cl}
  u_1 ' &= u_2  ,  \\
  u_2 ' &= -p_1  e^{u_1} , \\
\end{array} \end{equation}
with boundary conditions $ u_1(0)=0 , ~u_1(1)=0.$
Here $u_1$ and $u_2$ are allowed to be complex, 
while the parameter $p_1$ can only take real values.
In the real case, this is Bratu's equation, whose solution family 
contains a fold; see the demo \filef{exp}.
It is known 
(\citename{HeKe:90} \citeyear{HeKe:90}) that a simple quadratic fold gives rise to a pitch fork
bifurcation in the complex equation.
This bifurcation is located in the first computation below.
In the second and third run, both legs of the bifurcating solution family
are computed.
On it, both solution components $u_1$ and $u_2$ have nontrivial 
imaginary part.



\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | l |}
\hline
  \AUTO-COMMAND  & ACTION \\
\hline
%==============================================================================
  \commandf{mkdir ezp} & create an empty work directory \\ 
  \commandf{cd ezp} & change directory \\
  \commandf{demo('ezp')} & copy the demo files to the work directory \\
\hline
%==============================================================================
  \commandf{ezp=run(e='ezp',c='ezp')} & 1st run; compute solution family containing fold \\ 
\hline
%==============================================================================
  \commandf{ezp=ezp+run(ezp('BP1'),ISW=-1)} & \parbox[t]{3in}{2nd run; compute bifurcating complex solution family.  \vspace{0.2cm}}\\ 
  \commandf{ap('ezp')} & append output-files to \filef{p.ezp, s.ezp, d.ezp} \\ 
\hline
%==============================================================================
  \commandf{ezp=ezp+run(ezp('BP1'),ISW=-1,DS='-')} & \parbox[t]{3in}{3rd run; compute 2nd leg of bifurcating family. \vspace{0.2cm}}\\ 
  \commandf{save(ezp,'ezp')} & save combined output to \filef{b.ezp, s.ezp, d.ezp} \\
\hline
%==============================================================================
\end{tabular}
\caption{Commands for running demo \filef{ezp}.}
\label{tbl:demo_ezp}
\end{center}
\end{table}
%==============================================================================
\newpage

%
%==============================================================================
%DEMO=um2======================================================================
%==============================================================================
\section{ um2 : Basic computation of a 2D unstable manifold.} \label{sec:Demos_um2}
This demo shows how one can compute a 2D unstable manifold of an equilibrium
using {\it orbit continuation}.
The model equations are given by
\begin{equation} \begin{array}{cl}
 x' &= ~\eps x - y^3~, \\
 y' &=   ~~y + x^3~. \\
\end{array} \end{equation}
The origin has eigenvalues $\eps$ and $1$, where $\eps>0$, so that its 
unstable manifold is indeed $2$-dimensional. Since the phase space itself 
is $2$-dimensional, one can also consider this demo as showing how to generate 
part of a $2$-dimensional phase portrait. However, the basic steps in this demo 
also apply to the computation of $2$-dimensional unstable manifolds of equilibria 
in higher-dimensional phase space.

In the computations the independent time variable $t$ is scaled to vary in
the unit interval, so that the actual integration time $T$ becomes an 
explicit parameter in the equations, namely,

\begin{equation} \begin{array}{cl}
 x' &= ~T~(\eps x - y^3)~, \\
 y' &=      ~T~(~y + x^3)~. \\
\end{array} \end{equation}

To carry out the calculations run the Python script \filef{um2.auto} included 
in the demo. In order to better appreciate the power of orbit continuation 
for computing such manifolds, one can also run the script for a smaller value 
of $\eps$, {\it e.g.}, $\eps=10^{-2},\cdots,10^{-6}$, by changing the value
entered on the last line of the constants-file \filef{c.umn.2}. One can view
the phase portrait by plotting the solutions in the solutions-file \filef{s.3}
in the $x$-$y$ plane.

In the first run an orbit is ``grown'' by continuation in the integration time 
$T$, starting from a very small value of $T$, so that a solution that is
constant in time is an accurate initial approximation. The starting solution is 
in fact a point on a circle of small radius $r_0$ around the stationary point,
{\it i.e.}, around the origin. For illustrative purpose the value of $r_0$ is
$0.1$ in this demo, but could be smaller if more accuracy is needed.
The precise starting point is in the strongly unstable direction, namely, in 
the $y$-direction, which is the direction of the eigenvector associated with 
the ``strongly unstable eigenvalue'', which here has value $1$. 
The growing of the initial orbit is terminated when the norm of its endpoint 
reaches the value 0.6, {\it i.e.}, when $\sqrt{x(1)^2+y(1)^2}=0.6$. 

The value of $\eps$ is $0.5$ in the first run. In the second run continuation
is used to decrease the value of $\eps$ to $0.1$ (or, if desired, to a smaller 
value, as already mentioned above). The norm of the endpoint  $(x(1),y(1))$
is fixed in the second run, while $T$ is variable.

In the third run the norm of the endpoint remains fixed. However, the 
initial point $(x(0),y(0))$ is allowed to move around the small circle of 
radius $r_0$ around the orgin.  The endpoint thereby moves around the ``large''
circle of radius $0.6$. The integration time $T$ remains variable.
The orbits computed in this run generate the local 
manifold.

When viewing the orbits computed in the third run, as written in the file 
\filef{s.3}, notice that orbits near the ``weakly unstable direction'',
which here corresponds to the $x$ direction, have been well-computed. Such 
orbits are sensitively dependent on the initial condition $(x(0),y(0))$ when 
the problem is considered as an initial value problem. It is in fact the 
{\it continuation} of the {\it entire orbits} using a {\it boundary value 
approach} which enables their determination. As already mentioned, this 
feature is even more visible when running this demo with a smaller value 
of $\eps$.
\newpage

%==============================================================================
%DEMO=um3======================================================================
%==============================================================================
\section{ um3 : A 2D unstable manifold in 3D.} \label{sec:Demos_um3}
This demo uses {\it orbit continuation} to compute part of the 2D unstable 
manifold of the origin of the equations
\begin{equation} \begin{array}{cl}
 x' &= ~\eps x - y^3 + z^3~, \\
 y' &=   ~~y + x^3~, \\
 z' &=    -z + x^2~. \\
\end{array} \end{equation}
The origin has unstable eigenvalues $\eps$ and $1$, where $\eps>0$, so that its 
unstable manifold is $2$-dimensional. 
In the computations the independent time variable $t$ is scaled to vary in
the unit interval, so that the actual integration time $T$ becomes an 
explicit parameter in the equations; see, for example, demo \filef{um2}.
The calculations can be done by running the Python script \filef{um3.auto} 
included in the demo. 

In the first run an orbit is ``grown'' by continuation in the integration time 
$T$, starting from a very small value of $T$, so that a solution that is
constant in time is an accurate initial approximation. The starting solution is 
in fact a point on a circle of small radius $r_0=0.03$ in the unstable eigenspace
of the origin. 
The precise starting point is in the strongly unstable direction, namely, the
$y$-direction.
The initial orbit is grown until the $L_2$-norm of its endpoint 
$(x(1),y(1),z(1))$ reaches the value $1$. 
The value of $\eps$ is fixed at $0.5$ in the first run. In the second run 
continuation is used to decrease $\eps$ to $0.01$. The norm of the endpoint  
$(x(1),y(1),z(1))$ is fixed in this run, while $T$ is variable.

In the third run the norm of the endpoint remains fixed, but the 
initial point $(x(0),y(0),z(0))$ is allowed to move around the small circle of 
radius $r_0$ in the unstable eigenspace of the origin.  
The endpoint thereby moves on the surface of the ``large'' sphere of radius 
$1$. The integration time $T$ remains variable.
The orbits computed in this run generate the local manifold.

When viewing the orbits computed in the third run, as written in the file 
\filef{s.3}, notice that there appears to be second equilibrium with a 2D 
stable manifold which intersects the 2D unstable manifold of the origin. 
The intersection curve, which corresponds to a heteroclinic orbit,
is visible in the graphical representation of the manifold. 

\newpage
%
%==============================================================================
%DEMO=p2c======================================================================
%==============================================================================
\section{ p2c : Point to cycle connections.} \label{sec:Demos_p2c}
In this demo a point to cycle heteroclinic connection is computed via
homotopy, and then continued in two system parameters, in the Lorenz equations
\begin{eqnarray*}
  u_1' &=&  p_3 (u_2 - u_1), \\
  u_2' &=&  p_1 u_1 - u_2 - u_1 u_3,  \\
  u_3' &=&  u_1 u_2 - p_2 u_3. \end{eqnarray*}
Type \commandf{auto p2c.auto} to run the demo and
\commandf{auto clean.auto} to remove generated files.

Refer to \citename{DoKoVoKu08} \citeyear{DoKoVoKu08} and 
\url{http://www.bio.vu.nl/thb/research/project/globif/index_main.html}
for background information.

%
%==============================================================================
%DEMO=c2c======================================================================
%==============================================================================
\section{ c2c : Cycle to cycle connections.} \label{sec:Demos_c2c}

In this demo a cycle to cycle heteroclinic connection is computed via
homotopy, and then continued in one system parameter, in a food chain model:
\begin{eqnarray*}
    x' &=& x(1 - x) - \frac{5 x y}{1 + 3 x}, \\
    y' &=& \frac{5 x y}{1 + 3 x}  - p_1 y - \frac{0.1 y z}{1 + 2 y}, \\
    z' &=& \frac{0.1 y z}{1 + 2 y} - p_2 z. \end{eqnarray*}
Type \commandf{auto c2c.auto} to run the demo.
After that it is possible to compute two-parameter continuations of
folds of the cycle-to-cycle
connection, but since this is computationally intensive it is put in
a seperate file: type \commandf{auto c2cfolds.auto}.
Type \commandf{auto clean.auto} to remove all generated files.

Refer to \citename{DoKoVoKu09} \citeyear{DoKoVoKu09} and 
\url{http://www.bio.vu.nl/thb/research/project/globif/index_main.html}
for background information.

\newpage
 %==============================================================================
%DEMO=pcl======================================================================
 %==============================================================================
\section{ pcl : Lorenz: Point-to-cycle connections with Lin's method.} \label{sec:Demos_pcl}
This demo computes a point-to-cycle connection (or EtoP connection;
for equilibrium to periodic orbit) in the Lorenz equations
\begin{equation} \begin{array}{cl}
  x' &=  \sigma (y - x), \\
  y' &=  \rho x - y - x z,  \\
  z' &=  x y - \beta z, \\ \end{array} \end{equation}
using Lin's method, as described in \citename{KrRi:08}
\citeyear{KrRi:08}. Initially, we fix
$\beta=8/3$, $\sigma=10$, and let $\rho$ vary, starting from $0$.
Here we have a transition from simple to chaotic dynamics. For
approximate values of $\rho$ in the interval $[13.9265,24.0579]$
one finds preturbulence, organized by a pair of symmetrically
related periodic orbits that emanate from a homoclinic bifurcation
at $\rho\approx 13.9265$. For $\rho\approx 24.0579$ there exist
two symmetric point-to-cycle connections that mark the appearance
of a chaotic attractor for higher values of $\rho$.

The computation to find one of these two connections uses the following steps:
\begin{enumerate}
\item
Find the secondary equilibria emanating from the pitchfork
bifurcation of the equilibrium at $0$, and their Hopf bifurcations,
similarly to the demo \filef{lrz}.
\item
Follow the periodic orbit emanating from the Hopf bifurcation in
$\rho$ and its period $T$, until
$\rho=24.0579$, a value close to where a point-to-cycle connection is
known to exist.
\item
Extend the system, putting the variational equation (the eigenfunction)
into solution coordinates 4, 5, and 6. The trivial (0) eigenvector is
continued until we hit a branch point, corresponding to
where $\mu=$ \parf{PAR(12)} equals the natural logarithm of a Floquet
multiplier.
\item
Switch branches and continue the non-trivial eigenvector until its
norm $h$ equals 1.
\item
Extend the system again from 6 to 9 dimensions
to calculate a connection from the cross section $\Sigma$, given by
$x=10$, to the periodic orbit.
The connection starts at the non-trivial eigenvector with respect
to the periodic orbit with a distance of $\delta=10^{-7}$,
and grows backwards in time
until it hits the section $\Sigma$ at time $T^+$.
\item
Extend the system one last time from 9 to 12 dimensions.
We calculate a connection from the equilibrium at 0, starting at
its eigenvector over a distance of $\varepsilon=10^{-7}$,
to the cross section
$\Sigma$, at time $T^-$.
The second intersection is the one that is closest to the
intersection computed in step 5, and it is the one we want.
\item
Firstly, in the routine \funcf{PVLS} in the equations file \filef{pcl.f90},
the Lin vector, a normalized vector between the points of intersection
computed in steps 5 and 6 is put in $Z_x$, $Z_y$ and $Z_z$
  (\parf{PAR(24)-PAR(26)}).
Starting data for the Lin gap, which measures the distance between
these two points of intersection, is put in $\eta=$ \parf{PAR(23)}.
Subsequently, close this gap by continuing in 
$\eta$, $\rho$, $\delta$, $\varepsilon$, $T^-$, $T^+$, $\mu$, and $T$.
This process is illustrated in Figure~\ref{fig:Demos_pcl1}.
\item
Continue the point to cycle connection obtained in step 7
in the system parameters $\rho$ and $\beta$, together with
$\delta$, $\varepsilon$, $T^-$, $T^+$, $\mu$, and $T$.
Connections for various
values of $(\rho,\beta)$ are shown in Figure \ref{fig:Demos_pcl2}.
\end{enumerate}

The above sequence of calculations can be carried out by
running the Python script \filef{pcl.auto} (without constants files)
or \filef{pclc.auto} (with constants files) included in the demo.
See the script and the Fortran file \filef{pcl.f90} for details on
how all parameters are mapped and which precise AUTO constants
are changed at every step.
\begin{figure}[htb]
\begin{center}
\begin{picture}(550,190)
\put(-10,-20){\includegraphics[scale=0.48]{include/closegap_pcl_par}}
\put(240,-20){\includegraphics[scale=0.48]{include/closegap_pcl}}
\end{picture}
\caption{Closing the Lin-gap to obtain the point-to-cycle
connection.
The left panel is a plot of $\rho$ versus the gap size $\eta$,
and the right panel shows the corresponding orbit segments,
projected onto the $(x,z)$-plane.
To obtain these figures run \commandf{plot('closegap')} or
\commandf{@pp closegap}.}
\label{fig:Demos_pcl1}
\end{center}
\end{figure}

\begin{figure}[ht!]
\begin{center}
\begin{picture}(550,190)
\put(-10,-20){\includegraphics[scale=0.48]{include/cont_pcl_par}}
\put(240,-20){\includegraphics[scale=0.48]{include/cont_pcl}}
\end{picture}
\caption{Parameter space diagram (left) and corresponding
orbit segments in phase space (right),
where the connection is continued in $\rho$ and $\beta$.
To obtain these figures run \commandf{plot('cont')} or
\commandf{@pp cont}.}
\label{fig:Demos_pcl2}
\end{center}
\end{figure}


\newpage
%==============================================================================
%DEMO=snh======================================================================
%==============================================================================
\section{ snh : SNH with Global reinjection: Point-to-cycle connections with Lin's method.} \label{sec:Demos_snh}
This demo computes point-to-cycle
(or EtoP connection; for equilibrium to periodic orbit)
and homoclinic point-to-point connections in the model vector field
\begin{equation} \begin{array}{cl}
  x' &=  \nu_1 x - \omega y - (\alpha x - \beta y) \sin \varphi -
  (x^2+y^2)x + d (2 \cos \varphi+\nu_2)^2, \\
  y' &=  \nu_1 y + \omega x - (\alpha y + \beta x) \sin \varphi -
  (x^2+y^2) y + f (2 \cos \varphi+\nu_2)^2,  \\
  \varphi' &=  \nu_2 + s (x^2+y^2) + 2 \cos \varphi + c(x^2+y^2)^2,
  \\ \end{array} \end{equation}
using Lin's method, as described in Krauskopf and Rie\ss
(2008). %\cite{kr}
This system describes the dynamics near a saddle-node Hopf bifurcation
with global reinjection, as discussed in Krauskopf and Oldeman(2006).
We keep the following parameters fixed throughout: $\omega=1$,
$\alpha=-1.0$, $\beta=0$, $s=-1$, $c=0$, $d=0.01$, and $f=\pi d$.

Initially, we fix $\nu_2=-1.46$, since
for that value of $\nu_2$, close to $\nu_1=0.74$,
there exists a codimension-one connection from a periodic orbit
($\Gamma$) to an equilibrium ($b$). Together with a codimension-zero connection
back to $\Gamma$, it forms a heteroclinic cycle. In this example, the
flow is such that the codimension-one connecting orbit is an EtoP
orbit where the flow is from the periodic orbit to the equilibrium.
A homoclinic orbit
to $b$ also approaches this cycle. Below, we compute all three
connecting orbits.

The below sequences of calculations can be carried out by
running the Python script \filef{snh.auto} included in the demo.
The individual connections can be computed by running the scripts
\filef{h1b.auto} (homoclinic orbit), \filef{cb.auto} (codimension-one
EtoP), and \filef{tb.auto} (codimension-zero EtoP).
See the scripts and the Fortran file \filef{snh.f90} for details on
how all parameters are mapped and which precise AUTO constants
are changed at every step.

\subsection{The homoclinic point-to-point connection.}
The starting point for this investigation is a homoclinic orbit
connecting the point $b$ to itself, where the phase of $\varphi$ is
shifted by $2\pi$ (in other words, the homoclinic orbit reinjects
once and it is a heteroclinic orbit in the covering space).
We can most easily compute the homoclinic orbit using a 
homotopy method
(see the {\cal HomCont} section \ref{sec:Starting_strategies} for details):

\begin{enumerate}
\item
We locate the homoclinic orbit, or here, the heteroclinic orbit in the
covering space by continuing the one-dimensional stable manifold in
negative time. This way, {\cal HomCont} views the stable manifold as a
one-dimension unstable manifold to which its standard homotopy method
can be applied and which makes the method much more straightfoward
than starting with a two-dimensional unstable manifold.
We reach the unstable eigenspace of $E^u(b)$ as soon as the artificial
dummy parameter $\omega_1$, measuring a distance to $E^u(b)$, vanishes.
\item
We can now improve this connection by continuing in decreasing negative time,
keeping $\omega_1$ fixed, and freeing up the system parameter $\nu_1$.
\item
The resulting orbit can be continued forwards and backwards in the
system parameter $\nu_1$ and $\nu_2$, using standard {\cal HomCont} settings.
Note the setting of \parf{IEQUIB=1}: {\cal HomCont} auto-detects the phase
shift and only continues one equilibrium instead of treating
the orbit as a general heteroclinic orbit.
\end{enumerate}

The resulting homoclinic orbit snakes in parameter space between the two
tangencies of the codimension-zero connection and terminates at a
segment of the codimension-one EtoP connection. We show this in
Figure~\ref{fig:Demos_snh3}.

\subsection{The codimension-one point-to-cycle connection.}
To compute the codimension-one point-to-cycle connection,
the following steps are used (very similar to those in the
demo \commandf{pcl}):
\begin{enumerate}
\item
Continue the first equilibrium $a$ at $x=y=0$,
$\varphi=-\mathrm{arccos}(-\nu_2/2)$, which undergoes a Hopf bifurcation
at $\nu_1\approx 0.683447$.
\item
Follow the periodic orbit, emanating from the Hopf bifurcation, in
$\nu_1$ and its period $T$, until $\nu_1=0.74$.
\item
Extend the system, putting the variational equation (the eigenfunction)
into solution coordinates 4, 5, and 6. The trivial (0) eigenvector is
continued until we hit a branch point, corresponding to
where $\mu=$ \parf{PAR(12)} equals the natural logarithm of a Floquet
multiplier.
\item
Switch branches and continue the non-trivial eigenvector until its
norm $h$ equals 1.
\item
Extend the system again from 6 to 9 dimensions
to calculate a connection from the periodic orbit to the cross section
$\Sigma$, given by $\varphi=\pi$.
The connection starts at the non-trivial eigenvector with respect
to the periodic orbit with a distance of $\delta=-10^{-5}$,
and grows forwards in time
until it hits the section $\Sigma$ at time $T^-$.
\item
Extend the system one last time from 9 to 12 dimensions.
We calculate a connection backwards in time
from the second equilibrium $b$ at $x=y=0$,
$\varphi=\mathrm{arccos}(-\nu_2/2)$, starting at
its eigenvector over a distance of $\varepsilon=10^{-6}$,
to the cross section $\Sigma$, at time $T^+$.
The Lin vector, a normalized vector between the points of intersection
computed in steps 5 and 6, is put in $Z_x$, $Z_y$ and $Z_z$
(\parf{PAR(24)-PAR(26)}).
Starting data for the Lin gap, which measures the distance between
these two points of intersection is put in $\eta=$ \parf{PAR(23)}.
\item
Close the gap computed in step 6 by continuing in 
$\eta$, $\nu_1$, $\delta$, $\varepsilon$, $T^+$, $T^-$, $\mu$, and
$T$. The connection is found at $\nu_1=7.41189$.
This process is illustrated in Figure~\ref{fig:Demos_snh1}.
\item
Continue the point to cycle connection obtained in step 7
in the system parameters $\nu_1$ and $\nu_2$, together with
$\delta$, $\varepsilon$, $T^+$, $T^-$, $\mu$, and $T$.
Connections for various
values of $(\nu_1,\nu_2)$ are shown in Figure \ref{fig:Demos_snh2}.
\end{enumerate}

\begin{figure}[htb]
\begin{center}
\begin{picture}(550,190)
\put(-10,-20){\includegraphics[scale=0.48]{include/closegap_snh_par}}
\put(250,-15){\includegraphics[scale=0.48]{include/closegap_snh}}
\end{picture}
\caption{Closing the Lin-gap to obtain the point-to-cycle connection.
The left panel is a plot of $\nu_1$ versus the gap size $\eta$,
and the right panel shows the corresponding orbit segments.
To obtain these figures run \commandf{plot('closegap')} or
\commandf{@pp closegap}, and
\commandf{plot3('closegap')} or \commandf{@pl closegap}.}
\label{fig:Demos_snh1}
\end{center}
\end{figure}

\begin{figure}[h!]
\begin{center}
\begin{picture}(550,190)
\put(-10,-20){\includegraphics[scale=0.48]{include/cb_snh_par}}
\put(250,-15){\includegraphics[scale=0.48]{include/cb_snh}}
\end{picture}
\caption{Parameter space diagram (left) and corresponding orbit
segments in phase space (right),
where the connection is continued in $\nu_1$ and $\nu_2$.
To obtain these figures run \commandf{plot('cb')}
or \commandf{@pp cb}, and \commandf{plot3('cb')} or
\commandf{@pl cb}. Label 13 denotes the largest connection,
at a saddle-node bifurcation of limit cycles,
and label 16 the smallest one, where the periodic orbit disappears in
a Hopf bifurcation.}
\label{fig:Demos_snh2}
\end{center}
\end{figure}

\subsection{The codimension-zero point-to-cycle connection.}
Next we compute the codimension-zero connection back to the cycle
which must also exist near the accumulation of the parameter space
curve $h_1^b$.
This computation starts in the same way as the computation of the
codimension-one connection: steps 1 to 4 are the same except that in
step 3 we now find the negative Floquet exponent $\mu$,
instead of the positive exponent. Steps 5 to 8 proceed as follows:
\begin{enumerate}
\item[5.]
Similarly to step 5 before, we compute an orbit in the stable manifold
of the periodic orbit. However, Lin's method is not used, because it
is easier to use a homotopy method to connect directly to the unstable
eigenspace $E^u(b)$, which is given by the section where
$\varphi=\mathrm{arccos}(-\nu_2/2)$.
Because we compute an approximation to the stable rather than the
unstable manifold using almost the same boundary value problem,
we let $T^-$ be negative. Also the distance from the periodic orbit
to the connection is now given by $\delta=10^{-4}$, flipping its sign.
\item[6.]
Improve the connection computed in step 5, by decreasing
the negative value of $T^-$, fixing the starting point in $E^u(b)$
and freeing $\delta$.
\item[7.]
Follow the codimension-zero connection in the system parameter
$\nu_1$, together with $\mu$, $T$, $\delta$, and $T^-$, also adding
an integral condition for the connection. \AUTO detects two fold
points (LP), corresponding to tangencies of $W^u(b)$ and $W^s(\Gamma)$.
\item[8.]
Continue the two folds forwards and backwards in two parameters,
by adding the system parameter $\nu_2$ and setting the \AUTO constant
\parf{ISW=2}. The folds terminate where $\Gamma$ disappears in a
Hopf bifurcations (small $\nu_1$) and disappears in a saddle-node bifurcation
of limit cycles (large $\nu_1$). In both cases the continued
connection and orbit stop converging, so \AUTO reports MX.
\end{enumerate}

\begin{figure}[h!]
\begin{center}
\begin{picture}(550,190)
\put(-10,-20){\includegraphics[scale=0.48]{include/cont_snh_all_par}}
\put(251,-15){\includegraphics[scale=0.45]{include/cont_snh_all}}
\end{picture}
\caption{Parameter space diagram (left) and the corresponding homoclinic
orbit on the snaking curve $h_1^b$ for label 20 (right). The snaking
curve is in between the two tangencies for the codimension-zero EtoP
connection $t_b$ and terminates at a segment of the codimension-one
EtoP connection $c_b$.
To obtain these figures run \commandf{plot('all')}
or \commandf{@pp all}, and \commandf{plot3('all')} or
\commandf{@pl all}.}
\label{fig:Demos_snh3}
\end{center}
\end{figure}

\newpage
%==============================================================================
%DEMO=fnc======================================================================
%==============================================================================
\section{ fnc : Canards in the FitzHugh-Nagumo system.} \label{sec:Demos_fnc}

This demo computes attracting and repelling slow manifolds
in the self-coupled FitzHugh-Nagumo system:
\begin{equation} \label{eq:Demos_fnc} \begin{array}{cl} 
v' &= h - (v^3 - v + 1) / 2 - \gamma s v,\\
h' &= -\varepsilon (2h + 2.6 v),\\
s' &= -\varepsilon \delta s.\\
\end{array} \end{equation}
Furthermore, this demo continues canard orbits in parameter space.
Typically, trajectories in slow-fast systems such as this one
consist of a slow part
that follows the attracting slow manifold, followed by a fast part
when the trajectory hits a fold with respect to the fast direction.
After this jump, the trajectory follows a slow segment again.
A canard orbit, on the other hand, does not jump at the fold but
follows the repelling slow manifold. A central role is played by the
two-dimensional critical manifold $S$ which is given by the nullcline
of the fast variable in the limit for $\varepsilon=0$. It consists of
attracting and repelling sheets $S^a$ and $S^r$, which generically
meet at fold curves $F$ with respect to the fast flow direction.
For details, see \citename{DeKrOs:08} \citeyear{DeKrOs:08,DeKrOs:09}.

For system (\ref{eq:Demos_fnc}), where we fix $\gamma=0.5$ and
$\delta=0.565$, the critical manifold is given by
\begin{equation} \label{eq:Demos_fnc_S}
S=\{(v,h,s)\in \mathbb{R}^3| 2h-v^3+v-1-vs=0\},
\end{equation}
which is folded with respect to the fast variable $v$ along the folded
node curve
\begin{equation} \label{eq:Demos_fnc_F}
F=\{(v,h,s)\in S| 1 - 3v^2=0\}.
\end{equation}

The computation of the slow manifolds is performed in three steps.
They start with a constant-in-time solution at the folded node singularity
$(v,h,s)=(-0.49,0.6176,0.2797)$ for $\varepsilon=0.015$ on the scaled
time interval $[0,1]$ with time lengths $T^a=0$ and $T^r=0$, respectively.
Then, for the computation of the attracting manifold $(v^a,h^a,s^a)$,
via boundary conditions we always keep the starting point
$(v^a(0),h^a(0),s^a(0))$ on $S$ and $s^a(1)$ fixed to $0.2797$.
The steps are as follows:
\begin{enumerate}
\item
Homotopy step 1: grow the orbit segment in $T^a$, continuing also in
$v^a(0)$, $h^a(0)$, and $s^a(0)$, where the starting point
is kept on the folded node $F$ until $s^a(0)=0.6$.
\item
Homotopy step 2: the extra boundary condition for $F$ is dropped,
and we now instead fix $s^a(0)=0.6$.
We continue in $v^a(0)$, $h^a(0)$, and $T^a$ until $h^a(0)=-6.0$.
\item
Actual computation: we continue in $v^a(0)$, $s^a(0)$, and $T^a$,
fixing $h^a(0)=-6.0$. The end-point coordinates $v^a(1)$ and $h^a(1)$
are monitored so they can be matched with starting points of the
repelling manifold. These matches were found manually and are
now indicated at specific values of $T^a$ as UZ labels.
\end{enumerate}

For the repelling manifold $(v^r,h^r,s^r)$,
we always keep the end point $(v^r(1),h^r(1),s^r(1))$ on $S$
and $s^r(0)$ fixed to $0.2797$.
The steps are now as follows:
\begin{enumerate}
\item
Homotopy step 1: grow the orbit segment in $T^r$ until $s^r(1)=0.05$.
\item
Homotopy step 2: the extra boundary condition for $F$ is dropped,
and we now instead fix $s^r(1)=0.05$. We continue until $v^r(1)=0$.
\item
Actual computation: we continue in $s^r(0)$ and $T^r$,
fixing $v^r(1)=0$. The starting point coordinates $v^r(0)$ and $h^r(0)$
are now monitored for matches with the attracting manifold.
\end{enumerate}

The demo contains one folder \filef{attr}
for the "attracting" slow manifold and one folder \filef{rep} for 
the "repelling" slow manifold. In each of these two folders, the
manifolds can be computed by running the commands
\filef{auto attr.auto} and \filef{auto rep.auto}, respectively.
The alternative
script files \filef{attrc.auto} and \filef{repc.auto} use constants
files for every step instead of specifying the constants in the
script.

The main folder contains AUTO files to continue in 
parameter space six of the secondary canards of this systems. The
script \filef{fnc.auto} first computes the attracting and
repelling slow manifolds in their respective folders and next
concatenates matching manifolds in Python.  Six of these canard
orbits are then continued in $\varepsilon$ in both decreasing and
increasing direction.

If $T^a_j$ is the integration time for the canard segment $\xi^a_j$ on the 
attracting slow manifold and $T^r_j$ is the integration time for the orbit 
segment $\xi^r_j$ on the repelling slow manifold corresponding to the same 
canard solution, then the concatenated orbit segment $\xi_j$ has
$T^c_j=T^a_j+T^r_j$ as integration time.
The orbit $\xi_j$ is obtained from $\xi^a_j$ and $\xi^r_j$ by,
concatenating $\xi^a_j$ and $\xi^r_j$, and rescaling the time
so that it runs monotonically from 0 to 1.

Parameters are then also copied, where only those relating to the
start of the attracting manifold and the end of the repelling manifold
are kept, for these parameters are used for the boundary conditions of
the canard orbits. The new integration time $T^c_j$ is stored in
\parf{PAR(11)}.

Two constant files are provided. They correspond to the continuation
in epsilon in both decreasing (\filef{c.fnc}) and
and increasing (\filef{c.fnc.epsplus}) direction.
Continuation in any other system parameter is 
easily obtained by editing the \parf{ICP} entry.

The script \filef{plot.auto} produces the plots
we show here, in Figures~\ref{fig:Demos_fnc1},
\ref{fig:Demos_fnc2}, and \ref{fig:Demos_fnc3}.

\begin{figure}[h!]
\begin{center}
\begin{picture}(550,190)
\put(-10,-20){\includegraphics[scale=0.48]{include/fnc_attrrep1}}
\put(251,-15){\includegraphics[scale=0.45]{include/fnc_attrrep2}}
\end{picture}
\caption{Repelling and attracting slow manifold curves
where they match up (left) and their intersection curves at $s=0.2797$ in
the $(h,v)$ plane (right).}
\label{fig:Demos_fnc1}
\end{center}
\end{figure}

\begin{figure}[h!]
\begin{center}
\begin{picture}(550,190)
\put(-10,-20){\includegraphics[scale=0.48]{include/fnc_canards1}}
\put(240,-20){\includegraphics[scale=0.48]{include/fnc_canards2}}
\end{picture}
\caption{Continuation of canard orbits: the AUTO $L_2$ norm as
a function of $\varepsilon$ for all six orbits (left), and 
a projection of labels 4, 8, 11, and 16 (black, red, blue, green)
of the orbit $\xi_3$ on the $(v,s)$ plane (right).}
\label{fig:Demos_fnc2}
\end{center}
\end{figure}

\begin{figure}[h!]
\begin{center}
\begin{picture}(550,130)
\put(-17,-20){\includegraphics[scale=0.5]{include/fnc_canards3}}
\put(233,-20){\includegraphics[scale=0.5]{include/fnc_canards4}}
\put(359,-20){\includegraphics[scale=0.5]{include/fnc_canards5}}
\end{picture}
\caption{Continuation of canard orbits: projection of all canard
orbits on the $(v,s)$ plane for $\varepsilon=0.015$ (left),
$\varepsilon=10^{-4}$ (middle), and $\varepsilon=10^{-6}$ (right).}
\label{fig:Demos_fnc3}
\end{center}
\end{figure}

%==============================================================================
%==============================================================================
\chapter{ \AUTO Demos : Parabolic PDEs.} \label{ch:Demos_PDE}
%==============================================================================
%==============================================================================

\newpage
%==============================================================================
%DEMO=pd1======================================================================
%==============================================================================
\section{ pd1 : Stationary States (1D Problem).} \label{sec:Demos_pd1}
This demo uses Euler's method to locate a stationary solution of
a nonlinear parabolic PDE, followed by continuation of this stationary
state in a free problem parameter. The equation is
 $$ \frac{\partial u }{ \partial t} 
  = D~\frac{\partial^2 u }{ \partial x^2} ~+~  p_1~ u ~( 1-u) , $$
on the space interval $[0,L]$, where $L=$~{\tt PAR(11)}~$=10$ is fixed throughout,
as is the diffusion constant $D=$~{\tt PAR(15)}~$=0.1$.
The boundary conditions are $u(0) = u(L) = 0$ for all time.

In the first run the continuation parameter is the independent time variable,
namely \parf{PAR(14)}, while $p_1=1$ is fixed.
The \AUTO-constants \parf{DS}, \parf{DSMIN}, and \parf{DSMAX} then control the step size
in space-time, here consisting of \parf{PAR(14)} and  $u(x)$.
Initial data are $u(x)=\sin(\pi x/L)$ at time zero.
Note that in the subroutine \funcf{ STPNT} the initial data must be scaled to 
the unit interval, and that the scaled derivative must also be provided; 
see the equations-file \filef{pv1.f90}.
In the second run the continuation parameter is $p_1$.

Euler time integration is only first order accurate, so that
the time step must be sufficiently small to ensure correct results.
Indeed, this option has been added only as a convenience, and should 
generally be used only to locate stationary states.

\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | l |}
\hline
  \AUTO-COMMAND  & ACTION \\
\hline
%==============================================================================
  \commandf{mkdir pd1} & create an empty work directory \\ 
  \commandf{cd pd1} & change directory \\
  \commandf{demo('pd1') } & copy the demo files to the work directory \\
\hline
%==============================================================================
  \commandf{r1=run(e='pd1',c='pd1') } & time integration towards stationary state \\ 
  \commandf{save(r1,'1') } & save output-files as \filef{b.1, s.1, d.1} \\ 
\hline
%==============================================================================
\parbox[t]{3.3in}{
  \commandf{r2=run(r1,IPS=17,ICP=[1],NTST=20,
    NMX=100,RL1=50,NPR=25,DS=0.1,DSMAX=0.5)}}
& \parbox[t]{3in}{continuation of stationary states; read restart data
  from the last label of \parf{r1} \vspace{0.2cm}} \\ 
  \commandf{save(r2,'2') } & save output-files as \filef{b.2, s.2, d.2} \\ 
\hline
%==============================================================================
\end{tabular}
\caption{Commands for running demo \filef{pd1}.}
\label{tbl:demo_pd1}
\end{center}
\end{table}

\newpage
%==============================================================================
%DEMO=pd2======================================================================
%==============================================================================
\section{ pd2 : Stationary States (2D Problem).} \label{sec:Demos_pd2}
This demo uses Euler's method to locate a stationary solution of
a nonlinear parabolic PDE, followed by continuation of this stationary
state in a free problem parameter. The equations are
\begin{equation} \begin{array}{cl}
  {\partial u_1 / \partial t} &= D_1~{\partial^2 u_1 / \partial x^2}
  ~+~  p_1~ u ~( 1-u) ~-~ u_1 u_2 , \\
  {\partial u_2 / \partial t} 
  &= D_2~{\partial^2 u_2 / \partial x^2} ~-~ u_2 ~+~ u_1 u_2 , \\
\end{array} \end{equation}
on the space interval $[0,L]$, where $L=$~\parf{PAR(11)}~$=1$ is fixed throughout,
as are the diffusion constants $D_1=$~\parf{PAR(15)}~$=1$ and $D_2=$~\parf{PAR(16)}~$=1$.
The boundary conditions are $u_1(0) = u_1(L) = 0$ and $u_2(0) = u_2(L) = 1$,
for all time.

In the first run the continuation parameter is the independent time variable,
namely \parf{PAR(14)}, while $p_1=12$ is fixed.
The \AUTO-constants \parf{DS}, \parf{DSMIN}, and \parf{DSMAX} then control the step size
in space-time, here consisting of \parf{PAR(14)} and $(u_1(x),u_2(x))$.
Initial data at time zero are $u_1(x)=\sin(\pi x/L)$ and $u_2(x)=1$.
Note that in the subroutine \funcf{ STPNT} the initial data must be scaled to 
the unit interval, and that the scaled derivatives must also be provided; 
see the equations-file \filef{pv2.f90}.
In the second run the continuation parameter is $p_1$.
A branch point is located during this run.

Euler time integration is only first order accurate, so that
the time step must be sufficiently small to ensure correct results.
Indeed, this option has been added only as a convenience, and should 
generally be used only to locate stationary states.


\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | l |}
\hline
  \AUTO-COMMAND  & ACTION \\
\hline
%==============================================================================
  \commandf{mkdir pd2} & create an empty work directory \\ 
  \commandf{cd pd2} & change directory \\
  \commandf{demo('pd2') } & copy the demo files to the work directory \\
\hline
%==============================================================================

  \commandf{r1=run(e='pd2',c='pd2') } & time integration towards stationary state \\ 
  \commandf{save(r1,'1')} & save output-files as \filef{b.1, s.1, d.1} \\ 
\hline
%==============================================================================
\parbox[t]{3.4in}{
  \commandf{r2 = run(r1,IPS=17,ICP=[1],ISP=2,NMX=15,
            NPR=50,DS=-0.1,DSMAX=1.0,UZR=\{-1:0.0\})}} & \parbox[t]{3in}{continuation of stationary states; read restart data from \filef{s.1} \vspace{0.2cm}}\\ 
  \commandf{save(r2,'2') } & save output-files as \filef{b.2, s.2, d.2} \\ 
\hline
%==============================================================================
\end{tabular}
\caption{Commands for running demo \filef{pd2}.}
\label{tbl:demo_pd2}
\end{center}
\end{table}

\newpage
%==============================================================================
%DEMO=wav======================================================================
%==============================================================================
\section{ wav : Periodic Waves.} \label{sec:Demos_wav}
This demo illustrates the computation of various periodic wave solutions
to a system of coupled parabolic partial differential equations
on the spatial interval $[0,1]$.
The equations, that model an enzyme catalyzed reaction 
(\citename{DoKe:86a} \citeyear{DoKe:86a}) are~:
\begin{equation} \begin{array}{cl}
 {\partial u_1 / \partial t}
  &=
  ~{\partial^{2} u_1 / \partial x^{2}}
  -p_1 \bigl[p_4 R(u_1,u_2) - (p_2 - u_1) \bigr] ,\\
 {\partial u_2 / \partial t}
  &=
  \beta {\partial^{2} u_2 / \partial x^{2}}
  -p_1 \bigl[p_4 R(u_1,u_2) - p_7 (p_3 - u_2) \bigr].\\
\end{array} \end{equation}
All equation parameters, except $p_3$, are fixed throughout.

\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | l |}
\hline
  \AUTO-COMMAND  & ACTION \\
\hline
%==============================================================================
  \commandf{mkdir wav} & create an empty work directory \\ 
  \commandf{cd wav} & change directory \\
  \commandf{demo('wav')} & copy the demo files to the work directory \\
\hline
%==============================================================================
  \commandf{r1=run(e='wav',c='wav')} &
  \parbox[t]{3in}{
  1st run; stationary solutions of the system without diffusion \vspace{0.2cm}} \\ 
  \commandf{save(r1,"ode")} & save output-files as \filef{b.ode, s.ode, d.ode} \\ 
\hline
%==============================================================================
  \commandf{r2=run(e='wav',c='wav',IPS=11)} &
  \parbox[t]{3in}{2nd run; detect bifurcations to wave train solutions \vspace{0.2cm}}\\ 
\hline
%==============================================================================
  \parbox[t]{3.5in}{
  \commandf{r3=run(r2("HB1"),IPS=12,ICP=[3,11],ILP=0,
    ISP=0,RL1=700,DS=0.1,DSMAX=1.0,
    UZR=\{3:[610.0,638.0], -11:500.0\})}}
 & \parbox[t]{3in}{3rd run; wave train solutions of fixed wave speed \vspace{0.2cm}}\\ 
  \commandf{save(r2+r3,'wav') } & save output to \filef{b.wav, s.wav, d.wav} \\ 
\hline
%==============================================================================
  \parbox[t]{3.5in}{
  \commandf{uz3=load(r3("UZ3"),RL1=1000,
    DS=0.5,DSMAX=2.0,UZR=\{\})}}&
  load restart label\\
  \commandf{r4=run(uz3,ICP=[3,10],NPR=50)} & \parbox[t]{3in}{4th run; wave train solutions of fixed wave length \vspace{0.2cm}}\\ 
  \commandf{save(r4,'rng') } & save output-files as \filef{b.rng, s.rng, d.rng} \\ 
\hline
%==============================================================================
  \commandf{r5=run(uz3,IPS=14,ICP=[14],NMX=230,NPR=5)} & \parbox[t]{3in}{5th run; time evolution computation \vspace{0.2cm}}\\ 
  \commandf{save(r5,'tim') } & save output-files as \filef{b.tim, s.tim, d.tim} \\ 
%
%#
\hline
%==============================================================================
\end{tabular}
\caption{Commands for running demo \filef{wav}.}
\label{tbl:demo_wav}
\end{center}
\end{table}

\newpage
%==============================================================================
%DEMO=brc======================================================================
%==============================================================================
\section{ brc : Chebyshev Collocation in Space.} \label{sec:Demos_brc}
This demo illustrates the computation of stationary solutions and periodic
solutions to systems of parabolic PDEs in one space variable,
using Chebyshev collocation in space.
More precisely, the approximate solution is assumed of the form
$u(x,t) = \sum_{k=0}^{n+1} u_k(t) \ell_k(x)$.
Here $u_k(t)$ corresponds to $u(x_k,t)$ at the Chebyshev points
$\bigl\{ x_k \bigr\}_{k=1}^{n}$ with respect to the interval $[0,1]$.
The polynomials $\bigl\{ \ell_k(x) \bigr\}_{k=0}^{n+1}$ are the Lagrange
interpolating coefficients with respect to points 
$\bigl\{ x_k \bigr\}_{k=0}^{n+1}$, where $x_0=0$ and $x_{n+1}=1$.
The number of Chebyshev points in $[0,1]$,
as well as the number of equations in the PDE system,
can be set by the user in the file \filef{brc.f90}.

As an illustrative application we consider the Brusselator
(\citename{HoKnKu:87} \citeyear{HoKnKu:87})
\begin{equation} \begin{array}{cl}
  u_t &= {D_x / L^2} u_{xx} + u^2v - (B+1)u + A,  \\
  v_t &= {D_y / L^2} v_{xx} - u^2v + Bu,  \\
\end{array} \end{equation}
with boundary conditions $u(0,t)=u(1,t)=A$
and $v(0,t)=v(1,t)=B/A$.

Note that, given the non-adaptive spatial discretization,
the computational procedure here is not appropriate for
PDEs with solutions that rapidly vary in space, and care must
be taken to recognize spurious solutions and bifurcations.

\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | l |}
\hline
  \AUTO-COMMAND  & ACTION \\
\hline
%==============================================================================
  \commandf{mkdir brc} & create an empty work directory \\ 
  \commandf{cd brc} & change directory \\
  \commandf{demo('brc')} & copy the demo files to the work directory \\
\hline
%==============================================================================
  \commandf{r1=run(e='brc',c='brc') } & \parbox[t]{3in}{
compute the stationary solution family with Hopf bifurcations.
\vspace{0.2cm}}\\ 
\hline
%==============================================================================
  \commandf{r2=run(r1("HB1"),IPS=2,ICP=[5,11]) } & \parbox[t]{3in}{compute a family of periodic solutions from the first Hopf point. \vspace{0.2cm}}\\ 
\hline
%==============================================================================
  \commandf{r3=run(r2("BP1"),ISW=-1) } & \parbox[t]{3in}{compute a solution family from a secondary periodic bifurcation. \vspace{0.2cm}}\\ 
  \commandf{save(r1+r2+r3,'brc') } & save all output to \filef{b.brc, s.brc, d.brc} \\ 
\hline
%==============================================================================
\end{tabular}
\caption{Commands for running demo \filef{brc}.}
\label{tbl:demo_brc}
\end{center}
\end{table}


\newpage
%==============================================================================
%DEMO=brf======================================================================
%==============================================================================
\section{ brf : Finite Differences in Space.} \label{sec:Demos_brf}
This demo illustrates the computation of stationary solutions and periodic
solutions to systems of parabolic PDEs in one space variable.
A fourth order accurate finite difference approximation is used to
approximate the second order space derivatives. 
This reduces the PDE to an autonomous ODE of fixed dimension
which \AUTO is capable of treating.
The spatial mesh is uniform; the number of mesh intervals,
as well as the number of equations in the PDE system,
can be set by the user in the file \filef{brf.f90}.

As an illustrative application we consider the Brusselator
(\citename{HoKnKu:87} \citeyear{HoKnKu:87})
\begin{equation} \begin{array}{cl}
  u_t &= {D_x / L^2} u_{xx} + u^2v - (B+1)u + A,  \\
  v_t &= {D_y / L^2} v_{xx} - u^2v + Bu,  \\
\end{array} \end{equation}
with boundary conditions $u(0,t)=u(1,t)=A$
and $v(0,t)=v(1,t)=B/A$.

Note that, given the non-adaptive spatial discretization,
the computational procedure here is not appropriate for
PDEs with solutions that rapidly vary in space, and care must
be taken to recognize spurious solutions and bifurcations.


\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | l |}
\hline
  \AUTO-COMMAND  & ACTION \\
\hline
%==============================================================================
  \commandf{mkdir brf} & create an empty work directory \\ 
  \commandf{cd brf} & change directory \\
  \commandf{demo('brf') } & copy the demo files to the work directory \\
\hline
%==============================================================================
  \commandf{r1=run(e='brf',c='brf') } & \parbox[t]{3in}{compute the
    stationary solution family with Hopf bifurcations \vspace{0.2cm}}  \\ 
\hline
%==============================================================================
\parbox[t]{3in}{
  \commandf{r2=run(r1("HB1"),IPS=2,ICP=[5,11], NMX=120,EPSL=1e-8) }
\vspace{0.2cm}}
 & \parbox[t]{3in}{compute a family of periodic solutions from the first Hopf point. \vspace{0.2cm}}\\ 
\hline
%==============================================================================
\parbox[t]{3in}{
  \commandf{r3=run(r2("BP1"),ISW=-1, NMX=100,EPSL=1e-7) }
\vspace{0.2cm}}
& \parbox[t]{3in}{compute a solution family from a secondary periodic bifurcation.\vspace{0.2cm}}\\ 
  \commandf{save(r1+r2+r3,'brf') } & save all output to \filef{b.brf, s.brf, d.brf} \\ 
\hline
%==============================================================================
\end{tabular}
\caption{Commands for running demo \filef{brf}.}
\label{tbl:demo_brf}
\end{center}
\end{table}

\newpage
%==============================================================================
%DEMO=bru======================================================================
%==============================================================================
\section{ bru : Euler Time Integration (the Brusselator).} \label{sec:Demos_bru}
This demo illustrates the use of Euler's method for time integration
of a nonlinear parabolic PDE.
The example is the Brusselator
(\citename{HoKnKu:87} \citeyear{HoKnKu:87}), given by
\begin{equation} \begin{array}{cl}
  u_t &= {D_x / L^2} u_{xx} + u^2v - (B+1)u + A,  \\
  v_t &= {D_y / L^2} v_{xx} - u^2v + Bu,  \\
\end{array} \end{equation}
with boundary conditions $u(0,t)=u(1,t)=A$
and $v(0,t)=v(1,t)=B/A$. All parameters are given fixed values
for which a stable periodic solution is known to exist.

The continuation parameter is the independent time variable,
namely \parf{PAR(14)}.
The \AUTO-constants \parf{DS}, \parf{DSMIN}, and \parf{DSMAX}
then control the step size
in space-time, here consisting of \parf{PAR(14)} and $(u(x),v(x))$.
Initial data at time zero are 
$u(x)=A - 0.5 \sin(\pi x)$ and 
$v(x)=B/A + 0.7 \sin(\pi x)$.
Note that in the subroutine \funcf{ STPNT} the space derivatives of $u$ and $v$
must also be provided; 
see the equations-file \filef{bru.f90}.

Euler time integration is only first order accurate, so that
the time step must be sufficiently small to ensure correct results.
This option has been added only as a convenience, and should 
generally be used only to locate stationary states.
Indeed, in the case of the asymptotic periodic state of this demo,
the number of required steps is very large and use of a better time 
integrator is advisable.


\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | l |}
\hline
  \AUTO-COMMAND  & ACTION \\
\hline
%==============================================================================
  \commandf{mkdir bru} & create an empty work directory \\ 
  \commandf{cd bru} & change directory \\
  \commandf{demo('bru') } & copy the demo files to the work directory \\
\hline
%==============================================================================
  \commandf{r1=run(e='bru',c='bru') } & time integration \\ 
  \commandf{save(r1,'bru') } & save output-files as \filef{b.bru, s.bru, d.bru} \\ 
\hline
%==============================================================================
\end{tabular}
\caption{Commands for running demo \filef{bru}.}
\label{tbl:demo_bru}
\end{center}
\end{table}

%==============================================================================
%==============================================================================
\chapter{ \AUTO Demos : Optimization.} \label{ch:Demos_Opt}
%==============================================================================
%==============================================================================

\newpage
%==============================================================================
%DEMO=opt======================================================================
%==============================================================================
\section{ opt : A Model Algebraic Optimization Problem.} \label{sec:Demos_opt}
This demo illustrates the method of successive continuation 
for constrained optimization problems 
 by applying it to the following
simple problem~:~
Find the
maximum sum of coordinates on the unit sphere in $R^{5}$.
Coordinate 1 is treated as the state variable.
Coordinates 2-5 are treated as control parameters.
For details on the successive continuation procedure
see  \citename{DoKeKe:91a} \citeyear{DoKeKe:91a},
\citename{DoKeKe:91b} \citeyear{DoKeKe:91b}.

\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | l |}
\hline
  \AUTO-COMMAND  & ACTION \\
\hline
%==============================================================================
  \commandf{mkdir opt} & create an empty work directory \\ 
  \commandf{cd opt} & change directory \\
  \commandf{demo('opt')} & copy the demo files to the work directory \\
\hline
%==============================================================================
  \commandf{r1=run(e='opt',c='opt')} & one free equation parameter \\ 
  \commandf{save(r1,'1')} & save output-files as \filef{b.1, s.1, d.1} \\ 
\hline
%==============================================================================
  \commandf{r2=run(r1("LP1"))} & \parbox[t]{3in}{two free equation parameters; read restart data from \parf{r1} \vspace{0.2cm}}\\ 
  \commandf{save(r2,'2')} & save output-files as \filef{b.2, s.2, d.2} \\ 
\hline
%============================================================================== 
  \commandf{r3=run(r2("LP1"))} & \parbox[t]{3in}{three free equation parameters; read restart data from \parf{r2} \vspace{0.2cm}}\\ 
  \commandf{save(r3,'3')} & save output-files as \filef{b.3, s.3, d.3} \\ 
\hline
%==============================================================================
  \commandf{run(r3("LP1"))} & \parbox[t]{3in}{four free equation parameters; read restart data from \parf{r3} \vspace{0.2cm}}\\ 
  \commandf{save(r4,'4')} & save output-files as \filef{b.4, s.4, d.4} \\ 
\hline
%==============================================================================
\end{tabular}
\caption{Commands for running demo \filef{opt}.}
\label{tbl:demo_opt}
\end{center}
\end{table}

\newpage
%==============================================================================
%DEMO=ops======================================================================
%==============================================================================
\section{ ops : Optimization of Periodic Solutions.} \label{sec:Demos_ops}
This demo illustrates the method of successive continuation
for the optimization of periodic solutions.
For a detailed description of the basic method see
\citename{DoKeKe:91b} \citeyear{DoKeKe:91b}.
The illustrative system of autonomous ODEs, taken from 
\citename{Alej:91} \citeyear{Alej:91}, is
\begin{equation} \begin{array}{cl}
  x'(t) & = [-\lambda_4(x^3/3-x) + (z-x)/\lambda_2 - y]/\lambda_1, \\
  y'(t) &= x-\lambda_3, \\
  z'(t) &= -(z-x)/\lambda_2,
\end{array} \end{equation}
with objective functional
$$ \omega = 
  \int_0^{1} g(x,y,z;\lambda_1,\lambda_2,\lambda_3,\lambda_4) ~ dt, $$
where $g(x,y,z;\lambda_1,\lambda_2,\lambda_3,\lambda_4) \equiv \lambda_3$.
Thus, in this application, a one-parameter extremum of $g$ corresponds
to a fold with respect to the problem parameter $\lambda_3$, 
and multi-parameter extrema correspond to generalized folds.
Note that, in general, the objective functional is an integral along 
the periodic orbit, so that a variety of optimization problems
can be addressed.

For the case of periodic solutions, the extended optimality system
can be generated automatically, i.e., one need only define the vector field 
and the objective functional, as in done in the file \filef{ops.f90}.
For reference purpose it is convenient here to write down
the full extended system in its general form~:

\begin{equation} \begin{array}{cl}
  &u'(t)  = T f \bigl( u(t),\lambda \bigr) ,
  \qquad T\in \R {\rm ~(period)},~ u(\cdot),f(\cdot,\cdot) \in \Rn, 
  ~ \lambda \in \R^{n_{\lambda}},  \\
  & \cr
  &w'(t)  = -Tf_u\bigl( u(t),\lambda \bigr)^{*} w(t) 
  + \kappa u_0'(t) 
  + \gamma g_u\bigl( u(t),\lambda \bigr)^{*}, 
  \qquad w(\cdot) \in \Rn,~ \kappa, \gamma \in \R, \\
  & \cr
  &u(1) - u(0) = 0, \qquad w(1) - w(0) = 0,  \\
  & \cr  
  &\int_{0}^{1} u(t)^{*} u_0'(t)~ dt = 0,  \\
  & \cr
  &\int_{0}^{1}  \omega - g\bigl(u(t),\lambda\bigr)  ~dt = 0,  \\
  & \cr
  &\int_0^{1}  w(t)^{*}w(t)
  + \kappa^2 + \gamma^{2} - \alpha ~ dt = 0, 
  \qquad \alpha \in \R,  \\ 
  & \cr
  &\int_0^{1}  f\bigl( u(t),\lambda \bigr)^{*}w(t) 
  - \gamma g_{T}\bigl( u(t),\lambda \bigr)
  - \tau_0  ~ dt= 0, \qquad \tau_0 \in \R,  \\
  & \cr
  &\int_0^{1}  T f_{\lambda_i}\bigl( u(t),\lambda \bigr)^{*}w(t)
  - \gamma g_{\lambda_i}\bigl( u(t),\lambda \bigr)
  - \tau_i  ~dt= 0, 
  \qquad \tau_i \in \R, \quad i=1, \cdots, n_{\lambda}.\\
\end{array} \end{equation}
Above  $u_0$ is a reference solution, namely, the previous solution along 
a solution family.  

\newpage
In the computations below, the two preliminary runs, with \parf{IPS}=1 and \parf{IPS}=2,
respectively, locate periodic solutions. 
The subsequent runs are with \parf{IPS}=15 and hence use the automatically
 generated extended system.

\begin{itemize}
\item[-] 
  \commandf{Run 1.}~ Locate a Hopf bifurcation. 
  The free system parameter is $\lambda_3$. 
\item[-]\commandf{Run 2.}~ 
  Compute a family of periodic solutions from the Hopf bifurcation.
\item[-]\commandf{Run 3.}~ 
  This run retraces part of the periodic solution family, 
  using the full optimality system,
  but with all adjoint variables, $w(\cdot), \kappa, \gamma$, 
  and hence $\alpha$, equal to zero.
  The optimality parameters $\tau_0$ and $\tau_3$ are zero throughout.
  An extremum of the objective functional with respect to $\lambda_3$
  is located.
  Such a point corresponds to a branch point of the extended system. 
  Given the choice of objective functional in this demo, 
  this extremum is also a fold with respect to $\lambda_3$.
\item[-]\commandf{Run 4.}~
  Branch switching at the above-found branch point yields nonzero
  values of the adjoint variables.
  Any point on the bifurcating family away from the branch point
  can serve as starting solution for the next run.
  In fact, the branch-switching can be viewed as generating
  a nonzero eigenvector in an eigenvalue-eigenvector relation.
  Apart from the adjoint variables, all other variables remain
  unchanged along the bifurcating family.
\item[-]\commandf{Run 5.}~ 
  The above-found starting solution is continued in two system parameters, 
  here $\lambda_3$ and $\lambda_2$; i.e., a two-parameter family 
  of extrema with respect to $\lambda_3$ is computed.
  Along this family the value of the optimality parameter $\tau_2$ 
  is monitored, i.e., the value of the functional that vanishes 
  at an extremum with respect to the system parameter $\lambda_2$.
  Such a zero of $\tau_2$ is, in fact, located, and hence an extremum 
  of the objective functional with respect to both $\lambda_2$ and 
  $\lambda_3$ has been found.
  Note that, in general, $\tau_i$ is the value of the
  functional that vanishes at an extremum with respect to the system
  parameter $\lambda_i$.
\item[-]\commandf{Run 6.}~ 
  In the final run, the above-found two-parameter extremum is continued
  in three system parameters, here $\lambda_1$, $\lambda_2$, 
  and $\lambda_3$, toward $\lambda_1=0$.
  Again, given the particular choice of objective functional,
  this final continuation has an alternate significance here~:
  it also represents a three-parameter family of transcritical
  secondary periodic bifurcations points.
\end{itemize}

Although not illustrated here, one can restart an ordinary
continuation of periodic solutions, using \parf{IPS}=2 or \parf{IPS}=3,
from a labeled solution point on a family computed with \parf{IPS}=15.

\newpage
The free scalar variables specified in the \AUTO constants-files
for Run~3 and Run~4 are shown in  Table~\ref{tbl:demo_ops_1}.

\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | r | r | r | r | r | r | r |}
\hline
  Index& 3 & 11 & 12 & 22  & -22 & -23 & -31 \\
\hline
  Variable& $\lambda_3$ & $T$ &  $\alpha$ & $\tau_2$  
  & $[\lambda_2]$ & $[\lambda_3]$ & $[T]$ \\
\hline
\end{tabular}
\caption{\commandf{Runs 3 and 4}~ (files \filef{c.ops.3} and \filef{c.ops.4}).}
\label{tbl:demo_ops_1}
\end{center}
\end{table}

The parameter $\alpha$, which is the norm of the adjoint variables,
becomes nonzero after branch switching in Run~4.
The negative indices (-22, -23, and -31) set the active optimality 
functionals, namely for $\lambda_2$, $\lambda_3$, and $T$, respectively,
with corresponding variables $\tau_2$, $\tau_3$, and $\tau_0$,
respectively.
These should be set in the first run with \parf{IPS}=15 and remain unchanged
in all subsequent runs.


\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | r | r | r | r | r | r | r |}
\hline
  Index& 3 & ~2 & 11 & 22  & -22 & -23 & -31 \\
\hline
  Variable& $\lambda_3$ & $\lambda_2$ & $T$ & $\tau_2$  
  & $[\lambda_2]$ & $[\lambda_3]$ & $[T]$ \\
\hline
\end{tabular}
\caption{\commandf{Run 5}~ (file \filef{c.ops.5}).}
\label{tbl:demo_ops_2}
\end{center}
\end{table}

In Run~5 the parameter $\alpha$, which has been replaced by $\lambda_2$,
remains fixed and nonzero.
The variable $\tau_2$ monitors the value of the optimality functional 
associated with $\lambda_2$.
The zero of $\tau_2$ located in this run signals an extremum  
with respect to $\lambda_2$.


\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | r | r | r | r | r | r | r |}
\hline
  Index& 3 & ~2 & ~1 & 11  & -22 & -23 & -31 \\
\hline
  Variable& $\lambda_3$ & $\lambda_2$ & $\lambda_1$ & $T$  
  & $[\lambda_2]$ & $[\lambda_3]$ & $[T]$ \\
\hline
\end{tabular}
\caption{\commandf{Run 6}~ (file \filef{c.ops.6}).}
\label{tbl:demo_ops_3}
\end{center}
\end{table}


In Run~6 $\tau_2$, which has been replaced by $\lambda_1$, remains zero.


Note that $\tau_0$ and $\tau_3$ are not used as variables in any
of the runs; in fact, their values remain zero throughout.
Also note that the optimality functionals corresponding to 
$\tau_0$ and $\tau_3$ (or, equivalently, to $T$ and $\lambda_3$) 
\emp{ are} active in all runs.
This set-up allows the detection of the extremum of the objective functional,
with $T$ and $\lambda_3$ as scalar equation parameters,
as a bifurcation in the third run.

The parameter $\lambda_4$, and its corresponding optimality variable $\tau_4$,
are not used in this demo.
Also, $\lambda_1$ is used in the last run only, and its corresponding 
optimality variable $\tau_1$ is never used.

\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | l |}
\hline
  \AUTO-COMMAND  & ACTION \\
\hline
%==============================================================================
  \commandf{mkdir ops} & create an empty work directory \\ 
  \commandf{cd ops} & change directory \\
  \commandf{demo('ops')} & copy the demo files to the work directory \\
\hline
%==============================================================================
  \commandf{r1=run(e='ops',c='ops')} & locate a Hopf bifurcation \\ 
\hline
%==============================================================================
  \commandf{uzr=\{3:[0.92,0.93]\}} & set variable for \parf{UZR} \\
  \parbox[t]{3.2in}{\commandf{
      r2=run(r1("HB1"),IPS=2,ICP=[3,11], NMX=150,RL0=0.9,UZR=uzr)}} &
   \parbox[t]{3in}{compute a family of periodic solutions;  restart
     from \parf{r1} \vspace{0.2cm}}\\ 
  \commandf{save(r1+r2,'0')} & save output to \filef{b.0, s.0, d.0} \\ 
\hline
%==============================================================================
  \commandf{icp=[3,11,12,22,-22,-23,-31]} & set variable for \parf{ICP} \\
  \parbox[t]{3.2in}{\commandf{
   r3=run(r2("UZ1"),IPS=15,ILP=0, ICP=icp,ISP=2,NMX=25,ITNW=7,DS=-0.05)}}
  & \parbox[t]{3in}{locate a 1-parameter extremum as a bifurcation; restart from \parf{r2} \vspace{0.2cm}}\\ 
\hline
%==============================================================================
  \commandf{r4=run(r3("BP1"),ISW=-1,ISP=0,NMX=5)} & \parbox[t]{3in}{switch branches to generate optimality starting data; restart from \parf{r3} \vspace{0.2cm}}\\ 
  \commandf{save(r3+r4,'1')} & save output to \filef{b.1, s.1, d.1} \\ 
\hline
%==============================================================================
  \commandf{icp[1:3]=[2,11]} & set variable for \parf{ICP} \\
  \commandf{uzr[22]=0.0} & set variable for \parf{UZR} \\
  \parbox[t]{3.2in}{
  \commandf{r5=run(r4,ICP=icp,ISW=1,NMX=150, RL0=0.8,RL1=1.9,DS='-',UZR=uzr)}} 
 & \parbox[t]{3in}{compute 2-parameter family of 1-parameter extrema;
   restart from \parf{r4} \vspace{0.2cm}}\\ 
  \commandf{save(r5,'2')} & save the output-files as \filef{b.2, s.2, d.2} \\ 
\hline
%==============================================================================
  \commandf{icp[2:4]=[1,11]} & set variable for \parf{ICP} \\
  \parbox[t]{3.4in}{\commandf{r6=run(r5("UZ4"),IRS=15,ICP=icp,NTST=50,
UZR=\{1:[0.1,0.05,0.01,0.005,0.001]\})}} &
 \parbox[t]{3in}{compute 3-parameter family of 2-parameter extrema; restart from \parf{r5} \vspace{0.2cm}}\\ 
  \commandf{save(r6,'3')} & save the output-files as \filef{b.3, s.3, d.3} \\ 
\hline
%==============================================================================
\end{tabular}
\caption{Commands for running demo \filef{ops}.}
\label{tbl:demo_ops_4}
\end{center}
\end{table}

\newpage
%==============================================================================
%DEMO=obv======================================================================
%==============================================================================
\section{ obv : Optimization for a BVP.} \label{sec:Demos_obv}
This demo illustrates use of the method of successive continuation
for a  boundary value optimization problem.
A detailed description of the basic method, as well as a discussion
of the specific application considered here, is given in 
\citename{DoKeKe:91b} \citeyear{DoKeKe:91b}.
The required extended system is fully programmed here in the user-supplied
routines in \filef{obv.f90}.
For the case of periodic solutions the optimality system can be generated
automatically; see the demo \filef{ops}.

Consider the system
\begin{equation} \begin{array}{cl}
  u_1'(t) & = u_2(t), \\
  u_2'(t) &=
  -\lambda_1 e^{p(u_1,\lambda_2,\lambda_3)},
\end{array} \end{equation}
where
$ p(u_1,\lambda_2,\lambda_3) \equiv
  u_1 + \lambda_2 u_1^{2} + \lambda_3 u_1^{4},$
with boundary conditions
\begin{equation} \begin{array}{cl}
  u_1(0) &= 0, \\
  u_1(1) &= 0. \\
\end{array} \end{equation}
The objective functional is
$$ \omega = \int_0^{1} (u_1(t)-1)^{2}~ dt
  +  \frac{1}{10} \sum_{k=1}^{3} \lambda_{k}^{2}.  $$
The  successive continuation equations are given by
\begin{equation} \begin{array}{cl}
  u_1'(t) &= u_2(t), \\
  u_2'(t) &=
  -\lambda_1 e^{p(u_1,\lambda_2,\lambda_3)}, \\
  w_1'(t) &=
  \lambda_1 e^{p(u_1,\lambda_2,\lambda_3)} p_{u_1} w_2(t)
  + 2 \gamma(u_1(t)-1), \\
  w_2'(t) &= -w_1(t), \\
\end{array} \end{equation}
where
$$ p_{u_1} \equiv
  \frac{{\partial p} }{ {\partial u_1}} =
  1 + 2\lambda_2 u_1 + 4\lambda_3 u_1^{3},$$
with 
\begin{equation} \begin{array}{cl}
  u_1(0) = 0,\qquad  &w_1(0) - \beta_1 = 0,\qquad  w_2(0) = 0, \\
  u_1(1) = 0,\qquad  &w_1(1) + \beta_2 = 0,\qquad  w_2(1) = 0, \\\end{array} \end{equation}

$$ \int_0^{1} \bigl[ \omega - (u_1(t)-1)^{2}
  - \frac{1}{10} \sum_{k=1}^{3} \lambda_{k}^{2} \bigr]~ dt = 0, $$

$$ \int_0^{1} \bigl[w_1^{2}(t) - \alpha_0 \bigr]~ dt = 0, $$
 
\begin{equation} \begin{array}{cl}
  &\int_0^{1} \bigl[
  -e^{p(u_1,\lambda_2,\lambda_3)} w_2(t)
  - \frac{1}{5}\gamma \lambda_1
  \bigr]~ dt = 0, \\
  &\int_0^{1} \bigl[
  -\lambda_1 e^{p(u_1,\lambda_2,\lambda_3)} u_1(t)^{2} w_2(t)
  - \frac{1}{5}\gamma \lambda_2
  - \tau_2  \bigr]~ dt = 0, \\
  &\int_0^{1} \bigl[
  -\lambda_1 e^{p(u_1,\lambda_2,\lambda_3)} u_1(t)^{4} w_2(t)
  - \frac{1}{5}\gamma \lambda_3
  - \tau_3 \bigr]~ dt = 0. \\\end{array} \end{equation}

In the first run the free equation parameter is $\lambda_1$.
All adjoint variables are zero.
Three extrema of the objective function are located.
These correspond to branch points and, in the second run,
branch switching is done at one of these.
Along the bifurcating family the adjoint variables become nonzero,
while state variables and $\lambda_1$ remain constant.
Any such non-trivial solution point can be used for continuation 
in two equation parameters, after fixing the $L_2$-norm of one of 
the adjoint variables. This is done in the third run.
Along the resulting family several two-parameter extrema are located 
by monotoring certain inner products.
One of these is further continued in three equation parameters in the final run,
where a three-parameter extremum is located.


\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | l |}
\hline
  \AUTO-COMMAND  & ACTION \\
\hline
%==============================================================================
  \commandf{mkdir obv} & create an empty work directory \\ 
  \commandf{cd obv} & change directory \\
  \commandf{demo('obv')} & copy the demo files to the work directory \\
\hline
%==============================================================================
  \commandf{r1=run(e='obv',c='obv')} & locate 1-parameter extrema as branch points \\ 
  \commandf{save(r1,'obv')} & save output-files as \filef{b.obv, s.obv, d.obv} \\ 
\hline
%==============================================================================
  \commandf{r2=run(r1("BP1"),ISW=-1,NMX=5)} & \parbox[t]{3in}{compute a few step on the first bifurcating family \vspace{0.2cm}}\\ 
  \commandf{save(r2,'1')} & save the output-files as \filef{b.1, s.1, d.1} \\ 
\hline
%==============================================================================
\parbox[t]{3.2in}{
  \commandf{r3=run(r2,ICP=[10,1,2,17,18,13,14,15], ISW=1,NMX=100)}} & \parbox[t]{3in}{locate 2-parameter extremum; restart from \parf{r2} \vspace{0.2cm}}\\ 
  \commandf{save(r3,'2')} & save the output-files as \filef{b.2, s.2, d.2} \\ 
\hline
%==============================================================================
\parbox[t]{3.2in}{
  \commandf{r4=run(r3("UZ2"), ICP=[10,1,2,3,18,13,14,15],NMX=25)}} & \parbox[t]{3in}{locate 3-parameter extremum; restart from \parf{r3} \vspace{0.2cm}}\\ 
  \commandf{save(r4,'3')} & save the output-files as \filef{b.3, s.3, d.3} \\ 
\hline
%==============================================================================
\end{tabular}
\caption{Commands for running demo \filef{obv}.}
\label{tbl:demo_obv}
\end{center}
\end{table}

%==============================================================================
%==============================================================================
\chapter{ \AUTO Demos : Connecting orbits.} \label{ch:Demos_Heteroclinics}
%==============================================================================
%==============================================================================

\newpage
%==============================================================================
%DEMO=fsh======================================================================
%==============================================================================
\section{ fsh : A Saddle-Node Connection.} \label{sec:Demos_fsh}
This demo illustrates the computation of travelling wave front solutions
to the Fisher equation,
\begin{equation} \begin{array}{cl}
  & w_t = w_{xx} + f(w),
  \qquad -\infty < x < \infty,
  \quad  t > 0,  \\
  & f(w) \equiv w(1-w) .  \\
\end{array} \end{equation}
We look for solutions of the form $w(x,t)=u(x+ct)$, where
$c$ is the wave speed.
This gives the first order system
\begin{equation} \begin{array}{cl}
  &  u_1'(z)  = u_2(z),  \\
  &  u_2'(z)  = c u_2(z) - f\bigl(u_1(z)\bigr).  \\
\end{array} \end{equation}
Its fixed point $(0,0)$ has two positive eigenvalues when $c>2$.
The other fixed point, $(1,0)$, is a saddle point.
A family of orbits connecting the two fixed points
requires one free parameter; see 
\citename{FrDo:91} \citeyear{FrDo:91}.
Here we take this parameter to be the wave speed $c$.

In the first run a starting connecting orbit is computed 
by continuation in the period $T$.
This procedure can be used generally for time integration of an ODE with \AUTO.
Starting data in \funcf{STPNT} correspond to a point on the approximate stable manifold
of $(1,0)$, with $T$ small.
In this demo the ``free'' end point of the orbit necessary approaches the
unstable fixed point $(0,0)$.
A computed orbit with sufficiently large $T$ is then chosen as restart orbit
in the second run, where, typically, one replaces $T$ by $c$ as continuation
parameter.
However, in the second run below, we also add a phase condition, 
and both $c$ and $T$ remain free.



\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | l |}
\hline
  \AUTO-COMMAND  & ACTION \\
\hline
%==============================================================================
  \commandf{mkdir fsh} & create an empty work directory \\ 
  \commandf{cd fsh} & change directory \\
  \commandf{demo('fsh')} & copy the demo files to the work directory \\
\hline
%==============================================================================
  \commandf{r1=run(e='fsh',c='fsh')} & continuation in the period $T$, with $c$ fixed; no phase condition \\ 
  \commandf{save(r1,'0')} & save output-files as \filef{b.0, s.0, d.0} \\ 
\hline
%==============================================================================
 \parbox[t]{2in}{
  \commandf{r2 = run(r1("EP2"), ICP=[2,11,12,13,14], NINT=1,
DS='-', UZR=\{2:[1,2,3,5,10]\})} \vspace{0.2cm}} & 
 \parbox[t]{3in}{continuation in $c$ and $T$, with active phase
   condition. \vspace{0.2cm}} \\ 
  \commandf{save(r2,'fsh')} & save output-files as \filef{b.fsh, s.fsh, d.fsh} \\ 
\hline
%==============================================================================
\end{tabular}
\caption{Commands for running demo \filef{fsh}.}
\label{tbl:demo_fsh}
\end{center}
\end{table}

\newpage
%==============================================================================
%DEMO=nag======================================================================
%==============================================================================
\section{ nag : A Saddle-Saddle Connection.} \label{sec:Demos_nag}
This demo illustrates the computation of traveling wave front solutions
to Nagumo's equation,
\begin{equation} \begin{array}{cl}
  & w_t = w_{xx} + f(w,a),
  \qquad -\infty < x < \infty,
  \quad  t > 0,  \\
  & f(w,a) \equiv w(1-w)(w-a), \qquad 0<a<1.  \\
\end{array} \end{equation}
We look for solutions of the form $w(x,t)=u(x+ct)$, where
$c$ is the wave speed.
This gives the first order system
\begin{equation} \begin{array}{cl}
  &  u_1'(z)  = u_2(z),  \\
  &  u_2'(z)  = c u_2(z) - f\bigl(u_1(z),a\bigr),  \\
\end{array} \end{equation}
where $z=x+ct$, and $' = d/dz$.
If $a=1/2$ and $c=0$ then there are two analytically known
heteroclinic connections, one of which is given by
$$ u_1(z) = \frac{
  {e^{\frac{1}{2} \sqrt{2} z}}
  }{
  {1 + e^{\frac{1 }{ 2} \sqrt{2} z}}  },
  \qquad  u_2(z) = u_1'(z),  \qquad  -\infty < z < \infty.
  $$
The second heteroclinic connection is obtained by reflecting the
phase plane representation of the first with respect to the
$u_1$-axis.
In fact, the two connections together constitute a heteroclinic cycle.
One of the exact solutions is used below as starting orbit.
To start from the second exact solution, change SIGN=-1 in the  
routine \funcf{STPNT} in \filef{nag.f90} and repeat the computations below;
see also
\citename{FrDo:91} \citeyear{FrDo:91}.

\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | l |}
\hline
  \AUTO-COMMAND  & ACTION \\
\hline
%==============================================================================
  \commandf{mkdir nag} & create an empty work directory \\ 
  \commandf{cd nag} & change directory \\
  \commandf{demo('nag')} & copy the demo files to the work directory \\
\hline
%==============================================================================
  \commandf{r1=run(e='nag',c='nag')} & compute part of first family of heteroclinic orbits \\ 
\hline
%==============================================================================
  \commandf{r2=run(e='nag',c='nag',DS='-')} & compute first family in opposite direction\\ 
  \commandf{save(r1+r2,'nag')} & save all output to \filef{b.nag, s.nag, d.nag} \\ 
\hline
%==============================================================================
\end{tabular}
\caption{Commands for running demo \filef{nag}.}
\label{tbl:demo_nag}
\end{center}
\end{table}

\newpage
%==============================================================================
%DEMO=stw======================================================================
%==============================================================================
\section{ stw : Continuation of Sharp Traveling Waves.} \label{sec:Demos_stw}
This demo illustrates the computation of sharp traveling wave front solutions
to nonlinear diffusion problems of the form
$$ w_t = A(w) w_{xx} + B(w) w_x^{2} + C(w),  $$
with
$A(w) = a_1 w + a_2 w^{2}$,
$B(w) = b_0 + b_1 w + b_2 w^{2}$,
and
$C(w) = c_0 + c_1 w + c_2 w^{2}$.
Such equations can have \commandf{sharp traveling wave fronts} as solutions, i.e., solutions of the form
$w(x,t)=u(x+ct)$ for which there is a $z_0$ such that
$u(z)=0$ for $z \ge z_0$,
$u(z) \not= 0$ for $z < z_0$, and
$u(z) \rightarrow constant$ as $z \rightarrow -\infty$.
These solutions are actually generalized solutions, since they need
not be differentiable at $z_0$.

Specifically, in this demo a homotopy path will be computed 
from an analytically known exact sharp traveling wave solution of
$$ w_t = 2w w_{xx} + 2 w_x^{2} + w(1-w),  \leqno(1) $$
to a corresponding sharp traveling wave of
$$ w_t = (2w+w^{2}) w_{xx} + w w_x^{2} + w(1-w). \leqno(2) $$
This problem is also considered in
\citename{DoKeKe:91b} \citeyear{DoKeKe:91b}.
For these two special cases the functions $A,B,C$ are defined
by the coefficients in Table~\ref{tbl:demo_stw_1}.

\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | l | l | l | l | l | l | l | l |}
\hline
         & $a_1$ & $a_2$ & $b_0$ &$b_1$ &$b_2$ &$c_0$ &$c_1$ &$c_2$ \\
\hline
Case (1) &  2    &   0   &   2   &  0   &  0   &  0   &  1   &  -1 \\
\hline
Case (2) &  2    &   1   &   0   &  1   &  0   &  0   &  1   &  -1 \\
\hline
\end{tabular}
\caption{Problem coefficients in demo \filef{stw}.}
\label{tbl:demo_stw_1}
\end{center}
\end{table}

With $w(x,t)=u(x+ct)$, $z=x+ct$, one obtains the reduced system
\begin{equation} \begin{array}{cl}
  & u_1'(z) = u_2,  \\
  & u_2'(z) = \bigl[c u_2 - B(u_1) u_2^{2} - C(u_1) \bigr]/A(u_1). \\
\end{array} \end{equation}
To remove the singularity when $u_1=0$, we apply a
nonlinear transformation of the independent variable 
(see \citename{Ar:80} \citeyear{Ar:80}), viz.,
${d / d \tilde z} = A(u_1) {d / dz}$,
which changes the above equation into
\begin{equation} \begin{array}{cl}
  & u_1'(\tilde z) = A(u_1) u_2,  \\
  & u_2'(\tilde z) = c u_2 - B(u_1) u_2^{2} - C(u_1). \\
\end{array} \end{equation}
Sharp traveling waves then correspond to heteroclinic connections
in this transformed system.

\newpage 
Finally, we  map $ [0,T] \rightarrow [0,1] $
by the transformation $\xi = \tilde z / T$.
With this scaling of the independent variable, the reduced system
becomes
\begin{equation} \begin{array}{cl}
  & u_1'(\xi) = T A(u_1) u_2,  \\
  & u_2'(\xi) = T \bigl[ c u_2 - B(u_1) u_2^{2} - C(u_1)\bigr]. \\
\end{array} \end{equation}
For Case~1 this equation has a known exact solution, namely,
$$ u(\xi) = \frac{1 }{ 1 + \exp(T\xi) }, \qquad
  v(\xi) = \frac{ -\frac{1 }{ 2}  }{ 1 + \exp(-T\xi) }. $$
This solution has wave speed $c=1$.
In the limit as $T \rightarrow \infty$ its phase plane trajectory
connects the stationary points $(1,0)$ and $(0,-\frac{1 }{ 2})$.
 
The sharp traveling wave in Case~2
can now be obtained using the following homotopy.
Let
$(a_1,a_2,b_0,b_1,b_2) =
  (1-\lambda) (2,0,2,0,0) + \lambda (2,1,0,1,0)$.
Then as $\lambda$ varies continuously from 0 to 1, the parameters
$(a_1,a_2,b_0,b_1,b_2)$
vary continously from the values for Case~1
  to the values for Case~2.


\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | l |}
\hline
  \AUTO-COMMAND  & ACTION \\
\hline
%==============================================================================
  \commandf{mkdir stw} & create an empty work directory \\ 
  \commandf{cd stw} & change directory \\
  \commandf{demo('stw')} & copy the demo files to the work directory \\
\hline
%==============================================================================
  \commandf{r1=run(e='stw',c='stw')} & continuation of the sharp traveling wave \\ 
  \commandf{save(r1,'stw')} & save output-files as \filef{b.stw, s.stw, d.stw} \\ 
\hline
%==============================================================================
\end{tabular}
\caption{Commands for running demo \filef{stw}.}
\label{tbl:demo_stw_2}
\end{center}
\end{table}


%==============================================================================
%==============================================================================
\chapter{ \AUTO Demos : Miscellaneous.} \label{ch:Demos_Misc}
%==============================================================================
%==============================================================================

\newpage
%==============================================================================
%DEMO=pvl======================================================================
%==============================================================================
\section{ pvl : Use of the Routine \funcf{ PVLS}.} \label{sec:Demos_pvl}

Consider Bratu's equation
\begin{equation} \begin{array}{cl}
  u_1 ' &= u_2  ,  \\
  u_2 ' &= -p_1  e^{u_1} , \\ 
\end{array} \end{equation}
with boundary conditions $ u_1(0)=0$, $u_1(1)=0.$
As in demo \filef{exp}, a solution curve requires one free parameter;
here $p_1$.

Note that additional parameters are specified in the user-supplied subroutine 
\funcf{ PVLS} in file \filef{pvl.f90}, namely,
$p_2$ (the $L_2$-norm of $u_1$),
$p_3$ (the minimum of $u_2$ on the space-interval $[0,1]$~),
$p_4$ (the boundary value $u_2(0)$~),
$p_5$ (the same boundary value $u_2(0)$~).
These additional parameters should be considered as ``solution measures''
for output purposes; they should not be treated as true
continuation parameters.

Note also that four free parameters are specified in the \AUTO-constants file 
\filef{c.pvl}, namely, $p_1$, $p_2$, $p_3$, $p_4$, and $p_5$.
The first one in this list, $p_1$, is the true continuation parameter. 
The parameters $p_2$, $p_3$, $p_4$, and $p_5$ are \emp{ overspecified}
so that their values will appear in the output.
However, 
\emp{ it is essential that the true continuation parameter appear first.}
For example, it would be an error to specify the parameters
in the following order~: $p_2$, $p_1$, $p_3$, $p_4$, $p_5$.

In general, true continuation parameters must appear first in the
parameter-specification in the \AUTO constants-file.
Overspecified parameters will be printed, and can be
defined in \funcf{ PVLS}, but they are not part of the intrinsic continuation
procedure.

As this demo also illustrates (see the \parf{UZR} values in \filef{c.pvl}),
labeled solutions can also be output at selected values 
of the overspecified parameters.

\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | l |}
\hline
  \AUTO-COMMAND  & ACTION \\
\hline
%==============================================================================
  \commandf{mkdir pvl} & create an empty work directory \\ 
  \commandf{cd pvl} & change directory \\
  \commandf{demo('pvl')} & copy the demo files to the work directory \\
\hline
%==============================================================================
  \commandf{r1=run(e='pvl',c='pvl')} & compute a solution family \\ 
  \commandf{save(r1,'pvl')} & save output-files as \filef{b.pvl, s.pvl, d.pvl} \\ 
\hline
%==============================================================================
\end{tabular}
\caption{Commands for running demo \filef{pvl}.}
\label{tbl:demo_pvl}
\end{center}
\end{table}

\newpage
%==============================================================================
%DEMO=ext======================================================================
%==============================================================================
\section{ ext : Spurious Solutions to BVP.} \label{sec:Demos_ext}

This demo illustrates the computation of spurious solutions
to the boundary value problem
\begin{equation} \begin{array}{cl}
& u_1' - u_2 = 0 , \\
& u_2' + \lambda^2 \pi^2 \sin( u_1 + u_1^2 + u_1^3 ) = 0,
  \qquad t \in [0,1], \\ 
& u_1(0) = 0, \quad u_1(1) = 0. \\
\end{array} \end{equation}
Here the differential equation is discretized using a fixed uniform mesh.
This results in spurious solutions that disappear when an adaptive mesh is used.
See the \AUTO-constant \parf{IAD} in Section~\ref{sec:Discretization_constants}.
This example is also considered in
\citename{BeDo:81} \citeyear{BeDo:81}
and
\citename{DoKeKe:91b} \citeyear{DoKeKe:91b}.

\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | l |}
\hline
  \AUTO-COMMAND  & ACTION \\
\hline
%==============================================================================
  \commandf{mkdir ext} & create an empty work directory \\ 
  \commandf{cd ext} & change directory \\
  \commandf{demo('ext')} & copy the demo files to the work directory \\
\hline
%==============================================================================
  \commandf{r1=run(e='ext',c='ext')} & detect bifurcations from the trivial solution family \\ 
\hline
%==============================================================================
  \commandf{r2=run(r1("BP3"),ISW=-1,NCOL=3)} & \parbox[t]{3in}{compute a bifurcating family containing spurious bifurcations. \vspace{0.2cm}}\\ 
  \commandf{save(r1+r2,'ext')} & save all output to \filef{b.ext, s.ext, d.ext} \\ 
\hline
%==============================================================================
\end{tabular}
\caption{Commands for running demo \filef{ext}.}
\label{tbl:demo_ext}
\end{center}
\end{table}

\newpage
%==============================================================================
%DEMO=tim======================================================================
%==============================================================================
\section{ tim : A Test Problem for Timing \AUTO.} \label{sec:Demos_tim}
This demo is a boundary value problem with variable dimension \parf{NDIM}. 
It can be used to time the performance of \AUTO 
for various choices of \parf{NDIM} (which must be even), \parf{NTST}, and \parf{NCOL}.
The equations are
\begin{equation} \begin{array}{cl}
  u_i ' &= u_i  ,  \\
  v_i ' &= -p_1 ~  e(u_i) , \\
\end{array} \end{equation}
$i=1,\cdots$,\parf{NDIM}/2,
with boundary conditions $ u_i(0)=0$, $u_i(1)=0.$
Here 
$$ e(u) = \sum_{k=0}^{n} ~ \frac{u^k }{ k!} ~ , $$
with $n=25$.
The computation requires 10 full $LU$-decompositions of the linearized system
that arises from Newton's method for solving the collocation equations.
The commands for running the timing problem for a particular choice 
of \parf{NDIM}, \parf{NTST}, and \parf{NCOL} are given below.
(Note that if \parf{NDIM} is changed then \parf{NBC} must be changed accordingly.)

\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | l |}
\hline
  \AUTO-COMMAND  & ACTION \\
\hline
%==============================================================================
  \commandf{mkdir tim} & create an empty work directory \\ 
  \commandf{cd tim} & change directory \\
  \commandf{demo('tim')} & copy the demo files to the work directory \\
\hline
%==============================================================================
  \commandf{r1=run(e='tim',c='tim')} & Timing run \\ 
  \commandf{save(r1,'tim')} & save output-files as \filef{b.tim, s.tim, d.tim} \\ 
\hline
%==============================================================================
\end{tabular}
\caption{Commands for running demo \filef{tim}.}
\label{tbl:demo_tim}
\end{center}
\end{table}


%==============================================================================
%==============================================================================
\chapter{ {\cal HomCont}.} \label{ch:HomCont}
%==============================================================================
%==============================================================================
\section{ Introduction.} \label{sec:HomCont_Intro}
{\cal HomCont} is a collection of routines for the continuation 
of homoclinic solutions to ODEs in two or more parameters.
The accurate detection and multi-parameter continuation of certain
codimension-two singularities is allowed for, including all known
cases that involve a unique homoclinic orbit at the singular point.
Homoclinic connections to hyperbolic and non-hyperbolic equilibria are 
allowed as are certain heteroclinic orbits. 
Homoclinic orbits in reversible systems can also be computed.
The theory behind the methods used is
explained in \citeasnoun{ChKu:94}, \citeasnoun{BaCh:94},
\citename{Sa:95} \citeyear{Sa:95,Sa:95a}, \citeasnoun{ChKuSa:95} and
references therein.  The final cited paper contains a concise
description of the present version. 

The current implementation of {\cal HomCont} must be considered as experimental,
and updates are anticipated.
The {\cal HomCont} routines are in the file {\tt auto/07p/src/autlib5.f}. 
Expert users wishing to modify the routines may look there.
Note also that at present, {\cal HomCont} can be run only in 
{\cal AUTO} Command Mode and not with the GUI. 


\section{{\cal HomCont} Files and Routines.} \label{sec:HomCont_files}

In order to run {\cal HomCont} one must prepare an equations file \filef{xxx.f90}, 
where \filef{xxx} is the name of the example, 
and constants-file \filef{c.xxx}.
These files are in the standard {\cal AUTO} format, but
the \filef{c.xxx} file almost always also must
contain constants that are specific to homoclinic continuation.
The choice \parf{IPS}=9 in \filef{c.xxx} specifies the problem as
being homoclinic continuation.

The equation-file \filef{kpr.f90} serves as a sample for new equation
files. It contains the Fortran routines 
\funcf{ FUNC}, \funcf{ STPNT}, \funcf{ PVLS}, \funcf{ BCND}, \funcf{ ICND} 
and \funcf{ FOPT}. The final three are
dummy routines which are never needed for homoclinic continuation.
Note a minor difference in \funcf{ STPNT} and \funcf{ PVLS} with other 
{\cal AUTO} equation-files, in that the common block 
\parf{/BLHOM/} is required.

The constants-file \filef{c.xxx} is identical in format to other
{\cal AUTO} constants-files, except for the added constants.
Note that the values of the constants
\parf{NBC} and \parf{NINT} are irrelevant, as these are set
automatically by the choice \parf{IPS}=9. Also, the choice \parf{JAC=1}
is strongly recommended, because the Jacobian is used extensively for
calculating the linearization at the equilibria and hence for
evaluating boundary conditions and certain test functions. However,
note that \parf{JAC=1} does not necessarily mean that {\cal auto} will
use the analytically specified Jacobian for continuation.

The earlier HomCont files \filef{h.xxx} are obsolete but still
supported. You can convert from the old to the new format by running
the command \commandf{@cnvc xxx yyy} where \commandf{xxx} refers to either
or both of the files \filef{c.xxx} and \filef{h.xxx}. A new-style
constants file, \filef{c.yyy} is written. The command
\commandf{@cnvc xxx} overwrites \filef{c.xxx} and deletes \filef{h.xxx}.

\section{ {\cal HomCont}-Constants.} \label{sec:HomCont_Constants}
An example for the HomCont-specific constants in \filef{c.xxx} is listed below:
\begin{verbatim}
          NUNSTAB=1, NSTAB=2, IEQUIB=1, ITWIST=1, ISTART=5
          IREV = []
          IFIXED = [13]
          IPSI = [9,10]
\end{verbatim}
These constants have the following meaning. 

\subsection{\parf{NUNSTAB}}  \label{sec:NUNSTAB}

Number of unstable eigenvalues of the left-hand equilibrium (the equilibrium 
approached by the orbit as $t \to -\infty$). The default value is -1,
which means autodetection. In almost all cases autodetection is
possible. The exception is when starting from a homoclinic to a
saddle-node equilibrium when \parf{IEQUIB$\ne$1}. Examples for this
exception are in runs 9, 12, and 13 of the
demo \texttt{kpr} (see Chapter~\ref{ch:HomCont_kpr}).
Even in this case
only one of \parf{NUNSTAB} and \parf{NSTAB} needs to be specified, the
other one being computed as \parf{NDIM} minus the specified constant.

\subsection{\parf{NSTAB}}  \label{sec:NSTAB}
Number of stable eigenvalues of the right-hand equilibrium (the equilibrium
approached by the orbit as $t \to +\infty$). The same default as for
\parf{NUNSTAB} applies here.

\subsection{\parf{IEQUIB}}  \label{sec:IEQUIB}
\begin{itemize}
\item[-] \parf{IEQUIB=0}~: 
Homoclinic orbits to hyperbolic equilibria;  
the equilibrium is specified explicitly in \funcf{PVLS} and stored in
\parf{PAR(11+I)}, \parf{I=1,NDIM}.
\item[-] \parf{IEQUIB=1}~(default): 
Homoclinic orbits to hyperbolic equilibria;  
the equilibrium is solved for during continuation. Initial values for
the equilibrium are stored in \parf{PAR(11+I)}, \parf{I=1,NDIM} in \funcf{ STPNT}.
\item[-] \parf{IEQUIB=2}~: 
Homoclinic orbits to a saddle-node; initial values for
the equilibrium are stored in \parf{PAR(11+I)}, \parf{I=1,NDIM} in \funcf{ STPNT}.
\item[-] \parf{IEQUIB=-1}~: 
Heteroclinic orbits to hyperbolic equilibria;
the equilibria are specified explicitly in \funcf{ PVLS} and stored in
\parf{PAR(11+I)},  
\parf{I=1,NDIM} (left-hand equilibrium) and \parf{PAR(11+I)}, 
\parf{I=NDIM+1,2*NDIM} (right-hand equilibrium). 
\item[-] \parf{IEQUIB=-2}~: 
Heteroclinic orbits to hyperbolic equilibria;
the equilibria are solved for during continuation. Initial values are
specified in \funcf{ STPNT} and stored in \parf{PAR(11+I)}, \parf{I=1,NDIM} (left-hand equilibrium), 
\parf{PAR(11+I)}, \parf{I=NDIM+1,2*NDIM} (right-hand equilibrium).
\end{itemize}

\subsection{\parf{ITWIST}}  \label{sec:ITWIST}
\begin{itemize}
\item[-] \parf{ITWIST=0}~(default): 
the orientation of the homoclinic orbit is not computed.
\item[-] \parf{ITWIST=1}~: 
the orientation of the homoclinic orbit is computed. For this purpose, the
adjoint variational equation is solved for the unique bounded
solution. If \parf{IRS = 0}, an initial solution to the adjoint equation
must be specified as well. However, if \parf{IRS>0} and \parf{ITWIST} 
has just been increased from zero, then {\cal AUTO} will
automatically generate the initial solution to the adjoint. 
In this case, a dummy Newton-step should be performed, see 
Section~\ref{sec:Starting_strategies} for more details.
\end{itemize}

\subsection{\parf{ISTART}}  \label{sec:ISTART}
\begin{itemize}
\item[-] \parf{ISTART=1}~:
No special action is taken.
\item[-] \parf{ISTART=2}~: 
If \parf{IRS=0}, an explicit solution must be specified in the
subroutine \funcf{ STPNT} in the usual format. 
\item[-] \parf{ISTART=3}~: 
The ``homotopy'' approach is used for starting, see 
Section~\ref{sec:Starting_strategies} 
for more details. Note that this is not available with the choice 
\parf{IEQUIB=2}.
\item[-] \parf{ISTART=4}~:
A phase-shift is performed for homoclinic orbits to let the
equilibrium (either fixed or non-fixed, depending on IEQUIB)
correspond to $t=0$ and $t=1$. This is necessary if a periodic
orbit that is close to a homoclinic orbit is continued into
a homoclinic orbit.
\item[-] \parf{ISTART=5}~(default):
If \parf{IRS=0}, the restart solution comes from a data file, or
the restart solution is a homoclinic orbit with problem
type \parf{IPS=9}, no special action is taken, as for \parf{ISTART=1}.
For other problem types, use a phase-shift, as for \parf{ISTART=4}.
\item[-] \parf{ISTART=-N, $N=1,2,3,\ldots$}~:
Homoclinic branch switching: this description is for reference only.
We refer to the demo in Chapter~\ref{ch:HomCont_hbs} to see how this
can be used in actual practice and to \citeasnoun{OlChKr:03} for
theory and background.

The orbit is split into $N+1$ parts and
{\cal AUTO} sees it as an $(N+1)\times$\parf{NDIM}-dimensional object.
The first part $u_0$ goes from the equilibrium to the point $x_0$ that is 
furthest from the equilibrium. 
Then follow $N-1$ shifted copies of the orbit, which travel
from the point $x_0$ back to the point $x_0$. The last part $U_N$
goes from the point $x_0$ back to the equilibrium. 
The derivatives $\dot{x}_0$ with respect to time
of the point that is furthest from the equilibrium are stored at the 
parameters \parf{PAR(NP-NDIM+1...NP)}, where \parf{NP=max(NPARX,NPAR)}.

If \parf{ITWIST=1}, and this was also the case in the preceding run,
then a copy of the adjoint vector $\Psi$ at $x_0$ is stored at the parameters
\parf{PAR(NP-NDIM*2+1...NP-NDIM)} and Lin's method can be used
to do homoclinic branch switching. To be more precise, the individual parts
$u_i$ and $u_{i+1}$ are at distances $\varepsilon_i$ away from each
other, along the Lin vector $Psi$, at the left- and right-hand end
points. These gaps $\varepsilon_i$ are at parameters
\parf{PAR(20+2*i)}. Moreover, each part (except $u_{N+1}$) ends at
at a Poincar\'e section which goes through $x_0$ and is perpendicular
to $\dot{x}_0$.

The times $T_i$ that each part $u_i$ takes are stored as follows: 
$T_0=$\parf{PAR(10)}, $T_N=$\parf{PAR(11)} and $T_i=$\parf{PAR(19+2*i)}
for $i=1\ldots N-1$. Through a continuation in problem parameters,
gaps $\varepsilon_i$, and times $T_i$ 
it is possible to switch from a $1$-homoclinic to
an $N$-homoclinic orbit.

If \parf{ITWIST=0}, the adjoint vector is not computed and Lin's
method is not used. Instead, AUTO produces a gap
$\varepsilon$=\parf{PAR(22)} at the right-hand end point $p$ of
$u_{N+1}$, measuring the distance between the stable manifold of the
equilibrium and $p$. This technique can also be used to find 2-homoclinic
orbits, by varying in $\varepsilon$ and $T_1$, similar to the method
described before, but only if the unstable manifold in
one-dimensional. Because this method is more limited than the method
using Lin vectors, we do not recommend it for normal usage.

To switch back to a normal homoclinic orbit, set \parf{ISTART} back to
a positive value such as 1. Now HomCont has lost all the information
about the adjoint, so if \parf{ITWIST} is set to 0, HomCont
does a normal continuation without the adjoint, and
if \parf{ITWIST} is set to 1, one needs to do a Newton dummy step
first to recalculate the adhoint.
\end{itemize}

\subsection{\parf{IREV}}  \label{sec:IREV}
If \parf{IREV$\ne$[]} then it is assumed that
the system is reversible under the transformation 
$t \to -t$ and $U(i) \to -U(i)$ for all $i$ with 
\parf{IREV(i)>0}. Then only half the homoclinic solution is
solved for with right-hand boundary conditions specifying
that the solution is symmetric under the reversibility
(see \citeasnoun{ChSp:93}). The number of free parameters
is then reduced by one. Otherwise the default applies, \parf{IREV=[]}.

\subsection{\parf{IFIXED}}  \label{sec:IFIXED}
Labels of test functions that are held fixed. 
E.g., with \parf{IFIXED=[n]} one can compute a locus in
one extra parameter of a singularity defined by 
test function \parf{PSI(n)=0}. The default is \parf{IFIXED=[]}.

\subsection{\parf{IPSI}}  \label{sec:IPSI}
Labels of activated test functions for detecting homoclinic
bifurcations, see Section~\ref{sec:HomCont_Test_functions} 
for a list. If a test function is activated then the
corresponding parameter (\parf{IPSI(I)+20}) 
must be added to the list of continuation parameters \parf{ICP}
and zero of this parameter added to the list of user-defined
output points \parf{UZR,} in \filef{c.xxx}.
The default is \parf{IPSI=[]}.

\section{ Restrictions on {\cal HomCont} Constants.}
Note that certain combinations of these constants are not allowed
in the present implementation. In particular,
\begin{itemize}
\item[-] 
The computation of orientation \parf{ITWIST=1} is not
implemented for \parf{IEQUIB<0} (heteroclinic orbits), 
\parf{IEQUIB=2} (saddle-node homoclinics),
\parf{IREV$\ne$[]} (reversible systems), \parf{ISTART=3} (homotopy
method for starting), or if the equilibrium contains complex
eigenvalues in its linearization.  
\item[-] The homotopy method \parf{ISTART=3} is not fully implemented
for heteroclinic connections \parf{IEQUIB<0}, saddle-node homoclinic
orbits \parf{IEQUIB=2} or reversible systems \parf{IREV$\ne$[]}.
\item[-] Certain test functions are not valid for certain forms
of continuation 
(see Section~\ref{sec:HomCont_Test_functions} below); 
for example
\parf{PSI(13)} and \parf{PSI(14)} only make sense if 
\parf{ITWIST=1} and \parf{PSI(15)} and \parf{PSI(16)} only apply
to \parf{IEQUIB=2}.
\end{itemize}

\section{ Restrictions on the Use of \parf{PAR}.}
The parameters \parf{PAR(1)} -- \parf{PAR(9)} can be used freely by
the user. The other parameters are used as follows~:

\begin{itemize}

\item[-] \parf{PAR(11)}~: 
The value of \parf{PAR(11)} equals the length of the time interval over
which a homoclinic solution is computed. Also referred to as ``period''.
This must be specified in \funcf{ STPNT}.

\item[-] \parf{PAR(10)}~: 
If \parf{ITWIST=1} then \parf{PAR(10)} is used internally as a
dummy parameter so that the adjoint equation is well-posed.

\item[-] \parf{PAR(12)-PAR(20)}~:
These are used for specifying the 
equilibria and (if \parf{ISTART=3}) the artificial parameters of
the homotopy method (see Section~\ref{sec:Starting_strategies} below).

\item[-] \parf{PAR(21)-PAR(36)}~: 
These parameters are used for storing the test functions 
(see Section~\ref{sec:HomCont_Test_functions}).
\end{itemize}

The output is in an identical format to {\cal AUTO} except that
additional information at each computed point is written 
in \parf{fort.9}. This information comprises the eigenvalues of
the (left-hand) equilibrium, the values of each activated test
function and, if \parf{ITWIST=1}, 
whether the saddle homoclinic loop is orientable
or not.
Note that the statement about orientability is only meaningful if the
leading eigenvalues are not complex and the homoclinic solution is not
in a flip configuration, that is, none of the test functions 
$\psi_i$ for $i=11,12,13,14$ is zero (or close to zero), 
see Section~\ref{sec:HomCont_Test_functions}.
 Finally, the values of the \parf{IPSI} activated test functions are written. 

\section{ Test Functions.} \label{sec:HomCont_Test_functions}
Codimension-two homoclinic orbits are detected along branches of codim
1 homoclinics by locating zeroes of certain test functions
$\psi_i$. The test functions that are ``switched on'' during any
continuation are given by the choice of the labels $i$, and are
specified by the parameters \parf{IPSI)} in \filef{
c.xxx}.  Here \parf{IPSI=[IPSI(1),$\ldots$,IPSI(NPSI)]} gives the labels of
the test functions (numbers between 1 and 16). A zero of
each labeled test function defines a certain codimension-two 
homoclinic singularity, specified as follows.
The notation used for eigenvalues is the same as that in
\citeasnoun{ChKu:94} or \citeasnoun{ChKuSa:95}. 

\begin{itemize}
\item[-] $ i=1$: 
Resonant eigenvalues (neutral saddle); $\mu_1=-\lambda_1$.
\item[-] $ i=2$: 
Double real leading stable eigenvalues (saddle to saddle-focus
transition); $\mu_1=\mu_2$. 
\item[-] $ i=3$: 
Double real leading unstable eigenvalues (saddle to saddle-focus
transition);\\ 
$\lambda_1=\lambda_2$. 
\item[-] $ i=4$: 
Neutral saddle, saddle-focus or bi-focus (includes $ i=1$);
$\mbox{Re}(\mu_1)  =  - \mbox{Re}(\lambda_1)$. 
\item[-] $ i=5$: 
Neutrally-divergent saddle-focus (stable eigenvalues complex);\\
$\mbox{Re}(\lambda_1) = - \mbox{Re}(\mu_1) - \mbox{Re}(\mu_2)$.
\item[-] $ i=6$: 
Neutrally-divergent saddle-focus (unstable eigenvalues complex);\\
$\mbox{Re}(\mu_1) = - \mbox{Re}(\lambda_1) - \mbox{Re}(\lambda_2)$. 
\item[-] $ i=7$: 
Three leading eigenvalues (stable);
$\mbox{Re}(\lambda_1) = - \mbox{Re}(\mu_1) - \mbox{Re}(\mu_2)$. 
\item[-] $ i=8$: 
Three leading eigenvalues (unstable);
$\mbox{Re}(\mu_1) = - \mbox{Re}(\lambda_1) - \mbox{Re}(\lambda_2)$.
\item[-] $ i=9$: 
Local bifurcation (zero eigenvalue or Hopf): 
number of stable eigenvalues decreases; $\mbox{Re}(\mu_1)=0$.
\item[-] $ i=10$: 
Local bifurcation (zero eigenvalue or Hopf): 
number of unstable eigenvalues decreases; $\mbox{Re}(\lambda_1)=0$.
\item[-] $ i=11$: 
Orbit flip with respect to leading stable direction 
(e.g., 1D unstable manifold).
\item[-] $ i=12$: 
Orbit flip with respect to leading unstable direction, 
(e.g., 1D stable manifold).
\item[-] $ i=13$: 
Inclination flip with respect to stable manifold
(e.g., 1D unstable manifold).
\item[-] $ i=14$: 
Inclination flip with respect to unstable manifold
(e.g., 1D stable manifold).
\item[-] $ i=15$: 
Non-central homoclinic to saddle-node (in stable manifold).
\item[-] $ i=16$: 
Non-central homoclinic to saddle-node (in unstable manifold).
\end{itemize}

Expert users may wish to add their own test functions by editing 
the function \funcf{ PSIHO} in \filef{autlib5.f}.

{\it It is important to remember that, in order to specify activated 
test functions, it is required to also 
add the corresponding label $+20$ to the list of continuation
parameters and a zero of this parameter to the list of user-defined
output points. Having done this, the corresponding parameters
are output to the screen and zeros are accurately located.} 

\section{ Starting Strategies.} \label{sec:Starting_strategies}
There are four possible starting procedures for continuation. 

\begin{itemize}

\item[{\bf(i)}]
Data can be read from a previously-obtained output point from {\cal AUTO}
 (e.g., from continuation of a periodic orbit up to large period;
note that if the end-point of the data stored is not close to the
equilibrium, a phase shift must be performed by setting
\parf{ISTART=4}). These data can be read from fort.8 (saved to \filef{
s.xxx}) by making \parf{IRS} correspond to the label of the data
point in question.

\item[{\bf(ii)}]
Data from numerical integration (e.g.,\ computation of a stable
periodic orbit, or an approximate homoclinic obtained by shooting)  
can be read in from a data file using the \AUTO constant \parf{dat}
(see Section~\ref{sec:dat}). 
The  numerical data should be stored in
a file  \filef{xxx.dat}, in multi-column format according to the read statement
\begin{verbatim}
       READ(...,*) T(J),(U(I,J),I=1,NDIM)
\end{verbatim}
where $T$ runs in the interval \parf{[0,1]}.
When starting from this solution \parf{IRS} should be set to 0 and 
the value of \parf{ISTART} is irrelevant.

\item[{\bf(iii)}]
By setting \parf{ISTART=2},  
an explicit homoclinic solution can be specified in the routine \funcf{ STPNT} 
in the usual {\cal AUTO} format, that is 
$U=...(T)$ where $T$ is scaled to lie in the
interval $[0,1]$. 

\item[{\bf(iv)}]
The choice \parf{ISTART=3}, allows for
a homotopy method to be used to approach a homoclinic orbit
starting from a small approximation to a solution to the 
linear problem in the unstable manifold \cite{DoFrMo:93}. For
details of implementation, the reader is referred to 
Section~5.1.2.\ of \citeasnoun{ChKu:94}, under the simplification
that we do not solve for the adjoint $u(t)$ here. The basic idea
is to start with a small solution in the unstable manifold, and perform
continuation in \parf{PAR(11)=}$2T$ and dummy initial-condition 
parameters $\xi_i$ in order to satisfy the correct right-hand boundary
conditions, which are defined by zeros of other dummy parameters
$\omega_i$. More precisely, the left-hand end point is placed in the
tangent space to the unstable manifold of the saddle and is characterized by
\parf{NUNSTAB} coordinates $\xi_i$ satisfying the condition
$$
\xi_1^2 + \xi_2^2 + \ldots +\xi_\parf{NUNSTAB}^2  = \eps_0^2,
$$
where $\eps_0$ is a user-defined small number.
At the right-hand end point, \parf{NUNSTUB} values $\omega_i$ 
measure the deviation of this point from the tangent
space to the stable manifold of the saddle. 
\par
Suppose that \parf{IEQUIB=0,1} and set \parf{IP=12+IEQUIB*NDIM}. Then
\par
\medskip
\begin{center}
\begin{tabular}{ll}
\parf{PAR(IP)} & :$\ \ \eps_0$\\
\parf{PAR(IP+i)} &  :$\ \ \xi_\parf{i}$, \parf{i=1,2,...,NUNSTAB}\\
\parf{PAR(IP+NUNSTAB+i)} & :$\ \ \omega_\parf{i}$, \parf{i=1,2,...,NUNSTAB}
\end{tabular}
\end{center}
\par
\medskip
{\it Note that to avoid interference with the test functions 
(i.e. \parf{PAR(21)-PAR(36)}), one must have \parf{IP+2*NUNSTAB < 21}.} 
\par
If an $\omega_i$ is vanished, it can be frozen while another dummy or system parameter is allowed to
vary in order to make consequently all $\omega_i=0$. The resulting final solution
gives the initial homoclinic orbit provided the right-hand end point
is sufficiently close to the saddle. 
See Chapter~\ref{ch:HomCont_kpr} for an example, 
however, we recommend the homotopy method only for ``expert users''.
\end{itemize}

To compute the orientation of a homoclinic orbit (in order to detect
inclination-flip bifurcations) it is necessary to compute, in tandem,
a solution to the modified adjoint variational equation, by setting
\parf{ITWIST=1}. In order to obtain starting data for such a
computation when restarting from a point where just the homoclinic
is computed, upon increasing \parf{ITWIST} to 1, {\cal AUTO} generates
trivial data for the adjoint. Because the adjoint equations are
linear, only a single step of Newton's method is required to
enable these trivial data to converge to the correct unique bounded
solution. This can be achieved by making a single continuation step in a
trivial parameter (i.e. a parameter that does not appear
in the problem). 

Decreasing \parf{ITWIST} to 0 automatically deletes the data for the adjoint
from the continuation problem.


\section{ Notes on Running {\cal HomCont} Demos.} \label{sec:HomCont_Tutorial_examples}
{\cal HomCont} demos are given in the following chapters.
To copy all files of a demo \filef{xxx} (for example, \filef{san}),
move to a clean directory and type \commandf{demo('xxx')}.
Simply typing \commandf{auto xxx.auto} will then automatically
execute all runs of the demo.
%To automatically run a demo in ``step-by-step'' mode,
%type  \commandf{make first}, \commandf{make second}, etc.,
%to run each separate computation of the demo. 
At each step, the user is encouraged to plot the data
saved by using the command \commandf{plot} (e.g., \commandf{plot(r)}
plots the data saved in the \python variable \parf{r}).

Of course, in a real application, the runs will not have been prepared
in advance, and {\cal AUTO}-commands must be used.
Such commands can be found in a table at the end of each chapter.
A sequence of detailed \AUTO-commands will be given in these tables
as illustrated in Table~\ref{tbl:HomCont_demos_1}
and Table~\ref{tbl:HomCont_demos_2} for two representative runs of 
{\cal HomCont} demo \filef{san}.

The user is encouraged to copy the format of one of these demos
when constructing new examples.

The output of the {\cal HomCont} demos reproduced in  the following chapters
is somewhat machine dependent, as already noted 
in Section~\ref{sec:Tutorial_all_runs}.
In exceptional circumstances, {\cal AUTO} may reach its maximum number of
steps \parf{NMX} before a certain output point, or the label of
an output point may change. In such case the user may have
to make appropriate changes in the {\cal AUTO} constants-files.


\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | l |}
\hline
  COMMAND  & ACTION \\
\hline
%==============================================================================
  \commandf{san=load('san',IPS=9,NDIM=3,ISP=0,ILP=0,} &\\
  \commandf{  ITNW=7,JAC=1,NTST=35,IEQUIB=0,DS=0.05)}
  & set common \AUTO constants\\
  \commandf{r1=run(san,ICP=[1,8],UZR=\{-1:0.25\})} & run AUTO using the
  specified constants\\
  \commandf{save(r1,'6')}                & save output-files as \filef{b.6, s.6, d.6}  \\ 
\hline
%==============================================================================
  \commandf{@R san 1}           & use the constants file \filef{c.san.1}   \\ 
  \commandf{@sv 6}              &    \\ 
\hline
%==============================================================================
\end{tabular}
\caption{ These two sets of {\cal AUTO}-Commands are equivalent.}
\label{tbl:HomCont_demos_1}
\end{center}
\end{table}

\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | l |}
\hline
  COMMAND  & ACTION \\
\hline
%==============================================================================
  \commandf{r9=run(r8,ICP=[2,8],UZR=\{-2:3.0\})} & \parbox[t]{3in}{get
    the \AUTO constants-file and run \AUTO/{\cal HomCont}; restart
    from the last label in \parf{r8}\vspace{0.2cm}}\\
  \commandf{r6=r6+r9}                        & append output to the
  \python variable \parf{r6}  \\ 
  \commandf{save(r6,'6')}                    & save output to the
  files \filef{b.6, s.6, d.6}  \\ 
\hline
%==============================================================================
  \commandf{@R san 9 6}         & use the constants file
  \filef{c.san.9}, start from the file \filef{s.6}  \\ 
  \commandf{@ap 6}              & append output to the
   files \filef{b.6, s.6, d.6}  \\ 
\hline
%==============================================================================
\end{tabular}
\caption{ These two sets of {\cal AUTO}-Commands behave similarly.}
\label{tbl:HomCont_demos_2}
\end{center}
\end{table}



%==============================================================================
%==============================================================================
\chapter{ {\cal HomCont} Demo : san.} \label{ch:HomCont_san}
%==============================================================================
%==============================================================================

%==============================================================================
%DEMO=san======================================================================
%==============================================================================
\section{ Sandstede's Model.}
\newcommand{\ti}{\tilde}
Consider the system \cite{Sa:95b}
\begin{equation} \label{bs1} \begin{array}{rcl}
\dot{x} & = & a \, x + b \, y - a \, x^2 + (\ti \mu - \alpha \, z) \, x
\, (2-3x) \\
\dot{y} & = & b \, x + a \, y - \frac{3}{2} \, b \, x^2 - 
\frac{3}{2} \, a \, x \, y - (\ti \mu - \alpha \, z) \, 2 \, y \\
\dot{z} & = & c \, z + \mu \, x + \gamma\, x\, y + \alpha \, 
\beta \, (x^2 \, (1-x) - y^2)

\end{array} \end{equation}
as given in the file \filef{san.f90}.
Choosing the constants appearing
in (\ref{bs1}) appropriately allows for computing inclination and
orbit flips as well as non-orientable resonant bifurcations, see
\cite{Sa:95b} for details and proofs. The starting point for all
calculations is $a=0$, $b=1$ where there exists an explicit solution
given by  
$$ 
(x(t),y(t),z(t)) = 
\left( 1 - \left(\frac{1-e^t}{1+e^t}\right)^2 , 4 \, e^t \,
\frac{1-e^t}{(1+e^t)^3} , 0 \right). 
$$
This solution is specified in the routine \funcf{ STPNT}.

\section{Inclination Flip.}
We start by copying the demo to the current work directory 
and running the first step
\begin{center}
\commandf{demo('san')}\\
\commandf{san=load('san',IPS=9,NDIM=3,ISP=0,ILP=0,ITNW=7,JAC=1,NTST=35,IEQUIB=0,DS=0.05)}
\commandf{r1=run(san,ICP=[1,8],UZR=\{-1:0.25\})}
\end{center}
This computation starts from the analytic solution above with 
$a=0$, $b=1$, $c=-2$, $\alpha=0$, $\beta=1$ and 
$\gamma = \mu=\ti \mu =0$. The homoclinic solution is followed in the
parameters $(a,\ti \mu)$ \parf{=(PAR(1), PAR(8))} up to $a=0.25$. 
The output is summarised on the screen as
\begin{verbatim}
  BR    PT  TY  LAB    PAR(1)        L2-NORM            PAR(8)     
   1     1  EP    1   0.00000E+00   4.00000E-01 ...  0.00000E+00
   1     5  UZ    2   2.50000E-01   4.03054E-01 ... -1.85981E-11
\end{verbatim}
and saved in more detail in the \python variable \parf{r1}.

Next we want to add a solution to the adjoint equation to the
solution obtained at $a=0.25$. This is
achieved by starting from the last label, and making the changes
\parf{ITWIST = 1}, \parf{NMX = 2} and \parf{ICP(1) = 9}. We also disable any
user-defined functions \parf{UZR=\{\}}. The computation so-defined 
is a single step in a trivial parameter \parf{PAR(9)} (namely a parameter
that does not appear in the problem). The effect is to perform a Newton
step to enable \AUTO to converge to a solution of the adjoint equation.
\begin{center}
\commandf{r2=run(r1,ICP=[9,8],ITWIST=1,NMX=2,UZR=\{\})}
\end{center} 
The output is stored in the \python variable \parf{r2}.

We can now continue the homoclinic plus
adjoint in $(\alpha,\ti \mu)$ \parf{=(PAR(4), PAR(8))} by
changing the constants to read
\parf{NMX = 50} and \parf{ICP(1) = 4}.
We also add \parf{PAR(10)} to the list of continuation parameters
\parf{ICP}. Here \parf{PAR(10)} is a dummy parameter used in
order to make the continuation of the adjoint well posed. Theoretically,
it should be zero if the computation of the adjoint is successful
\cite{Sa:95b}.
The test functions for detecting resonant bifurcations 
(\parf{ISPI(1)=1}) and inclination flips (\parf{ISPI(1)=13}) are
also activated. Recall that this should be specified in
three ways. First we add \parf{PAR(21)} and \parf{PAR(33)}
to the list of continuation parameters, second we set up user defined
output at zeros of these parameters, and finally we set \parf{IPSI=[1,13]}
We also add another user zero for detecting when \parf{PAR(4)=1.0}.
Running 
\begin{center}
\commandf{r3=run(r2,ICP=[4,8,10,21,33],IPSI=[1,13],NMX=50,NPR=20,UZR=\{4:1.0,21:0,33:0\})}\\
\commandf{save(r3,'r3')}
\end{center}
starts from the last, and in this case, only, labelled solution in \parf{r2}
and outputs to the screen
\begin{verbatim}
 BR  PT  TY LAB    PAR(4)     ...    PAR(8)       PAR(10)   ...    PAR(33)    
  1  20       4  7.84722E-01  ... -2.72146E-11 -4.21812E-09 ...  1.44112E+01
  1  27  UZ   5  1.00000E+00  ... -3.91152E-11 -4.38659E-09 ...  5.70167E+00
  1  35  UZ   6  1.23086E+00  ... -6.18304E-11 -4.62672E-09 ... -9.48584E-06
  1  40       7  1.38397E+00  ... -8.41993E-11 -4.63701E-09 ... -1.34882E+00
  1  50  EP   8  1.69521E+00  ... -1.36449E-10 -5.35972E-09 ... -5.31105E-01
\end{verbatim}
Full output is stored in \filef{b.3}, \filef{s.3} and \filef{d.3}. 
\begin{figure}[b]
\epsfysize 9.0cm
\centerline{\epsffile{include/san1}}
\caption{Second versus third component of the solution to the adjoint
equation at labels 4, 6 and 8}
\label{Ftest1}
\end{figure}
Note that the artificial parameter $\epsilon=$\parf{PAR(10)} is zero within
the allowed tolerance. At label \parf{6}, a zero of test function $\psi_{13}$ has
been detected which corresponds to an inclination flip with respect to
the stable manifold. That the orientation of the homoclinic loop
changes as the family passes through this point can be read from
the information in \filef{d.3}.
However in \filef{d.3}, the line 
\begin{verbatim} 
ORIENTABLE (    0.2982090775E-03)
\end{verbatim}
at \parf{PT=35} would seems to contradict the 
detection of the inclination flip at this point. Nonetheless, the
important fact is the zero of the test function; and note that 
the value of the variable indicating the orientation is 
small compared to its value at the other regular points. 
Data for the adjoint equation at \parf{LAB= 4, 6} and \parf{8} at
and on either side of the inclination flip are presented in 
Fig.\ \ref{Ftest1}. The switching of the solution between components
of the leading unstable left eigenvector is apparent.
Finally, we remark that the Newton step in the dummy 
parameter \parf{PAR(20)} performed above is crucial
to obtain convergence. Indeed, if instead we try to continue the
homoclinic orbit and the solution of the adjoint equation directly by
setting
\begin{verbatim}
  ITWIST = 1   IRS = 2   NMX = 50   ICP(1) = 4
\end{verbatim}
and running
\begin{center}
\commandf{r4=run(r1,ICP=[4,8,10,21,33],ITWIST=1,IPSI=[1,13],NMX=50,UZR=\{33:0\})}
\end{center}
we obtain a no convergence error.

\section{Non-orientable Resonant Eigenvalues.}
Inspecting the output saved in the third run,
we observe the existence of a non-orientable homoclinic orbit at the
second \parf{UZ} label 
\parf{6}. We restart at this label, with
the first continuation parameter being once again $a=$\parf{PAR(1)}, 
by changing constants according to 
\begin{verbatim}
   DS = -0.05    NMX = 20    ICP(1) = 1
\end{verbatim}
Running, 
 \begin{center}
\commandf{r5=run(r3('UZ2'),ICP=[1,8,10,21,33],NMX=20,DS='-',sv='5')}\\
\end{center}
the output at label \parf{9}
\begin{verbatim}
  BR    PT  TY LAB     PAR(1)           PAR(8)        PAR(10)       PAR(21)       
   1     8  UZ   9  -1.30447E-07 ...  3.41490E-12  -1.63406E-09  -2.60894E-07
\end{verbatim}
indicates that \AUTO has detected a zero of
\parf{PAR(21)}, implying that a non-orientable resonant bifurcation
occurred at that point.

\section{Orbit Flip.}
In this section we compute an orbit flip. To this end we restart
from the original explicit solution, without computing the orientation. We 
begin by separately performing continuation in $(\alpha,\ti \mu)$, 
$(\beta,\ti \mu)$, $(a,\ti \mu)$, $(b,\ti \mu)$ and $(\mu, \ti \mu)$
in order to reach the parameter values 
$(a,b,\alpha,\beta, \mu)=(0.5,3,1,0,0.25)$.
The sequence of continuations up to the desired parameter values 
are run via
\begin{center}
\commandf{r6=run(san,ICP=[4,8],UZR=\{-4:1\})\\
r7=run(r6,ICP=[5,8],UZR=\{-5:0\},DS='-')\\
r8=run(r7,ICP=[1,8],UZR=\{-1:0.5\},DS='-')\\
r9=run(r8,ICP=[2,8],UZR=\{-2:3.0\})\\ 
r10=run(r9,ICP=[7,8],UZR=\{-7:0.25\})\\}
\end{center}
with appropriate continuation parameters and user output values
set. The desired output is stored in \parf{r10}.

The final saved point \parf{LAB=6} contains a homoclinic solution at
the desired parameter values. From here we perform continuation in
the negative direction of $(\mu,\ti \mu)=$ (\parf{PAR(7),PAR(8)}) with
the test function $\psi_{11}$ for orbit flips with respect to the
stable manifold activated.
\begin{center}
\commandf{r11=run(r10,ICP=[7,8,31],IPSI=[11],UZR=\{31:0.0,-7:-0.5\},DS='-')\\
save(r11,'11')}
\end{center}
The output detects an inclination flip (by a zero of \parf{PAR(31)}) 
at \parf{PAR(7)=0} 
\begin{verbatim}
  BR    PT  TY LAB    PAR(7)      ...    PAR(8)        PAR(31)    
   1     5  UZ   7  6.33545E-06   ...  1.70968E-06  -8.70508E-05
\end{verbatim}
at which parameter value the homoclinic orbit is contained in the $(x,y)$-plane
(see Fig.\ \ref{Ftest2}).

\begin{figure}[t]
\epsfysize 9.0cm
\centerline{\epsffile{include/san2}}
\caption{Orbits on either side of the orbit flip bifurcation. The critical
orbit is contained in the $(x,y)$-plane}
\label{Ftest2}
\end{figure}

Finally, we demonstrate that the orbit flip can be continued as 
three parameters (\parf{PAR(6), PAR(7), PAR(8)}) are varied. 
\begin{center}
\commandf{of = r11('UZ1')\\
r12=run(of,ICP=[7,8,6],IPSI=[],NPR=5,NMX=20,IFIXED=[11],UZR=\{\},DS='-')
save(r12,'12')}
\end{center}
\begin{verbatim}
 BR    PT  TY LAB    PAR(7)       ...    PAR(8)        PAR(6)     
  1     5       9  -7.38787E-19   ...  -2.91178E-10  -3.25000E-01
  1    10      10  -5.27166E-19   ...  -2.23972E-10  -8.25000E-01
  1    15      11  -6.15227E-19   ...  -2.91908E-10  -1.32500E+00
  1    20  EP  12  -5.96426E-19   ...  -3.20088E-10  -1.82500E+00
\end{verbatim}
The orbit flip continues to be defined by a planar homoclinic orbit
at \parf{PAR(7)=PAR(8)=0}.

\section{ Detailed \AUTO-Commands.}

\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | l |}
\hline
  \AUTO-COMMAND  & ACTION \\
\hline
%==============================================================================
  \commandf{mkdir san} & create an empty work directory \\ 
  \commandf{cd san} & change directory \\
  \commandf{demo('san')} & copy the demo files to the work directory\\
  \commandf{san=load('san',IPS=9,NDIM=3,ISP=0,ILP=0,} & \\
  \commandf{  ITNW=7,JAC=1,NTST=35,IEQUIB=0,DS=0.05)} & configure
    common constants\\
\hline
%==============================================================================
  \commandf{r1=run(san,ICP=[1,8],UZR=\{-1:0.25\})}& continuation in \parf{PAR(1)} \\ 
\hline
%==============================================================================
  \commandf{r2=run(r1,ICP=[9,8],ITWIST=1,NMX=2,UZR=\{\})} & generate adjoint variables \\ 
\hline
%=============================================================================
  \commandf{r3=run(r2,ICP=[4,8,10,21,33],IPSI=[1,13],} & \\
  \commandf{  NMX=50,NPR=20,UZR=\{4:1.0,21:0,33:0\}) } & continue homoclinic orbit and adjoint\\ 
  \commandf{save(r3,'3') } & save output-files as \filef{b.3, s.3, d.3} \\ 
\hline
%==============================================================================
  \commandf{r4=run(r1,ICP=[4,8,10,21,33],ITWIST=1,} & \\
  \commandf{  IPSI=[1,13],NMX=50,UZR=\{33:0\}) } & no convergence without dummy step \\ 
  \commandf{sv('4') } &  save output-files as \filef{b.4, s.4, d.4} \\ 
\hline
%=============================================================================
  \commandf{r5=run(r3('UZ2'),ICP=[1,8,10,21,33],NMX=20,} & continue non-orientable orbit\\
  \commandf{  DS='-',sv='5') }& save output-files as \filef{b.5, s.5, d.5} \\ 
\hline
%==============================================================================
\end{tabular}
\caption{Detailed \AUTO-Commands for running demo \filef{san}.}
\label{tbl:demo_san_1}
\end{center}
\end{table}


\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | l |}
\hline
  \AUTO-COMMAND  & ACTION \\
\hline
%==============================================================================
  \commandf{r6=run(san,ICP=[4,8],UZR=\{-4:1\})} & restart and homotopy to \parf{PAR(4)}=1.0 \\ 
\hline
%==============================================================================
  \commandf{r7=run(r6,ICP=[5,8],UZR=\{-5:0\},DS='-')} & homotopy
  to \parf{PAR(5)}=0.0 \\ 
\hline
%==============================================================================
  \commandf{r8=run(r7,ICP=[1,8],UZR=\{-1:0.5\},DS='-')} & homotopy to \parf{PAR(1)}=0.5 \\ 
\hline
  \commandf{r9=run(r8,ICP=[2,8],UZR=\{-2:3.0\})} & homotopy to \parf{PAR(2)}=3.0\\ 
\hline
%==============================================================================
  \commandf{r10=run(r9,ICP=[7,8],UZR=\{-7:0.25\})} & homotopy to \parf{PAR(7)}=0.25\\ 
\hline
%==============================================================================
  \commandf{r11=run(r10,ICP=[7,8,31],IPSI=[11],} & \\
  \commandf{  UZR=\{31:0.0,-7:-0.5\},DS='-')} & continue in \parf{PAR(7)} to detect orbit flip \\ 
  \commandf{save(r11,'11') } & save output-files as \filef{b.11, s.11, d.11} \\ 
\hline
%==============================================================================
  \commandf{of=r11('UZ1')} & select first UZ-labelled point
  of \parf{r11} to start from\\
  \commandf{r12=run(of,ICP=[7,8,6],IPSI=[],NPR=5,} & \\
  \commandf{  NMX=20,IFIXED=[11],UZR=\{\},DS='-') } & three-parameter continuation of orbit flip \\ 
  \commandf{save(r12,'12') } & save output-files as \filef{b.12, s.12, d.12} \\ 
\hline
%==============================================================================
\end{tabular}
\caption{Detailed \AUTO-Commands for running demo \filef{san}.}
\label{tbl:demo_san_2}
\end{center}
\end{table}




%==============================================================================
%==============================================================================
\chapter{ {\cal HomCont} Demo : mtn.} \label{ch:HomCont_mtn}
%==============================================================================
%==============================================================================

%==============================================================================
%DEMO=mtn======================================================================
%==============================================================================
\section{ A Predator-Prey Model with Immigration.}
Consider the following system of two equations \cite{Sc:95}
\begin{equation} \label{sn.1} \begin{array}{rcl}
\dot{X} & = & RX\left(1-{\ds \frac{X}{K}}\right) - 
{\ds \frac{A_1XY}{B_1+X}} + D_0K \\
\dot{Y} & = & E_1 {\ds \frac{A_1XY}{B_1+X}} - D_1Y - 
{\ds\frac{A_2ZY^2}{B_2^2+Y^2}}.
\end{array} \end{equation}
\begin{figure}[b]
\epsfysize 10.0cm
\centerline{\epsffile{include/mtn1}}
\caption{Parametric portrait of the predator-prey system }
\label{SNF.1}
\end{figure}
The values of all parameters except $(K,Z)$ are set as follows~:
$$
R=0.5,\ A_1=0.4,\ B_1=0.6,\ D_0=0.01,\ E_1=0.6,\ A_2=1.0,\ B_2=0.5,\ D_1=0.15.
$$
\par
\noindent
The parametric portrait of the system (\ref{sn.1}) on the
$(Z,K)$-plane is presented in Figure \ref{SNF.1}. It contains fold
($t_{1,2}$) and Hopf ($H$) bifurcation curves, as well as a homoclinic
bifurcation curve $P$. The fold curves meet at a cusp singular point
$C$, while the Hopf and the homoclinic curves originate at a
Bogdanov-Takens point $BT$. Only the homoclinic curve $P$ will be 
considered here, the other bifurcation curves can be computed using
\AUTO or,
for example, {\cal locbif} \cite{KhKuLeNi:93}.

\section{Continuation of Central Saddle-Node Homoclinics.}
Local bifurcation analysis shows that at $K=6.0,\ Z=0.06729762\ldots$,
the system has a saddle-node equilibrium 
$$
(X^0,Y^0) = (5.738626\ldots,0.5108401\ldots),
$$
with one zero and one negative eigenvalue. Direct simulations reveal a
homoclinic 
orbit to this saddle-node, departing and returning along its central
direction (i.e., tangent to the null-vector).
\par
Starting from this solution, stored in the file \filef{mtn.dat}, we
continue the saddle-node central homoclinic orbit 
with respect to the parameters $K$ and $Z$ by copying the
demo and running it
\begin{center}
\commandf{dm('mtn')}\\
\commandf{r1=run('mtn',c='mtn.1',sv='1')}
\end{center}
The file \filef{mtn.f90} contains approximate
parameter values
$$
K=\parf{PAR(1)}=6.0,\ Z=\parf{PAR(2)}=0.06729762,
$$
as well as the coordinates of the saddle-node
$$
X^0=\parf{PAR(12)}=5.738626,\ Y^0=\parf{PAR(13)}=0.5108401,
$$
and the length of the truncated time-interval
$$
T_0=\parf{PAR(11)} = 1046.178 \: .
$$
Since a homoclinic orbit to a saddle-node is being followed, we have also
made the choice
$$
\parf{IEQUIB = 2}
$$
in \filef{c.mtn.1}. The two test-functions, $\psi_{15}$ and $\psi_{16}$, 
to detect non-central saddle-node homoclinic
orbits are also activated, which must be specified in three ways. 
Firstly, in \filef{c.mtn.1}, \parf{IPSI} is
set to \parf{[15,16]} so the active test functions
are chosen as 15 and 16. This sets up the monitoring of these
test functions. Secondly, in \filef{c.mtn.1} user-defined functions
(\parf{UZR}) are set up to look for zeros of the parameters
corresponding to these test functions. Recall that the
parameters to be zeroed are always the test functions plus 20.
Finally, these parameters are included in the list of continuation
parameters (\parf{ICP}).

Among the output there is a line 
\begin{verbatim}
  BR    PT  TY  LAB    PAR(1)     ...    PAR(2)        PAR(35)       PAR(36)
   1    26  UZ    4   6.61046E+00 ...   6.93248E-02   5.23950E-09  -6.42344E-02
\end{verbatim}
indicating that a zero of the test function \parf{IPSI(1)=15} 
This means that at
$$
D_1=(K^1,Z^1)=(6.6105\ldots, 0.069325\ldots)
$$
the homoclinic orbit to the saddle-node becomes {\it non-central}, namely,
it returns to the equilibrium along the stable eigenvector, forming a
non-smooth loop. The output is saved in \filef{b.1}, \filef{s.1} and
\filef{d.1}. 
Repeating computations in the opposite direction along the curve, 
\parf{IRS=1, DS=-0.01} in \filef{c.mtn.2}, 
\begin{center}
\commandf{r1=r1+run(r1(1),c='mtn.2',ap='1')}
\end{center}
one obtains 
\begin{verbatim}
  BR    PT  TY  LAB    PAR(1)     ...    PAR(2)        PAR(35)       PAR(36)
   1    34  UZ   10   5.18039E+00 ...   6.38554E-02   8.86654E-10  -7.28132E-02
\end{verbatim}
which means another non-central saddle-node homoclinic bifurcation occurs
at
$$
D_2=(K^2,Z^2)=(5.1803\ldots,0.063855\ldots).
$$
Note that these data were obtained using a smaller value of \parf{NTST} than
the original computation (compare \filef{c.mtn.1} with \filef{c.mtn.2}). The
high original value of \parf{NTST} was only necessary for the first few steps
because the original solution is specified on a uniform mesh. 

\section{Switching between Saddle-Node and Saddle Homoclinic Orbits.}
Now we can switch to continuation of saddle homoclinic orbits at the
located codim 2 points $D_1$ and $D_2$. 
\begin{center}
\commandf{r1=r1+run(r1('UZ1'),c='mtn.3',ap='1')}
\end{center}
starts from $D_1$. Note that now 
\begin{center}
\parf{IEQUIB = 1}  
\end{center}
has been specified in \filef{c.mtn.3}. Also, test functions $\psi_9$
and $\psi_{10}$ have been activated in order
to monitor for non-hyperbolic equilibria along the homoclinic locus. 
We get the following output
\begin{verbatim}
  BR    PT  TY  LAB    PAR(1)     ...    PAR(2)        PAR(29)       PAR(30)    
   1    10       12   7.11454E+00 ...   7.08176E-02  -4.64986E-01   3.18355E-03
   1    20       13   9.17683E+00 ...   7.67874E-02  -4.68491E-01   1.60931E-02
   1    30       14   1.21084E+01 ...   8.54348E-02  -4.71887E-01   3.06966E-02
   1    40  EP   15   1.50379E+01 ...   9.42805E-02  -4.74379E-01   4.14457E-02
\end{verbatim}
The fact that \parf{PAR(29)} and \parf{PAR(30)} do not change sign indicates 
that there are no further non-hyperbolic equilibria
along this family. Note that restarting in the opposite direction with
\parf{IRS=15,DS=-0.02} 
\begin{center}
\commandf{r4=run(r1,c='mtn.4',sv='4')}
\end{center}
will detect the same codim 2 point $D_1$ but now as a zero
of the test-function $\psi_{10}$
\begin{verbatim}
  BR    PT  TY  LAB    PAR(1)     ...    PAR(2)        PAR(29)       PAR(30)
   1    38  UZ   11   6.61046E+00 ...   6.93248E-02  -4.63660E-01   3.13439E-08
\end{verbatim}
Note that the values of \parf{PAR(1)} and \parf{PAR(2)} are equal to those
at label \parf{4} up to at least six significant figures.

Actually, the program runs further and
eventually computes the point $D_2$ and the whole lower family of $P$
emanating from it, however, the solutions between $D_1$ and $D_2$
should be considered as spurious\footnote{\label{ft1} The program actually
computes the saddle-saddle heteroclinic orbit bifurcating from the
non-central saddle-node homoclinic at the point $D_1$, see
\citeasnoun[Fig. 2]{ChKuSa:95}, and continues it to the one emanating from
$D_2$.}, therefore we do not save these data.
The reliable way to compute the lower family of $P$ is to restart computation
of saddle homoclinic orbits in the other direction from the point $D_2$
\begin{center}
\commandf{r1=r1+run(r1('UZ3'),c='mtn.5',ap='1')}
\end{center}
This gives the lower family of $P$ approaching the BT point
(see Figure \ref{SNF.1})
\begin{verbatim}
  BR    PT  TY  LAB    PAR(1)     ...   PAR(2)        PAR(29)       PAR(30)
   1    10       16   4.96649E+00 ...  6.29843E-02  -4.38247E-01   4.94481E-03
   1    20       17   4.92531E+00 ...  7.96087E-02  -3.39922E-01   3.28829E-02
   1    30       18   7.09217E+00 ...  1.58708E-01  -1.69289E-01   3.87631E-02
   1    40  EP   19   1.10181E+01 ...  2.80980E-01  -3.48294E-02   2.10449E-02
\end{verbatim}
The data are appended to the stored results in \filef{b.1}, \filef{s.1} and
\filef{d.1}. One could now display all data using the \AUTO
command \commandf{@pp 1} to reproduce the curve $P$ shown in Figure
\ref{SNF.1}.
\par
%------------------------------------------------------
\begin{figure}[p]
\epsfysize 10.0cm
\centerline{\epsffile{include/mtn2}}
\caption{Approximation by a large-period cycle}
\label{SNF.2}
\end{figure}
%------------------------------------------------------
%------------------------------------------------------
\begin{figure}[p]
\epsfysize 9.0cm
\centerline{\epsffile{include/mtn3}}
\caption{Projection onto the ($K,D_0$)-plane of the 
three-parameter curve of non-central  saddle-node homoclinic orbit}
\label{SNF.3}
\end{figure}
%------------------------------------------------------
%
It is worthwhile to compare the homoclinic curves computed above with
a curve $T_0=const$ along which the system has a limit cycle of constant large
period $T_0=1046.178$, which can easily be computed using \AUTO or
{\cal locbif}. Such a curve is plotted in Figure \ref{SNF.2}. 
It obviously approximates well the saddle homoclinic loci of $P$, but 
demonstrates much bigger
deviation from the saddle-node homoclinic segment $D_1D_2$. This happens
because the period of the limit cycle grows to infinity while approaching both
types of homoclinic orbit, but with {\it different asymptotics}: 
as $-\ln\|\alpha-\alpha^*\|$, in the saddle homoclinic case, and 
as $\|\alpha-\alpha^*\|^{-1}$ in the saddle-node case. 

\section{Three-Parameter Continuation.}
Finally, we can follow the curve of non-central saddle-node homoclinic
orbits in three parameters. The extra continuation parameter is
$D_0$=\parf{PAR(3)}.  To achieve this we restart at label \parf{4},
corresponding to the codim 2 point $D_1$. We return to continuation of
saddle-node homoclinics, \parf{NUNSTAB=0},\parf{IEQUIB=2}, but append the
defining equation $\psi_{15}=0$ to the continuation problem
(via \parf{IFIXED=[15]}). The new
continuation problem is specified in \filef{c.mtn.6}.
\begin{center}
\commandf{r6=run(r1('UZ1'),c='mtn.6',sv='6')}
\end{center}
Notice that we set \parf{ILP=1} and choose \parf{PAR(3)} as the first 
continuation parameter so that \AUTO can detect limit points 
with respect to this parameter. We also make a user-defined function
(\parf{UZR})
to detect intersections with the plane $D_0=0.01$.
We get among other output
\begin{verbatim}
  BR    PT  TY  LAB    PAR(3)        L2-NORM    ...    PAR(1)        PAR(2)
   1    22  LP   20   1.08120E-02   5.32589E+00 ...   5.67363E+00   6.60818E-02
   1    31  UZ   21   1.00000E-02   4.81969E+00 ...   5.18032E+00   6.38551E-02
\end{verbatim}
the first line of which represents the $D_0$ value at which 
the homoclinic curve $P$ has a tangency with the family $t_2$ 
of fold bifurcations. Beyond this value of $D_0$,
$P$ consists entirely of saddle homoclinic orbits. The data at label \parf{20} 
reproduce the coordinates of the point $D_2$. The results of this
computation and a similar one starting from $D_1$ in the opposite direction
(with \parf{DS=-0.01}) are displayed in Figure \ref{SNF.3}.
%

\section{ Detailed \AUTO-Commands.}
\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | l |}
\hline
  \AUTO-COMMAND  & ACTION \\
\hline
%==============================================================================
  \commandf{mkdir mtn} & create an empty work directory \\ 
  \commandf{cd mtn} & change directory \\
  \commandf{demo('mtn')} & copy the demo files to the work directory \\
\hline
%==============================================================================
  \commandf{r1=run('mtn',c='mtn.1',sv='1')} &  continue saddle-node
  homoclinic orbit from \filef{mnt.dat}\\
  & save output-files as \filef{b.1, s.1, d.1} \\ 
\hline
%==============================================================================
  \commandf{r1=r1+run(r1(1),c='mtn.2',ap='1')} & continue in opposite
  direction; restart from label 1 \\ 
  & append output-files to \filef{b.1, s.1, d.1} \\ 
\hline
%=============================================================================
  \commandf{r1=r1+run(r1('UZ1'),c='mtn.3',ap='1')} & switch to saddle
  homoclinic orbit  ; restart: 1st \parf{UZ} \\ 
  & append output-files to \filef{b.1, s.1, d.1} \\ 
\hline
%==============================================================================
  \commandf{r4=run(r1,c='mtn.4',sv='4')} & continue in reverse
  direction; restart from last label \\ 
  & save output-files as \filef{b.4, s.4, d.4} \\ 
\hline
%=============================================================================
  \commandf{r1=r1+run(r1('UZ3'),c='mtn.5',ap='1')} & other saddle
  homoclinic orbit family; restart: 3rd \parf{UZ} \\
  & append output-files to \filef{b., s.1, d.1} \\ 
\hline
%==============================================================================
  \commandf{r6=run(r1('UZ1'),c='mtn.6',sv='6')} & 3-parameter non-central saddle-node homoclinic. \\ 
  & save output-files as \filef{b.6, s.6, d.6} \\ 
\hline
%==============================================================================
\end{tabular}
\caption{Detailed \AUTO-Commands for running demo \filef{mtn}.}
\label{tbl:demo_mtn_1}
\end{center}
\end{table}



%==============================================================================
%==============================================================================
\chapter{ {\cal HomCont} Demo : kpr.} \label{ch:HomCont_kpr}
%==============================================================================
%==============================================================================

%==============================================================================
%DEMO=kpr======================================================================
%==============================================================================
\section{ Koper's Extended Van der Pol Model.}
%
The equation-file \filef{kpr.f90} contains the equations
\begin{equation} \label{ko} \begin{array}{rcl}
\dot{x} & = & \eps_1^{-1}\:(k\: y - x^3 +3\:x - \lambda) \\
\dot{y} & = & x - 2\: y + z \\
\dot{z} & = & \eps_2(y-z), 
\end{array} \end{equation}
with $\eps_1 =0.1$ and $\eps_2=1$ \cite{Ko:95}.

To copy across the demo \filef{kpr} and compile we type
\begin{center}
\commandf{demo('kpr')} \\
\end{center}

\section{The Primary Branch of Homoclinics.}
First, we locate a homoclinic orbit using 
the homotopy method. The file \filef{kpr.f90} 
already contains 
approximate parameter values for a homoclinic orbit, 
namely $\lambda=$\parf{PAR(1)=-1.851185}, $k=$\parf{PAR(2)=-0.15}. 
The file \filef{c.kpr.1} specifies the appropriate
constants for continuation in $2T$\parf{=PAR(11)} (also referred
to as \parf{PERIOD}) and the dummy parameter $\omega_1$=\parf{PAR(17)}
starting
from a small solution in the local unstable manifold; 
\begin{center}
\commandf{r1=run('kpr',c='kpr.1',sv='1')}
\end{center}
Among the output there is the line
\begin{verbatim}
     BR    PT  TY LAB    PERIOD        L2-NORM     ...    PAR(17)    ...
      1    29  UZ   2  1.90018E+01   1.69382E+00   ...  4.46147E-09  ...
\end{verbatim}
which indicates that a zero of the artificial parameter $\omega_1$
has been located. This means that the right-hand end point of the solution
belongs to the plane that is tangent to the stable manifold at the saddle. 
The output is stored in files \filef{b.1, s.1, d.1}. 
Upon plotting the data at label \parf{2} (see Figure \ref{kf.1a})
it can be noted that although the right-hand projection boundary
condition is satisfied, the solution is still quite away from the
equilibrium. 

The right-hand endpoint can be made to approach the
equilibrium by performing a further continuation in $T$ with the
right-hand projection condition satisfied (\parf{PAR(17)} fixed) but
with $\lambda$ allowed to vary. 
%
\begin{figure}[p]
\epsfysize 9.0cm
\centerline{\epsffile{include/kpr1}}
\caption{Projection on the $(x,y)$-plane of solutions 
of the boundary value 
problem with $2T=19.08778$.}
\label{kf.1a}
\end{figure}
\begin{figure}[p]
\epsfysize 9.0cm
\centerline{\epsffile{include/kpr2}}
\caption{Projection on the $(x,y)$-plane of solutions of the 
boundary value problem with $2T = 60.0$.}
\label{kf.1b}
\end{figure}
%
\begin{center}
\commandf{r2=run(r1('UZ1'),c='kpr.2',sv='2')}
\end{center}
the output at label \parf{4}, stored in \filef{s.2},
\begin{verbatim}
   BR   PT TY  LAB    PERIOD       L2-NORM     ...    PAR(1)     ...
    1   35 UZ    4   6.00000E+01  1.67281E+00  ...  -1.85119E+00 ...
\end{verbatim}
provides a good approximation to a homoclinic solution (see Figure
\ref{kf.1b}). 

The second stage to obtain a starting solution 
is to add a solution to the modified adjoint
variational equation. This is achieved by setting both 
\parf{ITWIST} and \parf{ISTART} to 1 (in \filef{c.kpr.3}), which generates
a trivial guess for the adjoint equations. Because the adjoint
equations are linear, only a single
Newton step (by continuation in a trivial parameter) 
is required to provide a solution.
Rather than choose a parameter that might be used internally
by \AUTO, in \filef{c.kpr.3} we take the continuation parameter
to be \parf{PAR(11)}, which is not quite a trivial parameter
but whose affect upon the solution is mild.
\begin{center}
\commandf{r3=run(r2('UZ1'),c='kpr.3',sv='3')}
\end{center}
The output at the second point (label \parf{6}) 
contains the converged homoclinic
solution (variables (\parf{U(1), U(2), U(3)}) and the adjoint (\parf{
U(4), U(5), U(6)})). We now have a starting solution 
and are ready to perform two-parameter continuation.

The fourth run
\begin{center}
\commandf{r3=r3+run(r3,c='kpr.4',ap='3')}
\end{center}
continues the homoclinic orbit in \parf{PAR(1)} and \parf{PAR(2)}. 
%
%------------------------------------------------------
\begin{figure}[p]
\epsfysize 9.0cm
\centerline{\epsffile{include/kpr4}}
\caption{Projection on the $(x,y)$-plane of solutions $\phi(t)$
at \parf{1} ($\lambda=-1.825470, k=-0.1760749$) and
\parf{2} ($\lambda=-1.686154, k=-0.3183548$).}
\label{kf.2a}
\end{figure}
%------------------------------------------------------
%------------------------------------------------------
\begin{figure}[p]
\epsfysize 8.0cm
\centerline{\epsffile{include/kpr5}}
\caption{Three-dimensional blow-up of the solution curves
 $\phi(t)$ 
at labels \parf{1} (dotted) and \parf{2} (solid line) from Figure 3.8.}
\label{kf.2b}
\end{figure}
%------------------------------------------------------
%
Note that several other parameters appear in
the output. \parf{PAR(10)} is a dummy parameter
that should be zero when the adjoint is being computed correctly;
\parf{PAR(29)}, \parf{PAR(30)}, \parf{PAR(33)} correspond to the
test functions $\psi_9$,$\psi_{10}$ and $\psi_{13}$. 
That these test functions were activated is specified
in three places in \filef{c.kpr.4} 
as described in Section~\ref{sec:HomCont_Test_functions}.  

Note that at the end-point of
the family (reached when after \parf{NMX=50} steps) \parf{PAR(29)} is
approximately zero which corresponds to a zero of $\psi_9$, a 
non-central saddle-node homoclinic orbit. We shall return to the computation of
this codimension-two point later. Before reaching this point,
among the output we find two zeroes of \parf{PAR(33)}
(test function $\psi_{13}$) which gives the accurate
location of two inclination-flip bifurcations,
\begin{verbatim}
 BR  PT  TY LAB    PAR(1)     ...     PAR(2)        PAR(10)    ...   PAR(33)
  1   6  UZ   7  -1.80166E+00 ...  -2.00266E-01  -7.25140E-07 ...  1.14077E-04
  1  12  UZ   8  -1.56876E+00 ...  -4.39547E-01  -2.15617E-07 ... -1.48740E-07
\end{verbatim}
That the test function really does have a regular zero at this point can
be checked from the data saved in \filef{b.3}, plotting \parf{PAR(33)} as
a function of \parf{PAR(1)} or \parf{PAR(2)}. 
Figure \ref{kf.2a} presents solutions $\phi(t)$ of the modified adjoint 
variational equation (for details see \citeasnoun{ChKuSa:95})
at parameter values on the homoclinic 
family before and after the first detected inclination flip. 
Note that these solutions were obtained by choosing a smaller
step \parf{DS} and more output (smaller \parf{NPR}) in
\filef{c.kpr.4}.
A blow-up of the region close to the origin of this 
figure is shown in Figure \ref{kf.2b}.
It illustrates the flip of the solutions of the adjoint equation while
moving through the bifurcation point. Note that the data in this
figure were plotted after first performing an additional
continuation of the solutions with respect to \parf{PAR(11)}. 

Continuing in the other direction 
\begin{center}
\commandf{r3=r3+run(r3()[0],c='kpr.5',ap='3')}
\end{center}
we approach a Bogdanov-Takens point
\begin{verbatim}  
 BR    PT  TY LAB    PAR(1)     ...    PAR(10)    ...    PAR(33)    
  1    50  EP  10 -1.93828E+00  ... -7.52334E+00  ... -3.19793E+01
\end{verbatim}
%------------------------------------------------------
\begin{figure}[t]
\epsfysize 9.0cm
\centerline{\epsffile{include/kpr6}}
\caption{Computed homoclinic orbits approaching the BT point}
\label{kp.6}
\end{figure}
%------------------------------------------------------
Note that the numerical approximation has ceased to become reliable, since 
\parf{PAR(10)} has now become large. 
Phase portraits of homoclinic orbits between the BT point and the first
inclination flip 
are depicted in Figure \ref{kp.6}. Note how the computed homoclinic orbits
approaching the BT point have their endpoints well away from the equilibrium.
To follow the homoclinic orbit to 
the BT point with more precision, we would need to first perform continuation 
in $T$ (\parf{PAR(11)}) to obtain a more accurate homoclinic solution.


\section{More Accuracy and Saddle-Node Homoclinic Orbits.}
Continuation in $T$ 
in order to obtain an approximation of the homoclinic orbit over a
longer interval is necessary for parameter values near a non-hyperbolic
equilibrium (either a saddle-node or BT) where the convergence
to the equilibrium is slower. 
First, we start from the original homoclinic orbit computed
via the homotopy method, label \parf{4}, which is well away from
the non-hyperbolic equilibrium.
Also, we shall no longer be interested in
in inclination flips so we set \parf{ITWIST=0} in \filef{c.kpr.6},
and in order to compute up to \parf{PAR(11)=1000}, we set up a
user-defined function for this. Running \AUTO with \parf{PAR(11)} and 
\parf{PAR(2)} as free parameters
\begin{center}
\commandf{r6=run(r2('EP1'),c='kpr.6',sv='6')}
\end{center}
we obtain among the output
\begin{verbatim}
  BR    PT  TY LAB     PERIOD       L2-NORM    ...    PAR(2)     
   1    35  UZ   6   1.00000E+03  1.66191E+00  ... -1.50000E-01
\end{verbatim}

We can now repeat the computation of the family of saddle homoclinic
orbits in \parf{PAR(1)} and \parf{PAR(2)} from this point with
the test functions $\psi_9$ and $\psi_{10}$ for non-central
saddle-node homoclinic orbits activated 
\begin{center}
\commandf{r7=run(r6('UZ1'),c='kpr.7',sv='7')}
\end{center}
The saddle-node point is now detected at 
\begin{verbatim} 
  BR    PT  TY LAB    PAR(1)     ...    PAR(2)        PAR(29)       PAR(30)
   1    29  UZ   8  1.76505E-01  ... -2.40533E+00  -1.74004E-06   2.30933E+01
\end{verbatim}
which is stored in \filef{s.7}.
That \parf{PAR(29)} ($\psi_9$) is zeroed shows that this
is a non-central saddle-node connecting the centre manifold to the strong stable
manifold. Note that all output beyond this point, although a well-posed
solution to the boundary-value problem, is spurious in that it no longer
represents a homoclinic orbit to a saddle equilibrium (see
\citeasnoun{ChKuSa:95}). If we had chosen
to, we could continue in the other direction in order to
approach the BT point more accurately by reversing the sign of
\parf{DS} in \filef{c.kpr.7}.
 
The file \filef{c.kpr.8} contains the constants necessary 
for switching to continuation of the central saddle-node homoclinic curve 
in two parameters starting from the non-central saddle-node homoclinic orbit
stored as label \parf{8} in \filef{s.7}.
\begin{center}
\commandf{r8=run(r7('UZ1'),c='kpr.8',sv='8')}
\end{center}
In this run we have activated the test functions for saddle to saddle-node
transition points along curves of saddle homoclinic orbits ($\psi_{15}$ and 
$\psi_{16}$). Among the output we find
\begin{verbatim}
  BR    PT  TY LAB    PAR(1)     ...    PAR(2)        PAR(35)       PAR(36)    
   1    38  UZ  11   1.76509E-01 ...  -2.40533E+00   6.89014E-03   3.09956E-05
\end{verbatim}
%------------------------------------------------------
\begin{figure}[p]
\epsfysize 9.0cm
\centerline{\epsffile{include/kpr7}}
\caption{Two non-central saddle-node homoclinic orbits, \parf{1} and \parf{3};
and, \parf{2}, a central saddle-node homoclinic orbit between
these two points \label{kf.7}}
\end{figure}
%------------------------------------------------------
%------------------------------------------------------
\begin{figure}[p]
\epsfysize 9.0cm
\centerline{\epsffile{include/kpr8}}
\caption{The big homoclinic orbit approaching a figure-of-eight}
\label{kp.8}
\end{figure}
%------------------------------------------------------
%
which corresponds to the family of homoclinic orbits leaving
the locus of saddle-nodes in a second non-central saddle-node
homoclinic bifurcation (a zero of $\psi_{16}$). 

Note that the parameter values do not vary much between the
two codimension-two non-central saddle-node points (labels \parf{8} and \parf{11}).
However, Figure \ref{kf.7} shows clearly that between the two
codimension-two points 
the homoclinic orbit
rotates between the two components of the 1D stable manifold, i.e.\
between the two boundaries of the center-stable manifold of the saddle
node. The overall effect of this process is the transformation of a
nearby ``small'' saddle homoclinic orbit to a ``big'' saddle
homoclinic orbit (i.e.\ with two extra turning points in phase space).  

Finally, we can switch to continuation of the big saddle homoclinic orbit 
from the new codim 2 point at label \parf{11}. 
\begin{center}
\commandf{r9=run(r8('UZ1'),c='kpr.9',sv='9')}
\end{center}
Note that \AUTO takes a large number of steps near the line  
\parf{PAR(1)=0}, while \parf{PAR(2)} approaches $-2.189\ldots$  
(which is why we chose such a large value \parf{NMX=500} in \filef{c.kpr.9}). This
particular computation ends at 
\begin{verbatim}  
  BR    PT  TY LAB    PAR(1)        L2-NORM    ...    PAR(2)   
   1   500  EP  24  2.04263E-05   2.18126E-01  ... -2.18951E+00
\end{verbatim}
By plotting phase portraits of orbits approaching this end point (see Figure
\ref{kp.8}) we see a ``canard-like'' like transformation of the big homoclinic
orbit to a pair of homoclinic orbits in a figure-of-eight configuration.
That we get a figure-of-eight is not a surprise because \parf{PAR(1)=0}
corresponds to a symmetry in the differential equations \cite{Ko:94};
note also that the equilibrium, stored as (\parf{PAR(12), PAR(13), PAR(14)}) in
\filef{d.9}, approaches the origin as we approach the figure-of-eight homoclinic.

\section{Three-Parameter Continuation.}
We now consider curves in three parameters of each of
the codimension-two points encountered in this model, by
freeing the parameter $\eps=$ \parf{PAR(3)}.
First we continue the first inclination flip stored at label
\parf{7} in \filef{s.3}
\begin{center}
\commandf{r10=run(r3('UZ1'),c='kpr.10',sv='10')}
\end{center}
Note that \parf{ITWIST=1} in \filef{c.kpr.10}, so that the adjoint is also
continued, and there is one fixed condition \parf{IFIXED(1)=13} so that
test function $\psi_{13}$ has been frozen.
Among the output there is a codimension-three point (zero of $\psi_9$)
where the neutrally twisted homoclinic orbit collides with the saddle-node
curve
\begin{verbatim}
 BR  PT  TY LAB    PAR(1)     ...   PAR(2)        PAR(3)        PAR(29)    ...
  1  18  UZ  11   1.28270E-01 ... -2.51932E+00   5.74477E-01  -2.59151E-06 ...
\end{verbatim}
The other detected inclination flip (at label \parf{8} in \filef{s.3}) is continued
similarly
\begin{center}
\commandf{r11=run(r3('UZ2'),c='kpr.11',sv='11')}
\end{center}
giving among its output another codim 3 saddle-node inclination-flip point
\begin{verbatim} 
 BR  PT  TY LAB    PAR(1)     ...   PAR(2)        PAR(3)        PAR(29)    ...  
  1  27  UZ  11   1.53542E-01 ... -2.45810E+00   1.17171E+00  -1.13312E-06 ...
\end{verbatim}
Output beyond both of these codim 3 points is spurious and both computations end in
an \parf{MX} point (no convergence).

To continue the non-central saddle-node homoclinic orbits it is
necessary to work on the data without the solution $\phi(t)$. We
restart from the data saved at \parf{LAB=8} and \parf{LAB=11} in
\filef{s.7} and \filef{s.8} respectively. We could continue these codim 2 points in two
ways, either by appending the defining condition $\psi_{16} =0$ to
the continuation of saddle-node homoclinic orbits (with \parf{IEQUIB=2},
etc.), or by appending $\psi_{9} =0$ to the continuation 
of a saddle homoclinic orbit (with \parf{IEQUIB=1}). 
The first approach is used in the example \filef{mtn},  
for contrast we shall adopt the second approach here.
%------------------------------------------------------
\begin{figure}[p]
\epsfysize 9.0cm
\centerline{\epsffile{include/kpr10}}
\caption{Projection onto the \parf{(PAR(3),PAR(2))}-plane of the non-central
saddle-node homoclinic orbit curves (labeled \parf{1} and \parf{2}) and the 
inclination-flip curves (labeled \parf{3} and \parf{4})}.
\label{kp.10}
\end{figure}
%------------------------------------------------------
%
\begin{center}
\commandf{r12=run(r7('UZ1'),c='kpr.12',sv='12')}\\
\commandf{r12=r12+run(r8('UZ1'),c='kpr.13',ap='12')}
\end{center}
The projection onto the $(\eps,k)$-plane of all four of these
codimension-two curves is given in Figure \ref{kp.10}. 
The intersection of the inclination-flip lines with one of the
non-central saddle-node homoclinic lines is apparent. Note that the two
non-central saddle-node homoclinic orbit curves are almost overlaid, but
that as in Figure \ref{kf.7} the orbits look quite distinct in phase space.

\section{ Detailed \AUTO-Commands.}
\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | l |}
\hline
  \AUTO-COMMAND  & ACTION \\
\hline
%==============================================================================
  \commandf{mkdir kpr} & create an empty work directory \\ 
  \commandf{cd kpr} & change directory \\
  \commandf{demo('kpr')} & copy the demo files to the work directory \\
\hline
%==============================================================================
  \commandf{r1=run('kpr',c='kpr.1',sv='1')} &  continuation in the time-length parameter \parf{PAR(11)} \\ 
  & save output-files as \filef{b.1, s.1, d.1} \\ 
\hline
%==============================================================================
  \commandf{r2=run(r1('UZ1'),c='kpr.2',sv='2')} & locate the homoclinic orbit \\ 
  & save output-files as \filef{b.2, s.2, d.2} \\ 
\hline
%=============================================================================
  \commandf{r3=run(r2('UZ1'),c='kpr.3',sv='3')} & generate adjoint variables\\ 
  & save output-files as \filef{b.3, s.3, d.3} \\ 
\hline
%==============================================================================
  \commandf{r3=r3+run(r3,c='kpr.4',ap='3')} & continue the homoclinic orbit \\ 
  & append output-files to \filef{b.3, s.3, d.3} \\ 
\hline
%=============================================================================
  \commandf{r3=r3+run(r3()[0],c='kpr.5',ap='3')} & continue in reverse direction\\
  & append output-files to \filef{b.3, s.3, d.3} \\ 
\hline
%==============================================================================
  \commandf{r6=run(r2('EP1'),c='kpr.6',sv='6')} & increase the period \\ 
  & save output-files as \filef{b.6, s.6, d.6} \\ 
\hline
%==============================================================================
\end{tabular}
\caption{Detailed \AUTO-Commands for running demo \filef{kpr}.}
\label{tbl:demo_kpr_1}
\end{center}
\end{table}


\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | l |}
\hline
  \AUTO-COMMAND  & ACTION \\
\hline
%==============================================================================
  \commandf{r7=run(r6('UZ1'),c='kpr.7',sv='7')} & recompute the family
  of homoclinic orbits \\ 
  \commandf{sv('7')} & save output-files as \filef{b.7, s.7, d.7} \\ 
\hline
%==============================================================================
  \commandf{r8=run(r7('UZ1'),c='kpr.8',sv='8')} & continue central
  saddle-node homoclinics \\ 
  & save output-files as \filef{b.8, s.8, d.8} \\ 
\hline
%==============================================================================
  \commandf{r9=run(r8('UZ1'),c='kpr.9',sv='9')} & continue homoclinics
  from codim-2 point \\ 
  & save output-files as \filef{b.9, s.9, d.9} \\ 
\hline
%==============================================================================
  \commandf{r10=run(r3('UZ1'),c='kpr.10',} & 3-parameter curve of inclination-flips\\ 
  \commandf{  sv='10')} & save output-files as \filef{b.10, s.10, d.10} \\ 
\hline
%==============================================================================
  \commandf{r11=run(r3('UZ2'),c='kpr.11',} & another curve of inclination-flips \\ 
  \commandf{  sv='11')} & save output-files as \filef{b.11, s.11, d.11} \\ 
\hline
%==============================================================================
  \commandf{r12=run(r7('UZ1'),c='kpr.12',} & continue non-central saddle-node homoclinics\\ 
  \commandf{  sv='12')} & save output-files as \filef{b.12, s.12, d.12} \\ 
\hline
%==============================================================================
  \commandf{r12=r12+run(r8('UZ1'),c='kpr.13',} & continue non-central saddle-node homoclinics\\ 
  \commandf{  ap='12')} & append output-files to \filef{b.12, s.12, d.12} \\ 
\hline
%==============================================================================
\end{tabular}
\caption{Detailed \AUTO-Commands for running demo \filef{kpr}.}
\label{tbl:demo_kpr_2}
\end{center}
\end{table}


%==============================================================================
%==============================================================================
\chapter{ {\cal HomCont} Demo : cir.} \label{ch:HomCont_cir}
%==============================================================================
%==============================================================================

%==============================================================================
%DEMO=cir======================================================================
%==============================================================================
\section{ Electronic Circuit of Freire \textit{et al}.}
Consider the following model of a three-variable electronic circuit
\cite{FrRLuGaPo:93}
 \begin{equation}
\left \{ 
\begin{array}{rcl}
\dot{x} & = & \left [-(\beta+\nu) x + \beta y -a_3 x^3 
+b_3(y-x)^3\right ]/r, \\
\dot{y} & = & \beta x -(\beta+\gamma)y -z -b_3(y-x)^3, \\
\dot{z} & = & y.
\end{array}
\right.  
\label{5.fr1}
\end{equation}
These autonomous equations are also considered in the \AUTO demo \filef{tor}.

First, we copy the demo into a new directory and compile
\begin{center}
\commandf{dm('cir')} \\
\end{center}
The system is contained in 
the equation-file \filef{cir.f90} and the initial run-time constants
are stored in \filef{c.cir.1}. We begin by starting from
the data from \filef{cir.dat} for a saddle-focus homoclinic orbit 
at 
$\nu=-0.721309$, $\beta=0.6$, $\gamma=0$, $r=0.6$, $A_3=0.328578$ 
and $B_3=0.933578$, which was obtained by shooting over 
the time interval $2T=$\parf{PAR(11)}$=36.13$.
We wish to follow the family in the $(\beta,\nu)$-plane, but 
first we perform continuation in $(T,\nu)$ to obtain a better 
approximation to a homoclinic orbit.
\begin{center}
\commandf{r1=run('cir',c='cir.1')}
\end{center} 
yields the output
\begin{verbatim}
 BR  PT  TY LAB     PERIOD       L2-NORM    ...   PAR(1)     
  1  21  UZ   2  1.000000E+02  1.286637E-01 ... -7.213093E-01
  1  42  UZ   3  2.000000E+02  9.097899E-02 ... -7.213093E-01
  1  50  EP   4  2.400000E+02  8.305208E-02 ... -7.213093E-01
\end{verbatim}
Note that $\nu=$\parf{PAR(1)} remains constant during the continuation
as the parameter values do not change, only the length of
the interval over which the approximate homoclinic solution is computed.
Note from the eigenvalues, stored in \filef{d.1} that this is a homoclinic
orbit to a saddle-focus with a one-dimensional unstable manifold.

We now restart at \parf{LAB=3}, corresponding to a time interval $2T=200$,
and change the principal continuation parameters to be $(\nu,\beta)$.
The new constants defining the continuation are given in \filef{c.cir.2}.
We also activate the test functions pertinent to codimension-two
singularities which may be encountered along a family of saddle-focus
homoclinic orbits, viz.\ $\psi_2$, $\psi_4$, $\psi_5$, $\psi_9$ and $\psi_{10}$.
This must be specified in three ways: by appropriate
\parf{IPSI} in \filef{c.cir.2}, by adding the corresponding parameter labels
to the list of continuation parameters \parf{ICP(I)} in \filef{c.cir.2}
(recall that these parameter indices are 20 more than the corresponding
$\psi$ indices), and finally adding UZR functions defining zeros of
these parameters in \filef{c.cir.2}. Running 
\begin{center}  
\commandf{r2=run(r1('UZ2'),c='cir.2',sv='2')}
\end{center} 
results in
\begin{verbatim}
BR  PT  TY LAB    PAR(1)     ...    PAR(2)     ...    PAR(25)       PAR(29)    
1   17  UZ   5 -7.256925E-01 ...  4.535645E-01 ... -1.765251E-05 -2.888436E-01
1   75  UZ   6 -1.014704E+00 ...  9.998966E-03 ...  1.664509E+00 -5.035997E-03
1   78  UZ   7 -1.026445E+00 ... -2.330391E-05 ...  1.710804E+00  1.165176E-05
1   81  UZ   8 -1.038012E+00 ... -1.000144E-02 ...  1.756690E+00  4.964621E-03  
1  100  EP   9 -1.164160E+00 ... -1.087732E-01 ...  2.230329E+00  5.042736E-02
\end{verbatim}
with results saved in \filef{b.2, s.2, d.2}.
%------------------------------------------------------
\begin{figure}[p]
\epsfysize 9.0cm
\centerline{\epsffile{include/cir1}}
\caption{Solutions of the boundary value problem at labels 6 and 8, 
either side of the Shil'nikov-Hopf bifurcation}
\label{Fcircuit1}
\end{figure}
%------------------------------------------------------
%------------------------------------------------------
\begin{figure}[p]
\epsfysize 9.0cm
\centerline{\epsffile{include/cir2}}
\caption{Phase portraits of three homoclinic orbits 
on the family, showing the saddle-focus to saddle transition}
\label{Fcircuit2}
\end{figure}
%------------------------------------------------------
Upon inspection of the output, note that label 5, where \parf{PAR(25)}$\approx 0$, 
corresponds to a neutrally-divergent saddle-focus, $\psi_5=0$. 
Label 7, where \parf{PAR(29)}$\approx 0$ corresponds to a local bifurcation, $\psi_9=0$, 
which we note from the eigenvalues stored in \filef{d.2} corresponds to a \emp{
Shil'nikov-Hopf} bifurcation. Note that \parf{PAR(2)} is also approximately zero
at label 7, which accords with the analytical observation that the origin of
(\ref{5.fr1}) undergoes a Hopf bifurcation when $\beta=0$.
Labels 6 and 8 are the user-defined output
points, the solutions at which are plotted in Fig.\ \ref{Fcircuit1}.
Note that solutions beyond label 7 (e.g., the plotted solution
at label 8) do not correspond to homoclinic orbits, but to 
\emp{ point-to-cycle} heteroclinic orbits (c.f.\ Section~2.2.1 of
\citeasnoun{ChKuSa:95}).

We now continue in the other direction along the family. It turns out
that starting from the initial point in the other direction results in
missing a codim 2 point which is close to the starting point. Instead we
start from the first saved point from the previous computation
(label 5 in \filef{s.2}):
\begin{center}
\commandf{r3=run(r2('UZ1'),c='cir.3',ap='2')}
\end{center}
The output
\begin{verbatim}
 BR  PT  TY LAB    PAR(1)     ...    PAR(2)        PAR(22)       PAR(24)    
  1   9  UZ  10 -7.204001E-01 ...  5.912315E-01 -1.725669E+00 -3.295862E-05
  1  18  UZ  11 -7.590583E-01 ...  7.428734E-01  3.432139E-05 -2.822988E-01
  1  26  UZ  12 -7.746686E-01 ...  7.746147E-01  5.833163E-01  1.637611E-07
  1  28  EP  13 -7.746628E-01 ...  7.746453E-01  5.908902E-01  1.426214E-04
\end{verbatim}
contains a neutral saddle-focus (a \emp{ Belyakov} transition) 
at \parf{LAB=10} ($\psi_4=0$), a double real leading eigenvalue 
(saddle-focus to saddle transition) at \parf{LAB =11} ($\psi_2=0$) 
and a neutral saddle at \parf{LAB=12} ($\psi_4=0$). Data at several
points on the complete family are plotted in Fig.\ \ref{Fcircuit2}.
If we had continued further (by increasing \parf{NMX}), 
the computation would end at a no convergence error \parf{TY=MX} owing 
to the homoclinic family approaching a Bogdanov-Takens singularity 
at small amplitude. To compute further towards the BT point 
we would first need to continue to a higher value of \parf{PAR(11)}.

\section{ Detailed \AUTO-Commands.}
\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | l |}
\hline
  \AUTO-COMMAND  & ACTION \\
\hline
%==============================================================================
  \commandf{mkdir cir} & create an empty work directory \\ 
  \commandf{cd cir} & change directory \\
  \commandf{demo('cir')} & copy the demo files to the work directory \\
\hline
%==============================================================================
  \commandf{r1=run(c='cir.1',sv='1')} &  increase the truncation interval; restart from \filef{cir.dat}\\ 
  & save output-files as \filef{b.1, s.1, d.1} \\ 
\hline
%==============================================================================
  \commandf{r2=run(r1('UZ2'),c='cir.2',sv='2')} &  continue saddle-focus
  homoclinic orbit; restart from \parf{r1} \\ 
  & save output-files as \filef{b.2, s.2, d.2} \\ 
\hline
%=============================================================================
  \commandf{r3=run(r2('UZ1'),c='cir.3',ap='2')} & generate adjoint variables  ; restart from \parf{r2} \\ 
  & append output-files as \filef{b.2, s.2, d.2} \\ 
\hline
%==============================================================================
\end{tabular}
\caption{Detailed \AUTO-Commands for running demo \filef{cir}.}
\label{tbl:demo_cir_1}
\end{center}
\end{table}



%==============================================================================
%==============================================================================
\chapter{ {\cal HomCont} Demo : she.} \label{ch:HomCont_she}
%==============================================================================
%==============================================================================

%==============================================================================
%DEMO=she======================================================================
%==============================================================================
\section{ A Heteroclinic Example.}
The following system of five equations \citeasnoun{RuMa:95}
\begin{equation} \label{sh1} \begin{array}{rcl}
\dot{x} & = & \mu \, x + x\, y - z\, u, \\
\dot{y} & = & -y - x^2, \\
\dot{z} & = & \mu\, z + x\, u - 9\sigma\, z / 4(1+\sigma)  \\
\dot{u} & = & - \sigma u / 4 - \sigma Q v / 4\pi^2
+ 3(1 + \sigma) x z / 4\sigma \\
\dot{v} & = & \zeta u / 4  - \zeta v / 4
\end{array} 
\end{equation}
has been used to describe shearing instabilities in fluid convection.
The equations possess a rich structure of local and global bifurcations.
Here we shall reproduce a single curve in the $(\sigma,\mu)$-plane
of codimension-one heteroclinic orbits connecting a non-trivial 
equilibrium to the origin for $Q=0$ and $\zeta=4$. The defining
problem is contained in equation-file 
\filef{she.f90}\footnote{The last parameter used to store the equilibria (\parf{PAR(21)}) is
overlaped here with the first test-function. In this example, it is harmless since the test functions are 
irrelevant for heteroclinic continuation.}, and starting data for the orbit at 
$(\sigma,\mu)=(0.5,0.163875)$ are stored in \filef{she.dat},
with a truncation interval of \parf{PAR(11)=85.07}.

We begin by computing towards $\mu=0$ with the option \parf{IEQUIB=-2}
which means that both equilibria are solved for as part of
the continuation process.
\begin{center}
\commandf{demo('she')} \\
\commandf{r1=run('she',c='she.1',sv='1')}
\end{center} 
This yields the output
\begin{verbatim}
  BR    PT  TY  LAB    PAR(3)        L2-NORM    ...   PAR(1)     
   1     1  EP    1   5.00000E-01   4.05950E-01 ...  1.63875E-01
   1     5        2   4.52847E-01   3.72688E-01 ...  1.36505E-01
   1    10        3   3.94351E-01   3.30390E-01 ...  1.04419E-01
   1    15        4   3.35908E-01   2.87331E-01 ...  7.51623E-02
   1    20        5   2.77287E-01   2.43351E-01 ...  4.95320E-02
   1    25        6   2.18210E-01   1.98147E-01 ...  2.84629E-02
   1    30  EP    7   1.58178E-01   1.51246E-01 ...  1.29327E-02
\end{verbatim}
Alternatively, for this problem there exists an analytic expression for
the two equilibria. This is specified in the subroutine \funcf{PVLS} of
\filef{she.f90}. Re-running with \parf{IEQUIB=-1}
\begin{center}
\commandf{r2=run('she',c='she.2')}
\end{center}
we obtain the output
\begin{verbatim}
   1     1  EP    1   5.00000E-01   4.05950E-01 ...  1.63875E-01
   1     5        2   4.43202E-01   3.65772E-01 ...  1.31056E-01
   1    10        3   3.72309E-01   3.14244E-01 ...  9.30098E-02
   1    15        4   3.00884E-01   2.61156E-01 ...  5.93397E-02
   1    20        5   2.28665E-01   2.06219E-01 ...  3.17994E-02
   1    25        6   1.55541E-01   1.49165E-01 ...  1.23990E-02
   1    30  EP    7   8.10746E-02   9.14311E-02 ...  2.38662E-03
\end{verbatim}
This output is similar to that above, but note that it is obtained slightly
more efficiently because the extra parameters \parf{PAR(12-21)} representing the
coordinates of the equilibria are no longer
part of the continuation problem. Also note that \AUTO has chosen to take
slightly larger steps along the family. Finally, we can continue in the opposite
direction along the family from the original starting point (again with \parf{IEQUIB=-1}).
\begin{center}
\commandf{r3=run(r2(2),c='she.3')}\\
\commandf{save(r2+r3,'2')}
\end{center}
%
%------------------------------------------------------
\begin{figure}[b]
\epsfysize 9.0cm
\centerline{\epsffile{include/she1}}
\caption{Projections into $(x,y,z)$-space of the family of heteroclinic
orbits.}
\label{Fshear}
\end{figure}
%------------------------------------------------------
%
\begin{verbatim}
  BR    PT  TY  LAB    PAR(3)        L2-NORM    ...   PAR(1)     
   1     5        8   4.99759E-01   4.06015E-01 ...  1.63732E-01
   1    10        9   5.70530E-01   4.55187E-01 ...  2.06526E-01
   1    15       10   6.41644E-01   5.03184E-01 ...  2.50783E-01
   1    20       11   7.13330E-01   5.50067E-01 ...  2.95934E-01
   1    25       12   7.85769E-01   5.95871E-01 ...  3.41549E-01
   1    30       13   8.59097E-01   6.40618E-01 ...  3.87300E-01
   1    35  EP   14   9.33416E-01   6.84317E-01 ...  4.32927E-01
\end{verbatim}
The results of both computations are presented in Figure \ref{Fshear}, 
from which we see that the orbit shrinks to zero as
\parf{PAR(1)=}$\mu \to 0$.

\section{ Detailed \AUTO-Commands.}
\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | l |}
\hline
  \AUTO-COMMAND  & ACTION \\
\hline
%==============================================================================
  \commandf{mkdir she} & create an empty work directory \\ 
  \commandf{cd she} & change directory \\
  \commandf{demo('she')} & copy the demo files to the work directory \\
\hline
%==============================================================================
  \commandf{r1=run('she',c='she.1',sv='1')} &  continue heteroclinic orbit; start from \filef{she.dat}\\ 
  & save output-files as \filef{b.1, s.1, d.1} \\ 
\hline
%==============================================================================
  \commandf{r2=run('she',c='she.2')} &  repeat with \parf{IEQUIB=-1} \\ 
\hline
%=============================================================================
  \commandf{r3=run(r2(2),c='she.3')} & continue in reverse direction ;\\
  & restart from label 2 of \parf{r2} \\ 
  \commandf{save(r2+r3,'2')} & Save appended results to \filef{b.2, s.2, d.2}\\ 
\hline
%=============================================================================
\end{tabular}
\caption{Detailed \AUTO-Commands for running demo \filef{she}.}
\label{tbl:demo_she_1}
\end{center}
\end{table}





%==============================================================================
%==============================================================================
\chapter{ {\cal HomCont} Demo : rev.} \label{ch:HomCont_rev}
%==============================================================================
%==============================================================================

%==============================================================================
%DEMO=rev======================================================================
%==============================================================================
\section{ A Reversible System.}
The fourth-order differential equation
$$
u'''' + P u'' + u -u^3 =0
$$
arises in a number of contexts, e.g., as the travelling-wave
equation for a nonlinear-Schr\"{o}dinger equation with fourth-order
dissipation \cite{BuAk:95} and as a model of a strut on a symmetric 
nonlinear elastic foundation \cite{HuBoTh:89}. It may be expressed as
a system
\begin{equation}
\left \{ 
\begin{array}{rcl}
\dot{u_1} & = & u_2 \\
\dot{u_2} & = & u_3 \\
\dot{u_3} & = & u_4 \\
\dot{u_4} & = & -P u_3 - u_1 + u_1^3
\end{array}
\right.  
\label{6.1}
\end{equation}
Note that (\ref{6.1}) is invariant under two separate reversibilities
\begin{equation}
R_1: (u_1,u_2,u_3,u_4,t) \mapsto (u_1,-u_2,u_3,-u_4,-t)  
\label{6.R1}
\end{equation}
and 
\begin{equation}
R_2: (u_1,u_2,u_3,u_4,t) \mapsto (-u_1,u_2,-u_3,u_4,-t)  
\label{6.R2}
\end{equation}
First, we copy the demo into a new directory 
\begin{center}
\commandf{demo('rev')}
\end{center}
For this example, we shall make two separate starts
from data stored in equation and data files \filef{rev.c.1,
rev.dat.1} and \filef{rev.c.3, rev.dat.3} respectively. The first
of these contains initial data for a solution that is reversible
under $R_1$ and the second for data that is reversible under $R_2$. 
%
%Note that \commandf{make} or \commandf{make all} will only run the
%first of these. To make the output starting from the
%$R_2$-reversible solution we need to \commandf{make run2}. As before,
%though we illustrate here the step by step approach.


\section{An \texorpdfstring{$R_1$}{R1}-Reversible Homoclinic Solution.}

The first run
\begin{center}
\commandf{r1=run('rev',c='rev.1',sv='1')}
\end{center}
starts by using the file \filef{rev.dat.1} via the
\parf{'dat'} \AUTO-constant in \filef{c.rev.1}.
The orbit contained in
the data file is a ``primary'' homoclinic solution for $P=1.6$, with
truncation (half-)interval \parf{PAR(11) = 39.0448429}.
which is reversible under $R_1$. Note that this reversibility is
specified in \filef{c.rev.1} via \parf{IREV=[0,1,0,1]}. Note also, from
\filef{c.rev.1} that we only have one free parameter \parf{PAR(1)}
because symmetric homoclinic orbits in reversible systems are
generic rather than of codimension one.
The first run  results in the output
\begin{verbatim}
  BR    PT  TY  LAB    PAR(1)        L2-NORM       MAX U(1)   ...
   1     1  EP    1   1.60000E+00   2.85704E-01   3.62232E-01
   1     8  UZ    2   1.70000E+00   2.90288E-01   4.18225E-01
   1    11  UZ    3   1.80000E+00   2.95723E-01   4.80604E-01
   1    14  UZ    4   1.90000E+00   2.74864E-01   4.43069E-01
   1    20  EP    5   1.99678E+00   1.13379E-01   9.59430E-02
\end{verbatim}
which is consistent with the theoretical result that the solution
tends uniformly to zero as $P\to 0$. Note, by plotting the data
saved in \filef{s.1} that only ``half'' of the 
homoclinic orbit is computed up to its point of symmetry. See Figure
\ref{Frev1}.

%------------------------------------------------------
\begin{figure}[p]
\epsfysize 9.0cm
\centerline{\epsffile{include/rev1}}
\caption{$R_1$-Reversible homoclinic solutions on the half-interval
$x/T \in [0,1]$ where $T=39.0448429$ for $P$ approaching $2$ (solutions
with labels \parf{1-5} respectively have decreasing amplitude)}
\label{Frev1}
\end{figure}
%------------------------------------------------------
%------------------------------------------------------
\begin{figure}[p]
\epsfysize 9.0cm
\centerline{\epsffile{include/rev2}}
\caption{$R_1$-reversible homoclinic orbits with oscillatory decay 
as $x \to -\infty$ (corresponding to label \parf{6}) and monotone decay 
(at label \parf{10})}
\label{Frev2}
\end{figure}
%------------------------------------------------------

The second run continues in the other direction of \parf{PAR(1)}, with
the test function $\psi_2$ activated 
for the detection of saddle to saddle-focus transition points
\begin{center}
\commandf{r1=r1+run(r1('UZ1'),c='rev.2',ap='1')}
\end{center}
The output
\begin{verbatim}
 BR  PT  TY  LAB    PAR(1)        L2-NORM       MAX U(1)   ...   PAR(22)    
  1  11  UZ    6   1.00001E+00   2.81700E-01   1.76625E-01 ... -3.00001E+00
  1  22  UZ    7  -1.00743E-07   2.89421E-01   4.69706E-02 ... -2.00000E+00
  1  33  UZ    8  -1.00000E+00   3.02208E-01   4.32654E-03 ... -1.00000E+00
  1  44  UZ    9  -2.00000E+00   3.16798E-01   1.22616E-11 ...  2.66362E-08
  1  55  EP   10  -3.09920E+00   3.32927E-01  -4.00188E-10 ...  1.09920E+00
\end{verbatim}
shows a saddle to saddle-focus transition 
(indicated by a zero of \parf{PAR(22)}) at \parf{PAR(1)=-2}. Beyond
that label the first component of the solution is negative and (up to the
point of symmetry) monotone decreasing. See Figure \ref{Frev2}.

\section{An \texorpdfstring{$R_2$}{R2}-Reversible Homoclinic Solution.}

\begin{center}
\commandf{r3=run('rev',c='rev.3',sv='3')}
\end{center}
starts by using the file \filef{rev.dat.3} via the
\parf{'dat'} \AUTO-constant in \filef{c.rev.3},
and runs them with the constants stored in \filef{c.rev.3}. 
The orbit contained in
the data file is a ``multi-pulse'' homoclinic solution for $P=1.6$, with
truncation (half-)interval \parf{PAR(11) = 47.4464189}.
which is reversible under $R_2$. This reversibility is
specified in \filef{c.rev.1} via \parf{IREV=[1,0,1,0]}.
The output 
\begin{verbatim}
  BR    PT  TY  LAB    PAR(1)        L2-NORM       MAX U(1)   ...
   1     1  EP    1   1.60000E+00   3.69766E-01   3.83942E-01
   1     7  UZ    2   1.70000E+00   3.83640E-01   4.89066E-01
   1     9  LP    3   1.71157E+00   3.92475E-01   5.46080E-01
   1    11  UZ    4   1.69884E+00   4.04207E-01   6.10428E-01
   1    14  UZ    5   1.60000E+00   4.32940E-01   7.77395E-01
   1    26  UZ    6   1.00000E+00   4.80849E-01   1.08252E+00
   1    49  UZ    7  -5.38706E-08   5.15846E-01   1.25863E+00
   1   128  MX    8  -9.15462E-01   5.44202E-01   1.32395E+00
\end{verbatim}
contains the label of a limit point (\parf{ILP} was set to \parf{1} in
\filef{c.rev.3}), which corresponds to a ``coalescence'' of two reversible
homoclinic orbits. The two solutions on either side of this limit point are
displayed in Figure \ref{Frev3}. The computation ends in a no-convergence
point. The solution here is depicted in Figure \ref{Frev4}. The lack of
convergence is due to the large peak and trough of the solution rapidly
moving to the left as $P \to -2$ (cf. \citeasnoun{ChSp:93}).

%------------------------------------------------------
\begin{figure}[p]
\epsfysize 9.0cm
\centerline{\epsffile{include/rev3}}
\caption{Two $R_2$-reversible homoclinic orbits at $P=1.6$ 
corresponding to labels \parf{1} (smaller amplitude) and \parf{5} (larger amplitude)}
\label{Frev3}
\end{figure}
%------------------------------------------------------
%------------------------------------------------------
\begin{figure}[p]
\epsfysize 9.0cm
\centerline{\epsffile{include/rev4}}
\caption{An $R_2$-reversible homoclinic orbit at label \parf{8}}
\label{Frev4}
\end{figure}
%------------------------------------------------------

Continuing from the initial solution in the other parameter direction
\begin{center}
\commandf{r3=r3+run(r3('UZ1'),c='rev.4',ap='3')}
\end{center}
we obtain the output
\begin{verbatim}
  BR    PT  TY  LAB    PAR(1)        L2-NORM       MAX U(1)   ...
   1     7  UZ    9   1.60000E+00   3.70171E-01   3.84045E-01
   1    33  UZ   10   9.99998E-01   3.61440E-01   1.77504E-01
   1    94  UZ   11  -5.14775E-08   3.71301E-01   4.69706E-02
   1   153  MX   12  -2.54464E-01   3.75071E-01   3.00627E-02
\end{verbatim}
which again ends at a no convergence error for similar reasons.

\section{ Detailed \AUTO-Commands.}
\begin{table}[htbp]
\begin{center}
\begin{tabular}{| l | l |}
\hline
  \AUTO-COMMAND  & ACTION \\
\hline
%==============================================================================
  \commandf{mkdir rev} & create an empty work directory \\ 
  \commandf{cd rev} & change directory \\
  \commandf{demo('rev')} & copy the demo files to the work directory \\
\hline
%==============================================================================
  & use the starting data in \filef{rev.dat.1} \\ 
  \commandf{r1=run('rev',c='rev.1',sv='1')} &  increase \parf{PAR(1)} \\ 
  & save output-files as \filef{b.1, s.1, d.1} \\ 
\hline
%==============================================================================
  \commandf{r1=r1+run(r1('UZ1'),c='rev.2',ap='1')} &  continue in
  reverse direction; restart: 1st \parf{UZ} \\ 
  & append output-files to \filef{b.1, s.1, d.1} \\ 
\hline
%=============================================================================
  & use the starting data in \filef{rev.dat.3} \\ 
  \commandf{r3=run('rev',c='rev.3',sv='3')} & restart with different reversibility \\ 
  & save output-files as \filef{b.3, s.3, d.3} \\ 
\hline
%==============================================================================
  \commandf{r3=r3+run(r3('UZ1'),c='rev.4',ap='3')} & continue in
  reverse direction; restart: 1st \parf{UZ} \\ 
  & append output-files to \filef{b.3, s.3, d.3} \\ 
\hline
%=============================================================================
\end{tabular}
\caption{Detailed \AUTO-Commands for running demo \filef{rev}.}
\label{tbl:demo_rev_1}
\end{center}
\end{table}

%==============================================================================
%==============================================================================
\chapter{ {\cal HomCont} Demo : Homoclinic branch switching.} \label{ch:HomCont_hbs}
%==============================================================================
%==============================================================================

%==============================================================================
%DEMO=hbs======================================================================
%==============================================================================

This demo illustrates homoclinic branch switching, which is an
implementation of Lin's method \cite{Li:90,Sa:93,Ye:01}
as described in \citeasnoun{OlChKr:03}. We use a
direct branch switching method to switch from 1- to 2- and
3-homoclinic orbits near an inclination flip bifurcation 
in a model due to Sandstede, 
which was introduced in Chapter~\ref{ch:HomCont_san}.
This also shows how to obtain a homoclinic orbit through continuation
of a periodic orbit born at a Hopf bifurcation.
Thereafter, we illustrate homoclinic branch switching for the
FitzHugh-Nagumo equations and a 5th-order Korteweg-De Vries model.

The equation files in these demos are written in C.

\section{ Branch switching at an inclination flip in Sand\-stede's
  model.}
\label{sec:HomCont_hbs_san}
Consider the system \cite{Sa:95b}
\begin{equation} \begin{array}{rcl}
\dot{x} & = & a x + b y - a x^2 - \alpha z x (2-3x), \\
\dot{y} & = & b x + a y - \frac{3}{2} x (b x + a y) + \alpha z 2 y, \\
\dot{z} & = & c z + \mu x + 3 x z + \alpha (x^2 (1-x) - y^2).
\end{array} \end{equation}
as given in the file \filef{sib.c}, where for simplicity we have
set $\tilde\mu=0$, $\beta=1$ and $\gamma=3$.

We study an inclination flip that exists for $a=0.375$,
$b=0.625$ and $c=-0.75$. This corresponds to the situation
where the eigenvalues of the equilibrium at the origin are
$a+b=1$, $a-b=-0.25$ and $c=-0.75$. Hence, the corresponding
bifurcation diagram consists of a complicated structure involving a
fan of infinitely many $n$-periodic and $n$-homoclinic orbits
for arbitrary $n$ and a region with horseshoe dynamics; see
also \citeasnoun{HoKr:00} and the references therein.

This computation starts from an equilibrium at $(2/3,0,0)$, which
exists for $a=\mu=\alpha=0$. Also, $b$ is set to $0.625$ (the value
we would like it to be) and $c$ is set to $-2.5$ in \funcf{stpnt}.
Choosing $c=-2$ at this stage leads to convergence problems.
This equilibrium is not the one corresponding to the homoclinic orbit,
but it is an equilibrium with complex eigenvalues, that we can follow
until it reaches a Hopf bifurcation. A periodic orbit emanates from 
this Hopf bifurcation and can be followed to the homoclinic orbit.
However, first we need to change $a$ from $0$ to $0.375$.

All the following commands, except for \commandf{demo('sib')}
are contained within the file \commandf{'sib.auto'} which you can 
either execute in a batch mode by entering\\
\commandf{> auto sib.auto}\\
or step by step using\\
\commandf{AUTO> demofile('sib.auto')}.

We start by copying the demo to the current work directory 
and running the first step
\begin{center}
\commandf{demo('sib') }\\
\commandf{r1=run(e='sib',c='sib') } \\
\commandf{save(r1,'1') }
\end{center}
The equilibrium is followed in $a$ until $a$ (or \parf{PAR(1)}) is at our
desired value, $0.375$.
\begin{verbatim}
  BR    PT  TY  LAB    PAR(1)     ...    U(1)          U(2)          U(3)     
   1     1  EP    1   0.00000E+00 ... 6.66667E-01   0.00000E+00   0.00000E+00
   1     5  UZ    2   3.75000E-01 ... 6.66667E-01  -1.33333E-01   0.00000E+00
\end{verbatim}
The output is saved in the files \filef{b.1}, \filef{s.1} and
\filef{d.1}.
Next we continue in $\alpha$ (\parf{PAR(4)}) until a Hopf bifurcation is
found:
\begin{center}
\commandf{r2=run(r1,ICP=[4]) }\\
\commandf{save(r2,'2') }
\end{center}
or, alternatively,
\begin{center}
\commandf{rn(c='sib.2',s='1')}\\
\commandf{sv('2') }
\end{center}
\begin{verbatim}
  BR    PT  TY  LAB    PAR(4)     ...    U(1)          U(2)          U(3)     
   1     6  HB    3   3.18429E-01 ... 6.54375E-01  -1.34754E-01   7.70102E-02
\end{verbatim}
The output is saved in the files \filef{b.2}, \filef{s.2} and
\filef{d.2}.
This Hopf bifurcation can then be continued into a periodic orbit. The
periodic orbit eventually reaches a homoclinic bifurcation. We
continue in $\mu$=\parf{PAR(5)} and \parf{PAR(11)}, 
which corresponds to the period, and stop when the period is equal to $35$.
\begin{center}
\commandf{r3=run(r2('HB1'),IPS=2,ICP=[5,11],NMX=200,DS=0.01,DSMAX=0.01,UZR=\{-11:35\})} \\
\commandf{save(r3,'3')}
\end{center}
\begin{verbatim}
  BR    PT  TY  LAB    PAR(5)        L2-NORM    ...    PERIOD    
   3    10        5  -2.41881E-03   6.70569E-01 ...  1.08975E+01
                                                ...
   3    40        8  -1.29495E-02   6.14547E-01 ...  1.41297E+01
                                                ...
   3    81  UZ   13  -1.04657E-04   4.01829E-01 ...  3.50000E+01
\end{verbatim}
The output is saved in the files \filef{b.3}, \filef{s.3} and
\filef{d.3}. Note that $\mu$ first decreases and then increases towards
$0$, which is precisely what we expect in this model, as homoclinic
orbits occur on the line $\mu=0$ in the $(\alpha,\mu)$-plane.
It is now instructive to look at a phase space diagram to see what is
going on.
\begin{center}
\commandf{plot(r3) }
\end{center}
Selecting 'solution' for Type, [5,6,7,8,9,10,11,12,13] for Label,
[U(1)] for X and [U(2)] for Y, we obtain the diagram depicted in 
Figure~\ref{hopfbif}(a), where the periodic orbit grows from the
Hopf equilibrium to a homoclinic orbit.
\begin{figure}[htb]
\begin{center}
\begin{picture}(400,180)
\put(0,0){
\put(157,148){(a)}
\includegraphics[scale=0.5]{include/hopfbif}}
\put(200,0){
\put(157,148){(b)}
\includegraphics[scale=0.5]{include/notshifted}}
\end{picture}
\caption{Periodic orbit growing from a Hopf bifurcation to a
  homoclinic orbit (a). The unshifted homoclinic orbit (b).}
\label{hopfbif}
\end{center}
\end{figure}

Note however, that the homoclinic orbit has the wrong left-hand and
right-hand end points. This can be seen by plotting the solution
corresponding to Label [13] using 't' vs. 'x' (coordinate [U(1)]), 
as depicted in Figure~\ref{hopfbif}(b).

Hence, in order to continue this as a real homoclinic 
we have to give {\cal HomCont} special instructions, to do a phase-shift in
time. This can be done by setting \parf{ISTART=4}. Moreover, 
since we have not specified the value of
the equilibrium at the origin in \filef{sib.c}, 
we need to set \parf{IEQUIB=1} (this is the default value) to let
{\cal HomCont} detect the equilibrium. Note that in this case this is not
strictly necessary; however, we do this for instructional purposes.

Now we use {\cal HomCont} to continue the homoclinic orbit in $c$ and $\mu$ 
(\parf{PAR(3)}, \parf{PAR(5)}), to get the desired value $c=-2.0$.
\begin{center}
\commandf{r4=run(r3,IPS=9,ICP=[3,5],NPR=60,JAC=1,UZR=\{-3:-2.0\},ISTART=4) } \\
\commandf{save(r4,'4')}
\end{center}
\begin{verbatim}
  BR    PT  TY  LAB    PAR(3)        L2-NORM      ...    PAR(5)     
   3    51  UZ   14  -2.00000E+00   4.01890E-01   ...  2.66146E-09
\end{verbatim}
The output is saved in the files \filef{b.4}, \filef{s.4} and
\filef{d.4}. Note that \parf{PAR(5)}=$\mu$ remains zero, which is exactly
what we expect.

Next we want to add a solution to the adjoint equation to this
solution. This is achieved by making the change \parf{ITWIST = 1}.
Also, we set \parf{ISTART} to 1 to tell 
{\cal HomCont} that it should not try to shift the orbit anymore.
\begin{center}
\commandf{r5=run(r4,ICP=[5,8],NMX=2,ITWIST=1,ISTART=1)} \\
\commandf{save(r5,'5') }
\end{center}
or, alternatively,
\begin{center}
\commandf{rn(c='sib.5',s='4')}\\
\commandf{sv('5')}\\
\end{center}
The output is stored in \filef{b.5}, \filef{s.5}  and \filef{d.5}.
\begin{verbatim}
  BR    PT  TY  LAB    PAR(5)        L2-NORM    ...    PAR(8)     
   3     2  EP   15   2.66146E-09   4.01890E-01 ...   1.00000E-02
\end{verbatim}
Here \parf{PAR(8)} is a dummy (unused) parameter and $\mu$ just stays where
it is. Now that we have obtained the solution of the adjoint equation,
we are able to detect inclination flips. This can be achieved by
setting \parf{IPSI} to [13] and monitoring \parf{PAR(33)}.
\begin{center}
\commandf{r6=run(r5,ICP=[4,5,33],NMX=30,DS=-0.01,DSMAX=1.0,UZR=\{33:0,-4:0\},IPSI=[13])}
\end{center} 
\begin{verbatim}
  BR    PT  TY  LAB    PAR(4)        L2-NORM    ...  PAR(5)        PAR(33)
   3    19  UZ   16   7.11774E-02   4.01890E-01 ... 1.24376E-11  -2.36702E-07
\end{verbatim}   
The output is stored in the \python variable \parf{r6}.
Hence an inclination flip was found at $\alpha=0.711774$.

Now we are ready to perform homoclinic branch switching, using
the techniques described in \cite{OlChKr:03}. 
Our first aim is to find a 2-homoclinic orbit. The
ingredients we need are: a homoclinic orbit where $n$-homoclinic orbits
are close by, and the solution to the adjoint equation to
obtain the Lin vector. Since both ingredients are there, we can now
continue in $\mu$, $\varepsilon_1$ and $T_1$, to obtain the initial
Lin gap. Recall from Chapter~\ref{ch:HomCont} that the Lin gaps 
$\varepsilon_i$ correspond to
\parf{PAR(20+i*2)} and the time intervals $T_i$ 
correspond to \parf{PAR(21+i*2)}. We stop when
$\varepsilon_1=0.2$. We need to specify \parf{ITWIST=2}, to tell 
{\cal HomCont} we
aim to find a 2-homoclinic orbit, so that it will split it up in three
parts with two potential Lin gaps. We effectively have a 9-dimensional
system at this point.
\begin{center}
\commandf{r7=run(r6('UZ1'),ICP=[21,22,5],NMX=300,NPR=10,UZR=\{-22:0.2\},ISTART=-2,IPSI=[])}\\
\commandf{save(r7,'7')}
\end{center} 
\begin{verbatim}
  BR    PT  TY  LAB    PAR(21)       L2-NORM    ...  PAR(22)       PAR(5)     
   3    10       18   3.45897E+01   4.46818E-01 ... 7.87712E-07  -1.55885E-11
   3    20       19   2.73699E+01   4.46818E-01 ... 2.91119E-05  -1.63974E-09
   3    30       20   1.73720E+01   4.46817E-01 ... 4.42273E-03  -3.10167E-05
   3    38  UZ   21   1.01451E+01   4.46796E-01 ... 2.00000E-01  -1.48615E-02
\end{verbatim}
The output is stored in \filef{b.7}, \filef{s.7}  and \filef{d.7}.
Here we see that $T_1$, the time it takes to make the first loop with
respect to the Poincar\'e section, decreases. This is illustrated in
Figure~\ref{broken}. Next we are ready to close this gap, by continuing
in $\alpha$, $\mu$, and $\varepsilon_1$, while keeping $T_1$ at a
constant value.
\begin{figure}[htb]
\begin{center}
\begin{picture}(400,180)
\put(0,0){
\put(157,148){(a)}
\includegraphics[scale=0.5]{include/loop}}
\put(200,0){
\put(157,148){(b)}
\includegraphics[scale=0.5]{include/broken}}
\end{picture}
\caption{Behaviour of the second piece of the
`broken homoclinic orbit' when creating a Lin gap (a).
Projection of the ``broken homoclinic orbit''
onto the $(x,y)$-plane, where $\varepsilon_1=0.2$. To include all the
pieces necessary to obtain this
figure, the ``X'' box must contain [U(1),U(4),U(7)]
and the ``Y'' box must contain [U(2),U(5),U(8)] (b).}
\label{broken}
\end{center}
\end{figure}
\begin{center}
\commandf{r8=run(r7,ICP=[4,5,22],NPR=310,DS=0.01,DSMAX=0.01,UZR=\{-22:0.0,4:0.074\})} \\
\commandf{r6=r6+r8}
\end{center} 
\begin{verbatim}
  BR    PT  TY  LAB    PAR(4)        L2-NORM    ...   PAR(5)        PAR(22)    
   3     3  UZ   22   7.40000E-02   4.46781E-01 ... -1.43162E-02   1.93746E-01
   3    32  UZ   23   1.98414E-01   4.46590E-01 ... -6.05495E-03   2.29300E-06
\end{verbatim}
The output is appended to the \python variable \parf{r6}.
Now we have obtained a 2-homoclinic orbit at label 23. However, the
homoclinic orbit is still split in three parts. We can switch back to
a normal orbit by setting \parf{ITWIST} back to 0 and continuing in the usual
way. Here we continue back to the inclination flip point in $\alpha$
and $\mu$.
\begin{center}
\commandf{r9=run(r8,ICP=[4,5],NMX=30,DS='-',DSMAX=0.1,UZR=\{4:0.15\},ISTART=1,ITWIST=0)} \\
\commandf{r6=r6+r9}
\end{center} 
\begin{verbatim}
  BR    PT  TY  LAB    PAR(4)        L2-NORM    ...   PAR(5)     
   3     7  UZ   24   1.50000E-01   4.94490E-01 ... -3.60248E-03
   3    30  EP   25   7.61403E-02   4.98746E-01 ... -2.64847E-06
\end{verbatim}
So the 2-homoclinic orbit converges back to the 1-homoclinic orbit at
the inclination flip bifurcation.
The output is appended to the python variable \parf{r6}.
The resulting 2-homoclinic orbits can be seen using
\begin{center}
\commandf{plot(r6) }
\end{center} 
and is depicted in Figure~\ref{hom2}(a).
\begin{figure}[htb]
\begin{center}
\begin{picture}(400,180)
\put(0,0){
\put(157,148){(a)}
\includegraphics[scale=0.5]{include/hom2}}
\put(200,0){
\put(157,148){(b)}
\includegraphics[scale=0.5]{include/hom3}}
\end{picture}
\caption{The 2-homoclinic orbit as $a$ is changed (a).
The two different 3-homoclinic orbits (b).}
\label{hom2}
\end{center}
\end{figure}

Next, we aim to find a 3-homoclinic orbit. To do so, we
restart at the inclination flip point at label 16 and set
\parf{ITWIST=3}. Moreover, we need to continue in one more
gap, $\varepsilon_2$=\parf{PAR(24)} and, once again, stop
when $\varepsilon_1$=\parf{PAR(22)=0}. Note that the 
dimension of the boundary value problem we continue
is now equal to 12. This is not to be confused with the setting
of the \AUTO constant \parf{NDIM=3}, because {\cal HomCont} handles this
internally.
\begin{center}
\commandf{r10=run(r6('UZ1'), ICP=[21,22,24,5], NMX=300, NPR=10, 
  UZR=\{-22:0.2\}, ISTART=-3, IPSI=[])} \\
\commandf{save(r10,'10') }
\end{center} 
\begin{verbatim}
  BR    PT  TY  LAB    PAR(21)    ...   PAR(22)       PAR(24)       PAR(5)     
   3    10       26   3.45896E+01 ...  7.87894E-07   6.42157E-07  -1.06346E-11
   3    20       27   2.73699E+01 ...  2.91126E-05   6.51591E-07  -1.63655E-09
   3    30       28   1.73719E+01 ...  4.42289E-03   1.44090E-04  -3.10188E-05
   3    38  UZ   29   1.01451E+01 ...  2.00000E-01   6.97445E-02  -1.48615E-02
\end{verbatim}
The output is stored in \filef{b.10}, \filef{s.10}  and \filef{d.10}.
Now we need to subsequently close the Lin gaps. Our strategy is to
keep $T_1$ fixed. We first continue in $\alpha$, $\mu$,
$\varepsilon_1$ and $\varepsilon_2$ until $\varepsilon_1=0$.
\begin{center}
\commandf{r11=run(r10,ICP=[4,5,22,24],NPR=310,DS=0.01,DSMAX=0.01,UZR=\{-22:0.0,4:0.082\})} \\
\commandf{r6=r6+r11}
\end{center} 
\begin{verbatim}
  BR    PT  TY  LAB    PAR(4)     ...   PAR(5)        PAR(22)       PAR(24)
   3     6  UZ   30   8.20000E-02 ... -1.29790E-02   1.76995E-01   6.37184E-02
   3    32  UZ   31   1.98414E-01 ... -6.05495E-03   2.30717E-06   3.62449E-02
\end{verbatim}
The output is appended to the \python variable \parf{r6}.
Note that this continuation is very similar to the one where we found
a 2-homoclinic orbit. In fact we have now found a 2-homoclinic orbit
(numerically) followed by a `broken' 1-homoclinic orbit; only the mesh
is not aligned.

The next step is to close the gap corresponding to $\varepsilon_2$ to
obtain a 3-homoclinic orbit. We replace the continuation parameter
$\varepsilon_1$ by $T_2$, because $T_2$ (\parf{PAR(23)})
still has to be decreased from
its high value (35) and $\varepsilon_1$ needs to stay at 0.
\begin{center}
\commandf{r12=run(r11,ICP=[4,5,23,24],NMX=32,NTST=40,DS=-1,DSMAX=1,
  UZR=\{24:0,4:0.18\})}\\
\commandf{r6=r6+r12}
\end{center} 
\begin{verbatim}
  BR    PT  TY  LAB    PAR(4)     ...   PAR(5)        PAR(23)       PAR(24)
   3    16  UZ   32   1.98395E-01 ... -6.05536E-03   2.01311E+01   1.82491E-08
   3    24  UZ   33   1.80000E-01 ... -6.50293E-03   1.27554E+01  -3.14294E-02
   3    30  UZ   34   1.66990E-01 ... -6.89269E-03   9.41745E+00  -1.03179E-06
   3    32  EP   35   1.78172E-01 ... -6.55364E-03   9.50300E+00  -7.20367E-02
\end{verbatim}
The output is appended to the \python variable \parf{r6}.
Note that we have found two zeros of \parf{PAR(24)}, at labels 32 and
34, respectively. The two zeros
correspond to two different 3-homoclinic
orbits, which, when followed from periodic orbits, both emanate from
from the same saddle-node bifurcation.
These two 3-homoclinic orbits are depicted in Figure~\ref{hom2}(b).
We can follow both of these back to the inclination flip point, by
setting \parf{ITWIST} back to 0:
\begin{center}
\commandf{r13=run(r6('UZ7'), ICP=[4,5], NMX=30, DS=-0.01, DSMAX=0.1,
  UZR=\{4:0.13\}, ISTART=1, ITWIST=0)}\\
\commandf{r6=r6+r13}
\end{center} 
\begin{verbatim}
  BR    PT  TY  LAB    PAR(4)        L2-NORM    ...   PAR(5)     
   3    13  UZ   36   1.29999E-01   5.04807E-01 ... -2.33902E-03
   3    30  EP   37   9.27258E-02   5.06560E-01 ... -2.76788E-04
\end{verbatim}
\begin{center}
\commandf{r14=run(r6('UZ9'), ICP=[4,5], NMX=30, DS=-0.01, DSMAX=0.1,
  UZR=\{4:0.145\}, ISTART=1, ITWIST=0)} \\
\commandf{r6=r6+r14}
\commandf{save(r6,'6')}
\end{center}
\begin{verbatim}
  BR    PT  TY  LAB    PAR(4)        L2-NORM    ...   PAR(5)     
   3     7  UZ   38   1.45000E-01   5.47347E-01 ... -4.79400E-03
   3    30  EP   39   8.39399E-02   5.52605E-01 ... -7.36611E-05
\end{verbatim}
All the combined appended output is saved to \filef{b.6}, \filef{s.6}
and \filef{d.6}.
The bifurcation diagram and the paths we followed when closing the Lin
gaps are depicted in Figure~\ref{parspace}. It is possible and
straightforward to obtain $4, 5, 6, \dots$-homoclinic orbits by 
extending the above strategy.
\begin{figure}[htb]
\begin{center}
\includegraphics[scale=0.5]{include/parspace}
\caption{Parameter space diagram near an inclination flip. 
The curve
through label 17 corresponds to a 1-homoclinic orbit. 
The opening of the Lin gaps occurs along the vertical line from
label 16 to label 23. The curves
through labels 23 and 30 denote the path that is followed when
closing the Lin gaps. The (approximately overlaid)
curves though labels 25 and 35 correspond to the 
2- and one of the 3-homoclinic orbits.
Finally, the curve through label 37 corresponds to the other
3-homoclinic orbit, which was obtained for \parf{PAR(23)}=$T_2=12.03201$.}
\label{parspace}
\end{center}
\end{figure}

\section{ Branch switching for a Shil'nikov type homoclinic orbit in
the FitzHugh-Nagumo equations.}

The FitzHugh-Nagumo (FHN) equations \cite{FitzH:61,NaArYo:62} 
are a simplified version of the
Hodgkin-Huxley equations \cite{HoHu:52}. 
They model nerve axon dynamics and are given by

\begin{equation}
\begin{split}
u_t&=u_{xx}-f_a(u)-w, \\
w_t&=\epsilon(u-\gamma w),
\end{split}
\label{fhnpde}
\end{equation}
where
\[
f_a(u) = u (u-a)(u-1).
\]

Travelling wave solutions of the form $(u,w)(x,t)=(u,w)(\xi)$, where
$\xi=x+ct$ are solutions of the following ODE system:

\begin{equation}
\begin{split}
\dot u &= v,\\
\dot v &= c v + f_a(u) + w,\\
\dot w &= \frac{\epsilon}{c} (u - \gamma w).
\end{split}
\label{fhnode}
\end{equation}
In particular we consider solitary wave solutions of \eqref{fhnpde}.
These correspond to orbits homoclinic to $(u,v,w)=0$ in system \eqref{fhnode}.
In our numerical example we keep $\gamma=0$.

We aim to find a $2$-homoclinic orbit at a Shil'nikov bifurcation.
All the commands given here are in the file fnb.auto.
First we obtain a homoclinic orbit using a homotopy technique (see
\citeasnoun{FrDoMo:94}), using \parf{ISTART=3}, for the parameter 
values $c=0.21, a=0.2, \epsilon=0.0025$.

\begin{center}
\commandf{demo('fnb') }\\
\commandf{r1 = run('fhn',sv='1')}
\end{center}

Among the output we see:
\begin{verbatim}
  BR    PT  TY  LAB     PERIOD       L2-NORM    ...   PAR(17)
   1    21  UZ    4   2.91921E+01   2.38053E-01 ...  2.37630E-11
\end{verbatim}
and a zero of \parf{PAR(17)} means that a zero of an artificial parameter has
been located and the right-hand end point of the corresponding
solution belongs to the plane that is tangent to the stable manifold
at the saddle. This point still needs to come closer to the
equilibrium, which we can achieve by further increasing the period to
300, while keeping \parf{PAR(17)} at 0:
\begin{center}
\commandf{r2 = run(r1('UZ1'),c='fhn.2',sv='2')}
\end{center}
\begin{verbatim}
  BR    PT  TY  LAB     PERIOD       L2-NORM    ...   PAR(2)
   1   189  UZ   11   3.00000E+02   7.37932E-02 ...  1.79286E-01
\end{verbatim}

Next we stop using the homotopy technique and increase the period even
further, to 1000.
\begin{center}
\commandf{r3 = run(r2('UZ1'),c='fhn.3',sv='3')}
\end{center}
\begin{verbatim}
  BR    PT  TY  LAB     PERIOD       L2-NORM    ...   PAR(2)
   1    80  UZ   14   1.00000E+03   4.04183E-02 ...  1.79286E-01
\end{verbatim}

A continuation in \parf{PAR(2)}=$a$ and \parf{PAR(1)}=$c$ needs to be 
performed to arrive
at the place where we wish to find a 2-homoclinic orbit: $a=0$. At the
same time we monitor \parf{PAR(22)} to locate Belyakov points.
\begin{center}
\commandf{r4 = run(r3('UZ1'),c='fhn.4',sv='4')}
\end{center}
\begin{verbatim}
  BR    PT  TY  LAB    PAR(2)        L2-NORM    ...   PAR(1)        PAR(22)
   1     6  UZ   16   1.31812E-01   3.28710E-02 ...  2.17166E-01  -6.31253E-06
   1    23  UZ   20  -8.55398E-08   1.56158E-02 ...  2.74218E-01  -9.88772E-02
\end{verbatim}
Hence, there exists a Belyakov point at $(a,c)=(0.131812,0.21766)$.
At label 19 we have a lower value of $a$ than at the Belyakov point,
and by inspection of the file
\filef{d.4} we can observe that the equilibrium has one positive
eigenvalue and a complex conjugate pair of eigenvalues with negative
real part, and conclude that this orbit is of Shil'nikov type.
Before starting the homoclinic branch switching, we calculate
the adjoint to obtain a `Lin vector':
\begin{center}
\commandf{r5 = run(r4('UZ5'),c='fhn.5',sv='5')}
\end{center}
\begin{verbatim}
  BR    PT  TY  LAB    PAR(9)        L2-NORM    ...   PAR(3)     
   1     2  EP   29  -1.00000E+00   1.56158E-02 ...  2.50000E-03
\end{verbatim}
Next, we continue in the time $T_1$ (\parf{PAR(21)}), the gap
$\varepsilon_1$ (\parf{PAR(22)}) and $c$ (\parf{PAR(1)}), 
and by setting \parf{ISTART}=-2
we try to locate a 2-homoclinic orbit:
\begin{center}
\commandf{r6 = run(r5,c='fhn.6',sv='6')}
\end{center}
In fact we find many of them, exactly as is predicted by the theory:
\begin{verbatim}
  BR    PT  TY  LAB    PAR(21)    ...   PAR(1)        PAR(22)
... 
   1   174  UZ   45   1.64799E+02 ...  2.74218E-01  -3.44422E-11
   1   178  UZ   46   1.44799E+02 ...  2.74218E-01   3.29142E-14
   1   182  UZ   47   1.24854E+02 ...  2.74218E-01   1.70138E-15
   1   187  UZ   48   1.04789E+02 ...  2.74218E-01  -8.57896E-14
   1   191  UZ   49   8.49517E+01 ...  2.74218E-01   1.93804E-13
   1   196  UZ   50   6.45145E+01 ...  2.74218E-01  -2.26551E-09
\end{verbatim}
Each of these homoclinic orbits differ 
by about 20 in the value $T_1$. This is about 
the time it takes to make one half-turn close to and
around the equilibrium, so that orbits differ by the number of 
half turns around the equilibrium before a big excursion
in phase space. Note that the variation of 
$c$ is so small that it does not appear.

A plot of $T_1$ vs. $\varepsilon_1$ gives insight into how the gap
is opened and closed in the continuation process. This is depicted in 
Figure~\ref{shilgap}.
\begin{figure}[htb]
\begin{center}
\includegraphics[scale=0.5]{include/shilgap}
\caption{A plot of $\varepsilon_1$ as a function of $T_1$ 
during our computation of Shil'nikov-type two-homoclinic orbits. 
Each zero corresponds to a different orbit.}
\label{shilgap}
\end{center}
\end{figure}
We are now in a
position to continue each of these orbits as a
normal homoclinic orbit by setting \parf{ISTART=1} and
\parf{ITWIST=0}. We leave
this as an exercise to the reader.

\section{ Branch switching to a 3-homoclinic orbit in
a 5th-order Korteweg-De Vries model}

In \citeasnoun{ChGr:97} the following water wave model was considered:
\begin{equation}
\frac{2}{15}r''''-b r''+ar+\frac{3}{2}r^2-
\frac{1}{2}(r')^2+[rr']' = 0.
\label{cgode}
\end{equation}
It represents solitary-wave solutions $r(x+at)$, $r\to 0$ as $x\to
\pm\infty$ of the 5th-order PDE
\[
r_t+\frac{2}{15}r_{xxxx}-b r_{xxx}+3r r_x+2 r_x r_{xx}+r r_{xxx=0},
\]
where $a$ is the wave speed.
The ODE corresponds to a Hamiltonian system with Hamiltonian
\[ H=-\frac{1}{2}q_1^3-\frac{1}{2}a q_1^2+p_1 q_2-\frac{1}{2}b q_2^2+
\frac{15}{4}p_2^2+\frac{1}{2}q_2^2 q_1 \]
and 
\[q_1=r, \quad q_2=r', \quad p_1=-\frac{2}{15}r'''+br'-rr', \quad p_2=\frac{2}{15}r''.\]
System \eqref{cgode} is also reversible under the transformation 
\[ t \mapsto -t, (q_1,q_2,p_1,p_2)\mapsto (q_1,-q_2,-p_1,p_2),\] 
but we do not exploit the reversible structure (\parf{IREV=0}), and
instead use it as an example of Hamiltonian system.
This system exhibits an orbit flip for a reversible Hamiltonian system.
In Hamiltonian systems, homoclinic orbits are codimension-zero
phenomena, and we have to add an additional parameter $\lambda$ that breaks
the Hamiltonian structure in this system, by introducing artificial friction.
Thus, the actual system of equations that is
used for continuation is
\[\dot x=(\lambda I + J)\nabla H(x),\]
where $x=(q_1,q_2,p_1,p_2)$ and $J$ is the usual skew symmetric matrix
in $\mathbb{R}^4$.
It is now possible to continue a homoclinic orbit in {\cal HomCont} in two
parameters ($\lambda$ and either $a$ or $b$); see also
\citeasnoun{Be:90a}.

An explicit solution exists for $a=3/5(2b+1)(b-2), b\geq -1/2$, and it is
given by 
\[r(t)=3(b+\frac{1}{2})\mathrm{sech}^2\left([\frac{3}{4}(2b+1)]^{1/2}t\right).\]
It corresponds to a reversible orbit flip for $b>2$ ($a>0$) 
We start from this explicit solution, using \parf{ISTART=2}, for $a=3$ and
$b=(\sqrt{65}+3)/4$:

\begin{center}
\commandf{demo('kdv') }\\
\commandf{r1=run('kdv',sv='1')}
\end{center}
\begin{verbatim}
  BR    PT  TY  LAB    PAR(1)        L2-NORM    ...   PAR(3)     
   1     1  EP    1   3.00000E+00   5.56544E+00 ...  0.00000E+00
   1     2  EP    2   3.04959E+00   5.49141E+00 ... -4.53380E-18
\end{verbatim}
Here \parf{PAR(1)}=$a$, \parf{PAR(2)}=$b$, and
\parf{PAR(3)}=$\lambda$. We have only done a
very small continuation to give \AUTO a chance to create a good mesh
and avoid convergence problems later.
Next, we set \parf{ITWIST=1} and calculate the adjoint:
\begin{center}
\commandf{r2=run(r1,c='kdv.2',sv='2')}
\end{center}
\begin{verbatim}
  BR    PT  TY  LAB    PAR(2)        L2-NORM    ...   PAR(9)
   1     2  EP    3   2.76557E+00   5.49141E+00 ... -3.12500E-04
\end{verbatim}
We now need to move back to the orbit flip at $a=3$:
\begin{center}
\commandf{r3=run(r2,c='kdv.3',sv='3')}
\end{center}
\begin{verbatim}
  BR    PT  TY  LAB    PAR(1)        L2-NORM    ...   PAR(3)     
   1    14  UZ    5   3.00000E+00   5.47613E+00 ...  1.47725E-09
\end{verbatim}
Now all preparations are done to start homoclinic branch
switching. This is very similar to the technique used in 
Sandstede's model in Section~\ref{sec:HomCont_hbs_san}; 
to find a 3-homoclinic orbit, we open 2 Lin gaps,
until $T_1=3.5$, while also varying $\lambda$=\parf{PAR(3)}.
\begin{center}
\commandf{r4=run(r3('UZ2'),c='kdv.4',sv='4')}
\end{center}
\begin{verbatim}
  BR    PT  TY  LAB    PAR(3)     ...   PAR(21)       PAR(22)       PAR(24)
   1    13        8   5.85315E-10 ...  1.65474E+01  -9.20183E-08  -6.11537E-07
   1    23  UZ    9   1.52986E-09 ...  9.85223E+00  -6.68578E-12   2.01956E-07
   1    26       10   4.09273E-09 ...  6.87525E+00   2.68679E-07   7.64502E-07
   1    33  UZ   11   2.15483E-06 ...  3.49999E+00   7.94022E-04   3.99104E-04
\end{verbatim}
We then look for an orbit with $a<3$ and close the gap corresponding 
to $\varepsilon_1$=\parf{PAR(22)}, for decreasing $a$.
\begin{center}
\commandf{r5=run(r4,c='kdv.5',sv='5')}
\end{center}
\begin{verbatim}
  BR    PT  TY  LAB    PAR(2)     ...   PAR(3)        PAR(22)       PAR(24)
   1    10       12   2.57977E+00 ...  2.15713E-06   7.65450E-04   3.82670E-04
   1    13  UZ   13   2.32044E+00 ...  3.86701E-11   1.13817E-10   1.58675E-08
   1    20  EP   14  -1.47788E-01 ... -9.46232E-04  -7.53666E-01  -3.43203E-01
\end{verbatim}
and finally close the gap corresponding to $\varepsilon_2$=\parf{PAR(24)},
\begin{center}
\commandf{r6=run(r5('UZ1'),c='kdv.6',sv='6')}
\end{center}
\begin{verbatim}
  BR    PT  TY  LAB    PAR(2)     ...   PAR(3)        PAR(23)       PAR(24)
   1    23  UZ   15   2.32044E+00 ...  3.30393E-12   1.48758E+01  -2.30540E-10
   1    35       16   2.31894E+00 ... -2.15192E-08   7.69389E+00  -1.07760E-05
   1    51  UZ   17   2.33846E+00 ...  2.57829E-07   3.48152E+00   1.29755E-04
   1    58  UZ   18   3.08085E+00 ...  2.28299E-12   3.50004E+00  -1.62266E-10
\end{verbatim}
so that a three-homoclinic orbit is found. Here the zero at label
17 is the one we are looking for. Label 15 is a false positive since
$T_2=PAR(23)$ is still too high. At label 18, $a$=\parf{PAR(1)} 
has changed
considerably to the extend that $a>3$ and a second 3-homoclinic orbit 
is found. Note that for all zeros of \parf{PAR(24)}=$\varepsilon_2$, the
parameter $\lambda$=\parf{PAR(3)} is also zero (within \AUTO accuracy), 
which it has to be to remain
within the original Hamiltonian system.
Setting \parf{ISTART=1}, a normal ``trivial'' continuation (with \parf{NMX=1})
of the orbit corresponding to label 17
lets {\cal HomCont} produce a proper concatenated
3-homoclinic orbit:
\begin{center}
\commandf{r7=run(r6('UZ2'),c='kdv.7',sv='7')}
\end{center}
\begin{verbatim}
  BR    PT  TY  LAB    PAR(2)        L2-NORM    ...   PAR(3)     
   1     1  EP   20   2.33846E+00   7.50835E+00 ...  2.57829E-07
\end{verbatim}
This 3-homoclinic orbit is depicted in Figure~\ref{kdv3hom}.
\begin{figure}[htb]
\begin{center}
\includegraphics[scale=0.5]{include/kdv3hom}
\caption{A 3-homoclinic orbit in a 5th-order Hamiltonian 
Korteweg-De Vries model.}
\label{kdv3hom}
\end{center}
\end{figure}

%==============================================================================
%==============================================================================


\bibliography{include/auto} \label{sec:bibliography}


\end{document}