# Khan/khan-exercises

Switch branches/tags
Nothing to show
Fetching contributors…
Cannot retrieve contributors at this time
580 lines (565 sloc) 25.7 KB
 Recognizing slope of curves
randFromArray([ [[ 1, 0, -16, 0, 49], [-5, 5], [-100, 100]], [[-1, 0, 16, 0, -49], [-5, 5], [-250, 100]], [[ 1, 3, -14, -35, 21], [-5, 5], [-100, 200]], [[-1, -3, 14, 35, 0], [-5, 5], [-200, 100]], [[ 1, 4, -1, -4], [-5, 5], [ -40, 120]], [[ -1, -4, 1, 4], [-5, 5], [-150, 40]], [[ 1, 0, -16, 0], [-5, 5], [ -50, 50]], [[ -1, 0, 16, 0], [-5, 5], [ -70, 60]], [[ 1, 0, -22, 27], [-5, 5], [ -30, 70]], [[ -1, 0, 22, -27], [-5, 5], [ -70, 30]], [[ 1, 1, -13, -14], [-5, 5], [ -40, 40]], [[ -1, -1, 13, 14], [-5, 5], [ -40, 40]], [[ 1, 0, -12], [-5, 5], [ -20, 20]], [[ -1, 0, 12], [-5, 5], [ -20, 20]], [[ 1, -1, -6], [-5, 5], [ -20, 20]], [[ -1, 1, 6], [-5, 5], [ -30, 20]], [[ 1, 0, -3], [-5, 5], [ -20, 30]], [[ -1, 0, 3], [-5, 5], [ -30, 20]], [[ 1, 2, 0], [-5, 5], [ -10, 35]], [[ -1, -2, 0], [-5, 5], [ -40, 20]] ]) new Polynomial(0, COEF.length - 1, COEF.reverse()) function(x) {return POLYNOMIAL.evalOf(x);} function(x) {return POLYNOMIAL.derivative().evalOf(x);} _.reduce(findRootsNumerically(FNX, XRANGE), function(intervals, root) { var last = _.last(intervals) return _.initial(intervals).concat([[last[0], root], [root, last[1]]]); }, [XRANGE]) _.reduce(findRootsNumerically(DDX, XRANGE), function(intervals, root) { var last = _.last(intervals) return _.initial(intervals).concat([[last[0], root], [root, last[1]]]); }, [XRANGE]) _.filter(FNX_INTERVALS, function(intv) { return FNX(intv[0] + (intv[1] - intv[0]) / 2) > 0; }) _.filter(FNX_INTERVALS, function(intv) { return FNX(intv[0] + (intv[1] - intv[0]) / 2) < 0; }) _.filter(DDX_INTERVALS, function(intv) { return DDX(intv[0] + (intv[1] - intv[0]) / 2) > 0; }) _.filter(DDX_INTERVALS, function(intv) { return DDX(intv[0] + (intv[1] - intv[0]) / 2) < 0; }) _.reduce( sortNumbers(findRootsNumerically(FNX, XRANGE).concat(findRootsNumerically(DDX, XRANGE))), function(intervals, root) { var last = _.last(intervals) return _.initial(intervals).concat([[last[0], root], [root, last[1]]]); }, [XRANGE] ) _.filter(COMBINED_INTERVALS, function(intv) { return PREDICATE(intv[0] + (intv[1] - intv[0]) / 2); }) _.sortBy(SOLUTION_INTERVALS, function(intv) { return intv[0] - intv[1]; })[0]
graph.slidingWindow.getX()
var correct = _.reduce(_.range(guess, guess + 1, 0.02), function(correct, x) { return correct && PREDICATE(x); }, true); if (!graph.moved && !correct) { return "" } return correct;
graph.slidingWindow.moveTo(guess, 0);

initAutoscaledGraph([XRANGE, YRANGE]); addMouseLayer(); plot(FNX, XRANGE, { stroke: BLUE, strokeWidth: 3 }); graph.moved = false; // start the selection at the first zero of f'(x) which is // guaranteed to be wrong but not give info about the right answer var startX = DDX_INTERVALS[0][1] - 0.5; graph.slidingWindow = addRectGraph({ x: startX, y: YRANGE[0], width: 1, height: YRANGE[1] - YRANGE[0], normalStyle: { area: { "fill-opacity": 0.2 }, edges: { "stroke-width": 0 } }, hoverStyle: { area: { "fill-opacity": 0.3 } }, fixed: { points: [true, true, true, true], edges: [true, true, true, true] }, constraints: { constrainX: false, constrainY: true, xmin: XRANGE[0], xmax: XRANGE[1] }, onMove: function() { graph.moved = true; } });

f(x) = POLYNOMIAL.text()

function(x) { return DDX(x) > 0; }

A function f(x) is plotted below. Highlight an interval where f^\prime(x) > 0.

The first derivative, f^\prime(x), is greater than 0 wherever the function is increasing.

The interval where f(x) is increasing is highlighted above.

The intervals where f(x) is increasing are highlighted above.

_.each(DDX_INTERVALS_POS, function(interval) { plot(FNX, interval, { stroke: ORANGE, strokeWidth: 16, opacity: 0.7 }); });

Select any part of the function that is highlighted.

graph.slidingWindow.moveTo( (SOLUTION_INTERVAL[1] - SOLUTION_INTERVAL[0]) / 2 + SOLUTION_INTERVAL[0] - 0.5, 0);
function(x) { return DDX(x) < 0; }

A function f(x) is plotted below. Highlight an interval where f^\prime(x) < 0.

The first derivative, f^\prime(x), is less than 0 wherever the function is decreasing.

The interval where f(x) is decreasing is highlighted above.

The intervals where f(x) is decreasing are highlighted above.

_.each(DDX_INTERVALS_NEG, function(interval) { plot(FNX, interval, { stroke: ORANGE, strokeWidth: 16, opacity: 0.7 }); });

Select any part of the function that is highlighted.

graph.slidingWindow.moveTo( (SOLUTION_INTERVAL[1] - SOLUTION_INTERVAL[0]) / 2 + SOLUTION_INTERVAL[0] - 0.5, 0);
function(x) { return FNX(x) > 0 && DDX(x) > 0; }

A function f(x) is plotted below. Highlight an interval where f(x) > 0 and f^\prime(x) > 0.

The function f(x) is greater than 0 wherever it's positive.

The interval where f(x) is positive is highlighted above.

The intervals where f(x) is positive are highlighted above.

_.each(FNX_INTERVALS_POS, function(interval) { plot(FNX, [XRANGE[0] - 1, XRANGE[1] + 1], { stroke: ORANGE, strokeWidth: 16, opacity: 0.7 }).attr("clip-rect", scalePoint([range[0][0], range[1][1]])[0] + "," + scalePoint([range[0][0], range[1][1]])[1] + "," + scaleVector([range[0][1] - range[0][0], range[1][1]])[0] + "," + scaleVector([range[0][1] - range[0][0], range[1][1]])[1] ); });

The first derivative, f^\prime(x), is greater than 0 wherever the function is increasing.

The interval where f(x) is increasing is highlighted above.

The intervals where f(x) is increasing are highlighted above.

_.each(DDX_INTERVALS_POS, function(interval) { plot(FNX, interval, { stroke: RED, strokeWidth: 6, opacity: 0.8 }); });

Select any part of the function that is highlighted for both conditions.

graph.slidingWindow.moveTo( (SOLUTION_INTERVAL[1] - SOLUTION_INTERVAL[0]) / 2 + SOLUTION_INTERVAL[0] - 0.5, 0);
function(x) { return FNX(x) > 0 && DDX(x) < 0; }

A function f(x) is plotted below. Highlight an interval where f(x) > 0 and f^\prime(x) < 0.

The function f(x) is greater than 0 wherever it's positive.

The interval where f(x) is positive is highlighted above.

The intervals where f(x) is positive are highlighted above.

_.each(FNX_INTERVALS_POS, function(interval) { plot(FNX, [XRANGE[0] - 1, XRANGE[1] + 1], { stroke: ORANGE, strokeWidth: 16, opacity: 0.7 }).attr("clip-rect", scalePoint([range[0][0], range[1][1]])[0] + "," + scalePoint([range[0][0], range[1][1]])[1] + "," + scaleVector([range[0][1] - range[0][0], range[1][1]])[0] + "," + scaleVector([range[0][1] - range[0][0], range[1][1]])[1] ); });

The first derivative, f^\prime(x), is less than 0 wherever the function is decreasing.

The interval where f(x) is decreasing is highlighted above.

The intervals where f(x) is decreasing are highlighted above.

_.each(DDX_INTERVALS_NEG, function(interval) { plot(FNX, interval, { stroke: RED, strokeWidth: 6, opacity: 0.8 }); });

Select any part of the function that is highlighted for both conditions.

graph.slidingWindow.moveTo( (SOLUTION_INTERVAL[1] - SOLUTION_INTERVAL[0]) / 2 + SOLUTION_INTERVAL[0] - 0.5, 0);
function(x) { return FNX(x) < 0 && DDX(x) > 0; }

A function f(x) is plotted below. Highlight an interval where f(x) < 0 and f^\prime(x) > 0.

The function f(x) is less than 0 wherever it's negative.

The interval where f(x) is negative is highlighted above.

The intervals where f(x) is negative are highlighted above.

_.each(FNX_INTERVALS_NEG, function(interval) { plot(FNX, [XRANGE[0] - 1, XRANGE[1] + 1], { stroke: ORANGE, strokeWidth: 16, opacity: 0.7 }).attr("clip-rect", scalePoint([range[0][0], 0])[0] + "," + scalePoint([range[0][0], 0])[1] + "," + scaleVector([range[0][1] - range[0][0], -range[1][0]])[0] + "," + scaleVector([range[0][1] - range[0][0], -range[1][0]])[1] ); });

The first derivative, f^\prime(x), is greater than 0 wherever the function is increasing.

The interval where f(x) is increasing is highlighted above.

The intervals where f(x) is increasing are highlighted above.

_.each(DDX_INTERVALS_POS, function(interval) { plot(FNX, interval, { stroke: RED, strokeWidth: 6, opacity: 0.8 }); });

Select any part of the function that is highlighted for both conditions.

graph.slidingWindow.moveTo( (SOLUTION_INTERVAL[1] - SOLUTION_INTERVAL[0]) / 2 + SOLUTION_INTERVAL[0] - 0.5, 0);
function(x) { return FNX(x) < 0 && DDX(x) < 0; }

A function f(x) is plotted below. Highlight an interval where f(x) < 0 and f^\prime(x) < 0.

The function f(x) is less than 0 wherever it's negative.

The interval where f(x) is negative is highlighted above.

The intervals where f(x) is negative are highlighted above.

_.each(FNX_INTERVALS_NEG, function(interval) { plot(FNX, [XRANGE[0] - 1, XRANGE[1] + 1], { stroke: ORANGE, strokeWidth: 16, opacity: 0.7 }).attr("clip-rect", scalePoint([range[0][0], 0])[0] + "," + scalePoint([range[0][0], 0])[1] + "," + scaleVector([range[0][1] - range[0][0], -range[1][0]])[0] + "," + scaleVector([range[0][1] - range[0][0], -range[1][0]])[1] ); });

The first derivative, f^\prime(x), is less than 0 wherever the function is decreasing.

The interval where f(x) is decreasing is highlighted above.

The intervals where f(x) is decreasing are highlighted above.

_.each(DDX_INTERVALS_NEG, function(interval) { plot(FNX, interval, { stroke: RED, strokeWidth: 6, opacity: 0.8 }); });

Select any part of the function that is highlighted for both conditions.

graph.slidingWindow.moveTo( (SOLUTION_INTERVAL[1] - SOLUTION_INTERVAL[0]) / 2 + SOLUTION_INTERVAL[0] - 0.5, 0);