-
Notifications
You must be signed in to change notification settings - Fork 0
/
practice.html
268 lines (245 loc) · 8.85 KB
/
practice.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
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script type="text/javascript" async
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
</head>
<style>
table, th, td {
padding: 4px;
text-align: center;
border: 1px solid black;
border-collapse: collapse;
}
</style>
</head>
<script src="js/polydiv.js"> </script>
<script src="js/polydiv_rand.js"> </script>
<script>
let stepCount = 0;
let divisionResult = null;
PolyGrid.useGlyphQuestion = true;
function displayQuestion(divisionResult){
return latexRemoteImage(divisionResult.latexShowQuestion());
};
function displayAnswer(divisionResult) {
let htmlString = "The divisor has been placed down the first column of the grid.";
htmlString += " You must find the values to place along the top row.";
htmlString += " Multiplying the first colum by the top row fills the interior of the grid, and ";
htmlString += "summing all values in the interior of the grid should result in the dividend";
htmlString += " (possibly less the remainder).";
htmlString += "<br><br>";
htmlString += "<div>" + divisionResult.htmlLatexHistoryTo(stepCount) + "</div>";
htmlString += "<br>";
return htmlString;
};
function displayFullAnswer(divisionResult) {
let htmlString = "<br>";
htmlString += divisionResult.htmlLatexGrid();
htmlString += "<br>";
htmlString += latexRemoteImage(divisionResult.latexShowQuestion());
htmlString += "<br> " + latexRemoteImage("=" + divisionResult.latexShowSolution());
htmlString += "<button type='button' class='btn btn-info '";
htmlString += " data-toggle='collapse' data-target='#full"+ count + "'>";
htmlString += "Show Additional Steps</button>";
htmlString += "<div id='full" + count +"' class='collapse ' >";
htmlString += "<br>";
htmlString += "<div>" + divisionResult.htmlLatexHistory() + "</div>";
htmlString += "<br>";
htmlString += "So we finally have:";
htmlString += latexRemoteImage(divisionResult.latexShowQuestion());
htmlString += "<br> " + latexRemoteImage("=" + divisionResult.latexShowSolution());
htmlString += " </div>";
htmlString += " </div>";
return htmlString;
};
function reset(){
stepCount = 0;
divisionResult = nextExample().simplify();
initialDisplay();
}
function resetExamplesClicked(event) {
console.log("reset button clicked");
reset();
}
function initialDisplay() {
$("#latexHolder").html("");
$("#latexHolder").append(displayQuestion(divisionResult));
$("#latexHolder").append(displayAnswer(divisionResult));
$("#promptHolder").html(prompt());
$("#nextButton").show();
$('#coefficientInput').show();
$('#solutionButton').show();
MathJax.Hub.Typeset(); //required to render dynamically generated Latex
}
function handleClick(event) {
let solutionDegree = divisionResult.solution.main.degree();
let answer = parseInt($('#numInput').val());
let correct = divisionResult.solution.main.coefficient(solutionDegree - stepCount);
if (answer == correct){
stepCount ++
$("#promptHolder").html(prompt(true));
} else {
$("#promptHolder").html(prompt(false));
}
$("#latexHolder").html("");
$("#latexHolder").append(displayQuestion(divisionResult));
$("#latexHolder").append(displayAnswer(divisionResult));
if (stepCount > solutionDegree){
stepCount = solutionDegree;
$("#nextButton").hide();
$('#coefficientInput').hide();
$('#solutionButton').hide();
} else {
$("#nextButton").show();
$('#coefficientInput').show();
$('#solutionButton').show();
}
MathJax.Hub.Typeset(); //required to render dynamically generated Latex
};
$(document).ready(function(){
$("#nextButton").on("click", function(event){
handleClick(event);
});
$("#resetButton").on("click", function(event){
reset();
});
$(".checkbox").on('click',function(e){
let remainders = $('#remainderCheck:checked').val();
if (remainders == 'yes') {
generateWithRemainders = true;
} else {
generateWithRemainders = false;
}
});
$("#solutionButton").on("click", function(event){
solutionButtonClick();
});
reset();
});
function prompt(correct=true){
let resultHtml = "<br>";
let solutionDegree = divisionResult.solution.main.degree();
let questionDegree = divisionResult.question.numerator.degree();
if (stepCount > solutionDegree){
resultHtml += "Congratulations - we are done!";
resultHtml += "<br>";
resultHtml += latexRemoteImage(divisionResult.latexShowQuestion());
resultHtml += latexRemoteImage("=" + divisionResult.latexShowSolution());
} else {
let answer = parseInt($('#numInput').val());
let prevSolution = divisionResult.solution.main.polyAt(solutionDegree - stepCount +1);
if(!correct){
resultHtml += "Sorry, " + answer + " is not correct, please try again.";
resultHtml += "<br>";
} else if (stepCount > 0){
resultHtml += "Well done! The grid has been filled in using " ;
resultHtml += "\\("+ prevSolution.revShow()+"\\).";
resultHtml += "<br>"
}
$('#numInput').val(0);
let currentTarget = divisionResult.question.numerator.polyAt(( questionDegree- stepCount));
let solution = divisionResult.solution.main.polyAt(solutionDegree - stepCount);
let simpleTerm = Poly.term(1, solutionDegree - stepCount);
let denomDeg = divisionResult.question.denominator.degree();
let denomTerm = divisionResult.question.denominator.polyAt(denomDeg);
resultHtml += "We are working on the term \\("+ currentTarget.revShow()+"\\).";
resultHtml += "<br>";
if (simpleTerm.degree() > 0){
resultHtml += "Try to find the coefficient for the \\("+ simpleTerm.revShow()+"\\)";
} else {
resultHtml += "Try to find the coefficient for the zero degree ";
}
resultHtml += " term in the solution that will help complete the grid. ";
resultHtml += "All degree " + (questionDegree - stepCount) +" terms";
resultHtml += " in interior of the grid, along with the result of multiplying ";
resultHtml += "\\("+ denomTerm.revShow()+"\\) by the new entry in the top row, must add up to";
resultHtml += " \\("+ currentTarget.revShow()+"\\).";
resultHtml += "<br>"
}
return resultHtml;
};
function solutionButtonClick() {
$("#latexHolder").html("");
$("#latexHolder").append(displayQuestion(divisionResult));
$("#latexHolder").append(displayFullAnswer(divisionResult));
$("#promptHolder").html("");
$("#nextButton").hide();
$("#coefficientInput").hide();
$("#solutionButton").hide();
MathJax.Hub.Typeset(); //required to render dynamically generated Latex
};
</script>
<body>
<nav class="navbar navbar-default" style="margin-bottom:0px">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="..">
<img src="imgs/github_badge1.png" style="max-width:100%;max-height:100%" >
</a>
<p class="navbar-text navbar-right">
<a href=".." class="navbar-link">dmackinnon1.github.io</a>
</p>
</div>
</div>
</nav>
<div class="container-fluid">
<div class='row'>
<div class='col-sm-1'>
</div>
<div class='col-sm-10'>
<div class="page-header">
<h1>Polynomial Division using the Grid Method
<div class="btn-group btn-group-md " role="group">
<a class="btn btn-default" href="./calc.html">Calculator</a>
<a class="btn btn-default" href=".">Examples</a>
<a class="btn btn-primary" href="./practice">Practice</a>
</div>
</h1>
</div>
<div>
Most students learn how to divide polynomials using the long division method, a process very similar to long division for numbers.
A less widely known method is the grid or tabular method, described
<a href="http://www.mathrecreation.com/2009/03/dividing-polynomials-grid-method.html">here</a> and
<a href="http://www.mathrecreation.com/2015/09/more-polynomial-grid-division.html">here</a>.
</div>
<div>
<br>
<p>This page will randomly generate division problems and prompt you to provide the solutions, one step at a time.
<br>
<br>
<div class="well well-sm">
<form>
<div class="checkbox">
<label><input id="remainderCheck" type="checkbox" value="yes">generate questions with remainders</label>
</div>
</form>
</div>
<hr>
<div id="latexHolder" style="text-align=center"></div>
<div id="promptHolder" style="text-align=center"></div>
<div id="coefficientInput">
<br>
coefficient: <input id="numInput" type="number" min="-100" max="100" step="1" value="0" maxlength="4" size="4">
</div>
<br>
<div class="btn-group btn-group-md " role="group">
<button id="nextButton" class="btn btn-default"">submit</button>
<button id="solutionButton" class="btn btn-default"">skip to solution</button>
</div>
<br>
<hr>
<button id="resetButton" class="btn btn-default"">new question</button>
<br>
</div>
<div class='col-sm-1'>
</div>
</div>
</body>
</html>