Average Error: 0.0 → 0.0
Time: 3.0s
Precision: binary64
Cost: 6976
\[\left(\frac{1}{8} \cdot x - \frac{y \cdot z}{2}\right) + t \]
\[\mathsf{fma}\left(z \cdot -0.5, y, 0.125 \cdot x\right) + t \]
(FPCore (x y z t)
 :precision binary64
 (+ (- (* (/ 1.0 8.0) x) (/ (* y z) 2.0)) t))
(FPCore (x y z t) :precision binary64 (+ (fma (* z -0.5) y (* 0.125 x)) t))
double code(double x, double y, double z, double t) {
	return (((1.0 / 8.0) * x) - ((y * z) / 2.0)) + t;
}
double code(double x, double y, double z, double t) {
	return fma((z * -0.5), y, (0.125 * x)) + t;
}
function code(x, y, z, t)
	return Float64(Float64(Float64(Float64(1.0 / 8.0) * x) - Float64(Float64(y * z) / 2.0)) + t)
end
function code(x, y, z, t)
	return Float64(fma(Float64(z * -0.5), y, Float64(0.125 * x)) + t)
end
code[x_, y_, z_, t_] := N[(N[(N[(N[(1.0 / 8.0), $MachinePrecision] * x), $MachinePrecision] - N[(N[(y * z), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision] + t), $MachinePrecision]
code[x_, y_, z_, t_] := N[(N[(N[(z * -0.5), $MachinePrecision] * y + N[(0.125 * x), $MachinePrecision]), $MachinePrecision] + t), $MachinePrecision]
\left(\frac{1}{8} \cdot x - \frac{y \cdot z}{2}\right) + t
\mathsf{fma}\left(z \cdot -0.5, y, 0.125 \cdot x\right) + t

Error

Target

Original0.0
Target0.0
Herbie0.0
\[\left(\frac{x}{8} + t\right) - \frac{z}{2} \cdot y \]

Derivation

  1. Initial program 0.0

    \[\left(\frac{1}{8} \cdot x - \frac{y \cdot z}{2}\right) + t \]
  2. Applied egg-rr0.0

    \[\leadsto \color{blue}{\left(\left(y \cdot z\right) \cdot -0.5 + 0.125 \cdot x\right)} + t \]
  3. Applied egg-rr0.0

    \[\leadsto \color{blue}{\mathsf{fma}\left(z \cdot -0.5, y, 0.125 \cdot x\right)} + t \]
  4. Final simplification0.0

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

Alternatives

Alternative 1
Error8.7
Cost712
\[\begin{array}{l} t_1 := 0.125 \cdot x + t\\ \mathbf{if}\;x \leq -8.05866979369579 \cdot 10^{-14}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 6.472551119587065 \cdot 10^{+59}:\\ \;\;\;\;t + z \cdot \left(-0.5 \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error0.0
Cost704
\[t + \left(0.125 \cdot x + -0.5 \cdot \left(z \cdot y\right)\right) \]
Alternative 3
Error17.6
Cost320
\[0.125 \cdot x + t \]

Error

Reproduce

herbie shell --seed 2022295 
(FPCore (x y z t)
  :name "Diagrams.Solve.Polynomial:quartForm  from diagrams-solve-0.1, B"
  :precision binary64

  :herbie-target
  (- (+ (/ x 8.0) t) (* (/ z 2.0) y))

  (+ (- (* (/ 1.0 8.0) x) (/ (* y z) 2.0)) t))