Average Error: 0.1 → 0.1
Time: 16.8s
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, 1 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
Error16.1
Cost1892
\[\begin{array}{l} t_1 := 0.0625 \cdot \left(t \cdot z\right)\\ t_2 := t_1 - \left(a \cdot b\right) \cdot 0.25\\ t_3 := \left(c + y \cdot x\right) + -0.25 \cdot \left(a \cdot b\right)\\ \mathbf{if}\;c \leq -3.08148281323479 \cdot 10^{-20}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \leq -3.565656893866856 \cdot 10^{-110}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq -2.4599239581111038 \cdot 10^{-164}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \leq 2.241597195780208 \cdot 10^{-298}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 5.827907230892617 \cdot 10^{-150}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \leq 6.041668050320851 \cdot 10^{-140}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 1.954156676798629 \cdot 10^{-44}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \leq 3.602587979800786 \cdot 10^{-13}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 2.5037512526590507 \cdot 10^{+115}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;c + t_1\\ \end{array} \]
Alternative 2
Error30.1
Cost1508
\[\begin{array}{l} t_1 := c + y \cdot x\\ t_2 := z \cdot \left(0.0625 \cdot t\right)\\ t_3 := c + a \cdot \left(b \cdot -0.25\right)\\ \mathbf{if}\;z \leq -7.4 \cdot 10^{+274}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -1.12 \cdot 10^{+212}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -1.16 \cdot 10^{+198}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -5.9 \cdot 10^{+181}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq -7.4 \cdot 10^{+124}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -4.309850309758476 \cdot 10^{-166}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq -1.5283880744284696 \cdot 10^{-201}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 7.327320089958261 \cdot 10^{-243}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq 1.6320095734144689 \cdot 10^{-18}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 3
Error20.4
Cost1504
\[\begin{array}{l} t_1 := 0.0625 \cdot \left(t \cdot z\right)\\ t_2 := \left(a \cdot b\right) \cdot 0.25\\ t_3 := y \cdot x - t_2\\ t_4 := t_1 - t_2\\ t_5 := c + y \cdot x\\ \mathbf{if}\;c \leq -3.08148281323479 \cdot 10^{-20}:\\ \;\;\;\;t_5\\ \mathbf{elif}\;c \leq 2.241597195780208 \cdot 10^{-298}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;c \leq 5.827907230892617 \cdot 10^{-150}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \leq 6.041668050320851 \cdot 10^{-140}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;c \leq 1.954156676798629 \cdot 10^{-44}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \leq 3.602587979800786 \cdot 10^{-13}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;c \leq 10.424782791921974:\\ \;\;\;\;t_1 + y \cdot x\\ \mathbf{elif}\;c \leq 2.5037512526590507 \cdot 10^{+115}:\\ \;\;\;\;t_5\\ \mathbf{else}:\\ \;\;\;\;c + t_1\\ \end{array} \]
Alternative 4
Error24.7
Cost1372
\[\begin{array}{l} t_1 := c + y \cdot x\\ t_2 := c + 0.0625 \cdot \left(t \cdot z\right)\\ t_3 := c + a \cdot \left(b \cdot -0.25\right)\\ \mathbf{if}\;z \leq -4.3 \cdot 10^{+189}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -6.4 \cdot 10^{+147}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -5.631268661282474 \cdot 10^{+34}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -4.309850309758476 \cdot 10^{-166}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq -1.5283880744284696 \cdot 10^{-201}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 7.327320089958261 \cdot 10^{-243}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq 1.6320095734144689 \cdot 10^{-18}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 5
Error24.8
Cost1240
\[\begin{array}{l} t_1 := c + y \cdot x\\ t_2 := c + a \cdot \left(b \cdot -0.25\right)\\ t_3 := 0.0625 \cdot \left(t \cdot z\right)\\ t_4 := c + t_3\\ \mathbf{if}\;z \leq -1 \cdot 10^{+140}:\\ \;\;\;\;t_3 + y \cdot x\\ \mathbf{elif}\;z \leq -5.631268661282474 \cdot 10^{+34}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;z \leq -4.309850309758476 \cdot 10^{-166}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -1.5283880744284696 \cdot 10^{-201}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 7.327320089958261 \cdot 10^{-243}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 1.6320095734144689 \cdot 10^{-18}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_4\\ \end{array} \]
Alternative 6
Error5.7
Cost1224
\[\begin{array}{l} t_1 := \left(c + y \cdot x\right) + -0.25 \cdot \left(a \cdot b\right)\\ \mathbf{if}\;a \cdot b \leq -200000000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq 0.0002:\\ \;\;\;\;c + \left(0.0625 \cdot \left(t \cdot z\right) + y \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error5.6
Cost1224
\[\begin{array}{l} t_1 := 0.0625 \cdot \left(t \cdot z\right)\\ t_2 := -0.25 \cdot \left(a \cdot b\right)\\ \mathbf{if}\;a \cdot b \leq -200000000:\\ \;\;\;\;\left(c + t_1\right) + t_2\\ \mathbf{elif}\;a \cdot b \leq 0.0002:\\ \;\;\;\;c + \left(t_1 + y \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\left(c + y \cdot x\right) + t_2\\ \end{array} \]
Alternative 8
Error29.2
Cost1112
\[\begin{array}{l} t_1 := c + y \cdot x\\ t_2 := a \cdot \left(b \cdot -0.25\right)\\ \mathbf{if}\;c \leq -1.4429671700944535 \cdot 10^{-28}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -3.565656893866856 \cdot 10^{-110}:\\ \;\;\;\;z \cdot \left(0.0625 \cdot t\right)\\ \mathbf{elif}\;c \leq -2.4599239581111038 \cdot 10^{-164}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 9.071441797738179 \cdot 10^{-153}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 7.988255152288084 \cdot 10^{-64}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 1.858955287069624 \cdot 10^{-13}:\\ \;\;\;\;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
Error35.0
Cost848
\[\begin{array}{l} t_1 := a \cdot \left(b \cdot -0.25\right)\\ \mathbf{if}\;c \leq -319338325737142.8:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq 9.071441797738179 \cdot 10^{-153}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 1.3611566773576137 \cdot 10^{-85}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;c \leq 1.858955287069624 \cdot 10^{-13}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 11
Error21.0
Cost840
\[\begin{array}{l} \mathbf{if}\;c \leq -1030405013769350.9:\\ \;\;\;\;c + y \cdot x\\ \mathbf{elif}\;c \leq 1.954156676798629 \cdot 10^{-44}:\\ \;\;\;\;y \cdot x - \left(a \cdot b\right) \cdot 0.25\\ \mathbf{else}:\\ \;\;\;\;c + 0.0625 \cdot \left(t \cdot z\right)\\ \end{array} \]
Alternative 12
Error35.2
Cost456
\[\begin{array}{l} \mathbf{if}\;c \leq -1030405013769350.9:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq 8.026464602532605 \cdot 10^{+35}:\\ \;\;\;\;y \cdot x\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 13
Error43.0
Cost64
\[c \]

Error

Reproduce

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