Average Error: 2.1 → 0.3
Time: 18.9s
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(y, \log z - t, a \cdot \left(\mathsf{log1p}\left(-z\right) - b\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 y (- (log z) t) (* a (- (log1p (- z)) b))))))
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(y, (log(z) - t), (a * (log1p(-z) - b))));
}
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(y, Float64(log(z) - t), Float64(a * Float64(log1p(Float64(-z)) - b)))))
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[(y * N[(N[Log[z], $MachinePrecision] - t), $MachinePrecision] + N[(a * N[(N[Log[1 + (-z)], $MachinePrecision] - b), $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(y, \log z - t, a \cdot \left(\mathsf{log1p}\left(-z\right) - b\right)\right)}

Error

Derivation

  1. Initial program 2.1

    \[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(y, \log z - t, a \cdot \left(\mathsf{log1p}\left(-z\right) - b\right)\right)}} \]
    Proof
    (*.f64 x (exp.f64 (fma.f64 y (-.f64 (log.f64 z) t) (*.f64 a (-.f64 (log1p.f64 (neg.f64 z)) b))))): 0 points increase in error, 0 points decrease in error
    (*.f64 x (exp.f64 (fma.f64 y (-.f64 (log.f64 z) t) (*.f64 a (-.f64 (Rewrite<= log1p-def_binary64 (log.f64 (+.f64 1 (neg.f64 z)))) b))))): 10 points increase in error, 0 points decrease in error
    (*.f64 x (exp.f64 (fma.f64 y (-.f64 (log.f64 z) t) (*.f64 a (-.f64 (log.f64 (Rewrite<= sub-neg_binary64 (-.f64 1 z))) b))))): 0 points increase in error, 0 points decrease in error
    (*.f64 x (exp.f64 (Rewrite<= fma-def_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(y, \log z - t, a \cdot \left(\mathsf{log1p}\left(-z\right) - b\right)\right)} \]

Alternatives

Alternative 1
Error0.8
Cost33860
\[\begin{array}{l} t_1 := a \cdot \left(\log \left(1 - z\right) - b\right) + y \cdot \left(\log z - t\right)\\ \mathbf{if}\;t_1 \leq -4 \cdot 10^{-10}:\\ \;\;\;\;x \cdot e^{t_1}\\ \mathbf{else}:\\ \;\;\;\;x \cdot e^{a \cdot \left(\left(-z\right) - b\right)}\\ \end{array} \]
Alternative 2
Error1.7
Cost13636
\[\begin{array}{l} \mathbf{if}\;a \leq 1.2 \cdot 10^{+143}:\\ \;\;\;\;x \cdot e^{y \cdot \left(\log z - t\right) - a \cdot b}\\ \mathbf{else}:\\ \;\;\;\;x \cdot e^{a \cdot \left(\left(-z\right) - b\right)}\\ \end{array} \]
Alternative 3
Error2.6
Cost7436
\[\begin{array}{l} t_1 := x \cdot e^{y \cdot \left(-t\right) - a \cdot b}\\ \mathbf{if}\;y \leq -1.25 \cdot 10^{-127}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.9 \cdot 10^{-238}:\\ \;\;\;\;x \cdot e^{a \cdot \left(\left(-z\right) - b\right)}\\ \mathbf{elif}\;y \leq 1.45:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x \cdot {z}^{y}\\ \end{array} \]
Alternative 4
Error24.1
Cost7316
\[\begin{array}{l} t_1 := \left(1 + x \cdot \left(1 - z \cdot a\right)\right) + -1\\ \mathbf{if}\;y \leq -4.5 \cdot 10^{-46}:\\ \;\;\;\;\left(1 + a \cdot \left(x \cdot b\right)\right) + -1\\ \mathbf{elif}\;y \leq -7 \cdot 10^{-274}:\\ \;\;\;\;x \cdot \left(1 - a \cdot b\right)\\ \mathbf{elif}\;y \leq 9.5 \cdot 10^{-278}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 5.3 \cdot 10^{-124}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 2.3 \cdot 10^{-16}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x \cdot {z}^{y}\\ \end{array} \]
Alternative 5
Error6.5
Cost7176
\[\begin{array}{l} \mathbf{if}\;y \leq -6.4 \cdot 10^{-24}:\\ \;\;\;\;x \cdot e^{y \cdot \left(-t\right)}\\ \mathbf{elif}\;y \leq 0.112:\\ \;\;\;\;x \cdot e^{a \cdot \left(\left(-z\right) - b\right)}\\ \mathbf{else}:\\ \;\;\;\;x \cdot {z}^{y}\\ \end{array} \]
Alternative 6
Error10.5
Cost7048
\[\begin{array}{l} \mathbf{if}\;y \leq -1.16 \cdot 10^{+178}:\\ \;\;\;\;\left(1 + a \cdot \left(x \cdot b\right)\right) + -1\\ \mathbf{elif}\;y \leq 0.64:\\ \;\;\;\;x \cdot e^{a \cdot \left(-b\right)}\\ \mathbf{else}:\\ \;\;\;\;x \cdot {z}^{y}\\ \end{array} \]
Alternative 7
Error8.7
Cost7048
\[\begin{array}{l} \mathbf{if}\;y \leq -1.6 \cdot 10^{-95}:\\ \;\;\;\;x \cdot e^{y \cdot \left(-t\right)}\\ \mathbf{elif}\;y \leq 0.175:\\ \;\;\;\;x \cdot e^{a \cdot \left(-b\right)}\\ \mathbf{else}:\\ \;\;\;\;x \cdot {z}^{y}\\ \end{array} \]
Alternative 8
Error33.7
Cost1496
\[\begin{array}{l} t_1 := \left(1 + a \cdot \left(x \cdot b\right)\right) + -1\\ t_2 := \left(1 + x \cdot \left(1 - z \cdot a\right)\right) + -1\\ \mathbf{if}\;y \leq -4.5 \cdot 10^{-47}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -1.3 \cdot 10^{-274}:\\ \;\;\;\;x \cdot \left(1 - a \cdot b\right)\\ \mathbf{elif}\;y \leq 4.4 \cdot 10^{-278}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 1.35 \cdot 10^{-127}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 6.5 \cdot 10^{+91}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 3.5 \cdot 10^{+205}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 9
Error33.9
Cost1104
\[\begin{array}{l} t_1 := \left(1 + a \cdot \left(x \cdot b\right)\right) + -1\\ \mathbf{if}\;y \leq -4.5 \cdot 10^{-46}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -1.16 \cdot 10^{-285}:\\ \;\;\;\;x \cdot \left(1 - a \cdot b\right)\\ \mathbf{elif}\;y \leq 8 \cdot 10^{-277}:\\ \;\;\;\;t \cdot \left(y \cdot \left(-x\right)\right)\\ \mathbf{elif}\;y \leq 7 \cdot 10^{-19}:\\ \;\;\;\;x - y \cdot \left(x \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Error37.1
Cost976
\[\begin{array}{l} \mathbf{if}\;y \leq -4.2 \cdot 10^{-46}:\\ \;\;\;\;x \cdot \left(z \cdot \left(-a\right)\right)\\ \mathbf{elif}\;y \leq -3.4 \cdot 10^{-287}:\\ \;\;\;\;x \cdot \left(1 - a \cdot b\right)\\ \mathbf{elif}\;y \leq 8 \cdot 10^{-277}:\\ \;\;\;\;t \cdot \left(y \cdot \left(-x\right)\right)\\ \mathbf{elif}\;y \leq 1.75 \cdot 10^{-24}:\\ \;\;\;\;x - b \cdot \left(x \cdot a\right)\\ \mathbf{else}:\\ \;\;\;\;a \cdot \left(z \cdot \left(-x\right)\right)\\ \end{array} \]
Alternative 11
Error37.4
Cost976
\[\begin{array}{l} \mathbf{if}\;y \leq -3.3 \cdot 10^{-46}:\\ \;\;\;\;x \cdot \left(z \cdot \left(-a\right)\right)\\ \mathbf{elif}\;y \leq -1.16 \cdot 10^{-285}:\\ \;\;\;\;x \cdot \left(1 - a \cdot b\right)\\ \mathbf{elif}\;y \leq 8 \cdot 10^{-277}:\\ \;\;\;\;t \cdot \left(y \cdot \left(-x\right)\right)\\ \mathbf{elif}\;y \leq 2.65 \cdot 10^{-23}:\\ \;\;\;\;x - y \cdot \left(x \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;a \cdot \left(z \cdot \left(-x\right)\right)\\ \end{array} \]
Alternative 12
Error36.6
Cost912
\[\begin{array}{l} t_1 := a \cdot \left(z \cdot \left(-x\right)\right)\\ \mathbf{if}\;y \leq -4.5 \cdot 10^{-46}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -3.4 \cdot 10^{-287}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 2.7 \cdot 10^{-275}:\\ \;\;\;\;t \cdot \left(y \cdot \left(-x\right)\right)\\ \mathbf{elif}\;y \leq 3.3 \cdot 10^{-23}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 13
Error36.8
Cost912
\[\begin{array}{l} \mathbf{if}\;y \leq -4.5 \cdot 10^{-46}:\\ \;\;\;\;x \cdot \left(z \cdot \left(-a\right)\right)\\ \mathbf{elif}\;y \leq -3.4 \cdot 10^{-287}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 2 \cdot 10^{-276}:\\ \;\;\;\;t \cdot \left(y \cdot \left(-x\right)\right)\\ \mathbf{elif}\;y \leq 3.2 \cdot 10^{-23}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;a \cdot \left(z \cdot \left(-x\right)\right)\\ \end{array} \]
Alternative 14
Error36.8
Cost912
\[\begin{array}{l} \mathbf{if}\;y \leq -4.8 \cdot 10^{-48}:\\ \;\;\;\;x \cdot \left(z \cdot \left(-a\right)\right)\\ \mathbf{elif}\;y \leq -3.5 \cdot 10^{-287}:\\ \;\;\;\;x \cdot \left(1 - a \cdot b\right)\\ \mathbf{elif}\;y \leq 8 \cdot 10^{-277}:\\ \;\;\;\;t \cdot \left(y \cdot \left(-x\right)\right)\\ \mathbf{elif}\;y \leq 3.2 \cdot 10^{-23}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;a \cdot \left(z \cdot \left(-x\right)\right)\\ \end{array} \]
Alternative 15
Error35.3
Cost648
\[\begin{array}{l} t_1 := a \cdot \left(z \cdot \left(-x\right)\right)\\ \mathbf{if}\;y \leq -4.5 \cdot 10^{-46}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 2.46 \cdot 10^{-23}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 16
Error40.4
Cost452
\[\begin{array}{l} \mathbf{if}\;y \leq 10500000000:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;a \cdot \left(x \cdot b\right)\\ \end{array} \]
Alternative 17
Error44.2
Cost64
\[x \]

Error

Reproduce

herbie shell --seed 2022329 
(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))))))