Math-Cephes
view release on metacpan or search on metacpan
lib/Math/Cephes.pm view on Meta::CPAN
my $h = ($b - $a) / $n / 8;
my $f = [];
for($count=0; $count <= 8*$n; $count++, $x+=$h) {
$f->[$count] = &$r($x);
}
$sum = Math::Cephes::simpsn_wrap($f, $count-1, $h);
my $test = abs($sum - $sumold);
return $sum if ($test < $abs or abs($test/$sum) < $rel);
$sumold = $sum;
}
warn("Math::Cephes::simpson: Maximum number $nmax of iterations reached");
return undef;
}
sub bernum {
my $i = shift;
die "Cannot exceed i=30" if (defined $i and $i > 30);
my $num = [split //, 0 x 30 ];
my $den = [split //, 0 x 30 ];
Math::Cephes::bernum_wrap($num, $den);
return defined $i ? (int($num->[$i]), int($den->[$i])) : ($num, $den);
lib/Math/Cephes.pod view on Meta::CPAN
x = a t
where
t = 1 - d - ndtri(p) sqrt(d)
and
d = 1/9a,
the routine performs up to 10 Newton iterations to find the
root of igamc(a,x) - p = 0.
ACCURACY:
Tested at random a, p in the intervals indicated.
a p Relative error:
arithmetic domain domain # trials peak rms
IEEE 0.5,100 0,0.5 100000 1.0e-14 1.7e-15
IEEE 0.01,0.5 0,0.5 100000 9.0e-14 3.4e-15
lib/Math/Cephes.pod view on Meta::CPAN
# double a, b, x, y, incbi();
$x = incbi( $a, $b, $y );
DESCRIPTION:
Given y, the function finds x such that
incbet( a, b, x ) = y .
The routine performs interval halving or Newton iterations to find the
root of incbet(a,b,x) - y = 0.
ACCURACY:
Relative error:
x a,b
arithmetic domain domain # trials peak rms
IEEE 0,1 .5,10000 50000 5.8e-12 1.3e-13
IEEE 0,1 .25,100 100000 1.8e-13 3.9e-15
IEEE 0,1 0,5 50000 1.1e-12 5.5e-15
lib/Math/Cephes.pod view on Meta::CPAN
This evaluates the area under the graph of a function,
represented in a subroutine, from $a to $b, using an 8-point
Newton-Cotes formula. The routine divides up the interval into
equal segments, evaluates the integral, then compares that
to the result with double the number of segments. If the two
results agree, to within an absolute error $abs_err or a
relative error $rel_err, the result is returned; otherwise,
the number of segments is doubled again, and the results
compared. This continues until the desired accuracy is attained,
or until the maximum number of iterations $nmax is reached.
=item I<vecang>: angle between two vectors
SYNOPSIS:
# double p[3], q[3], vecang();
$y = vecang( $p, $q );
DESCRIPTION:
libmd/igami.c view on Meta::CPAN
* x = a t
*
* where
*
* t = 1 - d - ndtri(p) sqrt(d)
*
* and
*
* d = 1/9a,
*
* the routine performs up to 10 Newton iterations to find the
* root of igamc(a,x) - p = 0.
*
* ACCURACY:
*
* Tested at random a, p in the intervals indicated.
*
* a p Relative error:
* arithmetic domain domain # trials peak rms
* IEEE 0.5,100 0,0.5 100000 1.0e-14 1.7e-15
* IEEE 0.01,0.5 0,0.5 100000 9.0e-14 3.4e-15
libmd/incbi.c view on Meta::CPAN
* x = incbi( a, b, y );
*
*
*
* DESCRIPTION:
*
* Given y, the function finds x such that
*
* incbet( a, b, x ) = y .
*
* The routine performs interval halving or Newton iterations to find the
* root of incbet(a,b,x) - y = 0.
*
*
* ACCURACY:
*
* Relative error:
* x a,b
* arithmetic domain domain # trials peak rms
* IEEE 0,1 .5,10000 50000 5.8e-12 1.3e-13
* IEEE 0,1 .25,100 100000 1.8e-13 3.9e-15
libmd/polmisc.c view on Meta::CPAN
/* If first nonzero coefficient was at degree n > 0, multiply by
x^(n/2). */
if (n > 0)
{
polclr (x, MAXPOL);
x[n/2] = 1.0;
polmul (x, nn, y, nn, y);
}
#if 0
/* Newton iterations */
for( n=0; n<10; n++ )
{
poldiv( y, nn, pol, nn, z );
poladd( y, nn, z, nn, y );
for( i=0; i<=nn; i++ )
y[i] *= 0.5;
for( i=0; i<=nn; i++ )
{
u = md_fabs( y[i] - z[i] );
if( u > 1.0e-15 )
libmd/sqrt.c view on Meta::CPAN
*/
#endif
#ifdef MIEEE
x = ldexp( x, (e >> 1) );
/*
*q += ((e >>1) & 0x7ff) << 4;
*q &= 077777;
*/
#endif
/* Newton iterations: */
#ifdef UNK
x = 0.5*(x + w/x);
x = 0.5*(x + w/x);
x = 0.5*(x + w/x);
#endif
/* Note, assume the square root cannot be denormal,
* so it is safe to use integer exponent operations here.
*/
#ifdef DEC
libmd/sqrt.c.src view on Meta::CPAN
*/
#endif
#ifdef MIEEE
x = ldexp( x, (e >> 1) );
/*
*q += ((e >>1) & 0x7ff) << 4;
*q &= 077777;
*/
#endif
/* Newton iterations: */
#ifdef UNK
x = 0.5*(x + w/x);
x = 0.5*(x + w/x);
x = 0.5*(x + w/x);
#endif
/* Note, assume the square root cannot be denormal,
* so it is safe to use integer exponent operations here.
*/
#ifdef DEC
x = a t
where
t = 1 - d - ndtri(p) sqrt(d)
and
d = 1/9a,
the routine performs up to 10 Newton iterations to find the
root of igamc(a,x) - p = 0.
',
'catan' => 'catan: Complex circular arc tangent
SYNOPSIS:
# void catan();
# cmplx z, w;
# double a, b, x, y, incbi();
$x = incbi( $a, $b, $y );
DESCRIPTION:
Given y, the function finds x such that
incbet( a, b, x ) = y .
The routine performs interval halving or Newton iterations to find the
root of incbet(a,b,x) - y = 0.
',
'round' => 'round: Round double to nearest or even integer valued double
SYNOPSIS:
# double x, y, round();
$y = round( $x );
( run in 2.460 seconds using v1.01-cache-2.11-cpan-71847e10f99 )