Unit 3: Advanced Numerical Methods (Lab: PHYDSC354P)

Table of Contents

1. Laboratory Objectives

The objective of this final unit is to handle Dynamic Systems. You will learn to solve time-dependent physical equations, such as those describing radioactive decay, pendulum motion, or circuit transients, using advanced numerical algorithms.

2. Solving Ordinary Differential Equations (ODEs)

Most laws of physics are expressed as differential equations (e.g., F = m (d2x) / (dt2)). Numerical methods allow us to find the state of a system at any time t by stepping through time in small increments (h).

3. Euler and Modified Euler Methods

Euler's Method is the simplest numerical procedure for solving ODEs. It assumes the slope of the function is constant over the interval h.

Formula: yn+1 = yn + h · f(xn, yn)

Modified Euler improves accuracy by taking the average of the slopes at the beginning and the end of the interval.

4. Fourth-Order Runge-Kutta (RK4) Method

The RK4 method is the "gold standard" for solving ODEs in undergraduate physics. It provides high accuracy by calculating four different slopes (k1, k2, k3, k4) and taking their weighted average.

# RK4 Step implementation k1 = h * f(x, y) k2 = h * f(x + 0.5*h, y + 0.5*k1) k3 = h * f(x + 0.5*h, y + 0.5*k2) k4 = h * f(x + h, y + k3) y = y + (k1 + 2*k2 + 2*k3 + k4) / 6

5. Monte Carlo Simulations

Monte Carlo methods use random sampling to obtain numerical results. In physics, this is used to simulate stochastic processes or calculate complex integrals.

6. Curve Fitting and Least Squares Method

Experimental data points often have "noise." Least Squares Fitting finds the best-fit line (or curve) that minimizes the sum of the squares of the vertical deviations between each data point and the curve.

from scipy.optimize import curve_fit # Finds optimal parameters for a user-defined function popt, pcov = curve_fit(linear_func, x_data, y_data)

Lab Exam Focus Corner

Frequently Asked Questions

Common Mistakes

Practical Tips

Tip: Always plot your numerical solution against the Analytical Solution (if it exists). This "Validation Step" is the only way to prove your code is working correctly.