canon-0.1.1.3: Arithmetic for Psychedelically Large Numbers

Copyright(c) 2015-2019 Frederick Schneider
LicenseMIT
MaintainerFrederick Schneider <fws.nyc@gmail.com>
StabilityProvisional
Safe HaskellNone
LanguageHaskell2010

Math.NumberTheory.Canon.AurifCyclo

Description

Aurifeuillian and Cyclotomic factorization method functions.

Synopsis

Documentation

aurCandDec :: Integer -> Integer -> Bool -> Maybe (Integer, Integer) Source #

This function checks if the input is a candidate for Aurifeuillian decomposition. Its name is an abbreviation. If it is a candidate, split it into two and evaluate it. Otherwise, return nothing. The code will "prep" the input params for the internal function so they will be relatively prime. Possible solutions: Non-zero multiples of xi and yi (where xi and yi are relatively prime and of the form xi = a^(a*b), yi = 1 where a and b are positive integers and b is odd. (xi and y1 may be interchanged) If a is even, we will find factors of a^(a*b) + 1. The bool flag must be True If a is odd, we will find factors of a^(a*b) - 1. The bool flag must be False This function and those it calls internally implement Richard Brent's algorithm for computing Aurifeuillian factors. His logic is used in conjuction with cyclotomic polynomial decomposition. They are explained in these two papers: rpb127 and rpb135.

aurDec :: Integer -> Maybe (Array Integer Integer, Array Integer Integer) Source #

This function returns a pair of polynomials (in array form) or Nothing (if it's squareful). An illogical n (n <= 1) will generate an error.

applyCycloPair :: Integer -> Integer -> Integer -> [Integer] Source #

Wraps applyCycloPairWithMap with default CycloMap argument.

applyCycloPairWithMap :: Integer -> Integer -> Integer -> CycloMap -> ([Integer], CycloMap) Source #

This will use cyclotomic polynomial methods to factor x^e - b^e.

type CycloPair = (Integer, Poly) Source #

CycloPair: Pair of an Integer and its corresponding cyclotomic polynomial

type Poly = [Integer] Source #

Crude polynomial type. Look into optimizing at a later date

cyclo :: Integer -> (CycloPair, CycloMap) Source #

Integer wrapper for crCyclo with default CycloMap parameter

cycloWithMap :: Integer -> CycloMap -> (CycloPair, CycloMap) Source #

Integer wrapper for crCyclo

cycloDivSet :: Integer -> CycloMap Source #

Integer wrapper for crCycloDivSet with default CycloMap parameter

cycloDivSetWithMap :: Integer -> CycloMap -> (CycloMap, CycloMap) Source #

Integer wrapper for crCycloDivSet

chineseAurif :: Integer -> Integer -> Bool -> Maybe (Integer, Integer) Source #

Wrapper for chineseAurifWithMap with default CycloMap parameter

Integral examples to try. These both will return answers of the form: Just (bigFactor1, bigFactor2). The product of the two big factors will divide the equivalent value in each comment.

>>> (q,m,p,k,r,n)=(7,1,19,13,1,1)
>>> chineseAurif ((q^(2*m)*p)^(p*k)) ((r^(2*n))^(p*k)) True -- Equivalent to 931^247+1
>>> (q,m,p,k,r,n)=(5,8,29,13,11,1)
>>> chineseAurif ((q^(2*m)*p)^(p*k)) ((r^(2*n))^(p*k)) False -- Equivalent to (5^16*29)^377 - 121^377

chineseAurifWithMap :: Integer -> Integer -> Bool -> CycloMap -> (Maybe (Integer, Integer), CycloMap) Source #

The source for this algorithm is this paper The formula at 2.7 there is implemented in the internal chineseAurifCr function. This will handle a subset of the cases that the main Aurif. routines handle.

crCycloAurifApply :: Bool -> CR_ -> CR_ -> CR_ -> Integer -> CycloMap -> (CR_, CycloMap) Source #

This function checks if the inputs along with operator flag have a cyclotomic or Aurifeuillian form to greatly simplify factoring. If they do not, potentially much more expesive simple factorization is used via crSimpleApply. Note: The cyclotomic map is threaded into the functions

applyCrCycloPair :: Integer -> Integer -> CR_ -> CycloMap -> ([Integer], CycloMap) Source #

These "apply cyclo" functions will use cyclotomic polynomial methods to factor x^e - b^e.

divvy :: [Integer] -> Integer -> Integer -> [Integer] Source #

Internal function requires two integers (computed via Aurif. methods) along with a list of Integers. The product of the Integers must be a divisor of the list's product otherwise an error will be generated. It's called divvy because it splits the 2 integers across the array using the gcd. This will help factoring because the larger term(s) will be broken up into smaller pieces.

data CycloMap Source #

CycloMap is a newtype hiding the details of a map of CR_ to pairs of integers and corresponding cyclotomic polynomials.

Instances
Eq CycloMap Source # 
Instance details

Defined in Math.NumberTheory.Canon.AurifCyclo

Show CycloMap Source # 
Instance details

Defined in Math.NumberTheory.Canon.AurifCyclo

getIntegerBasedCycloMap :: CycloMap -> Map Integer CycloPair Source #

Unwrap the CycloMap and convert the internal canon rep keys to Integers, returning a "raw" map

showCyclo :: CR_ -> CycloMap -> [Char] Source #

This will display the cyclotomic polynomials for a CR.

crCycloInitMap :: CycloMap Source #

This is an initial map with the cyclotomic polynomials for 1.

multPoly :: Num a => [a] -> [a] -> [a] Source #

Multiply two polynomials

divPoly :: Integral a => [a] -> [a] -> [a] Source #

Div function for polynomials. The assumption is that p1 is a multiple of p2

addPoly :: Num a => [a] -> [a] -> [a] Source #

Add two polynomials

type CR_ = CanonRep_ Source #

Shorthand for canonical representation

type CanonRep_ = [CanonElement_] Source #

Canonical representation: list of canon elements

type CanonElement_ = (Integer, Integer) Source #

Canon element: prime and exponent pair