Average Error: 0.0 → 0.0
Time: 3.5s
Precision: binary64
Cost: 6976
\[\left(\frac{1}{8} \cdot x - \frac{y \cdot z}{2}\right) + t \]
\[\mathsf{fma}\left(y, z \cdot -0.5, 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 y (* z -0.5) (* 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(y, (z * -0.5), (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(y, Float64(z * -0.5), 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[(y * N[(z * -0.5), $MachinePrecision] + N[(0.125 * x), $MachinePrecision]), $MachinePrecision] + t), $MachinePrecision]
\left(\frac{1}{8} \cdot x - \frac{y \cdot z}{2}\right) + t
\mathsf{fma}\left(y, z \cdot -0.5, 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. Taylor expanded in x around 0 0.0

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(y, z \cdot -0.5, 0.125 \cdot x\right)} + t \]
    Proof
    (fma.f64 y (*.f64 z -1/2) (*.f64 1/8 x)): 0 points increase in error, 0 points decrease in error
    (Rewrite<= fma-def_binary64 (+.f64 (*.f64 y (*.f64 z -1/2)) (*.f64 1/8 x))): 1 points increase in error, 0 points decrease in error
    (+.f64 (Rewrite<= associate-*l*_binary64 (*.f64 (*.f64 y z) -1/2)) (*.f64 1/8 x)): 0 points increase in error, 0 points decrease in error
    (+.f64 (Rewrite<= *-commutative_binary64 (*.f64 -1/2 (*.f64 y z))) (*.f64 1/8 x)): 0 points increase in error, 0 points decrease in error
  4. Final simplification0.0

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

Alternatives

Alternative 1
Error9.1
Cost1488
\[\begin{array}{l} t_1 := 0.125 \cdot x + t\\ t_2 := t + y \cdot \left(z \cdot -0.5\right)\\ \mathbf{if}\;y \cdot z \leq -4 \cdot 10^{+96}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \cdot z \leq -50000000000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \cdot z \leq -2 \cdot 10^{-29}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \cdot z \leq 100000000000:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 2
Error32.8
Cost1360
\[\begin{array}{l} t_1 := -0.5 \cdot \left(y \cdot z\right)\\ \mathbf{if}\;y \cdot z \leq -3.409917717019904 \cdot 10^{-8}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \cdot z \leq 2.062138788734607 \cdot 10^{-28}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \cdot z \leq 3.5819068065927863 \cdot 10^{+62}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \cdot z \leq 5.861828449325967 \cdot 10^{+97}:\\ \;\;\;\;t\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error12.6
Cost1360
\[\begin{array}{l} t_1 := -0.5 \cdot \left(y \cdot z\right)\\ t_2 := 0.125 \cdot x + t\\ \mathbf{if}\;y \cdot z \leq -3.8128408973103664 \cdot 10^{+131}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \cdot z \leq 1.216740201055138 \cdot 10^{+26}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \cdot z \leq 3.5819068065927863 \cdot 10^{+62}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \cdot z \leq 5.861828449325967 \cdot 10^{+97}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error0.0
Cost704
\[t + \left(0.125 \cdot x + -0.5 \cdot \left(y \cdot z\right)\right) \]
Alternative 5
Error40.0
Cost64
\[t \]

Error

Reproduce

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