An amateur’s foray into physics

It has long bothered me that I know so little about physics and the maths that goes along with it. There are some great popular-science books on physics, but I wanted to dig deeper. So I turned myself into a “self-taught undergraduate” last year (on a tiny, after-work time budget).

Like any university course in physics, I started with the sub-field of classical mechanics, which is concerned with the “set of physical laws describing the motion of bodies under the action of a system of forces” (Wikipedia).

So I bought some books (primarily the notorious Landau/Lifshitz) and began. Some of the exercises, even simple-looking ones, lead into remarkably big calculations. Even though I usually enjoy calculating, it felt like a chore sometimes, and I looked for a remedy. Luckily, we have computer algebra systems these days, and after some thought and trial I ended up using the Mathematica software.

I soon found the computer-aided approach addictive. Not only does the software help with big, boring, error-prone calculations. The need to formulate solutions in a machine-tractable way also makes me think more deeply and conceptually about the maths. Plus, the software leads me to discover useful maths I don’t yet know, like any programming language leads to discovering new useful libraries. Finally, the software makes it easy to play around with the parameters of an exercise and visualize the solutions.

This post shows an example of an exercise aced with computer help. It is about a mass that can move around on some surface, in the presence of gravity, with no friction. Like a piece of soap in a bath tub. Here is a concrete case:

A mass tied to a surface, in the presence of gravity, with no friction

Classical mechanics has a neat way of describing a whole system of moving parts by a mathematical term called Lagrangian. It’s beyond the scope of this post to explain the theory behind Lagrangians, but they are really cool. The Lagrangian for this system is:

m2(x˙2+y˙2+z˙2)mgz \frac{m}{2}(\dot{x}^2 +\dot{y}^2 +\dot{z}^2) - m g z+λ(zh(x,y)+ \lambda(z - h(x,y)

The symbol mm stands for the particle's mass, gg is the gravity constant, xx, yy and zz are the particle's coordinates, and x˙\dot{x}, y˙\dot{y} and z˙\dot{z} the corresponding speeds. The function hh describes the shape of the surface. It can be any sufficiently well-behaved function. In our example, I used a certain polynomial to obtain an interesting hilly terrain. The most interesting part of our Lagrangian is probably the constraint, λ\lambda, which corresponds, up to constants, to the force that keeps the mass on the surface.

The Lagrangian is a succinct description of the system, but it does not lend itself well to calculate the actual motion. We need to calculate the laws of motion from a Lagrangian. The laws of motion are also called Euler-Lagrange Equations, or just Euler Equations or Lagrange Equations. They form a system of ordinary differential equations (ODEs). There is an easy method, which I won't introduce here, to obtain the laws of motion from the Lagrangian. Mathematica even has an optional package, called "VariationalMethods", which contains a command "EulerEquations", which does exactly this: get the laws of motions from a Lagrangian. The result, in our case, turns out to be this system of ODEs:

mx¨=λhxmy¨=λhymz¨=λmg0=zh \begin{aligned} m \ddot{x} &= -\lambda \frac{\partial h}{\partial x} \\ \\ m \ddot{y} &= -\lambda\frac{\partial h}{\partial y} \\ \\ m \ddot{z} &= -\lambda - m g \\ \\ 0 &= z - h \end{aligned}

Things are beginning to look quite Newtonian here: the first three equations have on the left side terms describing "mass times acceleration". On the right side, they have terms that at close inspection turn out to be forces. The last equation results from the constraint and just states that the vertical zz coordinate results from applying the surface description hh to the horizontal coordinates xx and yy.

We are now a step closer to calculating the actual motion, but we must still obtain the actual function that describes the movement. That function, which maps time to coordinates, is a solution of of the above system of ODEs. I wrote "a" solution and not "the" solution, because there is one solution for each initial condition, by which we mean the particle's coordinates and speeds at the start of its journey. Of course, we must also fill in the mass mm, the gravity constant gg, and the surface shape hh to determine the system fully.

In lucky circumstances, the "motion function" corresponding to a system of ODEs can be given as a symbolic formula. But often, the solution can only be approximated numerically. In our case, we can find symbolic solutions for certain very simple surfaces hh, e.g. non-curved surfaces, but not for interesting ones like the one in the animation above. In our case, the surface is actually

h(x,y)=(x3)(x2)(x1)(x+1)(x+2)(x+3)(y3)(y2)(y1)(y+1)(y+2)(y+3) \begin{aligned} h(x,y) &= (x-3)(x-2)(x-1) \\ & \quad (x+1)(x+2)(x+3) \\ & \quad (y-3)(y-2)(y-1) \\ & \quad (y+1)(y+2)(y+3) \end{aligned}

Neither I nor Mathematica can find a symbolic solution for this hh. (It's most likely impossible, but I don't know how to prove that.) Even when we ask only for a numerical solution, Mathematica cannot give one straight away, because the system of ODEs contains certain snags. For Mathematica to succeed, I had to eliminate zz and λ\lambda first, and then solve for x¨\ddot{x} and y¨\ddot{y}. I'll spare you the details, what counts is that finally, Mathematica is able to give a numerical solution.

Before I created the animation above, I played around with the initial conditions and let Mathematica visualize the trajectory of the particle:

The orbit of the sliding mass
The orbit of the sliding mass

After I found a nice trajectory to show off, I created the animation. The Mathematica programming language has convenient primitives for creating animations. The animation turned out to be very slow, because of the time the software needs to calculate the numerical solution of the ODE system. But that didn't matter for this post, because I had to export the animation as a animated GIF anyway. Mathematica has a nice trick for doing this: there a command, called Table, which allows to create a sequence of images instead of an animation, like a thumb cinema. That image sequence can than be exported as a GIF.

In summary, we have seen: Classical Mechanics provides a great way to model systems by so-called Lagrangians. These lead automatically to the laws of motion. These form a system of ODEs that can be solved either by hand or with software. The software can also help explore and visualize the system.

Comments