Average Error: 2.0 → 0.3
Time: 27.7s
Precision: binary64
Cost: 26368
\[x \cdot e^{y \cdot \left(\log z - t\right) + a \cdot \left(\log \left(1 - z\right) - b\right)} \]
\[x \cdot e^{\mathsf{fma}\left(a, \mathsf{log1p}\left(-z\right) - b, y \cdot \left(\log z - t\right)\right)} \]
(FPCore (x y z t a b)
 :precision binary64
 (* x (exp (+ (* y (- (log z) t)) (* a (- (log (- 1.0 z)) b))))))
(FPCore (x y z t a b)
 :precision binary64
 (* x (exp (fma a (- (log1p (- z)) b) (* y (- (log z) t))))))
double code(double x, double y, double z, double t, double a, double b) {
	return x * exp(((y * (log(z) - t)) + (a * (log((1.0 - z)) - b))));
}
double code(double x, double y, double z, double t, double a, double b) {
	return x * exp(fma(a, (log1p(-z) - b), (y * (log(z) - t))));
}
function code(x, y, z, t, a, b)
	return Float64(x * exp(Float64(Float64(y * Float64(log(z) - t)) + Float64(a * Float64(log(Float64(1.0 - z)) - b)))))
end
function code(x, y, z, t, a, b)
	return Float64(x * exp(fma(a, Float64(log1p(Float64(-z)) - b), Float64(y * Float64(log(z) - t)))))
end
code[x_, y_, z_, t_, a_, b_] := N[(x * N[Exp[N[(N[(y * N[(N[Log[z], $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision] + N[(a * N[(N[Log[N[(1.0 - z), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_, b_] := N[(x * N[Exp[N[(a * N[(N[Log[1 + (-z)], $MachinePrecision] - b), $MachinePrecision] + N[(y * N[(N[Log[z], $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
x \cdot e^{y \cdot \left(\log z - t\right) + a \cdot \left(\log \left(1 - z\right) - b\right)}
x \cdot e^{\mathsf{fma}\left(a, \mathsf{log1p}\left(-z\right) - b, y \cdot \left(\log z - t\right)\right)}

Error

Derivation

  1. Initial program 2.0

    \[x \cdot e^{y \cdot \left(\log z - t\right) + a \cdot \left(\log \left(1 - z\right) - b\right)} \]
  2. Simplified0.3

    \[\leadsto \color{blue}{x \cdot e^{\mathsf{fma}\left(a, \mathsf{log1p}\left(-z\right) - b, y \cdot \left(\log z - t\right)\right)}} \]
    Proof
    (*.f64 x (exp.f64 (fma.f64 a (-.f64 (log1p.f64 (neg.f64 z)) b) (*.f64 y (-.f64 (log.f64 z) t))))): 0 points increase in error, 0 points decrease in error
    (*.f64 x (exp.f64 (fma.f64 a (-.f64 (Rewrite<= log1p-def_binary64 (log.f64 (+.f64 1 (neg.f64 z)))) b) (*.f64 y (-.f64 (log.f64 z) t))))): 2 points increase in error, 0 points decrease in error
    (*.f64 x (exp.f64 (fma.f64 a (-.f64 (log.f64 (Rewrite<= sub-neg_binary64 (-.f64 1 z))) b) (*.f64 y (-.f64 (log.f64 z) t))))): 0 points increase in error, 0 points decrease in error
    (*.f64 x (exp.f64 (Rewrite<= fma-def_binary64 (+.f64 (*.f64 a (-.f64 (log.f64 (-.f64 1 z)) b)) (*.f64 y (-.f64 (log.f64 z) t)))))): 0 points increase in error, 0 points decrease in error
    (*.f64 x (exp.f64 (Rewrite<= +-commutative_binary64 (+.f64 (*.f64 y (-.f64 (log.f64 z) t)) (*.f64 a (-.f64 (log.f64 (-.f64 1 z)) b)))))): 0 points increase in error, 0 points decrease in error
  3. Final simplification0.3

    \[\leadsto x \cdot e^{\mathsf{fma}\left(a, \mathsf{log1p}\left(-z\right) - b, y \cdot \left(\log z - t\right)\right)} \]

Alternatives

Alternative 1
Error2.0
Cost20160
\[x \cdot e^{y \cdot \left(\log z - t\right) + a \cdot \left(\log \left(1 - z\right) - b\right)} \]
Alternative 2
Error8.8
Cost7444
\[\begin{array}{l} t_1 := x \cdot e^{b \cdot \left(-a\right)}\\ t_2 := x \cdot e^{t \cdot \left(-y\right)}\\ \mathbf{if}\;y \leq -2.05 \cdot 10^{+27}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq -3.2 \cdot 10^{-45}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -8.5 \cdot 10^{-58}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq -4 \cdot 10^{-85}:\\ \;\;\;\;x \cdot e^{z \cdot \left(-a\right)}\\ \mathbf{elif}\;y \leq 0.00076:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x \cdot {z}^{y}\\ \end{array} \]
Alternative 3
Error21.6
Cost7180
\[\begin{array}{l} \mathbf{if}\;y \leq -2.05 \cdot 10^{+27}:\\ \;\;\;\;b \cdot \left(x \cdot \left(\left(a \cdot a\right) \cdot \left(b \cdot 0.5\right)\right)\right)\\ \mathbf{elif}\;y \leq -2 \cdot 10^{-200}:\\ \;\;\;\;\left(1 + \left(x + x \cdot \left(y \cdot t\right)\right)\right) + -1\\ \mathbf{elif}\;y \leq 6.5 \cdot 10^{-77}:\\ \;\;\;\;x \cdot e^{z \cdot \left(-a\right)}\\ \mathbf{else}:\\ \;\;\;\;x \cdot {z}^{y}\\ \end{array} \]
Alternative 4
Error14.3
Cost7180
\[\begin{array}{l} t_1 := x \cdot e^{t \cdot \left(-y\right)}\\ \mathbf{if}\;y \leq -4.3 \cdot 10^{-212}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 7.8 \cdot 10^{-162}:\\ \;\;\;\;x \cdot e^{z \cdot \left(-a\right)}\\ \mathbf{elif}\;y \leq 1.5 \cdot 10^{-14}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x \cdot {z}^{y}\\ \end{array} \]
Alternative 5
Error6.9
Cost7176
\[\begin{array}{l} \mathbf{if}\;y \leq -2.05 \cdot 10^{+27}:\\ \;\;\;\;x \cdot e^{t \cdot \left(-y\right)}\\ \mathbf{elif}\;y \leq 3600000:\\ \;\;\;\;x \cdot e^{\left(z + b\right) \cdot \left(-a\right)}\\ \mathbf{else}:\\ \;\;\;\;x \cdot {z}^{y}\\ \end{array} \]
Alternative 6
Error23.9
Cost6920
\[\begin{array}{l} \mathbf{if}\;y \leq -2.05 \cdot 10^{+27}:\\ \;\;\;\;b \cdot \left(x \cdot \left(\left(a \cdot a\right) \cdot \left(b \cdot 0.5\right)\right)\right)\\ \mathbf{elif}\;y \leq -1.6 \cdot 10^{-191}:\\ \;\;\;\;\left(1 + \left(x + x \cdot \left(y \cdot t\right)\right)\right) + -1\\ \mathbf{else}:\\ \;\;\;\;x \cdot {z}^{y}\\ \end{array} \]
Alternative 7
Error40.9
Cost1628
\[\begin{array}{l} t_1 := \left(1 + \left(x + x \cdot \left(y \cdot t\right)\right)\right) + -1\\ \mathbf{if}\;b \leq -3.1 \cdot 10^{+99}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \leq -3.9 \cdot 10^{-125}:\\ \;\;\;\;x\\ \mathbf{elif}\;b \leq -1.65 \cdot 10^{-178}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \leq -2.6 \cdot 10^{-265}:\\ \;\;\;\;x\\ \mathbf{elif}\;b \leq 7.5 \cdot 10^{-251}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \leq 2.75 \cdot 10^{-154}:\\ \;\;\;\;x - y \cdot \left(x \cdot t\right)\\ \mathbf{elif}\;b \leq 0.036:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error34.8
Cost1356
\[\begin{array}{l} t_1 := b \cdot \left(x \cdot \left(\left(a \cdot a\right) \cdot \left(b \cdot 0.5\right)\right)\right)\\ \mathbf{if}\;y \leq -2.05 \cdot 10^{+27}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -1.6 \cdot 10^{-191}:\\ \;\;\;\;\left(1 + \left(x + x \cdot \left(y \cdot t\right)\right)\right) + -1\\ \mathbf{elif}\;y \leq 1.3 \cdot 10^{-27}:\\ \;\;\;\;x - \left(y \cdot t\right) \cdot \left(x + \left(y \cdot t\right) \cdot \left(x \cdot -0.5\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Error37.4
Cost1100
\[\begin{array}{l} t_1 := b \cdot \left(a \cdot \left(x \cdot \left(a \cdot \left(b \cdot 0.5\right)\right)\right)\right)\\ \mathbf{if}\;y \leq -2.05 \cdot 10^{+27}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -2 \cdot 10^{-200}:\\ \;\;\;\;\left(1 + \left(x + x \cdot \left(y \cdot t\right)\right)\right) + -1\\ \mathbf{elif}\;y \leq 0.25:\\ \;\;\;\;x - y \cdot \left(x \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Error35.8
Cost1100
\[\begin{array}{l} t_1 := b \cdot \left(x \cdot \left(\left(a \cdot a\right) \cdot \left(b \cdot 0.5\right)\right)\right)\\ \mathbf{if}\;y \leq -2.05 \cdot 10^{+27}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -2 \cdot 10^{-200}:\\ \;\;\;\;\left(1 + \left(x + x \cdot \left(y \cdot t\right)\right)\right) + -1\\ \mathbf{elif}\;y \leq 1.3 \cdot 10^{-27}:\\ \;\;\;\;x - y \cdot \left(x \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 11
Error39.8
Cost648
\[\begin{array}{l} \mathbf{if}\;y \leq -2.05 \cdot 10^{+27}:\\ \;\;\;\;a \cdot \left(x \cdot b\right)\\ \mathbf{elif}\;y \leq 0.25:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;b \cdot \left(x \cdot \left(-a\right)\right)\\ \end{array} \]
Alternative 12
Error39.9
Cost584
\[\begin{array}{l} t_1 := a \cdot \left(x \cdot b\right)\\ \mathbf{if}\;y \leq -2.05 \cdot 10^{+27}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 0.25:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 13
Error44.7
Cost64
\[x \]

Error

Reproduce

herbie shell --seed 2022291 
(FPCore (x y z t a b)
  :name "Numeric.SpecFunctions:incompleteBetaApprox from math-functions-0.1.5.2, B"
  :precision binary64
  (* x (exp (+ (* y (- (log z) t)) (* a (- (log (- 1.0 z)) b))))))