Exponent rules
Exponent rules (lesson 1.4.1)
0 of 7 correct
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
How to type answers
- Powers with
^:x^7,2^(1/3),a^-2. - Multiply with
*or by writing side by side:3x^2,2(x+1). ln(x)is the natural log,log(x, 2)is log base 2,eis Euler's number,sqrt(x)is a square root.sin(x),cos(x)andtan(x)take radians; writepifor π andsin(x)^2for sin²x.- Your first answer to each question is saved: it counts towards your score and brings the question back for review.
- Exact answers like
ln(20)/ln(3)are best. Decimals need about 4 significant figures.
Exponential functions and e
Exponentials and e (lesson 1.4.2)
0 of 6 correct
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
How to type answers
- Powers with
^:x^7,2^(1/3),a^-2. - Multiply with
*or by writing side by side:3x^2,2(x+1). ln(x)is the natural log,log(x, 2)is log base 2,eis Euler's number,sqrt(x)is a square root.sin(x),cos(x)andtan(x)take radians; writepifor π andsin(x)^2for sin²x.- Your first answer to each question is saved: it counts towards your score and brings the question back for review.
- Exact answers like
ln(20)/ln(3)are best. Decimals need about 4 significant figures.
Logarithms
Logarithms (lesson 1.4.3)
0 of 7 correct
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
How to type answers
- Powers with
^:x^7,2^(1/3),a^-2. - Multiply with
*or by writing side by side:3x^2,2(x+1). ln(x)is the natural log,log(x, 2)is log base 2,eis Euler's number,sqrt(x)is a square root.sin(x),cos(x)andtan(x)take radians; writepifor π andsin(x)^2for sin²x.- Your first answer to each question is saved: it counts towards your score and brings the question back for review.
- Exact answers like
ln(20)/ln(3)are best. Decimals need about 4 significant figures.
Solving equations
Solving for x (lesson 1.4.4)
0 of 7 correct
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
How to type answers
- Powers with
^:x^7,2^(1/3),a^-2. - Multiply with
*or by writing side by side:3x^2,2(x+1). ln(x)is the natural log,log(x, 2)is log base 2,eis Euler's number,sqrt(x)is a square root.sin(x),cos(x)andtan(x)take radians; writepifor π andsin(x)^2for sin²x.- Your first answer to each question is saved: it counts towards your score and brings the question back for review.
- Exact answers like
ln(20)/ln(3)are best. Decimals need about 4 significant figures.
Coding exercise
Solve for an unknown exponent
Write solve_exponent(a, b, c) that returns the solving .
- Isolate the power first, then use logs, as in lesson 1.4.4.
- Raise
ValueErrorwhen there is no solution: whenb <= 0, whenb == 1, whena == 0, or whenc / ais not positive.
The tests check easy cases, a decay base below 1, a negative a with a negative c, and each kind of impossible equation.
See the tests
import math
def _raises_value_error(a, b, c):
try:
solve_exponent(a, b, c)
except ValueError:
return True
return False
def test_simple_power():
"""2^x = 8 gives x = 3"""
expect_close(solve_exponent(1, 2, 8), 3.0, what="solve_exponent(1, 2, 8)")
def test_isolate_first():
"""5 · 2^x = 40 gives x = 3 (divide by 5 first)"""
expect_close(solve_exponent(5, 2, 40), 3.0, what="solve_exponent(5, 2, 40)")
def test_needs_logs():
"""100 · 1.05^x = 200 gives x = ln 2 / ln 1.05"""
expect_close(solve_exponent(100, 1.05, 200), math.log(2) / math.log(1.05), what="solve_exponent(100, 1.05, 200)")
def test_decay():
"""A base below 1 works too: 2 · 0.5^x = 0.25 gives x = 3"""
expect_close(solve_exponent(2, 0.5, 0.25), 3.0, what="solve_exponent(2, 0.5, 0.25)")
def test_answer_checks_out():
"""Putting the answer back in gives c: 3 · 7^x = 50"""
x = solve_exponent(3, 7, 50)
expect_close(3 * 7**x, 50.0, what="3 * 7**x with x = solve_exponent(3, 7, 50)")
def test_negative_a_and_c():
"""-2 · 3^x = -18 gives x = 2: only the sign of c / a matters"""
expect_close(solve_exponent(-2, 3, -18), 2.0, what="solve_exponent(-2, 3, -18)")
def test_negative_target_has_no_solution():
"""2^x = -8 has no solution, so raise ValueError"""
assert _raises_value_error(1, 2, -8), "expected ValueError for 1 · 2^x = -8"
def test_base_one_has_no_solution():
"""1^x is always 1, so 1^x = 5 raises ValueError"""
assert _raises_value_error(1, 1, 5), "expected ValueError for base 1"
def test_zero_a_has_no_solution():
"""0 · 2^x is always 0, so 0 · 2^x = 5 raises ValueError"""
try:
solve_exponent(0, 2, 5)
except ValueError:
return
except ZeroDivisionError:
raise AssertionError("got ZeroDivisionError for a = 0: check a == 0 first and raise ValueError")
raise AssertionError("expected ValueError for 0 · 2^x = 5")