?

Average Error: 0.1 → 0.1
Time: 12.1s
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
Error18.6
Cost7708
\[\begin{array}{l} t_0 := y \cdot \left(1 + \log z\right)\\ t_1 := x \cdot 0.5 - z \cdot y\\ \mathbf{if}\;z \leq 1.05 \cdot 10^{-293}:\\ \;\;\;\;y + \log z \cdot y\\ \mathbf{elif}\;z \leq 1.95 \cdot 10^{-264}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.5 \cdot 10^{-223}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 3 \cdot 10^{-178}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.45 \cdot 10^{-173}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1.35 \cdot 10^{-73}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 5 \cdot 10^{-38}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-z, y, x \cdot 0.5\right)\\ \end{array} \]
Alternative 2
Error18.6
Cost7647
\[\begin{array}{l} \mathbf{if}\;z \leq 1.4 \cdot 10^{-293} \lor \neg \left(z \leq 2.3 \cdot 10^{-264}\right) \land \left(z \leq 1.52 \cdot 10^{-223} \lor \neg \left(z \leq 6.8 \cdot 10^{-178}\right) \land \left(z \leq 1.5 \cdot 10^{-173} \lor \neg \left(z \leq 1.35 \cdot 10^{-73}\right) \land z \leq 7.5 \cdot 10^{-37}\right)\right):\\ \;\;\;\;y \cdot \left(1 + \log z\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot 0.5 - z \cdot y\\ \end{array} \]
Alternative 3
Error18.6
Cost7647
\[\begin{array}{l} \mathbf{if}\;z \leq 3.1 \cdot 10^{-293}:\\ \;\;\;\;y + \log z \cdot y\\ \mathbf{elif}\;z \leq 1.66 \cdot 10^{-264} \lor \neg \left(z \leq 1.5 \cdot 10^{-223} \lor \neg \left(z \leq 5.7 \cdot 10^{-179}\right) \land \left(z \leq 2.35 \cdot 10^{-173} \lor \neg \left(z \leq 1.1 \cdot 10^{-73}\right) \land z \leq 5.5 \cdot 10^{-38}\right)\right):\\ \;\;\;\;x \cdot 0.5 - z \cdot y\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(1 + \log z\right)\\ \end{array} \]
Alternative 4
Error10.8
Cost7368
\[\begin{array}{l} \mathbf{if}\;x \cdot 0.5 \leq -1 \cdot 10^{-47}:\\ \;\;\;\;x \cdot 0.5 - z \cdot y\\ \mathbf{elif}\;x \cdot 0.5 \leq 5 \cdot 10^{-108}:\\ \;\;\;\;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 5
Error18.2
Cost7241
\[\begin{array}{l} \mathbf{if}\;x \cdot 0.5 \leq -4 \cdot 10^{-119} \lor \neg \left(x \cdot 0.5 \leq 5 \cdot 10^{-108}\right):\\ \;\;\;\;x \cdot 0.5 - z \cdot y\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(\log z - z\right)\\ \end{array} \]
Alternative 6
Error1.0
Cost7108
\[\begin{array}{l} \mathbf{if}\;z \leq 0.008:\\ \;\;\;\;\log z \cdot y + \left(y + x \cdot 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-z, y, x \cdot 0.5\right)\\ \end{array} \]
Alternative 7
Error0.1
Cost7104
\[x \cdot 0.5 + \left(\left(1 - z\right) + \log z\right) \cdot y \]
Alternative 8
Error29.2
Cost785
\[\begin{array}{l} \mathbf{if}\;x \leq -3 \cdot 10^{-119}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;x \leq 3.2 \cdot 10^{-29} \lor \neg \left(x \leq 0.245\right) \land x \leq 2 \cdot 10^{+29}:\\ \;\;\;\;y \cdot \left(-z\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot 0.5\\ \end{array} \]
Alternative 9
Error18.6
Cost448
\[x \cdot 0.5 - z \cdot y \]
Alternative 10
Error35.2
Cost192
\[x \cdot 0.5 \]
Alternative 11
Error62.7
Cost64
\[y \]

Error

Reproduce?

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