20  Modeling with Functions

In this chapter, we’ll discuss one particular kind of modeling: approximating data with functions.

This kind of work, at the high-school level, is often not very data-sciencey. You get two columns of data, X and Y, and you’re trying to find a function so that if you make a scatter plot, the function comes close to the points. You are not awash in data.

You do, however, have a mathematical challenge involving data. It’s also the case that challenges like this “smell like” science. So it can be data and science without being data science.

That said, we can note:

20.1 Resource for Algebra II, Precalc, and beyond

I have another book, available on paper, called “The Model Shop.” It’s a collection of activities that connect geometry to functions through data. The activities are cool, but not within the scope of this book here.

That book has illustrations from Desmos and Fathom, but you can almost do everything in CODAP.

20.2 Basic modeling tools

If your graph has two numeric attributes—that is. it’s a scatter plot—various modeling tools are available.

20.2.1 Lines

You can find both a least-squares line and a movable line in the ruler palette. The movable line is especially cool; a line appears with handles, and as you change the line, the formula for the line updates.

If you have grouped the data (by dragging a categorical leftwards), the least-squares tool creates a separate line for each group.

20.2.2 More general functions

The ruler palette also has a Plot function command. If you select it, a white area appears at the top of the plot; if you click it, the formula editor appears.

Two caveats:

  • As with formulas for attributes, what you enter should only be the part after the equals sign. That is, if you’re entering \[A = \pi r^2\],

what you enter is pi * r^2 * As that formula suggests, the formula editor does not do implied multiplication. So enter a function like \[y = 2x(x-a)\] as 2 * x * (x - a)

20.2.3 Sliders

In the previous example, 2 * x * (x - a), that quantity a is a parameter. In CODAP, you should use a slider to represent it.

You’ll find sliders in the toolbar. Click the icon to create a slider in your workspace.

By default, the slider will have a name like V1 (that is, value 1) and a value of 0.5. Obviously, you slide the widget to change the value; you can also edit the value directly. Two things are not obvious:

  • The slider is actually an axis just like the axis of a graph, so you can rescale the axis by dragging the numbers, just as you do in a graph axis.
  • The name of the slider is editable as well. So rename it to something sensible (like a or density or whatever).

20.3 Nonlinear practice

Want to practice? The live example below show data from a video of a cotton ball falling. It’s very rough data, but the plot shows a distinct curve that we suspect of being quadratic. It may not start at time zero, however, so we might need two sliders, one for the quadratic corfficient, and one for the horizontal translation. (The ball was released at position zero, so we are spared the vertical translation for now.)

20.3.1 Show squares

If you check the Show squares box in the ruler palette, CODAP constructs a square on each residual segment and displays the sum of squares.

This is perfect for explaing the meaning of a least-squares model. That said, I am personally more interested in getting a model that’s pretty good than optimizing one.

20.4 Simple example: that Glucose thing

20.5 More complex example: BMI

20.6 Residuals

One thing I miss in CODAP that was present in Fathom was an easy way to see residuals. In Fathom, we learned how powerful residuals could be in helping create and assess functional models like these.

When I taught with CODAP, my students learned how to make residual plots for this purpose. It’s not automatic, but they were (mostly) able to handle it. The process ended up requiring two separate graphs: the original and the residual plot.

Here’s how it would work:

xxx continue and fill in