Feb 5, 2024
This talk uses a bit of Python code.
You can download the relevant code here.
First, we consider the following mysterious function in Python.
def mystery(x, N):
"""This mystery function outputs some value based on x and N.
We assume that x is a real number, and N is a positive integer."""
output = 0;
for n in range(0, N + 1):
output += ((-1)**n)*(x**(2*n+1))/(math.factorial(2*n+1));
return output;
Our big question today is:
We will try various strategies to get a handle on it.
Fill out the following table below, by hand or by programming.
$x = 0$ | $x = 1$ | $x = 2$ | $x = 3$ | |
---|---|---|---|---|
$N=1$ | ||||
$N=2$ | ||||
$N=3$ | ||||
$N=4$ |
Write a function table(C,R)
which produces a similar table of values with columns $x = 0, 1, 2, \dots, C$ and rows $N = 1, 2, \dots, R.$
Your function should return a two dimensional array of values.
$x = 0$ | $x = 1$ | $x = 2$ | $x = 3$ | $x = 4$ | $x = 5$ | $x = 6$ | $x = 7$ | $x = 8$ | $x = 9$ | $x = 10$ | |
---|---|---|---|---|---|---|---|---|---|---|---|
$N = 1$ | $0.0000$ | $0.8333$ | $0.6667$ | $-1.5000$ | $-6.6667$ | $-15.8333$ | $-30.0000$ | $-50.1667$ | $-77.3333$ | $-112.5000$ | $-156.6667$ |
$N = 2$ | $0.0000$ | $0.8417$ | $0.9333$ | $0.5250$ | $1.8667$ | $10.2083$ | $34.8000$ | $89.8917$ | $195.7333$ | $379.5750$ | $676.6667$ |
$N = 3$ | $0.0000$ | $0.8415$ | $0.9079$ | $0.0911$ | $-1.3841$ | $-5.2927$ | $-20.7429$ | $-73.5097$ | $-220.3683$ | $-569.4268$ | $-1307.4603$ |
$N = 4$ | $0.0000$ | $0.8415$ | $0.9093$ | $0.1453$ | $-0.6617$ | $0.0896$ | $7.0286$ | $37.6940$ | $149.4998$ | $498.2002$ | $1448.2716$ |
$N = 5$ | $0.0000$ | $0.8415$ | $0.9093$ | $0.1409$ | $-0.7668$ | $-1.1336$ | $-2.0603$ | $-11.8422$ | $-65.6961$ | $-287.9615$ | $-1056.9392$ |
$N = 6$ | $0.0000$ | $0.8415$ | $0.9093$ | $0.1411$ | $-0.7560$ | $-0.9376$ | $0.0372$ | $3.7172$ | $22.5894$ | $120.2379$ | $548.9652$ |
$N = 7$ | $0.0000$ | $0.8415$ | $0.9093$ | $0.1411$ | $-0.7568$ | $-0.9609$ | $-0.3224$ | $0.0867$ | $-4.3167$ | $-37.2105$ | $-215.7512$ |
$N = 8$ | $0.0000$ | $0.8415$ | $0.9093$ | $0.1411$ | $-0.7568$ | $-0.9588$ | $-0.2748$ | $0.7407$ | $2.0142$ | $9.6767$ | $65.3945$ |
$N = 9$ | $0.0000$ | $0.8415$ | $0.9093$ | $0.1411$ | $-0.7568$ | $-0.9589$ | $-0.2798$ | $0.6470$ | $0.8294$ | $-1.4281$ | $-16.8119$ |
$N = 10$ | $0.0000$ | $0.8415$ | $0.9093$ | $0.1411$ | $-0.7568$ | $-0.9589$ | $-0.2794$ | $0.6580$ | $1.0100$ | $0.7135$ | $2.7611$ |
If you examine the table of values, then you’ll notice that mystery(x,N)
eventually stops changing as a function of $N$.
That is, the value of mystery(x,N)
is essentially the same for all large values of $N$.
We call this the limiting value of the function.
To be concrete, we say that two numbers $a$ and $b$ are essentially the same if they differ by less than $10^{-10}$.
$$
|a - b| < 10^{-10} = 0. 000 000 000 1
$$
Create a new Python function limit(x)
which calculates the limiting value of mystery(x,N)
for each $x$.
You will want to use the built-in Python function
abs()
to compute the absolute value.
Use Python to approximate the smallest and biggest values of mystery(x,N)
on the domain $-3 \leq x \leq 3$ when $N$ is big.
To do so, calculate the value of limit(x)
at a large number of points in the domain $-3 \leq x \leq 3$.
Your final answers for the biggest and smallest values should specify both: the value of limit(x)
and the x
where this value is obtained.
On paper:
If you look carefully at the code, you’ll notice that mystery(x,N)
is a sum of powers of $x$.
Write it out as a polynomial, for $N = 3$.
To do so, you are going to need to use the factorial function.
The function math.factorial(n)
computes the product of the first $n$ whole numbers.
For example,
$$
\texttt{math.factorial(4)} = 1 \cdot 2 \cdot 3 \cdot 4 = 24.
$$
In mathematics, we usually write the factorial function as $n!$ because it grows so quickly.
It’s a very exciting function!
In Desmos: Graph the function mystery(x,N)
with a slider for $N$.
Notice that mystery(x,N)
is a summation from $n = 0$ to $n = N$.
In Desmos, typing sum
produces a summation sign $\displaystyle \sum_{n=}$.
What is the mystery function calculating?
Thanks to Mr. Nanthivarman for inviting me to speak at Lester B Pearson Collegiate Institute. Thanks to the following people for feedback on early drafts of this talk.
Thanks for reading! If you have any comments or questions about the content, please let me know. Anyone can contact me by email.