pqc/external/flint-2.4.3/double_extras/doc/double_extras.txt
2014-05-24 23:16:06 +02:00

72 lines
2.7 KiB
Plaintext

/*=============================================================================
This file is part of FLINT.
FLINT is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
FLINT is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with FLINT; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
=============================================================================*/
/******************************************************************************
Copyright (C) 2012 Fredrik Johansson
******************************************************************************/
*******************************************************************************
Random functions
*******************************************************************************
double d_randtest(flint_rand_t state)
Returns a random number in the interval $[0.5, 1)$.
*******************************************************************************
Arithmetic
*******************************************************************************
double d_polyval(const double * poly, int len, double x)
Uses Horner's rule to evaluate the the polynomial defined by the given
\code{len} coefficients. Requires that \code{len} is nonzero.
*******************************************************************************
Special functions
*******************************************************************************
double d_lambertw(double x)
Computes the principal branch of the Lambert W function, solving
the equation $x = W(x) \exp(W(x))$. If $x < -1/e$, the solution is
complex, and NaN is returned.
Depending on the magnitude of $x$, we start from a piecewise rational
approximation or a zeroth-order truncation of the asymptotic expansion
at infinity, and perform 0, 1 or 2 iterations with Halley's
method to obtain full accuracy.
A test of $10^7$ random inputs showed a maximum relative error smaller
than 0.95 times \code{DBL_EPSILON} ($2^{-52}$) for positive $x$.
Accuracy for negative $x$ is slightly worse, and can grow to
about 10 times \code{DBL_EPSILON} close to $-1/e$.
However, accuracy may be worse depending on compiler flags and
the accuracy of the system libm functions.