# Finite Difference Computing with Exponential Decay Models¶

Contents:

- Finite Difference Computing with Exponential Decay Models
- Preface
- Algorithms and implementations
- Implementation
- Computer language: Python
- Making a solver function
- Integer division
- Doc strings
- Formatting numbers
- Running the program
- Plotting the solution
- Verifying the implementation
- Computing the numerical error as a mesh function
- Computing the norm of the error mesh function
- Experiments with computing and plotting
- Memory-saving implementation

- Exercises
- Analysis
- Generalizations
- Model extensions
- General first-order ODEs
- Generic form of first-order ODEs
- The \(\theta\)-rule
- An implicit 2-step backward scheme
- Leapfrog schemes
- The 2nd-order Runge-Kutta method
- A 2nd-order Taylor-series method
- The 2nd- and 3rd-order Adams-Bashforth schemes
- The 4th-order Runge-Kutta method
- The Odespy software
- Example: Runge-Kutta methods
- Example: Adaptive Runge-Kutta methods

- Exercises
- Exercise 3.1: Experiment with precision in tests and the size of \(u\)
- Exercise 3.2: Implement the 2-step backward scheme
- Exercise 3.3: Implement the 2nd-order Adams-Bashforth scheme
- Exercise 3.4: Implement the 3rd-order Adams-Bashforth scheme
- Exercise 3.5: Analyze explicit 2nd-order methods
- Project 3.6: Implement and investigate the Leapfrog scheme
- Problem 3.7: Make a unified implementation of many schemes

- Models
- Scaling
- Evolution of a population
- Compound interest and inflation
- Newton’s law of cooling
- Radioactive decay
- Chemical kinetics
- Spreading of diseases
- Predator-prey models in ecology
- Decay of atmospheric pressure with altitude
- Compaction of sediments
- Vertical motion of a body in a viscous fluid
- Viscoelastic materials
- Decay ODEs from solving a PDE by Fourier expansions
- Exercises
- Problem 4.1: Radioactive decay of Carbon-14
- Exercise 4.2: Derive schemes for Newton’s law of cooling
- Exercise 4.3: Implement schemes for Newton’s law of cooling
- Exercise 4.4: Find time of murder from body temperature
- Exercise 4.5: Simulate an oscillating cooling process
- Exercise 4.6: Simulate stochastic radioactive decay
- Problem 4.7: Radioactive decay of two substances
- Exercise 4.8: Simulate a simple chemical reaction
- Exercise 4.9: Simulate an \(n\)-th order chemical reaction
- Exercise 4.10: Simulate a biochemical process
- Exercise 4.11: Simulate spreading of a disease
- Exercise 4.12: Simulate predator-prey interaction
- Exercise 4.13: Simulate the pressure drop in the atmosphere
- Exercise 4.14: Make a program for vertical motion in a fluid
- Project 4.15: Simulate parachuting
- Exercise 4.16: Formulate vertical motion in the atmosphere
- Exercise 4.17: Simulate vertical motion in the atmosphere
- Problem 4.18: Compute \(y=|x|\) by solving an ODE
- Problem 4.19: Simulate fortune growth with random interest rate
- Exercise 4.20: Simulate a population in a changing environment
- Exercise 4.21: Simulate logistic growth
- Exercise 4.22: Rederive the equation for continuous compound interest
- Exercise 4.23: Simulate the deformation of a viscoelastic material

- Scientific software engineering
- Implementations with functions and modules
- Mathematical problem and solution technique
- A first, quick implementation
- A more decent program
- Prefixing imported functions by the module name
- Implementing the numerical algorithm in a function
- Do not have several versions of a code
- Making a module
- Example on extending the module code
- Documenting functions and modules
- Logging intermediate results

- User interfaces
- Tests for verifying implementations
- Sharing the software with other users
- Classes for problem and solution method
- Automating scientific experiments
- Exercises
- Problem 5.1: Make a tool for differentiating curves
- Problem 5.2: Make solid software for the Trapezoidal rule
- Problem 5.3: Implement classes for the Trapezoidal rule
- Problem 5.4: Write a doctest and a test function
- Problem 5.5: Investigate the size of tolerances in comparisons
- Exercise 5.6: Make use of a class implementation
- Problem 5.7: Make solid software for a difference equation

- Implementations with functions and modules
- References