This repository has been archived by the owner on May 11, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 863
/
slope_intercept_form.html
194 lines (176 loc) · 10.9 KB
/
slope_intercept_form.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
<!DOCTYPE html>
<html data-require="math math-format graphie">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Slope intercept form</title>
<script data-main="../local-only/main.js" src="../local-only/require.js"></script>
<style>
.reading > span {
width: 40px;
}
</style>
</head>
<body>
<div class="exercise">
<div class="vars" data-ensure="Math.pow(Y1 - Y2, 2) + Math.pow(X1 - X2, 2) < 36 && X1 < X2 && -10 <= B && B <= 10">
<var id="X1">randRange(-9, 9)</var>
<var id="Y1">randRange(-9, 9)</var>
<var id="X2">randRange(-9, 9)</var>
<var id="Y2">randRange(-9, 9)</var>
<var id="M">(Y1 - Y2) / (X1 - X2)</var>
<var id="B">Y1 - M * X1</var>
</div>
<div class="problems">
<div id="show-table">
<div class="vars">
<var id="COORDS">
(function() {
var coords = [];
coords.push( [ X1, [ Y1, 1 ] ] );
coords.push( [ X2, [ Y2, 1 ] ] );
var xs = randRangeUnique( -10, 10, 5 );
for ( var i = 0; i < 5; i++ ) {
var x = xs[ i ];
if( x !== X1 && x !== X2 ) {
var denom = X1 - X2,
num = x * ( Y1 - Y2 ) + B * denom,
negative = ( num * denom < 0 ? -1 : 1 );
num = round( abs( num ) * negative );
denom = round( abs( denom ) );
coords.push( [ x, [ num / getGCD( num, denom ), denom / getGCD( num, denom )] ] );
}
}
return coords.sort( function(a, b) { return a[ 0 ] - b[ 0 ]; });
})()
</var>
</div>
<p>A line goes through the following points, and the equation of that line is written in <code>y = mx + b</code> form.</p>
<p class="question">What is the equation of the line?</p>
<p class="render-answer-area-here"></p>
<div class="fake_header reading">
<span><code>x</code></span><span><code>y</code></span>
</div>
<div class="fake_row reading" data-each="COORDS as i, coord">
<span><code><var>coord[ 0 ]</var></code></span><span><code><var>coord[ 1 ][ 1 ] === 1 ? coord[ 1 ][ 0 ] : coord[ 1 ].join( "/" )</var></code></span>
</div>
<div class="solution" data-type="multiple">
<p><code>y = {}</code><span class="sol short40" data-forms="integer, proper, improper, mixed, decimal, coefficient"><var>M</var></span> <code>x + {}</code><span class="sol short40"><var>B</var></span></p>
</div>
<div class="hints">
<div>
<p>We can plot all the points and the line that connects them.</p>
<div class="graphie">
graphInit({
range: 10,
scale: 20,
tickStep: 1,
labelStep: 1,
unityLabels: false,
labelFormat: function( s ) { return "\\small{" + s + "}"; },
axisArrows: "<->"
});
style({ stroke: BLUE, fill: BLUE });
line( [X1 - 19, Y1 - 19 * M], [X2 + 19, Y2 + 19 * M], {
stroke: BLUE
} );
$.each( COORDS, function( i, coord ) {
circle( [ coord[ 0 ], coord[ 1 ][ 0 ] / coord[ 1 ][ 1 ] ], 3 / 20 );
});
</div>
</div>
<p>We can choose any two points to determine the equation of the line.</p>
<p>Let's choose <code>(<var>X1</var>, <var>Y1</var>)</code> and <code>(<var>X2</var>, <var>Y2</var>)</code>.</p>
<p>The equation for the slope is <code>m = \dfrac{y_2 - y_1}{x_2 - x_1}</code>.</p>
<div>
<p>Substitute both points.</p>
<p><code>m = \dfrac{<var>Y2</var> - <var>negParens(Y1)</var>}{<var>X2</var> - <var>negParens(X1)</var>} = <var>fractionReduce( Y2 - Y1, X2 - X1 )</var></code></p>
</div>
<p>
Writing the equation of the line, we have <code>y = <var>( M === -1 ? "-" : ( M === 1 ? "" : fractionReduce( Y2 - Y1, X2 - X1 )))</var> x + b</code>
<span data-if="abs( M ) === 1"> (the value of <code>m</code> is equal to <code><var>M</var></code>)</span>.
</p>
<p>To find <code>b</code>, we can substitute in either of the two points into the above equation. Let's go through both cases:</p>
<div>
<p>Using the first point <code>(<var>X1</var>, <var>Y1</var>)</code>, substitute <code>y = <var>Y1</var></code> and <code>x = <var>X1</var></code>:</p>
<p><code><var>Y1</var> = (<var>fractionReduce( Y2 - Y1, X2 - X1 )</var>)(<var>X1</var>) + b</code></p>
<p><code>b = <var>Y1</var> - <var>fractionReduce( X1 * ( Y2 - Y1 ), X2 - X1 )</var> = <var>fractionReduce( Y1 * (X2 - X1) - X1 * ( Y2 - Y1 ), X2 - X1 )</var></code></p>
</div>
<div>
<p>Using the second point <code>(<var>X2</var>, <var>Y2</var>)</code>, substitute <code>y = <var>Y2</var></code> and <code>x = <var>X2</var></code>:</p>
<p><code><var>Y2</var> = (<var>fractionReduce( Y2 - Y1, X2 - X1 )</var>)(<var>X2</var>) + b</code></p>
<p><code>b = <var>Y2</var> - <var>fractionReduce( X2 * ( Y2 - Y1 ), X2 - X1 )</var> = <var>fractionReduce( Y2 * (X2 - X1) - X2 * ( Y2 - Y1 ), X2 - X1 )</var></code></p>
</div>
<p>In both cases, the equation of the line is <code>y = <var>( M === -1 ? "-" : ( M === 1 ? "" : fractionReduce( Y2 - Y1, X2 - X1 )))</var> x + <var>fractionReduce( Y1 * (X2 - X1) - X1 * ( Y2 - Y1 ), X2 - X1 )</var></code><span data-if="abs( M ) === 1"> (the value of <code>m</code> is equal to <code><var>M</var></code>)</span>.</p>
</div>
</div>
<div id="show-points-and-or-graph">
<div class="vars">
<var id="SHOW_GRAPH">randRange( 0, 1 )</var>
</div>
<div class="problem">
<p>The equation of the line through the points <code>(<var>X1</var>, <var>Y1</var>)</code> and <code>(<var>X2</var>, <var>Y2</var>)</code> is written in the form <code>y = mx + b</code>.</p>
</div>
<p class="question">What is the equation of the line?</p>
<p class="render-answer-area-here"></p>
<div class="graphie" data-if="SHOW_GRAPH">
graphInit({
range: 10,
scale: 20,
tickStep: 1,
labelStep: 1,
unityLabels: false,
labelFormat: function( s ) { return "\\small{" + s + "}"; },
axisArrows: "<->"
});
style({ stroke: BLUE, fill: BLUE });
line( [X1 - 19, Y1 - 19 * M], [X2 + 19, Y2 + 19 * M] );
circle( [X1, Y1], 3/20 );
circle( [X2, Y2], 3/20 );
</div>
<div class="solution" data-type="multiple">
<p><code>y =</code> <span class="sol short40" data-forms="integer, proper, improper, mixed, decimal, coefficient"><var>M</var></span><code>\enspace\cdot\enspace x + </code>
<span class="sol short40"><var>B</var></span></p>
</div>
<div class="hints">
<div class="graphie" data-if="!SHOW_GRAPH">
graphInit({
range: 10,
scale: 20,
tickStep: 1,
labelStep: 1,
unityLabels: false,
labelFormat: function( s ) { return "\\small{" + s + "}"; },
axisArrows: "<->"
});
style({ stroke: BLUE, fill: BLUE });
line( [X1 - 19, Y1 - 19 * M], [X2 + 19, Y2 + 19 * M] );
circle( [X1, Y1], 3/20 );
circle( [X2, Y2], 3/20 );
</div>
<p>The equation for the slope is <code>m = \dfrac{y_2 - y_1}{x_2 - x_1}</code>.</p>
<div>
<p>Substitute both points.</p>
<p><code>m = \dfrac{<var>Y2</var> - <var>negParens(Y1)</var>}{<var>X2</var> - <var>negParens(X1)</var>} = <var>fractionReduce( Y2 - Y1, X2 - X1 )</var></code></p>
</div>
<p>
Writing the equation of the line, we have <code>y = <var>( M === -1 ? "-" : ( M === 1 ? "" : fractionReduce( Y2 - Y1, X2 - X1 )))</var> x + b</code>
<span data-if="abs( M ) === 1"> (the value of <code>m</code> is equal to <code><var>M</var></code>)</span>.
</p>
<p>To find <code>b</code>, we can substitute in either of the two points into the above equation. Let's go through both cases:</p>
<div>
<p>Using the first point <code>(<var>X1</var>, <var>Y1</var>)</code>, substitute <code>y = <var>Y1</var></code> and <code>x = <var>X1</var></code>:</p>
<p><code><var>Y1</var> = (<var>fractionReduce( Y2 - Y1, X2 - X1 )</var>)(<var>X1</var>) + b</code></p>
<p><code>b = <var>Y1</var> - <var>fractionReduce( X1 * ( Y2 - Y1 ), X2 - X1 )</var> = <var>fractionReduce( Y1 * (X2 - X1) - X1 * ( Y2 - Y1 ), X2 - X1 )</var></code></p>
</div>
<div>
<p>Using the second point <code>(<var>X2</var>, <var>Y2</var>)</code>, substitute <code>y = <var>Y2</var></code> and <code>x = <var>X2</var></code>:</p>
<p><code><var>Y2</var> = (<var>fractionReduce( Y2 - Y1, X2 - X1 )</var>)(<var>X2</var>) + b</code></p>
<p><code>b = <var>Y2</var> - <var>fractionReduce( X2 * ( Y2 - Y1 ), X2 - X1 )</var> = <var>fractionReduce( Y2 * (X2 - X1) - X2 * ( Y2 - Y1 ), X2 - X1 )</var></code></p>
</div>
<p>In both cases, the equation of the line is <code>y = <var>( M === -1 ? "-" : ( M === 1 ? "" : fractionReduce( Y2 - Y1, X2 - X1 )))</var> x + <var>fractionReduce( Y1 * (X2 - X1) - X1 * ( Y2 - Y1 ), X2 - X1 )</var></code><span data-if="abs( M ) === 1"> (the value of <code>m</code> is equal to <code><var>M</var></code>)</span>.</p>
</div>
</div>
</div>
</div>
</body>
</html>