arithmoi-0.2.0.1: Efficient basic number-theoretic functions. Primes, powers, integer logarithms.

PortabilityNon-portable (GHC extensions)
StabilityProvisional
MaintainerDaniel Fischer <daniel.is.fischer@googlemail.com>

Math.NumberTheory.Powers.Fourth

Description

Functions dealing with fourth powers. Efficient calculation of integer fourth roots and efficient testing for being a square's square.

Synopsis

Documentation

integerFourthRoot :: Integral a => a -> aSource

Calculate the integer fourth root of a nonnegative number, that is, the largest integer r with r^4 <= n. Throws an error on negaitve input.

integerFourthRoot' :: Integral a => a -> aSource

Calculate the integer fourth root of a nonnegative number, that is, the largest integer r with r^4 <= n. The condition is not checked.

exactFourthRoot :: Integral a => a -> Maybe aSource

Returns Nothing if n is not a fourth power, Just r if n == r^4 and r >= 0.

isFourthPower :: Integral a => a -> BoolSource

Test whether an integer is a fourth power. First nonnegativity is checked, then the unchecked test is called.

isFourthPower' :: Integral a => a -> BoolSource

Test whether a nonnegative number is a fourth power. The condition is not checked. If a number passes the isPossibleFourthPower test, its integer fourth root is calculated.

isPossibleFourthPower :: Integral a => a -> BoolSource

Test whether a nonnegative number is a possible fourth power. The condition is not checked. This eliminates about 99.958% of numbers.