?

Average Accuracy: 85.8% → 99.8%
Time: 12.7s
Precision: binary64
Cost: 19712

?

\[\left(x \cdot \log y + z \cdot \log \left(1 - y\right)\right) - t \]
\[\mathsf{fma}\left(z, \mathsf{log1p}\left(-y\right), x \cdot \log y - t\right) \]
(FPCore (x y z t)
 :precision binary64
 (- (+ (* x (log y)) (* z (log (- 1.0 y)))) t))
(FPCore (x y z t)
 :precision binary64
 (fma z (log1p (- y)) (- (* x (log y)) t)))
double code(double x, double y, double z, double t) {
	return ((x * log(y)) + (z * log((1.0 - y)))) - t;
}
double code(double x, double y, double z, double t) {
	return fma(z, log1p(-y), ((x * log(y)) - t));
}
function code(x, y, z, t)
	return Float64(Float64(Float64(x * log(y)) + Float64(z * log(Float64(1.0 - y)))) - t)
end
function code(x, y, z, t)
	return fma(z, log1p(Float64(-y)), Float64(Float64(x * log(y)) - t))
end
code[x_, y_, z_, t_] := N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] + N[(z * N[Log[N[(1.0 - y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
code[x_, y_, z_, t_] := N[(z * N[Log[1 + (-y)], $MachinePrecision] + N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]
\left(x \cdot \log y + z \cdot \log \left(1 - y\right)\right) - t
\mathsf{fma}\left(z, \mathsf{log1p}\left(-y\right), x \cdot \log y - t\right)

Error?

Target

Original85.8%
Target99.6%
Herbie99.8%
\[\left(-z\right) \cdot \left(\left(0.5 \cdot \left(y \cdot y\right) + y\right) + \frac{0.3333333333333333}{1 \cdot \left(1 \cdot 1\right)} \cdot \left(y \cdot \left(y \cdot y\right)\right)\right) - \left(t - x \cdot \log y\right) \]

Derivation?

  1. Initial program 85.8%

    \[\left(x \cdot \log y + z \cdot \log \left(1 - y\right)\right) - t \]
  2. Simplified99.8%

    \[\leadsto \color{blue}{\mathsf{fma}\left(z, \mathsf{log1p}\left(-y\right), x \cdot \log y - t\right)} \]
    Proof

    [Start]85.8

    \[ \left(x \cdot \log y + z \cdot \log \left(1 - y\right)\right) - t \]

    +-commutative [=>]85.8

    \[ \color{blue}{\left(z \cdot \log \left(1 - y\right) + x \cdot \log y\right)} - t \]

    associate--l+ [=>]85.8

    \[ \color{blue}{z \cdot \log \left(1 - y\right) + \left(x \cdot \log y - t\right)} \]

    fma-def [=>]85.8

    \[ \color{blue}{\mathsf{fma}\left(z, \log \left(1 - y\right), x \cdot \log y - t\right)} \]

    sub-neg [=>]85.8

    \[ \mathsf{fma}\left(z, \log \color{blue}{\left(1 + \left(-y\right)\right)}, x \cdot \log y - t\right) \]

    log1p-def [=>]99.8

    \[ \mathsf{fma}\left(z, \color{blue}{\mathsf{log1p}\left(-y\right)}, x \cdot \log y - t\right) \]
  3. Final simplification99.8%

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

Alternatives

Alternative 1
Accuracy99.5%
Cost7360
\[\left(z \cdot \left(y \cdot \left(y \cdot -0.5\right) - y\right) + x \cdot \log y\right) - t \]
Alternative 2
Accuracy76.1%
Cost7121
\[\begin{array}{l} t_1 := x \cdot \log y\\ \mathbf{if}\;x \leq -2.8 \cdot 10^{+131}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.5 \cdot 10^{-19}:\\ \;\;\;\;z \cdot \left(\left(y \cdot y\right) \cdot \left(-0.5 + y \cdot -0.3333333333333333\right) - y\right) - t\\ \mathbf{elif}\;x \leq 1.02 \cdot 10^{+29} \lor \neg \left(x \leq 8.2 \cdot 10^{+125}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(y \cdot \left(y \cdot -0.5\right) - y\right) - t\\ \end{array} \]
Alternative 3
Accuracy90.6%
Cost7113
\[\begin{array}{l} t_1 := x \cdot \log y\\ \mathbf{if}\;t \leq -1.95 \cdot 10^{-35} \lor \neg \left(t \leq 1.5 \cdot 10^{-132}\right):\\ \;\;\;\;t_1 - t\\ \mathbf{else}:\\ \;\;\;\;t_1 - z \cdot y\\ \end{array} \]
Alternative 4
Accuracy90.4%
Cost7049
\[\begin{array}{l} \mathbf{if}\;x \leq -9 \cdot 10^{-38} \lor \neg \left(x \leq 4.4 \cdot 10^{-43}\right):\\ \;\;\;\;x \cdot \log y - t\\ \mathbf{else}:\\ \;\;\;\;z \cdot \mathsf{log1p}\left(-y\right) - t\\ \end{array} \]
Alternative 5
Accuracy90.3%
Cost6985
\[\begin{array}{l} \mathbf{if}\;x \leq -8 \cdot 10^{-37} \lor \neg \left(x \leq 3.8 \cdot 10^{-43}\right):\\ \;\;\;\;x \cdot \log y - t\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(\left(y \cdot y\right) \cdot \left(-0.5 + y \cdot -0.3333333333333333\right) - y\right) - t\\ \end{array} \]
Alternative 6
Accuracy99.2%
Cost6976
\[\left(x \cdot \log y - z \cdot y\right) - t \]
Alternative 7
Accuracy57.9%
Cost960
\[z \cdot \left(\left(y \cdot y\right) \cdot \left(-0.5 + y \cdot -0.3333333333333333\right) - y\right) - t \]
Alternative 8
Accuracy57.8%
Cost704
\[z \cdot \left(y \cdot \left(y \cdot -0.5\right) - y\right) - t \]
Alternative 9
Accuracy49.3%
Cost520
\[\begin{array}{l} \mathbf{if}\;t \leq -6.5 \cdot 10^{-39}:\\ \;\;\;\;-t\\ \mathbf{elif}\;t \leq 1.22 \cdot 10^{-132}:\\ \;\;\;\;z \cdot \left(-y\right)\\ \mathbf{else}:\\ \;\;\;\;-t\\ \end{array} \]
Alternative 10
Accuracy57.5%
Cost384
\[z \cdot \left(-y\right) - t \]
Alternative 11
Accuracy43.5%
Cost128
\[-t \]

Error

Reproduce?

herbie shell --seed 2023137 
(FPCore (x y z t)
  :name "Numeric.SpecFunctions:invIncompleteBetaWorker from math-functions-0.1.5.2, B"
  :precision binary64

  :herbie-target
  (- (* (- z) (+ (+ (* 0.5 (* y y)) y) (* (/ 0.3333333333333333 (* 1.0 (* 1.0 1.0))) (* y (* y y))))) (- t (* x (log y))))

  (- (+ (* x (log y)) (* z (log (- 1.0 y)))) t))