Average Error: 2.2 → 0.2
Time: 35.8s
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.2

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

    \[\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))))): 7 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.2

    \[\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
Error1.5
Cost20292
\[\begin{array}{l} \mathbf{if}\;a \leq 3.8 \cdot 10^{+117}:\\ \;\;\;\;x \cdot e^{y \cdot \left(\log z - t\right) + a \cdot \left(\log \left(1 - z\right) - b\right)}\\ \mathbf{else}:\\ \;\;\;\;x \cdot e^{\left(-a\right) \cdot \left(z + b\right)}\\ \end{array} \]
Alternative 2
Error1.6
Cost13636
\[\begin{array}{l} \mathbf{if}\;a \leq 3.05 \cdot 10^{+119}:\\ \;\;\;\;x \cdot e^{y \cdot \left(\log z - t\right) - a \cdot b}\\ \mathbf{else}:\\ \;\;\;\;x \cdot e^{\left(-a\right) \cdot \left(z + b\right)}\\ \end{array} \]
Alternative 3
Error2.8
Cost7372
\[\begin{array}{l} t_1 := \frac{x}{e^{y \cdot t + a \cdot b}}\\ \mathbf{if}\;y \leq -1.65 \cdot 10^{-118}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 3.7 \cdot 10^{-185}:\\ \;\;\;\;x \cdot e^{\left(-a\right) \cdot \left(z + b\right)}\\ \mathbf{elif}\;y \leq 1.1 \cdot 10^{-13}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x \cdot {z}^{y}\\ \end{array} \]
Alternative 4
Error25.0
Cost7316
\[\begin{array}{l} t_1 := \left(1 + x \cdot \left(1 - z \cdot a\right)\right) + -1\\ t_2 := a \cdot \left(x \cdot b\right)\\ \mathbf{if}\;y \leq -1.8 \cdot 10^{-8}:\\ \;\;\;\;\left(1 + t_2\right) + -1\\ \mathbf{elif}\;y \leq -1.8 \cdot 10^{-217}:\\ \;\;\;\;\frac{x \cdot x}{x + t_2}\\ \mathbf{elif}\;y \leq 2.05 \cdot 10^{-227}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 6.8 \cdot 10^{-149}:\\ \;\;\;\;x - x \cdot \left(y \cdot t\right)\\ \mathbf{elif}\;y \leq 2.7 \cdot 10^{-16}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x \cdot {z}^{y}\\ \end{array} \]
Alternative 5
Error7.2
Cost7176
\[\begin{array}{l} \mathbf{if}\;y \leq -4.3 \cdot 10^{-10}:\\ \;\;\;\;\frac{x}{e^{y \cdot t}}\\ \mathbf{elif}\;y \leq 2.4 \cdot 10^{-36}:\\ \;\;\;\;x \cdot e^{\left(-a\right) \cdot \left(z + b\right)}\\ \mathbf{else}:\\ \;\;\;\;x \cdot {z}^{y}\\ \end{array} \]
Alternative 6
Error9.1
Cost7116
\[\begin{array}{l} t_1 := \frac{x}{e^{y \cdot t}}\\ \mathbf{if}\;y \leq -2.7 \cdot 10^{-9}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 3.2 \cdot 10^{-134}:\\ \;\;\;\;\frac{x}{e^{a \cdot b}}\\ \mathbf{elif}\;y \leq 8.5 \cdot 10^{-14}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x \cdot {z}^{y}\\ \end{array} \]
Alternative 7
Error11.8
Cost6984
\[\begin{array}{l} \mathbf{if}\;y \leq -2.05 \cdot 10^{+30}:\\ \;\;\;\;\left(1 + a \cdot \left(x \cdot b\right)\right) + -1\\ \mathbf{elif}\;y \leq 2.4 \cdot 10^{-36}:\\ \;\;\;\;\frac{x}{e^{a \cdot b}}\\ \mathbf{else}:\\ \;\;\;\;x \cdot {z}^{y}\\ \end{array} \]
Alternative 8
Error33.7
Cost1236
\[\begin{array}{l} t_1 := \left(1 + a \cdot \left(x \cdot b\right)\right) + -1\\ \mathbf{if}\;y \leq -1.7 \cdot 10^{-50}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 4.4 \cdot 10^{-74}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 2 \cdot 10^{-47}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 7.5 \cdot 10^{-9}:\\ \;\;\;\;x - x \cdot \left(y \cdot t\right)\\ \mathbf{elif}\;y \leq 2.5 \cdot 10^{+70}:\\ \;\;\;\;a \cdot \left(x \cdot \left(-z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Error34.6
Cost1104
\[\begin{array}{l} t_1 := a \cdot \left(x \cdot b\right)\\ t_2 := \left(1 + t_1\right) + -1\\ \mathbf{if}\;y \leq -1.8 \cdot 10^{-8}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq -9.5 \cdot 10^{-218}:\\ \;\;\;\;\frac{x \cdot x}{x + t_1}\\ \mathbf{elif}\;y \leq 4.4 \cdot 10^{-228}:\\ \;\;\;\;\left(1 + x \cdot \left(1 - z \cdot a\right)\right) + -1\\ \mathbf{elif}\;y \leq 4.4 \cdot 10^{-74}:\\ \;\;\;\;x - t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 10
Error34.3
Cost972
\[\begin{array}{l} t_1 := a \cdot \left(x \cdot b\right)\\ t_2 := \left(1 + t_1\right) + -1\\ \mathbf{if}\;y \leq -1.8 \cdot 10^{-8}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 8 \cdot 10^{-228}:\\ \;\;\;\;\left(1 + x \cdot \left(1 - z \cdot a\right)\right) + -1\\ \mathbf{elif}\;y \leq 4.2 \cdot 10^{-74}:\\ \;\;\;\;x - t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 11
Error35.7
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -1.75 \cdot 10^{-55}:\\ \;\;\;\;x \cdot \left(z \cdot \left(-a\right)\right)\\ \mathbf{elif}\;y \leq 2.2 \cdot 10^{-12}:\\ \;\;\;\;x - x \cdot \left(y \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;a \cdot \left(x \cdot \left(-z\right)\right)\\ \end{array} \]
Alternative 12
Error35.5
Cost648
\[\begin{array}{l} t_1 := a \cdot \left(x \cdot \left(-z\right)\right)\\ \mathbf{if}\;y \leq -1.75 \cdot 10^{-55}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 0.00016:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 13
Error35.8
Cost648
\[\begin{array}{l} \mathbf{if}\;y \leq -1.6 \cdot 10^{-55}:\\ \;\;\;\;x \cdot \left(z \cdot \left(-a\right)\right)\\ \mathbf{elif}\;y \leq 8 \cdot 10^{-7}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;a \cdot \left(x \cdot \left(-z\right)\right)\\ \end{array} \]
Alternative 14
Error39.6
Cost584
\[\begin{array}{l} t_1 := a \cdot \left(x \cdot b\right)\\ \mathbf{if}\;y \leq -3.5 \cdot 10^{-9}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 64000:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 15
Error39.0
Cost584
\[\begin{array}{l} t_1 := \frac{x \cdot x}{x}\\ \mathbf{if}\;y \leq -3.65 \cdot 10^{-56}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 4.5 \cdot 10^{-128}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 16
Error44.5
Cost64
\[x \]

Error

Reproduce

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