Average Error: 9.2 → 0.1
Time: 7.8s
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 \]
(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;
}
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(log1p(Float64(-y)), z, Float64(log(y) * x)) - 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[(N[Log[1 + (-y)], $MachinePrecision] * z + N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\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

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original9.2
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.2

    \[\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. Taylor expanded in x around 0 9.2

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{log1p}\left(-y\right), z, \log y \cdot x\right)} - t \]
  5. Applied add-cube-cbrt_binary640.6

    \[\leadsto \mathsf{fma}\left(\mathsf{log1p}\left(-y\right), z, \color{blue}{\left(\left(\sqrt[3]{\log y} \cdot \sqrt[3]{\log y}\right) \cdot \sqrt[3]{\log y}\right)} \cdot x\right) - t \]
  6. Applied associate-*l*_binary640.6

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

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

    \[\leadsto \mathsf{fma}\left(\mathsf{log1p}\left(-y\right), z, \left(\sqrt[3]{\log y} \cdot \sqrt[3]{\log y}\right) \cdot \left(\color{blue}{{\left(\sqrt[3]{\log y}\right)}^{1}} \cdot {x}^{1}\right)\right) - t \]
  9. Applied pow-prod-down_binary640.6

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

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

    \[\leadsto \mathsf{fma}\left(\mathsf{log1p}\left(-y\right), z, \left(\color{blue}{{\left(\sqrt[3]{\log y}\right)}^{1}} \cdot {\left(\sqrt[3]{\log y}\right)}^{1}\right) \cdot {\left(\sqrt[3]{\log y} \cdot x\right)}^{1}\right) - t \]
  12. Applied pow-prod-down_binary640.6

    \[\leadsto \mathsf{fma}\left(\mathsf{log1p}\left(-y\right), z, \color{blue}{{\left(\sqrt[3]{\log y} \cdot \sqrt[3]{\log y}\right)}^{1}} \cdot {\left(\sqrt[3]{\log y} \cdot x\right)}^{1}\right) - t \]
  13. Applied pow-prod-down_binary640.6

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

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

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

Reproduce

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