File: maxima_49.html

package info (click to toggle)
maxima 5.21.1-2squeeze
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 94,928 kB
  • ctags: 43,849
  • sloc: lisp: 298,974; fortran: 14,666; perl: 14,325; tcl: 10,494; sh: 4,052; makefile: 2,975; ansic: 471; awk: 24; sed: 7
file content (779 lines) | stat: -rw-r--r-- 32,376 bytes parent folder | download
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
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
<html>
<!-- Created on April, 24 2010 by texi2html 1.76 -->
<!--
Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
            Karl Berry  <karl@freefriends.org>
            Olaf Bachmann <obachman@mathematik.uni-kl.de>
            and many others.
Maintained by: Many creative people <dev@texi2html.cvshome.org>
Send bugs and suggestions to <users@texi2html.cvshome.org>

-->
<head>
<title>Maxima 5.21.1 Manual: 49. dynamics</title>

<meta name="description" content="Maxima 5.21.1 Manual: 49. dynamics">
<meta name="keywords" content="Maxima 5.21.1 Manual: 49. dynamics">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="texi2html 1.76">
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
pre.display {font-family: serif}
pre.format {font-family: serif}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: serif; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: serif; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.sansserif {font-family:sans-serif; font-weight:normal;}
ul.toc {list-style: none}
body
{
    color: black;
    background: white; 
    margin-left: 8%;
    margin-right: 13%;
}

h1
{
    margin-left: +8%;
    font-size: 150%;
    font-family: sans-serif
}

h2
{
    font-size: 125%;
    font-family: sans-serif
}

h3
{
    font-size: 100%;
    font-family: sans-serif
}

h2,h3,h4,h5,h6 { margin-left: +4%; }

div.textbox
{
    border: solid;
    border-width: thin;
    /* width: 100%; */
    padding-top: 1em;
    padding-bottom: 1em;
    padding-left: 2em;
    padding-right: 2em
}

div.titlebox
{
    border: none;
    padding-top: 1em;
    padding-bottom: 1em;
    padding-left: 2em;
    padding-right: 2em;
    background: rgb(200,255,255);
    font-family: sans-serif
}

div.synopsisbox
{
    border: none;
    padding-top: 1em;
    padding-bottom: 1em;
    padding-left: 2em;
    padding-right: 2em;
     background: rgb(255,220,255);
    /*background: rgb(200,255,255); */
    /* font-family: fixed */
}

pre.example
{
    border: 1px solid gray;
    padding-top: 1em;
    padding-bottom: 1em;
    padding-left: 1em;
    padding-right: 1em;
    /* background: rgb(247,242,180); */ /* kind of sandy */
    /* background: rgb(200,255,255); */ /* sky blue */
    background-color: #F1F5F9; /* light blue-gray */
    /* font-family: "Lucida Console", monospace */
}

div.spacerbox
{
    border: none;
    padding-top: 2em;
    padding-bottom: 2em
}

div.image
{
    margin: 0;
    padding: 1em;
    text-align: center;
}

div.categorybox
{
    border: 1px solid gray;
    padding-top: 0px;
    padding-bottom: 0px;
    padding-left: 1em;
    padding-right: 1em;
    background: rgb(247,242,220);
}


-->
</style>

<link rel="icon" href="http://maxima.sourceforge.net/favicon.ico"/>
</head>

<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">

<a name="dynamics"></a>
<a name="SEC214"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="maxima_48.html#SEC213" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC215" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="maxima_48.html#SEC209" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="maxima.html#SEC_Top" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="maxima_50.html#SEC217" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="maxima.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="maxima_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="maxima_79.html#SEC331" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="maxima_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h1 class="chapter"> 49. dynamics </h1>

<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top"><a href="#SEC215">49.1 Introduction to dynamics</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC216">49.2 Functions and Variables for dynamics</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
</table>

<p><a name="Item_003a-Introduction-to-dynamics"></a>
</p><hr size="6">
<a name="Introduction-to-dynamics"></a>
<a name="SEC215"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC214" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC216" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC214" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC214" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="maxima_50.html#SEC217" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="maxima.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="maxima_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="maxima_79.html#SEC331" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="maxima_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 49.1 Introduction to dynamics </h2>

<p>The additional package <code>dynamics</code> includes several
functions to create various graphical representations of discrete
dynamical systems and fractals, and an implementation of the Runge-Kutta
4th-order numerical method for solving systems of differential equations.
</p>
<p>To use the functions in this package you must first load it with
<code>load(&quot;dynamics&quot;)</code>.
</p>
<p><b>Changes introduced in Maxima 5.12</b>
</p>
<p>Starting with Maxima 5.12, the dynamics package now uses the function
<code>plot2d</code> to do the graphs. The commands that produce graphics
(with the exception of <code>julia</code> and <code>mandelbrot</code>) now accept
any options of <code>plot2d</code>, including the option to change among the
various graphical interfaces, using different plot styles and colors,
and representing one or both axes in a logarithmic scale. The old
options <var>domain</var>, <var>pointsize</var>, <var>xcenter</var>, <var>xradius</var>,
<var>ycenter</var>, <var>yradius</var>, <var>xaxislabel</var> and <var>yaxislabel</var>
are not accepted in this new version.
</p>
<p>All programs will now accept any variables names, and not just <var>x</var>
and <var>y</var> as in the older versions. Two required parameters have
changes in two of the programs: <code>evolution2d</code> now requires a list
naming explicitely the two independent variables, and the horizontal
range for <code>orbits</code> no longer requires a step size; the range
should only specify the variable name, and the minimum and maximum
values; the number of steps can now be changed with the option
<var>nticks</var>.
</p>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Dynamical-systems">Dynamical systems</a>
 &middot;
<a href="maxima_95.html#Category_003a-Share-packages">Share packages</a>
 &middot;
<a href="maxima_95.html#Category_003a-Package-dynamics">Package dynamics</a>
</p>
</div>


<p><a name="Item_003a-Functions-and-Variables-for-dynamics"></a>
</p><hr size="6">
<a name="Functions-and-Variables-for-dynamics"></a>
<a name="SEC216"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC215" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="maxima_50.html#SEC217" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC214" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC214" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="maxima_50.html#SEC217" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="maxima.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="maxima_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="maxima_79.html#SEC331" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="maxima_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 49.2 Functions and Variables for dynamics </h2>

<p><a name="Item_003a-chaosgame"></a>
</p><dl>
<dt><u>Function:</u> <b>chaosgame</b><i> (<code>[[</code><var>x1</var>, <var>y1</var><code>]</code>...<code>[</code><var>xm</var>, <var>ym</var><code>]]</code>, <code>[</code><var>x0</var>, <var>y0</var><code>]</code>, <var>b</var>, <var>n</var>, ..., options, ...);</i>
<a name="IDX2017"></a>
</dt>
<dd><p>Implements the so-called chaos game: the initial point (<var>x0</var>,
<var>y0</var>) is plotted and then one of the <var>m</var> points
<code>[</code><var>x1</var>, <var>y1</var><code>]</code>...<code>[</code><var>xm</var>, <var>ym</var><code>]</code>
will be selected at random. The next point plotted will be on the
segment from the previous point plotted to the point chosen randomly, at a
distance from the random point which will be <var>b</var> times that segment's
length. The procedure is repeated <var>n</var> times.
</p>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Package-dynamics">Package dynamics</a>
 &middot;
<a href="maxima_95.html#Category_003a-Plotting">Plotting</a>
</p>
</div>


</dd></dl>

<p><a name="Item_003a-evolution"></a>
</p><dl>
<dt><u>Function:</u> <b>evolution</b><i> (<var>F</var>, <var>y0</var>, <var>n</var>, ..., options, ...);</i>
<a name="IDX2018"></a>
</dt>
<dd><p>Draws <var>n+1</var> points in a two-dimensional graph, where the horizontal
coordinates of the points are the integers 0, 1, 2, ..., <var>n</var>, and
the vertical coordinates are the corresponding values <var>y(n)</var> of the
sequence defined by the recurrence relation
</p><pre class="example">        y(n+1) = F(y(n))
</pre>
<p>With initial value <var>y(0)</var> equal to <var>y0</var>. <var>F</var> must be an
expression that depends only on one variable (in the example, it
depend on <var>y</var>, but any other variable can be used),
<var>y0</var> must be a real number and <var>n</var> must be a positive integer.
</p>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Package-dynamics">Package dynamics</a>
 &middot;
<a href="maxima_95.html#Category_003a-Plotting">Plotting</a>
</p>
</div>


</dd></dl>

<p><a name="Item_003a-evolution2d"></a>
</p><dl>
<dt><u>Function:</u> <b>evolution2d</b><i> (<code>[</code><var>F</var>, <var>G</var><code>]</code>, <code>[</code><var>u</var>, <var>v</var><code>]</code>, <code>[</code><var>u0</var>, <var>y0</var><code>]</code>, <var>n</var>, ..., options, ...);</i>
<a name="IDX2019"></a>
</dt>
<dd><p>Shows, in a two-dimensional plot, the first <var>n+1</var> points in the
sequence of points defined by the two-dimensional discrete dynamical
system with recurrence relations
</p><pre class="example">        u(n+1) = F(u(n), v(n))    v(n+1) = G(u(n), v(n))
</pre>
<p>With initial values <var>u0</var> and <var>v0</var>. <var>F</var> and <var>G</var> must be
two expressions that depend only on two variables, <var>u</var> and
<var>v</var>, which must be named explicitely in a list. 
</p>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Package-dynamics">Package dynamics</a>
 &middot;
<a href="maxima_95.html#Category_003a-Plotting">Plotting</a>
</p>
</div>


</dd></dl>

<p><a name="Item_003a-ifs"></a>
</p><dl>
<dt><u>Function:</u> <b>ifs</b><i> (<code>[</code><var>r1</var>, ..., <var>rm</var><code>]</code>, <code>[</code><var>A1</var>, ..., <var>Am</var><code>]</code>, <code>[[</code><var>x1</var>, <var>y1</var><code>]</code>, ..., <code>[</code><var>xm</var>, <var>ym</var><code>]]</code>, <code>[</code><var>x0</var>, <var>y0</var><code>]</code>, <var>n</var>, ..., options, ...);</i>
<a name="IDX2020"></a>
</dt>
<dd><p>Implements the Iterated Function System method. This method is similar
to the method described in the function <code>chaosgame</code>, but instead of
shrinking the segment from the current point to the randomly chosen
point, the 2 components of that segment will be multiplied by the 2 by 2
matrix <var>Ai</var> that corresponds to the point chosen randomly.
</p>
<p>The random choice of one of the <var>m</var> attractive points can be made with
a non-uniform probability distribution defined by the weights
<var>r1</var>,...,<var>rm</var>. Those weights are given in cumulative form; for instance if there are 3 points with probabilities 0.2, 0.5 and
0.3, the weights <var>r1</var>, <var>r2</var> and <var>r3</var> could be 2, 7 and 10.
</p>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Package-dynamics">Package dynamics</a>
 &middot;
<a href="maxima_95.html#Category_003a-Plotting">Plotting</a>
</p>
</div>


</dd></dl>

<p><a name="Item_003a-julia"></a>
</p><dl>
<dt><u>Function:</u> <b>julia</b><i> (<var>x</var>, <var>y</var>, ...<var>options</var>...)</i>
<a name="IDX2021"></a>
</dt>
<dd><p>Creates a graphics file with the representation of the Julia set for the
complex number (<var>x</var> + i <var>y</var>). The parameters <var>x</var> and <var>y</var>
must be real. The file is created in the current directory or in the user's
directory, using the XPM graphics format. The program may take several
seconds to run and after it is finished, a message will be printed with
the name of the file created.
</p>
<p>The points which do not belong to the Julia set are assigned different
colors, according to the number of iterations it takes the sequence
starting at that point to move out of the convergence circle of radius
2. The maximum number of iterations is set with the option <var>levels</var>;
after that number of iterations, if the sequence is still inside the
convergence circle, the point will be painted with the color defined by
the option <var>color</var>.
</p>
<p>All the colors used for the points that do not belong to the Julia set
will have the same <var>saturation</var> and <var>value</var>, but with different
hue angles distributed uniformly between <var>hue</var> and (<var>hue</var> +
<var>huerange</var>).
</p>
<p><var>options</var> is an optional sequence of options. The list of accepted
options is given in a section below.
</p>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Package-dynamics">Package dynamics</a>
 &middot;
<a href="maxima_95.html#Category_003a-Plotting">Plotting</a>
</p>
</div>


</dd></dl>

<p><a name="Item_003a-mandelbrot"></a>
</p><dl>
<dt><u>Function:</u> <b>mandelbrot</b><i> (<var>options</var>)</i>
<a name="IDX2022"></a>
</dt>
<dd><p>Creates a graphics file with the representation of the Mandelbrot
set. The file is created in the current directory or in the user's
directory, using the XPM graphics format. The program may take several
seconds to run and after it is finished, a message will be printed with
the name of the file created.
</p>
<p>The points which do not belong to the Mandelbrot set are
assigned different colors, according to the number of iterations it
takes the sequence generated with that point to move out of the
convergence circle o radius 2. The maximum number of iterations is set with
the option <var>levels</var>; after that number of iterations, if the
sequence is still inside the convergence circle, the point will be
painted with the color defined by the option <var>color</var>.
</p>
<p>All the colors used for the points that do not belong to the Mandelbrot
set will have the same <var>saturation</var> and <var>value</var>, but with
different hue angles distributed uniformly between <var>hue</var> and
(<var>hue</var> + <var>huerange</var>).
</p>
<p><var>options</var> is an optional sequence of options. The list of accepted
options is given in a section below.
</p>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Package-dynamics">Package dynamics</a>
 &middot;
<a href="maxima_95.html#Category_003a-Plotting">Plotting</a>
</p>
</div>


</dd></dl>

<p><a name="Item_003a-orbits"></a>
</p><dl>
<dt><u>Function:</u> <b>orbits</b><i> (<var>F</var>, <var>y0</var>, <var>n1</var>, <var>n2</var>, [<var>x</var>, <var>x0</var>, <var>xf</var>, <var>xstep</var>], ...options...);</i>
<a name="IDX2023"></a>
</dt>
<dd><p>Draws the orbits diagram for a family of one-dimensional
discrete dynamical systems, with one parameter <var>x</var>; that kind of
diagram is used to study the bifurcations of a one-dimensional discrete
system.
</p>
<p>The function <var>F(y)</var> defines a sequence with a starting value of
<var>y0</var>, as in the case of the function <code>evolution</code>, but in this
case that function will also depend on a parameter <var>x</var> that will
take values in the interval from <var>x0</var> to <var>xf</var> with increments of
<var>xstep</var>. Each value used for the parameter <var>x</var> is shown on the
horizontal axis. The vertical axis will show the <var>n2</var> values
of the sequence <var>y(n1+1)</var>,..., <var>y(n1+n2+1)</var> obtained after letting
the sequence evolve <var>n1</var> iterations.
</p>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Package-dynamics">Package dynamics</a>
 &middot;
<a href="maxima_95.html#Category_003a-Plotting">Plotting</a>
</p>
</div>


</dd></dl>

<p><a name="Item_003a-rk"></a>
</p><dl>
<dt><u>Function:</u> <b>rk</b><i> (<var>ODE</var>, <var>var</var>, <var>initial</var>, <var>domain</var>)</i>
<a name="IDX2024"></a>
</dt>
<dt><u>Function:</u> <b>rk</b><i> ([<var>ODE1</var>,...,<var>ODEm</var>], [<var>v1</var>,...,<var>vm</var>], [<var>init1</var>,...,<var>initm</var>], <var>domain</var>)</i>
<a name="IDX2025"></a>
</dt>
<dd><p>The first form solves numerically one first-order ordinary differential
equation, and the second form solves a system of m of those equations,
using the 4th order Runge-Kutta method. <var>var</var> represents the dependent
variable. <var>ODE</var> must be an expression that depends only on the independent
and dependent variables and defines the derivative of the dependent
variable with respect to the independent variable.
</p>
<p>The independent variable is specified with <code>domain</code>, which must be a
list of four elements as, for instance:
</p><pre class="example">[t, 0, 10, 0.1]
</pre><p>the first element of the list identifies the independent variable, the
second and third elements are the initial and final values for that
variable, and the last element sets the increments that should be used
within that interval.
</p>
<p>If <var>m</var> equations are going to be solved, there should be <var>m</var>
dependent variables <var>v1</var>, <var>v2</var>, ..., <var>vm</var>. The initial values
for those variables will be <var>init1</var>, <var>init2</var>, ..., <var>initm</var>.
There will still be just one independent variable defined by <code>domain</code>,
as in the previous case. <var>ODE1</var>, ..., <var>ODEm</var> are the expressions
that define the derivatives of each dependent variable in
terms of the independent variable. The only variables that may appear in
those expressions are the independent variable and any of the dependent
variables. It is important to give the derivatives <var>ODE1</var>, ...,
<var>ODEm</var> in the list in exactly the same order used for the dependent
variables; for instance, the third element in the list will be interpreted
as the derivative of the third dependent variable.
</p>
<p>The program will try to integrate the equations from the initial value
of the independent variable until its last value, using constant
increments. If at some step one of the dependent variables takes an
absolute value too large, the integration will be interrupted at that
point. The result will be a list with as many elements as the number of
iterations made. Each element in the results list is itself another list
with <var>m</var>+1 elements: the value of the independent variable, followed
by the values of the dependent variables corresponding to that point.
</p>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Package-dynamics">Package dynamics</a>
 &middot;
<a href="maxima_95.html#Category_003a-Differential-equations">Differential equations</a>
 &middot;
<a href="maxima_95.html#Category_003a-Numerical-methods">Numerical methods</a>
</p>
</div>


</dd></dl>

<p><a name="Item_003a-staircase"></a>
</p><dl>
<dt><u>Function:</u> <b>staircase</b><i> (<var>F</var>, <var>y0</var>, <var>n</var>, ...options...);</i>
<a name="IDX2026"></a>
</dt>
<dd><p>Draws a staircase diagram for the sequence defined by the recurrence
relation
</p><pre class="example">        y(n+1) = F(y(n))
</pre>
<p>The interpretation and allowed values of the input parameters is the
same as for the function <code>evolution</code>. A staircase diagram consists
of a plot of the function <var>F(y)</var>, together with the line
<var>G(y)</var> <code>=</code> <var>y</var>. A vertical segment is drawn from the
point (<var>y0</var>, <var>y0</var>) on that line until the point where it
intersects the function <var>F</var>. From that point a horizontal segment is
drawn until it reaches the point (<var>y1</var>, <var>y1</var>) on the line, and
the procedure is repeated <var>n</var> times until the point (<var>yn</var>, <var>yn</var>)
is reached.
</p>
<div class=categorybox>


<p>Categories:&nbsp;&nbsp;<a href="maxima_95.html#Category_003a-Package-dynamics">Package dynamics</a>
 &middot;
<a href="maxima_95.html#Category_003a-Plotting">Plotting</a>
</p>
</div>


</dd></dl>

<p><b>Options</b>
</p>
<p>Each option is a list of two or more items. The first item is the name
of the option, and the remainder comprises the arguments for the option.
</p>
<p>The options accepted by the functions <code>evolution</code>, <code>evolution2d</code>,
<code>staircase</code>, <code>orbits</code>, <code>ifs</code> and <code>chaosgame</code> are the same as the options for
<code>plot2d</code>. In addition to those options, <code>orbits</code> accepts and
extra option <var>pixels</var> that sets up the maximum number of different
points that will be represented in the vertical direction.
</p>
<p>The following options are accepted by the functions <code>julia</code> and <code>mandelbrot</code>:
</p>
<ul>
<li>
<em>size</em> takes either one or two arguments. If only one argument is
given, the width and height of the graphic file created will be equal to
that value, in pixels. If two arguments are given, they will define the
width and height. The default value is 400 pixels for both the width and
height. If the two values are not equal, the set will appear distorted.

</li><li>
<em>levels</em> defines the maximum number of iterations, which is also
equal to the number of colors used for points not belonging to the
set. The default value is 12; larger values mean much longer processing
times.

</li><li>
<em>huerange</em> defines the range of hue angles used for the hue of
points not belonging to the set. The default value is 360,
which means that the colors will expand all the range of hues. Values
bigger than 360, will mean repeated ranges of the hue, and negative
values can be used to make the hue angle decrease as the number of
iterations increases.

</li><li>
<em>hue</em> sets the hue, in degrees, of the first color used for the
points which do not belong to the set. Its default value is 300 degrees,
which corresponds to magenta; the values for other standard colors are 0
for red, 45 for orange, 60 for yellow, 120 for green, 180 for cyan and
240 for blue. See also option <var>huerange</var>.

</li><li>
<em>saturation</em> sets the value of the saturation used for points not
belonging to the set. It must be between 0 and 1. The default is 0.46.

</li><li>
<em>value</em> sets the value of the colors used for points not belonging
to the set. It must be between 0 and 1; the higher the value, the
brighter the colors. The default is 0.96

</li><li>
<em>color</em> must be followed by three parameters that define the hue,
saturation and value, for the color used to represent the points of the
set. The default value is 0 for the three parameters, which corresponds
to black. For an explanation of the range of allowed values, see options
<var>hue</var>, <var>saturation</var> and <var>value</var>.

</li><li>
<em>center</em> must be followed by two real parameters, which give the
coordinates, on the complex plane, of the point in the center of the
region shown. The default value is 0 for both coordinates (the origin).

</li><li>
<em>radius</em> sets the radius of the biggest circle inside the square
region that will be displayed. The default value is 2.

</li><li>
<em>filename</em> gives the name of the file where the resulting graph will
be saved. The extension .xpm will be added to that name. If the file
already exists, it will be replaced by the file generated by the
function. The default values are julia for the Julia set, and mandelbrot
for the Mandelbrot set.

</li></ul>

<p><b>Examples</b>
</p>
<p>Graphical representation and staircase diagram for the sequence:
2, cos(2), cos(cos(2)),...
</p>
<pre class="example">(%i1) load(&quot;dynamics&quot;)$

(%i2) evolution(cos(y), 2, 11);

(%i3) staircase(cos(y), 1, 11, [y, 0, 1.2]);
</pre>
<p><div class="image"><img src="./figures/dynamics1.gif" alt="figures/dynamics1"></div>
<div class="image"><img src="./figures/dynamics2.gif" alt="figures/dynamics2"></div>
</p>
<p>If your system is slow, you'll have to reduce the number of iterations in
the following examples. And if the dots appear too small in your
monitor, you might want to try a different style, such as
<code>[</code><var>style</var>,<code>[</code><var>points</var>,0.8<code>]]</code>.
</p>
<p>Orbits diagram for the quadratic map, with a parameter <var>a</var>.
</p><pre class="example">        x(n+1) = a + x(n)^2
</pre>
<pre class="example">(%i4) orbits(x^2+a, 0, 50, 200, [a, -2, 0.25], [style, dots]);
</pre>
<p><div class="image"><img src="./figures/dynamics3.gif" alt="figures/dynamics3"></div>
</p>
<p>To enlarge the region around the lower bifurcation near x <code>=</code> -1.25 use:
</p><pre class="example">(%i5) orbits(x^2+a, 0, 100, 400, [a,-1,-1.53], [x,-1.6,-0.8],
             [nticks, 400], [style,dots]);
</pre>
<p><div class="image"><img src="./figures/dynamics4.gif" alt="figures/dynamics4"></div>
</p>
<p>Evolution of a two-dimensional system that leads to a fractal:
</p>
<pre class="example">(%i6) f: 0.6*x*(1+2*x)+0.8*y*(x-1)-y^2-0.9$

(%i7) g: 0.1*x*(1-6*x+4*y)+0.1*y*(1+9*y)-0.4$

(%i8) evolution2d([f,g], [x,y], [-0.5,0], 50000, [style,dots]);
</pre>
<p><div class="image"><img src="./figures/dynamics5.gif" alt="figures/dynamics5"></div>
</p>
<p>And an enlargement of a small region in that fractal:
</p>
<pre class="example">(%i9) evolution2d([f,g], [x,y], [-0.5,0], 300000, [x,-0.8,-0.6],
                  [y,-0.4,-0.2], [style, dots]);
</pre>
<p><div class="image"><img src="./figures/dynamics6.gif" alt="figures/dynamics6"></div>
</p>
<p>A plot of Sierpinsky's triangle, obtained with the chaos game:
</p>
<pre class="example">(%i9) chaosgame([[0, 0], [1, 0], [0.5, sqrt(3)/2]], [0.1, 0.1], 1/2,
                 30000, [style, dots]);
</pre>
<p><div class="image"><img src="./figures/dynamics7.gif" alt="figures/dynamics7"></div>
</p>
<p>Barnsley's fern, obtained with an Iterated Function System:
</p>
<pre class="example">(%i10) a1: matrix([0.85,0.04],[-0.04,0.85])$

(%i11) a2: matrix([0.2,-0.26],[0.23,0.22])$

(%i12) a3: matrix([-0.15,0.28],[0.26,0.24])$

(%i13) a4: matrix([0,0],[0,0.16])$

(%i14) p1: [0,1.6]$

(%i15) p2: [0,1.6]$

(%i16) p3: [0,0.44]$

(%i17) p4: [0,0]$

(%i18) w: [85,92,99,100]$

(%i19) ifs(w, [a1,a2,a3,a4], [p1,p2,p3,p4], [5,0], 50000, [style,dots]);
</pre>
<p><div class="image"><img src="./figures/dynamics8.gif" alt="figures/dynamics8"></div>
</p>
<p>To create a file named <em>dynamics9.xpm</em> with a graphical
representation of the Mandelbrot set, with 12 colors, use:
</p>
<pre class="example">mandelbrot([filename,&quot;dynamics9&quot;])$
</pre>
<p><div class="image"><img src="./figures/dynamics9.gif" alt="figures/dynamics9"></div>
</p>
<p>and the Julia set for the number (-0.55 + i 0.6) can be obtained with:
</p><pre class="example">julia(-0.55, 0.6, [levels, 36], [center, 0, 0.6], [radius, 0.3],
      [hue, 240], [huerange, -180], [filename, &quot;dynamics10&quot;])$
</pre>
<p>the graph will be saved in the file <em>dynamics10.xpm</em> and will show
the region from -0.3 to 0.3 in the x direction, and from 0.3 to 0.9 in
the y direction. 36 colors will be used, starting with blue and ending
with yellow.
</p>
<p><div class="image"><img src="./figures/dynamics10.gif" alt="figures/dynamics10"></div>
</p>
<p>To solve numerically the differential equation
</p>
<pre class="example">          dx/dt = t - x^2
</pre>
<p>With initial value x(t=0) = 1, in the interval of t from 0 to 8 and with
increments of 0.1 for t, use:
</p>
<pre class="example">(%i20) results: rk(t-x^2,x,1,[t,0,8,0.1])$
</pre>
<p>the results will be saved in the list <code>results</code>.
</p>
<p>To solve numerically the system:
</p>
<pre class="example">        dx/dt = 4-x^2-4*y^2     dy/dt = y^2-x^2+1
</pre>
<p>for t between 0 and 4, and with values of -1.25 and 0.75 for x and y at t=0:
</p>
<pre class="example">(%i21) sol: rk([4-x^2-4*y^2,y^2-x^2+1],[x,y],[-1.25,0.75],[t,0,4,0.02])$
</pre>
<p><a name="Item_003a-ezunits"></a>
</p><hr size="6">
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC214" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="maxima_50.html#SEC217" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="maxima.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="maxima_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="maxima_79.html#SEC331" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="maxima_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<p>
 <font size="-1">
  This document was generated by <em>Robert Dodier</em> on <em>April, 24 2010</em> using <a href="http://texi2html.cvshome.org/"><em>texi2html 1.76</em></a>.
 </font>
 <br>

</p>
</body>
</html>