Skip to content
Math Foundations

math-foundations-ai999x

Arithmetic, fractions, percentages, ratios, algebraic equations and inequalities, functions, exponentials and logarithms, trigonometry, precalculus and complex numbers.

100capabilities
31topics
100formulas typeset
8worked examples below
1.0.0version
About this model

What Math Foundations does

Math Foundations (math-foundations-ai999x) is an offline Python package for math foundations. It covers arithmetic, fractions, percentages, ratios, algebraic equations and inequalities, functions, exponentials and logarithms, trigonometry, precalculus and complex numbers.

It has 100 capabilities — 100 computational procedures — in 31 topics, the largest being Trigonometry, Arithmetic, Algebra, Functions, Precalculus and Exponentials and logarithms. Ask a question in words with ask(), or call a capability by name with typed inputs with solve(). Every answer carries its value and unit, the steps that produced it and the formula in LaTeX.

When a question is not determined — a value is missing, an input is out of range, or the request is outside the package — it says so and names what it needs, instead of guessing. It runs on an ordinary CPU without a network connection (Python >=3.10), and the same question always gets the same answer.

Install

pip install math-foundations-ai999x
hf download AI999X/math-foundations-ai999x --local-dir math-foundations-ai999x

What it covers

Algebra11Absolute value inequality |ax + b| compared with c · Factor a quadratic over the integers · Partial fractions (two distinct linear factors) …Arithmetic12Arithmetic with fractions · Divide a quantity in a given ratio · Evaluate an arithmetic expression (order of operations) …Complex numbers5Arithmetic with complex numbers · Modulus, argument and polar form of a complex number · Power of a complex number (De Moivre) …Conic sections1Centre and radius of a circle from its general equationCoordinate plane1Distance between two pointsCounting and probability1Combinations and permutationsExponential functions1Compound interestExponential models1Doubling time of exponential growthExponentials and logarithms7Amount remaining after radioactive decay (half-life) · Continuous exponential growth or decay · Doubling time at a percentage growth rate …Exponents and logarithms1Solution of an exponential equationFactoring1Factoring a monic quadraticFunctions10Average rate of change of a function between two inputs · Composition of two linear functions · Distance from a point to a line …Inequalities1Solution of a linear inequalityLinear and absolute value inequalities2Solution interval of |x - c| < d · Solution set of |x - c| > dLinear equations1Root of a linear equationLinear functions4Average rate of change between two points · Line through two points · Slope of a perpendicular line …Logarithms1Solution of a basic logarithmic equationMatrices1Determinant and inverse of a 2 by 2 matrixMatrices and linear systems2Determinant of 2x2 matrix · Matrix scalar multiple definitionOther equations1Solutions of an absolute value equationPolynomial equations4Discriminant of a quadratic · Roots of a cubic equation · Roots of a quadratic equation …Polynomials1Product of two binomialsPrecalculus8Coefficient of a term in a binomial expansion · Dot product and angle between two vectors · Foci, axes and eccentricity of an ellipse …Quadratic functions1Vertex form of a quadratic functionRational expressions2Add rational expressions with same denominator · Multiply rational expressionsRational functions1Asymptotes of a linear rational functionReal numbers and algebraic expressions1Perimeter of a rectangleSequences2Term and partial sum of a geometric sequence · Term and partial sum of an arithmetic sequenceSystems of equations1Solution of two linear equations in two unknownsThe coordinate plane and graphs1Midpoint of a line segmentTrigonometry13Area of a triangle from its three sides (Heron) · Degrees to radians · Exact trigonometric values on the unit circle …
Try it

Worked examples

Each question below was put to math-foundations-ai999x and the answer shown is the one it returned, with the steps it took.

Polynomial equationsm.ask(…)

Solve x^2 - 5x + 6 = 0.

x1 = 2
x2 = 3
discriminant = 1
Show the steps
  1. Roots of a quadratic equation
    x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}
    with a = 1, b = -5, c = 6
    → x1 = 2, x2 = 3, discriminant = 1
Trigonometrym.ask(…)

In triangle ABC, a = 8, b = 10 and A = 40 degrees. Solve the triangle.

count = 2
B1 = 53.46414901
C1 = 86.53585099
c1 = 12.42304969
B2 = 126.535851
C2 = 13.46414901
Show the steps
  1. Law of sines, the ambiguous case (two sides and a non-included angle)
    \sin B = \frac{b\sin A}{a},\quad B_2 = 180^\circ - B_1
    with a = 8, b = 10, A = 40
    → count = 2, B1 = 53.46414901, C1 = 86.53585099, c1 = 12.42304969, B2 = 126.535851, C2 = 13.46414901, c2 = 2.897839169
Complex numbersm.ask(…)

Compute (3 + 2i) / (1 - i).

re = 0.5
im = 2.5
Show the steps
  1. Arithmetic with complex numbers
    \frac{a+bi}{c+di} = \frac{(ac+bd) + (bc-ad)i}{c^2+d^2}
    with a = 3, b = 2, c = 1, d = -1, op = /
    → re = 0.5, im = 2.5
Precalculusm.ask(…)

Find the coefficient of x^3 in (2x - 1)^5.

coefficient = 80
binomial = 10
Show the steps
  1. Coefficient of a term in a binomial expansion
    (ax + b)^n = \sum_{k=0}^{n} \binom{n}{k} a^k b^{n-k} x^k
    with a = 2, b = -1, n = 5, k = 3
    → coefficient = 80, binomial = 10
Complex numbersm.solve(…)
m.solve("de_moivre_power", a=1, b=1, n=8)
re = 16
im = 0
modulus = 16
argument_deg = 0
Show the steps
  1. Power of a complex number (De Moivre)
    \left[r(\cos\theta + i\sin\theta)\right]^n = r^n(\cos n\theta + i\sin n\theta)
    with a = 1, b = 1, n = 8
    → re = 16, im = 0, modulus = 16, argument_deg = 0
Algebram.ask(…)

Solve |2x + 3| < 7.

lower = -5
upper = 2
region = between
solution = -5 < x < 2
Show the steps
  1. Absolute value inequality |ax + b| compared with c
    |ax+b| < c \iff -c < ax+b < c,\qquad |ax+b| > c \iff ax+b < -c \ \text{or}\ ax+b > c
    with a = 2, b = 3, c = 7, rel = <
    → lower = -5, upper = 2, region = between, solution = -5 < x < 2
Arithmeticm.ask(…)

Compute 3/4 + 5/6 as a fraction in lowest terms.

numerator = 19
denominator = 12
value = 1.583333333
Show the steps
  1. Arithmetic with fractions
    \frac{a}{b} \pm \frac{c}{d} = \frac{ad \pm cb}{bd},\quad \frac{a}{b}\cdot\frac{c}{d} = \frac{ac}{bd},\quad \frac{a}{b} \div \frac{c}{d} = \frac{ad}{bc}
    with a = 3, b = 4, c = 5, d = 6, op = +
    → numerator = 19, denominator = 12, value = 1.583333333
Conic sectionsm.ask(…)

Find the centre and radius of x^2 + y^2 - 4x + 6y - 3 = 0.

h = 2
k = -3
rad = 4
Show the steps
  1. Centre and radius of a circle from its general equation
    \left(t - h\right)^{2} + \left(w - k\right)^{2} - \text{rad}^{2} = t^{2} + w^{2} + d_{d} t + e_{e} w + f_{f}
    with dd = -4, ee = 6, ff = -3
    → h = 2, k = -3, rad = 4
Use it

From Python or the command line

Every snippet was run as shown; the output under it is what it printed.

import math_foundations_ai999x as m

a = m.ask("Solve x^2 - 5x + 6 = 0.")
print(a.outcome)
print(a.values)
for step in a.steps:
    print(step["name"])
Output
SOLVED
{'x1': 2.0, 'x2': 3.0, 'discriminant': 1.0}
Roots of a quadratic equation
Figures

Computed, not drawn by hand

Every value in these figures was computed by the package, each point a run of solve(); in a notebook, plot() and plot_relation() draw a capability's curves the same way.

The five fifth roots of 8i

w_k = \sqrt[n]{r}\left(\cos\frac{\theta + 2\pi k}{n} + i\sin\frac{\theta + 2\pi k}{n}\right)
The five fifth roots of 8iThe 5 complex roots of z⁵ = 0 + 8i returned by the package — -0.890916 − 1.22624i, 0.890916 − 1.22624i, 1.44153 + 0.468382i, 0 + 1.51572i, -1.44153 + 0.468382i — the vertices of a regular pentagon on the circle of radius 1.51572 (= 8^(1/5)).-202-101|z| = 1.51572the 5 rootsRe zIm z
The 5 complex roots of z⁵ = 0 + 8i returned by the package — -0.890916 − 1.22624i, 0.890916 − 1.22624i, 1.44153 + 0.468382i, 0 + 1.51572i, -1.44153 + 0.468382i — the vertices of a regular pentagon on the circle of radius 1.51572 (= 8^(1/5)).

Ellipse and hyperbola with their foci

\frac{(x-h)^2}{A} + \frac{(y-k)^2}{B} = 1,\quad c^2 = a^2 - b^2,\quad e = \frac{c}{a}
Ellipse and hyperbola with their fociAn ellipse and a hyperbola drawn from the parameters the package returns: ellipse a = 5, b = 3, foci (±4, 0), eccentricity 0.8; hyperbola a = 4, b = 3, foci (±5, 0), eccentricity 1.25, asymptotes of slope ±0.75.-505-5-2.502.55ellipse x²/25 + y²/9 = 1, e = 0.8hyperbola x²/16 − y²/9 = 1, e = 1.25asymptotes y = ±0.75xxy
An ellipse and a hyperbola drawn from the parameters the package returns: ellipse a = 5, b = 3, foci (±4, 0), eccentricity 0.8; hyperbola a = 4, b = 3, foci (±5, 0), eccentricity 1.25, asymptotes of slope ±0.75.

A cubic and its three roots

a x^3 + b x^2 + c x + d = 0
A cubic and its three rootsThe cubic y = x³ − 6x² + 11x − 6, evaluated by the package at 81 points, and its three real roots as the package returns them: x = 1, 2 and 3.123-202123y = x³ - 6x² + 11x - 6rootsxy
The cubic y = x³ − 6x² + 11x − 6, evaluated by the package at 81 points, and its three real roots as the package returns them: x = 1, 2 and 3.

Powers of 1 + i spiral outwards (de Moivre)

\left[r(\cos\theta + i\sin\theta)\right]^n = r^n(\cos n\theta + i\sin n\theta)
Powers of 1 + i spiral outwards (de Moivre)The powers (1 + i)ⁿ for n = 0 … 8, each computed by the package: every step turns by 45° and stretches by √2; marked: n = 8, (1 + i)⁸ = 16 + 0i, modulus 16, argument 0°.010-10-505n=0n=1n=2n=3n=4n=5n=6n=7n=816 + 0i(1 + i)ⁿ, n = 0 … 8Re zIm z
The powers (1 + i)ⁿ for n = 0 … 8, each computed by the package: every step turns by 45° and stretches by √2; marked: n = 8, (1 + i)⁸ = 16 + 0i, modulus 16, argument 0°.

The unit circle with exact values

\sin 30^\circ = \tfrac12,\ \sin 45^\circ = \tfrac{\sqrt2}{2},\ \sin 60^\circ = \tfrac{\sqrt3}{2}
The unit circle with exact valuesThe unit circle with the exact cosine and sine the package returns at the multiples of 30° and 45° (16 angles; six labelled); for example cos 150° = -√3/2 = -0.866025 and sin 150° = 1/2 = 0.5 (marked).30°: (√3/2, 1/2)45°: (√2/2, √2/2)60°: (1/2, √3/2)120°: (-1/2, √3/2)210°: (-√3/2, -1/2)300°: (1/2, -√3/2)(cos θ, sin θ) at multiples of 30° and 45°
The unit circle with the exact cosine and sine the package returns at the multiples of 30° and 45° (16 angles; six labelled); for example cos 150° = -√3/2 = -0.866025 and sin 150° = 1/2 = 0.5 (marked).

An alternating geometric sequence and its partial sums

g_{n} = g_{1} q^{n - 1},\quad s_{n} \left(1 - q\right) = g_{1} \left(1 - q^{n}\right)
An alternating geometric sequence and its partial sumsThe geometric sequence g₁ = 3, q = -0.5: the alternating terms (stems) and the partial sums (dots), each computed by the package, settle on the sum of the infinite series, 2; g₁₂ = -0.00146484, s₁₂ = 1.99951.2.557.51012.502limit 2term gₙpartial sum sₙnvalue
The geometric sequence g₁ = 3, q = -0.5: the alternating terms (stems) and the partial sums (dots), each computed by the package, settle on the sum of the infinite series, 2; g₁₂ = -0.00146484, s₁₂ = 1.99951.
Formulas

The mathematics inside

12 of its 100 formulas; every one is in the capability browser below.

Roots of a quadratic equation
x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}
Law of sines, the ambiguous case (two sides and a non-included angle)
\sin B = \frac{b\sin A}{a},\quad B_2 = 180^\circ - B_1
Arithmetic with complex numbers
\frac{a+bi}{c+di} = \frac{(ac+bd) + (bc-ad)i}{c^2+d^2}
Coefficient of a term in a binomial expansion
(ax + b)^n = \sum_{k=0}^{n} \binom{n}{k} a^k b^{n-k} x^k
Power of a complex number (De Moivre)
\left[r(\cos\theta + i\sin\theta)\right]^n = r^n(\cos n\theta + i\sin n\theta)
Absolute value inequality |ax + b| compared with c
|ax+b| < c \iff -c < ax+b < c,\qquad |ax+b| > c \iff ax+b < -c \ \text{or}\ ax+b > c
Arithmetic with fractions
\frac{a}{b} \pm \frac{c}{d} = \frac{ad \pm cb}{bd},\quad \frac{a}{b}\cdot\frac{c}{d} = \frac{ac}{bd},\quad \frac{a}{b} \div \frac{c}{d} = \frac{ad}{bc}
Centre and radius of a circle from its general equation
\left(t - h\right)^{2} + \left(w - k\right)^{2} - \text{rad}^{2} = t^{2} + w^{2} + d_{d} t + e_{e} w + f_{f}
Factor a quadratic over the integers
ax^2+bx+c = g\,(px+q)(rx+s)
Divide a quantity in a given ratio
\mathrm{part}_i = \mathrm{total}\cdot\frac{r_i}{\sum_j r_j}
Modulus, argument and polar form of a complex number
z = r(\cos\theta + i\sin\theta),\quad r = \sqrt{a^2+b^2}
Distance between two points
\text{dist}^{2} = \left(x_{2} - x_{1}\right)^{2} + \left(y_{2} - y_{1}\right)^{2}
Capabilities

Every capability, with an example

Search by name, formula, input or topic. Each capability opens to show what it takes, what it returns, when it applies, and a question it answered.

100 capabilities

Algebra 11

Absolute value inequality |ax + b| compared with cabs_linear_inequality

Solve |a*x + b| < c, <= c, > c or >= c (c > 0): the two boundary points and whether x lies between or outside them.

|ax+b| < c \iff -c < ax+b < c,\qquad |ax+b| > c \iff ax+b < -c \ \text{or}\ ax+b > c

Inputs

  • a coefficient of x inside the bars
  • b constant inside the bars
  • c the bound (positive)
  • rel the comparison choice

Returns

  • lower the smaller boundary point
  • upper the larger boundary point
  • region between (for < and <=) or outside (for > and >=)
  • solution the solution set

Applies when

  • a != 0
  • c > 0

Example

m.ask("Solve |2x + 3| < 7.")
→ lower = -5, upper = 2, region = between, solution = -5 < x < 2
Factor a quadratic over the integersfactor_quadratic_integer

Factor a*x^2 + b*x + c with whole-number coefficients as g(px + q)(rx + s), or say that it does not factor over the integers.

ax^2+bx+c = g\,(px+q)(rx+s)

Inputs

  • a coefficient of x^2 (not 0) integer
  • b coefficient of x integer
  • c constant term integer

Returns

  • g common factor (sign of a)
  • p x-coefficient of the first factor
  • q constant of the first factor
  • r x-coefficient of the second factor
  • s constant of the second factor
  • factored the factored form

Applies when

  • whole-number coefficients
  • a != 0
  • the discriminant is a perfect square

Example

m.ask("Factor 6x^2 + 5x - 6 over the integers.")
→ g = 1, p = 2, q = 3, r = 3, s = -2, factored = (2x + 3)(3x - 2)
Partial fractions (two distinct linear factors)partial_fractions_linear

Write (p*x + q)/((x - r1)(x - r2)) as A/(x - r1) + B/(x - r2).

\frac{px+q}{(x-r_1)(x-r_2)} = \frac{A}{x-r_1} + \frac{B}{x-r_2},\quad A = \frac{pr_1+q}{r_1-r_2}

Inputs

  • p coefficient of x in the numerator
  • q constant of the numerator
  • r1 root of the first factor x - r1
  • r2 root of the second factor x - r2 (r2 != r1)

Returns

  • A numerator over x - r1
  • B numerator over x - r2

Applies when

  • r1 != r2

Example

m.ask("Decompose (5x + 1)/((x - 1)(x + 2)) into partial fractions.")
→ A = 2, B = 3
Polynomial long divisionpolynomial_long_division

Divide one polynomial by another: quotient and remainder, with p = q*d + r and deg r < deg d.

p(x) = q(x)\,d(x) + r(x),\quad \deg r < \deg d

Inputs

  • dividend coefficients of the dividend, highest power first vector
  • divisor coefficients of the divisor, highest power first (degree >= 1) vector

Returns

  • quotient coefficients of the quotient, highest power first
  • remainder coefficients of the remainder, highest power first

Applies when

  • divisor of degree >= 1

Example

m.ask("Divide 2x^3 + 3x^2 - x + 5 by x^2 + 1.")
→ quotient = [2.0, 3.0], remainder = [-3.0, 2.0]
Quadratic inequalityquadratic_inequality

Solve a*x^2 + b*x + c < 0 (or <=, >, >=) when the quadratic has two distinct real roots.

a(x - r_1)(x - r_2) < 0 \iff r_1 < x < r_2 \ \ (a > 0)

Inputs

  • a coefficient of x^2
  • b coefficient of x
  • c constant term
  • rel the comparison with 0 choice

Returns

  • r1 the smaller root
  • r2 the larger root
  • region between or outside the roots
  • solution the solution set

Applies when

  • a != 0
  • b^2 - 4ac > 0

Example

m.ask("Solve x^2 - 5x + 6 < 0.")
→ r1 = 2, r2 = 3, region = between, solution = 2 < x < 3
Radical equation sqrt(ax + b) = cx + dradical_equation

Solve sqrt(a*x + b) = c*x + d: square, solve, and keep only the roots that satisfy the original equation.

\sqrt{ax+b} = cx+d \;\Rightarrow\; ax+b = (cx+d)^2,\ cx+d \ge 0

Inputs

  • a coefficient of x under the root
  • b constant under the root
  • c coefficient of x on the right
  • d constant on the right

Returns

  • count number of solutions (0, 1 or 2)
  • solutions the solutions, ascending
  • extraneous roots of the squared equation that fail the original (extraneous)

Applies when

  • a != 0
  • real numbers

Example

m.ask("Solve sqrt(2x + 3) = x.")
→ count = 1, solutions = [3.0], extraneous = [-1.0]
Rational equation a/(x + b) = c/(x + d)rational_equation

Solve a/(x + b) = c/(x + d) for x, rejecting a candidate that makes a denominator 0.

\frac{a}{x+b} = \frac{c}{x+d} \;\Rightarrow\; x = \frac{cb - ad}{a - c}

Inputs

  • a numerator on the left
  • b constant in the left denominator x + b
  • c numerator on the right
  • d constant in the right denominator x + d

Returns

  • x the solution

Applies when

  • a != c
  • the candidate is not an excluded value

Example

m.ask("Solve 3/(x + 1) = 2/(x - 4).")
→ x = 14
Rational roots of a polynomial (rational root theorem)rational_roots

Every rational root of a polynomial with whole-number coefficients (degree up to 8).

a_n x^n + \dots + a_0 = 0,\ x = \tfrac{p}{q} \Rightarrow p \mid a_0,\ q \mid a_n

Inputs

  • coefficients whole-number coefficients, highest power first vector

Returns

  • count number of distinct rational roots
  • roots the rational roots, ascending
  • roots_exact the rational roots as fractions

Applies when

  • whole-number coefficients
  • degree 1 to 8

Example

m.ask("Find all rational roots of 2x^3 - 3x^2 - 11x + 6 = 0.")
→ count = 3, roots = [-2.0, 0.5, 3.0], roots_exact = ['-2', '1/2', '3']
Sum of an infinite geometric seriesinfinite_geometric_series

a + a*r + a*r^2 + ... = a/(1 - r) for |r| < 1 (a refusal when the series diverges).

\sum_{k=0}^{\infty} a r^k = \frac{a}{1-r},\quad |r| < 1

Inputs

  • a the first term
  • r the common ratio, |r| < 1

Returns

  • sum the sum to infinity

Applies when

  • |r| < 1

Example

m.ask("Find the sum of the infinite geometric series with first term 6 and ratio 1/3.")
→ sum = 9
Synthetic division and the remainder theoremsynthetic_division

Divide a polynomial by x - r: the quotient's coefficients and the remainder, which equals p(r).

p(x) = (x - r)\,q(x) + p(r)

Inputs

  • coefficients coefficients of the dividend, highest power first (2x^3 - 5x + 1 -> 2, 0, -5, 1) vector
  • r the number r of the divisor x - r

Returns

  • quotient coefficients of the quotient, highest power first
  • remainder the remainder = p(r)

Applies when

  • dividend of degree >= 1

Example

m.ask("Divide x^3 - 6x^2 + 11x - 6 by x - 1.")
→ quotient = [1.0, -5.0, 6.0], remainder = 0
System of three linear equationslinear_system_3x3

Solve three linear equations in x, y and z (a unique solution, or a refusal when there is none).

A\,\mathbf{x} = \mathbf{d},\quad \mathbf{x} = A^{-1}\mathbf{d}

Inputs

  • augmented augmented matrix, one row a b c d per equation a*x + b*y + c*z = d matrix

Returns

  • x x
  • y y
  • z z

Applies when

  • determinant of the coefficients != 0 (a unique solution)

Example

m.ask("Solve the system x + y + z = 6, 2x - y + z = 3, x + 2y - z = 2.")
→ x = 1, y = 2, z = 3

Arithmetic 12

Arithmetic with fractionsfraction_arithmetic

Add, subtract, multiply or divide two fractions a/b and c/d; the result in lowest terms.

\frac{a}{b} \pm \frac{c}{d} = \frac{ad \pm cb}{bd},\quad \frac{a}{b}\cdot\frac{c}{d} = \frac{ac}{bd},\quad \frac{a}{b} \div \frac{c}{d} = \frac{ad}{bc}

Inputs

  • a numerator of the first fraction integer
  • b denominator of the first fraction (not 0) integer
  • c numerator of the second fraction integer
  • d denominator of the second fraction (not 0) integer
  • op the operation choice

Returns

  • numerator numerator of the result in lowest terms
  • denominator denominator of the result (positive)
  • value the result as a decimal

Applies when

  • whole-number numerators and denominators
  • denominators not 0
  • no division by 0

Example

m.ask("Compute 3/4 + 5/6 as a fraction in lowest terms.")
→ numerator = 19, denominator = 12, value = 1.58333
Divide a quantity in a given ratioratio_split

Share a total in the ratio a:b (or a:b:c).

\mathrm{part}_i = \mathrm{total}\cdot\frac{r_i}{\sum_j r_j}

Inputs

  • total the quantity to share
  • a first term of the ratio (positive)
  • b second term of the ratio (positive)
  • c third term of the ratio (optional, positive) optional

Returns

  • part1 first share
  • part2 second share
  • part3 third share (a three-term ratio only)

Applies when

  • every term of the ratio positive

Example

m.ask("Divide 120 in the ratio 3:5.")
→ part1 = 45, part2 = 75
Evaluate an arithmetic expression (order of operations)order_of_operations

The exact value of an arithmetic expression with + - * / ^ and parentheses, following the order of operations.

\text{( )} \;\to\; a^{b} \;\to\; \times\,\div \;\to\; +\,-

Inputs

  • expression the expression, e.g. 3 + 4 * (2 - 5)^2 / 6 text

Returns

  • value the value
  • numerator numerator of the exact value in lowest terms
  • denominator denominator of the exact value

Applies when

  • numbers, + - * / ^ and parentheses only
  • no division by 0
  • integer exponents up to 64

Example

m.ask("Evaluate 3 + 4 * (2 - 5)^2 / 6.")
→ value = 9, numerator = 9, denominator = 1
Percent change (increase or decrease)percent_change

The percent change from an original value to a new value (negative for a decrease).

\Delta\% = \frac{\mathrm{new}-\mathrm{old}}{\mathrm{old}}\cdot 100

Inputs

  • old the original value (positive)
  • new the new value

Returns

  • percent_change percent change (negative = decrease)
  • difference new - old
  • direction increase, decrease or no change

Applies when

  • old > 0

Example

m.ask("Find the percent change from 80 to 100.")
→ percent_change = 25, difference = 20, direction = increase
Percent of a numberpercent_of_number

p% of x: the part that p per cent of x amounts to.

\frac{p}{100}\,x

Inputs

  • p the percentage p (per hundred)
  • x the whole x

Returns

  • result p% of x

Applies when

  • finite numbers

Example

m.ask("What is 15% of 80?")
→ result = 12
Round to decimal placesround_decimal_places

Round a number to n decimal places (or to the nearest tenth, hundredth, ten, hundred ...), halves away from zero.

\mathrm{round}(x, n) = \operatorname{sgn}(x)\,\frac{\lfloor |x|\,10^{n} + \tfrac12 \rfloor}{10^{n}}

Inputs

  • x the number to round
  • n decimal places (negative: tens, hundreds) integer

Returns

  • rounded the rounded number

Applies when

  • -9 <= n <= 12

Example

m.ask("Round 3.14159 to 2 decimal places.")
→ rounded = 3.14
Round to significant figuresround_significant_figures

Round a nonzero number to n significant figures, halves away from zero.

\mathrm{round}\big(x,\ n - 1 - \lfloor \log_{10}|x| \rfloor\big)

Inputs

  • x the number to round (not 0)
  • n number of significant figures integer

Returns

  • rounded the rounded number

Applies when

  • x != 0
  • 1 <= n <= 15

Example

m.ask("Round 0.0045678 to 3 significant figures.")
→ rounded = 0.00457
Scientific notationscientific_notation

Write a nonzero number as m × 10^e with 1 <= |m| < 10.

x = m \times 10^{e},\quad 1 \le |m| < 10

Inputs

  • x the number (not 0)

Returns

  • mantissa m, with 1 <= |m| < 10
  • exponent the integer power of ten e

Applies when

  • x != 0

Example

m.ask("Write 45600 in scientific notation.")
→ mantissa = 4.56, exponent = 4
Solve a proportionproportion_solve

Solve n1/d1 = n2/d2 for the one unknown term x (in any of the four positions).

\frac{n_1}{d_1} = \frac{n_2}{d_2} \iff n_1 d_2 = n_2 d_1

Inputs

  • p the first known term (reading n1, d1, n2, d2 in order)
  • q the second known term
  • r the third known term
  • position where the unknown x stands choice

Returns

  • x the unknown term

Applies when

  • denominators not 0
  • the proportion has a solution

Example

m.ask("Solve 3/4 = x/20.")
→ x = 15
Unit rates and the better buyunit_rate_compare

The unit rate (amount per one unit) of an offer, and of a second offer with which is cheaper per unit.

\text{unit rate} = \frac{\text{amount}}{\text{quantity}}

Inputs

  • n1 quantity of the first offer (positive)
  • c1 amount (price, distance, ...) of the first offer
  • n2 quantity of the second offer (optional) optional
  • c2 amount of the second offer (optional) optional

Returns

  • unit_rate_1 amount per unit, first offer
  • unit_rate_2 amount per unit, second offer
  • better the offer with the lower amount per unit: first, second or equal

Applies when

  • quantities positive
  • amounts not negative

Example

m.ask("Which is the better buy: 12 items for 30 or 20 items for 45?")
→ unit_rate_1 = 2.5, unit_rate_2 = 2.25, better = second
What percent one number is of anotherwhat_percent

The percentage p such that `part` is p% of `whole`.

p = 100\,\frac{\mathrm{part}}{\mathrm{whole}}

Inputs

  • part the part
  • whole the whole (not 0)

Returns

  • percent part as a percentage of whole

Applies when

  • whole != 0

Example

m.ask("What percent of 80 is 12?")
→ percent = 15
Whole from a part and its percentagepercent_of_what

The whole w of which `part` is p per cent (part is p% of what number?).

w = \frac{100\,\mathrm{part}}{p}

Inputs

  • part the known part
  • p the percentage that the part is of the whole

Returns

  • whole the whole

Applies when

  • p != 0

Example

m.ask("18 is 15% of what number?")
→ whole = 120

Complex numbers 5

Arithmetic with complex numberscomplex_arithmetic

(a + bi) + - * / (c + di) in the form re + im*i.

\frac{a+bi}{c+di} = \frac{(ac+bd) + (bc-ad)i}{c^2+d^2}

Inputs

  • a real part of the first number
  • b imaginary part of the first number
  • c real part of the second number
  • d imaginary part of the second number
  • op the operation choice

Returns

  • re real part of the result
  • im imaginary part of the result

Applies when

  • no division by 0

Example

m.ask("Compute (3 + 2i) / (1 - i).")
→ re = 0.5, im = 2.5
Modulus, argument and polar form of a complex numbercomplex_modulus_argument

|z| and the principal argument (-180, 180] degrees of z = a + bi, and z in polar form.

z = r(\cos\theta + i\sin\theta),\quad r = \sqrt{a^2+b^2}

Inputs

  • a real part
  • b imaginary part

Returns

  • modulus |z|
  • argument_deg principal argument, degrees in (-180, 180]
  • argument_rad principal argument, radians
  • polar z = r(cos t + i sin t)

Applies when

  • z != 0

Example

m.ask("Find the modulus and argument of -1 + i.")
→ modulus = 1.41421, argument_deg = 135, argument_rad = 2.35619, polar = 1.414213562(cos(135 deg) + i sin(135 deg))
Power of a complex number (De Moivre)de_moivre_power

(a + bi)^n for a whole number n (|n| <= 40): real and imaginary parts, modulus and argument.

\left[r(\cos\theta + i\sin\theta)\right]^n = r^n(\cos n\theta + i\sin n\theta)

Inputs

  • a real part
  • b imaginary part
  • n the power n integer

Returns

  • re real part of z^n
  • im imaginary part of z^n
  • modulus |z^n| = |z|^n
  • argument_deg argument of z^n, degrees

Applies when

  • |n| <= 40
  • z != 0 when n <= 0

Example

m.ask("Use De Moivre's theorem to compute (1 + i)^8.")
→ re = 16, im = 0, modulus = 16, argument_deg = 0
Product and modulus of complex numberscomplex_product_modulus

The product (a + b*i)(c + d*i) = re + im*i and the modulus of the product.

\operatorname{Re} = a c - b d,\quad \operatorname{Im} = a d + b c,\quad \text{modulus}^{2} = \left(a^{2} + b^{2}\right) \left(c^{2} + d^{2}\right)

Inputs

  • a real part of the first number
  • b imaginary part of the first number
  • c real part of the second number
  • d imaginary part of the second number

Returns

  • re real part of the product
  • im imaginary part of the product
  • modulus modulus of the product

Example

m.ask("Multiply (1 + 2i)(3 + 4i).")
→ re = -5, im = 10, modulus = 11.1803
The n-th roots of a complex numbercomplex_nth_roots

All n complex n-th roots of z = a + bi (n from 2 to 12), ordered by argument from 0 to 360 degrees.

w_k = \sqrt[n]{r}\left(\cos\frac{\theta + 2\pi k}{n} + i\sin\frac{\theta + 2\pi k}{n}\right)

Inputs

  • a real part of z
  • b imaginary part of z
  • n which roots (2 = square roots) integer

Returns

  • modulus the common modulus |z|^(1/n)
  • count the number of roots, n
  • roots the roots, by argument in [0, 360)

Applies when

  • z != 0
  • 2 <= n <= 12

Example

m.ask("Find the cube roots of 8i.")
→ modulus = 2, count = 3, roots = [(1.73205080757+1j), (-1.73205080757+1j), -2j]

Conic sections 1

Centre and radius of a circle from its general equationcircle_from_general_form

For x^2 + y^2 + D*x + E*y + F = 0, the centre (h, k) and radius rad.

\left(t - h\right)^{2} + \left(w - k\right)^{2} - \text{rad}^{2} = t^{2} + w^{2} + d_{d} t + e_{e} w + f_{f}

Inputs

  • dd coefficient D of x
  • ee coefficient E of y
  • ff constant F

Returns

  • h x-coordinate of the centre
  • k y-coordinate of the centre
  • rad radius

Applies when

  • dd**2/4 + ee**2/4 - ff > 0

Example

m.ask("Find the centre and radius of x^2 + y^2 - 4x + 6y - 3 = 0.")
→ h = 2, k = -3, rad = 4

Coordinate plane 1

Distance between two pointsdistance_between_points

The distance between (x1, y1) and (x2, y2) in the plane.

\text{dist}^{2} = \left(x_{2} - x_{1}\right)^{2} + \left(y_{2} - y_{1}\right)^{2}

Inputs

  • x1 x-coordinate of the first point
  • y1 y-coordinate of the first point
  • x2 x-coordinate of the second point
  • y2 y-coordinate of the second point

Returns

  • dist distance

Example

m.ask("Find the distance between (1, 1) and (4, 5).")
→ dist = 5

Counting and probability 1

Combinations and permutationscounting_choices

The number of ways to choose k items from n without order (combinations) and with order (permutations).

\binom{n}{k} = \frac{n!}{k!\,(n-k)!},\quad P(n,k) = \frac{n!}{(n-k)!}

Inputs

  • n number of items to choose from (a whole number)
  • k number of items chosen (a whole number, k <= n)

Returns

  • combinations C(n, k) = n! / (k! (n - k)!)
  • permutations P(n, k) = n! / (n - k)!

Applies when

  • n and k whole numbers
  • k <= n
  • n <= 170

Example

m.ask("How many ways are there to choose 3 books from 10?")
→ combinations = 120, permutations = 720

Exponential functions 1

Compound interestcompound_interest

The amount after t years when a principal is compounded n times a year at an annual rate r (a decimal).

\ln\left(\text{amount}\right) = \ln\left(\text{principal}\right) + n t \ln\left(1 + \frac{r}{n}\right)

Inputs

  • principal starting amount
  • r annual interest rate as a decimal
  • n compounding periods per year
  • t time in years

Returns

  • amount amount after t years

Applies when

  • principal > 0
  • n >= 1
  • t >= 0
  • 1 + r/n > 0

Example

m.ask("Find the amount after 2 years if 1000 is invested at rate 0.05 compounded 1 times a year.")
→ amount = 1102.5

Exponential models 1

Doubling time of exponential growthdoubling_time

The time for a quantity growing as N = N0*e^(k*t) to double, for a growth constant k > 0.

k t_{d} = \ln\left(2\right)

Inputs

  • k continuous growth constant per unit time

Returns

  • td doubling time

Applies when

  • k > 0

Example

m.ask("What is the doubling time for a growth constant of 0.1?")
→ td = 6.93147

Exponentials and logarithms 7

Amount remaining after radioactive decay (half-life)half_life_remaining

The amount left after time t of a substance with half-life T: N0 * (1/2)^(t/T).

N(t) = N_0 \left(\tfrac12\right)^{t/T}

Inputs

  • n0 initial amount (positive)
  • half_life the half-life T (positive)
  • t elapsed time, in the unit of T

Returns

  • remaining amount remaining (in the unit of N0)
  • fraction fraction remaining

Applies when

  • n0 > 0
  • T > 0
  • t >= 0
  • t and T in the same unit

Example

m.ask("An 80 g sample has a half-life of 5 years. How much remains after 15 years?")
→ remaining = 10, fraction = 0.125
Continuous exponential growth or decaycontinuous_growth

N(t) = N0 * e^(k t) for continuous growth (k > 0) or decay (k < 0), including continuous compounding.

N(t) = N_0\,e^{kt}

Inputs

  • n0 initial amount N0
  • k continuous rate per unit time, as a decimal (0.03 for 3%; negative for decay)
  • t elapsed time, in the rate's unit

Returns

  • amount N(t)

Applies when

  • |k t| <= 700

Example

m.ask("A population of 500 grows continuously at 3% per year. Find the population after 10 years.")
→ amount = 674.929
Doubling time at a percentage growth ratedoubling_time_percent

The time for a quantity growing by r% per period (compounded once per period) to double.

T = \frac{\ln 2}{\ln\left(1 + \frac{r}{100}\right)}

Inputs

  • r growth rate per period, in percent (positive)

Returns

  • doubling_time periods to double (exact)
  • rule_of_70_estimate the rule-of-70 approximation 70/r

Applies when

  • r > 0

Example

m.ask("How long does it take an investment to double at 7% interest compounded annually?")
→ doubling_time = 10.2448, rule_of_70_estimate = 10
Evaluate a logarithmlog_evaluate

log_b(x) for a positive base b != 1 and x > 0 (log is base 10, ln base e).

\log_b x = \frac{\ln x}{\ln b}

Inputs

  • b the base (positive, not 1)
  • x the number (positive)

Returns

  • value log_b(x)

Applies when

  • b > 0
  • b != 1
  • x > 0

Example

m.ask("Evaluate log base 2 of 32.")
→ value = 5
Exponential equation a*b^(cx + d) = kexponential_equation_general

Solve a * b^(c*x + d) = k for x by taking logarithms.

x = \frac{\log_b(k/a) - d}{c}

Inputs

  • a the coefficient a
  • b the base (positive, not 1; e for the natural base)
  • c coefficient of x in the exponent
  • d constant in the exponent
  • k the right-hand side

Returns

  • x the solution

Applies when

  • a != 0
  • c != 0
  • b > 0, b != 1
  • k/a > 0

Example

m.ask("Solve 3 * 2^(x + 1) = 48.")
→ x = 3
Laws of logarithms (product, quotient, power)log_laws_combine

Given log_b(M) = u and log_b(N) = v, the value of log_b(M^p * N^q) (quotients and roots included).

\log_b\!\left(M^{p} N^{q}\right) = p\log_b M + q\log_b N

Inputs

  • u log_b(M)
  • v log_b(N)
  • p power of M
  • q power of N (negative: N in the denominator)

Returns

  • value log_b(M^p N^q)

Applies when

  • M, N > 0

Example

m.ask("Given log_b(M) = 2 and log_b(N) = 3, find log_b(M^2 N).")
→ value = 7
Logarithmic equation log_b(cx + d) = klog_equation_linear_argument

Solve log_b(c*x + d) = k for x by rewriting it in exponential form.

\log_b(cx+d) = k \iff cx + d = b^{k}

Inputs

  • b the base (positive, not 1; 10 for log, e for ln)
  • c coefficient of x in the argument
  • d constant in the argument
  • k the right-hand side

Returns

  • x the solution

Applies when

  • b > 0, b != 1
  • c != 0

Example

m.ask("Solve log base 2 of (3x + 1) = 4.")
→ x = 5

Exponents and logarithms 1

Solution of an exponential equationexponential_equation

Solve b^x = y for x, with b > 0, b != 1 and y > 0.

x \ln\left(b\right) = \ln\left(y\right)

Inputs

  • b the base
  • y the value of the power

Returns

  • x the exponent

Applies when

  • b > 0
  • y > 0
  • b != 1

Example

m.ask("Solve 2^x = 32.")
→ x = 5

Factoring 1

Factoring a monic quadraticfactor_monic_quadratic

Write x^2 + b*x + c as (x + p)*(x + q) with real p and q.

\left(t + p\right) \left(t + q\right) = t^{2} + b t + c

Inputs

  • b coefficient of x
  • c constant term

Returns

  • p first constant
  • q second constant

Applies when

  • b**2 - 4*c >= 0

Example

m.ask("Factor x^2 + 5x + 6.")
→ p = 3, q = 2

Functions 10

Average rate of change of a function between two inputsaverage_rate_of_change_definition

(f(x_end) - f(x_start)) / (x_end - x_start) from two values of a function.

\text{arc} \left(x_{\text{end}} - x_{\text{start}}\right) = f_{x,end} - f_{x,start}

Inputs

  • x_start first input
  • f_x_start value of the function at the first input
  • x_end second input
  • f_x_end value of the function at the second input

Returns

  • arc average rate of change

Applies when

  • x_end != x_start

Example

m.ask("If f(0) = 1 and f(5) = 11, what is the average rate of change of f?")
→ arc = 2
Composition of two linear functionscompose_linear_functions

For f(x) = a*x + b and g(x) = c*x + d, the composition f(g(x)) = m*x + k.

m t + k = a \left(c t + d\right) + b

Inputs

  • a slope of f
  • b intercept of f
  • c slope of g
  • d intercept of g

Returns

  • m slope of f(g(x))
  • k intercept of f(g(x))

Example

m.ask("If f(x) = 2x + 1 and g(x) = 3x - 4, find f(g(x)).")
→ m = 6, k = -7
Distance from a point to a linedistance_point_to_line

The perpendicular distance from (x0, y0) to the line a*x + b*y + c = 0.

d = \frac{|a x_0 + b y_0 + c|}{\sqrt{a^2 + b^2}}

Inputs

  • x0 x-coordinate of the point
  • y0 y-coordinate of the point
  • a coefficient of x
  • b coefficient of y
  • c constant term

Returns

  • distance the perpendicular distance

Applies when

  • a and b not both 0

Example

m.ask("Find the distance from the point (1, 2) to the line 3x + 4y - 5 = 0.")
→ distance = 1.2
Domain of a square-root functiondomain_sqrt_over_linear

The domain of f(x) = sqrt(a*x + b)/(c*x + d) (or 1/sqrt(a*x + b)): where the radicand is allowed and the denominator is not 0.

ax + b \ge 0,\quad cx + d \ne 0

Inputs

  • a coefficient of x under the root
  • b constant under the root
  • c coefficient of x in the denominator (0 for none)
  • d constant in the denominator (1 for none)
  • root_in_denominator true when the root itself is in the denominator (the radicand must then be positive) boolean optional

Returns

  • boundary where the radicand is 0
  • side the inequality x must satisfy with the boundary
  • excluded a point removed because the denominator is 0 there (None if none)
  • domain the domain in interval notation

Applies when

  • a != 0
  • the denominator is not identically 0

Example

m.ask("Find the domain of f(x) = sqrt(2x - 4).")
→ boundary = 2, side = >=, excluded = none, domain = [2, inf)
Evaluate a function at a numberevaluate_function

The value f(x0) of a function given by a formula in x (exact when it is rational).

f(x_0)

Inputs

  • expression the formula of f in x: numbers, x, + - * / ^, parentheses, sqrt, abs, ln text
  • x the number x0 to put in

Returns

  • value f(x0)
  • numerator numerator of the exact value
  • denominator denominator of the exact value

Applies when

  • x0 in the domain of f (no division by 0, no root of a negative number, no logarithm of a number <= 0)

Example

m.ask("Evaluate f(3) for f(x) = 2x^2 - 3x + 1.")
→ value = 10, numerator = 10, denominator = 1
Evaluate a piecewise functionpiecewise_evaluate

f(x0) for f(x) = e1 when x < c (or x <= c) and e2 otherwise.

f(x) = \begin{cases} e_1(x) & x < c \\ e_2(x) & x \ge c \end{cases}

Inputs

  • e1 formula of the left piece text
  • left_rel the left piece holds for x < c or x <= c choice
  • c the break point c
  • e2 formula of the right piece text
  • x the number x0

Returns

  • value f(x0)
  • piece which piece applies (1 = left, 2 = right)

Applies when

  • the two conditions split the line at c (one < and one >=, or <= and >)
  • x0 in the domain of its piece

Example

m.ask("Evaluate f(3) for f(x) = 2x + 1 if x < 2, x^2 - 1 if x >= 2.")
→ value = 8, piece = 2
Image of a point under a graph transformationgraph_transformation_point

If (x0, y0) is on y = f(x), the corresponding point on y = A*f(B*(x - h)) + k.

(x_0, y_0) \mapsto \left(\frac{x_0}{B} + h,\; A y_0 + k\right)

Inputs

  • x0 x-coordinate of the point on y = f(x)
  • y0 y-coordinate of the point
  • A vertical stretch (negative: reflection in the x-axis) optional
  • B horizontal compression factor (negative: reflection in the y-axis) optional
  • h horizontal shift optional
  • k vertical shift optional

Returns

  • x_new x-coordinate of the image
  • y_new y-coordinate of the image

Applies when

  • A != 0
  • B != 0

Example

m.ask("The point (2, 5) is on the graph of y = f(x). Find the corresponding point on the graph of y = 3f(2(x - 1)) + 4.")
→ x_new = 2, y_new = 19
Intercepts and slope of a lineline_intercepts

The x- and y-intercepts and the slope of the line a*x + b*y = c.

ax + by = c:\quad x_0 = \frac{c}{a},\ y_0 = \frac{c}{b},\ m = -\frac{a}{b}

Inputs

  • a coefficient of x
  • b coefficient of y
  • c right-hand side

Returns

  • x_intercept where the line meets the x-axis (y = 0)
  • y_intercept where it meets the y-axis (x = 0)
  • slope the slope -a/b

Applies when

  • a != 0
  • b != 0

Example

m.ask("Find the x- and y-intercepts of 2x + 3y = 12.")
→ x_intercept = 6, y_intercept = 4, slope = -0.666667
Inverse of a linear functioninverse_linear_function

For f(x) = a*x + b (a != 0): f^-1(x) = x/a - b/a, and f^-1(y) for a given y.

f^{-1}(x) = \frac{x - b}{a}

Inputs

  • a slope of f
  • b intercept of f
  • y a value to invert (optional) optional

Returns

  • inv_slope slope of the inverse, 1/a
  • inv_intercept intercept of the inverse, -b/a
  • value f^-1(y)

Applies when

  • a != 0

Example

m.ask("Find the inverse of f(x) = 3x - 6.")
→ inv_slope = 0.333333, inv_intercept = 2
Value of a composite functioncomposite_function_value

f(g(x0)) or g(f(x0)) for two functions given by formulas.

(f\circ g)(x_0) = f\big(g(x_0)\big)

Inputs

  • f the formula of f in x text
  • g the formula of g in x text
  • x the number x0
  • order which composition choice

Returns

  • inner value of the inner function at x0
  • value value of the composite at x0

Applies when

  • each value in the domain of the function applied to it

Example

m.ask("If f(x) = x^2 + 1 and g(x) = 2x - 3, find f(g(2)).")
→ inner = 1, value = 2

Inequalities 1

Solution of a linear inequalitylinear_inequality

Solve a*x + b < c (or >): the boundary x0 and the direction s (s = 1 means the solution of the < form is x < x0; s = -1 means it reverses to x > x0 because a < 0).

a x_{0} + b = c,\quad s \sqrt{a^{2}} = a

Inputs

  • a coefficient of x
  • b constant on the left
  • c right-hand side

Returns

  • x0 boundary of the solution set
  • s 1 if the inequality keeps its direction, -1 if it reverses

Applies when

  • a != 0

Example

m.ask("Solve the inequality 2x + 1 < 7.")
→ x0 = 3, s = 1

Linear and absolute value inequalities 2

Solution interval of |x - c| < dabs_value_inequality_upper_bound

For |x - c| < d with d > 0, the solutions are lower < x < upper.

\text{upper} - \text{lower} = 2 d,\quad \text{upper} + \text{lower} = 2 c

Inputs

  • c centre c
  • d bound d

Returns

  • lower lower end of the solution interval (excluded)
  • upper upper end of the solution interval (excluded)

Applies when

  • d > 0

Example

m.ask("Solve |x - 4| < 1.")
→ lower = 3, upper = 5
Solution set of |x - c| > dabs_value_inequality_lower_bound

For |x - c| > d with d >= 0, the solutions are x < left_limit or x > right_limit.

\text{right limit} - \text{left limit} = 2 d,\quad \text{right limit} + \text{left limit} = 2 c

Inputs

  • c centre c
  • d bound d

Returns

  • left_limit x must be below this
  • right_limit or above this

Applies when

  • d >= 0

Example

m.ask("Solve |x - 1| > 3.")
→ left_limit = -2, right_limit = 4

Linear equations 1

Root of a linear equationlinear_equation_root

Solve a*x + b = c for x.

a x + b = c

Inputs

  • a coefficient of x
  • b constant term on the left side
  • c right-hand side

Returns

  • x the solution

Applies when

  • a != 0

Example

m.ask("Solve 3x + 6 = 0.")
→ x = -2

Linear functions 4

Average rate of change between two pointsaverage_rate_of_change_linear

(y2 - y1) / (x2 - x1) between the points (x1, y1) and (x2, y2).

m \left(x_{2} - x_{1}\right) = y_{2} - y_{1}

Inputs

  • x1 x-coordinate of the first point
  • y1 y-coordinate of the first point
  • x2 x-coordinate of the second point
  • y2 y-coordinate of the second point

Returns

  • m average rate of change

Applies when

  • x2 != x1

Example

m.ask("Find the average rate of change between the points (-2, 5) and (3, 0).")
→ m = -1
Line through two pointsline_through_two_points

The slope m and y-intercept k of the line through (x1, y1) and (x2, y2), in the form y = m*x + k.

m x_{1} + k = y_{1},\quad m x_{2} + k = y_{2}

Inputs

  • x1 x-coordinate of the first point
  • y1 y-coordinate of the first point
  • x2 x-coordinate of the second point
  • y2 y-coordinate of the second point

Returns

  • m slope
  • k y-intercept

Applies when

  • x2 - x1 != 0

Example

m.ask("Find the equation of the line through (0, 1) and (2, 5).")
→ m = 2, k = 1
Slope of a perpendicular lineperpendicular_lines_slope_product

The slope m_perp of a line perpendicular to a line of nonzero slope m.

m m_{\text{perp}} = -1

Inputs

  • m slope of the given line

Returns

  • m_perp slope of the perpendicular line

Applies when

  • m != 0

Example

m.ask("A line has slope 5. What is the slope of a line perpendicular to it?")
→ m_perp = -0.2
y-intercept of a line from its slope and a pointconvert_to_slope_intercept

The constant b of y = m*x + b for the line with slope m through (x1, y1).

y_{1} = m x_{1} + b

Inputs

  • m slope
  • x1 x-coordinate of the point
  • y1 y-coordinate of the point

Returns

  • b y-intercept

Example

m.ask("A line with slope 4 passes through (3, 10). What is its y-intercept?")
→ b = -2

Logarithms 1

Solution of a basic logarithmic equationlogarithmic_equation

Solve log_b(x) = c for x.

\ln\left(x\right) = c \ln\left(b\right)

Inputs

  • b base
  • c value of the logarithm

Returns

  • x the solution

Applies when

  • b > 0
  • b != 1

Example

m.ask("Solve log base 3 of x = 4.")
→ x = 81

Matrices 1

Determinant and inverse of a 2 by 2 matrixmatrix_2x2_inverse

For the matrix [[a, b], [c, d]], its determinant and the entries of its inverse.

\text{det} = a d - b c,\quad a i_{11} + b i_{21} = 1,\quad a i_{12} + b i_{22} = 0,\quad c i_{11} + d i_{21} = 0,\quad c i_{12} + d i_{22} = 1

Inputs

  • a top-left entry
  • b top-right entry
  • c bottom-left entry
  • d bottom-right entry

Returns

  • det determinant
  • i11 inverse, top-left
  • i12 inverse, top-right
  • i21 inverse, bottom-left
  • i22 inverse, bottom-right

Applies when

  • a*d - b*c != 0

Example

m.ask("Find the inverse of the matrix [[2, 1], [5, 3]].")
→ det = 1, i11 = 3, i12 = -1, i21 = -5, i22 = 2

Matrices and linear systems 2

Determinant of 2x2 matrixdeterminant_2x2_formula

Computes the determinant of a 2x2 matrix using the standard formula.

\text{det} = a d - b c

Inputs

  • a entry in row 1 column 1
  • b entry in row 1 column 2
  • c entry in row 2 column 1
  • d entry in row 2 column 2

Returns

  • det determinant of the matrix

Example

m.ask("Find the determinant of the matrix [[3, 1], [2, 4]].")
→ det = 10
Matrix scalar multiple definitionmatrix_scalar_multiple_definition

Computes the entries of a 2x2 matrix scaled by a scalar.

b_{11} = s a_{11},\quad b_{12} = s a_{12},\quad b_{21} = s a_{21},\quad b_{22} = s a_{22}

Inputs

  • s scalar multiplier
  • a11 entry in row 1 column 1
  • a12 entry in row 1 column 2
  • a21 entry in row 2 column 1
  • a22 entry in row 2 column 2

Returns

  • b11 entry in row 1 column 1 of result
  • b12 entry in row 1 column 2 of result
  • b21 entry in row 2 column 1 of result
  • b22 entry in row 2 column 2 of result

Example

m.ask("Calculate 3 times the matrix [[1, 2], [3, 4]].")
→ b11 = 3, b12 = 6, b21 = 9, b22 = 12

Other equations 1

Solutions of an absolute value equationabsolute_value_equation

Solve |a*x + b| = c for x (two solutions when c > 0, one when c = 0).

a x_{1} + b = c,\quad a x_{2} + b = -c

Inputs

  • a coefficient of x
  • b constant inside the absolute value
  • c right-hand side

Returns

  • x1 solution of a*x + b = c
  • x2 solution of a*x + b = -c

Applies when

  • a != 0
  • c >= 0

Example

m.ask("Solve |2x - 1| = 5.")
→ x1 = 3, x2 = -2

Polynomial equations 4

Discriminant of a quadraticquadratic_discriminant

The discriminant b^2 - 4ac of a*x^2 + b*x + c and the nature of the roots it implies.

\Delta = b^2 - 4ac

Inputs

  • a coefficient of x^2
  • b coefficient of x
  • c constant term

Returns

  • discriminant b^2 - 4ac
  • nature two distinct real / one repeated real / two complex conjugate roots

Applies when

  • a != 0
  • real coefficients

Example

m.ask("What is the discriminant of x^2 + 4x + 4?")
→ discriminant = 0, nature = one repeated real root
Roots of a cubic equationcubic_roots

Solve a*x^3 + b*x^2 + c*x + d = 0 for x: all three roots, real or complex.

a x^3 + b x^2 + c x + d = 0

Inputs

  • a coefficient of x^3
  • b coefficient of x^2
  • c coefficient of x
  • d constant term

Returns

  • x1 first root (real roots ascending, then complex roots)
  • x2 second root
  • x3 third root

Applies when

  • a != 0 (otherwise the equation is not cubic)
  • real coefficients

Example

m.ask("Solve x^3 - 6x^2 + 11x - 6 = 0.")
→ x1 = 1, x2 = 2, x3 = 3
Roots of a quadratic equationquadratic_roots

Solve a*x^2 + b*x + c = 0 for x: both roots, real or complex.

x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}

Inputs

  • a coefficient of x^2
  • b coefficient of x
  • c constant term

Returns

  • x1 first root (the smaller real root, or the one with positive imaginary part)
  • x2 second root
  • discriminant b^2 - 4ac

Applies when

  • a != 0 (otherwise the equation is linear)
  • real coefficients

Example

m.ask("Solve x^2 - 5x + 6 = 0.")
→ x1 = 2, x2 = 3, discriminant = 1
Roots of a quartic equationquartic_roots

Solve a*x^4 + b*x^3 + c*x^2 + d*x + e = 0 for x: all four roots, real or complex.

a x^4 + b x^3 + c x^2 + d x + e = 0

Inputs

  • a coefficient of x^4
  • b coefficient of x^3
  • c coefficient of x^2
  • d coefficient of x
  • e constant term

Returns

  • x1 first root (real roots ascending, then complex roots)
  • x2 second root
  • x3 third root
  • x4 fourth root

Applies when

  • a != 0 (otherwise the equation is not quartic)
  • real coefficients

Example

m.ask("Solve x^4 - 5x^2 + 4 = 0.")
→ x1 = -2, x2 = -1, x3 = 1, x4 = 2

Polynomials 1

Product of two binomialsbinomial_product

Expand (a*x + b)*(c*x + d) into p2*x^2 + p1*x + p0.

p_{2} t^{2} + p_{1} t + p_{0} = \left(a t + b\right) \left(c t + d\right)

Inputs

  • a coefficient of x in the first binomial
  • b constant of the first binomial
  • c coefficient of x in the second binomial
  • d constant of the second binomial

Returns

  • p2 coefficient of x^2
  • p1 coefficient of x
  • p0 constant term

Example

m.ask("Expand (x + 2)(x + 3).")
→ p2 = 1, p1 = 5, p0 = 6

Precalculus 8

Coefficient of a term in a binomial expansionbinomial_coefficient_term

The coefficient of x^k in (a*x + b)^n, by the binomial theorem.

(ax + b)^n = \sum_{k=0}^{n} \binom{n}{k} a^k b^{n-k} x^k

Inputs

  • a coefficient of x in the binomial
  • b constant of the binomial
  • n the power n integer
  • k the power of x whose coefficient is wanted integer

Returns

  • coefficient coefficient of x^k
  • binomial the binomial coefficient C(n, k)

Applies when

  • 0 <= n <= 60
  • k >= 0

Example

m.ask("Find the coefficient of x^3 in (2x - 1)^5.")
→ coefficient = 80, binomial = 10
Dot product and angle between two vectorsvector_dot_angle

The dot product, the magnitudes and the angle between two vectors in the plane or in space.

\mathbf u\cdot\mathbf v = |\mathbf u||\mathbf v|\cos\theta

Inputs

  • u the first vector, e.g. 3, 4 vector
  • v the second vector vector

Returns

  • dot u . v
  • mag_u |u|
  • mag_v |v|
  • angle_deg the angle between them, degrees (0 to 180)

Applies when

  • same dimension (2 or 3)
  • neither vector is zero

Example

m.ask("Find the angle between u = <3, 4> and v = <4, -3>.")
→ dot = 0, mag_u = 5, mag_v = 5, angle_deg = 90
Foci, axes and eccentricity of an ellipseellipse_parameters

For (x - h)^2/A + (y - k)^2/B = 1: semi-axes a and b, focal distance c, eccentricity and the two foci.

\frac{(x-h)^2}{A} + \frac{(y-k)^2}{B} = 1,\quad c^2 = a^2 - b^2,\quad e = \frac{c}{a}

Inputs

  • h x of the centre
  • k y of the centre
  • A denominator under the x term (positive)
  • B denominator under the y term (positive)

Returns

  • a semi-major axis
  • b semi-minor axis
  • c centre-to-focus distance
  • eccentricity e = c/a
  • f1x first focus x
  • f1y first focus y
  • f2x second focus x
  • f2y second focus y
  • orientation the major axis is horizontal or vertical

Applies when

  • A, B > 0
  • A != B (otherwise a circle)

Example

m.ask("Find the foci and eccentricity of the ellipse x^2/25 + y^2/9 = 1.")
→ a = 5, b = 3, c = 4, eccentricity = 0.8, f1x = -4, f1y = 0, f2x = 4, f2y = 0, orientation = horizontal
Foci, eccentricity and asymptotes of a hyperbolahyperbola_parameters

For (x - h)^2/A - (y - k)^2/B = 1 (or the vertical form): a, b, c, eccentricity, the asymptotes' slope and the foci.

\frac{(x-h)^2}{a^2} - \frac{(y-k)^2}{b^2} = 1,\quad c^2 = a^2 + b^2

Inputs

  • h x of the centre
  • k y of the centre
  • A denominator of the positive term
  • B denominator of the negative term
  • orientation horizontal (x term positive) or vertical choice

Returns

  • a a = sqrt(A)
  • b b = sqrt(B)
  • c centre-to-focus distance
  • eccentricity e = c/a
  • asymptote_slope slope of the asymptotes (plus or minus this)
  • f1x first focus x
  • f1y first focus y
  • f2x second focus x
  • f2y second focus y

Applies when

  • A, B > 0

Example

m.ask("Find the foci and asymptotes of the hyperbola x^2/16 - y^2/9 = 1.")
→ a = 4, b = 3, c = 5, eccentricity = 1.25, asymptote_slope = 0.75, f1x = -5, f1y = 0, f2x = 5, f2y = 0
Focus and directrix of a parabolaparabola_focus_directrix

Vertex, focal distance p, focus and directrix of (x - h)^2 = 4p(y - k) or (y - k)^2 = 4p(x - h).

(x-h)^2 = 4p(y-k):\ F = (h, k+p),\ y = k - p

Inputs

  • orientation vertical axis ((x-h)^2 = m(y-k)) or horizontal choice
  • m the coefficient m = 4p
  • h x of the vertex optional
  • k y of the vertex optional

Returns

  • p focal distance p = m/4 (signed)
  • focus_x x of the focus
  • focus_y y of the focus
  • directrix the directrix: y = this (vertical axis) or x = this (horizontal axis)
  • vertex_x x of the vertex
  • vertex_y y of the vertex

Applies when

  • m != 0

Example

m.ask("Find the focus and directrix of the parabola x^2 = 12y.")
→ p = 3, focus_x = 0, focus_y = 3, directrix = -3, vertex_x = 0, vertex_y = 0
Magnitude and direction of a vectorvector_magnitude_direction

The length of the plane vector <x, y> and its direction angle from the positive x-axis (0 to 360 degrees).

|\mathbf v| = \sqrt{x^2 + y^2},\quad \theta = \operatorname{atan2}(y, x)

Inputs

  • x the x-component
  • y the y-component

Returns

  • magnitude |v|
  • direction_deg the direction angle, degrees in [0, 360)

Applies when

  • not the zero vector

Example

m.ask("Find the magnitude and direction of the vector <-3, 4>.")
→ magnitude = 5, direction_deg = 126.87
Polar to rectangular coordinatespolar_to_rectangular

The point (x, y) with polar coordinates (r, theta).

x = r\cos\theta,\quad y = r\sin\theta

Inputs

  • r the distance r from the pole
  • theta the angle theta
  • unit degrees or radians choice

Returns

  • x x = r cos(theta)
  • y y = r sin(theta)

Applies when

  • the angle's unit stated

Example

m.ask("Convert the polar point (4, 60 degrees) to rectangular coordinates.")
→ x = 2, y = 3.4641
Rectangular to polar coordinatesrectangular_to_polar

Polar coordinates (r, theta) of the point (x, y), with r > 0 and theta in [0, 360) degrees / [0, 2 pi).

r = \sqrt{x^2+y^2},\quad \tan\theta = \frac{y}{x}

Inputs

  • x x-coordinate
  • y y-coordinate

Returns

  • r r = sqrt(x^2 + y^2)
  • theta_deg theta in degrees, [0, 360)
  • theta_rad theta in radians, [0, 2 pi)

Applies when

  • not the origin

Example

m.ask("Convert the point (3, -3) to polar coordinates.")
→ r = 4.24264, theta_deg = 315, theta_rad = 5.49779

Quadratic functions 1

Vertex form of a quadratic functionvertex_form

Write a*x^2 + b*x + c as a*(x - h)^2 + k, giving the vertex (h, k).

a \left(t - h\right)^{2} + k = a t^{2} + b t + c

Inputs

  • a coefficient of x^2
  • b coefficient of x
  • c constant term

Returns

  • h x-coordinate of the vertex
  • k y-coordinate of the vertex

Applies when

  • a != 0

Example

m.ask("Find the vertex of y = x^2 - 6x + 5.")
→ h = 3, k = -4

Rational expressions 2

Add rational expressions with same denominatoradd_rational_expressions_same_denom

Add two rational expressions that share a common denominator.

\text{sum num} = \text{num}_{1} + \text{num}_{2},\quad \text{sum den} = \text{den}

Inputs

  • num1 numerator of first expression
  • num2 numerator of second expression
  • den common denominator

Returns

  • sum_num numerator of the sum
  • sum_den denominator of the sum

Applies when

  • den != 0

Example

m.ask("Add 1/6 and 2/6.")
→ sum_num = 3, sum_den = 6
Multiply rational expressionsmultiply_rational_expressions

Compute the product of two rational expressions.

\text{prod num} = \text{num}_{1} \text{num}_{2},\quad \text{prod den} = \text{den}_{1} \text{den}_{2}

Inputs

  • num1 numerator of first expression
  • den1 denominator of first expression
  • num2 numerator of second expression
  • den2 denominator of second expression

Returns

  • prod_num numerator of the product
  • prod_den denominator of the product

Applies when

  • den1 != 0
  • den2 != 0

Example

m.ask("Multiply 2/3 by 5/7.")
→ prod_num = 10, prod_den = 21

Rational functions 1

Asymptotes of a linear rational functionrational_function_asymptotes

The vertical asymptote x = va and horizontal asymptote y = ha of f(x) = (a*x + b)/(c*x + d).

c v_{a} + d = 0,\quad c h_{a} = a

Inputs

  • a coefficient of x in the numerator
  • b constant of the numerator
  • c coefficient of x in the denominator
  • d constant of the denominator

Returns

  • va vertical asymptote
  • ha horizontal asymptote

Applies when

  • c != 0
  • a*d - b*c != 0

Example

m.ask("Find the asymptotes of f(x) = (2x + 1)/(x - 3).")
→ va = 3, ha = 2

Real numbers and algebraic expressions 1

Perimeter of a rectangleperimeter_of_rectangle

The perimeter p of a rectangle with width w and height h.

p - 2 h = 2 w

Inputs

  • w width
  • h height

Returns

  • p perimeter

Applies when

  • w >= 0
  • h >= 0

Example

m.ask("What is the perimeter of a rectangle with width 6 and height 2?")
→ p = 16

Sequences 2

Term and partial sum of a geometric sequencegeometric_sequence

The n-th term and the sum of the first n terms of the geometric sequence with first term g1 and common ratio q (q != 1).

g_{n} = g_{1} q^{n - 1},\quad s_{n} \left(1 - q\right) = g_{1} \left(1 - q^{n}\right)

Inputs

  • g1 first term
  • q common ratio
  • n position of the term

Returns

  • gn the n-th term
  • sn the sum of the first n terms

Applies when

  • q != 1
  • n >= 1

Example

m.ask("Find term 4 and the sum of the first 4 terms of the geometric sequence with first term 2 and ratio 3.")
→ gn = 54, sn = 80
Term and partial sum of an arithmetic sequencearithmetic_sequence

The n-th term and the sum of the first n terms of the arithmetic sequence with first term a1 and common difference d.

a_{n} = a_{1} + \left(n - 1\right) d,\quad 2 s_{n} = n \left(a_{1} + a_{n}\right)

Inputs

  • a1 first term
  • d common difference
  • n position of the term (a positive whole number)

Returns

  • an the n-th term
  • sn the sum of the first n terms

Applies when

  • n >= 1

Example

m.ask("Find the 10th term of the arithmetic sequence with first term 3 and common difference 4.")
→ an = 39, sn = 210

Systems of equations 1

Solution of two linear equations in two unknownslinear_system_2x2

Solve a*x + b*y = c and d*x + e*y = f for x and y.

a x + b y = c,\quad d x + e y = f

Inputs

  • a coefficient of x in the first equation
  • b coefficient of y in the first equation
  • c right-hand side of the first equation
  • d coefficient of x in the second equation
  • e coefficient of y in the second equation
  • f right-hand side of the second equation

Returns

  • x the value of x
  • y the value of y

Applies when

  • a*e - b*d != 0

Example

m.ask("Solve the system x + y = 10, x - y = 2.")
→ x = 6, y = 4

The coordinate plane and graphs 1

Midpoint of a line segmentmidpoint_of_segment

The midpoint (mx, my) of the segment from (x1, y1) to (x2, y2).

2 m_{x} = x_{1} + x_{2},\quad 2 m_{y} = y_{1} + y_{2}

Inputs

  • x1 x-coordinate of the first endpoint
  • y1 y-coordinate of the first endpoint
  • x2 x-coordinate of the second endpoint
  • y2 y-coordinate of the second endpoint

Returns

  • mx x-coordinate of the midpoint
  • my y-coordinate of the midpoint

Example

m.ask("Find the midpoint of the segment from (-4, 2) to (0, 6).")
→ mx = -2, my = 4

Trigonometry 13

Area of a triangle from its three sides (Heron)heron_area

The area of a triangle with sides a, b, c, and its semi-perimeter s.

K = \sqrt{s(s-a)(s-b)(s-c)},\quad s = \frac{a+b+c}{2}

Inputs

  • a side a
  • b side b
  • c side c

Returns

  • area the area
  • s the semi-perimeter (a + b + c)/2

Applies when

  • positive sides
  • triangle inequality

Example

m.ask("Find the area of a triangle with sides 13, 14 and 15.")
→ area = 84, s = 21
Degrees to radiansdeg_to_rad

Convert an angle in degrees to radians (also as a multiple of pi).

\theta_{\mathrm{rad}} = \theta_{\deg}\cdot\frac{\pi}{180}

Inputs

  • deg the angle in degrees

Returns

  • radians the angle in radians
  • pi_multiple the angle as a multiple of pi
  • exact exact form, e.g. 3pi/4

Applies when

  • a finite angle

Example

m.ask("Convert 135 degrees to radians.")
→ radians = 2.35619, pi_multiple = 0.75, exact = 3pi/4
Exact trigonometric values on the unit circleunit_circle_exact

The exact sin, cos and tan of an angle that is a multiple of 30 or 45 degrees (pi/6, pi/4), with the reference angle.

\sin 30^\circ = \tfrac12,\ \sin 45^\circ = \tfrac{\sqrt2}{2},\ \sin 60^\circ = \tfrac{\sqrt3}{2}

Inputs

  • deg the angle in degrees (a multiple of 30 or 45)

Returns

  • sin sin of the angle
  • cos cos of the angle
  • tan tan of the angle (None where undefined)
  • sin_exact exact sin
  • cos_exact exact cos
  • tan_exact exact tan
  • reference_angle the reference angle, degrees

Applies when

  • a whole multiple of 30 or 45 degrees

Example

m.ask("Find the exact values of sin, cos and tan of 150 degrees.")
→ sin = 0.5, cos = -0.866025, tan = -0.57735, sin_exact = 1/2, cos_exact = -sqrt(3)/2, tan_exact = -sqrt(3)/3, reference_angle = 30
Law of cosines (three sides)law_of_cosines_sss

Given the three sides a, b, c: the angles A, B, C.

\cos A = \frac{b^2 + c^2 - a^2}{2bc}

Inputs

  • a side a
  • b side b
  • c side c

Returns

  • A angle A, degrees
  • B angle B, degrees
  • C angle C, degrees

Applies when

  • positive sides
  • triangle inequality (each side shorter than the sum of the other two)

Example

m.ask("In triangle ABC, a = 7, b = 8 and c = 9. Find the angles.")
→ A = 48.1897, B = 58.4119, C = 73.3985
Law of cosines (two sides and the included angle)law_of_cosines_sas

Given sides b and c and the included angle A: the third side a and the angles B and C.

a^2 = b^2 + c^2 - 2bc\cos A

Inputs

  • b side b
  • c side c
  • A the included angle A, degrees

Returns

  • a side a
  • B angle B, degrees
  • C angle C, degrees

Applies when

  • b, c > 0
  • 0 < A < 180

Example

m.ask("In triangle ABC, b = 5, c = 7 and A = 49 degrees. Solve the triangle.")
→ a = 5.29867, B = 45.4117, C = 85.5883
Law of sines (two angles and a side)law_of_sines_aas

Given angles A and B and the side a opposite A: the third angle C and the sides b and c.

\frac{a}{\sin A} = \frac{b}{\sin B} = \frac{c}{\sin C}

Inputs

  • A angle A, degrees
  • B angle B, degrees
  • a side a, opposite A

Returns

  • C angle C, degrees
  • b side b
  • c side c

Applies when

  • A, B > 0
  • A + B < 180
  • a > 0

Example

m.ask("In triangle ABC, A = 40 degrees, B = 60 degrees and a = 10. Solve the triangle.")
→ C = 80, b = 13.473, c = 15.3209
Law of sines, the ambiguous case (two sides and a non-included angle)law_of_sines_ssa

Given sides a and b and the angle A opposite a: how many triangles exist (0, 1 or 2) and every one of them.

\sin B = \frac{b\sin A}{a},\quad B_2 = 180^\circ - B_1

Inputs

  • a side a, opposite A
  • b side b
  • A angle A, degrees

Returns

  • count number of triangles (1 or 2; none is refused)
  • B1 angle B of the first triangle (the acute one)
  • C1 angle C of the first triangle
  • c1 side c of the first triangle
  • B2 angle B of the second triangle (obtuse), when there are two
  • C2 angle C of the second triangle
  • c2 side c of the second triangle

Applies when

  • a, b > 0
  • 0 < A < 180
  • a triangle exists (else refused)

Example

m.ask("In triangle ABC, a = 8, b = 10 and A = 40 degrees. Solve the triangle.")
→ count = 2, B1 = 53.4641, C1 = 86.5359, c1 = 12.423, B2 = 126.536, C2 = 13.4641, c2 = 2.89784
Radians to degreesrad_to_deg

Convert an angle in radians (a number, or a multiple of pi such as 3pi/4) to degrees.

\theta_{\deg} = \theta_{\mathrm{rad}}\cdot\frac{180}{\pi}

Inputs

  • rad the angle in radians

Returns

  • degrees the angle in degrees

Applies when

  • a finite angle

Example

m.ask("Convert 3pi/4 radians to degrees.")
→ degrees = 135
Right triangle from a leg and the hypotenuseright_triangle_leg_hypotenuse

Given a leg a and the hypotenuse c of a right triangle: the other leg b and the acute angles A (opposite a) and B.

b = \sqrt{c^2 - a^2},\quad \sin A = \frac{a}{c}

Inputs

  • a the known leg (positive)
  • c the hypotenuse (longer than the leg)

Returns

  • b the other leg
  • A angle opposite a, degrees
  • B angle opposite b, degrees

Applies when

  • 0 < a < c

Example

m.ask("A right triangle has hypotenuse 13 and one leg 5. Find the other leg and the acute angles.")
→ b = 12, A = 22.6199, B = 67.3801
Right triangle from an acute angle and a sideright_triangle_angle_side

Given an acute angle A and one side (the hypotenuse, the side opposite A or the side adjacent to A): every side and the other angle.

\sin A = \frac{\mathrm{opp}}{\mathrm{hyp}},\ \cos A = \frac{\mathrm{adj}}{\mathrm{hyp}},\ \tan A = \frac{\mathrm{opp}}{\mathrm{adj}}

Inputs

  • A the acute angle A in degrees
  • side the length of the known side
  • which which side is known choice

Returns

  • opposite side opposite A
  • adjacent side adjacent to A
  • hypotenuse the hypotenuse
  • B the other acute angle, degrees

Applies when

  • 0 < A < 90
  • side > 0

Example

m.ask("In a right triangle, angle A is 30 degrees and the hypotenuse is 10. Find the other sides.")
→ opposite = 5, adjacent = 8.66025, hypotenuse = 10, B = 60
Right triangle from its two legsright_triangle_legs

Given the legs a and b of a right triangle: the hypotenuse c and the acute angles A (opposite a) and B.

c = \sqrt{a^2 + b^2},\quad \tan A = \frac{a}{b}

Inputs

  • a the leg opposite angle A (positive)
  • b the leg opposite angle B (positive)

Returns

  • c the hypotenuse
  • A angle opposite a, degrees
  • B angle opposite b, degrees

Applies when

  • a > 0
  • b > 0

Example

m.ask("A right triangle has legs 3 and 4. Find the hypotenuse and the acute angles.")
→ c = 5, A = 36.8699, B = 53.1301
Solve a trigonometric equation over one full turntrig_equation_interval

Every solution of a*sin(n x) = k (or cos, tan) with 0 <= x < 360 degrees or 0 <= x < 2 pi.

\sin u = k \Rightarrow u = \arcsin k,\ 180^\circ - \arcsin k \pmod{360^\circ},\quad u = n x

Inputs

  • func sin, cos or tan choice
  • k the value the function must take (after dividing by its coefficient)
  • n the multiple n in f(n x) (default 1) integer optional
  • unit degrees ([0, 360)) or radians ([0, 2pi)) choice optional

Returns

  • count number of solutions in the interval
  • solutions the solutions, ascending

Applies when

  • n a whole number from 1 to 12

Example

m.ask("Solve sin(x) = 0.5 for 0 <= x < 360 degrees.")
→ count = 2, solutions = [30.000000000000004, 150.0]
Trigonometric values from one value and the quadranttrig_values_from_one

Given sin, cos or tan of an angle and its quadrant: sin, cos, tan, sin 2t and cos 2t (Pythagorean and double-angle identities).

\cos t = \pm\sqrt{1 - \sin^2 t},\quad \sin 2t = 2\sin t\cos t,\quad \cos 2t = \cos^2 t - \sin^2 t

Inputs

  • func the function whose value is known choice
  • value its value
  • quadrant the quadrant of the angle (1 to 4) integer

Returns

  • sin sin t
  • cos cos t
  • tan tan t
  • sin2 sin 2t
  • cos2 cos 2t

Applies when

  • the value's sign agrees with the quadrant
  • 0 < |sin|, |cos| < 1

Example

m.ask("If sin(t) = 3/5 and t is in quadrant II, find cos(t), tan(t), sin(2t) and cos(2t).")
→ sin = 0.6, cos = -0.8, tan = -0.75, sin2 = -0.96, cos2 = 0.28
Questions

Frequently asked

What does math-foundations-ai999x do?

Math Foundations answers questions in math foundations: arithmetic, fractions, percentages, ratios, algebraic equations and inequalities, functions, exponentials and logarithms, trigonometry, precalculus and complex numbers. Each answer gives the value with its unit, the steps and the formula in LaTeX.

How do I install math-foundations-ai999x?

With pip: pip install math-foundations-ai999x. The same files are on Hugging Face (hf download AI999X/math-foundations-ai999x --local-dir math-foundations-ai999x) and GitHub.

Does it run offline?

Yes. It is a Python package that runs on an ordinary CPU without a network connection (Python >=3.10); no GPU and no API key are needed.

How many capabilities does math-foundations-ai999x have?

100 capabilities in 31 topics, including Trigonometry, Arithmetic, Algebra, Functions, Precalculus.

Which field and tasks does it cover?

Field: Mathematics & Statistics. Tasks: Question Answering, Token Classification, Text Classification, Sentence Similarity, Feature Extraction.

What does an answer look like?

Asked "Solve x^2 - 5x + 6 = 0.", it answers: x1 = 2, x2 = 3, discriminant = 1.

What happens when a question cannot be answered?

It says so and names what is missing or out of range, instead of guessing a number.

More from AI999X

Explore every model.