Amazing approximation

About this lesson plan

This is a lesson plan for indented for realization during 2h lesson activities.

It has been developed during work in iCSE4school project based on lesson carried out in 2015-2017 at The Stefan Batory High School in Chorzów.

It was prepared by Krzysztof Oleś based on his lesson.

Attention!

In each of the “code” cells you can change any number, text or instruction. In order to return to the original version refresh the webpage. Sometimes the next code depends on variables defined from the previous one, so one has to execute cells in order of apperance.

*This project is the result of activities (inspired by the textbook

“Matematyka się liczy” edited by prof. Wacław Zawadowski)*

Introduction

We want to use a computer to illustrate a SIMPLE problem by using BASIC programs.

  • Why BASIC?

Because we don’t know if we are familiar enough with SAGE.

  • Why SIMPLE?

Because we are keen on making some people surprised by this part of mathematics which is told to be boring… Most of people don’t like counting, so we’ll repeat not exciting calculations and computer will lead us (perhaps) to some misunderstandings in using numbers…

Part 1

Let’s start with approximation of square-root of two. We’ll use square-root algorithm (which is based on Newton’s method for finding zeros of a function, this case is known as Babylonian method).

Do you know

  • what does 2.12390141451912e-6 mean?

  • how does error change while n changes?

Let’s see how fast this algorithm is.

Wait a minute… What are we thinking about using a word “fast”?

Let’s make a comparison. One of the most popular number is \(\pi\), so we’ll use an algorithm of approximation of this object. It’ll be based on Wallis’ product for \(\pi\), written down in 1655:

\[\frac{\pi}{2}=\prod_{n=1}^\infty\left(\frac{2n}{2n-1}\cdot\frac{2n}{2n+1}\right).\]

It’s quite complicated - perhaps a big \(\pi\) makes us confused. What about a formula like that

\[\frac{\pi}{2}=\frac{2}{1}\cdot\frac{2}{3}\cdot\frac{4}{3}\cdot\frac{4}{5}\cdot\frac{6}{5}\cdot\frac{6}{7}\cdot\frac{8}{7}\cdot\frac{8}{9}\cdot\cdots?\]

Easier?

A big \(\pi\) stands for a product (something like many, many multiplications…).

How does it work?

Tiring (you can check on the paper…) calculations will do the computer.

Do you know

  • what does abs() mean?

  • what does N() mean?

  • how does error change while n changes?

  • how many reps do we have to do to get to 3.14?

Let’s see how fast this algorthm is.

Now we can compare the speed of the first and second algorithm and ask very awkward questions:

  • Have we ever wondered about how our calculator approximates the numbers?

  • Maybe our colleague’s calculator makes it better. What does “better” mean?

  • We counted some errors - SAGE had to approximate square-root of two and \(\pi\) (these numbers are not rational): did SAGE make a mistake? How big?

Part 2

Okay, but who is interested in differences in approximations of numbers, for example on the fifteenth decimal place?

Let’s try to take care of some geometrical problem.

Consider the cylinder inscribed in a cube (bases of the cylinder are inscribed in the two parallel faces of the cube). In the corner of the cube put the ball of maximum volume tangent to the cylinder. What is this volume?

As we can see the edge of the cube has a length of 1

\[x, y, z \in (-0.5,0.5),\]

and the cylinder is connected with the circle pattern of

\[x^2+y^2=0.25.\]

And where was taken

\[r=\frac{\sqrt{2}-1}{2\sqrt{2}+2}?\]

Denoted by \(r\) the radius of the search ball. With simple relationship between the diagonal of the square and the rays of both circles we receive:

\[\frac{1}{2}\sqrt{2}=r\sqrt{2}+r+\frac{1}{2}\]
\[\frac{1}{2}\sqrt{2}-\frac{1}{2}=r\left(1+\sqrt{2}\right)\]
\[r=\frac{\frac{1}{2}\sqrt{2}-\frac{1}{2}}{1+\sqrt{2}}=\frac{\sqrt{2}-1}{2\sqrt{2}+2}\]

and searched volume is equal to

\[\frac{4}{3}\pi r^3=\frac{4}{3}\pi \left(\frac{1}{2}\right)^3\left(\frac{\sqrt{2}-1}{\sqrt{2}+1}\right)^3=\frac{\pi}{6}\left(\frac{\sqrt{2}-1}{\sqrt{2}+1}\right)^3.\]

Everyone has heard about the transformation of expressions that contain numbers that are not rational, so let’s get to the tedious work…

\[\left(\frac{\sqrt{2}-1}{\sqrt{2}+1}\right)^3=\left(\frac{\sqrt{2}-1}{\sqrt{2}+1}\cdot\frac{\sqrt{2}-1}{\sqrt{2}-1}\right)^3=\left(\sqrt{2}-1\right)^6,\]

but

\[\left(\sqrt{2}-1\right)^6=\left(\left(\sqrt{2}-1\right)^2\right)^3=\left(3-2\sqrt{2}\right)^3,\]
\[\left(\sqrt{2}-1\right)^6=\left(\left(\sqrt{2}-1\right)^3\right)^2=\left(5\sqrt{2}-7\right)^2,\]

and finally

\[\left(\sqrt{2}-1\right)^6=\left(5\sqrt{2}-7\right)^2=99-70\sqrt{2}.\]

Let

\[w_1=99-70\sqrt{2},\quad w_2=\left(5\sqrt{2}-7\right)^2,\quad w_3=\left(3-2\sqrt{2}\right)^3,\]
\[w_4=\left(\sqrt{2}-1\right)^6,\quad w_5=\left(\frac{\sqrt{2}-1} {\sqrt{2}+1}\right)^3.\]

Of course \(w_1=w_2=w_3=w_4=w_5\), but: are there any difference among \(w_1,\dots,w_5\) when when we approach the square-root of two? Let’s see…

It turns out that the differences among approximations are big, if we accept the square-root of two as 1.41 (and yet many people think of approximations only to parts hundredths). What about: 1.414, 1.4142, 1.41421, 1.414213 and so on?

The differences are large, what we can see, considering graphs related functions connected with \(w_1,\dots,w_5\).

Let’s go back to the drawing containing our ball.

You should change

  • \(p\): 1.414, 1.4142, 1.41421, 1.414213; don’t forget about sqrt(2),

  • \(r\): \(r_1,\dots,r_5\).

Let’s look at all five balls at once.

Is not that strange?

Let’s finish our calculations, considering we’re looking for volume, whereby because we already have enough of looking at distant places after the decimal assume that the edge of the cube has a length of 60.

Again - you should change \(p\): 1.414, 1.4142, 1.41421, 1.414213; don’t forget about sqrt(2).

And again: is not that strange? Perhaps not, but considered above example shows how much we have to be careful using approximations.

Summary

We wanted to show how important is the difference between manipulating algebraic expression in kind

\[\frac{\sqrt{2}-1}{2\sqrt{2}+2}\]

and its approximation.

Why?

Firstly, due to the fact that we usually use the numbers which are not rational and that means the need to use their approximations. We tried to show two different - in the sense necessary number of the implementation iterations - algorithms. We suggested finding no small number of iterations leading to approximations of \(\pi\) proverbial 3.14. Because the differences of decimals can not really interest many people - we decided to see (!) in a geometric problem a specific significance of the adopted approximations square-root of two.

Secondly, in Polish schools, the advantage is algebraic problem solving (for example equations). This means that the matriculation examination solution of the equation

\[7x^2+27x-31=0\]

should look like

\[x_1=\frac{-27-\sqrt{1597}}{14},\quad x_2=\frac{-27+\sqrt{1597}}{14}.\]

There is a mental gap between writing the above “pictures” and the following “numbers”

\[x_1\approx -4.78303,\quad x_2\approx 0.92589.\]

Perhaps the whole project should be considered as draw attention to the difference between the signs

\[{\Large{=}}\qquad\textrm{ and }\qquad{\Large{\approx}}\]