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.

  1. --cp2.zip : Ch. 2 zip file, Aug. 29, 2015
  2. --cp2.pdf : Ch. 2, Aug. 29, 2015, Maxima 5.31.0, R 3.0.2, 71 pages
  3. --cp2.tex : Ch. 2 Latex code file, Aug. 29, 2015
  4. --k2util.mac : Maxima utility functions for Ch. 2, Aug. 29, 2015
  5. --myode.mac : Maxima code for Ch. 2 , Aug. 29, 2015, Maxima 5.31
  6. --myode.R : R code for Ch. 2, Aug. 29, 2015, R 3.0.2
  7. --myrkf45.mac : rkf45 Adaptive Runge Kutta Maxima code, Aug. 29, 2015, Maxima 5.31


Chapter 2 Topics

  1. The Euler Method, Truncation Errors, Round-off Errors, Instability
  2. 4th Order Runge-Kutta Code for R and Maxima
  3. The Maxima Methods rk and rkf45
  4. The R package deSolve and Use of ode
  5. Solving O.D.E.'s with External Forcing Data
  6. Integrating O.D.E.'s with Discontinuous Derivatives
  7. Integrating O.D.E.'s with Discontinuous Dependent Variables Using R
    1. Events Specified with a data.frame
    2. Intravenous Drug Injection Model
    3. Using an Event Function at Specified Times
    4. Using an Event Function when a Root Condition is Satisfied
    5. 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.

  1. --example2.pdf : Example 2, Aug. 28, 2015, Maxima 5.31, R 3.0.2, 25 pages
  2. --example2.tex : Example 2 Latex code file, Aug. 28, 2015
  3. --example2.R : R code for Example 2, Aug. 28, 2015, R 3.0.2
  4. --example2.mac : Maxima code for Example 2 , Aug. 28, 2015, Maxima 5.31
  5. --hhplota.R : R code for Example 2 , Aug. 28, 2015, R 3.0.2
  6. --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.

  1. --project2.pdf : Project 2, Aug. 25, 2015, Maxima 5.31.2, R 3.0.2, 27 pages
  2. --project2.tex : Project 2 Latex code file, Aug. 25, 2015
  3. --project2.R : R code for Project 2, Aug. 25, 2015, R 3.0.2
  4. --project2.mac : Maxima code for Project 2 , Aug. 25, 2015, Maxima 5.31
  5. --project2.zip : zip file contains all files for Project 2, Aug. 25, 2015