-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
274 lines (267 loc) · 21.8 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Pascal's Triangle</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css">
<link rel="stylesheet" href="pascal.css">
</head>
<body>
<nav class="navbar bg-light">
<div class="container-fluid d-flex">
<h1 class="navbar-brand mb-0 h1 mx-auto">Pascal's Triangle</h1><a href="https://github.com/jasonhe54/pascal-triangle" class="text-dark bi bi-github float-right" target="_blank"></a>
</div>
</nav>
<!-- <div class="alert alert-info" role="alert">
If you're on a smaller screen, or have a larger triangle with part of the triangle missing, you can scroll the triangle
right and left to see
the entire diagram
</div> -->
<div class="container text-center noPadding">
<div class="row align-items-start noMargin" style="max-width: 100%;">
<div class="col-lg-12 order-1 overflow-auto">
<div id="pTriangle" class="scaledv1" data-show0s="false"></div>
</div>
</div>
<span class="noCSS text-muted" style="font-size: 12px;">The first row is Row 0, representing (a + b)<sup>0</sup>.</span><br>
<span class="noCSS text-muted" style="font-size: 12px;">You can scroll the triangle right and left to see the entire triangle if any part is cut off.</span>
</div>
<hr>
<div class="masonry-container">
<div class="row noMargin" data-masonry='{"percentPosition": true }' style="max-width: 100%;">
<div class="col-sm-6 mb-4">
<div class="card text-bg-light mb-3" style="max-width: 30rem; margin: auto;">
<div class="card-header" id="ConfigurationPanel">Configuration</div>
<div class="card-body">
<form id="NumberOfRowsForm">
<label for="rows">Number of Rows:</label>
<input type="number" id="NumberOfRows_SettingInput" name="rows" min="1" required
style="width: 100px;">
<input type="submit" class="btn btn-dark" value="Set">
<br>
Current Number of Rows: <span id="NumberOfRows_Current" class="noCSS">-</span>
<br>
There is no maximum number of rows, but anything after 30 rows will not be formatted well.
<hr>
Note: The first row is <i>"row 0"</i>, so if you set the number of rows to 20, the last row will be called the 19th row, but it'll be the 20th row that you can see.
</form>
<hr>
<button id="showHide0sBtn" type="button" class="btn btn-dark" onclick="showHide0s()">Show 0s in Pascal's Triangle</button>
</div>
</div>
</div>
<!-- <div class="col-sm-6 mb-4">
<div class="card text-bg-light mb-3" style="max-width: 30rem; margin: auto;">
<div class="card-header">Notice</div>
<div class="card-body">
<p class="card-text">If you're on a smaller screen, or have a larger triangle with part of the triangle missing, you can scroll the triangle right and left to see the entire diagram.</p>
</div>
</div>
</div> -->
<div class="col-sm-6 mb-4">
<div class="card text-bg-light mb-3" style="max-width: 30rem; margin: auto;">
<div class="card-header">Triangle Creation Explanation</div>
<div class="card-body">
<p class="card-text">
<b>In General:</b>
<ul>
<li>
Pascal's Triangle can be created by placing a 1 in the first row (<i>"row 0"</i>). It is assumed that all empty spaces next to a <i>1</i> is a <i>0</i>. The following row can be created by taking the sum of the two numbers directly above it. This will be done for each non-0 number in the row, with the starting number always being <i>1</i> and the ending number always being <i>1</i>. This process will be repeated for each row until you have however many rows you want.
</li>
</ul>
If you want the more technical explanation of how the Pascal's Triangle on this page was created you can read the comments inside of the <kbd>createTriangle()</kbd> function in the <kbd>pascal.js</kbd> file <a href="./pascal.js" target="_blank">here</a>.
</p>
</div>
</div>
</div>
<!-- <div class="col-md-4 col-sm-6 mb-4">
<div class="card text-bg-light mb-3" style="max-width: 25rem; margin: auto;">
<div class="card-header">About</div>
<div class="card-body">
<p class="card-text">Created By: ...</p>
</div>
</div>
</div> -->
</div>
</div>
<hr>
<h2 id="ResearchQuestionSection" class="text-center">Research Questions:</h2>
<div class="masonry-container">
<div class="row noMargin" data-masonry='{"percentPosition": true }' style="max-width: 100%;">
<div class="col-sm-6 mb-4">
<div class="card text-bg-light mb-3" style="max-width: 30rem; margin: auto;">
<div class="card-header">Research Question #1</div>
<div class="card-body">
<b>
What is the Binomial Expansion Theorem? Explain and show how Pascal's Triangle can be used to expand any (ax +
by)<sup>n</sup>.
Discuss both coefficients and degree of variables.
</b>
<br>
The Binomial Expansion Theorem is used to expand binomials in the form of (a+b)<sup>n</sup>. See
<a href="./BinomialTheorem_FormulaApplication.jpg" target="_blank">this image</a> for an example on using the Binomial Expansion Theorem Formula. In connection to Pascal's Triangle, given the binomial (ax + by)<sup>n</sup> where <i>a</i> and <i>b</i> equal 1, you can look at row <i>n</i> of Pascal's Triangle to find the coefficients of the expanded binomial expression (See Example 1). If <i>a</i> and <i>b</i> aren't equal to 1, then it's still useful, just not as straightforward (See Example 2).<br>
<b>For Example:</b><br>
<ol>
<li>
Given (x+y)<sup>4</sup> where <i>a</i> and <i>b</i> both equal 1 and <i>n</i> equals 4, the coefficients of the
expanded binomial can be found in row 4 of Pascal's Triangle. The non-0 numbers in row 4 of Pascal's Triangle
are: <b>1, 4, 6, 4, 1</b>. Thus the expanded binomial is: <b>1</b>x<sup>4</sup> + <b>4</b>x<sup>3</sup>y +
<b>6</b>x<sup>2</sup>y<sup>2</sup> + <b>4</b>xy<sup>3</sup> + <b>1</b>y<sup>4</sup>.
</li>
<li>
Given (2x+2y)<sup>5</sup> where <i>a</i> and <i>b</i> both equal 2 and <i>n</i> equals 5, you would first look at the 5th row of Pascal's Triangle which has the numbers <b>1, 5, 10, 10, 5, 1</b>. The expanded expression would be <b>1</b>(2x)<sup>5</sup> + <b>5</b>(2x)<sup>4</sup>(2y) + <b>10</b>(2x)<sup>3</sup>(2y)<sup>2</sup> + <b>10</b>(2x)<sup>2</sup>(2y)<sup>3</sup> + <b>5</b>(2x)(2y)<sup>4</sup> + <b>1</b>(2y)<sup>5</sup>, which is the same as <b>32x<sup>5</sup> + 160x<sup>4</sup>y + 320x<sup>3</sup>y<sup>2</sup> + 320x<sup>2</sup>y<sup>3</sup> + 160xy<sup>4</sup> + 32y<sup>5</sup></b>.
</li>
</ol>
With regards to the degree of the variables, given that the binomial is written as (x+y)<sup>n</sup>, the degree of the x variable of the first term would be the
<i>n</i>th degree and the degree of the y variable in the first term would be the 0th degree, or no degree. The x
variable begins at the <i>n</i>th power and goes down to the 0th power while the y variable begins at the 0th power and
goes up to the <i>n</i>th power.<br>
<b>For Example:</b>
<ol>
<li>
Looking back to (x+y)<sup>4</sup>, the expanded form of the binomial is the following polynomial: 1x<sup>4</sup>
+ 4x<sup>3</sup>y + 6x<sup>2</sup>y<sup>2</sup> + 4xy<sup>3</sup> + 1y<sup>4</sup>, which is the same as
1x<sup>4</sup>y<sup>0</sup> + 4x<sup>3</sup>y<sup>1</sup> + 6x<sup>2</sup>y<sup>2</sup> +
4x<sup>1</sup>y<sup>3</sup> + 1x<sup>0</sup>y<sup>4</sup>. Notice how in the first term
(1x<sup>4</sup>y<sup>0</sup>) the x variable is raised to the 4th (or the <i>n</i>) power, the second term
(4x<sup>3</sup>y) the x variable is raised to the 3rd (or the <i>n-1</i>) power, so on and so forth until in the
last term (1y<sup>4</sup>) the x variable is raised to the 0th power. The opposite is true for the y variable.
It starts with y raised to the 0th power in the first term and goes up to the 4th (or the <i>n</i>) power in the
last term (1x<sup>0</sup>y<sup>4</sup>).
</li>
</ol>
<hr>
<b>
Resources:
</b>
<ol>
<li>
<a href="https://www.khanacademy.org/math/precalculus/x9e81a4f98389efdf:series/x9e81a4f98389efdf:binomial/v/binomial-theorem" target="_blank">Khan Academy: Intro to the Binomial Theorem</a><br>
</li>
<li>
<a href="https://www.khanacademy.org/math/precalculus/x9e81a4f98389efdf:series/x9e81a4f98389efdf:binomial/v/pascals-triangle-binomial-theorem" target="_blank">Khan Academy: Pascal's triangle and binomial expansion</a>
</li>
</ol>
</div>
<div class="card-footer text-muted">
<span class="noCSS">Jason He</span>
<a class="noCSS backToTop" onclick="scrollToResearchSection()">Back To Top of Questions</a>
</div>
</div>
</div>
<div class="col-sm-6 mb-4">
<div class="card text-bg-light mb-3" style="max-width: 30rem; margin: auto;">
<div class="card-header">Research Question #2</div>
<div class="card-body">
<b>
Who was Blaise Pascal, and what did he do? What and how did he contribute to the field of mathematics? What social, political, or other factors influenced him and his work?
</b>
<br>
Blaise Pascal was a French mathematician, physicist, and philosopher who is known for inventing the mechanical calculator, the syringe, and the hydraulic press, and for his contributions and developments in probability theory. In the field of mathematics, his main contributions were Pascal’s triangle, which was originally written for gambling purposes, and the invention of the Pascaline, or Pascal’s calculator. When he was 3, his mother died and his father, Étienne Pascal moved to Paris with his children and decided to educate them himself, where Blaise discovered his talents and interest in mathematics and science, something that his father was also passionate about. Étienne became a French tax officer and spent countless hours calculating taxes over and over. In order to help ease his father’s workload, Blaise, who was 18 at the time, invented a calculator, although it was only capable of addition and subtraction. In 1654, Pascal wrote up Pascal’s triangle, which he called the arithmetic triangle. The concept was written several times in Asia, but Pascal was the first in the western world to come up with the idea. The triangle contained binomial coefficients and patterns that were used in algebra, probabilities, and statistics
<hr>
<b>
Resources:
</b>
<ol>
<li>
<a href="https://mathshistory.st-andrews.ac.uk/Biographies/Pascal/#:~:text=Blaise%20Pascal%20was%20a%20very,for%20the%20theory%20of%20probability." target="_blank">Blaise Pascal Biography - MacTutor History of Mathematics</a><br>
</li>
<li>
<a href="https://en.wikipedia.org/wiki/Blaise_Pascal" target="_blank">Blaise Pascal - Wikipedia</a>
</li>
<li>
<a href="https://www.britannica.com/biography/Blaise-Pascal" target="_blank">Blaise Pascal - Britannica</a>
</li>
<li>
<a href="https://en.wikipedia.org/wiki/Pascal%27s_triangle" target="_blank">Pascal Triangle - Wikipedia</a>
</li>
</ol>
</div>
<div class="card-footer text-muted">
<span class="noCSS">Derik Leung</span>
<a class="noCSS backToTop" onclick="scrollToResearchSection()">Back To Top of Questions</a>
</div>
</div>
</div>
<div class="col-sm-6 mb-4">
<div class="card text-bg-light mb-3" style="max-width: 30rem; margin: auto;">
<div class="card-header">Research Question #3</div>
<div class="card-body">
<b>
How many odd numbers are in the 100th row of the triangle? The 101st row? The 200th row? Give a general procedure for determining the number of odd numbers in the <i>n</i>th row of the triangle without drawing it out.
</b><br>
<b>General Procedure:</b><br>
To find the amount of odd numbers in any row of Pascal's Triangle, you need to find the highest power of 2 that fits into the number of rows (the value of <i>n</i>), subtract that amount from <i>n</i>, then repeat until <i>n</i>=0. With this, you can turn the number into its binary representation.
<br>
<b>For Example:</b>
<ol>
<li>
Given <b>n = 100</b> <i class="bi bi-info-circle" data-bs-toggle="popover" data-bs-content="100th row you can see. Called the 99th row." data-bs-trigger="focus" tabindex="0"></i><br>
100 = <b>64+32+4</b><br>
It can be expressed as: <b>1(2<sup>6</sup>) + 1(2<sup>5</sup>) + 0(2<sup>4</sup>) + 0(2<sup>3</sup>) + 1(2<sup>2</sup>) + 0(2<sup>1</sup>) + 0(2<sup>0</sup>)</b><br>
100 in Binary = <b>1100100<sub>2</sub></b><br>
In the binary representation of 100, there are <b>3</b> 1s, therefore, there are <b>2<sup>3</sup></b> or <b>8</b> odd numbers in the 100th row of Pascal's Triangle.
</li>
<li>
Given <b>n = 101</b> <i class="bi bi-info-circle" data-bs-toggle="popover" data-bs-content="101st row you can see. Called the 100th row." data-bs-trigger="focus" tabindex="0"></i><br>
101 = <b>64+32+4+1</b><br>
It can be expressed as: <b>1(2<sup>6</sup>) + 1(2<sup>5</sup>) + 0(2<sup>4</sup>) + 0(2<sup>3</sup>) + 1(2<sup>2</sup>) + 0(2<sup>1</sup>) + 1(2<sup>0</sup>)</b><br>
101 in Binary = <b>1100101<sub>2</sub></b><br>
In the binary representation of 101, there are <b>4</b> 1s, therefore, there are <b>2<sup>4</sup></b> or <b>16</b> odd numbers in the 101st row of Pascal's Triangle.
</li>
<li>
Given <b>n = 200</b> <i class="bi bi-info-circle" data-bs-toggle="popover" data-bs-content="200th row you can see. Called the 199th row." data-bs-trigger="focus" tabindex="0"></i><br>
200 = <b>128+64+8</b><br>
It can be expressed as: <b>1(2<sup>7</sup>) + 1(2<sup>6</sup>) + 0(2<sup>5</sup>) + 0(2<sup>4</sup>) + 1(2<sup>3</sup>) + 0(2<sup>2</sup>) + 0(2<sup>1</sup>) + 0(2<sup>0</sup>)</b><br>
200 in Binary = <b>11001000<sub>2</sub></b><br>
In the binary representation of 200, there are <b>3</b> 1s, therefore, there are <b>2<sup>3</sup></b> or <b>8</b> odd numbers in the 200th row of Pascal's Triangle.
</li>
</ol>
<hr>
<b>
Proof Of Concept:
</b>
<form id="binaryPOCForm">
<div class="input-group mb-3">
<span class="input-group-text" id="binaryNumberInput">n=</span>
<input type="number" class="form-control" placeholder="Enter a number" aria-label="n="
aria-describedby="binaryNumberInput" id="binaryPOC_Input">
<button type="submit" class="btn btn-dark" onclick="oddNum_binaryPOC()">Get</button>
</div>
</form>
<span class="noCSS text-muted mb-0 pd-0" style="font-size: 12px;">First row is n=0. So if n=20, then it'll return the results for the 21st row that you can see. If you want to double check with Pascal's Triangle, make sure you use n+1 for the number of rows in the <a onclick="scrollToConfigurationPanel()" class="pointer text-primary">Configuration<i class="bi bi-arrow-up-right"></i></a> settings. If you want to see the 15th row, you'd use n=14 here and 15 under Configuration.</span>
<div id="binaryPOCOutput"></div>
<hr>
<b>
Resources:
</b>
<ol>
<li>
<a href="https://www.calculator.net/binary-calculator.html" target="_blank">Binary Calculator - calculator.net</a><br>
</li>
</ol>
</div>
<div class="card-footer text-muted">
<span class="noCSS">Derik Leung</span>
<a class="noCSS backToTop" onclick="scrollToResearchSection()">Back To Top of Questions</a>
</div>
</div>
</div>
</div>
</div>
<footer class="fixed-bottom text-center">
Created By: Jason He and Derik Leung
</footer>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/masonry.pkgd.min.js" integrity="sha384-GNFwBvfVxBkLMJpYMOABq3c+d3KnQxudP/mGPkzpZSTYykLBNsZEnG2D9G/X/+7D" crossorigin="anonymous" async></script>
<!-- <script src="scaling.js"></script> -->
<script src="pascal.js"></script>
<script src="listeners.js"></script>
<script src="scroll.js"></script>
<script src="binary.js"></script>
<script src="popover.js"></script>
</body>
</html>