?

Average Accuracy: 85.3% → 99.8%
Time: 11.7s
Precision: binary64
Cost: 26048

?

\[\left(x \cdot \log y + z \cdot \log \left(1 - y\right)\right) - t \]
\[\mathsf{fma}\left(x, \log y, \mathsf{fma}\left(z, \mathsf{log1p}\left(-y\right), -t\right)\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 x (log y) (fma z (log1p (- 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(x, log(y), fma(z, log1p(-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(x, log(y), fma(z, log1p(Float64(-y)), Float64(-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[(x * N[Log[y], $MachinePrecision] + N[(z * N[Log[1 + (-y)], $MachinePrecision] + (-t)), $MachinePrecision]), $MachinePrecision]
\left(x \cdot \log y + z \cdot \log \left(1 - y\right)\right) - t
\mathsf{fma}\left(x, \log y, \mathsf{fma}\left(z, \mathsf{log1p}\left(-y\right), -t\right)\right)

Error?

Target

Original85.3%
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.3%

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

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

    [Start]85.3

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

    associate--l+ [=>]85.3

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

    fma-def [=>]85.3

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

    fma-neg [=>]85.3

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

    sub-neg [=>]85.3

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

    log1p-def [=>]99.8

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

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

Alternatives

Alternative 1
Accuracy99.8%
Cost19712
\[\mathsf{fma}\left(x, \log y, z \cdot \mathsf{log1p}\left(-y\right)\right) - t \]
Alternative 2
Accuracy99.8%
Cost19712
\[\mathsf{fma}\left(z, \mathsf{log1p}\left(-y\right), x \cdot \log y - t\right) \]
Alternative 3
Accuracy99.2%
Cost13312
\[\mathsf{fma}\left(x, \log y, z \cdot \left(-y\right) - t\right) \]
Alternative 4
Accuracy90.5%
Cost7113
\[\begin{array}{l} t_1 := x \cdot \log y\\ \mathbf{if}\;t \leq -5.2 \cdot 10^{-87} \lor \neg \left(t \leq 6 \cdot 10^{-120}\right):\\ \;\;\;\;t_1 - t\\ \mathbf{else}:\\ \;\;\;\;t_1 - y \cdot z\\ \end{array} \]
Alternative 5
Accuracy90.4%
Cost7049
\[\begin{array}{l} \mathbf{if}\;x \leq -1.6 \cdot 10^{-122} \lor \neg \left(x \leq 8 \cdot 10^{-45}\right):\\ \;\;\;\;x \cdot \log y - t\\ \mathbf{else}:\\ \;\;\;\;z \cdot \mathsf{log1p}\left(-y\right) - t\\ \end{array} \]
Alternative 6
Accuracy90.1%
Cost6985
\[\begin{array}{l} \mathbf{if}\;x \leq -9 \cdot 10^{-123} \lor \neg \left(x \leq 1.7 \cdot 10^{-44}\right):\\ \;\;\;\;x \cdot \log y - t\\ \mathbf{else}:\\ \;\;\;\;-\mathsf{fma}\left(y, z, t\right)\\ \end{array} \]
Alternative 7
Accuracy99.2%
Cost6976
\[\left(x \cdot \log y - y \cdot z\right) - t \]
Alternative 8
Accuracy76.9%
Cost6921
\[\begin{array}{l} \mathbf{if}\;x \leq -2.1 \cdot 10^{+92} \lor \neg \left(x \leq 6 \cdot 10^{+37}\right):\\ \;\;\;\;x \cdot \log y\\ \mathbf{else}:\\ \;\;\;\;-\mathsf{fma}\left(y, z, t\right)\\ \end{array} \]
Alternative 9
Accuracy76.9%
Cost6857
\[\begin{array}{l} \mathbf{if}\;x \leq -4.2 \cdot 10^{+90} \lor \neg \left(x \leq 2.1 \cdot 10^{+37}\right):\\ \;\;\;\;x \cdot \log y\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(-y\right) - t\\ \end{array} \]
Alternative 10
Accuracy49.6%
Cost520
\[\begin{array}{l} \mathbf{if}\;t \leq -1.15 \cdot 10^{-91}:\\ \;\;\;\;-t\\ \mathbf{elif}\;t \leq 5.2 \cdot 10^{-119}:\\ \;\;\;\;z \cdot \left(-y\right)\\ \mathbf{else}:\\ \;\;\;\;-t\\ \end{array} \]
Alternative 11
Accuracy58.0%
Cost384
\[z \cdot \left(-y\right) - t \]
Alternative 12
Accuracy43.6%
Cost128
\[-t \]

Error

Reproduce?

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