Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

187 lines (172 sloc) 9.171 kB
<!DOCTYPE html>
<html data-require="math math-format polynomials calculus graphie derivative-intuition">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Derivative intuition</title>
<script src="../khan-exercise.js"></script>
</head>
<body>
<div class="exercise">
<div class="problems">
<div id="polynomial" data-weight="4">
<div class="vars">
<var id="SCENARIO">{}</var>
<var id="POLYNOMIAL">new Polynomial(randRange(0, 3), randRange(2, 4))</var>
<var id="FNXTEXT">POLYNOMIAL.text()</var>
<var id="DDXTEXT">ddxPolynomial(POLYNOMIAL).text()</var>
<var id="FNX">function(x) {return POLYNOMIAL.evalOf(x);}</var>
<var id="DDX">function(x) {return ddxPolynomial(POLYNOMIAL).evalOf(x);}</var>
<var id="POINTS">[-2, -1.5, -1, 0, 1, 1.5, 2]</var>
<var id="XRANGE">[-2.5, 2.5]</var>
<var id="YMIN">min.apply(Math, $.map(POINTS, FNX).concat( $.map(POINTS, DDX)))</var>
<var id="YMAX">max.apply(Math, $.map(POINTS, FNX).concat( $.map(POINTS, DDX)))</var>
<var id="YRANGE">[floorTo(-1, YMIN - (YMAX-YMIN)*0.05 ), ceilTo(-1, YMAX + (YMAX-YMIN)*0.05)]</var>
<var id="OPTIONS">{}</var>
</div>
<div class="question">
<p>
<code class="hint_blue">f(x) = <var>FNXTEXT</var></code>
<span id="ddxspan" style="margin-left: 5em; display: none; opacity:0">
<code class="hint_orange">\frac{d}{dx}f(x) = <var>DDXTEXT</var></code>
</span>
</p>
<p>
Drag each one of the <var>POINTS.length</var> <span class="hint_orange">orange</span> points up and down
to adjust the slope of the corresponding tangent line.</p>
<p>
The derivative of a function is defined as the slope of a line tangent to the curve at each point.
Adjust the slopes of the lines to visually find the derivative <code>\frac{d}{dx} f(x)</code> at each point.
</p>
</div>
<div class="problem">
<div class="graphie" id="ddxplot">
initAutoscaledGraph([ XRANGE, YRANGE], OPTIONS);
style({
stroke: "#6495ED",
strokeWidth: 3
}, function() {
plot( function( x ) {
return FNX( x );
}, XRANGE );
});
initDerivativeIntuition(FNX, DDX, POINTS);
</div>
</div>
<div class="solution" data-type="custom">
<div class="instruction">
<table id="answers">
<tr data-each="POINTS as X">
<td class="sol" style="display: none" data-fallback="0"><var>roundTo(2, DDX(X))</var></td>
<td style="text-align: right" data-if="OPTIONS.xLabelFormat"><code>\frac{d}{dx} f(<var>OPTIONS.xLabelFormat(X)</var>) = </code></td>
<td style="text-align: right" data-else><code>\frac{d}{dx} f(<var>X</var>) = </code></td>
<td class="answer-label">0</td>
</tr>
</table>
</div>
<div class="guess">
(function(){
var guess = [];
$("#answers").find('.answer-label').each(function(label) {
guess.push(parseFloat($(this).text()));
});
return guess;
})()
</div>
<div class="validator-function">
var allDefault = _(guess).all(function(x) {
return x === 0;
});
if (allDefault) {
return "";
}
var correct = _(points).map(function(x) {
return roundTo(2, ddx(x));
});
return guess.join() === correct.join();
</div>
<div class="show-guess">
_(guess).each(function(coordY, i) {
setSlope(i, coordY);
});
var correct = _(points).map(function(x) {
return roundTo(2, ddx(x));
});
if (guess.join() === correct.join()) {
revealDerivative(0);
}
</div>
<div class="show-guess-solutionarea">
$("#answers").find('.answer-label').each(function(index, label) {
$(label).text(guess.length ? guess[index] : 0);
});
</div>
</div>
<div class="hints">
<div>
<p>
The orange curve shows the derivative of <code>f(x)</code>. Drag all of the orange points
onto the orange curve. Notice how the tangent lines change as you move the orange dots.
Pay attention to the relationship between the tangent lines and the blue curve.
</p>
<div class="graphie" data-update="ddxplot">
revealDerivative();
</div>
</div>
</div>
</div>
<div id="special" data-type="polynomial">
<div class="vars">
<var id="SCENARIO">randFromArray([
{
text: "sin(x)",
ddxtext: "cos(x)",
fnx: function(x) { return Math.sin(x); },
ddx: function(x) { return Math.cos(x); },
xrange: [-1.25*Math.PI, 1.25*Math.PI],
yrange: [ -1.25, 1.25 ],
points: [ -1*Math.PI, -3*Math.PI/4, -Math.PI/2, -Math.PI/4, 0, Math.PI/4, Math.PI/2, 3*Math.PI/4, Math.PI ],
options: { xLabelFormat: piFraction }
}, {
text: "cos(x)",
ddxtext: "-sin(x)",
fnx: function(x) { return Math.cos(x); },
ddx: function(x) { return -Math.sin(x); },
xrange: [-1.25*Math.PI, 1.25*Math.PI],
yrange: [ -1.25, 1.25 ],
points: [ -1*Math.PI, -3*Math.PI/4, -Math.PI/2, -Math.PI/4, 0, Math.PI/4, Math.PI/2, 3*Math.PI/4, Math.PI ],
options: { xLabelFormat: piFraction }
}, {
text: "e^x",
ddxtext: "e^x",
fnx: function(x) { return Math.exp(x, Math.E); },
ddx: function(x) { return Math.exp(x, Math.E); },
xrange: [-5, 5],
yrange: [ -5, 15 ],
points: [ -2, -1, 0, 1, 2 ],
options: {}
}, {
text: "ln(x)",
ddxtext: "\\frac{1}{x}",
fnx: function(x) { return Math.log(x); },
ddx: function(x) { return 1/x; },
xrange: [ 0.001, 5 ],
yrange: [ -5, 5 ],
points: [ 0.25, 0.5, 1, 2, 3, 4 ],
options: { range: [ [ -0.25, 4.75 ], [ -5, 5 ] ] }
}
])
</var>
<var id="FNXTEXT">SCENARIO.text</var>
<var id="DDXTEXT">SCENARIO.ddxtext</var>
<var id="FNX">SCENARIO.fnx</var>
<var id="DDX">SCENARIO.ddx</var>
<var id="XRANGE">SCENARIO.xrange</var>
<var id="YRANGE">SCENARIO.yrange</var>
<var id="POINTS">SCENARIO.points</var>
<var id="OPTIONS">SCENARIO.options || {}</var>
</div>
</div>
</div>
</div>
</body>
</html>
Jump to Line
Something went wrong with that request. Please try again.