#### February 25, 2014

Student’s program to calculate the volume of a curve rotated around the x-axis using the Disk Method in Calculus.

This VPython program was written by a student, Mr. Alex Shine, to demonstrate how to find the volume of a curve that’s rotated around the x-axis using the disk method in Calculus II.

The program finds volume for the curve:

between *x = 0* and *x = 3*.

To change the curve, change the function *R(x)*, and to set the upper and lower bounds change *a* and *b* respectively.

*volume_disk_method.py* by Alex Shine.

from visual import*
def R(x):
y = -(1.0/4.0)*x**2 + 4
return y
dx = 0.5
a = 0.0
b = 3.0
x_axis = curve(pos=[(-10,0,0),(10,0,0)])
y_axis = curve(pos=[(0,-10,0),(0,10,0)])
z_axis = curve(pos=[(0,0,-10),(0,0,10)])
line = curve(x=arange(0,3,.1))
line.color=color.cyan
line.radius = .1
line.y = -(1.0/4.0) * (line.x**2) + 4
#scene.background = color.white
for i in range(-10, 11):
curve(pos=[(-0.5,i),(0.5,i)])
curve(pos=[(i,-0.5),(i,0.5)])
VT = 0
for x in arange(a + dx,b + dx,dx):
V = pi * R(x)**2 * dx
disk = cylinder(pos=(x,0,0),radius=R(x),axis=(-dx,0,0), color = color.yellow)
VT = V + VT
print V
print "Volume =", VT

**Citing this post**: **Urbano**, L., 2014. Finding Volumes Using the Disk Method, Retrieved March 27th, 2017, from *Montessori Muddle*: http://MontessoriMuddle.org/ .

**Attribution (Curator's Code )**: Via: ᔥ Montessori Muddle; Hat tip: ↬ Montessori Muddle.

Posted in Mathematics, ProgrammingNo Comments » - Tags: calculus, geometry, volumes, vpython

#### April 20, 2013

Numerically integrating the area under the curve using four trapezoids.

I gave a quick introduction to programming for my calculus class, which has been working on numerical integration.

Numerical integration is usually used for functions that can’t be integrated (or not easily integrated) but for this example we’ll use a simple parabolic function so we can compare the numerical results to the analytical solution (as seen here).

With the equation:

To find the area under the curve between *x = 1* and *x = 5* we’d find the definite integral:

which gives the result:

For numerical integration, we break the area of concern into a number of trapezoids, find the areas of all the trapezoids and add them up.

We’ll define the left and right boundaries of the area as **a** and **b**, and we can write the integral as:

The left and right boundaries of the area we’re interested in are defined as *a* and *b* respectively. The area of each trapezoid is defined as A_{n}.

We also have to choose a number of trapezoids (**n**) or the width of each trapezoid (**dx**). Here we choose four trapezoids (*n = 4*), which gives a trapezoid width of one (*dx = 1*).

The area of the first trapezoid can be calculated from its width (dx) and the height of the two upper ends of the trapezoid (f(x_{0}) and f(x_{1}).

So if we define the x values of the left and right sides of the first trapezoids as *x*_{0} and *x*_{1}, the area of the first trapezoid is:

For this program, we’ll set the trapezoid width (*dx*) and then calculate the number of trapezoids (*n*) based on the width and the locations of the end boundaries *a* and *b*. So:

and the sum of all the areas will be:

We can also figure out that since the x values change by the same value (dx) for every trapezoid, it’s an arithmetic progression, so:

and,

so our summation becomes:

Which we can program with:

*numerical_integration.py*

# the function to be integrated
def func(x):
return -0.25*x**2 + x + 4
# define variables
a = 1. # left boundary of area
b = 5. # right boundary of area
dx = 1 # width of the trapezoids
# calculate the number of trapezoids
n = int((b - a) / dx)
# define the variable for area
Area = 0
# loop to calculate the area of each trapezoid and sum.
for i in range(1, n+1):
#the x locations of the left and right side of each trapezpoid
x0 = a+(i-1)*dx
x1 = a+i*dx
#the area of each trapezoid
Ai = dx * (func(x0) + func(x1))/ 2.
# cumulatively sum the areas
Area = Area + Ai
#print out the result.
print "Area = ", Area

And the output looks like

>>>
Area = 17.5
>>>

While the programming is pretty straightforward, it was a bit of a pain getting Python to work for one of my students who is running Windows 8. I still have not figured out a way to get it to work properly, so I’m considering trying to do it using Javascript.

# Update

The javascript functions for numerical integration:

function numerically_integrate(a, b, dx, f) {
// calculate the number of trapezoids
n = (b - a) / dx;
// define the variable for area
Area = 0;
//loop to calculate the area of each trapezoid and sum.
for (i = 1; i <= n; i++) {
//the x locations of the left and right side of each trapezpoid
x0 = a + (i-1)*dx;
x1 = a + i*dx;
// the area of each trapezoid
Ai = dx * (f(x0) + f(x1))/ 2.;
// cumulatively sum the areas
Area = Area + Ai
}
return Area;
}
//define function to be integrated
function f(x){
return -0.25*Math.pow(x,2) + x + 4;
}
// define variables
a = 1; // left boundary of area
b = 5; // right boundary of area
dx = 1; // width of the trapezoids
// print out output
alert("Area = "+ numerically_integrate(a, b, dx, f));

This is a demonstration of a full html file that uses the function, and should work in any modern browser (download files: numerical-integration.zip).

# Update 2

I've added the above javascript code to the embeddable graphs to allow it to calculate and display numerical integrals: you can change the values in the interactive graph below.

**Citing this post**: **Urbano**, L., 2013. Programming Numerical Integration with Python (and Javascript), Retrieved March 27th, 2017, from *Montessori Muddle*: http://MontessoriMuddle.org/ .

**Attribution (Curator's Code )**: Via: ᔥ Montessori Muddle; Hat tip: ↬ Montessori Muddle.

Posted in Calculus, Mathematics, ProgrammingNo Comments » - Tags: calculus, embeddable graphs, integration, javascript, math and programming, numerical methods, programming, python

#### March 13, 2013

Animation showing the motion of the ballistic motion of a soccer ball.

If you throw a soccer ball up into the air and take a quick series of photographs you can capture the motion of the ball over time. The height of the ball can be measured off the photographs, which can then be used for some interesting physics and mathematics analysis. This assignment focuses on the analysis. It starts with the height of the ball and the time between each photograph already measured (Figure 1 and Table 1).

Figure 1. Height of a thrown ball, measured off a series of photographs. The photographs have been overlaid to create this image of multiple balls.

*Table 1: Height of a thrown soccer ball over a period of approximately 2.5 seconds. This data were taken from a previous experiment on projectile motion.*

Photo |
Time (s) |
Measured Height (m) |

P_{0} |
0 |
1.25 |

P_{1} |
0.436396062 |
6.526305882 |

P_{2} |
0.849230104 |
9.825317647 |

P_{3} |
1.262064145 |
11.40310588 |

P_{4} |
1.674898187 |
11.30748235 |

P_{5} |
2.087732229 |
9.657976471 |

P_{6} |
2.50056627 |
6.191623529 |

# Assignment

- Pre-Algebra: Draw a graph showing the height of the ball (y-axis) versus time (x-axis).
- Algebra/Pre-calculus: Determine the equation that describes the height of the ball over time:
*h(t)*. Plot it on a graph.
- Calculus: Determine the equation that shows how the velocity of the ball changes over time:
*v(t)*.
- Calculus: Determine the equation that shows how the acceleration of the ball changes with time:
*a(t)*
- Physics: What does this all mean?

**Citing this post**: **Urbano**, L., 2013. Analyzing the Motion of Soccer Ball using a Camera and Calculus, Retrieved March 27th, 2017, from *Montessori Muddle*: http://MontessoriMuddle.org/ .

**Attribution (Curator's Code )**: Via: ᔥ Montessori Muddle; Hat tip: ↬ Montessori Muddle.

Posted in Algebra, Calculus, Mathematics, Natural World, PhysicsNo Comments » - Tags: algebra, ballistics, calculus, experiments, math applications, physics

#### February 22, 2013

The first stage rocket booster separates. Image from NASA via Wikipedia.

Fully loaded, the first stage of the Saturn V rockets that launched the Apollo missions would burn through a liter of fuel for every four centimeters it moved. That’s 5 inches/gallon, which, for comparison, is a lot less than your modern automobile that typically gets over 20 miles/gallon.

**Citing this post**: **Urbano**, L., 2013. Rates of change: 4 cm/liter, Retrieved March 27th, 2017, from *Montessori Muddle*: http://MontessoriMuddle.org/ .

**Attribution (Curator's Code )**: Via: ᔥ Montessori Muddle; Hat tip: ↬ Montessori Muddle.

Posted in Algebra, Calculus, MathematicsNo Comments » - Tags: algebra, calculus, math, rates of change

#### February 19, 2013

Approaching a change in slope.

We took a school trip to the ski slopes in Hidden Valley. It was the interim, and it was a day dedicated to taking a break. However, it would have been a great place to talk about gradients, changes in slopes, and first and second differentials. The physics of mass, acceleration, and friction would have been interesting topics as well.

Calculus student about to take the second differential.

This year has been cooler than last year, but they’ve still struggled a bit to keep snow on the slopes. They make the snow on colder nights, and hope it lasts during the warmer spells. The thermodynamics of ice formation would fit in nicely into physics and discussion of weather, while the impact of a warming climate on the economy is a topic we’ve broached in environmental science already.

The blue cannon launches water into the air, where, if it’s cold enough, it crystallizes into artificial snow. The water is pumped up from a lake at the bottom of the ski slopes.

**Citing this post**: **Urbano**, L., 2013. Ski Trip (to Hidden Valley), Retrieved March 27th, 2017, from *Montessori Muddle*: http://MontessoriMuddle.org/ .

**Attribution (Curator's Code )**: Via: ᔥ Montessori Muddle; Hat tip: ↬ Montessori Muddle.

Posted in Algebra, Calculus, Environmental Science, Mathematics, Natural World, PhysicsNo Comments » - Tags: algebra, calculus, climate change, global warming, interim, math, physics applications, skiing

#### October 16, 2012

Inverse relationships pop-up everywhere. They’re pretty common in physics (see Boyle’s Law for example: P ∝ 1/V), but there you sort-of expect them. You don’t quite expect to see them in the number of views of my blog posts, as are shown in the Popular Posts section of the column to the right.

*Table 1: Views of the posts on the Montessori Muddle in the previous month as of October 16th, 2012.*

You can plot these data to show the relationship.

Views of the top 10 blog posts on the Montessori Muddle in the last month (as of 10/16/2012).

And if you think about it, part of it sort of makes sense that this relationship should be inverse. After all, as you get to lower ranked (less visited) posts, the number of views should asymptotically approach zero.

## Questions

So, given this data, can my pre-Calculus students find the equation for the best-fit inverse function? That way I could estimate how many hits my 20th or 100th ranked post gets per month.

Can my Calculus students use the function they come up with to estimate the total number of hits on all of my posts over the last month? Or even the top 20 most popular posts?

**Citing this post**: **Urbano**, L., 2012. Inverse Relationships, Retrieved March 27th, 2017, from *Montessori Muddle*: http://MontessoriMuddle.org/ .

**Attribution (Curator's Code )**: Via: ᔥ Montessori Muddle; Hat tip: ↬ Montessori Muddle.

Posted in Calculus, MathematicsNo Comments » - Tags: calculus, math, pre-Calculus, real data, real-time data, using real data

#### August 30, 2012

Microsoft Excel, like most graphical calculators and spreadsheet programs, has the built in ability to do linear regression of measured data using certain types of functions — lines, polynomials, logarithms, and exponents for example. However, you can get it to do any type of function — sinusoidal, natural log, whatever — if you work through the spreadsheet and can use the iterative Solver tool.

This more general approach is quite useful in teaching pre-Calculus, because the primary purpose of all the functions they have to learn is to create mathematical models (functions) based on data that can be used for predictions.

### The Data

I started this year’s pre-calculus class by having them collect some data. In a simplification of the snow-melt experiment I did with the middle school last year, I had them put a beaker of water (about 300ml) on a hot plate and measure the temperature every minute as warmed up.

To make the experiment a little more interesting, I had each student in each group of four take just three consecutive measurements and try to find the equation of the straight line that best fit their data, and could be used to try to predict the other measurements of their peers in their group.

Figure 1. Scatter plot of measured temperatures during the warming of a beaker of water on a hot plate. Data given in Table 1.

It did not quite work out as I’d hoped. Since you only need two points to find the equation of a straight line, having three points produced a little confusion. I’d hoped to produce that confusion, but hadn’t realized that I’d need to do a review of how to find the equation of a straight line. A large fraction of the class was a little bit rusty after hot months of summer.

So, we pooled all the data and reviewed how to find the equation of a straight line.

*Table 1: The Data*

Time (minutes) |
Measured Temperature (°C) |

0 |
22 |

1 |
26 |

2 |
31 |

3 |
36 |

4 |
40 |

5 |
44 |

6 |
48 |

7 |
53 |

8 |
58 |

9 |
61 |

10 |
65 |

11 |
68 |

12 |
71 |

### Finding the Equation for a Straight Line using Two Points

The general equation for a straight lines is:

(1)

and we need to determine the coefficients *m* and *b*. *m* is the slope, which can be calculated from two points using the equation:

(2)

using the points at *t=6* and *t=11* — the points (x_{1}, y_{1}) = (6,48) and (x_{2}, y_{2}) = (11,68) respectively — for example, gives a slope of:

so our general equation becomes:

to find *b* we substitute either one of the points into the equation for *x* and *y*. If we use the first point, *x = 6*, and *y = 48*, we get:

and the equation of our line becomes:

(3)

Now, since we’re actually looking at a relationship between temperature and time, with temperature on the y-axis and time on the x-axis, we could relabel the terms in the equation with T = temperature and t = time to have:

(4)

While this equation is more satisfying to me, because I think it better describes the relationship we have, the more vocal students preferred the equation in terms of x and y (Eqn 3). These are the terms they are more familiar with in the context of a math class, and I recall seeing some evidence that students seem to learn better with the more abstract representations sometimes (though I can’t quite remember the source; I should have blogged about it).

### Plotting the Data and the Modeled Straight Line

The straight line equation we came up with (Eqn. 4) is our *model* of the data. It’s not quite perfect. All the data do not lie on the line, although, if we did everything right, only the points (6, 48) and (11, 68) are guaranteed to be on the line.

Figure 2. The equation of our straight line model (red line) matches the data (blue diamonds) pretty well.

I showed the class how to plot the scatter graph using MS Excel, and how to draw the line to show the modeled data. The measured data are represented as points since the measurements were made at discrete points in time. The modeled equation, however, is a continuous function, hence the straight line. The Excel sheet below (Resource 1) illustrates:

Resource 1: Excel Spreadsheet of Measured versus Modeled Data

### The Best Fit Curve

The Excel spreadsheet (Resource 1) was set up so that when I entered the slope (m) and intercept (b) values, the graph would quickly update. So I went through the class. Everyone called out their slope and intercept values, I plugged them in, and they could all see how the modeled line changed slightly based on the points used to calculate it. So I put the question to them, “How can we figure out which model equation is the best?”

That’s how I was able to introduce the topic of error. What if we compared the temperature predicted by the model for each data point, to the actual value. The smaller the difference in modeled versus measured temperatures, the better the fit of the model. Indeed, if we sum all the differences, or better yet take the average of the differences, we could get a single number, we’ll call the average error (ε), that could be used to compare the different models. I used this opportunity to introduce sigma notation, which the pre-calculus students had not seen much of before.

As a first pass (which, as we’ll see below, has a major problem), the error (ε) for each point (i) is:

The average error is the sum of all the errors divided by the number of points (n) (we have 12 points so *n=12* in this example):

(5)

Now this works, but there is one problem. I was quite pleased and a little bit surprise that one of my students recognized what it was without any coaxing and also suggested a solution: by simply taking the difference to calculate the error, a point that is offset above the modeled line can be canceled out by a point offset by the same amount below the line. So what we really need is to use the absolute value of the error.

(6)

This works, and is what we went with, but I did also point that what’s usually done is to use the square of the error instead of the absolute value. Squaring makes any number positive, so it accomplishes the same goal as the absolute value, and is the approach we’ll use when I go into linear regression later on.

Setting up the Excel spreadsheet to calculate the average error is fairly straightforward as shown in Resource 2:

Resource 2. Calculating the average error using Excel.

So once again, we went through the class and everyone called out their slope and intercept values and cheered when I plugged the numbers in and they saw if they had the lowest value.

It is important to remember, though, that the competition gives a somewhat random result: students’ average error is a function of the points they happened to pick, not how well they did the math (assuming everyone did the math correctly).

Figure 2. Showing the spreadsheet used to calculate the average error (Resource 2).

**Citing this post**: **Urbano**, L., 2012. Modeling Data with Straight Lines using Excel, Retrieved March 27th, 2017, from *Montessori Muddle*: http://MontessoriMuddle.org/ .

**Attribution (Curator's Code )**: Via: ᔥ Montessori Muddle; Hat tip: ↬ Montessori Muddle.

Posted in Calculus, MathematicsNo Comments » - Tags: calculus, data, data collection, math, pre-Calculus, temperature, using real data

#### July 24, 2012

The video shows 300 seconds of purely exponential growth (uninhibited), captured from the exponential growth VAMP scenario. Like the exponential growth function itself, the video starts off slowly then gets a lot more exciting (for a given value of exciting).

The modeled growth is based on the exponential growth function:

(1)

where:

*N* = number of cells (or concentration of biomass);
*N*_{0} = the starting number of cells;
*r* = the rate constant, which determines how fast growth occurs; and
*t* = time.

### Finding the Rate Constant/Doubling Time (*r*)

You can enter either the rate constant (*r*) or the doubling time of the particular organism into the model. Determining the doubling time from the exponential growth equation is a nice exercise for pre-calculus students.

Let’s call the doubling time, *t*_{d}. When the organism doubles from it’s initial concentration the growth equation becomes:

divide through by *N*_{0}:

take the natural logs of both sides:

bring the exponent down (that’s one of the rules of logarithms);

remember that ln(e) = 1:

and solve for the doubling time:

### Decay

A nice follow up would be to solve for the half life given the exponential decay function, which differs from the exponential growth function only by the negative in the exponent:

The UCSD math website has more details about Exponential Growth and Decay.

### Finding the Growth Rate

A useful calculus assignment would be to determine the growth rate at any point in time, because that’s what the model actually uses to calculate the growth in cells from timestep to timestep.

The growth rate would be the change in the number of cells with time:

starting with the exponential growth equation:

since we have a natural exponent term, we’ll use the rule for differentiating natural exponents:

So to make this work we’ll have to define:

which can be differentiated to give:

and since *N*_{0} is a constant:

substituting in for *u* and *du/dt* gives:

rearranging (to make it look prettier (and clearer)):

(2)

### Numerical Methods: Euler’s method

With this formula, the model could use linear approximations — like in Euler’s method — to simulate the growth of the biomass.

First we can discretize the differential so that the change in *N* and the change in time (*t$*) take on discrete values:

Now the change in *N* is the difference between the current value *N*^{t} and the new value *N*^{t+1}:

Now using this in our differentiated equation (Eq. 2) gives:

Which we can solve for the new biomass (*N^*^{t+1}):

to get:

This linear approximation, however, does introduce some error.

The approximated exponential growth curve (blue line) deviates from the analytical equation. The deviation compounds itself, getting worse exponentially, as time goes on.

Excel file for graphed data: exponential_growth.xls

### VAMP

This is the first, basic but useful product of my summer work on the IMPS website, which is centered on the VAMP biochemical model. The VAMP model is, as of this moment, still in it’s alpha stage of development — it’s not terribly user-friendly and is fairly limited in scope — but is improving rapidly.

**Citing this post**: **Urbano**, L., 2012. Exponential Cell Growth, Retrieved March 27th, 2017, from *Montessori Muddle*: http://MontessoriMuddle.org/ .

**Attribution (Curator's Code )**: Via: ᔥ Montessori Muddle; Hat tip: ↬ Montessori Muddle.

Posted in Biology, Calculus, Mathematics, Natural World, videoNo Comments » - Tags: biology, calculus, imps, math, math and programming, microbiology, numerical methods, population growth, pre-Calculus