Computational Physics with Maxima or R
Ch. 2 Initial Value Problems
Ted Woollett
A variety of initial value problems are solved using both R and Maxima.
Homemade codes for the Euler method and the classical fourth order Runge-Kutta method are demonstrated with numerous examples.
The standard Maxima methods rk and rkf45 are discussed, and the R deSolve package ode method is extensively discussed with many examples.
Finally, methods for solving initial value problems in which the derivatives are discontinuous and in which the dependent variables are discontinuous are discussed.
- --cp2.zip : Ch. 2 zip file, Aug. 29, 2015
- --cp2.pdf : Ch. 2, Aug. 29, 2015, Maxima 5.31.0, R 3.0.2, 71 pages
- --cp2.tex : Ch. 2 Latex code file, Aug. 29, 2015
- --k2util.mac : Maxima utility functions for Ch. 2, Aug. 29, 2015
- --myode.mac : Maxima code for Ch. 2 , Aug. 29, 2015, Maxima 5.31
- --myode.R : R code for Ch. 2, Aug. 29, 2015, R 3.0.2
- --myrkf45.mac : rkf45 Adaptive Runge Kutta Maxima code, Aug. 29, 2015, Maxima 5.31
Chapter 2 Topics
- The Euler Method, Truncation Errors, Round-off Errors, Instability
- 4th Order Runge-Kutta Code for R and Maxima
- The Maxima Methods rk and rkf45
- The R package deSolve and Use of ode
- Solving O.D.E.'s with External Forcing Data
- Integrating O.D.E.'s with Discontinuous Derivatives
- Integrating O.D.E.'s with Discontinuous Dependent Variables Using R
- Events Specified with a data.frame
- Intravenous Drug Injection Model
- Using an Event Function at Specified Times
- Using an Event Function when a Root Condition is Satisfied
- Use of a Switching Parameter as a Dependent Variable
Example 2: Surfaces of Section for the Henon-Heiles Potential
Examples of "bottom-up" programming in both R and Maxima for the trajectories and
surfaces of section for a classical particle orbiting in the Henon-Heiles
potential. This potential was first studied as a mathematical model to describe
the chaotic motion of a test star in an axisymmetric galactic mean gravitational field.
The June 3 update includes new code rk41 designed to land on the final point, providing
improved surface of section behavior.
- --example2.pdf : Example 2, Aug. 28, 2015, Maxima 5.31, R 3.0.2, 25 pages
- --example2.tex : Example 2 Latex code file, Aug. 28, 2015
- --example2.R : R code for Example 2, Aug. 28, 2015, R 3.0.2
- --example2.mac : Maxima code for Example 2 , Aug. 28, 2015, Maxima 5.31
- --hhplota.R : R code for Example 2 , Aug. 28, 2015, R 3.0.2
- --example2.zip : zip file contains all files for Example 2 , Aug. 28, 2015
Project 2: Structure of a White Dwarf Star
A pedagogical discussion of the differential equations for the mass profile m(r) and the mass density profile rho(r), assuming the cold
degenerate relativistic electron gas provides the internal pressure, and the non-degenerate heavy
nuclei provide the gravitational attraction. Both R and Maxima code are used in parallel treatments
to draw plots (for a given central density) of m(r), rho(r), kinetic energy profile k(r), gravitational energy profile u(r),
and to explore the total energy (including rest mass energy) as a function of central mass density and
the stellar mass, and to plot the stellar radius as a function of stellar mass.
- --project2.pdf : Project 2, Aug. 25, 2015, Maxima 5.31.2, R 3.0.2, 27 pages
- --project2.tex : Project 2 Latex code file, Aug. 25, 2015
- --project2.R : R code for Project 2, Aug. 25, 2015, R 3.0.2
- --project2.mac : Maxima code for Project 2 , Aug. 25, 2015, Maxima 5.31
- --project2.zip : zip file contains all files for Project 2, Aug. 25, 2015