Average Error: 6.2 → 0.8
Time: 8.6s
Precision: binary64
\[2 \cdot \left(\left(x \cdot y + z \cdot t\right) - \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\right) \]
\[\begin{array}{l} t_1 := i \cdot \left(c \cdot \mathsf{fma}\left(c, b, a\right)\right)\\ \mathbf{if}\;i \leq -3.4 \cdot 10^{+124}:\\ \;\;\;\;2 \cdot \mathsf{fma}\left(y, x, t \cdot z - t_1\right)\\ \mathbf{elif}\;i \leq 5 \cdot 10^{-19}:\\ \;\;\;\;2 \cdot \mathsf{fma}\left(y, x, t \cdot z - c \cdot \mathsf{fma}\left(i \cdot c, b, i \cdot a\right)\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \mathsf{fma}\left(z, t, y \cdot x - t_1\right)\\ \end{array} \]
(FPCore (x y z t a b c i)
 :precision binary64
 (* 2.0 (- (+ (* x y) (* z t)) (* (* (+ a (* b c)) c) i))))
(FPCore (x y z t a b c i)
 :precision binary64
 (let* ((t_1 (* i (* c (fma c b a)))))
   (if (<= i -3.4e+124)
     (* 2.0 (fma y x (- (* t z) t_1)))
     (if (<= i 5e-19)
       (* 2.0 (fma y x (- (* t z) (* c (fma (* i c) b (* i a))))))
       (* 2.0 (fma z t (- (* y x) t_1)))))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	return 2.0 * (((x * y) + (z * t)) - (((a + (b * c)) * c) * i));
}
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	double t_1 = i * (c * fma(c, b, a));
	double tmp;
	if (i <= -3.4e+124) {
		tmp = 2.0 * fma(y, x, ((t * z) - t_1));
	} else if (i <= 5e-19) {
		tmp = 2.0 * fma(y, x, ((t * z) - (c * fma((i * c), b, (i * a)))));
	} else {
		tmp = 2.0 * fma(z, t, ((y * x) - t_1));
	}
	return tmp;
}
function code(x, y, z, t, a, b, c, i)
	return Float64(2.0 * Float64(Float64(Float64(x * y) + Float64(z * t)) - Float64(Float64(Float64(a + Float64(b * c)) * c) * i)))
end
function code(x, y, z, t, a, b, c, i)
	t_1 = Float64(i * Float64(c * fma(c, b, a)))
	tmp = 0.0
	if (i <= -3.4e+124)
		tmp = Float64(2.0 * fma(y, x, Float64(Float64(t * z) - t_1)));
	elseif (i <= 5e-19)
		tmp = Float64(2.0 * fma(y, x, Float64(Float64(t * z) - Float64(c * fma(Float64(i * c), b, Float64(i * a))))));
	else
		tmp = Float64(2.0 * fma(z, t, Float64(Float64(y * x) - t_1)));
	end
	return tmp
end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(2.0 * N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(a + N[(b * c), $MachinePrecision]), $MachinePrecision] * c), $MachinePrecision] * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(i * N[(c * N[(c * b + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[i, -3.4e+124], N[(2.0 * N[(y * x + N[(N[(t * z), $MachinePrecision] - t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[i, 5e-19], N[(2.0 * N[(y * x + N[(N[(t * z), $MachinePrecision] - N[(c * N[(N[(i * c), $MachinePrecision] * b + N[(i * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(z * t + N[(N[(y * x), $MachinePrecision] - t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
2 \cdot \left(\left(x \cdot y + z \cdot t\right) - \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\right)
\begin{array}{l}
t_1 := i \cdot \left(c \cdot \mathsf{fma}\left(c, b, a\right)\right)\\
\mathbf{if}\;i \leq -3.4 \cdot 10^{+124}:\\
\;\;\;\;2 \cdot \mathsf{fma}\left(y, x, t \cdot z - t_1\right)\\

\mathbf{elif}\;i \leq 5 \cdot 10^{-19}:\\
\;\;\;\;2 \cdot \mathsf{fma}\left(y, x, t \cdot z - c \cdot \mathsf{fma}\left(i \cdot c, b, i \cdot a\right)\right)\\

\mathbf{else}:\\
\;\;\;\;2 \cdot \mathsf{fma}\left(z, t, y \cdot x - t_1\right)\\


\end{array}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Bits error versus b

Bits error versus c

Bits error versus i

Target

Original6.2
Target1.7
Herbie0.8
\[2 \cdot \left(\left(x \cdot y + z \cdot t\right) - \left(a + b \cdot c\right) \cdot \left(c \cdot i\right)\right) \]

Derivation

  1. Split input into 3 regimes
  2. if i < -3.4e124

    1. Initial program 1.1

      \[2 \cdot \left(\left(x \cdot y + z \cdot t\right) - \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\right) \]
    2. Simplified2.4

      \[\leadsto \color{blue}{2 \cdot \mathsf{fma}\left(z, t, \mathsf{fma}\left(\mathsf{fma}\left(b, c, a\right), i \cdot \left(-c\right), x \cdot y\right)\right)} \]
    3. Taylor expanded in z around 0 26.1

      \[\leadsto 2 \cdot \color{blue}{\left(\left(y \cdot x + t \cdot z\right) - \left(c \cdot \left(a \cdot i\right) + {c}^{2} \cdot \left(i \cdot b\right)\right)\right)} \]
    4. Simplified1.1

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

    if -3.4e124 < i < 5.0000000000000004e-19

    1. Initial program 8.6

      \[2 \cdot \left(\left(x \cdot y + z \cdot t\right) - \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\right) \]
    2. Simplified1.8

      \[\leadsto \color{blue}{2 \cdot \mathsf{fma}\left(z, t, \mathsf{fma}\left(\mathsf{fma}\left(b, c, a\right), i \cdot \left(-c\right), x \cdot y\right)\right)} \]
    3. Taylor expanded in z around 0 9.2

      \[\leadsto 2 \cdot \color{blue}{\left(\left(y \cdot x + t \cdot z\right) - \left(c \cdot \left(a \cdot i\right) + {c}^{2} \cdot \left(i \cdot b\right)\right)\right)} \]
    4. Simplified8.6

      \[\leadsto 2 \cdot \color{blue}{\mathsf{fma}\left(y, x, t \cdot z - i \cdot \left(c \cdot \mathsf{fma}\left(c, b, a\right)\right)\right)} \]
    5. Taylor expanded in i around inf 1.9

      \[\leadsto 2 \cdot \mathsf{fma}\left(y, x, t \cdot z - \color{blue}{c \cdot \left(i \cdot \left(c \cdot b + a\right)\right)}\right) \]
    6. Applied egg-rr0.8

      \[\leadsto 2 \cdot \mathsf{fma}\left(y, x, t \cdot z - c \cdot \color{blue}{\left(b \cdot \left(c \cdot i\right) + i \cdot a\right)}\right) \]
    7. Applied egg-rr0.8

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

    if 5.0000000000000004e-19 < i

    1. Initial program 0.7

      \[2 \cdot \left(\left(x \cdot y + z \cdot t\right) - \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\right) \]
    2. Simplified0.9

      \[\leadsto \color{blue}{2 \cdot \mathsf{fma}\left(z, t, \mathsf{fma}\left(\mathsf{fma}\left(b, c, a\right), i \cdot \left(-c\right), x \cdot y\right)\right)} \]
    3. Taylor expanded in b around 0 17.1

      \[\leadsto 2 \cdot \mathsf{fma}\left(z, t, \color{blue}{y \cdot x - \left({c}^{2} \cdot \left(i \cdot b\right) + c \cdot \left(i \cdot a\right)\right)}\right) \]
    4. Simplified0.6

      \[\leadsto 2 \cdot \mathsf{fma}\left(z, t, \color{blue}{y \cdot x - i \cdot \left(c \cdot \mathsf{fma}\left(c, b, a\right)\right)}\right) \]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;i \leq -3.4 \cdot 10^{+124}:\\ \;\;\;\;2 \cdot \mathsf{fma}\left(y, x, t \cdot z - i \cdot \left(c \cdot \mathsf{fma}\left(c, b, a\right)\right)\right)\\ \mathbf{elif}\;i \leq 5 \cdot 10^{-19}:\\ \;\;\;\;2 \cdot \mathsf{fma}\left(y, x, t \cdot z - c \cdot \mathsf{fma}\left(i \cdot c, b, i \cdot a\right)\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \mathsf{fma}\left(z, t, y \cdot x - i \cdot \left(c \cdot \mathsf{fma}\left(c, b, a\right)\right)\right)\\ \end{array} \]

Reproduce

herbie shell --seed 2022160 
(FPCore (x y z t a b c i)
  :name "Diagrams.ThreeD.Shapes:frustum from diagrams-lib-1.3.0.3, A"
  :precision binary64

  :herbie-target
  (* 2.0 (- (+ (* x y) (* z t)) (* (+ a (* b c)) (* c i))))

  (* 2.0 (- (+ (* x y) (* z t)) (* (* (+ a (* b c)) c) i))))