# Engaging students: Solving one-step algebra problems

In my capstone class for future secondary math teachers, I ask my students to come up with ideas for engaging their students with different topics in the secondary mathematics curriculum. In other words, the point of the assignment was not to devise a full-blown lesson plan on this topic. Instead, I asked my students to think about three different ways of getting their students interested in the topic in the first place.

I plan to share some of the best of these ideas on this blog (after asking my students’ permission, of course).

This student submission again comes from my former student Emma White. Her topic, from Algebra: solving one-step algebra problems.

How can this topic be used in your students’ future courses in mathematics or science?

Solving one-step algebra problems strings into many future scenarios the student may (and will probably) encounter. One-step algebra problems infer that there must be two-step algebra problems and three-step algebra problems and so forth. As mathematicians, we know this to be true. While mathematics in my focus of study, I want to show the importance of learning this concept as it will aid in other classes. Stoichiometry is a concept taught in chemistry that has to do with the “relationship between reactants and products in a reaction” (Washington University in St. Louis, 2005). Chemical reactions require a balance. Essentially, once-step algebra expressions require just the same where both sides of the equations must be equal for the expression to be true. An example of a stoichiometry equation one may see in chemistry would be:

_KMnO${}_4$ + _HCl → _MnCl${}_2$ + _KCl + _Cl${}_2$ + _H${}_2$O

In the blanks, a variable can be placed, such that:

aKMnO${}_4$ + bHCl → cMnCl${}_2$ + dKCl + eCl${}_2$ + fH${}_2$O

Next, we would apply the Conservation of Mass. This concept deals with the number of atoms that must be on each side for the equation to be balanced. Writing the elements and their balanced equations with the variables, it follows:

K: a = d
Mn: a = c
O: 4a = f
H: b = 2f
Cl: b = 2c + d + 2e

As we can see, there is going to be more expressions and substitutions that must take place. That is something you can solve on your own if you wish. Overall, we see the importance of learning one-step algebra problems because this will be the foundation for solving more complex questions, even more so outside of the math classroom.

How has this topic appeared in high culture (art, classical music, theatre, etc.)?

Theatre is more than the actors on the stage. While the performance and show are the part most people acknowledge and enjoy, the technical part behind the performance is what allows the show to happen. Algebraic problems are often used in technical theatre, especially when it comes to building a set. A prime example is building a single foundation (usually used in One Act plays where the whole play takes place in one scene). Focusing on a rectangular foundation, if we know the amount of space the actors, set, and featuring décor need, we can use this in an algebraic expression. Furthermore, if we also know dimensions of one of the sides (length or width), a variable can be used for the unknown side (since the area of a rectangle is length times the width). If we want to take this a step further, multiple one-step algebraic expressions can be used when making the foundation. If we know the length and width of the foundation and the length and width of the sheet floorboards to be used, we can write various expressions to determine how many sheet floorboards need to be used lengthwise and widthwise (example shown below).

How can technology (YouTube, Khan Academy [khanacademy.org], Vi Hart, Geometers Sketchpad, graphing calculators, etc.) be used to effectively engage students with this topic?

The use of technology is on the rise and the involvement of newer generations is greatly rising as well. Because of this, utilizing online resources is an effective way to capture the attention of the students and make math more engaging. Using algebra tiles is a perfect way to resemble this topic, even more so when it can be done online. Therefore, the teacher does not need to buy any materials and the students (especially high schoolers) don’t have to carry paper resources around or even home where, we all know, they will end up in the trash. Online algebra tiles provide a way to visually see the one-step algebra problem and work accordingly. Even so, these tiles can be an introduction and foundation on what is to come (these tiles are also a great source for solving two-step equations, distribution, polynomials, the perfect square, and so forth). Another insight for using online algebra tiles is in some schools where technology such as tablets/computers are provided, the students can share their screens to a projector (or whatever resources the classroom may have) and describe their thinking process to the class. This builds on the idea of students learning, processing, and being able to teach their peers what they learned as well.

References

# Thoughts on Numerical Integration (Part 20): Simpson’s rule and local rate of convergence

Numerical integration is a standard topic in first-semester calculus. From time to time, I have received questions from students on various aspects of this topic, including:
• Why is numerical integration necessary in the first place?
• Where do these formulas come from (especially Simpson’s Rule)?
• How can I do all of these formulas quickly?
• Is there a reason why the Midpoint Rule is better than the Trapezoid Rule?
• Is there a reason why both the Midpoint Rule and the Trapezoid Rule converge quadratically?
• Is there a reason why Simpson’s Rule converges like the fourth power of the number of subintervals?
In this series, I hope to answer these questions. While these are standard questions in a introductory college course in numerical analysis, and full and rigorous proofs can be found on Wikipedia and Mathworld, I will approach these questions from the point of view of a bright student who is currently enrolled in calculus and hasn’t yet taken real analysis or numerical analysis.
In this post, we will perform an error analysis for Simpson’s Rule

$\int_a^b f(x) \, dx \approx \frac{h}{3} \left[f(x_0) + 4(x_1) + 2f(x_2) + \dots + 2f(x_{n-2}) + 4f(x_{n-1}) +f(x_n) \right] \equiv T_n$

where $n$ is the number of subintervals (which has to be even) and $h = (b-a)/n$ is the width of each subinterval, so that $x_k = x_0 + kh$.

For this special case, the true area under the curve $f(x) = x^k$ on the subinterval $[x_i, x_i +h]$ will be

$\displaystyle \int_{x_i}^{x_i+h} x^k \, dx = \frac{1}{k+1} \left[ (x_i+h)^{k+1} - x_i^{k+1} \right]$

$= \displaystyle \frac{1}{k+1} \left[x_i^{k+1} + {k+1 \choose 1} x_i^k h + {k+1 \choose 2} x_i^{k-1} h^2 + {k+1 \choose 3} x_i^{k-2} h^3 + {k+1 \choose 4} x_i^{k-3} h^4+ {k+1 \choose 5} x_i^{k-4} h^5+ O(h^6) - x_i^{k+1} \right]$

$= \displaystyle \frac{1}{k+1} \bigg[ (k+1) x_i^k h + \frac{(k+1)k}{2} x_i^{k-1} h^2 + \frac{(k+1)k(k-1)}{6} x_i^{k-2} h^3+ \frac{(k+1)k(k-1)(k-2)}{24} x_i^{k-3} h^4$

$+ \displaystyle \frac{(k+1)k(k-1)(k-2)(k-3)}{120} x_i^{k-4} h^5 \bigg] + O(h^6)$

$= x_i^k h + \displaystyle \frac{k}{2} x_i^{k-1} h^2 + \frac{k(k-1)}{6} x_i^{k-2} h^3 + \frac{k(k-1)(k-2)}{24} x_i^{k-3} h^4 + \frac{k(k-1)(k-2)(k-3)}{120} x_i^{k-4} h^5 + O(h^6)$

In the above, the shorthand $O(h^6)$ can be formally defined, but here we’ll just take it to mean “terms that have a factor of $h^6$ or higher that we’re too lazy to write out.” Since $h$ is supposed to be a small number, these terms will small in magnitude and thus can be safely ignored.
Earlier in this series, we derived the very convenient relationship $S_{2n} = \displaystyle \frac{2}{3} M_n + \frac{1}{3} T_n$ relating the approximations from Simpson’s Rule, the Midpoint Rule, and the Trapezoid Rule. We now exploit this relationship to approximate $\displaystyle \int_{x_i}^{x_i+h} x^k \, dx$. Earlier in this series, we found the Midpoint Rule approximation on this subinterval to be

$M = x_i^k h + \displaystyle \frac{k}{2} x_i^{k-1} h^2 + \frac{k(k-1)}{8} x_i^{k-2} h^3 + \frac{k(k-1)(k-2}{48} x_i^{k-3} h^4$

$\displaystyle + \frac{k(k-1)(k-2)(k-3)}{384} x_i^{k-4} h^5 + O(h^6)$

while we found the Trapezoid Rule approximation to be

$T = x_i^k h + \displaystyle \frac{k}{2} x_i^{k-1} h^2 + \frac{k(k-1)}{4} x_i^{k-2} h^3 + \frac{k(k-1)(k-2)}{12} x_i^{k-3} h^4$

$\displaystyle + \frac{k(k-1)(k-2)(k-3)}{48} x_i^{k-4} h^5 + O(h^6)$.

Therefore, if there are $2n$ subintervals, the Simpson’s Rule approximation of $\displaystyle \int_{x_i}^{x_i+h} x^k \, dx$ — that is, the area under the parabola that passes through $(x_i, x_i^k)$, $(x_i + h/2, (x_i +h/2)^k)$, and $(x_i + h, (x_i +h)^k)$ — will be $S = \frac{2}{3}M + \frac{1}{3}T$. Since

$\displaystyle \frac{2}{3} \frac{1}{8} + \frac{1}{3} \frac{1}{4} = \frac{1}{6}$,

$\displaystyle \frac{2}{3} \frac{1}{48} + \frac{1}{3} \frac{1}{12} = \frac{1}{24}$,

and

$\displaystyle \frac{2}{3} \frac{1}{384} + \frac{1}{3} \frac{1}{48} = \frac{5}{576}$,

we see that

$S = x_i^k h + \displaystyle \frac{k}{2} x_i^{k-1} h^2 + \frac{k(k-1)}{6} x_i^{k-2} h^3 + \frac{k(k-1)(k-2)}{24} x_i^{k-3} h^4$

$\displaystyle + \frac{5k(k-1)(k-2)(k-3)}{576} x_i^{k-4} h^5 + O(h^6)$.

We notice that something wonderful just happened: the first four terms of $S$ perfectly match the first four terms of the exact value of the integral! Subtracting from the actual integral, the error in this approximation will be equal to

$\displaystyle \frac{k(k-1)(k-2)(k-3)}{120} x_i^{k-4} h^5 - \frac{5k(k-1)(k-2)(k-3)}{576} x_i^{k-4} h^5 + O(h^6)$

$= -\displaystyle \frac{k(k-1)(k-2)(k-3)}{2880} x_i^{k-4} h^5 + O(h^6)$

Before moving on, there’s one minor bookkeeping issue to deal with. We note that this is the error for $S_{2n}$, where $2n$ subintervals are used. However, the value of $h$ in this equal arose from $T_n$ and $M_n$, where only $n$ subintervals are used. So let’s write the error with $2n$ subintervals as

$-\displaystyle \frac{k(k-1)(k-2)(k-3)}{90} x_i^{k-4} \left( \frac{h}{2} \right)^5 + O(h^6)$,

where $h/2$ is the width of all of the $2n$ subintervals. By analogy, we see that the error for $n$ subintervals will be

$-\displaystyle \frac{k(k-1)(k-2)(k-3)}{90} x_i^{k-4} h^5 + O(h^6)$.

But even after adjusting for this constant, we see that this local error behaves like $O(h^5)$, a vast improvement over both the Midpoint Rule and the Trapezoid Rule. This illustrates a general principle of numerical analysis: given two algorithms that are $O(h^3)$, an improved algorithm can typically be made by taking some linear combination of the two algorithms. Usually, the improvement will be to $O(h^4)$; however, in this example, we magically obtained an improvement to $O(h^5)$.

# Engaging students: Finding points on the coordinate plane

In my capstone class for future secondary math teachers, I ask my students to come up with ideas for engaging their students with different topics in the secondary mathematics curriculum. In other words, the point of the assignment was not to devise a full-blown lesson plan on this topic. Instead, I asked my students to think about three different ways of getting their students interested in the topic in the first place.

I plan to share some of the best of these ideas on this blog (after asking my students’ permission, of course).

This student submission comes from my former student Morgan Mayfield. His topic, from Pre-Algebra: finding points on the coordinate plane.

C2: How has this topic appeared in high culture (art, classical music, theatre, etc.)?

One popular art/sport high school students may take part in is marching band. I did four years of marching band in high school and I loved it. One has to wonder: “how does each performer know where they should be?” I’ve included a link from bandtek.com that describes the coordinate system marching bands use. It isn’t quite the same as the coordinate plane in a math class. When starting marching band, you learn how to take appropriately sized “8 to 5” steps, which simply means 8 equally spaced steps for every 5 yards on a football field. Each member will receive little cards that have “sets” on them. A set is a specific point on the field where the performer must be at a specific time of the show. Usually, performers will take straight paths from set to set in a specific amount of 8-5 steps. Looking at a bird eye’s view of the football field, one can see a rough coordinate plane. Like a coordinate plane has 4 quadrants, a football field has a rough 4 quadrant system where a performer is assigned to stand a specified amount of 8-5 steps from a specified yard line either on side 1 or 2 for their horizontal position and a specified amount of 8-5 steps from the front/back hash for vertical position facing the home sideline. Side 1 refers to the left side of the field from the home side perspective, Side 2 refers to the right side of the field from the home side perspective, and the front/back hash refers to the line of dashes that cut through the middle of the field horizontally from the home side perspective.

An example bandtek.com uses is, “4 outside the side 1 45, 3 in front of the front hash” which would mean the following position:

D1: What interesting things can you say about the people who contributed to the discovery and/or the development of this topic?

René Descartes was a 17th century (1600’s) French mathematician and philosopher. Many people study his work in modern day math and philosophy classes. Some may know him as the man who wrote “cogito, ergo sum” or “I think, therefore I am”. Well, there is a legend about his discovery of the Coordinate Plane. Descartes was often sick as a kid, way before modern medication and technology. He would often have to stay in bed at his boarding school until noon because of his illnesses. This gave him quite a bit of downtime to be observant of his environment. Laying on his bed, he could see a fly crawl around on his ceiling. He thought of ways to describe the location of the fly as it scuttled about the ceiling. Imagine telling a friend where the location of the fly was, “A little to the left of the right wall and a little down from the top wall”. This just isn’t precise enough, nor an easy way to communicate information. However, Descartes realized he could quantify the precise location of the fly from using the distance from a pair of perpendicular walls. Descartes then translated this idea onto a graph where the perpendicular “walls” continued infinitely in both directions and became “axes”. “Flies” then became “points” or “coordinate pairs”. Thus, the coordinate plane was born, and so was a way to describe points in space. Just a little bit of imagination, self-questioning, and observation lead to a fundamental change in Mathematics, a way to tie Algebra and Geometry together.

E1: How can technology (YouTube, Khan Academy [khanacademy.org], Vi Hart, Geometers Sketchpad, graphing calculators, etc.) be used to effectively engage students with this topic? Note: It’s not enough to say “such-and-such is a great website”; you need to explain in some detail why it’s a great website.

I believe that https://www.chess.com/vision could be an effective website to engage students on finding points on the coordinate plane in a class that is being introduced to the idea for the first time. Many students won’t know how a chessboard is setup or even know how to play chess. The cool things are that they don’t need to know the fundamentals of chess and that the chessboard is essentially Quadrant I of a coordinate plane (where a1 is in the bottom left corner). The above website tests the player to locate as many squares (points) on a chessboard (coordinate plane) as they can in 30 seconds, given random chess coordinates. There is a way to toggle settings to also test yourself on moves and squares. In a classroom, I would only toggle the setting to list random “black and white squares” where the board is set with a1 at the bottom left corner. Students could start the day with this website as a precursor to formalizing the idea of finding points on a coordinate plane. This website is engaging (with an exclamation point)! The game can be made into a fun little competition amongst students. The time limit and game-y feeling to it encourages active participation. The game takes minimal explanation from the teacher for students to get the hang of it (no chess skills required). The fact that chessboards have one axis in letters and the other axis in numbers aids students in reading the coordinate plane x-axis first, then y-axis like the chess coordinates. I would only have the students run the game for a few rounds, making the activity in total 7 minutes or less.

References:

https://www.chess.com/vision

https://wild.maths.org/ren%C3%A9-descartes-and-fly-ceiling

https://maths2art.com.sg/2018/01/16/have-you-ever-followed-a-fly

# Thoughts on Numerical Integration (Part 19): Trapezoid rule and global rate of convergence

Numerical integration is a standard topic in first-semester calculus. From time to time, I have received questions from students on various aspects of this topic, including:
• Why is numerical integration necessary in the first place?
• Where do these formulas come from (especially Simpson’s Rule)?
• How can I do all of these formulas quickly?
• Is there a reason why the Midpoint Rule is better than the Trapezoid Rule?
• Is there a reason why both the Midpoint Rule and the Trapezoid Rule converge quadratically?
• Is there a reason why Simpson’s Rule converges like the fourth power of the number of subintervals?
In this series, I hope to answer these questions. While these are standard questions in a introductory college course in numerical analysis, and full and rigorous proofs can be found on Wikipedia and Mathworld, I will approach these questions from the point of view of a bright student who is currently enrolled in calculus and hasn’t yet taken real analysis or numerical analysis.
In the previous post, we showed that the Trapezoid Rule approximation of $\displaystyle \int_{x_i}^{x_i+h} x^k \, dx$  has error

$\displaystyle \frac{k(k-1)}{12} x_i^{k-2} h^3 + O(h^4)$

In this post, we consider the global error when integrating on the interval $[a,b]$ instead of a subinterval $[x_i,x_i+h]$. The logic is almost a perfect copy-and-paste from the analysis used for the Midpoint Rule. The total error when approximating $\displaystyle \int_a^b x^k \, dx = \int_{x_0}^{x_n} x^k \, dx$ will be the sum of the errors for the integrals over $[x_0,x_1]$, $[x_1,x_2]$, through $[x_{n-1},x_n]$. Therefore, the total error will be

$E \approx \displaystyle \frac{k(k-1)}{12} \left(x_0^{k-2} + x_1^{k-2} + \dots + x_{n-1}^{k-2} \right) h^3$.

So that this formula doesn’t appear completely mystical, this actually matches the numerical observations that we made earlier. The figure below shows the left-endpoint approximations to $\displaystyle \int_1^2 x^9 \, dx$ for different numbers of subintervals. If we take $n = 100$ and $h = 0.01$, then the error should be approximately equal to

$\displaystyle \frac{9 \times 8}{12} \left(1^7 + 1.01^7 + \dots + 1.99^7 \right) (0.01)^3 \approx 0.0187462$,

which, as expected, is close to the actual error of $102.3191246 - 102.3 \approx 0.0191246$. Let $y_i = x_i^{k-2}$, so that the error becomes

$E \approx \displaystyle \frac{k(k-1)}{12} \left(y_0 + y_1 + \dots + y_{n-1} \right) h^3 + O(h^4) = \displaystyle \frac{k(k-1)}{12} \overline{y} n h^3$,

where $\overline{y} = (y_0 + y_1 + \dots + y_{n-1})/n$ is the average of the $y_i$. Clearly, this average is somewhere between the smallest and the largest of the $y_i$. Since $y = x^{k-2}$ is a continuous function, that means that there must be some value of $x_*$ between $x_0$ and $x_{k-1}$ — and therefore between $a$ and $b$ — so that $x_*^{k-2} = \overline{y}$ by the Intermediate Value Theorem. We conclude that the error can be written as

$E \approx \displaystyle \frac{k(k-1)}{12} x_*^{k-2} nh^3$,

Finally, since $h$ is the length of one subinterval, we see that $nh = b-a$ is the total length of the interval $[a,b]$. Therefore,

$E \approx \displaystyle \frac{k(k-1)}{12} x_*^{k-2} (b-a)h^2 \equiv ch^2$,

where the constant $c$ is determined by $a$, $b$, and $k$. In other words, for the special case $f(x) = x^k$, we have established that the error from the Trapezoid Rule is approximately quadratic in $h$ — without resorting to the generalized mean-value theorem and confirming the numerical observations we made earlier.

# Engaging students: Making and interpreting bar charts, frequency charts, pie charts, and histograms

In my capstone class for future secondary math teachers, I ask my students to come up with ideas for engaging their students with different topics in the secondary mathematics curriculum. In other words, the point of the assignment was not to devise a full-blown lesson plan on this topic. Instead, I asked my students to think about three different ways of getting their students interested in the topic in the first place.

I plan to share some of the best of these ideas on this blog (after asking my students’ permission, of course).

This student submission comes from my former student Taylor Bigelow. Her topic, from Pre-Algebra: making and interpreting bar charts, frequency charts, pie charts, and histograms.

How could you as a teacher create an activity or project that involves your topic?

Charts allow for a lot of fun class activities. For example, we can have them take their own data for a table and create charts from that data. For my activity, I will give them all dice, which they should be very familiar with, and have them roll the dice 20 times and keep track of how many times it lands on each number in a table. From that table, they will make their own bar charts, frequency charts, and pie charts. After they roll their dice and make their charts, they will then answer questions interpreting the charts. This tests their ability to understand data and make all the different types of charts.

How has this topic appeared in the news?

Charts are all over in the news, especially recently. There were pie charts and frequency charts all over during the election cycle, and with covid, all we see is bar charts of covid data. An easy engage for this topic would be to make observations about these types of graphs that they’ll probably see all the time during election seasons and might even be familiar with. First, we will ask the students what news can benefit from graphs, and what news they have seen graphs in recently. I expect answers similar to elections, covid, and economics. Then we can look at some of the graphs that usually show up around election cycles. We will take a minute as a class to discuss what they notice about the graphs and what they mean. Questions like “what type of graph is this”, “what are the variables in this graph”, and “what information do you get from this graph”. This will show the students that being able to read these graphs has real life applications, and it also teaches them what important things to look for in the graphs during class time and homework.

How can technology be used to effectively engage students with this topic?

# Thoughts on Numerical Integration (Part 18): Trapezoid rule and local rate of convergence

Numerical integration is a standard topic in first-semester calculus. From time to time, I have received questions from students on various aspects of this topic, including:
• Why is numerical integration necessary in the first place?
• Where do these formulas come from (especially Simpson’s Rule)?
• How can I do all of these formulas quickly?
• Is there a reason why the Midpoint Rule is better than the Trapezoid Rule?
• Is there a reason why both the Midpoint Rule and the Trapezoid Rule converge quadratically?
• Is there a reason why Simpson’s Rule converges like the fourth power of the number of subintervals?
In this series, I hope to answer these questions. While these are standard questions in a introductory college course in numerical analysis, and full and rigorous proofs can be found on Wikipedia and Mathworld, I will approach these questions from the point of view of a bright student who is currently enrolled in calculus and hasn’t yet taken real analysis or numerical analysis.
In this post, we will perform an error analysis for the Trapezoid Rule

$\int_a^b f(x) \, dx \approx \frac{h}{2} \left[f(x_0) + 2f(x_1) + 2f(x_2) + \dots + 2f(x_{n-1}) +f(x_n) \right] \equiv T_n$

where $n$ is the number of subintervals and $h = (b-a)/n$ is the width of each subinterval, so that $x_k = x_0 + kh$.
As noted above, a true exploration of error analysis requires the generalized mean-value theorem, which perhaps a bit much for a talented high school student learning about this technique for the first time. That said, the ideas behind the proof are accessible to high school students, using only ideas from the secondary curriculum (especially the Binomial Theorem), if we restrict our attention to the special case $f(x) = x^k$, where $k \ge 5$ is a positive integer.

For this special case, the true area under the curve $f(x) = x^k$ on the subinterval $[x_i, x_i +h]$ will be

$\displaystyle \int_{x_i}^{x_i+h} x^k \, dx = \frac{1}{k+1} \left[ (x_i+h)^{k+1} - x_i^{k+1} \right]$

$= \displaystyle \frac{1}{k+1} \left[x_i^{k+1} + {k+1 \choose 1} x_i^k h + {k+1 \choose 2} x_i^{k-1} h^2 + {k+1 \choose 3} x_i^{k-2} h^3 + {k+1 \choose 4} x_i^{k-3} h^4+ {k+1 \choose 5} x_i^{k-4} h^5+ O(h^6) - x_i^{k+1} \right]$

$= \displaystyle \frac{1}{k+1} \bigg[ (k+1) x_i^k h + \frac{(k+1)k}{2} x_i^{k-1} h^2 + \frac{(k+1)k(k-1)}{6} x_i^{k-2} h^3+ \frac{(k+1)k(k-1)(k-2)}{24} x_i^{k-3} h^4$

$+ \displaystyle \frac{(k+1)k(k-1)(k-2)(k-3)}{120} x_i^{k-4} h^5 \bigg] + O(h^6)$

$= x_i^k h + \displaystyle \frac{k}{2} x_i^{k-1} h^2 + \frac{k(k-1)}{6} x_i^{k-2} h^3 + \frac{k(k-1)(k-2)}{24} x_i^{k-3} h^4 + \frac{k(k-1)(k-2)(k-3)}{120} x_i^{k-4} h^5 + O(h^6)$

In the above, the shorthand $O(h^6)$ can be formally defined, but here we’ll just take it to mean “terms that have a factor of $h^6$ or higher that we’re too lazy to write out.” Since $h$ is supposed to be a small number, these terms will small in magnitude and thus can be safely ignored. I wrote the above formula to include terms up to and including $h^5$ because I’ll need this later in this series of posts. For now, looking only at the Trapezoid Rule, it will suffice to write this integral as

$\displaystyle \int_{x_i}^{x_i+h} x^k \, dx =x_i^k h + \displaystyle \frac{k}{2} x_i^{k-1} h^2 + \frac{k(k-1)}{6} x_i^{k-2} h^3 + O(h^4)$.

Using the Trapezoid Rule, we approximate $\displaystyle \int_{x_i}^{x_i+h} x^k \, dx$ as $\displaystyle \frac{h}{2} \left[x_i^k + (x_i + h)^k \right]$, using the width $h$ and the bases $x_i^k$ and $(x_i + h)^k$ of the trapezoid. Using the Binomial Theorem, this expands as

$x_i^k h + \displaystyle {k \choose 1} x_i^{k-1} \frac{h^2}{2} + {k \choose 2} x_i^{k-2} \frac{h^3}{2} + {k \choose 3} x_i^{k-3} \frac{h^4}{2} + {k \choose 4} x_i^{k-4} \frac{h^5}{2} + O(h^6)$

$= x_i^k h + \displaystyle \frac{k}{2} x_i^{k-1} h^2 + \frac{k(k-1)}{4} x_i^{k-2} h^3 + \frac{k(k-1)(k-2)}{12} x_i^{k-3} h^4$

$\displaystyle + \frac{k(k-1)(k-2)(k-3)}{48} x_i^{k-4} h^5 + O(h^6)$

Once again, this is a little bit overkill for the present purposes, but we’ll need this formula later in this series of posts. Truncating somewhat earlier, we find that the Trapezoid Rule for this subinterval gives

$x_i^k h + \displaystyle \frac{k}{2} x_i^{k-1} h^2 + \displaystyle \frac{k(k-1)}{4} x_i^{k-2} h^3 + O(h^4)$

Subtracting from the actual integral, the error in this approximation will be equal to

$\displaystyle x_i^k h + \frac{k}{2} x_i^{k-1} h^2 + \frac{k(k-1)}{6} x_i^{k-2} h^3 - x_i^k h - \frac{k}{2} x_i^{k-1} h^2 - \frac{k(k-1)}{4} x_i^{k-2} h^3 + O(h^4)$

$= \displaystyle \frac{k(k-1)}{12} x_i^{k-2} h^3 + O(h^4)$

In other words, like the Midpoint Rule, both of the first two terms $x_i^k h$ and $\displaystyle \frac{k}{2} x_i^{k-1} h^2$ cancel perfectly, leaving us with a local error on the order of $h^3$. We also recall, from the previous post in this series that the local error from the Midpoint Rule was $\displaystyle \frac{k(k-1)}{24} x_i^{k-2} h^3 + O(h^4)$. In other words, while both the Midpoint Rule and Trapezoid Rule have local errors on the order of $O(h^3)$, we expect the error in the Midpoint Rule to be about half of the error from the Trapezoid Rule.

# Thoughts on Numerical Integration (Part 17): Midpoint rule and global rate of convergence

Numerical integration is a standard topic in first-semester calculus. From time to time, I have received questions from students on various aspects of this topic, including:
• Why is numerical integration necessary in the first place?
• Where do these formulas come from (especially Simpson’s Rule)?
• How can I do all of these formulas quickly?
• Is there a reason why the Midpoint Rule is better than the Trapezoid Rule?
• Is there a reason why both the Midpoint Rule and the Trapezoid Rule converge quadratically?
• Is there a reason why Simpson’s Rule converges like the fourth power of the number of subintervals?
In this series, I hope to answer these questions. While these are standard questions in a introductory college course in numerical analysis, and full and rigorous proofs can be found on Wikipedia and Mathworld, I will approach these questions from the point of view of a bright student who is currently enrolled in calculus and hasn’t yet taken real analysis or numerical analysis.
In the previous post, we showed that the midpoint approximation of $\displaystyle \int_{x_i}^{x_i+h} x^k \, dx$  has error

$= \displaystyle \frac{k(k-1)}{24} x_i^{k-2} h^3 + O(h^4)$

In this post, we consider the global error when integrating on the interval $[a,b]$ instead of a subinterval $[x_i,x_i+h]$. The logic for determining the global error is much the same as what we used earlier for the left-endpoint rule. The total error when approximating $\displaystyle \int_a^b x^k \, dx = \int_{x_0}^{x_n} x^k \, dx$ will be the sum of the errors for the integrals over $[x_0,x_1]$, $[x_1,x_2]$, through $[x_{n-1},x_n]$. Therefore, the total error will be

$E \approx \displaystyle \frac{k(k-1)}{24} \left(x_0^{k-2} + x_1^{k-2} + \dots + x_{n-1}^{k-2} \right) h^3$.

So that this formula doesn’t appear completely mystical, this actually matches the numerical observations that we made earlier. The figure below shows the left-endpoint approximations to $\displaystyle \int_1^2 x^9 \, dx$ for different numbers of subintervals. If we take $n = 100$ and $h = 0.01$, then the error should be approximately equal to

$\displaystyle \frac{9 \times 8}{24} \left(1^7 + 1.01^7 + \dots + 1.99^7 \right) (0.01)^3 \approx 0.0093731$,

which, as expected, is close to the actual error of $102.3 - 102.2904379 \approx 0.00956211$. Let $y_i = x_i^{k-2}$, so that the error becomes

$E \approx \displaystyle \frac{k(k-1)}{24} \left(y_0 + y_1 + \dots + y_{n-1} \right) h^3 + O(h^4) = \displaystyle \frac{k(k-1)}{24} \overline{y} n h^3$,

where $\overline{y} = (y_0 + y_1 + \dots + y_{n-1})/n$ is the average of the $y_i$. Clearly, this average is somewhere between the smallest and the largest of the $y_i$. Since $y = x^{k-2}$ is a continuous function, that means that there must be some value of $x_*$ between $x_0$ and $x_{k-1}$ — and therefore between $a$ and $b$ — so that $x_*^{k-2} = \overline{y}$ by the Intermediate Value Theorem. We conclude that the error can be written as

$E \approx \displaystyle \frac{k(k-1)}{24} x_*^{k-2} nh^3$,

Finally, since $h$ is the length of one subinterval, we see that $nh = b-a$ is the total length of the interval $[a,b]$. Therefore,

$E \approx \displaystyle \frac{k(k-1)}{24} x_*^{k-2} (b-a)h^2 \equiv ch^2$,

where the constant $c$ is determined by $a$, $b$, and $k$. In other words, for the special case $f(x) = x^k$, we have established that the error from the Midpoint Rule is approximately quadratic in $h$ — without resorting to the generalized mean-value theorem and confirming the numerical observations we made earlier.