Butterflies in Polar Coordinates

A butterfly outline drawn from a trigonometric function in polar coordinates.
A butterfly outline drawn from a trigonometric function in polar coordinates.

I was looking for mathematical functions I could use to shape guitar bodies, and I came across Hubpages’ user calculus-geometry‘s beautiful page on how to generate butterfly outlines using functions in polar coordinates.

The butterfly above was generated using the function:

r(θ) = 12 – sin(θ) + 2 sin(3θ) + 2 sin(5θ) – sin(7θ) + 3 cos(2θ) – 2 cos(4θ)

The code I used (using VPython) is:

from visual import *

''' the main function '''
def r(theta):
    #r = 1+cos(theta)
    
    #Archimides' sprial
    #r = 0.5*(theta) 
    
    #heart: http://jwilson.coe.uga.edu/EMT669/Essay.ideas/Heart/Hearts.html
    #r = 5*sin(theta) - sin(5*theta)
    
    #butterfly: http://calculus-geometry.hubpages.com/hub/Butterfly-Curves-in-Polar-Coordinates-on-a-Graphing-Calculator
    #r = 8-sin(theta)+2*sin(3*theta)+2*sin(5*theta)-sin(7*theta)+3*cos(2*theta)-2*cos(4*theta)
    r = 12-sin(theta)+2*sin(3*theta)+2*sin(5*theta)-sin(7*theta)+3*cos(2*theta)-2*cos(4*theta)

    return r

'''convert to rectangular coordinates'''
def xy(r, theta):
    x = r * cos(theta)
    y = r * sin(theta)
    return vector(x, y)


path = curve(color=color.green, radius=.2)


theta = 0.0

print pi, theta, r(theta) , xy(r(theta), theta)

while theta <= 2*pi:
    rate(100)
    theta += 0.01
    path.append(pos=xy(r(theta), theta))
    


Necks, Fretboards, and Scale Length

Pluck a string on a guitar and the sound you hear depends on how fast it vibrates. The frequency is how many times it vibrates back and forth in each second. An A4 note has a frequency of 440 vibrations per second (one vibration per second is one Hertz).

The vibration frequency of a guitar string depends on three things:

  • the mass of the string
  • the tension on the string (how tight it’s pulled)
  • and, the length of the string.

Guitar string sets come with wires of different masses. The guitar has little knobs on the end for adjusting the tension. For building the guitar, you have the most control over the last last parameter, the length of the string, which is called the scale length. Since the guitar string masses are pretty much set, and the strings can only hold so much tension, there are limits to the scale length you can choose for your guitar.

In a guitar, the scale length only refers to the length of the string that’s actually vibrating when you pluck the string, so it’s the distance between the nut and the bridge. For many guitars this turns out to be about 24.75 inches.

For a guitar, the scale length is the length of the strings that are free to vibrate.
For a guitar, the scale length is the length of the strings that are free to vibrate.

Frets

To play different notes, you shorten the vibrating length of the string by using your finger to hold down the string somewhere along the neck of the instrument. The fret board (which is attached to the neck) has a set of marks to help locate the fingering for the different notes. How do you determine where the fret marks are located?

Well, the music of math post showed how the frequency of different notes are related by a common ratio (r). With:

 r = \sqrt[12]{2}

So given the notes:

Note Number (n) Note
0 C
1 C#
2 D
3 D#
4 E
5 F
6 F#
7 G
8 G#
9 A
10 A#
11 B
12 C

Since the equation for the frequency of a note is:

 f_n = f_0 \; r^n

we can find the length the string needs to be to play each note if we know the relationship between the frequency of the string (f) and the length of the string (l).

It turns out that the length is inversely proportional to the frequency.

 l = \frac{1}{f}

So we can calculate the length of string for each note (ln) as a fraction of the scale length (Ls).

 l_n = \frac{1}{f_n}

substituting for fn gives:

 l_n = \frac{1}{f_0 \; r^n}

but since we know the length for f0 is the scale length (Ls) (that inverse relationship again):

 l_n = \frac{1}{\frac{1}{L_s} \; r^n}

giving:

 l_n = \frac{L_s}{r^n}

When we play the different notes on the guitar, we move our fingers along the neck to shorten the vibrating parts of the string, so the base of the string stays at the same place–at the bridge. So, to mark where we need to place our fingers for each note, we put in marks at the right distance from the bridge. These marks are called frets, and we’ll call the distance from the bridge to each mark the fret distance (D_n). So we reformulate our formula to subtract the length of the vibrating string from the scale length of the guitar:

 D_n = L_s - \frac{L_s}{r^n}

Showing the fret distance.
Showing the fret distance.

The fret marks are cut into a fret board that was supplied by the guitarbuilding team, which we glued onto the necks of our guitars. We did, however, have to add our own fret wire.

Placing the fret wire into the fret cuts. The wire still needs to be fully pressed in.
Placing the fret wire into the fret cuts. The wire still needs to be fully pressed in.

The team also has an activity for students to use a formula (a different one that’s recursive) to calculate the fret distance, but the Excel spreadsheet fret-spacing.xls can be used for reference (though it’s a good exercise for students to make their own).

The Chicken Coops are Here

Finding the right place for the chicken coops.
Finding the right place for the chicken coops.

Now that we’re at the end of the academic year, our middle school business’ chicken coops have finally arrived (they were on back order). The kids had some fun finding the right spot for the coops, and we staked out an area for fencing; we plan to clip the birds’ wings.

Although, the coops came pre-assembled, the students needed to make some final adjustments.

Figuring out how the coops work.
Figuring out how the coops work.
Delineating the area for fencing.
Delineating the area for fencing.

Tomorrow, during math, they’ll be finding the perimeter so we can order fencing, and finding the area so we can know how much space we’ll have per bird.

Useful Games and Apps

Ellen Holderman has an excellent post about “24 Apps, Games, and Websites Teachers are Using in STEAM Classrooms” that are mostly free. (STEAM stands for Science, Technology, Engineering, Arts, and Mathematics).

They’re mostly aimed at a younger audience–middle school and below–, but there are things like Khan Academy that’s useful for all ages. Quite a number have to do with introducing coding.

Ms. Lannert.

Volumes of Rotation: The Disk Method: 3d with Javascript Three.js

Finally, relatively easy interactive 3d on the web. You can rotate and zoom into the scene. (Although it may not yet be compatible with all browsers it does work with Firefox at least).

This method uses the three.js Javascript library. Here I use it to show the volume of a rotated surface using the disk method. It’s almost identical to my calculus student’s project, except here I’m finding the volume between x=1 and x=3, using disks that are 0.5 units in height (Δx).

Since the volume of cylinder is:

 V_{cylinder} = \pi r^2 h

where r is the radius of the cylinder.

We’re finding the volume created by a function that’s rotated around the x-axis. Using the function:

 y = -\frac{x^2}{4}+4

The radius of each cylinder is the value of the function for that x value, so you could write the radius as:

 R(x) = -\frac{x^2}{4}+4

Therefore the volume of each disk is:

 V_{disk} = \pi R(x)^2 \Delta x

There are four disks and we use the function value at the far end of the disk to draw the disk so the total volume is:

 V = \pi R(1.5)^2 \Delta x + \pi R(2.0)^2 \Delta x + \pi R(2.5)^2 \Delta x + \pi R(3.0)^2 \Delta x

Factoring out the π and the Δx gives:

 V = \pi \Delta x \left(R(1.5)^2 +  R(2.0)^2 + R(2.5)^2  +  R(3.0)^2 \right)

Since Δx = 0.5, a = 1.0, and b = 3.0, we can define the number of disks as n = 4 then we can rewrite using summation formula:

 V = \pi \Delta x \sum\limits_{i=1}^n R(1.0+i \Delta x)^2

reverting back to a and b gives the general equation:

 V = \pi \Delta x \sum\limits_{i=1}^n R(a+i \Delta x)^2

where:
 n = \frac{b-a}{\Delta x}

Project Euler: Math/Programming Challenge

On the recommendation of Mr. Schmidt, two of my students have been quite fascinated over the last few days trying to solve problems on Project Euler. They’ve been working on them together to, I suspect, the detriment of some of their other classes, but as their math teacher I find it hard to object.

An example problem is something like this:

If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.

Find the sum of all the multiples of 3 or 5 below 1000.

They’ve been solving them numerically using Python. It’s been quite fascinating to see.