?

Average Error: 0.14% → 0.14%
Time: 12.5s
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.18%
Herbie0.14%
\[\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.14

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

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

Alternatives

Alternative 1
Error22.33%
Cost7313
\[\begin{array}{l} t_0 := y \cdot \left(1 + \log z\right)\\ \mathbf{if}\;y \leq -2.8 \cdot 10^{+218}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -6.5 \cdot 10^{+168}:\\ \;\;\;\;x \cdot 0.5 - z \cdot y\\ \mathbf{elif}\;y \leq -4.2 \cdot 10^{+136} \lor \neg \left(y \leq 2.35 \cdot 10^{+174}\right):\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-z, y, x \cdot 0.5\right)\\ \end{array} \]
Alternative 2
Error22.35%
Cost7250
\[\begin{array}{l} \mathbf{if}\;y \leq -1.75 \cdot 10^{+218} \lor \neg \left(y \leq -1.75 \cdot 10^{+167} \lor \neg \left(y \leq -1.15 \cdot 10^{+136}\right) \land y \leq 6.2 \cdot 10^{+170}\right):\\ \;\;\;\;y \cdot \left(1 + \log z\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot 0.5 - z \cdot y\\ \end{array} \]
Alternative 3
Error16.58%
Cost7113
\[\begin{array}{l} \mathbf{if}\;y \leq -5.2 \cdot 10^{+53} \lor \neg \left(y \leq 0.00122\right):\\ \;\;\;\;y \cdot \left(\left(1 + \log z\right) - z\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-z, y, x \cdot 0.5\right)\\ \end{array} \]
Alternative 4
Error1.33%
Cost7108
\[\begin{array}{l} \mathbf{if}\;z \leq 0.27:\\ \;\;\;\;x \cdot 0.5 + y \cdot \left(1 + \log z\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-z, y, x \cdot 0.5\right)\\ \end{array} \]
Alternative 5
Error0.14%
Cost7104
\[x \cdot 0.5 + \left(\left(1 - z\right) + \log z\right) \cdot y \]
Alternative 6
Error46.64%
Cost785
\[\begin{array}{l} \mathbf{if}\;x \leq -2.35 \cdot 10^{+60}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;x \leq -3.6 \cdot 10^{-22} \lor \neg \left(x \leq -1.4 \cdot 10^{-125}\right) \land x \leq 1150000000:\\ \;\;\;\;z \cdot \left(-y\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot 0.5\\ \end{array} \]
Alternative 7
Error28.06%
Cost448
\[x \cdot 0.5 - z \cdot y \]
Alternative 8
Error54.02%
Cost192
\[x \cdot 0.5 \]
Alternative 9
Error97.94%
Cost64
\[y \]

Error

Reproduce?

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