Average Error: 0.2 → 0.0
Time: 19.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(y, x, \mathsf{fma}\left(t, z \cdot 0.0625, \mathsf{fma}\left(a \cdot b, -0.25, 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 y x (fma t (* z 0.0625) (fma (* a b) -0.25 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(y, x, fma(t, (z * 0.0625), fma((a * b), -0.25, 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(y, x, fma(t, Float64(z * 0.0625), fma(Float64(a * b), -0.25, 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[(y * x + N[(t * N[(z * 0.0625), $MachinePrecision] + N[(N[(a * b), $MachinePrecision] * -0.25 + 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(y, x, \mathsf{fma}\left(t, z \cdot 0.0625, \mathsf{fma}\left(a \cdot b, -0.25, c\right)\right)\right)

Error

Derivation

  1. Initial program 0.2

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

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

Alternatives

Alternative 1
Error20.4
Cost2008
\[\begin{array}{l} t_1 := \left(0.0625 \cdot t\right) \cdot z\\ t_2 := t_1 + c\\ t_3 := -0.25 \cdot \left(a \cdot b\right) + c\\ t_4 := y \cdot x + c\\ \mathbf{if}\;a \cdot b \leq -1 \cdot 10^{+81}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \cdot b \leq -2 \cdot 10^{-183}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \cdot b \leq 2 \cdot 10^{-232}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;a \cdot b \leq 2 \cdot 10^{-73}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \cdot b \leq 10^{-20}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;a \cdot b \leq 10^{-19}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 2
Error10.5
Cost1744
\[\begin{array}{l} t_1 := \left(y \cdot x + 0.0625 \cdot \left(t \cdot z\right)\right) + c\\ t_2 := y \cdot x - 0.25 \cdot \left(a \cdot b\right)\\ \mathbf{if}\;a \cdot b \leq -1 \cdot 10^{+81}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \cdot b \leq 10^{-19}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq 2 \cdot 10^{+50}:\\ \;\;\;\;-0.25 \cdot \left(a \cdot b\right) + c\\ \mathbf{elif}\;a \cdot b \leq 2 \cdot 10^{+169}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 3
Error22.0
Cost1488
\[\begin{array}{l} t_1 := y \cdot x + c\\ t_2 := -0.25 \cdot \left(a \cdot b\right) + c\\ \mathbf{if}\;a \cdot b \leq -5 \cdot 10^{+33}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \cdot b \leq -2 \cdot 10^{-80}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq -5 \cdot 10^{-150}:\\ \;\;\;\;\left(0.0625 \cdot t\right) \cdot z\\ \mathbf{elif}\;a \cdot b \leq 10^{-19}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 4
Error36.1
Cost1380
\[\begin{array}{l} t_1 := \left(0.0625 \cdot t\right) \cdot z\\ t_2 := \left(-0.25 \cdot a\right) \cdot b\\ \mathbf{if}\;c \leq -7.8 \cdot 10^{+94}:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq -1000000:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;c \leq -2.85 \cdot 10^{-31}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 7.5 \cdot 10^{-206}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 6.2 \cdot 10^{-157}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 1.28 \cdot 10^{-138}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;c \leq 4.3 \cdot 10^{+46}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 5.5 \cdot 10^{+100}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 1.65 \cdot 10^{+122}:\\ \;\;\;\;y \cdot x\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 5
Error22.1
Cost1368
\[\begin{array}{l} t_1 := y \cdot x - 0.25 \cdot \left(a \cdot b\right)\\ t_2 := y \cdot x + 0.0625 \cdot \left(t \cdot z\right)\\ \mathbf{if}\;c \leq -2900000000000:\\ \;\;\;\;y \cdot x + c\\ \mathbf{elif}\;c \leq -2.9 \cdot 10^{-71}:\\ \;\;\;\;-0.25 \cdot \left(a \cdot b\right) + c\\ \mathbf{elif}\;c \leq -1.4 \cdot 10^{-147}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 1.6 \cdot 10^{-208}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 1.3 \cdot 10^{+51}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 1.45 \cdot 10^{+124}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\left(0.0625 \cdot t\right) \cdot z + c\\ \end{array} \]
Alternative 6
Error5.9
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 -1 \cdot 10^{+81}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq 10^{-19}:\\ \;\;\;\;\left(y \cdot x + 0.0625 \cdot \left(t \cdot z\right)\right) + c\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error5.7
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 -5 \cdot 10^{+33}:\\ \;\;\;\;\left(c + t_1\right) - t_2\\ \mathbf{elif}\;a \cdot b \leq 10^{-19}:\\ \;\;\;\;\left(y \cdot x + t_1\right) + c\\ \mathbf{else}:\\ \;\;\;\;\left(c + y \cdot x\right) - t_2\\ \end{array} \]
Alternative 8
Error0.1
Cost1088
\[\left(\left(x \cdot y + \left(z \cdot 0.0625\right) \cdot t\right) - \frac{a \cdot b}{4}\right) + c \]
Alternative 9
Error29.4
Cost980
\[\begin{array}{l} t_1 := y \cdot x + c\\ t_2 := \left(0.0625 \cdot t\right) \cdot z\\ \mathbf{if}\;t \leq -2 \cdot 10^{+65}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 8 \cdot 10^{+25}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 5.5 \cdot 10^{+52}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 2.7 \cdot 10^{+134}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.8 \cdot 10^{+282}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Error35.7
Cost852
\[\begin{array}{l} \mathbf{if}\;c \leq -1.3 \cdot 10^{+95}:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq -900000000:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;c \leq -8 \cdot 10^{-11}:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq 5.5 \cdot 10^{-194}:\\ \;\;\;\;\left(-0.25 \cdot a\right) \cdot b\\ \mathbf{elif}\;c \leq 1.1 \cdot 10^{+83}:\\ \;\;\;\;y \cdot x\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 11
Error36.3
Cost720
\[\begin{array}{l} \mathbf{if}\;c \leq -1.25 \cdot 10^{+95}:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq -680000:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;c \leq -6.8 \cdot 10^{-67}:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq 5.4 \cdot 10^{+84}:\\ \;\;\;\;y \cdot x\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 12
Error43.7
Cost64
\[c \]

Error

Reproduce

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