---
title: Kinematics with calculus
heading: Motion profiles for motors, elevators and print heads
eyebrow: B1 · Lesson 2 · Kinematics with calculus
xp: 40
---

::: hook
A 3D printer's head, a hard drive's arm and a factory robot all have to move from one spot to another as fast as possible without exceeding their motor's limits. The controller plans a **motion profile**: speed up at the largest acceleration the motor can give, cruise at the top speed, and slow down to land exactly on target. Planning one is pure kinematics, but with accelerations that change partway through, so the constant-acceleration formulas of lesson 1 aren't enough. Calculus is: velocity is the area under acceleration, and distance is the area under velocity.
:::

::: play
- The curve is the speed of a carriage that accelerates at $a$, cruises at $v_\text{max}$ and decelerates at $a$ to stop at time $T$. The shaded area is the distance covered.
- Lower $v_\text{max}$: the cruise gets longer and the move covers less ground in the same time.
- Raise $v_\text{max}$ until the profile becomes a triangle. What limits the move now?
:::
:::

```sim plot
view: graph
x: t = 0..4 s
y: v = 0..2.2 m/s
slider: a = 0.5..4 step 0.1 = 2 m/s²
slider: vm = 0.2..2 step 0.05 = 1 m/s
slider: T = 0.5..4 step 0.1 = 2 s
plot: step(t)*step(T - t)*((a*t + a*(T - t) - abs(a*t - a*(T - t)))/2 + vm - abs((a*t + a*(T - t) - abs(a*t - a*(T - t)))/2 - vm))/2 | label: speed | fill: 0..T | samples: 800
readout: distance covered, m = step(T - 2*vm/a)*vm*(T - vm/a) + step(2*vm/a - T)*a*T^2/4 | digits: 3
readout: time to reach top speed, s = vm/a | digits: 3
```

::: predict
## A carriage accelerates at 2 m/s² up to 1 m/s, cruises, then brakes at 2 m/s² to a stop, taking 2 s in all. How far does it go?

- [ ] 2 m
- [x] 1.5 m
- [ ] 1 m
- [ ] 4 m

::: reveal
1.5 m. Reaching 1 m/s takes 0.5 s, and stopping takes another 0.5 s, leaving 1 s of cruising. The speed graph is a trapezoid: its area is $1 \times (2 - 0.5) = 1.5$ m. Cruising at top speed the whole time would give 2 m; the ramps cost half a second's worth.
:::
:::

::: nameit
## Rates and areas

Position $x(t)$, velocity $v(t)$ and acceleration $a(t)$ are linked by derivatives and integrals (A5):

$$v = \frac{dx}{dt} \qquad a = \frac{dv}{dt} \qquad v(t) = v_0 + \int_0^t a\,dt' \qquad x(t) = x_0 + \int_0^t v\,dt'$$

On graphs: velocity is the slope of the position curve, and the distance covered is the area under the velocity curve. The constant-acceleration formulas are the special case $a = $ constant:

$$v = v_0 + at \qquad x = x_0 + v_0t + \tfrac12at^2 \qquad v^2 = v_0^2 + 2a(x - x_0)$$

## Piecewise motion

When the acceleration changes in steps, apply the constant-acceleration formulas to each stretch, starting each one from where the last ended. A **trapezoidal profile** with acceleration $a$, top speed $v_\text{max}$ and distance $d$:

- ramp time $t_r = \frac{v_\text{max}}{a}$, ramp distance $\frac{v_\text{max}^2}{2a}$ each way;
- if $d > \frac{v_\text{max}^2}{a}$ the speed reaches $v_\text{max}$, and the move takes $T = \frac{d}{v_\text{max}} + \frac{v_\text{max}}{a}$;
- otherwise the profile is a **triangle** that peaks at $\sqrt{ad}$, taking $T = 2\sqrt{d/a}$.

## Changing acceleration

When $a$ varies continuously, integrate. **Jerk**, $\frac{da}{dt}$, is limited in smooth motion systems (S-curve profiles), because sudden changes in acceleration shake the machine. A velocity is largest where the acceleration passes through zero.
:::

::: example
## A carriage must move 1.5 m with $a = 2$ m/s² and $v_\text{max} = 1$ m/s. How long does the move take?

::: solution
1. **The ramps.** Each ramp takes 0.5 s and covers
   $$\frac{1^2}{2 \times 2} = 0.25\ \text{m}$$
2. **The cruise.** The remaining 1.0 m at 1 m/s takes 1 s.
3. **Total time.**
   $$0.5 + 1 + 0.5 = 2.0\ \text{s}$$
4. **Check with the formula.**
   $$\begin{aligned} T &= \frac{d}{v_\text{max}} + \frac{v_\text{max}}{a} \\ &= 1.5 + 0.5 \\ &= 2.0\ \text{s} \end{aligned}$$

**Answer:** the move takes 2.0 s.
:::
:::

::: example
## A vehicle starts from rest with acceleration $a(t) = 6 - 2t$ m/s². Find its speed and position at $t = 3$ s.

::: solution
1. **Speed.** Integrate the acceleration from rest:
   $$\begin{aligned} v &= \int_0^t (6 - 2t')\,dt' \\ &= 6t - t^2 \\ v(3) &= 9\ \text{m/s} \end{aligned}$$
2. **Position.** Integrate the speed:
   $$\begin{aligned} x &= \int_0^t (6t' - t'^2)\,dt' \\ &= 3t^2 - \frac{t^3}{3} \\ x(3) &= 27 - 9 \\ &= 18\ \text{m} \end{aligned}$$
3. **Top speed.** At $t = 3$ s the acceleration is zero, so 9 m/s is the top speed.

**Answer:** at 3 s the vehicle is at its top speed of 9 m/s and has gone 18 m.
:::
:::

::: example
## A train accelerates at 1 m/s² to 20 m/s, cruises for 60 s, then brakes at 1.25 m/s² to a stop. How far does it travel, and in what time?

::: solution
1. **Accelerating.** It takes $\frac{20}{1} = 20$ s and covers
   $$\frac{20^2}{2 \times 1} = 200\ \text{m}$$
2. **Cruising.**
   $$20 \times 60 = 1200\ \text{m}$$
3. **Braking.** It takes $\frac{20}{1.25} = 16$ s and covers
   $$\frac{20^2}{2 \times 1.25} = 160\ \text{m}$$
4. **Totals.**
   $$\begin{aligned} d &= 200 + 1200 + 160 \\ &= 1560\ \text{m} \\ t &= 20 + 60 + 16 \\ &= 96\ \text{s} \end{aligned}$$
   an average of 16.25 m/s.
5. **On a graph.** On a velocity-time graph this is a trapezoid, and the distance is its area.

**Answer:** the train travels 1560 m in 96 s.
:::
:::

::: check
given: d = 1 | 2 | 3; a = 2 | 4; v = 0.5 | 1
answer: d/v + v/a
unit: s
tolerance: 0.5%

## A carriage moves {d} m with acceleration and braking of {a} m/s² and a top speed of {v} m/s (which it reaches). How long does the move take?

::: right
Right. $\frac{d}{v_\text{max}} + \frac{v_\text{max}}{a}$ = {answer}.
:::

::: misses
- [d/v] That ignores the time lost speeding up and slowing down.
- [d/v + 2*v/a] Each ramp takes $v/a$, but during the two ramps the carriage still covers the distance of one ramp time at full speed.
- [any] Not yet. Ramp, cruise, ramp: add the three times.
:::
:::

::: check
given: d = 0.1 | 0.2; a = 5 | 10
answer: 2*sqrt(d/a)
unit: s
tolerance: 0.5%

## A short move of {d} m never reaches top speed: it accelerates at {a} m/s² for half the distance and brakes for the other half. How long does it take?

::: right
Right. Each half takes $\sqrt{d/a}$, since $\frac{d}{2} = \frac12at^2$: total {answer}.
:::

::: misses
- [sqrt(2*d/a)] That's the time if it accelerated over the whole distance without stopping.
- [sqrt(d/a)] That's one half of the move.
- [any] Not yet. Solve $\frac{d}{2} = \frac12at^2$ for each half.
:::
:::

::: check
given: v = 3 | 5; a = 4 | 6
answer: v^2/(2*a)
unit: m
tolerance: 0.5%

## A cart moving at {v} m/s brakes at {a} m/s². How far does it travel while stopping?

::: right
Right. $\frac{v^2}{2a}$ = {answer}.
:::

::: misses
- [v^2/a] Use $v^2 = 2ad$: the factor 2 matters.
- [v/a] That's the stopping time.
- [any] Not yet. $v^2 = v_0^2 + 2a\Delta x$ with final speed 0.
:::
:::

::: check
given: c = 6 | 8; k = 2 | 4; t = 1 | 2
answer: c*t - k*t^2/2
unit: m/s
tolerance: 0.5%

## A vehicle starts from rest with $a(t) = \given{c} - \given{k}t$ m/s². What is its speed at $t$ = {t} s?

::: right
Right. $\int_0^t (c - kt')\,dt' = ct - \frac{kt^2}{2}$ = {answer}.
:::

::: misses
- [c - k*t] That's the acceleration at that moment; integrate it.
- [c*t - k*t^2] Integrating $kt$ gives $\frac{kt^2}{2}$.
- [any] Not yet. Velocity is the integral of acceleration.
:::
:::

::: check
given: c = 6 | 8; k = 2 | 4
answer: c/k
unit: s
tolerance: 0.5%

## For the same $a(t) = \given{c} - \given{k}t$ m/s², starting from rest, when is the speed greatest?

::: right
Right. Where the acceleration is zero: $t = \frac{c}{k}$ = {answer}.
:::

::: misses
- [2*c/k] That's when the speed returns to zero.
- [any] Not yet. Speed peaks where its derivative, the acceleration, is zero.
:::
:::

::: check
given: v = 0.5 | 1; T = 2 | 4; tr = 0.25 | 0.5
answer: v*(T - tr)
unit: m
tolerance: 0.5%

## A trapezoidal move lasts {T} s, with ramps of {tr} s at each end and a top speed of {v} m/s. How far does it go?

::: right
Right. The trapezoid's area: $v_\text{max}(T - t_r)$ = {answer}.
:::

::: misses
- [v*T] The ramps cover less ground than cruising would.
- [v*(T - 2*tr)] That leaves out the distance covered during the ramps, half a ramp's time each at full speed.
- [any] Not yet. Area of the trapezoid under the speed curve.
:::
:::

::: check
kind: parts
given: a1 = 1 | 0.5; v = 20 | 15; tc = 60 | 30; a2 = 1.25 | 1

## A vehicle accelerates at {a1} m/s² to {v} m/s, cruises {tc} s, then brakes at {a2} m/s².

::: part
answer: v^2/(2*a1) + v*tc + v^2/(2*a2)
unit: m
tolerance: 0.5%

### How far does it travel?

::: misses
- [any] Add the three phases' areas under the velocity graph.
:::
:::

::: part
answer: v/a1 + tc + v/a2
unit: s
tolerance: 0.5%

### How long does it take?

::: misses
- [any] $\frac{v}{a_1} + t_c + \frac{v}{a_2}$.
:::
:::
:::

::: check
kind: derivation
vars: a = 0.5..5, d = 0.1..5

## A move of length d with acceleration a for half the distance and braking at a for the rest (a triangular profile).

::: step
answer: sqrt(a*d)

### What is the peak speed?
:::

::: step
answer: 2*sqrt(d/a)

### What is the total time?
:::

::: right
Right. Each half covers $\frac d2 = \frac{v^2}{2a}$, and takes $\frac va$.
:::
:::

::: explain
## Why is the distance traveled equal to the area under the velocity graph?

::: model
Over a very short time $dt$, the velocity is nearly constant, so the distance covered is $v\,dt$: a thin strip under the graph with height $v$ and width $dt$. Adding all the strips gives the total distance, which is the area, or in calculus terms the integral $\int v\,dt$. The same reasoning gives velocity as the area under the acceleration graph.
:::
:::

::: practice

::: check
given: v = 2 | 5; a = 1 | 4
answer: v/a
unit: s
tolerance: 0.5%

## How long does it take to reach {v} m/s from rest at {a} m/s²?

::: misses
- [any] $t = v/a$.
:::
:::

::: check
given: a = 2 | 3; t = 2 | 4
answer: a*t^2/2
unit: m
tolerance: 0.5%

## Starting from rest at {a} m/s², how far does a cart go in {t} s?

::: misses
- [a*t^2] $\frac12at^2$.
- [any] $x = \frac12at^2$.
:::
:::

::: check
given: a = 2 | 5; d = 0.5 | 2
answer: sqrt(a*d)
unit: m/s
tolerance: 0.5%

## A triangular move of {d} m at {a} m/s² peaks at what speed?

::: misses
- [sqrt(2*a*d)] It only accelerates over half the distance.
- [any] $v^2 = 2a\frac{d}{2}$.
:::
:::
:::
