Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

Carson Witt

2061 views
1
\documentclass[landscape]{article}
2
3
% set font encoding for PDFLaTeX or XeLaTeX
4
\usepackage{ifxetex}
5
\ifxetex
6
\usepackage{fontspec}
7
\else
8
\usepackage[T1]{fontenc}
9
\usepackage[utf8]{inputenc}
10
\usepackage{lmodern}
11
\fi
12
13
% used in maketitle
14
\title{Irrational Numbers Project}
15
\author{Carson Witt}
16
17
\usepackage{amsmath}
18
\usepackage{lipsum}
19
\usepackage{enumitem}
20
\usepackage{listings}
21
\usepackage{color}
22
23
\definecolor{codegreen}{rgb}{0,0.6,0}
24
\definecolor{codegray}{rgb}{0.5,0.5,0.5}
25
\definecolor{codepurple}{rgb}{0.58,0,0.82}
26
\definecolor{backcolour}{rgb}{0.95,0.95,0.92}
27
28
\lstdefinestyle{mystyle}{
29
backgroundcolor=\color{white},
30
commentstyle=\color{codegreen},
31
keywordstyle=\color{magenta},
32
numberstyle=\tiny\color{codegray},
33
stringstyle=\color{codepurple},
34
basicstyle=\footnotesize,
35
breakatwhitespace=false,
36
breaklines=true,
37
captionpos=b,
38
keepspaces=true,
39
numbers=left,
40
numbersep=5pt,
41
showspaces=false,
42
showstringspaces=false,
43
showtabs=false,
44
tabsize=2
45
}
46
47
\lstset{style=mystyle}
48
49
% Enable SageTeX to run SageMath code right inside this LaTeX file.
50
% documentation:
51
% http://mirrors.ctan.org/macros/latex/contrib/sagetex/sagetexpackage.pdf
52
% \usepackage{sagetex}
53
54
55
%% ADDED PREAMBLE
56
\usepackage{todonotes}
57
\usepackage[displaymath, mathlines]{lineno}
58
\usepackage{hyperref}
59
\usepackage{pagecolor}
60
\usepackage{tabularx}
61
62
\newcommand{\sg}[1]{\todo[color=red!40,fancyline]{#1}}
63
\newcommand{\good}[1]{\todo[color=blue!40,fancyline]{#1}}
64
\newcommand{\comm}[1]{\todo[color=orange!40,fancyline]{#1}}
65
%%
66
67
68
\begin{document}
69
70
%% ADDED FEEDBACK
71
\pagecolor{yellow!30!white}
72
\mbox{\LARGE Irrationals }\hfill Carson Witt
73
74
\vspace{1cm}
75
76
\hrule
77
78
\vspace{1cm}
79
80
Grade: 100
81
82
\vspace{1cm}
83
84
\begin{tabularx}{15cm}{ |p{6cm} | p{8cm}|}
85
\hline
86
Approriate Introduction &
87
Very nice! I really like the use of subsections within the abstract
88
to help the reader with your report.
89
\\
90
\hline
91
Proof of the irrationality of $\sqrt{2}$ &
92
Excellent outline of the proof.
93
\\
94
\hline
95
Explanation of continued fractions &
96
Very nice! It's great to see you add in the additional detail about
97
history and background. Stuff like that really adds to the quality of
98
your report -- and also helps the reader to enjoy reading it!
99
\\
100
\hline
101
Working Python code to approximate one of $e$, $\pi$, or $\sqrt{2}$ &
102
Yes. Good explanations of the code as well.
103
\\
104
\hline
105
Use of the lstlisting environment &
106
Yes.
107
\\
108
\hline
109
Proper formatting &
110
Yes.
111
\\
112
\hline
113
\end{tabularx}
114
115
\newpage
116
117
\listoftodos[List of Comments]
118
119
\newpage
120
121
\maketitle
122
123
\linenumbers
124
\pagecolor{white}
125
%%
126
127
128
129
\section*{Abstract}
130
131
\noindent{\textbf{Introduction:}}
132
133
An irrational number is a number that cannot be expressed as a ratio of two
134
numbers, or a fraction. Commonly known irrational numbers are the ratio $\pi$ of
135
a circle's circumference to its diameter, Euler's number $e$, the golden ratio
136
$\phi$, and the square root of two. All square roots of natural numbers, other
137
than of perfect squares, are irrational. When expressed as decimals, irrational
138
numbers do not repeat or terminate. \par
139
140
\noindent{\textbf{History:}}
141
142
According to Wikipedia, "The first proof of the existence of irrational numbers
143
is usually attributed to a Pythagorean (possibly Hippasus of Metapontum), who
144
probably discovered them while identifying sides of the pentagram. The then-
145
current Pythagorean method would have claimed that there must be some
146
sufficiently small, indivisible unit that could fit evenly into one of these
147
lengths as well as the other." \par
148
149
\noindent{\textbf{Task For This Project:}}
150
151
In this project, I will be proving that $\sqrt{2}$ is irrational (by
152
contradiction), explaining continued fractions and showing the continued
153
fraction for $e$, $\sqrt{2}$, and $\pi$, and writing Python code that
154
approximates $e$, $\sqrt{2}$, and $\pi$ to a requested number of digits.
155
156
\section*{Context/Work}
157
158
\textbf{Proving that $\sqrt{2}$ is irrational by contradiction:}
159
160
\begin{enumerate}
161
\item Let's assume that $\sqrt{2}$ is rational, meaning it can be written as the
162
ratio of two integers, $a$ and $b$:
163
\end{enumerate}
164
165
$$
166
\sqrt{2} = \frac{a}{b}
167
$$
168
Where $b \neq 0$ and we assume that $a$ and $b$ have no common factors. If
169
common factors exist, we cancel them in the numerator and denominator.
170
171
\begin{enumerate}[resume]
172
\item Squaring both sides of the equation gives us:
173
\end{enumerate}
174
175
$$
176
2 = \frac{a^2}{b^2}
177
$$
178
179
\begin{enumerate}[resume]
180
\item Which implies:
181
\end{enumerate}
182
183
$$
184
a^2 = 2b^2
185
$$
186
187
\begin{enumerate}[resume]
188
\item This means that $\sqrt{a}$ must be even, since $\sqrt{a}$ is $2$
189
multiplied by some number. We know this to be true because the multiplication of
190
two even numbers will always be even.
191
\item This also means that $a$ itself is even because if $a$ was odd, $a*a$
192
would be odd as well.
193
\item Since $a$ is an even number, it is $2$ times another whole number.
194
\end{enumerate}
195
196
$$
197
a = 2k
198
$$
199
200
\begin{enumerate}[resume]
201
\item If we substitute $a = 2k$ into the squared original equation, we get:
202
\end{enumerate}
203
204
$$
205
2 = \frac{(2k)^2}{b^2}
206
$$
207
$$
208
2 = \frac{4k^2}{b^2}
209
$$
210
$$
211
2b^2 = 4k^2
212
$$
213
$$
214
b^2 = 2k^2
215
$$
216
217
\begin{enumerate}[resume]
218
\item This means that $b^2$ is even, which follows that $b$ itself is even.
219
\item \textbf{This is where there is a contradiction.} If $a$ and $b$ are both
220
even numbers, then $\frac{a}{b}$ is not in its simplest form and still has
221
common factors. This is a contradiction because we assumed that the equation was
222
rational and had no common factors from the start. \textbf{Therefore, $\sqrt{2}$
223
must be irrational.}
224
\end{enumerate}
225
226
\newpage
227
228
\noindent{\textbf{Continued Fractions:}} \par
229
230
A continued fraction is a fraction of infinite length whose denominator is a
231
quantity plus a fraction, which latter fraction has a similar denominator, and
232
so on. Continued fractions are great ways to express irrational numbers like
233
$e$, $\pi$, and $\sqrt{2}$. \par
234
235
\vspace{0.02cm}{\noindent{Interesting Facts:}}
236
237
\begin{itemize}
238
\item John Wallis first used the term "continued fraction" in his Arithmetica
239
Infinitorum of 1653.
240
\item Another word for a continued fraction is anthyphairetic ratio.
241
\end{itemize}
242
243
\noindent{The basic form of a continued fraction is as follows:}
244
245
$$
246
a_0 +\cfrac{b_1}{a_1+\cfrac{b_2}{a_2+\cfrac{b_3}{a_3+\cdots}}}
247
$$
248
249
where $a_n$ and $b_n$ are either rational numbers, real numbers, or complex
250
numbers. If $b_n = 1$ for all $n$ the expression is called a simple continued
251
fraction. If the expression has a finite amount of terms, it is called a finite
252
continued fraction. Similarly, if the expression has an infinite number of
253
terms, it is called an infinite continued fraction.
254
255
\vspace{0.02cm}{$e$ as a continued fraction:}
256
257
$$
258
e = 2+\cfrac{1}{1+\cfrac{1}{2+\cfrac{2}{3+\cfrac{3}{4+\cdots}}}}
259
$$
260
261
$\pi$ as a continued fraction:
262
263
$$
264
\pi = {\cfrac{4}{1+\cfrac{1^2}{3+\cfrac{2^2}{5+\cfrac{3^2}{7+\cfrac{4^2}{9+\cdot
265
s}}}}}}
266
$$
267
268
$\sqrt{2}$ as a continued fraction:
269
270
$$
271
\sqrt{2} = 1+\cfrac{1}{2+\cfrac{1}{2+\cfrac{1}{2+\cfrac{1}{2+\cdots}}}}
272
$$
273
274
\newpage
275
276
\noindent\textbf{{Python Code For Approximating e:}} \par
277
278
Below is the code I wrote to approximate $e$:
279
280
\begin{lstlisting}[language=Python, caption=Estimator for $e$]
281
n = input("How many decimals of e would you like to approximate?")
282
283
sum = 0
284
desired_e = N(e, digits = n + 1)
285
term_number = 0
286
287
while sum != desired_e:
288
sum += 1/factorial(term_number)
289
term_number += 1
290
291
print "NOTE: The code will approximate to the " + str(n) + " digits you
292
requested, but it will show " + str(n+1) + " digits to prevent rounding errors."
293
print "-----------------------------------------------------------"
294
print "Estimated value of e: " + str(N(sum, digits = n + 1))
295
print "-----------------------------------------------------------"
296
print "Actual value of e: " + str(desired_e)
297
print "-----------------------------------------------------------"
298
print "Difference: " + str((N(desired_e - sum, digits = 2)))
299
print "-----------------------------------------------------------"
300
\end{lstlisting}
301
302
\vspace{0.2cm}{\noindent\textbf{{Explanation:}}} \par
303
304
The code will ask how many digits of $e$ you would like to approximate and store
305
it in variable $n$. The variable "sum" has an initial value of $0$. While "sum"
306
is not equal to the actual value of $e$ ("desired{\_}e"), the series expansion
307
for $e$ (shown below) will be continuously added to "sum", increasing the
308
"term{\_}number" ($k$) by $1$ integer each time until "sum" does equal
309
"desired{\_}e". When "sum" does equal "desired{\_}e", the code will exit the
310
While loop. The code will then print the value of $e$ estimated with the
311
variable "sum" with $n+1$ digits. Underneath that, the code will print the
312
actual value of $e$ (stored as a constant by SageMathCloud) with the variable
313
"desired{\_}e" with $n+1$ digits. The code will then calculate the difference
314
between the estimated and actual value of $e$ and print that number. NOTE: The
315
difference should always be zero if the code is properly functioning. \par
316
317
\vspace{0.2cm}{\noindent\textbf{{Series Expansion Used for $e$:}}} \par
318
319
$$
320
e =\sum ^{\infty }_{k=0}\dfrac{1}{k!}
321
$$
322
323
\newpage
324
325
\noindent\textbf{{Python Code For Approximating $\sqrt{2}$:}} \par
326
327
Below is the code I wrote to approximate $\sqrt{2}$:
328
329
\begin{lstlisting}[language=Python, caption=Estimator For $\sqrt{2}$]
330
n_2 = input("How many decimals of sqrt(2) would you like to approximate?")
331
332
sum_2 = 0
333
desired_2 = N(sqrt(2), digits = n_2 + 1)
334
term_number_2 = 0
335
336
while sum_2 != desired_2:
337
sum_2 += (factorial(2*(term_number_2)+1))/((2^(3*(term_number_2)+1))*(factorial(
338
term_number_2))^2)
339
term_number_2 += 1
340
341
print "NOTE: The code will approximate to the " + str(n_2) + " digits you
342
requested, but it will show " + str(n_2+1) + " digits to prevent rounding
343
errors."
344
print "-----------------------------------------------------------"
345
print "Estimated value of 2: " + str(N(sum_2, digits = n_2 + 1))
346
print "-----------------------------------------------------------"
347
print "Actual value of 2: " + str(desired_2)
348
print "-----------------------------------------------------------"
349
print "Difference: " + str((N(desired_2 - sum_2, digits = 2)))
350
print "-----------------------------------------------------------"
351
\end{lstlisting}
352
353
\vspace{0.2cm}{\noindent\textbf{{Explanation:}}} \par
354
355
The code for approximating $\sqrt{2}$ is essentially the same as the code for
356
approximating $e$. The only difference is in the variables and the series
357
expansions.\par
358
359
\vspace{0.2cm}{\noindent\textbf{{Series Expansion Used for $\sqrt{2}$:}}} \par
360
361
$$
362
\sqrt{2} =\sum ^{\infty }_{k=0}\dfrac {\left( 2k+1\right) !}{2^{3k+1}\left(
363
k!\right) ^{2}}
364
$$
365
366
\newpage
367
368
\noindent\textbf{{Python Code For Approximating $\pi$}} \par
369
370
Below is the code I wrote to approximate $\pi$:
371
372
\begin{lstlisting}[language=Python, caption=Estimator For $\pi$]
373
n_pi = input("How many decimals of pi would you like to approximate?")
374
375
sum_pi = 0
376
desired_pi = N(pi, digits = n_pi + 1)
377
term_number_pi = 0
378
379
while sum_pi != desired_pi:
380
sum_pi += (1/(16^term_number_pi))*((4/(8*(term_number_pi)+1))-(2/(8*(term_number
381
_pi)+4))-(1/(8*(term_number_pi)+5))-(1/(8*(term_number_pi)+6)))
382
term_number_pi += 1
383
384
print "NOTE: The code will approximate to the " + str(n_pi) + " digits you
385
requested, but it will show " + str(n_pi+1) + " digits to prevent rounding
386
errors."
387
print "-----------------------------------------------------------"
388
print "Estimated value of pi: " + str(N(sum_pi, digits = n_pi + 1))
389
print "-----------------------------------------------------------"
390
print "Actual value of pi: " + str(desired_pi)
391
print "-----------------------------------------------------------"
392
print "Difference: " + str((N(desired_pi - sum_pi, digits = 2)))
393
print "-----------------------------------------------------------"
394
\end{lstlisting}
395
396
\vspace{0.2cm}{\noindent\textbf{{Explanation:}}} \par
397
398
The code for approximating $\pi$ is essentially the same as the code for
399
approximating $e$ and $\sqrt{2}$. The only difference is in the variables and
400
the series expansions.\par
401
402
\vspace{0.2cm}{\noindent\textbf{{Series Expansion for $\pi$
403
(Bailey–Borwein–Plouffe Formula):}}} \par
404
405
$$
406
\pi =\sum ^{\infty }_{k=0}\left[ \dfrac {1}{16^{k}}\left( \dfrac
407
{4}{8k+1}-\dfrac {2}{8k+4}-\dfrac {1}{8k+5}-\dfrac {1}{8k+6}\right) \right]
408
$$
409
410
Interestingly enough, the code for approximating $\pi$ gave me the most trouble.
411
The series expansions that I had previously used in the code either did not
412
converge fast enough or somehow made the variable "sum{\_}pi" infinitely locked
413
in the While loop. After some research and trial and error, I discovered the
414
Bailey–Borwein–Plouffe Formula and decided to try it. It worked perfectly.
415
416
\newpage
417
418
\section*{Conclusion}
419
420
Overall, this has been my favorite project. The code was fairly challenging and
421
I initially ran into a couple of issues, but this was the first project where I
422
figured the code out on my own. While I went to Mr. Abell when technical issues
423
arose, the basic structure of the code was my own. In addition, this is the
424
first project that I started well in advance of the due date. I usually try to
425
figure the project out the day it is assigned, but then I put it off until the
426
last few days. This time, I had finished the code a week or two before the due
427
date, making it possible for me to write the report without any stress. \par
428
429
I have really enjoyed brushing up my Python skills and learning \LaTeX \space
430
this year, and I hope I can continue to use these tools in the future, whether
431
it be for school or just for fun.
432
433
\end{document}
434
435