# Khan/khan-exercises

Summary:
Apologies in advance for the awful logic in convert-values... I considered doing something object-oriented but it
seems like it will be almost as ugly that way. Also there is some overlap in the problem types, but there is
actually significant difference in the hints for each, and since the hints are the meat of the exercise anyway,
it seemed ok to keep them as separate.

Reviewers: eater

Reviewed By: eater

CC: emily, eater

Differential Revision: http://phabricator.khanacademy.org/D601
1 parent c069833 commit b6b17379c1c91a9c874990f4772501f4dc3ff232 mwittels committed Aug 15, 2012
Showing with 745 additions and 0 deletions.
1. +560 −0 exercises/pythagorean_identities.html
2. +185 −0 utils/convert-values.js
560 exercises/pythagorean_identities.html
 @@ -0,0 +1,560 @@ + + + + + Pythagorean trig identities + + + +
+
+
+
+ + shuffle(["\\sin\\theta", "\\cos\\theta", + "\\tan\\theta", "\\sec\\theta", "\\csc\\theta", + "\\cot\\theta"]).slice(0,3) + + randFromArray(OPTIONS) + random() < 0.5 +
+

+

+ (\sin^2 \theta + \cos^2 \theta)(FUNC) + = \; ? +
+
+ \dfrac{FUNC} + {\sin^2 \theta + \cos^2 \theta} = \; ? +
+

+
FUNC
+ +
+
• op
• +
+
+
+ We can use the identity + \blue{\sin^2 \theta} + \orange{\cos^2 \theta} + = 1 + to simplify this expression. +
+ init({ + range: [[-1.2, 1.2], [-1.3, 1.3]], + scale: 130 + }); + with(KhanUtil.currentGraph) { + style({ + stroke: "#ddd", + strokeWidth: 1, + arrows: "->" + }); + circle([0, 0], 1); + line([-1.2, 0], [1.2, 0]); + line([0, -1.2], [0, 1.2]); + line([1.2, 0], [-1.2, 0]); + line([0, 1.2], [0, -1.2]); + style({ + strokeWidth: 2.5, + arrows: "" + }); + ang = 2*Math.PI/3; + line([0, 0], [cos(ang), sin(ang)], + {stroke: "black"}); + label([cos(ang)/2, sin(ang)/2], + "1", "above right"); + line([0, 0], [cos(ang), 0], + {stroke: ORANGE}); + label([cos(ang), sin(ang)/2], + "\\blue{\\sin\\theta}", "left"); + line([cos(ang), 0], + [cos(ang), sin(ang)], + {stroke: BLUE}); + label([cos(ang)/2, 0], + "\\orange{\\cos\\theta}", "below"); + arc([0,0], 0.2, 0, 120, + {stroke: "black", arrows: "->"}); + label([0,0.1], "\\theta", "above right"); + } +
+ We can see why this is true by using the + Pythagorean Theorem. +
+

+ So, (\sin^2 \theta + \cos^2 \theta)(FUNC) + = 1 \cdot FUNC = FUNC +

+

+ So, \dfrac{FUNC} + {\sin^2 \theta + \cos^2 \theta} = + \dfrac{FUNC}{1} = FUNC +

+
+
+
+
+ random() < 0.5 + random() < 0.5 + + SIN ? ["1 - \\sin^2\\theta", "\\cos^2\\theta"] + : ["1 - \\cos^2\\theta", "\\sin^2\\theta"] + + + trig.getOptionsResult(EQUIV, (MULT ? "*" : "/")) + + + MULT ? + trig.showSimplified(FUNC) : trig.showSimplified(FUNC, true) + +
+ +

+

+ (IDENT)(FUNC) = \; ? +
+
+ \dfrac{IDENT}{FUNC} + = \; ? +
+

+ +
ANS +
+ +
+
• op
• +
+ +
+
+ We can use the identity + \blue{\sin^2 \theta} + \orange{\cos^2 \theta} + = 1 + to simplify this expression. +
+ init({ + range: [[-1.2, 1.2], [-1.3, 1.3]], + scale: 130 + }); + with(KhanUtil.currentGraph) { + style({ + stroke: "#ddd", + strokeWidth: 1, + arrows: "->" + }); + circle([0, 0], 1); + line([-1.2, 0], [1.2, 0]); + line([0, -1.2], [0, 1.2]); + line([1.2, 0], [-1.2, 0]); + line([0, 1.2], [0, -1.2]); + style({ + strokeWidth: 2.5, + arrows: "" + }); + ang = 2*Math.PI/3; + line([0, 0], [cos(ang), sin(ang)], + {stroke: "black"}); + label([cos(ang)/2, sin(ang)/2], + "1", "above right"); + line([0, 0], [cos(ang), 0], + {stroke: ORANGE}); + label([cos(ang), sin(ang)/2], + "\\blue{\\sin\\theta}", "left"); + line([cos(ang), 0], + [cos(ang), sin(ang)], + {stroke: BLUE}); + label([cos(ang)/2, 0], + "\\orange{\\cos\\theta}", "below"); + arc([0,0], 0.2, 0, 120, + {stroke: "black", arrows: "->"}); + label([0,0.1], "\\theta", "above right"); + } +
+ We can see why this is true by using the + Pythagorean Theorem. +

+
+
+ So, IDENT = EQUIV +

+
+
+ Plugging into our expression, we get +
+

+
+
+

+
+
+
+ To make simplifying easier, let's put everything + in terms of \sin and \cos. + FUNC = FUNC_SIMP + , so we can plug that in to get +
+

\qquad + \left(EQUIV\right) + \left(FUNC_SIMP\right) +

+
+
+

+
+
+
+ This is ANS. +
+
+
+
+
+ random() < 0.5 + random() < 0.5 + + TAN ? ["1 + \\tan^2\\theta", "\\sec^2\\theta"] + : ["\\sec^2\\theta-1", "\\tan^2\\theta"] + + + trig.getOptionsResult(EQUIV, (MULT ? "*" : "/")) + + + [trig.showSimplified(FUNC, !MULT), + trig.showSimplified(EQUIV, !MULT)] + + + trig.showSimplified(ANS) + +
+ +

+

+ (IDENT)(FUNC) = \; ? +
+
+ \dfrac{IDENT}{FUNC} + = \; ? +
+

+ +
ANS +
+ +
+
• op
• +
+ +
+
+ We can derive a useful identity from + \blue{\sin^2 \theta} + \orange{\cos^2 \theta} + = 1 + to simplify this expression. +
+ init({ + range: [[-1.2, 1.2], [-1.3, 1.3]], + scale: 130 + }); + with(KhanUtil.currentGraph) { + style({ + stroke: "#ddd", + strokeWidth: 1, + arrows: "->" + }); + circle([0, 0], 1); + line([-1.2, 0], [1.2, 0]); + line([0, -1.2], [0, 1.2]); + line([1.2, 0], [-1.2, 0]); + line([0, 1.2], [0, -1.2]); + style({ + strokeWidth: 2.5, + arrows: "" + }); + ang = 2*Math.PI/3; + line([0, 0], [cos(ang), sin(ang)], + {stroke: "black"}); + label([cos(ang)/2, sin(ang)/2], + "1", "above right"); + line([0, 0], [cos(ang), 0], + {stroke: ORANGE}); + label([cos(ang), sin(ang)/2], + "\\blue{\\sin\\theta}", "left"); + line([cos(ang), 0], + [cos(ang), sin(ang)], + {stroke: BLUE}); + label([cos(ang)/2, 0], + "\\orange{\\cos\\theta}", "below"); + arc([0,0], 0.2, 0, 120, + {stroke: "black", arrows: "->"}); + label([0,0.1], "\\theta", "above right"); + } +
+ We can see why this identity is true by using the + Pythagorean Theorem. +

+
+
+ Dividing both sides by \cos^2\theta, we get +

\qquad \dfrac{\sin^2\theta}{\cos^2\theta} + + \dfrac{\cos^2\theta}{\cos^2\theta} + = \dfrac{1}{\cos^2\theta}

+
+ \qquad 1 + \tan^2\theta = \sec^2\theta +
+

+
+
+ Plugging into our expression, we get +
+

\qquad + \left(EQUIV\right) + \left(FUNC\right) +

+
+
+

\qquad + \dfrac{EQUIV} + {FUNC} +

+
+
+
+ To make simplifying easier, let's put everything + in terms of \sin and \cos. + We know EQUIV + = EQUIV_SIMP + and FUNC = FUNC_SIMP + , so we can substitute to get +
+

\qquad + \left(EQUIV\right) + \left(FUNC_SIMP\right) +

+

\qquad + \left(EQUIV_SIMP\right) + \left(FUNC_SIMP\right) +

+
+
+

+

+
+
+
+ To make simplifying easier, let's put everything + in terms of \sin and \cos. + We know EQUIV + = EQUIV_SIMP, so we can substitute + to get +
+

\qquad + \left(EQUIV\right) + \left(FUNC_SIMP\right) +

+

\qquad + \left(EQUIV_SIMP\right) + \left(FUNC_SIMP\right) +

+
+
+

\qquad + \dfrac{EQUIV} + {FUNC_SIMP} +

+

\qquad + \dfrac{EQUIV_SIMP} + {FUNC_SIMP} +

+
+
+
+ This is ANS_SIMP = ANS. +
+
+ This is ANS. +
+
+
+
+
+ random() < 0.5 + random() < 0.5 + + COT ? ["1 + \\cot^2\\theta", "\\csc^2\\theta"] + : ["\\csc^2\\theta-1", "\\cot^2\\theta"] + + + trig.getOptionsResult(EQUIV, (MULT ? "*" : "/")) + + + [trig.showSimplified(FUNC, !MULT), + trig.showSimplified(EQUIV, !MULT)] + + + trig.showSimplified(ANS) + +
+ +

+

+ (IDENT)(FUNC) = \; ? +
+
+ \dfrac{IDENT}{FUNC} + = \; ? +
+

+ +
ANS +
+ +
+
• op
• +
+ +
+
+ We can derive a useful identity from + \blue{\sin^2 \theta} + \orange{\cos^2 \theta} + = 1 + to simplify this expression. +
+ init({ + range: [[-1.2, 1.2], [-1.3, 1.3]], + scale: 130 + }); + with(KhanUtil.currentGraph) { + style({ + stroke: "#ddd", + strokeWidth: 1, + arrows: "->" + }); + circle([0, 0], 1); + line([-1.2, 0], [1.2, 0]); + line([0, -1.2], [0, 1.2]); + line([1.2, 0], [-1.2, 0]); + line([0, 1.2], [0, -1.2]); + style({ + strokeWidth: 2.5, + arrows: "" + }); + ang = 2*Math.PI/3; + line([0, 0], [cos(ang), sin(ang)], + {stroke: "black"}); + label([cos(ang)/2, sin(ang)/2], + "1", "above right"); + line([0, 0], [cos(ang), 0], + {stroke: ORANGE}); + label([cos(ang), sin(ang)/2], + "\\blue{\\sin\\theta}", "left"); + line([cos(ang), 0], + [cos(ang), sin(ang)], + {stroke: BLUE}); + label([cos(ang)/2, 0], + "\\orange{\\cos\\theta}", "below"); + arc([0,0], 0.2, 0, 120, + {stroke: "black", arrows: "->"}); + label([0,0.1], "\\theta", "above right"); + } +
+ We can see why this identity is true by using the + Pythagorean Theorem. +

+
+
+ Dividing both sides by \sin^2\theta, we get +

\qquad \dfrac{\sin^2\theta}{\sin^2\theta} + + \dfrac{\cos^2\theta}{\sin^2\theta} + = \dfrac{1}{\sin^2\theta}

+
+ \qquad 1 + \cot^2\theta = \csc^2\theta +
+

+
+
+ Plugging into our expression, we get +
+

\qquad + \left(EQUIV\right) + \left(FUNC\right) +

+
+
+

\qquad + \dfrac{EQUIV} + {FUNC} +

+
+
+
+ To make simplifying easier, let's put everything + in terms of \sin and \cos. + We know EQUIV + = EQUIV_SIMP + and FUNC = FUNC_SIMP + , so we can substitute to get +
+

\qquad + \left(EQUIV\right) + \left(FUNC_SIMP\right) +

+

\qquad + \left(EQUIV_SIMP\right) + \left(FUNC_SIMP\right) +

+
+
+

+

+
+
+
+ To make simplifying easier, let's put everything + in terms of \sin and \cos. + We know EQUIV + = EQUIV_SIMP, so we can substitute + to get +
+

\qquad + \left(EQUIV\right) + \left(FUNC_SIMP\right) +

+

\qquad + \left(EQUIV_SIMP\right) + \left(FUNC_SIMP\right) +

+
+
+

\qquad + \dfrac{EQUIV} + {FUNC_SIMP} +

+

\qquad + \dfrac{EQUIV_SIMP} + {FUNC_SIMP} +

+
+
+
+ This is ANS_SIMP = ANS. +
+
+ This is ANS. +
+
+
+
+
+ +
185 utils/convert-values.js
 @@ -216,3 +216,188 @@ $.extend(KhanUtil, { return toReturn; } }); + +// I would love to hear a better way of doing this than this mess +$.extend(KhanUtil, { + trig: { + // given the simplification of a trig identity and an operation, + // finds a pair (function, result) such that that simplification + // operation'd with function equals result, and result is not a + // horrible mess of trig functions with sin^4 everywhere and all that + getOptionsResult: function(firstPart, operation) { + var options; + var func; + if(firstPart === "\\cos^2\\theta") { + options = ["1", "\\cot^2\\theta", + "\\cos^2\\theta \\cdot \\sin^2\\theta"]; + } + else if(firstPart === "\\sin^2\\theta") { + options = ["1", "\\tan^2\\theta", + "\\cos^2\\theta \\cdot \\sin^2\\theta"]; + } + else if(firstPart === "\\tan^2\\theta") { + options = ["1", "\\sin^2\\theta", + "\\sec^2\\theta"]; + } + else if(firstPart === "\\sec^2\\theta") { + options = ["1", "\\tan^2\\theta", "\\csc^2\\theta"]; + } + else if(firstPart === "\\cot^2\\theta") { + options = ["1", "\\cos^2\\theta", "\\csc^2\\theta"]; + } + else if(firstPart === "\\csc^2\\theta") { + options = ["1", "\\cot^2\\theta", "\\sec^2\\theta"]; + } + + var result = KhanUtil.randFromArray(options); + if(operation === "*") { + if(result === "1") { + if(firstPart === "\\cos^2\\theta") { + func = "\\sec^2\\theta"; + } + else if(firstPart === "\\sin^2\\theta") { + func = "\\csc^2\\theta"; + } + else if(firstPart === "\\tan^2\\theta") { + func = "\\cot^2\\theta"; + } + else if(firstPart === "\\sec^2\\theta") { + func = "\\cos^2\\theta"; + } + else if(firstPart === "\\cot^2\\theta") { + func = "\\tan^2\\theta"; + } + else if(firstPart === "\\csc^2\\theta") { + func = "\\sin^2\\theta"; + } + } + else if(result === "\\tan^2\\theta") { + if(firstPart === "\\sin^2\\theta") { + func = "\\sec^2\\theta"; + } + else if(firstPart === "\\sec^2\\theta") { + func = "\\sin^2\\theta"; + } + } + else if(result === "\\cot^2\\theta") { + if(firstPart === "\\cos^2\\theta") { + func = "\\csc^2\\theta"; + } + else if(firstPart === "\\csc^2\\theta") { + func = "\\cos^2\\theta"; + } + } + else if(result === "\\cos^2\\theta \\cdot \\sin^2\\theta") { + if(firstPart === "\\cos^2\\theta") { + func = "\\sin^2\\theta"; + } + else if(firstPart === "\\sin^2\\theta") { + func = "\\cos^2\\theta"; + } + } + else if(result === "\\sin^2\\theta") { + if(firstPart === "\\tan^2\\theta") { + func = "\\cos^2\\theta"; + } + } + else if(result === "\\cos^2\\theta") { + if(firstPart === "\\cot^2\\theta") { + func = "\\sin^2\\theta"; + } + } + else if(result === "\\sec^2\\theta") { + if(firstPart === "\\tan^2\\theta") { + func = "\\csc^2\\theta"; + } + else if(firstPart === "\\csc^2\\theta") { + func = "\\tan^2\\theta"; + } + } + else if(result === "\\csc^2\\theta") { + if(firstPart === "\\sec^2\\theta") { + func = "\\cot^2\\theta"; + } + else if(firstPart === "\\cot^2\\theta") { + func = "\\sec^2\\theta"; + } + } + } + + else if(operation === "/") { + if(result === "1") { + func = firstPart; + } + else if(result === "\\tan^2\\theta") { + if(firstPart === "\\sin^2\\theta") { + func = "\\cos^2\\theta"; + } + else if(firstPart === "\\sec^2\\theta") { + func = "\\csc^2\\theta"; + } + } + else if(result === "\\cot^2\\theta") { + if(firstPart === "\\cos^2\\theta") { + func = "\\sin^2\\theta"; + } + else if(firstPart === "\\csc^2\\theta") { + func = "\\sec^2\\theta"; + } + } + else if (result === "\\cos^2\\theta \\cdot \\sin^2\\theta") { + if(firstPart === "\\cos^2\\theta") { + func = "\\csc^2\\theta"; + } + else if(firstPart === "\\sin^2\\theta") { + func = "\\sec^2\\theta"; + } + } + else if (result === "\\sin^2\\theta") { + if(firstPart === "\\tan^2\\theta") { + func = "\\sec^2\\theta"; + } + } + else if(result === "\\cos^2\\theta") { + if(firstPart === "\\cot^2\\theta") { + func = "\\csc^2\\theta"; + } + } + else if (result === "\\sec^2\\theta") { + if(firstPart === "\\tan^2\\theta") { + func = "\\sin^2\\theta"; + } + else if(firstPart === "\\csc^2\\theta") { + func = "\\cot^2\\theta"; + } + } + else if (result === "\\csc^2\\theta") { + if(firstPart === "\\sec^2\\theta") { + func = "\\tan^2\\theta"; + } + else if(firstPart === "\\cot^2\\theta") { + func = "\\cos^2\\theta"; + } + } + } + return [options, func, result]; + }, + + // expresses the given trig^2 function in terms of sin and cosine + showSimplified: function(func, small) { + d = small ? "\\frac" : "\\dfrac"; + switch(func) { + case "\\sin^2\\theta" : + return func; + case "\\cos^2\\theta" : + return func; + case "\\csc^2\\theta" : + return d+"{1}{\\sin^2\\theta}"; + case "\\sec^2\\theta" : + return d+"{1}{\\cos^2\\theta}"; + case "\\tan^2\\theta" : + return d+"{\\sin^2\\theta}{\\cos^2\\theta}"; + case "\\cot^2\\theta" : + return d+"{\\cos^2\\theta}{\\sin^2\\theta}"; + } + } + } +});