# Power function

### From HaskellWiki

(format table) |
m (format) |
||

Line 14: | Line 14: | ||

In the past I needed the power of two complex numbers only once, namely for the [http://www.math.uni-bremen.de/~thielema/Research/cwt.pdf Cauchy wavelet] (see also: [http://ieeexplore.ieee.org/iel5/78/18506/00852022.pdf?arnumber=852022]): | In the past I needed the power of two complex numbers only once, namely for the [http://www.math.uni-bremen.de/~thielema/Research/cwt.pdf Cauchy wavelet] (see also: [http://ieeexplore.ieee.org/iel5/78/18506/00852022.pdf?arnumber=852022]): | ||

: <math> f(t) = (1- i\cdot k\cdot t) ^ {-\frac{1}{2} + \frac{\mu_2}{k} + i\cdot \mu_1 } </math> | : <math> f(t) = (1- i\cdot k\cdot t) ^ {-\frac{1}{2} + \frac{\mu_2}{k} + i\cdot \mu_1 } </math> | ||

− | + | However, I could not use the built-in complex power function | |

because the resulting function became discontinuous. | because the resulting function became discontinuous. | ||

Of course, powers of complex numbers have the problem of branch cuts and | Of course, powers of complex numbers have the problem of branch cuts and |

## Revision as of 15:36, 18 December 2007

## 1 Question

Why are there several notions of power in Haskell, namely

## 2 Answer

The reason is that there is no definition for the power function which covers all exotic choices for basis and exponent.
It is even sensible to refine the set of power functions as it is done in the NumericPrelude project.
In mathematical notation we don't respect types and we do not distinguish between powers of different types.
However if we assume the most general types for both basis and exponent, the result of the power is no longer unique.
Actually all possible solutions of say 1^{x},
where *x* is irrational is dense in the complex unit circle.
In the past I needed the power of two complex numbers only once, namely for the Cauchy wavelet (see also: [1]):

However, I could not use the built-in complex power function because the resulting function became discontinuous. Of course, powers of complex numbers have the problem of branch cuts and the choice of the branch built into the implementation of the complex power is quite arbitrary and might be inappropriate.

But also for real numbers there are problems:

For computingand a real 10^{15}th root of − 1 does not exist.

So I propose some balancing: The more general the basis the less general the exponent and vice versa. I also think the following symbols are more systematic and intuitive. They are used in NumericPrelude.

basis type | provides | symbol | exponent type | definition |

any ring | * |
^ |
cardinal | repeated multiplication |

any field | / |
^- |
integer | multiplication and division |

an algebraic field | root |
^/ |
rational | list of polynomial zeros (length = denominator of the exponent) |

positive real | log |
^? | any ring with a notion of limit | exponential series |

- examples for rings are: Polynomials, Matrices, Residue classes
- examples for fields: Fractions of polynomials (rational functions), Residue classes with respect to irreducible divisors, in fact we do not need fields, we only need the division and associativity, thus invertible Matrices are fine

## 3 See also

- Haskell-Cafe: Proposal for restructuring Number classes