Reliable integration of differential
equations |
This document shows how to use reliable integration for the classical
pendulum problem, within the Mathemagix
interpreter.
Pendulum vector field
Mmx] |
bit_precision := 128; significant_digits := 6; |
Mmx] |
z == analytic (ball 0.0, ball 1.0); |
Mmx] |
vector_field (v) == [ v[1], -v[2], v[1]*v[3], -v[1]*v[2] ]; |
Mmx] |
initial_conditions == [ ball 0.0, ball 1.0, ball 0.0, ball 1.0 ]; |
Mmx] |
pendulum == integrate_analytic (vector_field, initial_conditions); |
Mmx] |
significant_digits := 0; |
Mmx] |
radius pendulum[0] (0.2) |
Mmx] |
significant_digits := 15; |
Mmx] |
points == [ (0.25 * t, pendulum[0] (0.25 * t)) || t in 0 to 20 ] |
Mmx] |
include "graphix/simple_plot.mmx";
$draw_diagram ([ [Re center points[i,0],
Re center points[i,1]] | i in 0..rows points ]) |
© 2012 Joris van der Hoeven and Grégoire Lecerf
Permission is granted to copy, distribute and/or modify this document
under the terms of the
GNU General Public License. If you
don't have this file, write to the Free Software Foundation, Inc., 59
Temple Place - Suite 330, Boston, MA 02111-1307, USA.