?

Average Error: 10.0 → 0.1
Time: 16.9s
Precision: binary64
Cost: 19712

?

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

Error?

Target

Original10.0
Target0.3
Herbie0.1
\[\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 10.0

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

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

    [Start]10.0

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

    cancel-sign-sub [<=]10.0

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

    distribute-lft-neg-in [<=]10.0

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

    fma-neg [=>]10.0

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

    remove-double-neg [=>]10.0

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

    sub-neg [=>]10.0

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

    log1p-def [=>]0.1

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

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

Alternatives

Alternative 1
Error0.3
Cost13632
\[\left(x \cdot \log y - z \cdot \left(\mathsf{log1p}\left(y\right) + y \cdot y\right)\right) - t \]
Alternative 2
Error0.6
Cost13312
\[\mathsf{fma}\left(x, \log y, y \cdot \left(-z\right) - t\right) \]
Alternative 3
Error15.7
Cost7121
\[\begin{array}{l} t_1 := x \cdot \log y\\ \mathbf{if}\;x \leq -3 \cdot 10^{+25}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 3.5 \cdot 10^{-29}:\\ \;\;\;\;z \cdot \left(y \cdot \left(y \cdot -0.5\right) - y\right) - t\\ \mathbf{elif}\;x \leq 3.7 \cdot 10^{+76} \lor \neg \left(x \leq 4.5 \cdot 10^{+104}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;-t\\ \end{array} \]
Alternative 4
Error6.9
Cost7049
\[\begin{array}{l} \mathbf{if}\;x \leq -7.5 \cdot 10^{-8} \lor \neg \left(x \leq 1.85 \cdot 10^{-29}\right):\\ \;\;\;\;x \cdot \log y - t\\ \mathbf{else}:\\ \;\;\;\;z \cdot \mathsf{log1p}\left(-y\right) - t\\ \end{array} \]
Alternative 5
Error7.1
Cost6985
\[\begin{array}{l} \mathbf{if}\;x \leq -2.65 \cdot 10^{-5} \lor \neg \left(x \leq 2.35 \cdot 10^{-29}\right):\\ \;\;\;\;x \cdot \log y - t\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(y \cdot \left(y \cdot -0.5\right) - y\right) - t\\ \end{array} \]
Alternative 6
Error0.6
Cost6976
\[\left(x \cdot \log y - y \cdot z\right) - t \]
Alternative 7
Error26.5
Cost704
\[z \cdot \left(y \cdot \left(y \cdot -0.5\right) - y\right) - t \]
Alternative 8
Error33.3
Cost520
\[\begin{array}{l} \mathbf{if}\;t \leq -1.9 \cdot 10^{-156}:\\ \;\;\;\;-t\\ \mathbf{elif}\;t \leq 3.2 \cdot 10^{-178}:\\ \;\;\;\;y \cdot \left(-z\right)\\ \mathbf{else}:\\ \;\;\;\;-t\\ \end{array} \]
Alternative 9
Error26.7
Cost384
\[y \cdot \left(-z\right) - t \]
Alternative 10
Error36.5
Cost128
\[-t \]
Alternative 11
Error62.6
Cost64
\[t \]

Error

Reproduce?

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