Here you can find some m-files that are not posted in 'Lectures' part, as well as the existing m-files with commentaries. To see the commentary, type

>> help filename

in Matlab command window. (here 'filename' should be replaced by actual name, for instance, midp).

**Disclaimer:** These files are provided "as is", without warranties of any kind.

Here is a user-defined function, which can be modified and used as an input to the numerical integration or differentiation subroutines below: myfunc.m

Finite difference formulas for numerical differentiation:

- Two-point forward difference formula for first derivative: d1fd2p.m
- Three-point centered-difference formula for first derivative: d1cd3p.m
- Three-point centered-difference formula for second derivative: d2cd3p.m
- Two-point forward difference formula for first derivative, varying h: d1fd2p_varh
- Three-point centered-difference formula for first derivative, varying h: d1cd3p_varh.m
- Three-point centered-difference formula for second derivative, varying h: d2cd3p_varh.m

Composite Newton-Cotes rules for numerical integration:

- Trapezoid rule: trap.m
- Simpson's rule: simp.m
- Newton's rule: newt.m
- Boole's rule: boole.m
- Midpoint rule: midp.m
- Two-point open rule: mid2p.m
- Three-point open rule: mid3p.m

More advanced algorithms for numerical integration:

- Romberg integration: romberg.m
- Adaptive trapezoid method (uses trap.m above): adaptrap.m

Some fixed-stepsize Runge-Kutta type solvers for initial value problems:

- Euler's method for scalar equations: euler1.m
- Heun's method for scalar equations: heun1.m
- The midpoint method for scalar equations: midpoint1.m
- (General) Euler's method: euler.m
- (General) Heun's method: heun.m
- The (general) midpoint method: midpoint.m
- Runge-Kutta method of order 4: rk4.m

One step at a time:

- One step of Euler's method: eulerstep.m
- One step of Heun's method: heunstep.m
- One step of the midpoint method: midpointstep.m
- One step of Runge-Kutta method of order 4: rk4step.m
- A fixed-stepsize solver that can use any of the above as steps: solver1.m

Some examples of modeling and simulation by IVPs:

- Pendulum (the bug is fixed by Matt Comber): pend.m
- Two-body problem (modification of the program for one-body problem): orbit2.m

Variable step-size (aka adaptive) methods:

- Runge-Kutta-Fehlberg order 4/order 5 embedded pair: rkf45.m

Implicit methods:

- Backward Euler with Newton's method as a solver (fixed step-size): beuler.m

Equation solvers:

- A simple implementation of Newton's method: newton.m
- A simple implementation of the secant method: secant.m

Multistep methods:

- Adams-Bashforth 4-step method: ab4.m
- Adams-Bashforth / Adams-Moulton predictor-corrector pair of order 4: abm4.m

Shooting methods for 2nd order (Dirichlet) boundary value problems:

- Linear shooting method (with fixed stepsize IVP solvers): linshoot.m
- Shooting method using bisection (with fixed stepsize IVP solvers): bisectshoot.m
- Shooting method using bisection (with Runge-Kutta-Fehlberg 4/5 variable stepsize solver): rkf45bisectshoot.m

Finite difference methods for 2nd order (Dirichlet) boundary value problems: