Thoughts on Numerical Integration (Part 23): The normalcdf function on TI calculators

I end this series about numerical integration by returning to the most common (if hidden) application of numerical integration in the secondary mathematics curriculum: finding the area under the normal curve. This is a critically important tool for problems in both probability and statistics; however, the antiderivative of \displaystyle \frac{1}{\sqrt{2\pi}} e^{-x^2/2} cannot be expressed using finitely many elementary functions. Therefore, we must resort to numerical methods instead.

In days of old, of course, students relied on tables in the back of the textbook to find areas under the bell curve, and I suppose that such tables are still being printed. For students with access to modern scientific calculators, of course, there’s no need for tables because this is a built-in function on many calculators. For the line of TI calculators, the command is normalcdf.

Unfortunately, it’s a sad (but not well-known) fact of life that the TI-83 and TI-84 calculators are not terribly accurate at computing these areas. For example:

TI-84: \displaystyle \int_0^1 \frac{e^{-x^2/2}}{\sqrt{2\pi}} \, dx \approx 0.3413447\underline{399}

Correct answer, with Mathematica: 0.3413447\underline{467}\dots

TI-84: \displaystyle \int_1^2 \frac{e^{-x^2/2}}{\sqrt{2\pi}} \, dx \approx 0.1359051\underline{975}

Correct answer, with Mathematica: 0.1359051\underline{219}\dots

TI-84: \displaystyle \int_2^3 \frac{e^{-x^2/2}}{\sqrt{2\pi}} \, dx \approx 0.021400\underline{0948}

Correct answer, with Mathematica: 0.021400\underline{2339}\dots

TI-84: \displaystyle \int_3^4 \frac{e^{-x^2/2}}{\sqrt{2\pi}} \, dx \approx 0.0013182\underline{812}

Correct answer, with Mathematica: 0.0013182\underline{267}\dots

TI-84: \displaystyle \int_4^5 \frac{e^{-x^2/2}}{\sqrt{2\pi}} \, dx \approx 0.0000313\underline{9892959}

Correct answer, with Mathematica: 0.0000313\underline{84590261}\dots

TI-84: \displaystyle \int_5^6 \frac{e^{-x^2/2}}{\sqrt{2\pi}} \, dx \approx 2.8\underline{61148776} \times 10^{-7}

Correct answer, with Mathematica: 2.8\underline{56649842}\dots \times 10^{-7}

I don’t presume to know the proprietary algorithm used to implement normalcdf on TI-83 and TI-84 calculators. My honest if brutal assessment is that it’s probably not worth knowing: in the best case (when the endpoints are close to 0), the calculator provides an answer that is accurate to only 7 significant digits while presenting the illusion of a higher degree of accuracy. I can say that Simpson’s Rule with only n = 26 subintervals provides a better approximation to \displaystyle \int_0^1 \frac{e^{-x^2/2}}{\sqrt{2\pi}} \, dx than the normalcdf function.

For what it’s worth, I also looked at the accuracy of the NORMSDIST function in Microsoft Excel. This is much better, almost always producing answers that are accurate to 11 or 12 significant digits, which is all that can be realistically expected in floating-point double-precision arithmetic (in which numbers are usually stored accurate to 13 significant digits prior to any computations).

Engaging students: Finding prime factorizations

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 Bri Del Pozzo. Her topic, from Pre-Algebra: finding prime factorizations.

green line

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

An activity that I would create for my students involving Prime Factorization is based on an example that I saw on Pinterest. I would prepare an activity where students would be given a picture of a tree and assigned a two-digit number. I would then have students decorate their tree and at the base of the tree, they would write their assigned number. Then, as the roots expand down, students would be able to write the factors of their number as a factor tree until they are left with only prime factors (based on the image from https://www.hmhco.com/blog/teaching-prime-factorization-of-36). In the example from Pinterest, the teacher focused on finding the greatest common divisors between two numbers and used the factors trees as guidance. For my activity, I would assign some students the same number and emphasize that some numbers (such as 24, 36, 72, etc.) can be factored in multiple ways, so the roots of the trees could look different depending on how the student decides to factor their number.

green line

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

There are a few ways that Prime Factorization can be used in my students’ future math courses. Prime Factorization is incredibly useful when learning how to simplify fractions. By practicing Prime Factorization, students become more familiar with the factors of large numbers, which becomes helpful when simplifying fractions. In the instance that a fraction is not in its simplest form, students will have an easier time recognizing such and will feel more confident in simplifying the fraction. Additionally, Prime Factorization prepares students for finding Greatest Common Divisors. Knowing how to find Greatest Common Divisors can be useful when solving real-world problems as well as in simplifying fractions. At a higher level of math, Prime Factorization allows students to practice the skills needed to prepare themselves for factoring things more complicated than numbers. For example, the idea of factoring can be applied to factoring a common factor out of an expression, factoring quadratic equations, and factoring polynomials with complex numbers.

green line

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.

Khanacademy.org would be a fantastic website to engage students in this topic because of the inclusion of multiple representations. This website allows students to work through multiple practice problems where they can find the Prime Factorization of a number. When the student gets the question correct, they can move on to the next question, or they have the option to view a brief explanation on how to arrive at the correct answer. If students get a problem incorrect, they can retry the problem or get help on the question. The “get help” feature also provides students with a brief explanation, with options in video form and picture/written form, of how to solve the problem. Another important feature of this website is the ability for students to write out their thoughts as they work through the problem. Khan Academy allows students the option to use an online “whiteboard” feature that appears directly below the problem. This “whiteboard” feature allows students to write out their work and also offers a walkthrough of how to draw a factor tree.

Resources:
https://www.khanacademy.org/math/pre-algebra/pre-algebra-factors-multiples/pre-algebra-prime-factorization-prealg/e/prime_factorization
https://www.hmhco.com/blog/teaching-prime-factorization-of-36

Thoughts on Numerical Integration (Part 22): Comparison to theorems about magnitudes of errors

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 series, we have shown the following approximations of errors when using various numerical approximations for \int_a^b x^k \, dx. We obtained these approximations using only techniques within the reach of a talented high school student who has mastered Precalculus — especially the Binomial Theorem — and elementary techniques of integration.

As we now present, the formulas that we derived are (of course) easily connected to known theorems for the convergence of these techniques. These proofs, however, require some fairly advanced techniques from calculus. So, while the formulas derived in this series of posts only apply to f(x) = x^k (and, by an easy extension, any polynomial), the formulas that we do obtain easily foreshadow the actual formulas found on Wikipedia or Mathworld or calculus textbooks, thus (hopefully) taking some of the mystery out of these formulas.

Left and right endpoints: Our formula was

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

where x_* is some number between a and b. By comparison, the actual formula for the error is

E = \displaystyle \frac{f'(x_*) (b-a)^2}{2n} = \frac{f'(x_*)}{2} (b-a)h.

This reduces to the formula that we derived since f'(x) = kx^{k-1}.
 

Midpoint Rule: Our formula was

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

where x_* is some number between a and b. By comparison, the actual formula for the error is

E = \displaystyle \frac{f''(x_*) (b-a)^3}{24n^2} = \frac{f''(x_*)}{24} (b-a)h^2.

This reduces to the formula that we derived since f''(x) = k(k-1)x^{k-2}.

Trapezoid Rule: Our formula was

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

where x_* is some number between a and b. By comparison, the actual formula for the error is

E = \displaystyle \frac{f''(x_*) (b-a)^3}{12n^2} = \frac{f''(x_*)}{12} (b-a)h^2.

This reduces to the formula that we derived since f''(x) = k(k-1)x^{k-2}.

This reduces to the formula that we derived since f''(x) = k(k-1)x^{k-2}.

Simpson’s Rule: Our formula was

E \approx \displaystyle \frac{k(k-1)(k-2)(k-3)}{180} x_*^{k-4} (b-a)h^4,

where x_* is some number between a and b. By comparison, the actual formula for the error is

E = \displaystyle \frac{f^{(4)}(x_*)}{180} (b-a)h^4.

This reduces to the formula that we derived since f^{(4)}(x) = k(k-1)(k-2)(k-3)x^{k-4}.

Engaging students: Solving two-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 comes from my former student Chi Lin. Her topic, from Pre-Algebra: solving two-step algebra problems.

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

There is an interesting activity that I found online. It is called mini task cards. However, I want to rename this activity as “Find your partners” as an engage activity in this topic. I am going to create some two-step equations on the cards and give those cards randomly to the students at the beginning of the class. Each student has one mini card. The students will have 5 minutes to solve the equations and they will find the partners who have the same answers as them (there is 2-3 person in each group). The person who has the same answer with them will be the partner that they are working together with in the class. I will set up the answer as their group name (for example, if the answer is 1, then it means the group name is “Group One”). Here is an example that how the card will look like.


Reference:

12 Activities that Make Practicing Two-Step Equations Pop

green line

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

Solving two-step equations is the foundation of solving multi-step equations. Solving two-step equations looks easy but it can become very hard. This topic can be applied in lots of areas such as high-level math classes, computer science, chemistry, physics, engineer, and so on. Most definitely, the students will see lots of problems about solving multi-step equations in different high-level mathematics courses in college, such as pre-calculus, calculus 1-3, differential equations, and so on. Also, the students will use the knowledge when they write the code in computer science class. For example, when they write down the code of two-step or multi-step algebra problems, they need to know which step goes first. If they do the step wrong, then the computer program will compute the wrong result. Moreover, the students will use solving two-step equations in chemistry class. For example, the students will apply this knowledge, when they write down the chemical equations and try to balance the equations.

green line

How does this topic extend what your students should have learned in previous courses?
First, students should know what linear equations are and how to write down the linear equations. Second, students should know how to solve one-step algebra problems, such as x+8=16 or x/8=16. Students should have learned that when they solve for the one-step equations (addition and subtract), whatever they do to one side of the equation, they need to make sure they add the same thing to the other side. For example, when they solve the equation x+8=16, they can subtract 8 for both sides, which is x+8-8=16-8. Therefore, x=8. Also, student should know that when they solve for the one-step equations (multiplication and division), they need to multiply both side by the reciprocal of the coefficient of the variable. For example, when they solve the equation x/8=16, they need to multiply the reciprocal of 1/8 for both sides, which is x/8*8=16*8. Therefore, x=128. Thus, when they learn to solve two-step equations, they need to combine these rules.

References:
https://www.khanacademy.org/math/algebra-home/alg-basic-eq-ineq/alg-one-step-mult-div-equations/a/one-step-equation-review

Solving Two-Step Equations

 

Thoughts on Numerical Integration (Part 21): Simpson’s 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 this previous post in this series, we showed that the Simpson’s Rule approximation of \displaystyle \int_{x_i}^{x_i+2h} x^k \, dx has an error of 

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

In this post, we consider the global error when integrating on the interval [a,b] instead of a subinterval [x_i,x_i+2h]. 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_2], [x_2,x_4], through [x_{n-2},x_n]. Therefore, the total error will be

$latex E \approx \displaystyle \frac{k(k-1)(k-2)(k-3)}{90} \left(x_0^{k-4} + x_2^{k-4} + \dots + x_{n-2}^{k-4} \right) h^5.

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 \times 7 \times 6}{90} \left(1^5 + 1.02^5 + 1.04^5 + \dots + 1.98^5 \right) (0.01)^5 \approx 0.0000017,

which, as expected, is close to the observed error of 102.3000018 - 102.3 \approx 0.0000018.
Let y_i = x_i^{k-4}, so that the error becomes

E \approx \displaystyle \frac{k(k-1)(k-2)(k-3)}{90} \left(y_0 + y_2 + \dots + y_{n-2} \right) h^5 = \displaystyle \frac{k(k-1)(k-2)(k-3)}{90} \overline{y} \frac{n}{2} h^5,

where \overline{y} = (y_0 + y_2 + \dots + y_{n-2})/(n/2) is the average of the y_i. (We notice that there are only n/2 terms in this sum since we’re adding only the even terms.) Clearly, this average is somewhere between the smallest and the largest of the y_i. Since y = x^{k-4} is a continuous function, that means that there must be some value of x_* between x_0 and x_{k-2} — and therefore between a and b — so that x_*^{k-4} = \overline{y} by the Intermediate Value Theorem. We conclude that the error can be written as

E \approx \displaystyle \frac{k(k-1)(k-2)(k-3)}{180} x_*^{k-4} nh^5,

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)(k-2)(k-3)}{180} x_*^{k-4} (b-a)h^4 \equiv ch^4,

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 Simpson’s Rule is approximately quartic in h — without resorting to the generalized mean-value theorem and confirming the numerical observations we made earlier.