A Byte of PhysicsLogo

Force models as functions

A force law says how a force depends on the situation. A constant push, spring force, and drag force should be separate functions, not branches scattered through a renderer.

Think like a programmer

A force model is a dependency you can pass into an integrator. It accepts state and returns a vector, so you can unit-test it at known positions and replace it without rewriting the update loop.

Model checklist

Inputs
Position, velocity, time, and model parameters.
State
The body state supplied to each force function.
Rule
Evaluate every force model and sum outputs.
Output
Net force for one update.
Check
A constant force returns the same vector for every valid state.

Net force becomes acceleration

Change an applied force and mass. Friction stays at 2 N to the left, so only net force changes velocity.

Applied force 8 N; net force 6.0 N; acceleration 3.00 m/s².

type ForceModel = (state: BodyState, timeSeconds: number) => Vector2;
const constantPush: ForceModel = () => vector(8, 0);

Try this experiment

Prediction: Changing mass affects acceleration, not the value returned by a constant force model.

Keep applied force fixed while moving the mass control. Identify which function output is unchanged and which derived value changes.

Where this model breaks

A simple function can still omit important effects. Drag needs velocity and a regime; springs need a reference length; contact forces can require a constraint solve instead of one direct formula.

Summary

Write force laws as small pure functions. Sum their outputs, then connect the result to motion in a separate update step.

Glossary

Self-check

  1. What should a force-model function return?
  2. Why is a constant force easy to test?
  3. Which state does drag need?

Sources

Model contract

Treat the lesson as a small function before treating it as a fact to memorize. Give every value a unit, keep only the state needed for the next step, and make the output easy to inspect.

\[\text{observable output} = f(\text{inputs},\,\text{state})\]
Inputs
Quantities you set or measure, with units and useful bounds.
State
Values the program must retain to reproduce the next result.
Rule
The relationship or update that turns inputs and state into a result.
Check
A known limit, unit check, invariant, or measured result that can expose a bad model.

Implement the idea as a model

For Force Models as Functions, write down the quantities you can control, the values your program must retain, and the result a reader could inspect. In Forces and Laws of Motion, the useful program is not the drawing: it is the smallest explicit model that makes a prediction you can test.

Guided experiment

Prediction: changing one declared input while holding the others fixed should change only the outputs that the model connects to that input. Choose one input, predict the direction of change, then check a limiting case such as zero, a symmetric arrangement, or a familiar low-speed or small-change approximation.

Where this model breaks

This lesson is a teaching model, not a complete simulator. Before using it outside the stated question, check which interactions, scales, uncertainties, boundary conditions, and measurement limits it leaves out.

Summary

Treat Force Models as Functions as a contract: named inputs and units enter a rule, the rule produces an observable result, and a known limit or invariant checks whether the implementation deserves trust.

Glossary

  • Input: a measured value or chosen parameter supplied to a model.
  • State: the smallest set of values needed to continue or reproduce a model.
  • Validation: comparing an output with a known result, limit, invariant, or measurement.

Self-check

  1. Which values are inputs, and which values must remain state?
  2. What observable result would tell you the model is behaving as expected?
  3. Which assumption would you test first before applying the model to a real system?

Model review: turn Force Models as Functions into a test

Treat force laws as functions of state, position, and time so simulations can swap and test them independently.

  1. Name the inputs and units that the forces and laws of motion model needs.
  2. Separate the state you must keep from values you can calculate when needed.
  3. Write one rule that maps the current state and inputs to an observable result.
  4. Choose a limiting case, unit check, invariant, or known result before trusting an output.
  5. State one assumption you would change before using this simplified model for a real decision.

Share to: