arithmoi-0.13.0.0: Efficient basic number-theoretic functions.

Copyright | (c) 2018 Andrew Lelechenko
License | MIT
Maintainer | Andrew Lelechenko <andrew.lelechenko@gmail.com>
Safe Haskell | Safe-Inferred
Language | Haskell2010

Math.NumberTheory.Moduli.Equations

Description

Polynomial modular equations.

Synopsis

- solveLinear :: KnownNat m => Mod m -> Mod m -> [Mod m]
- solveQuadratic :: SFactors Integer m -> Mod m -> Mod m -> Mod m -> [Mod m]

# Documentation

solveLinear Source #

Arguments

:: KnownNat m |
=> Mod m | a
-> Mod m | b
-> [Mod m] | list of x

Find all solutions of ax + b ≡ 0 (mod m).

    >>> :set -XDataKinds
    >>> solveLinear (6 :: Mod 10) 4 -- solving 6x + 4 ≡ 0 (mod 10)
    [(1 `modulo` 10),(6 `modulo` 10)]

solveQuadratic Source #

Arguments

:: SFactors Integer m |
-> Mod m | a
-> Mod m | b
-> Mod m | c
-> [Mod m] | list of x

Find all solutions of ax² + bx + c ≡ 0 (mod m).

    >>> :set -XDataKinds
    >>> solveQuadratic sfactors (1 :: Mod 32) 0 (-17) -- solving x² - 17 ≡ 0 (mod 32)
    [(9 `modulo` 32),(25 `modulo` 32),(7 `modulo` 32),(23 `modulo` 32)]