?

Average Error: 2.1 → 0.3
Time: 18.5s
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.0
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 -20000:\\ \;\;\;\;x \cdot e^{t_1}\\ \mathbf{else}:\\ \;\;\;\;x \cdot e^{a \cdot \left(-\left(z + b\right)\right)}\\ \end{array} \]
Alternative 2
Error26.6
Cost7316
\[\begin{array}{l} t_1 := t \cdot \left(x \cdot y\right)\\ \mathbf{if}\;y \leq -1.55 \cdot 10^{-59}:\\ \;\;\;\;0.5 \cdot \left(x \cdot \left(a \cdot \left(a \cdot \left(b \cdot b\right)\right)\right)\right)\\ \mathbf{elif}\;y \leq -3.05 \cdot 10^{-148}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -2.5 \cdot 10^{-156}:\\ \;\;\;\;0.5 \cdot \left(\left(x \cdot \left(b \cdot b\right)\right) \cdot \left(a \cdot a\right)\right)\\ \mathbf{elif}\;y \leq 2.5 \cdot 10^{-291}:\\ \;\;\;\;x \cdot e^{a \cdot b}\\ \mathbf{elif}\;y \leq 10^{-278}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x \cdot {z}^{y}\\ \end{array} \]
Alternative 3
Error26.3
Cost7184
\[\begin{array}{l} \mathbf{if}\;y \leq -1.8 \cdot 10^{-72}:\\ \;\;\;\;0.5 \cdot \left(x \cdot \left(a \cdot \left(a \cdot \left(b \cdot b\right)\right)\right)\right)\\ \mathbf{elif}\;y \leq -1.32 \cdot 10^{-148}:\\ \;\;\;\;t \cdot \left(x \cdot y\right)\\ \mathbf{elif}\;y \leq -2.5 \cdot 10^{-156}:\\ \;\;\;\;0.5 \cdot \left(\left(x \cdot \left(b \cdot b\right)\right) \cdot \left(a \cdot a\right)\right)\\ \mathbf{elif}\;y \leq -3.3 \cdot 10^{-234}:\\ \;\;\;\;x \cdot \left(1 + b \cdot \left(0.5 \cdot \left(a \cdot \left(a \cdot b\right)\right) - a\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot {z}^{y}\\ \end{array} \]
Alternative 4
Error6.2
Cost7176
\[\begin{array}{l} \mathbf{if}\;y \leq -5.2 \cdot 10^{+20}:\\ \;\;\;\;x \cdot e^{y \cdot \left(-t\right)}\\ \mathbf{elif}\;y \leq 4.6 \cdot 10^{-5}:\\ \;\;\;\;x \cdot e^{a \cdot \left(-\left(z + b\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;x \cdot {z}^{y}\\ \end{array} \]
Alternative 5
Error8.4
Cost7048
\[\begin{array}{l} \mathbf{if}\;y \leq -1.7 \cdot 10^{+20}:\\ \;\;\;\;x \cdot e^{y \cdot \left(-t\right)}\\ \mathbf{elif}\;y \leq 1.22 \cdot 10^{-26}:\\ \;\;\;\;x \cdot e^{a \cdot \left(-b\right)}\\ \mathbf{else}:\\ \;\;\;\;x \cdot {z}^{y}\\ \end{array} \]
Alternative 6
Error22.2
Cost6984
\[\begin{array}{l} \mathbf{if}\;y \leq -3.05 \cdot 10^{-12}:\\ \;\;\;\;0.5 \cdot \left(x \cdot \left(a \cdot \left(a \cdot \left(b \cdot b\right)\right)\right)\right)\\ \mathbf{elif}\;y \leq 1.55 \cdot 10^{-34}:\\ \;\;\;\;x \cdot e^{z \cdot a}\\ \mathbf{else}:\\ \;\;\;\;x \cdot {z}^{y}\\ \end{array} \]
Alternative 7
Error10.9
Cost6916
\[\begin{array}{l} \mathbf{if}\;y \leq 1.22 \cdot 10^{-26}:\\ \;\;\;\;x \cdot e^{a \cdot \left(-b\right)}\\ \mathbf{else}:\\ \;\;\;\;x \cdot {z}^{y}\\ \end{array} \]
Alternative 8
Error36.8
Cost1488
\[\begin{array}{l} t_1 := 0.5 \cdot \left(x \cdot \left(a \cdot \left(a \cdot \left(b \cdot b\right)\right)\right)\right)\\ \mathbf{if}\;y \leq -1.8 \cdot 10^{-60}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -1.32 \cdot 10^{-148}:\\ \;\;\;\;t \cdot \left(x \cdot y\right)\\ \mathbf{elif}\;y \leq -2.5 \cdot 10^{-156}:\\ \;\;\;\;0.5 \cdot \left(\left(x \cdot \left(b \cdot b\right)\right) \cdot \left(a \cdot a\right)\right)\\ \mathbf{elif}\;y \leq -3.3 \cdot 10^{-234}:\\ \;\;\;\;x \cdot \left(1 + b \cdot \left(0.5 \cdot \left(a \cdot \left(a \cdot b\right)\right) - a\right)\right)\\ \mathbf{elif}\;y \leq 6.4 \cdot 10^{-26}:\\ \;\;\;\;x \cdot \left(1 - y \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Error36.7
Cost1364
\[\begin{array}{l} t_1 := 0.5 \cdot \left(x \cdot \left(a \cdot \left(a \cdot \left(b \cdot b\right)\right)\right)\right)\\ \mathbf{if}\;y \leq -3.9 \cdot 10^{-72}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -1.32 \cdot 10^{-148}:\\ \;\;\;\;t \cdot \left(x \cdot y\right)\\ \mathbf{elif}\;y \leq -2.5 \cdot 10^{-156}:\\ \;\;\;\;0.5 \cdot \left(\left(x \cdot \left(b \cdot b\right)\right) \cdot \left(a \cdot a\right)\right)\\ \mathbf{elif}\;y \leq -4.6 \cdot 10^{-239}:\\ \;\;\;\;x \cdot \left(1 - a \cdot b\right)\\ \mathbf{elif}\;y \leq 6.4 \cdot 10^{-26}:\\ \;\;\;\;x \cdot \left(1 - y \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Error35.8
Cost969
\[\begin{array}{l} \mathbf{if}\;y \leq -6.8 \cdot 10^{-102} \lor \neg \left(y \leq 4.2 \cdot 10^{-26}\right):\\ \;\;\;\;0.5 \cdot \left(x \cdot \left(a \cdot \left(a \cdot \left(b \cdot b\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 - y \cdot t\right)\\ \end{array} \]
Alternative 11
Error41.6
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -6.8 \cdot 10^{-102}:\\ \;\;\;\;a \cdot \left(b \cdot \left(-x\right)\right)\\ \mathbf{elif}\;y \leq 4.2 \cdot 10^{-26}:\\ \;\;\;\;x \cdot \left(1 - y \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(a \cdot \left(-b\right)\right)\\ \end{array} \]
Alternative 12
Error41.6
Cost648
\[\begin{array}{l} \mathbf{if}\;y \leq -6.8 \cdot 10^{-102}:\\ \;\;\;\;a \cdot \left(b \cdot \left(-x\right)\right)\\ \mathbf{elif}\;y \leq 6.4 \cdot 10^{-26}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(a \cdot \left(-b\right)\right)\\ \end{array} \]
Alternative 13
Error41.5
Cost585
\[\begin{array}{l} \mathbf{if}\;y \leq -6.8 \cdot 10^{-102} \lor \neg \left(y \leq 3.2 \cdot 10^{-11}\right):\\ \;\;\;\;a \cdot \left(x \cdot b\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 14
Error41.6
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -6.8 \cdot 10^{-102}:\\ \;\;\;\;a \cdot \left(x \cdot b\right)\\ \mathbf{elif}\;y \leq 6.4 \cdot 10^{-26}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;b \cdot \left(x \cdot a\right)\\ \end{array} \]
Alternative 15
Error41.6
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -6.8 \cdot 10^{-102}:\\ \;\;\;\;a \cdot \left(b \cdot \left(-x\right)\right)\\ \mathbf{elif}\;y \leq 6.4 \cdot 10^{-26}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;b \cdot \left(x \cdot a\right)\\ \end{array} \]
Alternative 16
Error44.7
Cost64
\[x \]

Error

Reproduce?

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