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
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add exercise -- line graph intuition
- Loading branch information
Showing
2 changed files
with
129 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
<!DOCTYPE html> | ||
<html data-require="math math-format graphie"> | ||
<head> | ||
<title>Line Graph Intuition</title> | ||
<script src="../khan-exercise.js"></script> | ||
<script> | ||
// Eh... | ||
function updateEquation() { | ||
with( jQuery.tmpl.VARS ) { | ||
with( KhanUtil.currentGraph ) { | ||
PLOT.remove(); | ||
style({ | ||
clipRect:[ [-10, -10], [20, 20] ] | ||
}, function() { | ||
PLOT = plot( function( x ) { | ||
return x * MN / MD + BN / BD; | ||
}, [-10, 10]); | ||
}); | ||
|
||
LABEL.remove(); | ||
LABEL = label( [1, 11], "y = " + KhanUtil.fractionReduce(MN, MD) + "x +" + KhanUtil.fractionReduce(BN, BD)); | ||
|
||
jQuery( "#slope-sol input" ).val( MN + "/" + MD ); | ||
jQuery( "#intercept-sol input" ).val( BN + "/" + BD ); | ||
} | ||
} | ||
} | ||
|
||
function changeSlope( dir ) { | ||
with ( jQuery.tmpl.VARS ) { | ||
var prevDenominator = MD; | ||
MD = KhanUtil.getLCM( prevDenominator, INCR ); | ||
MN = ( MD / prevDenominator * MN ) | ||
+ ( dir * MD / INCR ); | ||
|
||
updateEquation(); | ||
} | ||
} | ||
|
||
function changeIntercept( dir ) { | ||
with( jQuery.tmpl.VARS ) { | ||
var prevDenominator = BD; | ||
BD = KhanUtil.getLCM( prevDenominator, INCR ); | ||
BN = ( BD / prevDenominator * BN ) | ||
+ ( dir * BD / INCR ); | ||
updateEquation(); | ||
} | ||
} | ||
</script> | ||
</head> | ||
<body> | ||
<div class="exercise"> | ||
<div class="vars" data-ensure="X1 !== X2 && !(M === 1 && B === 0)"> | ||
<var id="X1">randRange( -8, 8 )</var> | ||
<var id="X2">randRange( -8, 8 )</var> | ||
<var id="Y1">randRange( -8, 8 )</var> | ||
<var id="Y2">randRange( -8, 8 )</var> | ||
<var id="RISE">Y1 - Y2</var> | ||
<var id="RUN">X1 - X2</var> | ||
<var id="M">RISE / RUN</var> | ||
<var id="B">Y1 - X1 * M</var> | ||
<var id="MN">1</var> | ||
<var id="MD">1</var> | ||
<var id="BN">1</var> | ||
<var id="BD">1</var> | ||
<var id="INCR">abs( RUN ) / getGCD( abs( RISE), abs( RUN ) )</var> | ||
<var id="PLOT">{}</var> | ||
<var id="LABEL">{}</var> | ||
</div> | ||
|
||
<div class="problems"> | ||
<div> | ||
<div class="question"> | ||
Adjust the slope and y-intercept until it connects the two points. How do the slope and y-intercept values affect the line? | ||
</div> | ||
|
||
<div class="graphie" id="grid"> | ||
(function(){ | ||
init({ | ||
range: [[-10, 10], [-10, 12]], | ||
scale: [30, 30] | ||
}); | ||
|
||
grid( [-10, 10], [-10, 10], { | ||
stroke: "#ccc" | ||
}); | ||
|
||
style({ | ||
stroke: "#888", | ||
strokeWidth: 2 | ||
}); | ||
path( [ [-10, 0], [10, 0] ] ); | ||
path( [ [0, -10], [0, 10] ] ); | ||
|
||
style({ | ||
stroke: "#6495ED", | ||
fill: "#6495ED" | ||
}); | ||
|
||
circle( [X1, Y1], 0.15 ); | ||
circle( [X2, Y2], 0.15 ); | ||
|
||
style({ | ||
clipRect:[ [-10, -10], [20, 20] ] | ||
}, function() { | ||
PLOT = plot( function( x ) { | ||
return x * MN / MD + BN / BD; | ||
}, [-10, 10]); | ||
}); | ||
|
||
LABEL = label( [1, 11], "y = " + KhanUtil.fractionReduce(MN, MD) + "x +" + KhanUtil.fractionReduce(BN, BD)); | ||
})() | ||
|
||
</div> | ||
<div class="solution" data-type="multiple"> | ||
<div><input type="button" value="Increase slope" onclick="changeSlope(1)"></div> | ||
<div><input type="button" value="Decrease slope" onclick="changeSlope(-1)"></div> | ||
<div><input type="button" value="Increase y-intercept" onclick="changeIntercept(1)"></div> | ||
<div style="padding: 0px 0px 10px 0px"><input type="button" value="Decrease y-intercept" onclick="changeIntercept(-1)"></div> | ||
|
||
<span class="sol" data-type="rational" data-simplify="optional" style="display: none" id="slope-sol"><var>M</var></span> | ||
<span class="sol" data-type="rational" data-simplify="optional" style="display: none" id="intercept-sol"><var>B</var></span> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters