Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add exercise: Logarithms 1.5

Summary:
Inspired by the comment:

> The exercises should include negative and fractional logarithms as well, e.g. log(8,2) = 1/3 and log(4,1/64) = -3.

Test Plan: ... looked at hints for all the different cases? Not sure what one writes in a test plan for new exercises.

Reviewers: eater

Reviewed By: eater

Differential Revision: http://phabricator.khanacademy.org/D979
  • Loading branch information...
commit b2c978b00dd1312ecf60bfbcabda6b4c44a9ac49 1 parent 13f3664
@spicyj spicyj authored
Showing with 58 additions and 0 deletions.
  1. +58 −0 exercises/logarithms_1.5.html
View
58 exercises/logarithms_1.5.html
@@ -0,0 +1,58 @@
+<!DOCTYPE html>
+<html data-require="math">
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>Logarithms 1.5</title>
+ <script src="../khan-exercise.js"></script>
+</head>
+<body>
+ <div class="exercise">
+ <div class="problems">
+ <div id="integral">
+ <div class="vars" data-ensure="ABS_NUM < 1000">
+ <var id="BASE">randRange(2, 16)</var>
+ <var id="EXP">randRange(-4, 4)</var>
+ <var id="ABS_NUM">pow(BASE, abs(EXP))</var>
+ <var id="NUM_STR">
+ (EXP &lt; 0
+ ? "\\dfrac{1}{" + ABS_NUM + "}"
+ : "" + ABS_NUM)
+ </var>
+ </div>
+
+ <p class="question">What is the value of the following logarithm?</p>
+ <p><code>\log_{<var>BASE</var>} <var>EXP &lt; 0 ? "\\left(" + NUM_STR + "\\right)" : NUM_STR</var></code></p>
+ <p class="solution"><var>EXP</var></p>
+
+ <div class="hints">
+ <p>If <code>b^y = x</code>, then <code>\log_{b} x = y</code>.</p>
+ <p>Therefore, we want to find the value <code>y</code> such that <code><var>BASE</var>^{y} = <var>NUM_STR</var></code>.</p>
+ <p data-if="EXP === 1">Any number raised to the power <code>1</code> is simply itself, so <code><var>BASE</var>^{1} = <var>BASE</var></code> and thus <code>\log_{<var>BASE</var>} <var>BASE</var> = 1</code>.</p>
+ <p data-else-if="EXP === 0">Any non-zero number raised to the power <code>0</code> is simply <code>1</code>, so <code><var>BASE</var>^0 = 1</code> and thus <code>\log_{<var>BASE</var>} 1 = 0</code>.</p>
+ <p data-else-if="EXP === -1">Any number raised to the power <code>-1</code> is its reciprocal, so <code><var>BASE</var>^{-1} = \dfrac{1}{<var>BASE</var>}</code> and thus <code>\log_{<var>BASE</var>} \left(\dfrac{1}{<var>BASE</var>}\right) = -1</code>.</p>
+ <p data-else>In this case, <code><var>BASE</var>^{<var>EXP</var>} = <var>NUM_STR</var></code>, so <code>\log_{<var>BASE</var>} <var>EXP &lt; 0 ? "\\left(" + NUM_STR + "\\right)" : NUM_STR</var> = <var>EXP</var></code>.</p>
+ </div>
+ </div>
+
+ <div id="root">
+ <div class="vars" data-ensure="NUM < 1000">
+ <var id="BASE">randRange(2, 16)</var>
+ <var id="EXP">randRange(2, 5)</var>
+ <var id="NUM">pow(BASE, EXP)</var>
+ </div>
+
+ <p class="question">What is the value of the following logarithm?</p>
+ <p><code>\log_{<var>NUM</var>} <var>BASE</var></code></p>
+ <p class="solution"><var>1/EXP</var></p>
+
+ <div class="hints">
+ <p>If <code>b^y = x</code>, then <code>\log_{b} x = y</code>.</p>
+ <p>Notice that <code><var>BASE</var></code> is the <var>["square", "cube", "fourth", "fifth"][EXP - 2]</var> root of <code><var>NUM</var></code>.</p>
+ <p>That is, <code>\sqrt<var>EXP === 2 ? "" : "[" + EXP + "]"</var>{<var>NUM</var>} = <var>NUM</var>^{1/<var>EXP</var>} = <var>BASE</var></code>.</p>
+ <p>Thus, <code>\log_{<var>NUM</var>} <var>BASE</var> = \dfrac{1}{<var>EXP</var>}</code>.</p>
+ </div>
+ </div>
+ </div>
+ </div>
+</body>
+</html>
Please sign in to comment.
Something went wrong with that request. Please try again.