API Reference#

Algebra#

Counting#

Number Theory#

mathematics.number_theory.d(n, m)#

Checks if n divides m, equivalent to n|m

Parameters:
Return type:

bool

mathematics.number_theory.euclidean_algorithm(a, b)#
mathematics.number_theory.extended_euclidean_algorithm()#
mathematics.number_theory.factors(number)#

Returns the factors of the number

Parameters:

number (int) –

Return type:

list[int]

mathematics.number_theory.nth_power(repetitions, power)#

returns a list with every i from 1 to repetitions with every element raised to the power

Return type:

list[int]

mathematics.number_theory.partition(n)#

Returns the partitions of n

Parameters:

n (int) –

Return type:

list[list[int]]

mathematics.number_theory.pigeon_hole(colors, number_needed)#
Parameters:
  • colors (int) –

  • number_needed (int) –

Return type:

int

mathematics.number_theory.prime_factor(number)#

Returns a list of prime factors of a number

Parameters:

number (int) –

Return type:

list[int]

mathematics.number_theory.primitive_root(n)#
Parameters:

n (int) –

mathematics.number_theory.primitive_roots(n)#
Parameters:

n (int) –

Return type:

list

mathematics.number_theory.root_equivalents(modulus, square_of_root)#
Parameters:
  • modulus (int) –

  • square_of_root (int) –

Return type:

list[int]

mathematics.number_theory.step_in_euclidean_algorithm(a, b)#
Return type:

tuple

mathematics.number_theory.totient(m)#

The euler totient function returns the number of positive integers less than or equal to m that are relatively prime to m. :return: The number of positive integers less than or equal to m that are relatively prime to m.

Parameters:

m (int) –

Return type:

int

number_theory_extended#

mathematics.number_theory.number_theory_extended.addition_sums_mod_n(n)#
mathematics.number_theory.number_theory_extended.addition_sums_mod_n_gen(start, stop)#
mathematics.number_theory.number_theory_extended.distance(mod, number)#
mathematics.number_theory.number_theory_extended.nth_power_mod_m(stop, m, power)#
mathematics.number_theory.number_theory_extended.partial_sum_for_half_plus_fourth(n)#
mathematics.number_theory.number_theory_extended.pattern_mod_n_adding(n, mod)#
mathematics.number_theory.number_theory_extended.pattern_mod_n_adding_gen(end, start_1, start_2)#
mathematics.number_theory.number_theory_extended.pattern_mod_n_adding_gen_primes(end, start_1, start_2)#
mathematics.number_theory.number_theory_extended.pattern_mod_n_analytics_v1(end_1, start_1_1, start_2_1, end_2, start_1_2, start_2_2, the_function)#
mathematics.number_theory.number_theory_extended.pattern_mod_n_multiplying(number, mod)#
mathematics.number_theory.number_theory_extended.pattern_mod_n_multiplying_gen(end, start_1, start_2)#
mathematics.number_theory.number_theory_extended.powers_of_x_plus_1_mod_prime(prime, x, p)#
mathematics.number_theory.number_theory_extended.powers_of_x_plus_1_mod_prime_gen(x, prime, stop_p)#
mathematics.number_theory.number_theory_extended.prime_mult(n)#
mathematics.number_theory.number_theory_extended.prime_mult_gen(n)#
mathematics.number_theory.number_theory_extended.root_equivalents(modulus, root)#
mathematics.number_theory.number_theory_extended.sieve_numbers(num)#
mathematics.number_theory.number_theory_extended.special_exclusion_partition(n, i)#
mathematics.number_theory.number_theory_extended.squares_mod_m(stop, m)#
mathematics.number_theory.number_theory_extended.sum_set(set_a, set_b)#

Adds the sets, not the same as union

number_theory.primes#

mathematics.number_theory.primes.is_mersenne_number(n)#
mathematics.number_theory.primes.is_prime(num)#

Uses 6k+-1

Parameters:

num (int) –

Return type:

bool

mathematics.number_theory.primes.is_prime_fermat_little_theorem(num)#

Check for primality using fermats little theorem, faster than wilsons theorem for larger numbers, but is incorrect for any Carmicheal number

mathematics.number_theory.primes.is_prime_six_k_pm_one(n)#
Parameters:

n (int) –

Return type:

bool

mathematics.number_theory.primes.is_prime_wilsons_theorem(num)#

Check for primality using wilsons theorem

mathematics.number_theory.primes.lucas_lehmer(p)#

Implements Lucas Lehmer mersenne prime test. Checks if the pth mersenne number is prime

mathematics.number_theory.primes.lucas_lehmer_gen(start, stop)#
mathematics.number_theory.primes.mersenne(n)#

Returns the nth mersenne number :param n: :return:

mathematics.number_theory.primes.prime_gen(*args, **kwargs)#

Generates primes from start=>stop

Probability#

class mathematics.probability.Probability(desired_outcomes, all_outcomes)#

Bases: object

This implements basic probability functions

Parameters:
  • desired_outcomes (list) –

  • all_outcomes (list) –

complement()#

Returns the complement of the Probability

Return type:

Fraction

value()#
Return type:

Fraction

mathematics.probability.a_and_b_single_try_independent(a, b, universal_set)#
Return type:

Fraction

mathematics.probability.a_and_b_two_tries_independent(a, b)#
mathematics.probability.a_given_b(a, b, universal_set)#
mathematics.probability.a_or_b(a, b, universal_set)#
Return type:

Fraction

mathematics.probability.are_mutually_exclusive(a, b)#
Return type:

bool

mathematics.probability.bayes_a_given_b(a, b, universal_set)#

Stats#