SigmaField
Mathematical Foundations for Quant Finance
0 of 256 lessons

Level 0, Orientation and fluency 0.3 Algebra fluency Lesson 4 of 5

Practice setLesson 0.3.4 in Level 0, Orientation and fluency. About 15 minutes.

Practice set: algebra

Fractions, percentages and order of operations

Fractions and percentages (lesson 0.3.1)

0 of 6 correct

  1. 1.
  2. 2.
  3. 3.
  4. 4.
  5. 5.
  6. 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, e is Euler's number, sqrt(x) is a square root.
  • sin(x), cos(x) and tan(x) take radians; write pi for π and sin(x)^2 for 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.

Rearranging equations

Solving and rearranging (lesson 0.3.2)

0 of 5 correct

  1. 1.
  2. 2.
  3. 3.
  4. 4.
  5. 5.
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, e is Euler's number, sqrt(x) is a square root.
  • sin(x), cos(x) and tan(x) take radians; write pi for π and sin(x)^2 for 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.

Inequalities and absolute value

Inequalities and absolute value (lesson 0.3.3)

0 of 5 correct

  1. 1.
  2. 2.
  3. 3.
  4. 4.
  5. 5.
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, e is Euler's number, sqrt(x) is a square root.
  • sin(x), cos(x) and tan(x) take radians; write pi for π and sin(x)^2 for 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

Exercise

Solve any linear equation

Write solve_linear(a, b, c, d) that returns the xx solving ax+b=cx+dax + b = cx + d.

  • Gather and factor as in lesson 0.3.2: x(a−c)=d−bx(a - c) = d - b.
  • When a == c there is no single answer. Raise ValueError.

The tests include answers that are fractions and negative numbers, and they check each answer by putting it back into the equation.

See the tests
def _raises_value_error(*args):
    try:
        solve_linear(*args)
    except ValueError:
        return True
    return False


def test_x_on_one_side():
    """3x + 5 = 20 gives x = 5"""
    expect_close(solve_linear(3, 5, 0, 20), 5.0, what="solve_linear(3, 5, 0, 20)")


def test_x_on_both_sides():
    """5x − 3 = 2x + 9 gives x = 4"""
    expect_close(solve_linear(5, -3, 2, 9), 4.0, what="solve_linear(5, -3, 2, 9)")


def test_negative_answer():
    """6x + 4 = 2x − 8 gives x = −3"""
    expect_close(solve_linear(6, 4, 2, -8), -3.0, what="solve_linear(6, 4, 2, -8)")


def test_fraction_answer():
    """2x + 1 = 5x gives x = 1/3"""
    expect_close(solve_linear(2, 1, 5, 0), 1 / 3, what="solve_linear(2, 1, 5, 0)")


def test_answer_checks_out():
    """Putting the answer back in makes both sides equal: 0.7x + 2.5 = −1.3x + 9"""
    x = solve_linear(0.7, 2.5, -1.3, 9)
    expect_close(0.7 * x + 2.5, -1.3 * x + 9, what="left side vs right side at your x")


def test_no_single_answer():
    """2x + 1 = 2x + 5 has no single answer, so raise ValueError"""
    assert _raises_value_error(2, 1, 2, 5), "expected ValueError when a == c"

Free further reading

Optional. This lesson covers what you need; these add more examples and practice. All are free to read.