Average Error: 0.1 → 0.1
Time: 6.7s
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.1
Target0.1
Herbie0.1
\[\left(y + 0.5 \cdot x\right) - y \cdot \left(z - \log z\right) \]

Derivation

  1. Initial program 0.1

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

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

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

Alternatives

Alternative 1
Error11.1
Cost7888
\[\begin{array}{l} t_0 := y \cdot \left(\left(1 + \log z\right) - z\right)\\ t_1 := \mathsf{fma}\left(-z, y, x \cdot 0.5\right)\\ \mathbf{if}\;x \cdot 0.5 \leq -5 \cdot 10^{+38}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \cdot 0.5 \leq -100000000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \cdot 0.5 \leq -5 \cdot 10^{-91}:\\ \;\;\;\;x \cdot 0.5 - z \cdot y\\ \mathbf{elif}\;x \cdot 0.5 \leq 10^{-83}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error0.1
Cost7232
\[x \cdot 0.5 + \left(y \cdot \left(1 + \log z\right) - z \cdot y\right) \]
Alternative 3
Error0.9
Cost7108
\[\begin{array}{l} \mathbf{if}\;z \leq 0.28:\\ \;\;\;\;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 4
Error0.1
Cost7104
\[x \cdot 0.5 + \left(\left(1 - z\right) + \log z\right) \cdot y \]
Alternative 5
Error14.1
Cost7048
\[\begin{array}{l} t_0 := y \cdot \left(1 + \log z\right)\\ \mathbf{if}\;y \leq -7.5 \cdot 10^{+129}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 7 \cdot 10^{+170}:\\ \;\;\;\;\mathsf{fma}\left(-z, y, x \cdot 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error14.1
Cost6984
\[\begin{array}{l} t_0 := y \cdot \left(1 + \log z\right)\\ \mathbf{if}\;y \leq -9.5 \cdot 10^{+130}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 8 \cdot 10^{+170}:\\ \;\;\;\;x \cdot 0.5 - z \cdot y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 7
Error28.8
Cost520
\[\begin{array}{l} \mathbf{if}\;x \leq -1.12 \cdot 10^{-58}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;x \leq 8.4 \cdot 10^{-77}:\\ \;\;\;\;y \cdot \left(-z\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot 0.5\\ \end{array} \]
Alternative 8
Error18.1
Cost448
\[x \cdot 0.5 - z \cdot y \]
Alternative 9
Error34.9
Cost192
\[x \cdot 0.5 \]
Alternative 10
Error62.7
Cost64
\[y \]

Error

Reproduce

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