Skip to content
Tutorials Center
My learning

Topics

Lesson 2 of 47 Β· Getting Started

What Is Computational Physics?

Learn what computational physics is, how it sits beside theory and experiment, and the model, algorithm, code and check loop behind every trustworthy simulation.

For most of history, physics had two pillars. Theory wrote laws as equations and solved them with pencil and paper. Experiment measured what nature actually does. In the twentieth century a third pillar arrived: computation. Once electronic computers could add millions of numbers per second, physicists could explore equations that had no neat solution and probe systems too large, too small, too fast or too dangerous to build in a lab.

Today you meet computational physics everywhere: weather forecasts, crash tests run on a screen, the design of batteries and chips, simulations of colliding galaxies, and the data pipelines behind gravitational-wave detectors.

The computational physics loop: question, model, algorithm, code, check, with a return arrow to refine
Every simulation follows this loop. The dashed arrow is where most of the learning happens.

What you will learn

  • How computation relates to theory and experiment.
  • The five steps of the computational physics workflow.
  • The difference between verification and validation.
  • Why even a simple pendulum needs a numerical method.

Key terms

Analytical solution: an exact formula for the answer, such as y = y0 - g tΒ² / 2.

Numerical solution: an approximate answer computed by an algorithm, usually as a table of numbers.

Verification: checking that the code solves the equations correctly.

Validation: checking that the equations describe the real system well enough.

Convergence: the answer settles toward one value as the step size shrinks.

Three pillars of physics

Think of a falling stone. Theory gives y = y0 - g tΒ² / 2. Experiment drops stones and times them. Computation sits between them: it can handle the stone with air drag, a spinning stone, or a thousand stones bouncing off each other, where no tidy formula exists.

Pillar Strength Weakness
Theory Exact, gives insight Works only for simple systems
Experiment Reality is the judge Costly, limited access
Computation Handles complexity, cheap to vary Only as good as model and method

Good scientists move between all three. A simulation that disagrees with an experiment points to a flaw in the model or in the code. A theory that predicts something strange can be tested on a computer long before anyone builds an apparatus.

The five-step loop

  1. Question. State precisely what you want to know, with units: "How far does a 0.15 kg ball travel when launched at 30 m/s?"
  2. Model. Choose the physics to include. Newton's second law, with or without drag? A point mass or a spinning sphere? Every model leaves things out on purpose.
  3. Algorithm. Pick a numerical method that turns the model into a finite list of operations, such as "advance time in steps of dt."
  4. Code. Implement the algorithm clearly. NumPy arrays and small functions make errors easier to find.
  5. Check. Compare with known cases, conserved quantities and a halved step size. If the check fails, return to an earlier step.

The loop never really ends. Each pass makes the model better or the method cheaper.

Verification versus validation

These two words are easy to mix up, and the difference matters.

Verification asks: am I solving the equations right? You verify with limiting cases (turn drag off and compare with the parabola), conservation laws (energy should stay constant in a frictionless system) and convergence tests (halve the step and watch the answer settle).

Validation asks: am I solving the right equations? You validate by comparing with experiments or trusted data. A flawless solver for a wrong model still gives wrong predictions.

Verify first. If you cannot trust the code, a disagreement with experiment tells you nothing.

A pendulum that resists pencil and paper

A pendulum of length L swings with period T0 = 2Ο€ √(L/g) when the swing is tiny. Textbooks use that formula because it is easy. For a larger swing, the exact period depends on the amplitude ΞΈ0 and involves a special integral, the complete elliptic integral of the first kind K:

T = 4 √(L/g) · K(m), with m = sin²(θ0 / 2)

There is no elementary closed form for K, but a computer evaluates it instantly. The ratio T / T0 tells you how wrong the small-angle formula is.

Python How wrong is the small-angle pendulum?

Press Run (or Ctrl + Enter) to see the result here.

Program input Β· what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

At 5 degrees the two agree to about 0.05 percent. By 90 degrees the true period is about 18 percent longer. Real clocks avoid large swings for exactly this reason.

Python Plot the error of the small-angle formula

Press Run (or Ctrl + Enter) to see the result here.

Program input Β· what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Common misconceptions

"A numerical answer is just an approximation, so it is less scientific." Analytic formulas are also approximations of nature (the small-angle pendulum ignores the amplitude). Numerical answers can be made as accurate as you need, with a measured error.

"Simulation replaces experiment." It does not. Simulations rest on models, and only experiments can tell whether the model is right.

Check your understanding

Quick check Β· 4 questions

of 4 answered You scored / 4 Β· perfect!

  1. 1. Which pair describes verification and validation correctly?

    Verification tests the code against the equations; validation tests the equations against reality.
  2. 2. Which check is a verification test for a frictionless pendulum code?

    Energy conservation is a property of the equations, so a drifting energy points to a numerical problem.
  3. 3. A 90 degree pendulum swing has T/T0 of about 1.18. What does that mean?

    T/T0 above 1 means the true period is longer. 1.18 means about 18 percent longer, so the formula T0 is too small.
  4. 4. Which step comes last in the loop and sends you back when it fails?

    The check step decides whether the result is trustworthy. If it fails, you refine the model, the algorithm or the code.

Summary

  • Computation is the third pillar of physics, beside theory and experiment.
  • The workflow is question, model, algorithm, code, check, and then refine.
  • Verification checks the solver against the equations; validation checks the equations against reality.
  • Even a pendulum has no elementary exact period, which is why numerical tools matter.
  • The small-angle formula is accurate only for small swings.

Next: Python and NumPy for Physics