Average Error: 2.1 → 0.2
Time: 29.6s
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(a, \mathsf{log1p}\left(-z\right) - b, y \cdot \left(\log z - t\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 a (- (log1p (- z)) b) (* y (- (log z) t))))))
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(a, (log1p(-z) - b), (y * (log(z) - t))));
}
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(a, Float64(log1p(Float64(-z)) - b), Float64(y * Float64(log(z) - t)))))
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[(a * N[(N[Log[1 + (-z)], $MachinePrecision] - b), $MachinePrecision] + N[(y * N[(N[Log[z], $MachinePrecision] - t), $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(a, \mathsf{log1p}\left(-z\right) - b, y \cdot \left(\log z - t\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.2

    \[\leadsto \color{blue}{x \cdot e^{\mathsf{fma}\left(a, \mathsf{log1p}\left(-z\right) - b, y \cdot \left(\log z - t\right)\right)}} \]
    Proof
    (*.f64 x (exp.f64 (fma.f64 a (-.f64 (log1p.f64 (neg.f64 z)) b) (*.f64 y (-.f64 (log.f64 z) t))))): 0 points increase in error, 0 points decrease in error
    (*.f64 x (exp.f64 (fma.f64 a (-.f64 (Rewrite<= log1p-def_binary64 (log.f64 (+.f64 1 (neg.f64 z)))) b) (*.f64 y (-.f64 (log.f64 z) t))))): 8 points increase in error, 0 points decrease in error
    (*.f64 x (exp.f64 (fma.f64 a (-.f64 (log.f64 (Rewrite<= sub-neg_binary64 (-.f64 1 z))) b) (*.f64 y (-.f64 (log.f64 z) t))))): 0 points increase in error, 0 points decrease in error
    (*.f64 x (exp.f64 (Rewrite<= fma-def_binary64 (+.f64 (*.f64 a (-.f64 (log.f64 (-.f64 1 z)) b)) (*.f64 y (-.f64 (log.f64 z) t)))))): 0 points increase in error, 0 points decrease in error
    (*.f64 x (exp.f64 (Rewrite<= +-commutative_binary64 (+.f64 (*.f64 y (-.f64 (log.f64 z) t)) (*.f64 a (-.f64 (log.f64 (-.f64 1 z)) b)))))): 0 points increase in error, 0 points decrease in error
  3. Final simplification0.2

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

Alternatives

Alternative 1
Error0.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 -0.0002:\\ \;\;\;\;x \cdot e^{t_1}\\ \mathbf{else}:\\ \;\;\;\;x \cdot e^{a \cdot \left(\left(-b\right) - z\right)}\\ \end{array} \]
Alternative 2
Error7.0
Cost13448
\[\begin{array}{l} \mathbf{if}\;y \leq -1.22 \cdot 10^{+159}:\\ \;\;\;\;x \cdot e^{y \cdot \left(-t\right)}\\ \mathbf{elif}\;y \leq 1.55 \cdot 10^{-11}:\\ \;\;\;\;x \cdot e^{a \cdot \left(\left(-b\right) - z\right)}\\ \mathbf{else}:\\ \;\;\;\;x \cdot {\left(\frac{z}{e^{t}}\right)}^{y}\\ \end{array} \]
Alternative 3
Error17.7
Cost7444
\[\begin{array}{l} t_1 := x \cdot {z}^{y}\\ t_2 := y \cdot \left(\left(x \cdot \left(t \cdot t\right)\right) \cdot \left(y \cdot 0.5\right)\right)\\ t_3 := x \cdot e^{y \cdot \left(-t\right)}\\ \mathbf{if}\;t \leq -2.8 \cdot 10^{+21}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq -1.75 \cdot 10^{-262}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 3.7 \cdot 10^{-165}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 3.8 \cdot 10^{-144}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 2.1 \cdot 10^{-133}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 4
Error9.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.22 \cdot 10^{+159}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 1.85 \cdot 10^{-153}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.8 \cdot 10^{-120}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 155000:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x \cdot {z}^{y}\\ \end{array} \]
Alternative 5
Error20.5
Cost7180
\[\begin{array}{l} \mathbf{if}\;y \leq -5.2 \cdot 10^{+136}:\\ \;\;\;\;\left(1 + \left(x + x \cdot \left(a \cdot b\right)\right)\right) + -1\\ \mathbf{elif}\;y \leq -1.7 \cdot 10^{+62}:\\ \;\;\;\;y \cdot \left(\left(x \cdot \left(t \cdot t\right)\right) \cdot \left(y \cdot 0.5\right)\right)\\ \mathbf{elif}\;y \leq 4.7 \cdot 10^{-17}:\\ \;\;\;\;x \cdot e^{a \cdot \left(-z\right)}\\ \mathbf{else}:\\ \;\;\;\;x \cdot {z}^{y}\\ \end{array} \]
Alternative 6
Error6.6
Cost7176
\[\begin{array}{l} \mathbf{if}\;y \leq -1.22 \cdot 10^{+159}:\\ \;\;\;\;x \cdot e^{y \cdot \left(-t\right)}\\ \mathbf{elif}\;y \leq 0.21:\\ \;\;\;\;x \cdot e^{a \cdot \left(\left(-b\right) - z\right)}\\ \mathbf{else}:\\ \;\;\;\;x \cdot {z}^{y}\\ \end{array} \]
Alternative 7
Error25.7
Cost7052
\[\begin{array}{l} t_1 := x \cdot {z}^{y}\\ \mathbf{if}\;t \leq -4.8 \cdot 10^{+42}:\\ \;\;\;\;\left(1 + \left(x + x \cdot \left(a \cdot b\right)\right)\right) + -1\\ \mathbf{elif}\;t \leq -1.75 \cdot 10^{-262}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 3.7 \cdot 10^{-165}:\\ \;\;\;\;y \cdot \left(\left(x \cdot \left(t \cdot t\right)\right) \cdot \left(y \cdot 0.5\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error36.2
Cost1364
\[\begin{array}{l} t_1 := \left(1 + \left(x + x \cdot \left(a \cdot b\right)\right)\right) + -1\\ \mathbf{if}\;t \leq -4.7 \cdot 10^{+42}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -2.2 \cdot 10^{-42}:\\ \;\;\;\;x - a \cdot \left(x \cdot \left(z + b\right)\right)\\ \mathbf{elif}\;t \leq -3.3 \cdot 10^{-167}:\\ \;\;\;\;\left(1 + \left(x + x \cdot \left(y \cdot t\right)\right)\right) + -1\\ \mathbf{elif}\;t \leq 5.8 \cdot 10^{-133}:\\ \;\;\;\;y \cdot \left(\left(x \cdot \left(t \cdot t\right)\right) \cdot \left(y \cdot 0.5\right)\right)\\ \mathbf{elif}\;t \leq 9 \cdot 10^{+23}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Error36.6
Cost1100
\[\begin{array}{l} t_1 := y \cdot \left(\left(x \cdot \left(t \cdot t\right)\right) \cdot \left(y \cdot 0.5\right)\right)\\ \mathbf{if}\;y \leq -7.5 \cdot 10^{-34}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 3 \cdot 10^{-52}:\\ \;\;\;\;x \cdot \left(1 - a \cdot b\right)\\ \mathbf{elif}\;y \leq 3.5 \cdot 10^{+160}:\\ \;\;\;\;-1 + \left(1 + x \cdot \left(y \cdot t\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Error36.5
Cost840
\[\begin{array}{l} t_1 := -1 + \left(1 + x \cdot \left(y \cdot t\right)\right)\\ \mathbf{if}\;a \leq -4.5 \cdot 10^{-125}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 1.65 \cdot 10^{+16}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 11
Error36.9
Cost840
\[\begin{array}{l} t_1 := -1 + \left(1 + x \cdot \left(y \cdot t\right)\right)\\ \mathbf{if}\;a \leq -5 \cdot 10^{-126}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 1.95 \cdot 10^{+77}:\\ \;\;\;\;x \cdot \left(1 - a \cdot b\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 12
Error42.3
Cost584
\[\begin{array}{l} t_1 := y \cdot \left(x \cdot t\right)\\ \mathbf{if}\;a \leq -1200000000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 3.1 \cdot 10^{+174}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 13
Error44.2
Cost64
\[x \]

Error

Reproduce

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