?

Average Error: 0.1 → 0.1
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.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
Cost7113
\[\begin{array}{l} \mathbf{if}\;y \leq -4.5 \cdot 10^{+89} \lor \neg \left(y \leq 1.95 \cdot 10^{+15}\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 2
Error1.3
Cost7108
\[\begin{array}{l} \mathbf{if}\;z \leq 1.32 \cdot 10^{-11}:\\ \;\;\;\;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 3
Error0.1
Cost7104
\[x \cdot 0.5 + \left(\left(1 - z\right) + \log z\right) \cdot y \]
Alternative 4
Error14.8
Cost7049
\[\begin{array}{l} \mathbf{if}\;y \leq -2.5 \cdot 10^{+190} \lor \neg \left(y \leq 7.6 \cdot 10^{+164}\right):\\ \;\;\;\;y \cdot \left(1 + \log z\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-z, y, x \cdot 0.5\right)\\ \end{array} \]
Alternative 5
Error14.8
Cost6985
\[\begin{array}{l} \mathbf{if}\;y \leq -2.5 \cdot 10^{+190} \lor \neg \left(y \leq 2.05 \cdot 10^{+172}\right):\\ \;\;\;\;y \cdot \left(1 + \log z\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot 0.5 - z \cdot y\\ \end{array} \]
Alternative 6
Error29.7
Cost653
\[\begin{array}{l} \mathbf{if}\;z \leq 110000000 \lor \neg \left(z \leq 5.5 \cdot 10^{+32}\right) \land z \leq 1.5 \cdot 10^{+95}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(-y\right)\\ \end{array} \]
Alternative 7
Error29.7
Cost652
\[\begin{array}{l} \mathbf{if}\;z \leq 190000000:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;z \leq 5.3 \cdot 10^{+32}:\\ \;\;\;\;y - z \cdot y\\ \mathbf{elif}\;z \leq 1.55 \cdot 10^{+95}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(-y\right)\\ \end{array} \]
Alternative 8
Error18.4
Cost448
\[x \cdot 0.5 - z \cdot y \]
Alternative 9
Error35.0
Cost192
\[x \cdot 0.5 \]
Alternative 10
Error62.7
Cost64
\[y \]

Error

Reproduce?

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