fix(integrate): name IntegrateFunction in quadrature errors
This commit is contained in:
+7
-7
@@ -25,8 +25,8 @@ import (
|
||||
// rational substitution before the rule runs; an integrand over an
|
||||
// infinite interval has to decay to zero for this to converge.
|
||||
|
||||
// QuadratureOptions tunes Integrate. RelTol ≤ 0 means 1e-10, AbsTol
|
||||
// ≤ 0 means 1e-12, MaxIntervals ≤ 0 means 256.
|
||||
// QuadratureOptions tunes IntegrateFunction. RelTol ≤ 0 means 1e-10,
|
||||
// AbsTol ≤ 0 means 1e-12, MaxIntervals ≤ 0 means 256.
|
||||
type QuadratureOptions struct {
|
||||
RelTol float64
|
||||
AbsTol float64
|
||||
@@ -131,7 +131,7 @@ func IntegrateFunction(f func(x float64) (float64, error), a, b float64, opts Qu
|
||||
opts.MaxIntervals = 256
|
||||
}
|
||||
if math.IsNaN(a) || math.IsNaN(b) {
|
||||
return 0, 0, base.Errf("Integrate: bounds must not be NaN")
|
||||
return 0, 0, base.Errf("IntegrateFunction: bounds must not be NaN")
|
||||
}
|
||||
sign := 1.0
|
||||
if b < a {
|
||||
@@ -229,7 +229,7 @@ func IntegrateFunction(f func(x float64) (float64, error), a, b float64, opts Qu
|
||||
|
||||
first, err := measure(lo, hi)
|
||||
if err != nil {
|
||||
return 0, 0, base.Errf("Integrate: %w", err)
|
||||
return 0, 0, base.Errf("IntegrateFunction: %w", err)
|
||||
}
|
||||
leaves := []leaf{first}
|
||||
budget := func() (total, errSum float64) {
|
||||
@@ -242,7 +242,7 @@ func IntegrateFunction(f func(x float64) (float64, error), a, b float64, opts Qu
|
||||
value, errSum := budget()
|
||||
for errSum > math.Max(opts.AbsTol, opts.RelTol*math.Abs(value)) {
|
||||
if len(leaves) >= opts.MaxIntervals {
|
||||
return 0, 0, base.Errf("Integrate: error estimate %g exceeds the tolerance within %d subintervals",
|
||||
return 0, 0, base.Errf("IntegrateFunction: error estimate %g exceeds the tolerance within %d subintervals",
|
||||
errSum, opts.MaxIntervals)
|
||||
}
|
||||
// Bisect the leaf that contributes the most error.
|
||||
@@ -255,11 +255,11 @@ func IntegrateFunction(f func(x float64) (float64, error), a, b float64, opts Qu
|
||||
w := leaves[worst]
|
||||
left, lerr := measure(w.l, (w.l+w.r)/2)
|
||||
if lerr != nil {
|
||||
return 0, 0, base.Errf("Integrate: %w", lerr)
|
||||
return 0, 0, base.Errf("IntegrateFunction: %w", lerr)
|
||||
}
|
||||
right, rerr := measure((w.l+w.r)/2, w.r)
|
||||
if rerr != nil {
|
||||
return 0, 0, base.Errf("Integrate: %w", rerr)
|
||||
return 0, 0, base.Errf("IntegrateFunction: %w", rerr)
|
||||
}
|
||||
leaves[worst] = left
|
||||
leaves = append(leaves, right)
|
||||
|
||||
Reference in New Issue
Block a user