Fall 2007 to summer 2008
Two cyclists in an office
I came to Hope College to be an engineer. Math was the class I kept enjoying. In the fall of 2007 I introduced myself to Tim Pennings, a math professor best known among mathematicians for his dog. Elvis, a Welsh corgi, chased tennis balls into Lake Michigan along very nearly the fastest possible path, and Tim wrote the paper proving it, “Do Dogs Know Calculus?”
I told Tim two things about myself. I liked explaining math to classmates, and I had just started racing triathlons. He told me one thing back. In 1981, for his master's degree at the University of North Dakota, he had written a thesis called Mathematical Modeling of Bicycle Dynamics with Computer Simulation. He had always wanted to turn it into a project his own students could work through. Would I like to spend a summer doing that?
I said yes. In the summer of 2008 I read the thesis start to finish. Its programs, with names like LEAN, simulated a rider at 10 miles per hour with a reaction time of three tenths of a second. Those two numbers are still in everything on this page.
One thing I wanted to change was the path. Tim's thesis drew the bike's route as short straight segments joined at angles. I thought it had to be a chain of arcs. We settled it the direct way.
“Pennings and I spent an afternoon riding our bicycles on lined pavement.”From a research essay I wrote that December. We rode along painted lines and watched what path each steering move traced. It was arcs.


The physics
Why a moving bicycle stays up
Most people guess gyroscopes: the spinning wheels hold the bike up like a top. They help a little. The main reason is simpler, and you already know it from the playground.
Sit on the edge of a spinning merry-go-round and you feel flung outward. Nothing is pushing you. Your body wants to travel in a straight line and the ride keeps pulling you into a circle. From your seat, that feels like a force pointing out of the turn. Physicists call it centrifugal force.
Now picture a bicycle from behind, leaning to the right. Gravity pulls down on the center of mass and twists the bike further over. If the rider steers to the right, the bike starts to travel in a circle, and the centrifugal force pushes the center of mass to the left, back toward upright. You stay up by steering into the fall. Those two twists, one from gravity and one from the turn, are the whole model.
Here \(\theta\) is the lean, \(m\) the mass of bike and rider, \(r_{cm}\) the height of the center of mass, \(v\) the speed and \(R\) the radius of the turn. A tighter turn or a faster bike makes \(\tau_c\) bigger. Notice the \(v^2\). It comes back later and it is not kind.

Try it
Balance gravity against the turn
Three things decide whether this bike stays up. The lean \(\theta\) sets how hard gravity twists it over. The speed \(v\) and the steering \(S\) together set how hard the turn twists it back. Your job is to make the two bars at the top match. When they do, the bike holds its lean and neither falls nor rises.
Three to try. Each sets the lean and speed, and you find the steering.
Notice the second one. At half the speed the same lean needs four times the steering. That is the \(v^2\) at work, and it is why a slow bike is a wobbly bike.
In one line. A moving bicycle stays up because steering into a fall makes a turn, and the turn pushes it back upright.
The calculus
From two torques to one equation
- Newton's second law, for rotation.Torque equals moment of inertia times angular acceleration. Gravity tips the bike, the turn rights it.$$I\,\frac{d^2\theta}{dt^2}=m g r_{cm}\sin\theta-\frac{m v^2 r_{cm}}{R}\cos\theta$$
- Make it solvable.That equation has no tidy solution. For small leans a Taylor series says \(\sin\theta\approx\theta\) and \(\cos\theta\approx 1\). Group the constants as \(c_1=mgr_{cm}/I\) and \(c_2=mv^2r_{cm}/(IR)\).$$\frac{d^2\theta}{dt^2}=c_1\,\theta-c_2$$
- Solve it.A second-order linear differential equation, the kind a sophomore meets in MATH 231. With starting lean \(\theta_0\) and lean rate \(\omega_0\):$$\theta(t)=\tfrac12\!\left(\theta_0+\tfrac{\omega_0}{\sqrt{c_1}}-\tfrac{c_2}{c_1}\right)e^{\sqrt{c_1}\,t}+\tfrac12\!\left(\theta_0-\tfrac{\omega_0}{\sqrt{c_1}}-\tfrac{c_2}{c_1}\right)e^{-\sqrt{c_1}\,t}+\tfrac{c_2}{c_1}$$
- Read what it says.That first exponential grows. Whatever lean you have beyond the balance point \(c_2/c_1\) multiplies itself, again and again. A bicycle is never at rest. It is always falling one way or the other, and riding is the act of continually changing your mind about which.

Try it
Freeze the handlebars and see which way it goes
The rider locks the bars in a gentle right turn and does nothing else. The chart shows the lean over the next two seconds. Each faint curve is a ride that began at a different lean. Yours is the bold one. Change the starting lean and watch it peel away from the dashed balance line, one way or the other.
In one line. Any lean away from the balance point grows exponentially, so no fixed steering angle works. The rider has to keep correcting.
The control problem
Now ride it
No fixed steering angle works, so the rider needs a rule: look at the bike, decide how much to steer, repeat. In Tim's thesis and in our project the rider looks every 0.3 seconds, a typical human reaction time, holds the bars still in between, then looks again.
In symbols: \(\theta\) is the lean angle, \(\omega\) is the lean rate (how fast the lean is changing), \(S\) is the steering angle, and \(\Delta t\) is the reaction time between looks.
Two more facts close the loop. A bike with wheelbase \(L\) and its front wheel turned by a steering angle \(S\) rides a circle of radius \(R=L/S\). And in one reaction time it covers a distance \(v\,\Delta t\) along that circle. String the arcs together and you have the path.
The job: keep the bike upright, and keep it on a straight line. We start every attempt the same way, leaning 5° to the right and falling at 8° per second. Below is the Maple program I wrote in 2008, rebuilt to run in your browser. Work through the attempts in order. That is the path the project takes students down.

The steering lab · the 2008 Maple program, rebuilt
Lean angle (degrees)
Distance from the line (feet, right is positive)
What the five attempts teach
Attempt 1 fails with the numbers we first hand students, and it fails in an instructive way: every correction is too big for a rider who only looks three times a second. Attempt 2 gets the bike vertical at every glance and leaves it thrashing. Attempt 3 calms it and takes forever. Attempt 4 is the one that feels like riding.
Go back to attempt 1 and set α near 1.2 and β near 0.35. It works beautifully. Each of the clever attempts turns out to be the first rule again with better numbers, because the equation is linear. The calculus was finding those numbers for us.
Attempt 5, and what the first four were missing
Rules 1 through 4 watch two things, the lean \(\theta\) and the lean rate \(\omega\). That is enough to stay upright. It says nothing about where the bike is going. Staying on a line needs two more measurements:
Heading \(\psi\) is the direction the bike is pointing compared with the line. Zero means parallel to it. Distance \(y\) is how far to the side of the line the bike has drifted. The lab draws both on the road view.
Attempt 5 steers on all four at once: \(S=\alpha\theta+\beta\omega+\gamma\psi+\kappa y\). Four numbers are too many to tune by hand, so I let control theory choose them. The method is called a linear quadratic regulator. You tell it how much you care about each kind of error, and how much you care about not yanking the handlebars. It returns the four numbers that keep the total as small as possible over the whole ride.
That is the real difference from attempts 3 and 4. They used calculus to find the best move for the next 0.3 seconds only. This method finds the best rule for every step from here to the horizon, with the path included. It is how balancing machines are designed today, and it is the piece the 2008 project stopped just short of.
A correction, eighteen years late. In 2008 our plot for attempt 4 showed the bike settling within an inch or two of the line, and that is what we published. Rebuilding the program for this page turned up a sign slip in how it added up left turns. The balance results were right all along. The path was not: the bike stays up and quietly rides off at an angle, because nothing in rules 1 through 4 ever looks at the road. Attempt 5 does. Watch its first move. To get back to a line on its left, it steers right. That is countersteering, and nobody told the math to do it.
In one line. Steer in proportion to the lean and the lean rate and the bike stays up. Add heading and position to the rule and it also stays on its line.
August 2008 to 2012
Into the classroom, and into print
By August the summer's work was a workbook: 27 problems that walk a student from a force diagram to a working steering rule, with a Maple program to test each idea. Tim made it the closing project of MATH 231, Multivariable Mathematics I, the sophomore course where linear algebra, differential equations and multivariable calculus come together. The project sits right at that level. In the fall of 2009 two sections, 57 students, spent the closing days of the semester teaching a simulated rider to stay up.
We wrote it up as an article too. Stabilizing a Bicycle: A Modeling Project went to the journal PRIMUS in December 2008, was accepted two months later, and appeared in volume 20 in 2010. In 2012 the editor wrote to say it had been the journal's most downloaded article that year.
I gave the talk four times, the last at a Mathematical Association of America meeting in May 2009, under a title I still like: Teaching a Computer to Ride a Bike.
We wrote the article for instructors: everything needed to run the project in a course at that level, with the problems, the solutions and the program.
Three documents came out of the math project. Open any of them below. They are the same idea at three stages: Tim's 1981 thesis, the workbook students filled in, and the article for teachers. Two more documents, from the engineering build, are in chapter 9.

Fall 2008 to spring 2009
“I'm an engineer. I want to build it.”
That fall I took a course on dynamic systems and controls, and I could not stop thinking about a question near the end of our own workbook: could a robot really ride a bike with this model? There was one way to find out.
Dr. Miguel Abrahantes in engineering agreed to advise me. The obstacles were time and money, so I went looking for both. I wrote two proposals for a project nobody had assigned: one to NASA's Michigan Space Grant Consortium, one to the Howard Hughes Medical Institute's research scholars program at Hope.
“How is it, exactly, that a human keeps a bicycle upright?”The question my HHMI research plan opened with, February 2009.
Both said yes. The Space Grant fellowship was $2,500. Cross Country Cycle in Holland donated a used Schwinn Continental. That June I was in Japan on Hope's exchange with Technos College in Tokyo. Dr. Ichiro Takahashi, a professor there, arranged a visit and drove me to Keio University in Yokohama to meet Dr. Toshiyuki Murakami, whose lab had built a self-stabilizing bicycle. It was a highlight of the trip. Back home I traded emails with a student at MIT doing the same.
In October the college magazine wrote up the project as “Biking in the Balance.” Tim told the reporter I did a great job.
That is now in print, and I remind him of it more often than he would like.



Summer 2009
Build the robot
Every symbol in the equations has to become a physical thing. The steering angle \(S\) needs a motor. The speed \(v\) needs another. The lean \(\theta\) and lean rate \(\omega\) need sensors. The rule that connects them needs a computer, and all of it has to ride along, because there is no rider to carry anything.
Add the parts one at a time. Each one is here because a term in the math asked for it.


Assemble it

The half the equations leave out
The parts list was the easy half. None of those pieces were made to go on a bicycle, so most of the summer went into making them fit.
I learned to run the mill and the lathe in the engineering machine shop, and cut the motor mounts and sensor brackets out of aluminum and plastic stock. I drew each mount in CAD before I cut it. I chose and ordered every part against an $800 budget. I learned to wire a data acquisition unit, to read a sensor's datasheet, to track down electrical noise, and to write the LabVIEW program that tied it all together.
The equations say a motor has to turn the fork. They do not say how to hold a motor to a head tube. A lot of what I took from this project is that second kind of knowledge: fabricating, assembling, and debugging with my hands. I have used it as much as the math.







August 2009
From the drawing to the real thing


Summer 2009
Program it
The robot runs the same loop as the rider in chapter 4, with one difference. A person looks about three times a second. The laptop looked twenty times a second.
Each pass through the loop has four steps. Click one to see what happens inside it.

I wrote it in LabVIEW, where a program is a wiring diagram. The language does not matter. Today the whole loop fits on a microcontroller the size of a stick of gum, and the code beside this is very nearly all of it.
The rule I loaded was the first one from the paper: steering equals a number times the lean plus a number times the lean rate. After many runs up and down the sidewalk, the numbers that worked best were 1.2 and 0.6.
# twenty times a second
every 50 ms:
lean_rate = gyro.read()
lean = 0.3 * tilt_from(accelerometer)
+ 0.7 * running_sum(lean_rate)
steer = 1.2 * lean + 0.6 * lean_rate # S = αθ + βω
stepper.go_to(steer)
log(time, lean, lean_rate, steer)
if abs(lean) > limit:
drive_motor.stop() # safety
System architecture
Everything on the bike, and how it talks
Follow the arrows: two sensors in, two motors out, one laptop in between, and the bicycle itself closing the loop. Tap any block for the part number and what it did.
Total parts cost in 2009: $617.96. The details are in the design report, sections 5 and 6.

August 2009
Nine seconds
August 11 and 12, 2009, on campus. Shot at 320 by 240 on a pocket camera, restored and upscaled for this page. Stay for the last run.
This is the real thing. The drive motor could hold the bike at speed but could not get it moving from a standstill, where the most torque is needed. So in the name of science I ran alongside to bring it up to speed, let go, and watched.
A bicycle with no rider carries on across the plaza, its front wheel twitching left and right as the stepper motor works. It was quite a sight in the middle of a quiet summer campus: a student sprinting behind a bike with a laptop on the back, then standing there while it wobbled away on its own. I got some looks.
With the controller switched off, the bike stayed up for about three seconds. With it on, a typical run lasted nine. Then a wobble would start, grow, and tip it onto an outrigger.
Scrappy, on purpose and by necessity
I was a college student with an $800 budget and no one down the hall who had built one of these. I used what I could find. The drive motor was a car window motor left over from another project in the lab. It seemed strong, so it went on the bike. I researched the stepper motor carefully and geared it for torque, but I chose it without knowing how fast the steering really had to move.
Looking back, the right way is to work out the torques and speeds the bicycle demands first, then choose motors and sensors to meet them. I did it the other way round and made the machine work with what I had. It was enough to get real data and to show that the controller beat no controller at all.
It never did ride off down College Avenue. I wrote that plainly in the report, with the data and the limits of the system, and handed it in.


Why it fell, worked out in 2026
The modeling process ends with two steps: compare the simulation with the real world, then adjust. In 2009 I ran out of semester before I could. So I did it for this page, and the math had the answer waiting.
The tilt sensor could not feel the tilt. An accelerometer measures lean perfectly on a parked bike. On a moving one, the same turn that balances the bike also cancels what the sensor feels. The controller was seeing about 70% of the true lean.
And the gain had no margin. Remember the \(v^2\). At 7 mph the steering has to be at least 1.15 times the lean just to cancel gravity. My 1.2, seen through a sensor reading 70%, was really 0.84.

Simulation
The 2009 bike, rebuilt inside the computer
This is a simulated copy of my bicycle. It has the same weight, wheelbase and speed, the same two sensors and their filters, and the same program with the same two numbers, all taken from the report. Press the button and it is released the way I released the real one. Bumps in the pavement do the rest. Watch it fall the way the real one did. Then change one thing and release it again.
Lean angle in degrees over time. The outriggers catch the bike at 20.
If I built it today
In the simulation the 2009 bike falls after five or six seconds, the same order as the real nine. Change any one of three things and it stays up for as long as you care to watch. The idea was sound and the machine was close.
So here is the version I would build now. Size the motors from the torques and speeds the bicycle needs, so it can start from a stop and steer as fast as the math asks. Estimate the lean properly. Use the rule from attempt 5, so it holds a line as well as its balance. Swap the laptop in its plywood box for a microcontroller smaller than a deck of cards.
That bicycle would not need me running behind it. It would roll out of the engineering building, down College Avenue, and keep going across Holland, past the tulips and the windmill, all the way to the lake.
The picture is a simulation of a bicycle I have not built yet. Every equation it depends on is on this page.

In one line. The machine worked and the model was right. A few numbers were off, and the model was the tool that found them.
Why it matters
Math you can build with
Look at what the project used. A force diagram. A Taylor series. One second-order differential equation. A rule with two numbers in it. All of it is in a sophomore's toolkit, and it was enough to make a machine do something that takes a child weeks to learn.
That is what mathematical modeling is: you write down what you believe about the world in a form you can calculate with, you let the calculation tell you things you did not know, and then you go and check. When the bike fell at nine seconds, the model was not wrong. It was telling me which of my numbers to look at.
The robots arriving now run on this. A drone stays level with the loop from chapter 8, a few hundred times a second. A walking robot is an upside-down pendulum that refuses to fall, the same equation as chapter 3 with more joints. The machine-learning systems that teach robots to move do their practicing inside simulators, and a simulator is differential equations all the way down. The better the model, the less the robot has to relearn when it meets the real floor.

Where it took me
The bicycle work led to a Goldwater Scholarship and an NSF Graduate Research Fellowship, which opened the door to graduate school. From there I went on to work on self-driving cars at Tesla, on autonomous drones at Skydio, and now on self-driving semi-trucks at Aurora. Each of those machines is this bicycle grown up: sensors, a model of the physics, a rule that decides, and motors that act, many times a second. The AI on board is far beyond my two-number steering rule. It stands on the same ground.
Physical AI is what you get when math and physics are given a body. As more of the world starts to move on its own, the people who understand the equations underneath are the ones who will make it work and keep it safe. I carried that from Tim's office through my whole career, and I see it mattering more every year.
So if you are sitting in a calculus class wondering what it is for: it is for this. Anyone who can learn the math on this page can build the machine on this page. I know because I did both, in that order, two years apart.







