Linear Functions, Cardiods, and the Mandelbrot Set

This tweet was retweeted by Steve Strogatz:

What a great video, linking linear functions, cardiods, and the family of Mandelbrot sets. Rang my bell.

Here’s some of my previous lessons and experiments that involved these things:

  • The Mandelbrot Set viewed through Pre-Calculus. Presentation, Lesson Plans, and Interactives. Links to the various blog posts are at the bottom of the page.
  • Processing Experiments:
    • Waning Moon – Steps through linear functions with slope 1 to 4.
    • Interactive Waning Moon – Uses the mouse to control the slope and the y-intercept of the linear function.
    • Linear Waning Moon – Interactive. Same process, but instead of a circle, inputs are in a line at the top and outputs are in a line at the bottom.
    • Linear Mod Art – Interactive, similar setup as above, but useful for teaching how it works.
    • Sine Mod Art – Same as above, but using a sine function instead of a linear function.
    • Waning Sine Moon – Interactive circular version using sine.
    • Waning Exponential Moon – Interactive circular version using an exponential function.

The nice thing about the processing versions is you can pretty easily create large image files that you can print:


The Last Seat : Car Talk Puzzler

Yet another great car talk puzzler, The Last Seat:

RAY: You’re one of a hundred people standing in line to get onto an airplane that has 100 seats. There’s a seat for every person who’s in line, and each of you has a boarding pass for your assigned a seat. The first person to walk onto the plane drops his boarding pass and, instead of picking it up, decides, “I’m just going to sit anyplace.” He takes a seat at random.

Now, every other passenger will take either his assigned seat or, if that seat is taken, that passenger will take any seat at random.

TOM: I’ve been on that flight!

RAY: You are the last passenger to walk onto the plane. Obviously, there’s going to be one seat left, because everyone else is sitting in his correct seat, or not.

The question is: What are the chances that you get to sit in your assigned seat? I’m going make this multiple choice.

A: 1 out of 2.
B: 1 out of 10.
C: 2 out of 50.
D: 1 out of 100
E: Zero.

What strategies could you give students to help them reason their way through this puzzle?

Visualization of a Function Through Time

(This post demonstrates the math behind the creation of some unusual math art. I got the idea from this tumblr post which I don’t even think works like this. But it was the inspiration behind the pictures.)

Take this function: f(x) = x^2 + a*cos(ax). When you take values of a between 0 and 8 and back to 0, you get the following:


I’d like to make an image that represents the entire family of this function. Problem one: the function values get pretty large in this window, so find the remainder of the function output after dividing by 5. Here’s the gif of that output:

gifsmos (1)

Problem two: How do we represent this in one static picture? If you take the first image (where a = 0)


and take the function values from 0 to 5 and make the pixels for row 1 colored based on the function value (0 being black, and 5 being white), then you get this row of pixels (expanded to 20 pixels high for ease of viewing):


So this row of pixels represents a = 0. If you set a to be 0 at the top of the picture, a to be 8 at the middle of the picture, and a to be back to 0 at the bottom of the picture, stitch all these lines together you get:

Click on image for full 4k by 4k resolution.

Here’s another with the function y=(10a)/(1+x^2) with a going from 8 to 0 to 8.

Click on image for full 4k by 4k resolution.

Here’s another with the function y=ceil(ax) – ax + floor(ax) with a going from 0 to 5 to 0.

Click on image for full 4k by 4k resolution.

And lastly, here’s the last one, but colorized. The 0 to 255 now controls the hue of the color (with full saturation and balance, using HSB color).
Click on image for full 4k by 4k resolution.

Here’s the code for those who are interested (or view it live on openprocessing)!

int max_a;

float mod(float a, float b)
  //desmos mod and processing mod act differently.
  //desmos mod always returns a positive value
  return (abs(a % b));

float func(float x, float a)
  //type 1
  max_a = 8;
  return (mod(x*x - a * cos(a*x),5));
  //type 2 this counts from a= 8 to 0 to 8
  //max_a = 8;
  //a = max_a - a;
  //return (mod((10*a)/(1+x*x) ,5));
  //type 3
  //max_a = 5;
  //return(mod(ceil(a*x)-a*x+floor(a*x) ,5));

void setup()
  int w,h;
  float x,a,f,hue;
  max_a = 5;
  for (int i = 0; i < pixels.length; i++)
    w = i % width;
    h = int(i / width);
    x = map(w,0,width,-6,6);
    if (h < height/2)
      a = map(h,0,height/2,0,max_a);
      a = map(h,height/2,height,max_a,0);

    f = func(x,a);
    hue = map(f,0,5,0,255);
    pixels[i] = color(hue,255,255);

edit 10/16/15:
Here are a couple more pictures for you (the code on openprocessing is up to date with these new types):


Madeup and Calculus

The madeup language for creating 3d models came out a week ago for the kickstarter backers. There is more information about the computer programming language found at the kickstarter page. It’s been a lot of fun to play with but looking at it through the lens of being able to create calculus 3d solids has been really exciting.

Rotational Volumes

Here is the code to sketch out this 2d shape on the x-y plane and rotate it around the x-axis:
Screenshot 2015-10-09 at 2.10.41 PM

to func x
    out = -1 * (x - 1)^2 + 5

moveto 0,0,0
x = 0
xmax = 3.0
numPoints = 100

while (x < xmax)
    out = func(x)
    moveto x,out,0
    x = x + xmax//numPoints

moveto xmax,0,0
moveto 0,0,0

nsides = 100
revolve 1,0,0,270

When you click the solidify you get this 3d shape (only rotated 3/4 of the way around for sake of visulization):
Screenshot 2015-10-09 at 2.04.11 PM

Here’s the magic step. Click Download and open the .obj file with your 3d printer software and hit print:

IMG_1866 (1)

Want to rotate around the y-axis instead and practice shells? No problem.


And print!




Cross-sectional Volumes

The AP (but not the IB) curriculum has students find the volume of a solid created by extruding out a known cross-section from a given area. For instance, on the 2010 AP Calculus AB exam, they asked the following question, zone in on part (c):
Screenshot 2015-10-09 at 1.33.40 PM
This type of question is difficult for students to visualize. Madeup can make some great models (that can be printed) for the students. While I think the programming is tricky enough that I wouldn’t encourage you to bring the code directly to novices; it is pretty clean and easy to modify. For example: take the same area as above and find the volume by taking cross sectional squares with one side on the xy plane and perpendicular to the x-axis.

In the madeup world, the code looks like this:

to func x
    out = x ^ 0.5 + 1

moveto 0,0,0
x = 0
xmax = 3
numRect = 14

while (x < xmax)
    out = func(x)
    moveto x,out,0
    moveto x + xmax//numRect,out,0
    moveto x + xmax//numRect,0,0
    moveto x,0,0
    x = x + xmax//numRect
    extrude 0,0,1,out

moveto xmax,0,0
moveto 0,0,0

When you hit the extrude button, it takes the 14 rectangle slices and brings it up the z-axis to make a square. The result is the 3d shape:


Here’s the shape (approximated) with 4 rectangles:


And here’s the shape with 100 rectangles:





Enjoy! As always, please fire away with questions/comments/etc.

Programming and Anna Weltman’s This Is Not A Math Book and Dan Meyer’s Contest

PSA: check out Anna Weltman’s new book, This Is Not A Math Book. Looks great.
Also check out Dan Meyer’s fall contest (ends 10/6/15) that asks the students to be creative in making their own Loop-de-loop mathematical art.
Programming connection: have the students make their loop-de-loop with python and turtles, here is a 3-5-2 loop-de-loop:
or with Scratch, here is a 2-4-5: 2015-09-29_07h56_53

BetterQs Blog

At TMC 2015 I attended a fantastic session by Rachel Kernodle that encouraged us to improve our questioning in class. I took this goal to heart, in fact, it ended up being my “One TMC15 Thing” that I’d like to work on.

Thankfully this message found much traction in the #mtbos. Rachel and Sam Shah started up the BetterQs blog where many guests have written posts on questioning. I wrote a post today, Hints and One Helpful Question. If you’d like, go over and read it, and considering adding BetterQs to your blog aggregator of preference.

Car Talk: False Positive?

From the fantastic car talk puzzler division

RAY: There’s a rare disease that’s sweeping through your town. Of all the people who are exposed to it, 0.1 percent of the people actually contract the disease. There are no symptoms until the disease actually occurs. However, there’s a diagnostic test that can detect the presence of the disease up to a year before it strikes. You go to your doctor, and he administers the test. It comes out positive. You say, “I’m done for!” Then you get a little bit encouraged. You say, “Wait a minute, doc, is this test 100 percent accurate?” Your doctor responds, “Well, not really. It’s 95 percent accurate.” In other words, 5 percent of the people who take the test will test positive but they don’t really have the disease. Here’s the question: What are the chances that you actually have the disease?

Car Talk: Barber Math

From the fantastic car talk puzzler:

RAY: A barber had his first customer of the day, who happened to be a friend. When he was done, the barber refused to take the money from the customer. The fellow said, “Look, I know we’re friends, but, business is business. I want to pay for my haircut.”

The barber said, “Here’s what we’ll do. You open the cash register. I don’t have any idea how much money is in there. But, you match whatever is in there, and then take out 20 bucks.”

The customer says, “Okay,” and he does that.

The barber says, “Gee, I kind of like this.” So, the next customer comes in, he gets his haircut, and the barber says, “You can do the same thing my first customer did. Open the cash register, match what’s in there, and then take out 20 bucks.”

The second customer does that, and he leaves. The third customer does the same. The fourth customer, after receiving his haircut, opens the cash register, and says, “I can’t do it. ”

The barber says, “Why not?”

“There’s no money in here. Not a cent.”

The question is, how much money was in there to start?

Tracking Venus and Earth over 8 years

I came about this tweet:

It reminded me strongly of the waning moon and linear mod art projects that I’ve been playing with.

For instance, here’s a screenshot from the waning moon (specifically y = 56x)
A quick intro: the picture above was made by taking 360 points around a circle, and shifting them by the function (y = 56x), and then graphing a line between the input and output. If the output is greater than 360, then take the remainder after dividing by 360.
pent drift
From lunar planner.

And from John Carlos Baez’s blog:

It’s called the pentagram of Venus, because it has 5 ‘lobes’ where Venus makes its closest approach to Earth. At each closest approach, Venus move backwards compared to its usual motion across the sky: this is called retrograde motion.

Actually, what I just said is only approximately true. The Earth orbits the Sun once every


days. Venus orbits the Sun once every


days. So, Venus orbits the Sun in

224.701 / 365.256 ≈ 0.615187

Earth years. And here’s the cool coincidence:

8/13 ≈ 0.615385

That’s pretty close! So in 8 Earth years, Venus goes around the Sun almost 13 times. Actually, it goes around 13.004 times.

2015-05-19 13h39_41
Hey do you recognize what that ratio is close to?

Anyway, there’s a lot to investigate here. How is the function y = 56x related to these planetary orbits?