Average Error: 9.9 → 0.1
Time: 12.7s
Precision: binary64
\[\left(x \cdot \log y + z \cdot \log \left(1 - y\right)\right) - t \]
\[\mathsf{fma}\left(\mathsf{log1p}\left(-y\right), z, \log y \cdot x\right) - t \]
\left(x \cdot \log y + z \cdot \log \left(1 - y\right)\right) - t
\mathsf{fma}\left(\mathsf{log1p}\left(-y\right), z, \log y \cdot x\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 (log1p (- y)) z (* (log y) x)) 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(log1p(-y), z, (log(y) * x)) - t;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original9.9
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 9.9

    \[\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} \]
  3. Applied add-cube-cbrt_binary640.7

    \[\leadsto \mathsf{fma}\left(x, \log y, z \cdot \mathsf{log1p}\left(-y\right)\right) - \color{blue}{\left(\sqrt[3]{t} \cdot \sqrt[3]{t}\right) \cdot \sqrt[3]{t}} \]
  4. Applied add-cube-cbrt_binary641.3

    \[\leadsto \color{blue}{\left(\sqrt[3]{\mathsf{fma}\left(x, \log y, z \cdot \mathsf{log1p}\left(-y\right)\right)} \cdot \sqrt[3]{\mathsf{fma}\left(x, \log y, z \cdot \mathsf{log1p}\left(-y\right)\right)}\right) \cdot \sqrt[3]{\mathsf{fma}\left(x, \log y, z \cdot \mathsf{log1p}\left(-y\right)\right)}} - \left(\sqrt[3]{t} \cdot \sqrt[3]{t}\right) \cdot \sqrt[3]{t} \]
  5. Applied prod-diff_binary641.3

    \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt[3]{\mathsf{fma}\left(x, \log y, z \cdot \mathsf{log1p}\left(-y\right)\right)} \cdot \sqrt[3]{\mathsf{fma}\left(x, \log y, z \cdot \mathsf{log1p}\left(-y\right)\right)}, \sqrt[3]{\mathsf{fma}\left(x, \log y, z \cdot \mathsf{log1p}\left(-y\right)\right)}, -\sqrt[3]{t} \cdot \left(\sqrt[3]{t} \cdot \sqrt[3]{t}\right)\right) + \mathsf{fma}\left(-\sqrt[3]{t}, \sqrt[3]{t} \cdot \sqrt[3]{t}, \sqrt[3]{t} \cdot \left(\sqrt[3]{t} \cdot \sqrt[3]{t}\right)\right)} \]
  6. Simplified0.1

    \[\leadsto \color{blue}{\left(\mathsf{fma}\left(\mathsf{log1p}\left(-y\right), z, \log y \cdot x\right) - t\right)} + \mathsf{fma}\left(-\sqrt[3]{t}, \sqrt[3]{t} \cdot \sqrt[3]{t}, \sqrt[3]{t} \cdot \left(\sqrt[3]{t} \cdot \sqrt[3]{t}\right)\right) \]
  7. Simplified0.1

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

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

Reproduce

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