Blame doc/specfunc-pow-int.rst
|
Packit |
67cb25 |
.. index::
|
|
Packit |
67cb25 |
single: power function
|
|
Packit |
67cb25 |
single: integer powers
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
The following functions are equivalent to the function :func:`gsl_pow_int`
|
|
Packit |
67cb25 |
with an error estimate. These functions are
|
|
Packit |
67cb25 |
declared in the header file :file:`gsl_sf_pow_int.h`.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. function:: double gsl_sf_pow_int (double x, int n)
|
|
Packit |
67cb25 |
int gsl_sf_pow_int_e (double x, int n, gsl_sf_result * result)
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
These routines compute the power :math:`x^n` for integer :data:`n`. The
|
|
Packit |
67cb25 |
power is computed using the minimum number of multiplications. For
|
|
Packit |
67cb25 |
example, :math:`x^8` is computed as :math:`((x^2)^2)^2`, requiring only 3
|
|
Packit |
67cb25 |
multiplications. For reasons of efficiency, these functions do not
|
|
Packit |
67cb25 |
check for overflow or underflow conditions. The following is a simple example::
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
#include <gsl/gsl_sf_pow_int.h>
|
|
Packit |
67cb25 |
/* compute 3.0**12 */
|
|
Packit |
67cb25 |
double y = gsl_sf_pow_int(3.0, 12);
|