# Khan/khan-exercises

Fetching contributors…
Cannot retrieve contributors at this time
72 lines (66 sloc) 4.01 KB
 Evaluating logarithms 2
randRange(2, 16) randRange(-4, 4) pow(BASE, abs(EXP)) EXP < 0 ? "\\dfrac{1}{" + ABS_NUM + "}" : "" + ABS_NUM

\large{\log_{BASE}} EXP < 0 ? "\\left(" + NUM_STR + "\\right)" : NUM_STR = \text{?}

EXP

If b^y = x, then \log_{b} x = y.

Therefore, we want to find the value y such that BASE^{y} = NUM_STR.

Any number raised to the power 1 is simply itself, so BASE^{1} = BASE and thus \log_{BASE} BASE = 1.

Any non-zero number raised to the power 0 is simply 1, so BASE^0 = 1 and thus \log_{BASE} 1 = 0.

Any number raised to the power -1 is its reciprocal, so BASE^{-1} = \dfrac{1}{BASE} and thus \log_{BASE} \left(\dfrac{1}{BASE}\right) = -1.

In this case, BASE^{EXP} = NUM_STR, so \log_{BASE} \left(NUM_STR\right) = EXP. In this case, BASE^{EXP} = NUM_STR, so \log_{BASE} NUM_STR = EXP.

randRange(2, 16) randRange(2, 5) pow(BASE, EXP)

\large{\log_{NUM}} BASE = \text{?}

1/EXP

If b^y = x, then \log_{b} x = y.

Notice that BASE is the ["square", "cube", "fourth", "fifth"][EXP - 2] root of NUM.

That is, \sqrt{NUM} = NUM^{1/EXP} = BASE.

That is, \sqrt[EXP]{NUM} = NUM^{1/EXP} = BASE.

Thus, \log_{NUM} BASE = \dfrac{1}{EXP}.