Khan/khan-exercises

Fetching contributors…
Cannot retrieve contributors at this time
389 lines (358 sloc) 17.3 KB
 Views of a function
randRangeNonZero(-3, 3) randRangeNonZero(-3, 3) randRangeNonZero(-3, 3) randFromArray(["f", "g", "h"]) randFromArray([["t", "u"], ["v", "w"], ["x", "y"]]) rand(5) [ generatePiecemealFunction(), function(x) { return B * x + C; }, function(x) { return B / 2 * x * x + A * x + C; }, function(x) { return B * sin(C * x / Math.PI) + A; }, function(x) { return B * pow(Math.E, C * x / 3) + A; } ][N] (function() { var xs = chooseXValues(FUNC, 1); if (xs.length >= 3) { return sortNumbers(shuffle(xs, 3)); } else { xs = chooseXValues(FUNC, 2); return sortNumbers(shuffle(xs, 3)); } })() _.map(X_EXAMPLES, FUNC) _.map(Y_EXAMPLES, function(y) { return round(2 * y) / 2; })
0.5

Choose any three points on the following graph of Y = F(X), and fill the table so each column represents a point.

graphInit({ range: 10, scale: 20, tickStep: 1, labelStep: 1, unityLabels: false, labelFormat: function(s) { return "\\small{" + s + "}"; }, axisArrows: "<->", axisLabels: [X, Y] }); plot(FUNC, [-10, 10], { stroke: BLUE });
X
F(X)
(function(){ var guess = []; var rows = $(".ttable tr"); for (var i = 1; i < 4; i++) { var x =$(rows[0].children[i]).find("input").val(); var y = $(rows[1].children[i]).find("input").val(); guess.push([x, y]); } return guess; })() var attempted = 0; var correct = 0; var xs = []; var i = 0; var validatePoint = Khan.answerTypes.predicate.createValidatorFunctional(function(x, maxError) { var validateY = Khan.answerTypes.predicate.createValidatorFunctional(function(y, maxError) { if (abs(FUNC(x) - y) < maxError) { correct += 1; xs.push(x); return true; } }, {forms: 'decimal', inexact: true, maxError: maxError}); var result = validateY(guess[i][1]); return result.correct; }, {forms: 'decimal', inexact: true, maxError: CORRECTOFFSET}); for (i = 0; i < 3; ++i) { if ($.trim(guess[i][0]) !== "" && \$.trim(guess[i][1]) !== "") { attempted += 1; validatePoint(guess[i][0]); } } if (attempted === 0) { return ""; } if (attempted < 3) { return i18n._("You must enter three points"); } xs = KhanUtil.sortNumbers(xs); var different = 1; for (var i = 0; i < correct - 1; ++i) { if (xs[i + 1] - xs[i] >= 0.5) { different += 1; } } return different === attempted;

We can start by choosing three input values. For example, let's use the input values X_EXAMPLES[0], X_EXAMPLES[1], and X_EXAMPLES[2].

Now we can find the corresponding output values to the input values we chose, using the graph: The coordinates of every point on the graph of Y = f(X) can be written as (X, Y), where the X-coordinate represents the input value and the Y-coordinate represents the corresponding output value.

As we can see on the graph, the point with an \blue{x}-coordinate of \blue{X_EXAMPLES[0]} has a \pink{y}-coordinate of \pink{Y_EXAMPLES_R[0]}. In other words, F(\blue{X_EXAMPLES[0]}) = \pink{Y_EXAMPLES_R[0]}.

line([X_EXAMPLES[0], -11], [X_EXAMPLES[0], 11], { strokeWidth: 1, stroke: PINK }); circle([X_EXAMPLES[0], Y_EXAMPLES[0]], 0.2, { stroke: PINK, fill: PINK });

To record this in our table, we put \blue{X_EXAMPLES[0]} in the x-row and \pink{Y_EXAMPLES_R[0]} in the F(X)-row below it.

We can do the same for the other two input values we chose.

\quad \begin{align} F(\blue{X_EXAMPLES[1]}) &= \pink{Y_EXAMPLES_R[1]} \\ F(\blue{X_EXAMPLES[2]}) &= \pink{Y_EXAMPLES_R[2]} \end{align}

line([X_EXAMPLES[1], -11], [X_EXAMPLES[1], 11], { strokeWidth: 1, stroke: PINK }); circle([X_EXAMPLES[1], Y_EXAMPLES[1]], 0.2, { stroke: PINK, fill: PINK }); line([X_EXAMPLES[2], -11], [X_EXAMPLES[2], 11], { strokeWidth: 1, stroke: PINK }); circle([X_EXAMPLES[2], Y_EXAMPLES[2]], 0.2, { stroke: PINK, fill: PINK });

This is a possible complete table:

X X_EXAMPLES[0] X_EXAMPLES[1] X_EXAMPLES[2]
F(X) Y_EXAMPLES_R[0] Y_EXAMPLES_R[1] Y_EXAMPLES_R[2]

Note: There can be other correct tables that contain different points.

rand(3) [ function(x) { return B * x + C; }, function(x) { return A * x + A * B + C; }, function(x) { return abs(B) * x * x + C; } ][N] [ coefficient(B) + X + " + " + C, coefficient(A) + "(" + X + " + " + B + ") + " + C, coefficient(abs(B)) + X + "^2 + " + C ][N] (function() { var xs = chooseXValues(FUNC, 1); if (xs.length >= 3) { return sortNumbers(shuffle(xs, 3)); } else { xs = chooseXValues(FUNC, 2); return sortNumbers(shuffle(xs, 3)); } })() [ coefficient(B) + "\\blue{" + X_EXAMPLES[0] + "} + " + C, coefficient(A) + "(\\blue{" + X_EXAMPLES[0] + "}" + B + ") + " + C, coefficient(abs(B)) + "\\blue{" + X_EXAMPLES[0] + "}^2 + " + C ][N] _.map(X_EXAMPLES, FUNC) _.map(Y_EXAMPLES, function(y) { return "" + round(10 * y) / 10; }) 0.1

Pick any three pairs of corresponding input and output values of the following function, and fill the table accordingly.

F(X) = FUNCSHOW

We can start by choosing three input values. For example, let's use the input values X_EXAMPLES[0], X_EXAMPLES[1], and X_EXAMPLES[2].

Now we can find the corresponding output values to the input values we chose, using the function's formula: For any input value a, we can find its corresponding output value by substituting X = a into the formula for F(X).

Now find the output value that corresponds to \blue{x}=\blue{X_EXAMPLES[0]}.

To record this in the table, we put \blue{X_EXAMPLES[0]} in the X-row and \pink{Y_EXAMPLES_R[0]} in the F(X)-row located directly below it.

We can do the same for the other two input values we chose.

We can do the same for the other two input values we chose.

\quad \begin{align} F(\blue{X_EXAMPLES[1]}) &= \pink{Y_EXAMPLES_R[1]} \\ F(\blue{X_EXAMPLES[2]}) &= \pink{Y_EXAMPLES_R[2]} \end{align}

This is a possible complete table:

X X_EXAMPLES[0] X_EXAMPLES[1] X_EXAMPLES[2]
F(X) Y_EXAMPLES_R[0] Y_EXAMPLES_R[1] Y_EXAMPLES_R[2]

Note: There can be other correct tables that contain different points.