?

Average Error: 1.9 → 0.3
Time: 21.1s
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 1.9

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

    \[ 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.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.8
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 -1 \cdot 10^{+20}:\\ \;\;\;\;x \cdot e^{t_1}\\ \mathbf{else}:\\ \;\;\;\;x \cdot e^{a \cdot \left(\left(-b\right) - z\right)}\\ \end{array} \]
Alternative 2
Error27.1
Cost7451
\[\begin{array}{l} \mathbf{if}\;x \leq -7 \cdot 10^{+126} \lor \neg \left(x \leq -2.65 \cdot 10^{-281} \lor \neg \left(x \leq 1.35 \cdot 10^{-304}\right) \land \left(x \leq 1.25 \cdot 10^{-133} \lor \neg \left(x \leq 4.5 \cdot 10^{+80}\right) \land x \leq 1.35 \cdot 10^{+153}\right)\right):\\ \;\;\;\;x \cdot {z}^{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot x}{x + a \cdot \left(x \cdot b\right)}\\ \end{array} \]
Alternative 3
Error8.1
Cost7312
\[\begin{array}{l} t_1 := x \cdot e^{a \cdot \left(-b\right)}\\ t_2 := x \cdot e^{y \cdot \left(-t\right)}\\ \mathbf{if}\;y \leq -1.02 \cdot 10^{-5}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 1.6 \cdot 10^{-112}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.56 \cdot 10^{-72}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 0.88:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x \cdot {z}^{y}\\ \end{array} \]
Alternative 4
Error6.8
Cost7312
\[\begin{array}{l} t_1 := x \cdot e^{y \cdot \left(-t\right)}\\ \mathbf{if}\;y \leq -7.6 \cdot 10^{-7}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 2 \cdot 10^{-102}:\\ \;\;\;\;x \cdot e^{a \cdot \left(\left(-b\right) - z\right)}\\ \mathbf{elif}\;y \leq 8.6 \cdot 10^{-73}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 0.105:\\ \;\;\;\;x \cdot e^{a \cdot \left(-b\right)}\\ \mathbf{else}:\\ \;\;\;\;x \cdot {z}^{y}\\ \end{array} \]
Alternative 5
Error19.2
Cost7048
\[\begin{array}{l} \mathbf{if}\;y \leq -6.4 \cdot 10^{-52}:\\ \;\;\;\;\frac{x \cdot x}{x + a \cdot \left(x \cdot b\right)}\\ \mathbf{elif}\;y \leq 7 \cdot 10^{-5}:\\ \;\;\;\;x \cdot e^{a \cdot \left(-z\right)}\\ \mathbf{else}:\\ \;\;\;\;x \cdot {z}^{y}\\ \end{array} \]
Alternative 6
Error10.5
Cost7048
\[\begin{array}{l} \mathbf{if}\;y \leq -2 \cdot 10^{+207}:\\ \;\;\;\;\frac{\left(a \cdot a\right) \cdot \left(\left(x \cdot x\right) \cdot \left(b \cdot \left(-b\right)\right)\right)}{x + a \cdot \left(x \cdot b\right)}\\ \mathbf{elif}\;y \leq 0.0144:\\ \;\;\;\;x \cdot e^{a \cdot \left(-b\right)}\\ \mathbf{else}:\\ \;\;\;\;x \cdot {z}^{y}\\ \end{array} \]
Alternative 7
Error17.7
Cost6984
\[\begin{array}{l} \mathbf{if}\;a \leq -1.7 \cdot 10^{+128}:\\ \;\;\;\;\frac{x \cdot x}{x + a \cdot \left(x \cdot b\right)}\\ \mathbf{elif}\;a \leq 1.05 \cdot 10^{+24}:\\ \;\;\;\;x \cdot {z}^{y}\\ \mathbf{else}:\\ \;\;\;\;x \cdot {\left(-z\right)}^{a}\\ \end{array} \]
Alternative 8
Error19.2
Cost6984
\[\begin{array}{l} \mathbf{if}\;y \leq -6.5 \cdot 10^{-52}:\\ \;\;\;\;\frac{x \cdot x}{x + a \cdot \left(x \cdot b\right)}\\ \mathbf{elif}\;y \leq 0.00012:\\ \;\;\;\;\frac{x}{e^{z \cdot a}}\\ \mathbf{else}:\\ \;\;\;\;x \cdot {z}^{y}\\ \end{array} \]
Alternative 9
Error34.9
Cost1941
\[\begin{array}{l} t_1 := x + a \cdot \left(x \cdot b\right)\\ t_2 := \frac{x \cdot x}{t_1}\\ \mathbf{if}\;y \leq -3.3 \cdot 10^{-137}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 1.55 \cdot 10^{-170}:\\ \;\;\;\;x + x \cdot \left(\left(z \cdot a\right) \cdot \left(-1 + \left(z \cdot a\right) \cdot 0.5\right)\right)\\ \mathbf{elif}\;y \leq 9 \cdot 10^{+58} \lor \neg \left(y \leq 1.2 \cdot 10^{+223}\right) \land y \leq 2.7 \cdot 10^{+267}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(a \cdot a\right) \cdot \left(\left(x \cdot x\right) \cdot \left(b \cdot \left(-b\right)\right)\right)}{t_1}\\ \end{array} \]
Alternative 10
Error35.9
Cost1233
\[\begin{array}{l} t_1 := \frac{x \cdot x}{x + a \cdot \left(x \cdot b\right)}\\ \mathbf{if}\;y \leq -9.6 \cdot 10^{-136}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 5.8 \cdot 10^{-167}:\\ \;\;\;\;x - x \cdot \left(y \cdot t\right)\\ \mathbf{elif}\;y \leq 2.1 \cdot 10^{+59} \lor \neg \left(y \leq 3.2 \cdot 10^{+206}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(a \cdot \left(-b\right)\right)\\ \end{array} \]
Alternative 11
Error36.0
Cost1233
\[\begin{array}{l} t_1 := \frac{x \cdot x}{x + a \cdot \left(x \cdot b\right)}\\ \mathbf{if}\;y \leq -3.9 \cdot 10^{-135}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 4.8 \cdot 10^{-174}:\\ \;\;\;\;x + x \cdot \left(\left(z \cdot a\right) \cdot \left(-1 + \left(z \cdot a\right) \cdot 0.5\right)\right)\\ \mathbf{elif}\;y \leq 2.3 \cdot 10^{+59} \lor \neg \left(y \leq 1.1 \cdot 10^{+207}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(a \cdot \left(-b\right)\right)\\ \end{array} \]
Alternative 12
Error39.4
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -6.9 \cdot 10^{-6}:\\ \;\;\;\;x \cdot \left(a \cdot \left(-b\right)\right)\\ \mathbf{elif}\;y \leq 27000000000000:\\ \;\;\;\;x - x \cdot \left(y \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;b \cdot \left(x \cdot \left(-a\right)\right)\\ \end{array} \]
Alternative 13
Error39.6
Cost648
\[\begin{array}{l} \mathbf{if}\;y \leq -4.6 \cdot 10^{-30}:\\ \;\;\;\;a \cdot \left(x \cdot \left(-b\right)\right)\\ \mathbf{elif}\;y \leq 27000000000000:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;b \cdot \left(x \cdot \left(-a\right)\right)\\ \end{array} \]
Alternative 14
Error39.5
Cost648
\[\begin{array}{l} \mathbf{if}\;y \leq -1.12 \cdot 10^{+21}:\\ \;\;\;\;x \cdot \left(a \cdot \left(-b\right)\right)\\ \mathbf{elif}\;y \leq 27000000000000:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;b \cdot \left(x \cdot \left(-a\right)\right)\\ \end{array} \]
Alternative 15
Error40.0
Cost585
\[\begin{array}{l} \mathbf{if}\;y \leq -4.6 \cdot 10^{-30} \lor \neg \left(y \leq 4.1 \cdot 10^{+37}\right):\\ \;\;\;\;a \cdot \left(x \cdot b\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 16
Error40.0
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -4.6 \cdot 10^{-30}:\\ \;\;\;\;a \cdot \left(x \cdot \left(-b\right)\right)\\ \mathbf{elif}\;y \leq 4 \cdot 10^{+37}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;a \cdot \left(x \cdot b\right)\\ \end{array} \]
Alternative 17
Error44.2
Cost64
\[x \]

Error

Reproduce?

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