Average Error: 2.1 → 0.3
Time: 21.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

    [Start]2.1

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

    fma-def [=>]1.9

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

    sub-neg [=>]1.9

    \[ x \cdot e^{\mathsf{fma}\left(y, \log z - t, a \cdot \left(\log \color{blue}{\left(1 + \left(-z\right)\right)} - b\right)\right)} \]

    log1p-def [=>]0.3

    \[ x \cdot e^{\mathsf{fma}\left(y, \log z - t, a \cdot \left(\color{blue}{\mathsf{log1p}\left(-z\right)} - b\right)\right)} \]
  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
Error1.6
Cost40712
\[\begin{array}{l} t_1 := y \cdot \left(\log z - t\right)\\ t_2 := t_1 + a \cdot \left(\log \left(1 - z\right) - b\right)\\ \mathbf{if}\;t_2 \leq -10:\\ \;\;\;\;x \cdot e^{t_2}\\ \mathbf{elif}\;t_2 \leq 5 \cdot 10^{-9}:\\ \;\;\;\;x \cdot e^{a \cdot \left(\mathsf{log1p}\left(-z\right) - b\right)}\\ \mathbf{else}:\\ \;\;\;\;x \cdot e^{t_1}\\ \end{array} \]
Alternative 2
Error6.4
Cost13576
\[\begin{array}{l} \mathbf{if}\;y \leq -8.1 \cdot 10^{+34}:\\ \;\;\;\;x \cdot e^{y \cdot \left(-t\right)}\\ \mathbf{elif}\;y \leq 1.15:\\ \;\;\;\;x \cdot e^{a \cdot \left(\mathsf{log1p}\left(-z\right) - b\right)}\\ \mathbf{else}:\\ \;\;\;\;x \cdot {z}^{y}\\ \end{array} \]
Alternative 3
Error6.4
Cost7176
\[\begin{array}{l} \mathbf{if}\;y \leq -2.35 \cdot 10^{+23}:\\ \;\;\;\;x \cdot e^{y \cdot \left(-t\right)}\\ \mathbf{elif}\;y \leq 0.55:\\ \;\;\;\;x \cdot e^{a \cdot \left(\left(-b\right) - z\right)}\\ \mathbf{else}:\\ \;\;\;\;x \cdot {z}^{y}\\ \end{array} \]
Alternative 4
Error8.3
Cost7048
\[\begin{array}{l} \mathbf{if}\;y \leq -3.3 \cdot 10^{-28}:\\ \;\;\;\;x \cdot e^{y \cdot \left(-t\right)}\\ \mathbf{elif}\;y \leq 0.052:\\ \;\;\;\;x \cdot e^{a \cdot \left(-b\right)}\\ \mathbf{else}:\\ \;\;\;\;x \cdot {z}^{y}\\ \end{array} \]
Alternative 5
Error10.7
Cost6916
\[\begin{array}{l} \mathbf{if}\;y \leq 0.045:\\ \;\;\;\;x \cdot e^{a \cdot \left(-b\right)}\\ \mathbf{else}:\\ \;\;\;\;x \cdot {z}^{y}\\ \end{array} \]
Alternative 6
Error26.2
Cost6852
\[\begin{array}{l} \mathbf{if}\;t \leq -5.2 \cdot 10^{+93}:\\ \;\;\;\;x \cdot e^{a \cdot b}\\ \mathbf{else}:\\ \;\;\;\;x \cdot {z}^{y}\\ \end{array} \]
Alternative 7
Error25.6
Cost6788
\[\begin{array}{l} \mathbf{if}\;y \leq -1.9:\\ \;\;\;\;a \cdot \left(x \cdot b\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot {z}^{y}\\ \end{array} \]
Alternative 8
Error41.3
Cost452
\[\begin{array}{l} \mathbf{if}\;y \leq 1.65 \cdot 10^{+22}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;a \cdot \left(x \cdot b\right)\\ \end{array} \]
Alternative 9
Error44.9
Cost64
\[x \]

Error

Reproduce

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