Portability | Non-portable (GHC extensions) |
---|---|

Stability | Provisional |

Maintainer | Daniel Fischer <daniel.is.fischer@googlemail.com> |

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

- integerFourthRoot :: Integral a => a -> a
- integerFourthRoot' :: Integral a => a -> a
- exactFourthRoot :: Integral a => a -> Maybe a
- isFourthPower :: Integral a => a -> Bool
- isFourthPower' :: Integral a => a -> Bool
- isPossibleFourthPower :: Integral a => a -> Bool

# 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.