Average Error: 0.1 → 0.1
Time: 17.5s
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)))))): 2 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)))))): 2 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
Error0.1
Cost7360
\[c + \left(\mathsf{fma}\left(z, 0.0625 \cdot t, -0.25 \cdot \left(a \cdot b\right)\right) + y \cdot x\right) \]
Alternative 2
Error24.6
Cost2160
\[\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 := c + t_2\\ t_4 := c + y \cdot x\\ t_5 := y \cdot x + -0.25 \cdot \left(a \cdot b\right)\\ \mathbf{if}\;t \leq -2.509200357990876 \cdot 10^{-79}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq -2.594853383762494 \cdot 10^{-244}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 2.8089528454168967 \cdot 10^{-149}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;t \leq 1.3609710468251942 \cdot 10^{-58}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 9.011429079070469 \cdot 10^{-26}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;t \leq 8.5 \cdot 10^{+57}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq 6 \cdot 10^{+72}:\\ \;\;\;\;t_5\\ \mathbf{elif}\;t \leq 2.6 \cdot 10^{+100}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq 3.5 \cdot 10^{+122}:\\ \;\;\;\;t_5\\ \mathbf{elif}\;t \leq 1.15 \cdot 10^{+130}:\\ \;\;\;\;z \cdot \left(0.0625 \cdot t\right)\\ \mathbf{elif}\;t \leq 9.5 \cdot 10^{+150}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 10^{+211}:\\ \;\;\;\;t_2 + y \cdot x\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 3
Error21.0
Cost2024
\[\begin{array}{l} t_1 := 0.0625 \cdot \left(t \cdot z\right)\\ t_2 := t_1 + y \cdot x\\ t_3 := -0.25 \cdot \left(a \cdot b\right)\\ t_4 := t_1 + t_3\\ t_5 := y \cdot x + t_3\\ \mathbf{if}\;c \leq -8.334889013386037 \cdot 10^{+46}:\\ \;\;\;\;c + t_1\\ \mathbf{elif}\;c \leq -1.4333462564751985 \cdot 10^{-127}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq -2.454533527054137 \cdot 10^{-292}:\\ \;\;\;\;t_5\\ \mathbf{elif}\;c \leq 2.960069210471872 \cdot 10^{-290}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 1.840749591005769 \cdot 10^{-216}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;c \leq 3.6792766155776506 \cdot 10^{-96}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 6.400641411631306 \cdot 10^{-78}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;c \leq 1.9239223479446394 \cdot 10^{-66}:\\ \;\;\;\;t_5\\ \mathbf{elif}\;c \leq 2.4622250245799415 \cdot 10^{-17}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 1.887025534469488 \cdot 10^{+89}:\\ \;\;\;\;t_4\\ \mathbf{else}:\\ \;\;\;\;c + y \cdot x\\ \end{array} \]
Alternative 4
Error7.0
Cost1872
\[\begin{array}{l} t_1 := 0.0625 \cdot \left(t \cdot z\right)\\ t_2 := c + \left(t_1 + y \cdot x\right)\\ t_3 := \left(c + t_1\right) + -0.25 \cdot \left(a \cdot b\right)\\ \mathbf{if}\;a \cdot b \leq -2 \cdot 10^{-47}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \cdot b \leq 10^{-79}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \cdot b \leq 10^{+26}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \cdot b \leq 10^{+86}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 5
Error24.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 := c + t_2\\ t_4 := c + y \cdot x\\ \mathbf{if}\;t \leq -2.509200357990876 \cdot 10^{-79}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq -2.594853383762494 \cdot 10^{-244}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 2.8089528454168967 \cdot 10^{-149}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;t \leq 1.3609710468251942 \cdot 10^{-58}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 9.011429079070469 \cdot 10^{-26}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;t \leq 8.5 \cdot 10^{+57}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq 3.4 \cdot 10^{+67}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;t \leq 2.7 \cdot 10^{+116}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 10^{+211}:\\ \;\;\;\;t_2 + y \cdot x\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 6
Error23.9
Cost1372
\[\begin{array}{l} t_1 := c + a \cdot \left(b \cdot -0.25\right)\\ t_2 := c + 0.0625 \cdot \left(t \cdot z\right)\\ t_3 := c + y \cdot x\\ \mathbf{if}\;t \leq -2.509200357990876 \cdot 10^{-79}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq -2.594853383762494 \cdot 10^{-244}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 2.8089528454168967 \cdot 10^{-149}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq 1.3609710468251942 \cdot 10^{-58}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 9.011429079070469 \cdot 10^{-26}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq 8.5 \cdot 10^{+57}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 1.7 \cdot 10^{+71}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 7
Error5.7
Cost1224
\[\begin{array}{l} t_1 := -0.25 \cdot \left(a \cdot b\right) + \left(c + y \cdot x\right)\\ \mathbf{if}\;a \cdot b \leq -2 \cdot 10^{+47}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq 10000000:\\ \;\;\;\;c + \left(0.0625 \cdot \left(t \cdot z\right) + y \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error34.3
Cost1112
\[\begin{array}{l} t_1 := z \cdot \left(0.0625 \cdot t\right)\\ t_2 := c + y \cdot x\\ t_3 := a \cdot \left(b \cdot -0.25\right)\\ \mathbf{if}\;b \leq -1.0225525821366135:\\ \;\;\;\;t_3\\ \mathbf{elif}\;b \leq -3.202138454853139 \cdot 10^{-69}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \leq -2.2541349886344 \cdot 10^{-161}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;b \leq 5.879347117796242 \cdot 10^{-213}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \leq 6.388611946712801 \cdot 10^{-180}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \leq 3.6 \cdot 10^{+177}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Error0.1
Cost1088
\[c + \left(\left(\frac{t \cdot z}{16} + y \cdot x\right) - \frac{a \cdot b}{4}\right) \]
Alternative 10
Error25.1
Cost976
\[\begin{array}{l} t_1 := c + y \cdot x\\ t_2 := c + 0.0625 \cdot \left(t \cdot z\right)\\ \mathbf{if}\;t \leq -3.314677663620364 \cdot 10^{-216}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 9.011429079070469 \cdot 10^{-26}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 8.5 \cdot 10^{+57}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 1.7 \cdot 10^{+71}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 11
Error15.1
Cost972
\[\begin{array}{l} t_1 := 0.0625 \cdot \left(t \cdot z\right)\\ t_2 := c + t_1\\ \mathbf{if}\;t \leq -2.509200357990876 \cdot 10^{-79}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 9.5 \cdot 10^{+150}:\\ \;\;\;\;-0.25 \cdot \left(a \cdot b\right) + \left(c + y \cdot x\right)\\ \mathbf{elif}\;t \leq 10^{+211}:\\ \;\;\;\;t_1 + y \cdot x\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 12
Error35.6
Cost848
\[\begin{array}{l} t_1 := z \cdot \left(0.0625 \cdot t\right)\\ \mathbf{if}\;c \leq -8.334889013386037 \cdot 10^{+46}:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq 2.1171934039680406 \cdot 10^{-117}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 0.00016991034124446525:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;c \leq 3.260629586153631 \cdot 10^{+69}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 13
Error35.4
Cost456
\[\begin{array}{l} \mathbf{if}\;c \leq -8.334889013386037 \cdot 10^{+46}:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq 1.2352568447349488 \cdot 10^{-10}:\\ \;\;\;\;y \cdot x\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 14
Error43.6
Cost64
\[c \]

Error

Reproduce

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