Missing miles

I took a bike ride this morning on a portion of the I&M Canal Trail from Romeoville to Joliet and back. It’s a fairly short ride, eight miles each way, and that distance got me thinking about using Mathematica to do some calculations after I got back home.

The trail has mile markers with little snippets of information about the canal and the surrounding area. Here are the markers I passed this morning:

Mileage markers 27 through 31

The mileage figures on the markers increase as you go south and west, which is downstream. There are several more markers in Lockport, where they’re graduated in tenths of a mile, but these will do for our purposes.

My ride started nearly a mile before Marker 27 and continued about a mile after Marker 31, which would lead you to believe I rode six miles, not eight. But the trip is definitely eight miles. I have my Fitness app set to record in kilometers, and it always tells me this trip is 13 kilometers one way. And as we know from the Fibonacci conversion, 13 km = 8 mi.

As I passed Marker 27 on the way south, I was reminded of this anomaly and decided to use the trip to figure out why the markers and the mileage don’t match up. I checked my Workout screen on my watch as I passed each marker and learned that there were two miles between Markers 28 and 29 and between Markers 30 and 31. After turning around in the parking lot of the Joliet Iron Works, I decided to take a photo of each marker on the way back north and use the photos to calculate distances.

I already knew about Mathematica’s GeoDistance function, and I figured it must have a way of extracting the latitude and longitude of photos from their EXIF data. That turned out to be the Import function, and I was able to put the two together to make this short notebook:

As you can see, the distances between the photos (and therefore between the markers) were:

Markers Distance
27–28 1.019 mi
28–29 1.886 mi
29–30 1.041 mi
30–31 1.939 mi

These are geodesic or “as the crow flies” distances. The canal and its trail are pretty straight, but there are a couple of doglegs between Markers 28 and 29, which explains why the distance between them is over a tenth of a mile off from two miles.

As you can see near the bottom of the notebook, I used the GeoListPlot function to make a map with the marker positions on it. I combined that in Acorn with the map from my iPhone’s Fitness app to make this image:

Mathematica and Fitness app maps

It took some trial and error with the GeoRange option to get the scales to match up reasonably well, but I think it was worth it. You can see where the mile markers fall on my route, and it’s clear that the distances between Markers 28 and 29 and Markers 30 and 31 are about twice as far as the other distances. Also, you can see how the geodesic distance between Markers 28 and 29 cuts the corners, making it less than two miles.

So I’ve solved the six-mile/eight-mile mystery, but I still don’t understand why the mileage on the markers is wrong.


Fourier series in Mathematica

After my last post—the one about using Fourier series—I started thinking about how to use Mathematica to develop Fourier series.1 I could, of course, use the Integrate function to determine the Fourier coefficients, but Mathematica has other functions that can do the job directly once you understand how they work.

Mathematica has several Fourier functions, but I’m going to stick with the ones associated with sine series, FourierSinCoefficient and FourierSinSeries. They’re meant to be easy to use, and they are, but you need to know how they’re defined.

The coefficients used in both of these functions are defined this way:

fn=2π0πf(x)sinnxdx

This doesn’t match up exactly with the definition I used for getting the Fourier coefficients of a loading function, q(x):

qn=2L0Lq(x)sinnπxLdx

To use the Mathematica functions to get the qn, we have to do a change of variable. Let

z=πxL

so

x=Lzπanddx=Lπdz

(Here, z is just another variable name; I’m not using it to represent a complex number.)

This changes the expression for qn to

qn=2π0πq(Lzπ)sin(nz)dz

which means we can use the Mathematica functions as long as we substitute Lz/π in for x in the expression for q.

Let’s give it a try on this parabolic loading function:

q=4qmaxx(Lx)

It shouldn’t take many Fourier terms to get a good approximation of this.

Parabolic loading

Here are the Mathematica commands I used:

q = 4 qmax x (L - x)
qn = FourierSinCoefficient[q /. x -> L z/Pi, z, n]

You can see the substitution in the first argument to FourierSinCoefficient.

After simplification, the results were

qn={32L2qmaxn3π3for odd n0for even n

We could also get the series (through n=7) directly with FourierSinSeries:

qapprox2 = FourierSinSeries[q /. x -> L z/Pi, z, 7] /. z -> Pi x /L

where the inverse substitution comes at the end to put the expression back in the form we want. Here’s a screenshot from the Mathematica notebook:

Mathematica notebook screenshot of Fourier series

You can see that the coefficients match what we got earlier.

A quick plot of the difference between this truncated Fourier series and the original parabolic function shows that, as expected, the series does a good job of replicating the original. The largest error, near the ends, is just 0.3% of qmax, and that’s with only four terms.

Error of Fourier series estimate

If you’re interested, here’s the entire Mathematica notebook:

Now that I understand the way these functions work, I can do more complicated Fourier analysis in Mathematica without questioning myself on whether I’m using them correctly.


  1. Something I couldn’t do in any of the posts in that series, as that would be breaking the rules I had set up for myself. 


Simply supported beam—Fourier series solution of the ODE

We’re finally here, at the end of all things. In this post, we’ll use a Fourier series to get the formula for the center deflection of a simply supported beam with a uniformly distributed load. We’ll see some of the same math that we saw in the previous Fourier series solution, but the fundamental approach will be different.

Let’s start with the fourth-order ordinary differential equation for a beam with a general loading function, q(x):

EIyiv=q

The simple supports at both ends give us these boundary conditions:

y(0)=y(L)=y(0)=y(L)=0

Let’s work out the solution for a loading condition we haven’t considered before, a distributed load in the form of a sine wave:

q(x)=qmsinmπxL

where m is a positive integer and qm is some constant amplitude. Given the form of the governing ODE and the boundary conditions, it seems likely that the solution will look like this:

y(x)=ymsinmπxL

It satisfies the boundary conditions, and if we plug it and the expression for q into the governing ODE, we get

EI(mπL)4ymsinmπL=qmsinmπL

which is a solution for all values of x if

ym=1EI(Lmπ)4qm

This will work for any value of m that’s a positive integer.

Since the governing ODE is linear, if q is the sum of several sine terms, the solution will be the sum of several sine terms. Returning to our favorite problem,

Simply supported beam with uniform load

we now have a path for expressing the solution as a sum of sines, as long as we can express the constant function, q(x)=w, as a sum of sines.

And of course we can. The Fourier sine series expression that fits a constant is

q(x)=m=1qmsinmπxL=w

where

qm=2L0LwsinmπxLdx={4wmπfor odd m0for even m

This result comes from the orthogonality of the sine function. The Fourier coefficients are the same as those for a square wave.

Plugging this result into the expression for ym, we get

ym=1EI(Lmπ)4(4wmπ)=4wL4m5π5EI

for odd m. Therefore,

y(L2)=4wL4π5EIm=1,3,5,1m5sinmπ2

You may recall from our earlier post that there’s a closed-form solution for this sum:

Simitses Table A-2

The last entry in this table with x=π/2 gives us

m=1,3,5,1m5sinmπ2=(π496)(π2)(π248)(π2)3+(π96)(π2)4=5π51536

Substituting the closed-form solution in for the sum yields our old friend:

y(L2)=(4wL4π5EI)(5π51536)=5wL4384EI


The purpose of this series of posts—apart from a bit of showing off—was to demonstrate why I love structural analysis. It has, even in the simplest of problems, a depth that rewards those who study it. And when you’re confronted with problems that aren’t so simple, you can draw on that depth to understand and solve them.


Simply supported beam—Newmark’s method

This would have been the last post in the series if I hadn’t realized recently that another method deserved a post. So this is the penultimate. It was described in this 1943 paper by Nathan Newmark and is known—or was known—as Newmark’s method.

I say was because this method is dead. How dead? Forty-five years ago, when I was an undergraduate taking structural analysis courses, Newmark’s method wasn’t being taught in the department that he had been the head of for decades and whose main building is named after him. That’s dead.

Which isn’t to say it wasn’t a good method. Some of my professors talked about using it when they were young, and it was a practical technique when engineers used slide rules and desk calculators, but it was clear by the 80s that its time had passed. Still, it’s desncribed in the textbook I used as an undergrad, and I did eventually learn it well after I was out of school, so here it is.

Newmark’s method is basically a way of doing double integration, so you can use it to go from loading to bending moments or from bending moments to deflection. As Newmark says in the introduction to his paper,

The numerical procedure is approximate, but leads to exact moments (or deflections) when the loading diagram (or diagram of “angle changes”) is made up of segments that are bounded by straight lines or by arcs of parabolas.

For our simply supported, uniformly loaded beam, the “angle change” diagram—which we’ve been calling a curvature diagram—is a parabola, so we can get an exact solution.

Let’s say we have a beam with any kind of support conditions and some general distributed loading:

Beam with generic loading

The fundamental trick of Newmark’s method is to imagine a set of simply supported beams inserted between the load and the real beam.

Insertion of simply supported beams

The small imaginary beam segments are all of the same length, λ, and the analysis proceeds by calculating the reaction forces at the ends of these beams and then building a table of loads, shears, and moments based on these reactions (reversed in direction) acting on the large original beam.

Here’s a figure from the paper that explains how to calculate the reaction forces for parabolically distributed loading:

Equivalent concentrated loads for parabolas

There are simpler formulas if the loading is distributed linearly.

You may have noticed the double curvature in the right drawing, which means that the load shown there is not parabolic. Newmark suggests using the formulas in this figure even if the loading curve is of higher order—the parabolic formulas are close enough if you divide the beam into several segments.

I’ve focused here on the process of going from loads to bending moments because I think the mechanics of that is easier to understand. But the same process applies to going from curvature to deflection. We went through that in the conjugate beam post.

In fact, Newmark does our problem in the paper. He uses the constant q as the intensity of the load and splits the beam into four segments:

Newmark four-segment solution

This may look impenetrable, but we can simplify it by using only two segments and explaining each step. Here’s the table, starting with the moment diagram:

Newmark two-segment solution

The row labeled Moment is the value of the bending moment at each point. The Curvature row is just the moment at each point divided by EI and with the sign reversed. Those are the easy ones.

The Angle change row is based on the curvature values and the formulas in Figure 5 above. The value at the left end is

L/224[70+6(wL28EI)0]=wL364EI

where we’ve used λ=L/2. This is also the value at the right end.

The value at the center is

L/212[0+10(wL28EI)+0]=5wL396EI

We start the Average slope row with the knowledge that the slope at the center of the beam is zero, so if the angle change across the center is

5wL396EI

then the average slope must go from

5wL3192EIto5wL3192EI

as we move from the left half of the beam to the right half.

(If you’re having trouble with this, remember that angle change is analogous to shear and think of a beam with an antisymmetric shear diagram. If the change in shear across the centerline is F, then the shear must be F/2 in the left half of the beam and F/2 in the right half.)

For the Deflection row, we know that the deflection is zero at the left and right ends. Since the average slope in the left half of the beam is

5wL2192EI

the deflection at the center must be

(5wL3192EI)(L2)=5wL4384EI

an answer we’ve now seen twelve times.