This file is indexed.

/usr/share/doc/libghc-math-functions-doc/html/math-functions.txt is in libghc-math-functions-doc 0.2.1.0-1build1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Special functions and Chebyshev polynomials
--   
--   This library provides implementations of special mathematical
--   functions and Chebyshev polynomials. These functions are often useful
--   in statistical and numerical computing.
@package math-functions
@version 0.2.1.0


-- | Functions for summing floating point numbers more accurately than the
--   naive <a>sum</a> function and its counterparts in the <tt>vector</tt>
--   package and elsewhere.
--   
--   When used with floating point numbers, in the worst case, the
--   <a>sum</a> function accumulates numeric error at a rate proportional
--   to the number of values being summed. The algorithms in this module
--   implement different methods of /compensated summation/, which reduce
--   the accumulation of numeric error so that it either grows much more
--   slowly than the number of inputs (e.g. logarithmically), or remains
--   constant.
module Numeric.Sum

-- | A class for summation of floating point numbers.
class Summation s where sum f = f . foldl' add zero

-- | The identity for summation.
zero :: Summation s => s

-- | Add a value to a sum.
add :: Summation s => s -> Double -> s

-- | Sum a collection of values.
--   
--   Example: <tt>foo = <a>sum</a> <a>kbn</a> [1,2,3]</tt>
sum :: (Summation s, Foldable f) => (s -> Double) -> f Double -> Double

-- | <i>O(n)</i> Sum a vector of values.
sumVector :: (Vector v Double, Summation s) => (s -> Double) -> v Double -> Double

-- | Kahan-Babuška-Neumaier summation. This is a little more
--   computationally costly than plain Kahan summation, but is
--   <i>always</i> at least as accurate.
data KBNSum
KBNSum :: {-# UNPACK #-} !Double -> {-# UNPACK #-} !Double -> KBNSum

-- | Return the result of a Kahan-Babuška-Neumaier sum.
kbn :: KBNSum -> Double

-- | Second-order Kahan-Babuška summation. This is more computationally
--   costly than Kahan-Babuška-Neumaier summation, running at about a third
--   the speed. Its advantage is that it can lose less precision (in
--   admittedly obscure cases).
--   
--   This method compensates for error in both the sum and the first-order
--   compensation term, hence the use of "second order" in the name.
data KB2Sum
KB2Sum :: {-# UNPACK #-} !Double -> {-# UNPACK #-} !Double -> {-# UNPACK #-} !Double -> KB2Sum

-- | Return the result of an order-2 Kahan-Babuška sum.
kb2 :: KB2Sum -> Double

-- | Kahan summation. This is the least accurate of the compensated
--   summation methods. In practice, it only beats naive summation for
--   inputs with large magnitude. Kahan summation can be <i>less</i>
--   accurate than naive summation for small-magnitude inputs.
--   
--   This summation method is included for completeness. Its use is not
--   recommended. In practice, <a>KBNSum</a> is both 30% faster and more
--   accurate.
data KahanSum
KahanSum :: {-# UNPACK #-} !Double -> {-# UNPACK #-} !Double -> KahanSum

-- | Return the result of a Kahan sum.
kahan :: KahanSum -> Double

-- | <i>O(n)</i> Sum a vector of values using pairwise summation.
--   
--   This approach is perhaps 10% faster than <a>KBNSum</a>, but has poorer
--   bounds on its error growth. Instead of having roughly constant error
--   regardless of the size of the input vector, in the worst case its
--   accumulated error grows with <i>O(log n)</i>.
pairwiseSum :: (Vector v Double) => v Double -> Double
instance Data.Vector.Unboxed.Base.Unbox Numeric.Sum.KB2Sum
instance Data.Vector.Generic.Mutable.Base.MVector Data.Vector.Unboxed.Base.MVector Numeric.Sum.KB2Sum
instance Data.Vector.Generic.Base.Vector Data.Vector.Unboxed.Base.Vector Numeric.Sum.KB2Sum
instance Numeric.Sum.Summation Numeric.Sum.KB2Sum
instance Control.DeepSeq.NFData Numeric.Sum.KB2Sum
instance Data.Data.Data Numeric.Sum.KB2Sum
instance GHC.Show.Show Numeric.Sum.KB2Sum
instance GHC.Classes.Eq Numeric.Sum.KB2Sum
instance Data.Vector.Unboxed.Base.Unbox Numeric.Sum.KBNSum
instance Data.Vector.Generic.Mutable.Base.MVector Data.Vector.Unboxed.Base.MVector Numeric.Sum.KBNSum
instance Data.Vector.Generic.Base.Vector Data.Vector.Unboxed.Base.Vector Numeric.Sum.KBNSum
instance Numeric.Sum.Summation Numeric.Sum.KBNSum
instance Control.DeepSeq.NFData Numeric.Sum.KBNSum
instance Data.Data.Data Numeric.Sum.KBNSum
instance GHC.Show.Show Numeric.Sum.KBNSum
instance GHC.Classes.Eq Numeric.Sum.KBNSum
instance Data.Vector.Unboxed.Base.Unbox Numeric.Sum.KahanSum
instance Data.Vector.Generic.Mutable.Base.MVector Data.Vector.Unboxed.Base.MVector Numeric.Sum.KahanSum
instance Data.Vector.Generic.Base.Vector Data.Vector.Unboxed.Base.Vector Numeric.Sum.KahanSum
instance Numeric.Sum.Summation Numeric.Sum.KahanSum
instance Control.DeepSeq.NFData Numeric.Sum.KahanSum
instance Data.Data.Data Numeric.Sum.KahanSum
instance GHC.Show.Show Numeric.Sum.KahanSum
instance GHC.Classes.Eq Numeric.Sum.KahanSum
instance Numeric.Sum.Summation GHC.Types.Double


-- | Chebyshev polynomials.
module Numeric.Polynomial.Chebyshev

-- | Evaluate a Chebyshev polynomial of the first kind. Uses Clenshaw's
--   algorithm.
chebyshev :: (Vector v Double) => Double -> v Double -> Double

-- | Evaluate a Chebyshev polynomial of the first kind. Uses Broucke's
--   ECHEB algorithm, and his convention for coefficient handling. It treat
--   0th coefficient different so
--   
--   <pre>
--   chebyshev x [a0,a1,a2...] == chebyshevBroucke [2*a0,a1,a2...]
--   </pre>
chebyshevBroucke :: (Vector v Double) => Double -> v Double -> Double


-- | Function for evaluating polynomials using Horher's method.
module Numeric.Polynomial

-- | Evaluate polynomial using Horner's method. Coefficients starts from
--   lowest. In pseudocode:
--   
--   <pre>
--   evaluateOddPolynomial x [1,2,3] = 1 + 2*x + 3*x^2
--   </pre>
evaluatePolynomial :: (Vector v a, Num a) => a -> v a -> a

-- | Evaluate polynomial with only even powers using Horner's method.
--   Coefficients starts from lowest. In pseudocode:
--   
--   <pre>
--   evaluateOddPolynomial x [1,2,3] = 1 + 2*x^2 + 3*x^4
--   </pre>
evaluateEvenPolynomial :: (Vector v a, Num a) => a -> v a -> a

-- | Evaluate polynomial with only odd powers using Horner's method.
--   Coefficients starts from lowest. In pseudocode:
--   
--   <pre>
--   evaluateOddPolynomial x [1,2,3] = 1*x + 2*x^3 + 3*x^5
--   </pre>
evaluateOddPolynomial :: (Vector v a, Num a) => a -> v a -> a
evaluatePolynomialL :: (Num a) => a -> [a] -> a
evaluateEvenPolynomialL :: (Num a) => a -> [a] -> a
evaluateOddPolynomialL :: (Num a) => a -> [a] -> a


-- | Constant values common to much numeric code.
module Numeric.MathFunctions.Constants

-- | The smallest <a>Double</a> ε such that 1 + ε ≠ 1.
m_epsilon :: Double

-- | Largest representable finite value.
m_huge :: Double

-- | The smallest representable positive normalized value.
m_tiny :: Double

-- | The largest <a>Int</a> <i>x</i> such that 2**(<i>x</i>-1) is
--   approximately representable as a <a>Double</a>.
m_max_exp :: Int

-- | Positive infinity.
m_pos_inf :: Double

-- | Negative infinity.
m_neg_inf :: Double

-- | Not a number.
m_NaN :: Double

-- | Maximum possible finite value of <tt>log x</tt>
m_max_log :: Double

-- | Logarithm of smallest normalized double (<a>m_tiny</a>)
m_min_log :: Double

-- | <pre>
--   1 / sqrt 2
--   </pre>
m_1_sqrt_2 :: Double

-- | <pre>
--   2 / sqrt pi
--   </pre>
m_2_sqrt_pi :: Double

-- | <pre>
--   log(sqrt((2*pi))
--   </pre>
m_ln_sqrt_2_pi :: Double

-- | <pre>
--   sqrt 2
--   </pre>
m_sqrt_2 :: Double

-- | <pre>
--   sqrt (2 * pi)
--   </pre>
m_sqrt_2_pi :: Double

-- | Euler–Mascheroni constant (γ = 0.57721...)
m_eulerMascheroni :: Double


-- | Functions for working with infinite sequences. In particular summation
--   of series and evaluation of continued fractions.
module Numeric.Series

-- | Infinite series. It's represented as opaque state and step function.
data Sequence a
Sequence :: s -> (s -> (a, s)) -> Sequence a

-- | <tt>enumSequenceFrom x</tt> generate sequence:
--   
--   &lt;math&gt;
enumSequenceFrom :: Num a => a -> Sequence a

-- | <tt>enumSequenceFromStep x d</tt> generate sequence:
--   
--   &lt;math&gt;
enumSequenceFromStep :: Num a => a -> a -> Sequence a

-- | Analog of <a>scanl</a> for sequence.
scanSequence :: (b -> a -> b) -> b -> Sequence a -> Sequence b

-- | Calculate sum of series
--   
--   &lt;math&gt;
--   
--   Summation is stopped when
--   
--   &lt;math&gt;
--   
--   where ε is machine precision (<a>m_epsilon</a>)
sumSeries :: Sequence Double -> Double

-- | Calculate sum of series
--   
--   &lt;math&gt;
--   
--   Calculation is stopped when next value in series is less than ε·sum.
sumPowerSeries :: Double -> Sequence Double -> Double

-- | Convert series to infinite list
sequenceToList :: Sequence a -> [a]

-- | Evaluate continued fraction using modified Lentz algorithm. Sequence
--   contain pairs (a[i],b[i]) which form following expression:
--   
--   &lt;math&gt;
--   
--   Modified Lentz algorithm is described in Numerical recipes 5.2
--   "Evaluation of Continued Fractions"
evalContFractionB :: Sequence (Double, Double) -> Double
instance GHC.Base.Functor Numeric.Series.Sequence
instance GHC.Base.Applicative Numeric.Series.Sequence
instance GHC.Num.Num a => GHC.Num.Num (Numeric.Series.Sequence a)
instance GHC.Real.Fractional a => GHC.Real.Fractional (Numeric.Series.Sequence a)


-- | Functions for approximate comparison of floating point numbers.
--   
--   Approximate floating point comparison, based on Bruce Dawson's
--   "Comparing floating point numbers":
--   <a>http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm</a>
module Numeric.MathFunctions.Comparison

-- | Calculate relative error of two numbers:
--   
--   &lt;math&gt;
--   
--   It lies in [0,1) interval for numbers with same sign and (1,2] for
--   numbers with different sign. If both arguments are zero or negative
--   zero function returns 0. If at least one argument is transfinite it
--   returns NaN
relativeError :: Double -> Double -> Double

-- | Check that relative error between two numbers <tt>a</tt> and
--   <tt>b</tt>. If <a>relativeError</a> returns NaN it returns
--   <tt>False</tt>.
eqRelErr :: Double -> Double -> Double -> Bool

-- | Add N ULPs (units of least precision) to <tt>Double</tt> number.
addUlps :: Int -> Double -> Double

-- | Measure distance between two <tt>Double</tt>s in ULPs (units of least
--   precision). Note that it's different from <tt>abs (ulpDelta a b)</tt>
--   since it returns correct result even when <a>ulpDelta</a> overflows.
ulpDistance :: Double -> Double -> Word64

-- | Measure signed distance between two <tt>Double</tt>s in ULPs (units of
--   least precision). Note that unlike <a>ulpDistance</a> it can overflow.
--   
--   <pre>
--   &gt;&gt;&gt; ulpDelta 1 (1 + m_epsilon)
--   1
--   </pre>
ulpDelta :: Double -> Double -> Int64

-- | Compare two <a>Double</a> values for approximate equality, using
--   Dawson's method.
--   
--   The required accuracy is specified in ULPs (units of least precision).
--   If the two numbers differ by the given number of ULPs or less, this
--   function returns <tt>True</tt>.
within :: Int -> Double -> Double -> Bool


-- | Haskell functions for finding the roots of real functions of real
--   arguments.
module Numeric.RootFinding

-- | The result of searching for a root of a mathematical function.
data Root a

-- | The function does not have opposite signs when evaluated at the lower
--   and upper bounds of the search.
NotBracketed :: Root a

-- | The search failed to converge to within the given error tolerance
--   after the given number of iterations.
SearchFailed :: Root a

-- | A root was successfully found.
Root :: a -> Root a

-- | Returns either the result of a search for a root, or the default value
--   if the search failed.
fromRoot :: a -> Root a -> a

-- | Use the method of Ridders to compute a root of a function.
--   
--   The function must have opposite signs when evaluated at the lower and
--   upper bounds of the search (i.e. the root must be bracketed).
ridders :: Double -> (Double, Double) -> (Double -> Double) -> Root Double

-- | Solve equation using Newton-Raphson iterations.
--   
--   This method require both initial guess and bounds for root. If Newton
--   step takes us out of bounds on root function reverts to bisection.
newtonRaphson :: Double -> (Double, Double, Double) -> (Double -> (Double, Double)) -> Root Double
instance GHC.Generics.Generic (Numeric.RootFinding.Root a)
instance Data.Data.Data a => Data.Data.Data (Numeric.RootFinding.Root a)
instance GHC.Show.Show a => GHC.Show.Show (Numeric.RootFinding.Root a)
instance GHC.Read.Read a => GHC.Read.Read (Numeric.RootFinding.Root a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Numeric.RootFinding.Root a)
instance GHC.Base.Functor Numeric.RootFinding.Root
instance GHC.Base.Monad Numeric.RootFinding.Root
instance GHC.Base.MonadPlus Numeric.RootFinding.Root
instance GHC.Base.Applicative Numeric.RootFinding.Root
instance GHC.Base.Alternative Numeric.RootFinding.Root


-- | Special functions and factorials.
module Numeric.SpecFunctions

-- | Error function.
--   
--   &lt;math&gt;
--   
--   Function limits are:
--   
--   [ begin{aligned} &amp;operatorname{erf}(-infty) &amp;=&amp; -1 --
--   &amp;operatorname{erf}(0) &amp;=&amp; phantom{-},0 --
--   &amp;operatorname{erf}(+infty) &amp;=&amp; phantom{-},1 --
--   end{aligned}
erf :: Double -> Double

-- | Complementary error function.
--   
--   &lt;math&gt;
--   
--   Function limits are:
--   
--   [ begin{aligned} &amp;operatorname{erf}(-infty) &amp;=&amp;, 2 --
--   &amp;operatorname{erf}(0) &amp;=&amp;, 1 --
--   &amp;operatorname{erf}(+infty) &amp;=&amp;, 0 -- end{aligned}
erfc :: Double -> Double

-- | Inverse of <a>erf</a>.
invErf :: Double -> Double

-- | Inverse of <a>erfc</a>.
invErfc :: Double -> Double

-- | Compute the logarithm of the gamma function, Γ(<i>x</i>).
--   
--   &lt;math&gt;
--   
--   This implementation uses Lanczos approximation. It gives 14 or more
--   significant decimal digits, except around <i>x</i> = 1 and <i>x</i> =
--   2, where the function goes to zero.
--   
--   Returns ∞ if the input is outside of the range (0 &lt; <i>x</i> ≤
--   1e305).
logGamma :: Double -> Double

-- | Synonym for <a>logGamma</a>. Retained for compatibility
logGammaL :: Double -> Double

-- | Compute the normalized lower incomplete gamma function
--   γ(<i>z</i>,<i>x</i>). Normalization means that γ(<i>z</i>,∞)=1
--   
--   &lt;math&gt;
--   
--   Uses Algorithm AS 239 by Shea.
incompleteGamma :: Double -> Double -> Double

-- | Inverse incomplete gamma function. It's approximately inverse of
--   <a>incompleteGamma</a> for the same <i>z</i>. So following equality
--   approximately holds:
--   
--   <pre>
--   invIncompleteGamma z . incompleteGamma z ≈ id
--   </pre>
invIncompleteGamma :: Double -> Double -> Double

-- | Compute ψ(<i>x</i>), the first logarithmic derivative of the gamma
--   function.
--   
--   &lt;math&gt;
--   
--   Uses Algorithm AS 103 by Bernardo, based on Minka's C implementation.
digamma :: Double -> Double

-- | Compute the natural logarithm of the beta function.
--   
--   &lt;math&gt;
logBeta :: Double -> Double -> Double

-- | Regularized incomplete beta function.
--   
--   &lt;math&gt;
--   
--   Uses algorithm AS63 by Majumder and Bhattachrjee and quadrature
--   approximation for large <i>p</i> and <i>q</i>.
incompleteBeta :: Double -> Double -> Double -> Double

-- | Regularized incomplete beta function. Same as <a>incompleteBeta</a>
--   but also takes logarithm of beta function as parameter.
incompleteBeta_ :: Double -> Double -> Double -> Double -> Double

-- | Compute inverse of regularized incomplete beta function. Uses initial
--   approximation from AS109, AS64 and Halley method to solve equation.
invIncompleteBeta :: Double -> Double -> Double -> Double

-- | Compute sinc function <tt>sin(x)/x</tt>
sinc :: Double -> Double

-- | <tt><a>log1p</a> x</tt> computes <tt><a>log</a> (1 + x)</tt>, but
--   provides more precise results for small (absolute) values of
--   <tt>x</tt> if possible.
log1p :: Floating a => a -> a

-- | Compute log(1+x)-x:
log1pmx :: Double -> Double

-- | <i>O(log n)</i> Compute the logarithm in base 2 of the given value.
log2 :: Int -> Int

-- | <tt><a>expm1</a> x</tt> computes <tt><a>exp</a> x - 1</tt>, but
--   provides more precise results for small (absolute) values of
--   <tt>x</tt> if possible.
expm1 :: Floating a => a -> a

-- | Compute the factorial function <i>n</i>!. Returns +∞ if the input is
--   above 170 (above which the result cannot be represented by a 64-bit
--   <a>Double</a>).
factorial :: Int -> Double

-- | Compute the natural logarithm of the factorial function. Gives 16
--   decimal digits of precision.
logFactorial :: Integral a => a -> Double

-- | Calculate the error term of the Stirling approximation. This is only
--   defined for non-negative values.
--   
--   &lt;math&gt;
stirlingError :: Double -> Double

-- | Compute the binomial coefficient <i>n</i> <tt>`<a>choose</a>`</tt>
--   <i>k</i>. For values of <i>k</i> &gt; 50, this uses an approximation
--   for performance reasons. The approximation is accurate to 12 decimal
--   places in the worst case
--   
--   Example:
--   
--   <pre>
--   7 `choose` 3 == 35
--   </pre>
choose :: Int -> Int -> Double

-- | Compute logarithm of the binomial coefficient.
logChoose :: Int -> Int -> Double


-- | Less common mathematical functions.
module Numeric.SpecFunctions.Extra

-- | Evaluate the deviance term <tt>x log(x/np) + np - x</tt>.
bd0 :: Double -> Double -> Double

-- | Calculate binomial coefficient using exact formula
chooseExact :: Int -> Int -> Double

-- | Quickly compute the natural logarithm of <i>n</i>
--   <tt><a>choose</a></tt> <i>k</i>, with no checking.
--   
--   Less numerically stable:
--   
--   <pre>
--   exp $ lg (n+1) - lg (k+1) - lg (n-k+1)
--     where lg = logGamma . fromIntegral
--   </pre>
logChooseFast :: Double -> Double -> Double

-- | Compute the logarithm of the gamma function Γ(<i>x</i>). Uses
--   Algorithm AS 245 by Macleod.
--   
--   Gives an accuracy of 10-12 significant decimal digits, except for
--   small regions around <i>x</i> = 1 and <i>x</i> = 2, where the function
--   goes to zero. For greater accuracy, use <tt>logGammaL</tt>.
--   
--   Returns ∞ if the input is outside of the range (0 &lt; <i>x</i> ≤
--   1e305).
logGammaAS245 :: Double -> Double

-- | Compute the log gamma correction factor for Stirling approximation for
--   <tt>x</tt> ≥ 10. This correction factor is suitable for an alternate
--   (but less numerically accurate) definition of <a>logGamma</a>:
--   
--   &lt;math&gt;
logGammaCorrection :: Double -> Double