Average Error: 0.1 → 0.1
Time: 21.3s
Precision: binary64
Cost: 19904
\[\left(\left(x \cdot y + \frac{z \cdot t}{16}\right) - \frac{a \cdot b}{4}\right) + c \]
\[\mathsf{fma}\left(a, b \cdot -0.25, \mathsf{fma}\left(y, x, \mathsf{fma}\left(0.0625, t \cdot z, c\right)\right)\right) \]
(FPCore (x y z t a b c)
 :precision binary64
 (+ (- (+ (* x y) (/ (* z t) 16.0)) (/ (* a b) 4.0)) c))
(FPCore (x y z t a b c)
 :precision binary64
 (fma a (* b -0.25) (fma y x (fma 0.0625 (* t z) c))))
double code(double x, double y, double z, double t, double a, double b, double c) {
	return (((x * y) + ((z * t) / 16.0)) - ((a * b) / 4.0)) + c;
}
double code(double x, double y, double z, double t, double a, double b, double c) {
	return fma(a, (b * -0.25), fma(y, x, fma(0.0625, (t * z), c)));
}
function code(x, y, z, t, a, b, c)
	return Float64(Float64(Float64(Float64(x * y) + Float64(Float64(z * t) / 16.0)) - Float64(Float64(a * b) / 4.0)) + c)
end
function code(x, y, z, t, a, b, c)
	return fma(a, Float64(b * -0.25), fma(y, x, fma(0.0625, Float64(t * z), c)))
end
code[x_, y_, z_, t_, a_, b_, c_] := N[(N[(N[(N[(x * y), $MachinePrecision] + N[(N[(z * t), $MachinePrecision] / 16.0), $MachinePrecision]), $MachinePrecision] - N[(N[(a * b), $MachinePrecision] / 4.0), $MachinePrecision]), $MachinePrecision] + c), $MachinePrecision]
code[x_, y_, z_, t_, a_, b_, c_] := N[(a * N[(b * -0.25), $MachinePrecision] + N[(y * x + N[(0.0625 * N[(t * z), $MachinePrecision] + c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(\left(x \cdot y + \frac{z \cdot t}{16}\right) - \frac{a \cdot b}{4}\right) + c
\mathsf{fma}\left(a, b \cdot -0.25, \mathsf{fma}\left(y, x, \mathsf{fma}\left(0.0625, t \cdot z, c\right)\right)\right)

Error

Derivation

  1. Initial program 0.1

    \[\left(\left(x \cdot y + \frac{z \cdot t}{16}\right) - \frac{a \cdot b}{4}\right) + c \]
  2. Taylor expanded in x around 0 0.1

    \[\leadsto \color{blue}{\left(c + \left(y \cdot x + 0.0625 \cdot \left(t \cdot z\right)\right)\right) - 0.25 \cdot \left(a \cdot b\right)} \]
  3. Simplified0.1

    \[\leadsto \color{blue}{\mathsf{fma}\left(a, b \cdot -0.25, \mathsf{fma}\left(y, x, \mathsf{fma}\left(0.0625, t \cdot z, c\right)\right)\right)} \]
    Proof
    (fma.f64 a (*.f64 b -1/4) (fma.f64 y x (fma.f64 1/16 (*.f64 t z) c))): 0 points increase in error, 0 points decrease in error
    (fma.f64 a (*.f64 b -1/4) (fma.f64 y x (Rewrite<= fma-def_binary64 (+.f64 (*.f64 1/16 (*.f64 t z)) c)))): 0 points increase in error, 0 points decrease in error
    (fma.f64 a (*.f64 b -1/4) (fma.f64 y x (Rewrite<= +-commutative_binary64 (+.f64 c (*.f64 1/16 (*.f64 t z)))))): 0 points increase in error, 0 points decrease in error
    (fma.f64 a (*.f64 b -1/4) (Rewrite<= fma-def_binary64 (+.f64 (*.f64 y x) (+.f64 c (*.f64 1/16 (*.f64 t z)))))): 1 points increase in error, 0 points decrease in error
    (fma.f64 a (*.f64 b -1/4) (Rewrite=> +-commutative_binary64 (+.f64 (+.f64 c (*.f64 1/16 (*.f64 t z))) (*.f64 y x)))): 0 points increase in error, 0 points decrease in error
    (fma.f64 a (*.f64 b -1/4) (Rewrite<= associate-+r+_binary64 (+.f64 c (+.f64 (*.f64 1/16 (*.f64 t z)) (*.f64 y x))))): 0 points increase in error, 0 points decrease in error
    (fma.f64 a (*.f64 b -1/4) (+.f64 c (Rewrite<= +-commutative_binary64 (+.f64 (*.f64 y x) (*.f64 1/16 (*.f64 t z)))))): 0 points increase in error, 0 points decrease in error
    (Rewrite<= fma-def_binary64 (+.f64 (*.f64 a (*.f64 b -1/4)) (+.f64 c (+.f64 (*.f64 y x) (*.f64 1/16 (*.f64 t z)))))): 3 points increase in error, 0 points decrease in error
    (+.f64 (Rewrite<= associate-*l*_binary64 (*.f64 (*.f64 a b) -1/4)) (+.f64 c (+.f64 (*.f64 y x) (*.f64 1/16 (*.f64 t z))))): 0 points increase in error, 0 points decrease in error
    (+.f64 (Rewrite<= *-commutative_binary64 (*.f64 -1/4 (*.f64 a b))) (+.f64 c (+.f64 (*.f64 y x) (*.f64 1/16 (*.f64 t z))))): 0 points increase in error, 0 points decrease in error
    (Rewrite<= +-commutative_binary64 (+.f64 (+.f64 c (+.f64 (*.f64 y x) (*.f64 1/16 (*.f64 t z)))) (*.f64 -1/4 (*.f64 a b)))): 0 points increase in error, 0 points decrease in error
    (+.f64 (+.f64 c (+.f64 (*.f64 y x) (*.f64 1/16 (*.f64 t z)))) (*.f64 (Rewrite<= metadata-eval (neg.f64 1/4)) (*.f64 a b))): 0 points increase in error, 0 points decrease in error
    (Rewrite<= cancel-sign-sub-inv_binary64 (-.f64 (+.f64 c (+.f64 (*.f64 y x) (*.f64 1/16 (*.f64 t z)))) (*.f64 1/4 (*.f64 a b)))): 0 points increase in error, 0 points decrease in error
  4. Final simplification0.1

    \[\leadsto \mathsf{fma}\left(a, b \cdot -0.25, \mathsf{fma}\left(y, x, \mathsf{fma}\left(0.0625, t \cdot z, c\right)\right)\right) \]

Alternatives

Alternative 1
Error26.7
Cost2024
\[\begin{array}{l} t_1 := 0.0625 \cdot \left(t \cdot z\right)\\ t_2 := c + t_1\\ t_3 := c + y \cdot x\\ t_4 := -0.25 \cdot \left(a \cdot b\right)\\ t_5 := t_1 + t_4\\ \mathbf{if}\;b \leq -4.04839252956605 \cdot 10^{-159}:\\ \;\;\;\;c + a \cdot \left(b \cdot -0.25\right)\\ \mathbf{elif}\;b \leq 2.9228611281942957 \cdot 10^{-117}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \leq 1.1639123791181285 \cdot 10^{-25}:\\ \;\;\;\;y \cdot x + t_1\\ \mathbf{elif}\;b \leq 1.7948754687142242 \cdot 10^{+30}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \leq 1.15 \cdot 10^{+58}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;b \leq 10^{+142}:\\ \;\;\;\;t_5\\ \mathbf{elif}\;b \leq 10^{+186}:\\ \;\;\;\;y \cdot x + t_4\\ \mathbf{elif}\;b \leq 2 \cdot 10^{+231}:\\ \;\;\;\;t_5\\ \mathbf{elif}\;b \leq 2.15 \cdot 10^{+258}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;b \leq 4.25 \cdot 10^{+285}:\\ \;\;\;\;t_5\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 2
Error22.8
Cost1876
\[\begin{array}{l} t_1 := y \cdot x + -0.25 \cdot \left(a \cdot b\right)\\ t_2 := c + 0.0625 \cdot \left(t \cdot z\right)\\ \mathbf{if}\;a \cdot b \leq -1 \cdot 10^{+44}:\\ \;\;\;\;c + a \cdot \left(b \cdot -0.25\right)\\ \mathbf{elif}\;a \cdot b \leq -1 \cdot 10^{-36}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq -2 \cdot 10^{-61}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \cdot b \leq -2 \cdot 10^{-117}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq 5 \cdot 10^{+27}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error27.6
Cost1764
\[\begin{array}{l} t_1 := c + a \cdot \left(b \cdot -0.25\right)\\ t_2 := 0.0625 \cdot \left(t \cdot z\right)\\ t_3 := y \cdot x + t_2\\ \mathbf{if}\;t \leq -1.4610896689249652 \cdot 10^{-186}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq 5.676692576998345 \cdot 10^{-267}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 7.150303631180973 \cdot 10^{-193}:\\ \;\;\;\;c + y \cdot x\\ \mathbf{elif}\;t \leq 2.517687032542628 \cdot 10^{-90}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 9.455774866077695 \cdot 10^{-64}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq 9.144909023192843 \cdot 10^{-21}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 0.029639936124417593:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq 1.7 \cdot 10^{+74}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 10^{+130}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;c + t_2\\ \end{array} \]
Alternative 4
Error35.4
Cost1376
\[\begin{array}{l} t_1 := z \cdot \left(0.0625 \cdot t\right)\\ t_2 := a \cdot \left(b \cdot -0.25\right)\\ \mathbf{if}\;c \leq -7.808715646699018 \cdot 10^{+64}:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq -23489.31727342009:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq -1.1657054458150758 \cdot 10^{-247}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 1.5179572167878022 \cdot 10^{-270}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 1.6232664476791848 \cdot 10^{-180}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 0.010714215479033928:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;c \leq 5.714270454769437 \cdot 10^{+59}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 1.815067079719887 \cdot 10^{+94}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 5
Error7.1
Cost1352
\[\begin{array}{l} t_1 := 0.0625 \cdot \left(t \cdot z\right)\\ \mathbf{if}\;a \cdot b \leq -1 \cdot 10^{-20}:\\ \;\;\;\;\left(c + y \cdot x\right) - \left(a \cdot b\right) \cdot 0.25\\ \mathbf{elif}\;a \cdot b \leq 4 \cdot 10^{-114}:\\ \;\;\;\;c + \left(y \cdot x + t_1\right)\\ \mathbf{else}:\\ \;\;\;\;\left(c + t_1\right) + -0.25 \cdot \left(a \cdot b\right)\\ \end{array} \]
Alternative 6
Error33.3
Cost1244
\[\begin{array}{l} t_1 := c + y \cdot x\\ t_2 := z \cdot \left(0.0625 \cdot t\right)\\ t_3 := a \cdot \left(b \cdot -0.25\right)\\ \mathbf{if}\;b \leq -3.583124208257808 \cdot 10^{-89}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;b \leq 9.00476416142008 \cdot 10^{-106}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \leq 1.8050314883847044 \cdot 10^{-93}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \leq 1.15 \cdot 10^{+58}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \leq 5.1 \cdot 10^{+140}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \leq 7.3 \cdot 10^{+155}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \leq 3.5 \cdot 10^{+212}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error32.2
Cost1240
\[\begin{array}{l} t_1 := c + 0.0625 \cdot \left(t \cdot z\right)\\ t_2 := a \cdot \left(b \cdot -0.25\right)\\ t_3 := c + y \cdot x\\ \mathbf{if}\;b \leq -3.970598339454207 \cdot 10^{-90}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \leq 1.1450783104180212 \cdot 10^{-56}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \leq 486.1938319483654:\\ \;\;\;\;t_3\\ \mathbf{elif}\;b \leq 1.02 \cdot 10^{+79}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \leq 1.55 \cdot 10^{+195}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \leq 4.2 \cdot 10^{+290}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 8
Error9.2
Cost1224
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -5 \cdot 10^{+58}:\\ \;\;\;\;c + a \cdot \left(b \cdot -0.25\right)\\ \mathbf{elif}\;a \cdot b \leq 10^{+58}:\\ \;\;\;\;c + \left(y \cdot x + 0.0625 \cdot \left(t \cdot z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot x + -0.25 \cdot \left(a \cdot b\right)\\ \end{array} \]
Alternative 9
Error6.2
Cost1224
\[\begin{array}{l} t_1 := \left(c + y \cdot x\right) - \left(a \cdot b\right) \cdot 0.25\\ \mathbf{if}\;a \cdot b \leq -1 \cdot 10^{-20}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq 10^{+17}:\\ \;\;\;\;c + \left(y \cdot x + 0.0625 \cdot \left(t \cdot z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Error27.1
Cost1108
\[\begin{array}{l} t_1 := c + 0.0625 \cdot \left(t \cdot z\right)\\ t_2 := c + y \cdot x\\ \mathbf{if}\;a \leq -8.8 \cdot 10^{+95}:\\ \;\;\;\;c + a \cdot \left(b \cdot -0.25\right)\\ \mathbf{elif}\;a \leq -8.331305519933894 \cdot 10^{+27}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq -4.720080894573427 \cdot 10^{-76}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq -2.0823346778247216 \cdot 10^{-195}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq -1.244384097950414 \cdot 10^{-277}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 11
Error0.1
Cost1088
\[c + \left(\left(\frac{t \cdot z}{16} + y \cdot x\right) - \frac{a \cdot b}{4}\right) \]
Alternative 12
Error35.6
Cost852
\[\begin{array}{l} t_1 := z \cdot \left(0.0625 \cdot t\right)\\ \mathbf{if}\;c \leq -2.461402941209299 \cdot 10^{+64}:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq 1.6232664476791848 \cdot 10^{-180}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 0.010714215479033928:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;c \leq 9.538439067119094 \cdot 10^{+92}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 7.349731980644859 \cdot 10^{+105}:\\ \;\;\;\;y \cdot x\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 13
Error35.4
Cost456
\[\begin{array}{l} \mathbf{if}\;c \leq -4.814924538003789 \cdot 10^{+31}:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq 7.349731980644859 \cdot 10^{+105}:\\ \;\;\;\;y \cdot x\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 14
Error43.4
Cost64
\[c \]

Error

Reproduce

herbie shell --seed 2022318 
(FPCore (x y z t a b c)
  :name "Diagrams.Solve.Polynomial:quartForm  from diagrams-solve-0.1, C"
  :precision binary64
  (+ (- (+ (* x y) (/ (* z t) 16.0)) (/ (* a b) 4.0)) c))