?

Average Error: 2.0 → 0.2
Time: 23.4s
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.0

    \[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

    [Start]2.0

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

    fma-def [=>]1.7

    \[ 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.7

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

    \[ 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.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
Error0.9
Cost33860
\[\begin{array}{l} t_1 := y \cdot \left(\log z - t\right) + a \cdot \left(\log \left(1 - z\right) - b\right)\\ \mathbf{if}\;t_1 \leq -50:\\ \;\;\;\;x \cdot e^{t_1}\\ \mathbf{else}:\\ \;\;\;\;x \cdot e^{\left(z + b\right) \cdot \left(-a\right)}\\ \end{array} \]
Alternative 2
Error6.8
Cost13380
\[\begin{array}{l} \mathbf{if}\;y \leq -9.8 \cdot 10^{-16}:\\ \;\;\;\;x \cdot e^{y \cdot \left(\log z - t\right)}\\ \mathbf{elif}\;y \leq 0.44:\\ \;\;\;\;x \cdot e^{\left(z + b\right) \cdot \left(-a\right)}\\ \mathbf{else}:\\ \;\;\;\;x \cdot {z}^{y}\\ \end{array} \]
Alternative 3
Error6.6
Cost7176
\[\begin{array}{l} \mathbf{if}\;y \leq -1.1 \cdot 10^{+39}:\\ \;\;\;\;x \cdot e^{y \cdot \left(-t\right)}\\ \mathbf{elif}\;y \leq 0.44:\\ \;\;\;\;x \cdot e^{\left(z + b\right) \cdot \left(-a\right)}\\ \mathbf{else}:\\ \;\;\;\;x \cdot {z}^{y}\\ \end{array} \]
Alternative 4
Error6.6
Cost7112
\[\begin{array}{l} \mathbf{if}\;y \leq -1.1 \cdot 10^{+39}:\\ \;\;\;\;x \cdot e^{y \cdot \left(-t\right)}\\ \mathbf{elif}\;y \leq 0.5:\\ \;\;\;\;\frac{x}{e^{a \cdot \left(z + b\right)}}\\ \mathbf{else}:\\ \;\;\;\;x \cdot {z}^{y}\\ \end{array} \]
Alternative 5
Error8.0
Cost7048
\[\begin{array}{l} \mathbf{if}\;y \leq -1.75 \cdot 10^{-14}:\\ \;\;\;\;x \cdot e^{y \cdot \left(-t\right)}\\ \mathbf{elif}\;y \leq 0.34:\\ \;\;\;\;x \cdot e^{a \cdot \left(-b\right)}\\ \mathbf{else}:\\ \;\;\;\;x \cdot {z}^{y}\\ \end{array} \]
Alternative 6
Error10.9
Cost6916
\[\begin{array}{l} \mathbf{if}\;y \leq 0.25:\\ \;\;\;\;x \cdot e^{a \cdot \left(-b\right)}\\ \mathbf{else}:\\ \;\;\;\;x \cdot {z}^{y}\\ \end{array} \]
Alternative 7
Error10.9
Cost6852
\[\begin{array}{l} \mathbf{if}\;y \leq 0.31:\\ \;\;\;\;\frac{x}{e^{a \cdot b}}\\ \mathbf{else}:\\ \;\;\;\;x \cdot {z}^{y}\\ \end{array} \]
Alternative 8
Error18.4
Cost6788
\[\begin{array}{l} \mathbf{if}\;y \leq 6.2 \cdot 10^{-11}:\\ \;\;\;\;\frac{x}{1 + a \cdot \left(z + b\right)}\\ \mathbf{else}:\\ \;\;\;\;x \cdot {z}^{y}\\ \end{array} \]
Alternative 9
Error45.2
Cost849
\[\begin{array}{l} \mathbf{if}\;x \leq -5.8 \cdot 10^{-151}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -2.5 \cdot 10^{-264} \lor \neg \left(x \leq 8.5 \cdot 10^{-257}\right) \land x \leq 2.55 \cdot 10^{-98}:\\ \;\;\;\;y \cdot \left(x \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 10
Error35.1
Cost713
\[\begin{array}{l} \mathbf{if}\;y \leq -1.06 \cdot 10^{-14} \lor \neg \left(y \leq 0.2\right):\\ \;\;\;\;a \cdot \left(-x \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 - z \cdot a\right)\\ \end{array} \]
Alternative 11
Error34.1
Cost713
\[\begin{array}{l} \mathbf{if}\;y \leq -4.3 \cdot 10^{-14} \lor \neg \left(y \leq 0.205\right):\\ \;\;\;\;a \cdot \left(-x \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{1 + z \cdot a}\\ \end{array} \]
Alternative 12
Error29.4
Cost708
\[\begin{array}{l} \mathbf{if}\;y \leq 0.85:\\ \;\;\;\;\frac{x}{1 + a \cdot \left(z + b\right)}\\ \mathbf{else}:\\ \;\;\;\;a \cdot \left(-x \cdot z\right)\\ \end{array} \]
Alternative 13
Error37.2
Cost649
\[\begin{array}{l} \mathbf{if}\;y \leq -4.3 \cdot 10^{-14} \lor \neg \left(y \leq 0.195\right):\\ \;\;\;\;z \cdot \left(x \cdot \left(-a\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 14
Error35.1
Cost649
\[\begin{array}{l} \mathbf{if}\;y \leq -2.05 \cdot 10^{-14} \lor \neg \left(y \leq 0.195\right):\\ \;\;\;\;a \cdot \left(-x \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 15
Error44.0
Cost584
\[\begin{array}{l} \mathbf{if}\;b \leq -1.55 \cdot 10^{+98}:\\ \;\;\;\;t \cdot \left(x \cdot y\right)\\ \mathbf{elif}\;b \leq 3.35 \cdot 10^{+128}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(x \cdot t\right)\\ \end{array} \]
Alternative 16
Error44.3
Cost452
\[\begin{array}{l} \mathbf{if}\;b \leq 2.9 \cdot 10^{+126}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y \cdot t\right)\\ \end{array} \]
Alternative 17
Error44.7
Cost64
\[x \]

Error

Reproduce?

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