?

Average Error: 0.14% → 0.13%
Time: 11.9s
Precision: binary64
Cost: 13376

?

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

Error?

Target

Original0.14%
Target0.19%
Herbie0.13%
\[\left(y + 0.5 \cdot x\right) - y \cdot \left(z - \log z\right) \]

Derivation?

  1. Initial program 0.14

    \[x \cdot 0.5 + y \cdot \left(\left(1 - z\right) + \log z\right) \]
  2. Applied egg-rr0.13

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

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

Alternatives

Alternative 1
Error28.1%
Cost7382
\[\begin{array}{l} \mathbf{if}\;z \leq 3 \cdot 10^{-292} \lor \neg \left(z \leq 3.7 \cdot 10^{-244}\right) \land \left(z \leq 3.5 \cdot 10^{-128} \lor \neg \left(z \leq 2 \cdot 10^{-60}\right) \land z \leq 1.28 \cdot 10^{-39}\right):\\ \;\;\;\;y \cdot \left(1 + \log z\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot 0.5 - z \cdot y\\ \end{array} \]
Alternative 2
Error28.05%
Cost7382
\[\begin{array}{l} \mathbf{if}\;z \leq 2.95 \cdot 10^{-292}:\\ \;\;\;\;y + \log z \cdot y\\ \mathbf{elif}\;z \leq 5.7 \cdot 10^{-244} \lor \neg \left(z \leq 7.4 \cdot 10^{-128} \lor \neg \left(z \leq 2.3 \cdot 10^{-60}\right) \land z \leq 1.65 \cdot 10^{-39}\right):\\ \;\;\;\;x \cdot 0.5 - z \cdot y\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(1 + \log z\right)\\ \end{array} \]
Alternative 3
Error18.09%
Cost7378
\[\begin{array}{l} \mathbf{if}\;y \leq -1.2 \cdot 10^{+59} \lor \neg \left(y \leq -9.8 \cdot 10^{-75}\right) \land \left(y \leq -6.6 \cdot 10^{-97} \lor \neg \left(y \leq 9.5 \cdot 10^{+139}\right)\right):\\ \;\;\;\;y \cdot \left(\left(1 + \log z\right) - z\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot 0.5 - z \cdot y\\ \end{array} \]
Alternative 4
Error18.09%
Cost7377
\[\begin{array}{l} \mathbf{if}\;y \leq -3.8 \cdot 10^{+58}:\\ \;\;\;\;y \cdot \left(\left(1 + \log z\right) - z\right)\\ \mathbf{elif}\;y \leq -2.2 \cdot 10^{-76} \lor \neg \left(y \leq -3.3 \cdot 10^{-97}\right) \land y \leq 9.5 \cdot 10^{+139}:\\ \;\;\;\;x \cdot 0.5 - z \cdot y\\ \mathbf{else}:\\ \;\;\;\;y + y \cdot \left(\log z - z\right)\\ \end{array} \]
Alternative 5
Error0.14%
Cost7232
\[x \cdot 0.5 + \left(y \cdot \left(1 + \log z\right) - z \cdot y\right) \]
Alternative 6
Error1.36%
Cost7108
\[\begin{array}{l} \mathbf{if}\;z \leq 0.27:\\ \;\;\;\;x \cdot 0.5 + y \cdot \left(1 + \log z\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot 0.5 - z \cdot y\\ \end{array} \]
Alternative 7
Error0.14%
Cost7104
\[x \cdot 0.5 + \left(\left(1 - z\right) + \log z\right) \cdot y \]
Alternative 8
Error45.06%
Cost918
\[\begin{array}{l} \mathbf{if}\;z \leq 3.5 \cdot 10^{+22} \lor \neg \left(z \leq 3 \cdot 10^{+64}\right) \land \left(z \leq 1.65 \cdot 10^{+91} \lor \neg \left(z \leq 5 \cdot 10^{+179}\right) \land z \leq 5 \cdot 10^{+184}\right):\\ \;\;\;\;x \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(-y\right)\\ \end{array} \]
Alternative 9
Error28.41%
Cost448
\[x \cdot 0.5 - z \cdot y \]
Alternative 10
Error54.14%
Cost192
\[x \cdot 0.5 \]

Error

Reproduce?

herbie shell --seed 2023102 
(FPCore (x y z)
  :name "System.Random.MWC.Distributions:gamma from mwc-random-0.13.3.2"
  :precision binary64

  :herbie-target
  (- (+ y (* 0.5 x)) (* y (- z (log z))))

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