?

Average Error: 2.0 → 0.2
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 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.5
Cost14016
\[x \cdot e^{-1 + \left(y \cdot \left(\log z - t\right) + \left(1 - \left(z \cdot a + a \cdot b\right)\right)\right)} \]
Alternative 2
Error6.9
Cost7112
\[\begin{array}{l} \mathbf{if}\;y \leq -1.55 \cdot 10^{+75}:\\ \;\;\;\;x \cdot e^{y \cdot \left(-t\right)}\\ \mathbf{elif}\;y \leq 2 \cdot 10^{-16}:\\ \;\;\;\;\frac{x}{e^{a \cdot \left(z + b\right)}}\\ \mathbf{else}:\\ \;\;\;\;x \cdot {z}^{y}\\ \end{array} \]
Alternative 3
Error26.3
Cost7052
\[\begin{array}{l} t_1 := x + a \cdot \left(x \cdot b\right)\\ \mathbf{if}\;y \leq -4.8 \cdot 10^{-8}:\\ \;\;\;\;\frac{\left(a \cdot a\right) \cdot \left(\left(b \cdot b\right) \cdot \left(x \cdot \left(-x\right)\right)\right)}{t_1}\\ \mathbf{elif}\;y \leq 9.6 \cdot 10^{-275}:\\ \;\;\;\;x + \left(y \cdot t\right) \cdot \left(\left(y \cdot t\right) \cdot \left(x \cdot 0.5\right) - x\right)\\ \mathbf{elif}\;y \leq 7.2 \cdot 10^{-112}:\\ \;\;\;\;\frac{x \cdot x}{t_1}\\ \mathbf{else}:\\ \;\;\;\;x \cdot {z}^{y}\\ \end{array} \]
Alternative 4
Error8.7
Cost6984
\[\begin{array}{l} \mathbf{if}\;y \leq -3 \cdot 10^{-40}:\\ \;\;\;\;x \cdot e^{y \cdot \left(-t\right)}\\ \mathbf{elif}\;y \leq 2 \cdot 10^{-16}:\\ \;\;\;\;\frac{x}{e^{a \cdot b}}\\ \mathbf{else}:\\ \;\;\;\;x \cdot {z}^{y}\\ \end{array} \]
Alternative 5
Error19.7
Cost6852
\[\begin{array}{l} \mathbf{if}\;a \leq 3.4 \cdot 10^{+20}:\\ \;\;\;\;x \cdot {z}^{y}\\ \mathbf{else}:\\ \;\;\;\;x \cdot {\left(-z\right)}^{a}\\ \end{array} \]
Alternative 6
Error11.0
Cost6852
\[\begin{array}{l} \mathbf{if}\;y \leq 2 \cdot 10^{-16}:\\ \;\;\;\;\frac{x}{e^{a \cdot b}}\\ \mathbf{else}:\\ \;\;\;\;x \cdot {z}^{y}\\ \end{array} \]
Alternative 7
Error38.1
Cost1809
\[\begin{array}{l} t_1 := x + a \cdot \left(x \cdot b\right)\\ t_2 := \frac{\left(a \cdot a\right) \cdot \left(\left(b \cdot b\right) \cdot \left(x \cdot \left(-x\right)\right)\right)}{t_1}\\ \mathbf{if}\;y \leq -3 \cdot 10^{-7}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 8 \cdot 10^{-275}:\\ \;\;\;\;x + \left(y \cdot t\right) \cdot \left(\left(y \cdot t\right) \cdot \left(x \cdot 0.5\right) - x\right)\\ \mathbf{elif}\;y \leq 2.2 \cdot 10^{+119} \lor \neg \left(y \leq 5 \cdot 10^{+254}\right):\\ \;\;\;\;\frac{x \cdot x}{t_1}\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 8
Error36.9
Cost1233
\[\begin{array}{l} t_1 := \frac{x \cdot x}{x + a \cdot \left(x \cdot b\right)}\\ \mathbf{if}\;y \leq -2 \cdot 10^{-8}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 6.2 \cdot 10^{-273}:\\ \;\;\;\;x - x \cdot \left(a \cdot b\right)\\ \mathbf{elif}\;y \leq 1.7 \cdot 10^{+119} \lor \neg \left(y \leq 2.3 \cdot 10^{+183}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\left(a \cdot b\right) \cdot \left(-x\right)\\ \end{array} \]
Alternative 9
Error37.0
Cost1233
\[\begin{array}{l} t_1 := \frac{x \cdot x}{x + a \cdot \left(x \cdot b\right)}\\ \mathbf{if}\;y \leq -2 \cdot 10^{-8}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 2.4 \cdot 10^{-272}:\\ \;\;\;\;x + x \cdot \left(\left(a \cdot b\right) \cdot \left(-1 + \left(a \cdot b\right) \cdot 0.5\right)\right)\\ \mathbf{elif}\;y \leq 1.3 \cdot 10^{+119} \lor \neg \left(y \leq 1.4 \cdot 10^{+184}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\left(a \cdot b\right) \cdot \left(-x\right)\\ \end{array} \]
Alternative 10
Error36.9
Cost1233
\[\begin{array}{l} t_1 := \frac{x \cdot x}{x + a \cdot \left(x \cdot b\right)}\\ \mathbf{if}\;y \leq -2.2 \cdot 10^{-8}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 5.8 \cdot 10^{-275}:\\ \;\;\;\;x + \left(y \cdot t\right) \cdot \left(\left(y \cdot t\right) \cdot \left(x \cdot 0.5\right) - x\right)\\ \mathbf{elif}\;y \leq 1.8 \cdot 10^{+120} \lor \neg \left(y \leq 1.15 \cdot 10^{+185}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\left(a \cdot b\right) \cdot \left(-x\right)\\ \end{array} \]
Alternative 11
Error40.3
Cost649
\[\begin{array}{l} \mathbf{if}\;y \leq -3.9 \lor \neg \left(y \leq 2.85 \cdot 10^{-30}\right):\\ \;\;\;\;b \cdot \left(x \cdot \left(-a\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 12
Error39.9
Cost648
\[\begin{array}{l} \mathbf{if}\;y \leq -4.2:\\ \;\;\;\;b \cdot \left(x \cdot \left(-a\right)\right)\\ \mathbf{elif}\;y \leq 4.6:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;\left(a \cdot b\right) \cdot \left(-x\right)\\ \end{array} \]
Alternative 13
Error40.0
Cost585
\[\begin{array}{l} \mathbf{if}\;y \leq -6.5 \lor \neg \left(y \leq 4.6\right):\\ \;\;\;\;a \cdot \left(x \cdot b\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 14
Error44.7
Cost64
\[x \]

Error

Reproduce?

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