Diagrams.Solve.Polynomial:quartForm from diagrams-solve-0.1, C

Percentage Accurate: 97.6% → 98.9%
Time: 8.7s
Alternatives: 12
Speedup: 0.5×

Specification

?
\[\begin{array}{l} \\ \left(\left(x \cdot y + \frac{z \cdot t}{16}\right) - \frac{a \cdot b}{4}\right) + c \end{array} \]
(FPCore (x y z t a b c)
 :precision binary64
 (+ (- (+ (* 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 (((x * y) + ((z * t) / 16.0)) - ((a * b) / 4.0)) + c;
}
real(8) function code(x, y, z, t, a, b, c)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    code = (((x * y) + ((z * t) / 16.0d0)) - ((a * b) / 4.0d0)) + c
end function
public static 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;
}
def code(x, y, z, t, a, b, c):
	return (((x * y) + ((z * t) / 16.0)) - ((a * b) / 4.0)) + 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 tmp = code(x, y, z, t, a, b, c)
	tmp = (((x * y) + ((z * t) / 16.0)) - ((a * b) / 4.0)) + 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]
\begin{array}{l}

\\
\left(\left(x \cdot y + \frac{z \cdot t}{16}\right) - \frac{a \cdot b}{4}\right) + c
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 12 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 97.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left(\left(x \cdot y + \frac{z \cdot t}{16}\right) - \frac{a \cdot b}{4}\right) + c \end{array} \]
(FPCore (x y z t a b c)
 :precision binary64
 (+ (- (+ (* 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 (((x * y) + ((z * t) / 16.0)) - ((a * b) / 4.0)) + c;
}
real(8) function code(x, y, z, t, a, b, c)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    code = (((x * y) + ((z * t) / 16.0d0)) - ((a * b) / 4.0d0)) + c
end function
public static 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;
}
def code(x, y, z, t, a, b, c):
	return (((x * y) + ((z * t) / 16.0)) - ((a * b) / 4.0)) + 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 tmp = code(x, y, z, t, a, b, c)
	tmp = (((x * y) + ((z * t) / 16.0)) - ((a * b) / 4.0)) + 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]
\begin{array}{l}

\\
\left(\left(x \cdot y + \frac{z \cdot t}{16}\right) - \frac{a \cdot b}{4}\right) + c
\end{array}

Alternative 1: 98.9% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(x, y, \mathsf{fma}\left(z, \frac{t}{16}, \frac{a \cdot b}{-4}\right)\right) + c \end{array} \]
(FPCore (x y z t a b c)
 :precision binary64
 (+ (fma x y (fma 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(x, y, fma(z, (t / 16.0), ((a * b) / -4.0))) + c;
}
function code(x, y, z, t, a, b, c)
	return Float64(fma(x, y, fma(z, Float64(t / 16.0), Float64(Float64(a * b) / -4.0))) + c)
end
code[x_, y_, z_, t_, a_, b_, c_] := N[(N[(x * y + N[(z * N[(t / 16.0), $MachinePrecision] + N[(N[(a * b), $MachinePrecision] / -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + c), $MachinePrecision]
\begin{array}{l}

\\
\mathsf{fma}\left(x, y, \mathsf{fma}\left(z, \frac{t}{16}, \frac{a \cdot b}{-4}\right)\right) + c
\end{array}
Derivation
  1. Initial program 97.6%

    \[\left(\left(x \cdot y + \frac{z \cdot t}{16}\right) - \frac{a \cdot b}{4}\right) + c \]
  2. Step-by-step derivation
    1. associate--l+97.6%

      \[\leadsto \color{blue}{\left(x \cdot y + \left(\frac{z \cdot t}{16} - \frac{a \cdot b}{4}\right)\right)} + c \]
    2. fma-define99.2%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, y, \frac{z \cdot t}{16} - \frac{a \cdot b}{4}\right)} + c \]
    3. associate-/l*99.2%

      \[\leadsto \mathsf{fma}\left(x, y, \color{blue}{z \cdot \frac{t}{16}} - \frac{a \cdot b}{4}\right) + c \]
    4. fma-neg99.6%

      \[\leadsto \mathsf{fma}\left(x, y, \color{blue}{\mathsf{fma}\left(z, \frac{t}{16}, -\frac{a \cdot b}{4}\right)}\right) + c \]
    5. distribute-neg-frac299.6%

      \[\leadsto \mathsf{fma}\left(x, y, \mathsf{fma}\left(z, \frac{t}{16}, \color{blue}{\frac{a \cdot b}{-4}}\right)\right) + c \]
    6. metadata-eval99.6%

      \[\leadsto \mathsf{fma}\left(x, y, \mathsf{fma}\left(z, \frac{t}{16}, \frac{a \cdot b}{\color{blue}{-4}}\right)\right) + c \]
  3. Simplified99.6%

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, y, \mathsf{fma}\left(z, \frac{t}{16}, \frac{a \cdot b}{-4}\right)\right) + c} \]
  4. Add Preprocessing
  5. Final simplification99.6%

    \[\leadsto \mathsf{fma}\left(x, y, \mathsf{fma}\left(z, \frac{t}{16}, \frac{a \cdot b}{-4}\right)\right) + c \]
  6. Add Preprocessing

Alternative 2: 98.1% accurate, 0.1× speedup?

\[\begin{array}{l} \\ c + \left(\mathsf{fma}\left(x, y, z \cdot \frac{t}{16}\right) - a \cdot \frac{b}{4}\right) \end{array} \]
(FPCore (x y z t a b c)
 :precision binary64
 (+ c (- (fma x y (* z (/ t 16.0))) (* a (/ b 4.0)))))
double code(double x, double y, double z, double t, double a, double b, double c) {
	return c + (fma(x, y, (z * (t / 16.0))) - (a * (b / 4.0)));
}
function code(x, y, z, t, a, b, c)
	return Float64(c + Float64(fma(x, y, Float64(z * Float64(t / 16.0))) - Float64(a * Float64(b / 4.0))))
end
code[x_, y_, z_, t_, a_, b_, c_] := N[(c + N[(N[(x * y + N[(z * N[(t / 16.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(a * N[(b / 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
c + \left(\mathsf{fma}\left(x, y, z \cdot \frac{t}{16}\right) - a \cdot \frac{b}{4}\right)
\end{array}
Derivation
  1. Initial program 97.6%

    \[\left(\left(x \cdot y + \frac{z \cdot t}{16}\right) - \frac{a \cdot b}{4}\right) + c \]
  2. Step-by-step derivation
    1. associate-+l-97.6%

      \[\leadsto \color{blue}{\left(x \cdot y + \frac{z \cdot t}{16}\right) - \left(\frac{a \cdot b}{4} - c\right)} \]
    2. *-commutative97.6%

      \[\leadsto \left(x \cdot y + \frac{\color{blue}{t \cdot z}}{16}\right) - \left(\frac{a \cdot b}{4} - c\right) \]
    3. associate-+l-97.6%

      \[\leadsto \color{blue}{\left(\left(x \cdot y + \frac{t \cdot z}{16}\right) - \frac{a \cdot b}{4}\right) + c} \]
    4. fma-define98.0%

      \[\leadsto \left(\color{blue}{\mathsf{fma}\left(x, y, \frac{t \cdot z}{16}\right)} - \frac{a \cdot b}{4}\right) + c \]
    5. *-commutative98.0%

      \[\leadsto \left(\mathsf{fma}\left(x, y, \frac{\color{blue}{z \cdot t}}{16}\right) - \frac{a \cdot b}{4}\right) + c \]
    6. associate-/l*98.0%

      \[\leadsto \left(\mathsf{fma}\left(x, y, \color{blue}{z \cdot \frac{t}{16}}\right) - \frac{a \cdot b}{4}\right) + c \]
    7. associate-/l*98.0%

      \[\leadsto \left(\mathsf{fma}\left(x, y, z \cdot \frac{t}{16}\right) - \color{blue}{a \cdot \frac{b}{4}}\right) + c \]
  3. Simplified98.0%

    \[\leadsto \color{blue}{\left(\mathsf{fma}\left(x, y, z \cdot \frac{t}{16}\right) - a \cdot \frac{b}{4}\right) + c} \]
  4. Add Preprocessing
  5. Final simplification98.0%

    \[\leadsto c + \left(\mathsf{fma}\left(x, y, z \cdot \frac{t}{16}\right) - a \cdot \frac{b}{4}\right) \]
  6. Add Preprocessing

Alternative 3: 98.5% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \left(x \cdot y + \frac{z \cdot t}{16}\right) - \frac{a \cdot b}{4}\\ \mathbf{if}\;t\_1 \leq \infty:\\ \;\;\;\;c + t\_1\\ \mathbf{else}:\\ \;\;\;\;c + a \cdot \left(b \cdot -0.25\right)\\ \end{array} \end{array} \]
(FPCore (x y z t a b c)
 :precision binary64
 (let* ((t_1 (- (+ (* x y) (/ (* z t) 16.0)) (/ (* a b) 4.0))))
   (if (<= t_1 INFINITY) (+ c t_1) (+ c (* a (* b -0.25))))))
double code(double x, double y, double z, double t, double a, double b, double c) {
	double t_1 = ((x * y) + ((z * t) / 16.0)) - ((a * b) / 4.0);
	double tmp;
	if (t_1 <= ((double) INFINITY)) {
		tmp = c + t_1;
	} else {
		tmp = c + (a * (b * -0.25));
	}
	return tmp;
}
public static double code(double x, double y, double z, double t, double a, double b, double c) {
	double t_1 = ((x * y) + ((z * t) / 16.0)) - ((a * b) / 4.0);
	double tmp;
	if (t_1 <= Double.POSITIVE_INFINITY) {
		tmp = c + t_1;
	} else {
		tmp = c + (a * (b * -0.25));
	}
	return tmp;
}
def code(x, y, z, t, a, b, c):
	t_1 = ((x * y) + ((z * t) / 16.0)) - ((a * b) / 4.0)
	tmp = 0
	if t_1 <= math.inf:
		tmp = c + t_1
	else:
		tmp = c + (a * (b * -0.25))
	return tmp
function code(x, y, z, t, a, b, c)
	t_1 = Float64(Float64(Float64(x * y) + Float64(Float64(z * t) / 16.0)) - Float64(Float64(a * b) / 4.0))
	tmp = 0.0
	if (t_1 <= Inf)
		tmp = Float64(c + t_1);
	else
		tmp = Float64(c + Float64(a * Float64(b * -0.25)));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a, b, c)
	t_1 = ((x * y) + ((z * t) / 16.0)) - ((a * b) / 4.0);
	tmp = 0.0;
	if (t_1 <= Inf)
		tmp = c + t_1;
	else
		tmp = c + (a * (b * -0.25));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_, c_] := Block[{t$95$1 = N[(N[(N[(x * y), $MachinePrecision] + N[(N[(z * t), $MachinePrecision] / 16.0), $MachinePrecision]), $MachinePrecision] - N[(N[(a * b), $MachinePrecision] / 4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, Infinity], N[(c + t$95$1), $MachinePrecision], N[(c + N[(a * N[(b * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \left(x \cdot y + \frac{z \cdot t}{16}\right) - \frac{a \cdot b}{4}\\
\mathbf{if}\;t\_1 \leq \infty:\\
\;\;\;\;c + t\_1\\

\mathbf{else}:\\
\;\;\;\;c + a \cdot \left(b \cdot -0.25\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (+.f64 (*.f64 x y) (/.f64 (*.f64 z t) 16)) (/.f64 (*.f64 a b) 4)) < +inf.0

    1. Initial program 100.0%

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

    if +inf.0 < (-.f64 (+.f64 (*.f64 x y) (/.f64 (*.f64 z t) 16)) (/.f64 (*.f64 a b) 4))

    1. Initial program 0.0%

      \[\left(\left(x \cdot y + \frac{z \cdot t}{16}\right) - \frac{a \cdot b}{4}\right) + c \]
    2. Add Preprocessing
    3. Taylor expanded in a around inf 66.7%

      \[\leadsto \color{blue}{-0.25 \cdot \left(a \cdot b\right)} + c \]
    4. Step-by-step derivation
      1. *-commutative66.7%

        \[\leadsto \color{blue}{\left(a \cdot b\right) \cdot -0.25} + c \]
      2. associate-*r*66.7%

        \[\leadsto \color{blue}{a \cdot \left(b \cdot -0.25\right)} + c \]
    5. Simplified66.7%

      \[\leadsto \color{blue}{a \cdot \left(b \cdot -0.25\right)} + c \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(x \cdot y + \frac{z \cdot t}{16}\right) - \frac{a \cdot b}{4} \leq \infty:\\ \;\;\;\;c + \left(\left(x \cdot y + \frac{z \cdot t}{16}\right) - \frac{a \cdot b}{4}\right)\\ \mathbf{else}:\\ \;\;\;\;c + a \cdot \left(b \cdot -0.25\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 86.9% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \left(z \cdot t\right) \cdot 0.0625\\ t_2 := \left(a \cdot b\right) \cdot 0.25\\ \mathbf{if}\;a \cdot b \leq -1 \cdot 10^{+107}:\\ \;\;\;\;c + \left(t\_1 - t\_2\right)\\ \mathbf{elif}\;a \cdot b \leq -1 \cdot 10^{-96} \lor \neg \left(a \cdot b \leq 2 \cdot 10^{+42}\right):\\ \;\;\;\;c + \left(x \cdot y - t\_2\right)\\ \mathbf{else}:\\ \;\;\;\;c + \left(x \cdot y + t\_1\right)\\ \end{array} \end{array} \]
(FPCore (x y z t a b c)
 :precision binary64
 (let* ((t_1 (* (* z t) 0.0625)) (t_2 (* (* a b) 0.25)))
   (if (<= (* a b) -1e+107)
     (+ c (- t_1 t_2))
     (if (or (<= (* a b) -1e-96) (not (<= (* a b) 2e+42)))
       (+ c (- (* x y) t_2))
       (+ c (+ (* x y) t_1))))))
double code(double x, double y, double z, double t, double a, double b, double c) {
	double t_1 = (z * t) * 0.0625;
	double t_2 = (a * b) * 0.25;
	double tmp;
	if ((a * b) <= -1e+107) {
		tmp = c + (t_1 - t_2);
	} else if (((a * b) <= -1e-96) || !((a * b) <= 2e+42)) {
		tmp = c + ((x * y) - t_2);
	} else {
		tmp = c + ((x * y) + t_1);
	}
	return tmp;
}
real(8) function code(x, y, z, t, a, b, c)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_1 = (z * t) * 0.0625d0
    t_2 = (a * b) * 0.25d0
    if ((a * b) <= (-1d+107)) then
        tmp = c + (t_1 - t_2)
    else if (((a * b) <= (-1d-96)) .or. (.not. ((a * b) <= 2d+42))) then
        tmp = c + ((x * y) - t_2)
    else
        tmp = c + ((x * y) + t_1)
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b, double c) {
	double t_1 = (z * t) * 0.0625;
	double t_2 = (a * b) * 0.25;
	double tmp;
	if ((a * b) <= -1e+107) {
		tmp = c + (t_1 - t_2);
	} else if (((a * b) <= -1e-96) || !((a * b) <= 2e+42)) {
		tmp = c + ((x * y) - t_2);
	} else {
		tmp = c + ((x * y) + t_1);
	}
	return tmp;
}
def code(x, y, z, t, a, b, c):
	t_1 = (z * t) * 0.0625
	t_2 = (a * b) * 0.25
	tmp = 0
	if (a * b) <= -1e+107:
		tmp = c + (t_1 - t_2)
	elif ((a * b) <= -1e-96) or not ((a * b) <= 2e+42):
		tmp = c + ((x * y) - t_2)
	else:
		tmp = c + ((x * y) + t_1)
	return tmp
function code(x, y, z, t, a, b, c)
	t_1 = Float64(Float64(z * t) * 0.0625)
	t_2 = Float64(Float64(a * b) * 0.25)
	tmp = 0.0
	if (Float64(a * b) <= -1e+107)
		tmp = Float64(c + Float64(t_1 - t_2));
	elseif ((Float64(a * b) <= -1e-96) || !(Float64(a * b) <= 2e+42))
		tmp = Float64(c + Float64(Float64(x * y) - t_2));
	else
		tmp = Float64(c + Float64(Float64(x * y) + t_1));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a, b, c)
	t_1 = (z * t) * 0.0625;
	t_2 = (a * b) * 0.25;
	tmp = 0.0;
	if ((a * b) <= -1e+107)
		tmp = c + (t_1 - t_2);
	elseif (((a * b) <= -1e-96) || ~(((a * b) <= 2e+42)))
		tmp = c + ((x * y) - t_2);
	else
		tmp = c + ((x * y) + t_1);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_, c_] := Block[{t$95$1 = N[(N[(z * t), $MachinePrecision] * 0.0625), $MachinePrecision]}, Block[{t$95$2 = N[(N[(a * b), $MachinePrecision] * 0.25), $MachinePrecision]}, If[LessEqual[N[(a * b), $MachinePrecision], -1e+107], N[(c + N[(t$95$1 - t$95$2), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[N[(a * b), $MachinePrecision], -1e-96], N[Not[LessEqual[N[(a * b), $MachinePrecision], 2e+42]], $MachinePrecision]], N[(c + N[(N[(x * y), $MachinePrecision] - t$95$2), $MachinePrecision]), $MachinePrecision], N[(c + N[(N[(x * y), $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \left(z \cdot t\right) \cdot 0.0625\\
t_2 := \left(a \cdot b\right) \cdot 0.25\\
\mathbf{if}\;a \cdot b \leq -1 \cdot 10^{+107}:\\
\;\;\;\;c + \left(t\_1 - t\_2\right)\\

\mathbf{elif}\;a \cdot b \leq -1 \cdot 10^{-96} \lor \neg \left(a \cdot b \leq 2 \cdot 10^{+42}\right):\\
\;\;\;\;c + \left(x \cdot y - t\_2\right)\\

\mathbf{else}:\\
\;\;\;\;c + \left(x \cdot y + t\_1\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 a b) < -9.9999999999999997e106

    1. Initial program 94.7%

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

      \[\leadsto \color{blue}{\left(0.0625 \cdot \left(t \cdot z\right) - 0.25 \cdot \left(a \cdot b\right)\right)} + c \]

    if -9.9999999999999997e106 < (*.f64 a b) < -9.9999999999999991e-97 or 2.00000000000000009e42 < (*.f64 a b)

    1. Initial program 96.0%

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

      \[\leadsto \color{blue}{\left(x \cdot y - 0.25 \cdot \left(a \cdot b\right)\right)} + c \]

    if -9.9999999999999991e-97 < (*.f64 a b) < 2.00000000000000009e42

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{\left(0.0625 \cdot \left(t \cdot z\right) + x \cdot y\right)} + c \]
  3. Recombined 3 regimes into one program.
  4. Final simplification93.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \cdot b \leq -1 \cdot 10^{+107}:\\ \;\;\;\;c + \left(\left(z \cdot t\right) \cdot 0.0625 - \left(a \cdot b\right) \cdot 0.25\right)\\ \mathbf{elif}\;a \cdot b \leq -1 \cdot 10^{-96} \lor \neg \left(a \cdot b \leq 2 \cdot 10^{+42}\right):\\ \;\;\;\;c + \left(x \cdot y - \left(a \cdot b\right) \cdot 0.25\right)\\ \mathbf{else}:\\ \;\;\;\;c + \left(x \cdot y + \left(z \cdot t\right) \cdot 0.0625\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 87.1% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \cdot b \leq -1 \cdot 10^{-96} \lor \neg \left(a \cdot b \leq 2 \cdot 10^{+42}\right):\\ \;\;\;\;c + \left(x \cdot y - \left(a \cdot b\right) \cdot 0.25\right)\\ \mathbf{else}:\\ \;\;\;\;c + \left(x \cdot y + \left(z \cdot t\right) \cdot 0.0625\right)\\ \end{array} \end{array} \]
(FPCore (x y z t a b c)
 :precision binary64
 (if (or (<= (* a b) -1e-96) (not (<= (* a b) 2e+42)))
   (+ c (- (* x y) (* (* a b) 0.25)))
   (+ c (+ (* x y) (* (* z t) 0.0625)))))
double code(double x, double y, double z, double t, double a, double b, double c) {
	double tmp;
	if (((a * b) <= -1e-96) || !((a * b) <= 2e+42)) {
		tmp = c + ((x * y) - ((a * b) * 0.25));
	} else {
		tmp = c + ((x * y) + ((z * t) * 0.0625));
	}
	return tmp;
}
real(8) function code(x, y, z, t, a, b, c)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8) :: tmp
    if (((a * b) <= (-1d-96)) .or. (.not. ((a * b) <= 2d+42))) then
        tmp = c + ((x * y) - ((a * b) * 0.25d0))
    else
        tmp = c + ((x * y) + ((z * t) * 0.0625d0))
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b, double c) {
	double tmp;
	if (((a * b) <= -1e-96) || !((a * b) <= 2e+42)) {
		tmp = c + ((x * y) - ((a * b) * 0.25));
	} else {
		tmp = c + ((x * y) + ((z * t) * 0.0625));
	}
	return tmp;
}
def code(x, y, z, t, a, b, c):
	tmp = 0
	if ((a * b) <= -1e-96) or not ((a * b) <= 2e+42):
		tmp = c + ((x * y) - ((a * b) * 0.25))
	else:
		tmp = c + ((x * y) + ((z * t) * 0.0625))
	return tmp
function code(x, y, z, t, a, b, c)
	tmp = 0.0
	if ((Float64(a * b) <= -1e-96) || !(Float64(a * b) <= 2e+42))
		tmp = Float64(c + Float64(Float64(x * y) - Float64(Float64(a * b) * 0.25)));
	else
		tmp = Float64(c + Float64(Float64(x * y) + Float64(Float64(z * t) * 0.0625)));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a, b, c)
	tmp = 0.0;
	if (((a * b) <= -1e-96) || ~(((a * b) <= 2e+42)))
		tmp = c + ((x * y) - ((a * b) * 0.25));
	else
		tmp = c + ((x * y) + ((z * t) * 0.0625));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_, c_] := If[Or[LessEqual[N[(a * b), $MachinePrecision], -1e-96], N[Not[LessEqual[N[(a * b), $MachinePrecision], 2e+42]], $MachinePrecision]], N[(c + N[(N[(x * y), $MachinePrecision] - N[(N[(a * b), $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c + N[(N[(x * y), $MachinePrecision] + N[(N[(z * t), $MachinePrecision] * 0.0625), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -1 \cdot 10^{-96} \lor \neg \left(a \cdot b \leq 2 \cdot 10^{+42}\right):\\
\;\;\;\;c + \left(x \cdot y - \left(a \cdot b\right) \cdot 0.25\right)\\

\mathbf{else}:\\
\;\;\;\;c + \left(x \cdot y + \left(z \cdot t\right) \cdot 0.0625\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 a b) < -9.9999999999999991e-97 or 2.00000000000000009e42 < (*.f64 a b)

    1. Initial program 95.6%

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

      \[\leadsto \color{blue}{\left(x \cdot y - 0.25 \cdot \left(a \cdot b\right)\right)} + c \]

    if -9.9999999999999991e-97 < (*.f64 a b) < 2.00000000000000009e42

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{\left(0.0625 \cdot \left(t \cdot z\right) + x \cdot y\right)} + c \]
  3. Recombined 2 regimes into one program.
  4. Final simplification91.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \cdot b \leq -1 \cdot 10^{-96} \lor \neg \left(a \cdot b \leq 2 \cdot 10^{+42}\right):\\ \;\;\;\;c + \left(x \cdot y - \left(a \cdot b\right) \cdot 0.25\right)\\ \mathbf{else}:\\ \;\;\;\;c + \left(x \cdot y + \left(z \cdot t\right) \cdot 0.0625\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 65.7% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \cdot y \leq -6.2 \cdot 10^{+153}:\\ \;\;\;\;c + x \cdot y\\ \mathbf{elif}\;x \cdot y \leq 1.65 \cdot 10^{+24}:\\ \;\;\;\;c + a \cdot \left(b \cdot -0.25\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot y + \left(z \cdot t\right) \cdot 0.0625\\ \end{array} \end{array} \]
(FPCore (x y z t a b c)
 :precision binary64
 (if (<= (* x y) -6.2e+153)
   (+ c (* x y))
   (if (<= (* x y) 1.65e+24)
     (+ c (* a (* b -0.25)))
     (+ (* x y) (* (* z t) 0.0625)))))
double code(double x, double y, double z, double t, double a, double b, double c) {
	double tmp;
	if ((x * y) <= -6.2e+153) {
		tmp = c + (x * y);
	} else if ((x * y) <= 1.65e+24) {
		tmp = c + (a * (b * -0.25));
	} else {
		tmp = (x * y) + ((z * t) * 0.0625);
	}
	return tmp;
}
real(8) function code(x, y, z, t, a, b, c)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8) :: tmp
    if ((x * y) <= (-6.2d+153)) then
        tmp = c + (x * y)
    else if ((x * y) <= 1.65d+24) then
        tmp = c + (a * (b * (-0.25d0)))
    else
        tmp = (x * y) + ((z * t) * 0.0625d0)
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b, double c) {
	double tmp;
	if ((x * y) <= -6.2e+153) {
		tmp = c + (x * y);
	} else if ((x * y) <= 1.65e+24) {
		tmp = c + (a * (b * -0.25));
	} else {
		tmp = (x * y) + ((z * t) * 0.0625);
	}
	return tmp;
}
def code(x, y, z, t, a, b, c):
	tmp = 0
	if (x * y) <= -6.2e+153:
		tmp = c + (x * y)
	elif (x * y) <= 1.65e+24:
		tmp = c + (a * (b * -0.25))
	else:
		tmp = (x * y) + ((z * t) * 0.0625)
	return tmp
function code(x, y, z, t, a, b, c)
	tmp = 0.0
	if (Float64(x * y) <= -6.2e+153)
		tmp = Float64(c + Float64(x * y));
	elseif (Float64(x * y) <= 1.65e+24)
		tmp = Float64(c + Float64(a * Float64(b * -0.25)));
	else
		tmp = Float64(Float64(x * y) + Float64(Float64(z * t) * 0.0625));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a, b, c)
	tmp = 0.0;
	if ((x * y) <= -6.2e+153)
		tmp = c + (x * y);
	elseif ((x * y) <= 1.65e+24)
		tmp = c + (a * (b * -0.25));
	else
		tmp = (x * y) + ((z * t) * 0.0625);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_, c_] := If[LessEqual[N[(x * y), $MachinePrecision], -6.2e+153], N[(c + N[(x * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 1.65e+24], N[(c + N[(a * N[(b * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * y), $MachinePrecision] + N[(N[(z * t), $MachinePrecision] * 0.0625), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -6.2 \cdot 10^{+153}:\\
\;\;\;\;c + x \cdot y\\

\mathbf{elif}\;x \cdot y \leq 1.65 \cdot 10^{+24}:\\
\;\;\;\;c + a \cdot \left(b \cdot -0.25\right)\\

\mathbf{else}:\\
\;\;\;\;x \cdot y + \left(z \cdot t\right) \cdot 0.0625\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 x y) < -6.2e153

    1. Initial program 91.2%

      \[\left(\left(x \cdot y + \frac{z \cdot t}{16}\right) - \frac{a \cdot b}{4}\right) + c \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 78.0%

      \[\leadsto \color{blue}{x \cdot y} + c \]

    if -6.2e153 < (*.f64 x y) < 1.6499999999999999e24

    1. Initial program 99.3%

      \[\left(\left(x \cdot y + \frac{z \cdot t}{16}\right) - \frac{a \cdot b}{4}\right) + c \]
    2. Add Preprocessing
    3. Taylor expanded in a around inf 66.5%

      \[\leadsto \color{blue}{-0.25 \cdot \left(a \cdot b\right)} + c \]
    4. Step-by-step derivation
      1. *-commutative66.5%

        \[\leadsto \color{blue}{\left(a \cdot b\right) \cdot -0.25} + c \]
      2. associate-*r*66.5%

        \[\leadsto \color{blue}{a \cdot \left(b \cdot -0.25\right)} + c \]
    5. Simplified66.5%

      \[\leadsto \color{blue}{a \cdot \left(b \cdot -0.25\right)} + c \]

    if 1.6499999999999999e24 < (*.f64 x y)

    1. Initial program 97.1%

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

      \[\leadsto \color{blue}{\left(0.0625 \cdot \left(t \cdot z\right) + x \cdot y\right)} + c \]
    4. Taylor expanded in c around 0 70.3%

      \[\leadsto \color{blue}{0.0625 \cdot \left(t \cdot z\right) + x \cdot y} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification69.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y \leq -6.2 \cdot 10^{+153}:\\ \;\;\;\;c + x \cdot y\\ \mathbf{elif}\;x \cdot y \leq 1.65 \cdot 10^{+24}:\\ \;\;\;\;c + a \cdot \left(b \cdot -0.25\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot y + \left(z \cdot t\right) \cdot 0.0625\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 65.1% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \cdot y \leq -1.6 \cdot 10^{+162} \lor \neg \left(x \cdot y \leq 2.4 \cdot 10^{+96}\right):\\ \;\;\;\;c + x \cdot y\\ \mathbf{else}:\\ \;\;\;\;c + a \cdot \left(b \cdot -0.25\right)\\ \end{array} \end{array} \]
(FPCore (x y z t a b c)
 :precision binary64
 (if (or (<= (* x y) -1.6e+162) (not (<= (* x y) 2.4e+96)))
   (+ c (* x y))
   (+ c (* a (* b -0.25)))))
double code(double x, double y, double z, double t, double a, double b, double c) {
	double tmp;
	if (((x * y) <= -1.6e+162) || !((x * y) <= 2.4e+96)) {
		tmp = c + (x * y);
	} else {
		tmp = c + (a * (b * -0.25));
	}
	return tmp;
}
real(8) function code(x, y, z, t, a, b, c)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8) :: tmp
    if (((x * y) <= (-1.6d+162)) .or. (.not. ((x * y) <= 2.4d+96))) then
        tmp = c + (x * y)
    else
        tmp = c + (a * (b * (-0.25d0)))
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b, double c) {
	double tmp;
	if (((x * y) <= -1.6e+162) || !((x * y) <= 2.4e+96)) {
		tmp = c + (x * y);
	} else {
		tmp = c + (a * (b * -0.25));
	}
	return tmp;
}
def code(x, y, z, t, a, b, c):
	tmp = 0
	if ((x * y) <= -1.6e+162) or not ((x * y) <= 2.4e+96):
		tmp = c + (x * y)
	else:
		tmp = c + (a * (b * -0.25))
	return tmp
function code(x, y, z, t, a, b, c)
	tmp = 0.0
	if ((Float64(x * y) <= -1.6e+162) || !(Float64(x * y) <= 2.4e+96))
		tmp = Float64(c + Float64(x * y));
	else
		tmp = Float64(c + Float64(a * Float64(b * -0.25)));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a, b, c)
	tmp = 0.0;
	if (((x * y) <= -1.6e+162) || ~(((x * y) <= 2.4e+96)))
		tmp = c + (x * y);
	else
		tmp = c + (a * (b * -0.25));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_, c_] := If[Or[LessEqual[N[(x * y), $MachinePrecision], -1.6e+162], N[Not[LessEqual[N[(x * y), $MachinePrecision], 2.4e+96]], $MachinePrecision]], N[(c + N[(x * y), $MachinePrecision]), $MachinePrecision], N[(c + N[(a * N[(b * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -1.6 \cdot 10^{+162} \lor \neg \left(x \cdot y \leq 2.4 \cdot 10^{+96}\right):\\
\;\;\;\;c + x \cdot y\\

\mathbf{else}:\\
\;\;\;\;c + a \cdot \left(b \cdot -0.25\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 x y) < -1.6000000000000001e162 or 2.39999999999999993e96 < (*.f64 x y)

    1. Initial program 94.4%

      \[\left(\left(x \cdot y + \frac{z \cdot t}{16}\right) - \frac{a \cdot b}{4}\right) + c \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 72.1%

      \[\leadsto \color{blue}{x \cdot y} + c \]

    if -1.6000000000000001e162 < (*.f64 x y) < 2.39999999999999993e96

    1. Initial program 99.4%

      \[\left(\left(x \cdot y + \frac{z \cdot t}{16}\right) - \frac{a \cdot b}{4}\right) + c \]
    2. Add Preprocessing
    3. Taylor expanded in a around inf 64.4%

      \[\leadsto \color{blue}{-0.25 \cdot \left(a \cdot b\right)} + c \]
    4. Step-by-step derivation
      1. *-commutative64.4%

        \[\leadsto \color{blue}{\left(a \cdot b\right) \cdot -0.25} + c \]
      2. associate-*r*64.4%

        \[\leadsto \color{blue}{a \cdot \left(b \cdot -0.25\right)} + c \]
    5. Simplified64.4%

      \[\leadsto \color{blue}{a \cdot \left(b \cdot -0.25\right)} + c \]
  3. Recombined 2 regimes into one program.
  4. Final simplification67.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y \leq -1.6 \cdot 10^{+162} \lor \neg \left(x \cdot y \leq 2.4 \cdot 10^{+96}\right):\\ \;\;\;\;c + x \cdot y\\ \mathbf{else}:\\ \;\;\;\;c + a \cdot \left(b \cdot -0.25\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 76.9% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -12500000 \lor \neg \left(b \leq 1.35 \cdot 10^{+131}\right):\\ \;\;\;\;c + a \cdot \left(b \cdot -0.25\right)\\ \mathbf{else}:\\ \;\;\;\;c + \left(x \cdot y + \left(z \cdot t\right) \cdot 0.0625\right)\\ \end{array} \end{array} \]
(FPCore (x y z t a b c)
 :precision binary64
 (if (or (<= b -12500000.0) (not (<= b 1.35e+131)))
   (+ c (* a (* b -0.25)))
   (+ c (+ (* x y) (* (* z t) 0.0625)))))
double code(double x, double y, double z, double t, double a, double b, double c) {
	double tmp;
	if ((b <= -12500000.0) || !(b <= 1.35e+131)) {
		tmp = c + (a * (b * -0.25));
	} else {
		tmp = c + ((x * y) + ((z * t) * 0.0625));
	}
	return tmp;
}
real(8) function code(x, y, z, t, a, b, c)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8) :: tmp
    if ((b <= (-12500000.0d0)) .or. (.not. (b <= 1.35d+131))) then
        tmp = c + (a * (b * (-0.25d0)))
    else
        tmp = c + ((x * y) + ((z * t) * 0.0625d0))
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b, double c) {
	double tmp;
	if ((b <= -12500000.0) || !(b <= 1.35e+131)) {
		tmp = c + (a * (b * -0.25));
	} else {
		tmp = c + ((x * y) + ((z * t) * 0.0625));
	}
	return tmp;
}
def code(x, y, z, t, a, b, c):
	tmp = 0
	if (b <= -12500000.0) or not (b <= 1.35e+131):
		tmp = c + (a * (b * -0.25))
	else:
		tmp = c + ((x * y) + ((z * t) * 0.0625))
	return tmp
function code(x, y, z, t, a, b, c)
	tmp = 0.0
	if ((b <= -12500000.0) || !(b <= 1.35e+131))
		tmp = Float64(c + Float64(a * Float64(b * -0.25)));
	else
		tmp = Float64(c + Float64(Float64(x * y) + Float64(Float64(z * t) * 0.0625)));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a, b, c)
	tmp = 0.0;
	if ((b <= -12500000.0) || ~((b <= 1.35e+131)))
		tmp = c + (a * (b * -0.25));
	else
		tmp = c + ((x * y) + ((z * t) * 0.0625));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_, c_] := If[Or[LessEqual[b, -12500000.0], N[Not[LessEqual[b, 1.35e+131]], $MachinePrecision]], N[(c + N[(a * N[(b * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c + N[(N[(x * y), $MachinePrecision] + N[(N[(z * t), $MachinePrecision] * 0.0625), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \leq -12500000 \lor \neg \left(b \leq 1.35 \cdot 10^{+131}\right):\\
\;\;\;\;c + a \cdot \left(b \cdot -0.25\right)\\

\mathbf{else}:\\
\;\;\;\;c + \left(x \cdot y + \left(z \cdot t\right) \cdot 0.0625\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < -1.25e7 or 1.35000000000000002e131 < b

    1. Initial program 94.9%

      \[\left(\left(x \cdot y + \frac{z \cdot t}{16}\right) - \frac{a \cdot b}{4}\right) + c \]
    2. Add Preprocessing
    3. Taylor expanded in a around inf 71.3%

      \[\leadsto \color{blue}{-0.25 \cdot \left(a \cdot b\right)} + c \]
    4. Step-by-step derivation
      1. *-commutative71.3%

        \[\leadsto \color{blue}{\left(a \cdot b\right) \cdot -0.25} + c \]
      2. associate-*r*71.3%

        \[\leadsto \color{blue}{a \cdot \left(b \cdot -0.25\right)} + c \]
    5. Simplified71.3%

      \[\leadsto \color{blue}{a \cdot \left(b \cdot -0.25\right)} + c \]

    if -1.25e7 < b < 1.35000000000000002e131

    1. Initial program 99.4%

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

      \[\leadsto \color{blue}{\left(0.0625 \cdot \left(t \cdot z\right) + x \cdot y\right)} + c \]
  3. Recombined 2 regimes into one program.
  4. Final simplification80.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -12500000 \lor \neg \left(b \leq 1.35 \cdot 10^{+131}\right):\\ \;\;\;\;c + a \cdot \left(b \cdot -0.25\right)\\ \mathbf{else}:\\ \;\;\;\;c + \left(x \cdot y + \left(z \cdot t\right) \cdot 0.0625\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 37.4% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -2.9 \cdot 10^{-107}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;y \leq 6.6 \cdot 10^{-159}:\\ \;\;\;\;z \cdot \left(t \cdot 0.0625\right)\\ \mathbf{elif}\;y \leq 5.5 \cdot 10^{+92}:\\ \;\;\;\;c\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \end{array} \]
(FPCore (x y z t a b c)
 :precision binary64
 (if (<= y -2.9e-107)
   (* x y)
   (if (<= y 6.6e-159) (* z (* t 0.0625)) (if (<= y 5.5e+92) c (* x y)))))
double code(double x, double y, double z, double t, double a, double b, double c) {
	double tmp;
	if (y <= -2.9e-107) {
		tmp = x * y;
	} else if (y <= 6.6e-159) {
		tmp = z * (t * 0.0625);
	} else if (y <= 5.5e+92) {
		tmp = c;
	} else {
		tmp = x * y;
	}
	return tmp;
}
real(8) function code(x, y, z, t, a, b, c)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8) :: tmp
    if (y <= (-2.9d-107)) then
        tmp = x * y
    else if (y <= 6.6d-159) then
        tmp = z * (t * 0.0625d0)
    else if (y <= 5.5d+92) then
        tmp = c
    else
        tmp = x * y
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b, double c) {
	double tmp;
	if (y <= -2.9e-107) {
		tmp = x * y;
	} else if (y <= 6.6e-159) {
		tmp = z * (t * 0.0625);
	} else if (y <= 5.5e+92) {
		tmp = c;
	} else {
		tmp = x * y;
	}
	return tmp;
}
def code(x, y, z, t, a, b, c):
	tmp = 0
	if y <= -2.9e-107:
		tmp = x * y
	elif y <= 6.6e-159:
		tmp = z * (t * 0.0625)
	elif y <= 5.5e+92:
		tmp = c
	else:
		tmp = x * y
	return tmp
function code(x, y, z, t, a, b, c)
	tmp = 0.0
	if (y <= -2.9e-107)
		tmp = Float64(x * y);
	elseif (y <= 6.6e-159)
		tmp = Float64(z * Float64(t * 0.0625));
	elseif (y <= 5.5e+92)
		tmp = c;
	else
		tmp = Float64(x * y);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a, b, c)
	tmp = 0.0;
	if (y <= -2.9e-107)
		tmp = x * y;
	elseif (y <= 6.6e-159)
		tmp = z * (t * 0.0625);
	elseif (y <= 5.5e+92)
		tmp = c;
	else
		tmp = x * y;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_, c_] := If[LessEqual[y, -2.9e-107], N[(x * y), $MachinePrecision], If[LessEqual[y, 6.6e-159], N[(z * N[(t * 0.0625), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 5.5e+92], c, N[(x * y), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.9 \cdot 10^{-107}:\\
\;\;\;\;x \cdot y\\

\mathbf{elif}\;y \leq 6.6 \cdot 10^{-159}:\\
\;\;\;\;z \cdot \left(t \cdot 0.0625\right)\\

\mathbf{elif}\;y \leq 5.5 \cdot 10^{+92}:\\
\;\;\;\;c\\

\mathbf{else}:\\
\;\;\;\;x \cdot y\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -2.8999999999999998e-107 or 5.50000000000000053e92 < y

    1. Initial program 96.3%

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

      \[\leadsto \color{blue}{\left(0.0625 \cdot \left(t \cdot z\right) + x \cdot y\right)} + c \]
    4. Taylor expanded in c around 0 60.7%

      \[\leadsto \color{blue}{0.0625 \cdot \left(t \cdot z\right) + x \cdot y} \]
    5. Taylor expanded in t around 0 40.8%

      \[\leadsto \color{blue}{x \cdot y} \]

    if -2.8999999999999998e-107 < y < 6.6000000000000003e-159

    1. Initial program 100.0%

      \[\left(\left(x \cdot y + \frac{z \cdot t}{16}\right) - \frac{a \cdot b}{4}\right) + c \]
    2. Add Preprocessing
    3. Taylor expanded in z around inf 55.8%

      \[\leadsto \color{blue}{0.0625 \cdot \left(t \cdot z\right)} + c \]
    4. Step-by-step derivation
      1. *-commutative55.8%

        \[\leadsto 0.0625 \cdot \color{blue}{\left(z \cdot t\right)} + c \]
      2. associate-*r*55.8%

        \[\leadsto \color{blue}{\left(0.0625 \cdot z\right) \cdot t} + c \]
      3. *-commutative55.8%

        \[\leadsto \color{blue}{t \cdot \left(0.0625 \cdot z\right)} + c \]
    5. Simplified55.8%

      \[\leadsto \color{blue}{t \cdot \left(0.0625 \cdot z\right)} + c \]
    6. Taylor expanded in t around inf 33.1%

      \[\leadsto \color{blue}{0.0625 \cdot \left(t \cdot z\right)} \]
    7. Step-by-step derivation
      1. *-commutative33.1%

        \[\leadsto \color{blue}{\left(t \cdot z\right) \cdot 0.0625} \]
      2. *-commutative33.1%

        \[\leadsto \color{blue}{\left(z \cdot t\right)} \cdot 0.0625 \]
      3. associate-*r*33.1%

        \[\leadsto \color{blue}{z \cdot \left(t \cdot 0.0625\right)} \]
      4. *-commutative33.1%

        \[\leadsto z \cdot \color{blue}{\left(0.0625 \cdot t\right)} \]
    8. Simplified33.1%

      \[\leadsto \color{blue}{z \cdot \left(0.0625 \cdot t\right)} \]

    if 6.6000000000000003e-159 < y < 5.50000000000000053e92

    1. Initial program 98.0%

      \[\left(\left(x \cdot y + \frac{z \cdot t}{16}\right) - \frac{a \cdot b}{4}\right) + c \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 53.5%

      \[\leadsto \color{blue}{x \cdot y} + c \]
    4. Taylor expanded in x around 0 34.1%

      \[\leadsto \color{blue}{c} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification37.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.9 \cdot 10^{-107}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;y \leq 6.6 \cdot 10^{-159}:\\ \;\;\;\;z \cdot \left(t \cdot 0.0625\right)\\ \mathbf{elif}\;y \leq 5.5 \cdot 10^{+92}:\\ \;\;\;\;c\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 53.0% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -1.4 \cdot 10^{+214} \lor \neg \left(z \leq 2.4 \cdot 10^{-30}\right):\\ \;\;\;\;z \cdot \left(t \cdot 0.0625\right)\\ \mathbf{else}:\\ \;\;\;\;c + x \cdot y\\ \end{array} \end{array} \]
(FPCore (x y z t a b c)
 :precision binary64
 (if (or (<= z -1.4e+214) (not (<= z 2.4e-30)))
   (* z (* t 0.0625))
   (+ c (* x y))))
double code(double x, double y, double z, double t, double a, double b, double c) {
	double tmp;
	if ((z <= -1.4e+214) || !(z <= 2.4e-30)) {
		tmp = z * (t * 0.0625);
	} else {
		tmp = c + (x * y);
	}
	return tmp;
}
real(8) function code(x, y, z, t, a, b, c)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8) :: tmp
    if ((z <= (-1.4d+214)) .or. (.not. (z <= 2.4d-30))) then
        tmp = z * (t * 0.0625d0)
    else
        tmp = c + (x * y)
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b, double c) {
	double tmp;
	if ((z <= -1.4e+214) || !(z <= 2.4e-30)) {
		tmp = z * (t * 0.0625);
	} else {
		tmp = c + (x * y);
	}
	return tmp;
}
def code(x, y, z, t, a, b, c):
	tmp = 0
	if (z <= -1.4e+214) or not (z <= 2.4e-30):
		tmp = z * (t * 0.0625)
	else:
		tmp = c + (x * y)
	return tmp
function code(x, y, z, t, a, b, c)
	tmp = 0.0
	if ((z <= -1.4e+214) || !(z <= 2.4e-30))
		tmp = Float64(z * Float64(t * 0.0625));
	else
		tmp = Float64(c + Float64(x * y));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a, b, c)
	tmp = 0.0;
	if ((z <= -1.4e+214) || ~((z <= 2.4e-30)))
		tmp = z * (t * 0.0625);
	else
		tmp = c + (x * y);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_, c_] := If[Or[LessEqual[z, -1.4e+214], N[Not[LessEqual[z, 2.4e-30]], $MachinePrecision]], N[(z * N[(t * 0.0625), $MachinePrecision]), $MachinePrecision], N[(c + N[(x * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.4 \cdot 10^{+214} \lor \neg \left(z \leq 2.4 \cdot 10^{-30}\right):\\
\;\;\;\;z \cdot \left(t \cdot 0.0625\right)\\

\mathbf{else}:\\
\;\;\;\;c + x \cdot y\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.3999999999999999e214 or 2.39999999999999985e-30 < z

    1. Initial program 97.6%

      \[\left(\left(x \cdot y + \frac{z \cdot t}{16}\right) - \frac{a \cdot b}{4}\right) + c \]
    2. Add Preprocessing
    3. Taylor expanded in z around inf 64.1%

      \[\leadsto \color{blue}{0.0625 \cdot \left(t \cdot z\right)} + c \]
    4. Step-by-step derivation
      1. *-commutative64.1%

        \[\leadsto 0.0625 \cdot \color{blue}{\left(z \cdot t\right)} + c \]
      2. associate-*r*64.1%

        \[\leadsto \color{blue}{\left(0.0625 \cdot z\right) \cdot t} + c \]
      3. *-commutative64.1%

        \[\leadsto \color{blue}{t \cdot \left(0.0625 \cdot z\right)} + c \]
    5. Simplified64.1%

      \[\leadsto \color{blue}{t \cdot \left(0.0625 \cdot z\right)} + c \]
    6. Taylor expanded in t around inf 48.1%

      \[\leadsto \color{blue}{0.0625 \cdot \left(t \cdot z\right)} \]
    7. Step-by-step derivation
      1. *-commutative48.1%

        \[\leadsto \color{blue}{\left(t \cdot z\right) \cdot 0.0625} \]
      2. *-commutative48.1%

        \[\leadsto \color{blue}{\left(z \cdot t\right)} \cdot 0.0625 \]
      3. associate-*r*48.1%

        \[\leadsto \color{blue}{z \cdot \left(t \cdot 0.0625\right)} \]
      4. *-commutative48.1%

        \[\leadsto z \cdot \color{blue}{\left(0.0625 \cdot t\right)} \]
    8. Simplified48.1%

      \[\leadsto \color{blue}{z \cdot \left(0.0625 \cdot t\right)} \]

    if -1.3999999999999999e214 < z < 2.39999999999999985e-30

    1. Initial program 97.6%

      \[\left(\left(x \cdot y + \frac{z \cdot t}{16}\right) - \frac{a \cdot b}{4}\right) + c \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 52.6%

      \[\leadsto \color{blue}{x \cdot y} + c \]
  3. Recombined 2 regimes into one program.
  4. Final simplification51.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.4 \cdot 10^{+214} \lor \neg \left(z \leq 2.4 \cdot 10^{-30}\right):\\ \;\;\;\;z \cdot \left(t \cdot 0.0625\right)\\ \mathbf{else}:\\ \;\;\;\;c + x \cdot y\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 35.7% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c \leq -1.8 \cdot 10^{+74}:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq 2.35 \cdot 10^{-84}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \end{array} \]
(FPCore (x y z t a b c)
 :precision binary64
 (if (<= c -1.8e+74) c (if (<= c 2.35e-84) (* x y) c)))
double code(double x, double y, double z, double t, double a, double b, double c) {
	double tmp;
	if (c <= -1.8e+74) {
		tmp = c;
	} else if (c <= 2.35e-84) {
		tmp = x * y;
	} else {
		tmp = c;
	}
	return tmp;
}
real(8) function code(x, y, z, t, a, b, c)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8) :: tmp
    if (c <= (-1.8d+74)) then
        tmp = c
    else if (c <= 2.35d-84) then
        tmp = x * y
    else
        tmp = c
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b, double c) {
	double tmp;
	if (c <= -1.8e+74) {
		tmp = c;
	} else if (c <= 2.35e-84) {
		tmp = x * y;
	} else {
		tmp = c;
	}
	return tmp;
}
def code(x, y, z, t, a, b, c):
	tmp = 0
	if c <= -1.8e+74:
		tmp = c
	elif c <= 2.35e-84:
		tmp = x * y
	else:
		tmp = c
	return tmp
function code(x, y, z, t, a, b, c)
	tmp = 0.0
	if (c <= -1.8e+74)
		tmp = c;
	elseif (c <= 2.35e-84)
		tmp = Float64(x * y);
	else
		tmp = c;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a, b, c)
	tmp = 0.0;
	if (c <= -1.8e+74)
		tmp = c;
	elseif (c <= 2.35e-84)
		tmp = x * y;
	else
		tmp = c;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_, c_] := If[LessEqual[c, -1.8e+74], c, If[LessEqual[c, 2.35e-84], N[(x * y), $MachinePrecision], c]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.8 \cdot 10^{+74}:\\
\;\;\;\;c\\

\mathbf{elif}\;c \leq 2.35 \cdot 10^{-84}:\\
\;\;\;\;x \cdot y\\

\mathbf{else}:\\
\;\;\;\;c\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -1.79999999999999994e74 or 2.35e-84 < c

    1. Initial program 98.2%

      \[\left(\left(x \cdot y + \frac{z \cdot t}{16}\right) - \frac{a \cdot b}{4}\right) + c \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 52.6%

      \[\leadsto \color{blue}{x \cdot y} + c \]
    4. Taylor expanded in x around 0 40.4%

      \[\leadsto \color{blue}{c} \]

    if -1.79999999999999994e74 < c < 2.35e-84

    1. Initial program 97.2%

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

      \[\leadsto \color{blue}{\left(0.0625 \cdot \left(t \cdot z\right) + x \cdot y\right)} + c \]
    4. Taylor expanded in c around 0 62.4%

      \[\leadsto \color{blue}{0.0625 \cdot \left(t \cdot z\right) + x \cdot y} \]
    5. Taylor expanded in t around 0 38.7%

      \[\leadsto \color{blue}{x \cdot y} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification39.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -1.8 \cdot 10^{+74}:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq 2.35 \cdot 10^{-84}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 22.0% accurate, 17.0× speedup?

\[\begin{array}{l} \\ c \end{array} \]
(FPCore (x y z t a b c) :precision binary64 c)
double code(double x, double y, double z, double t, double a, double b, double c) {
	return c;
}
real(8) function code(x, y, z, t, a, b, c)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    code = c
end function
public static double code(double x, double y, double z, double t, double a, double b, double c) {
	return c;
}
def code(x, y, z, t, a, b, c):
	return c
function code(x, y, z, t, a, b, c)
	return c
end
function tmp = code(x, y, z, t, a, b, c)
	tmp = c;
end
code[x_, y_, z_, t_, a_, b_, c_] := c
\begin{array}{l}

\\
c
\end{array}
Derivation
  1. Initial program 97.6%

    \[\left(\left(x \cdot y + \frac{z \cdot t}{16}\right) - \frac{a \cdot b}{4}\right) + c \]
  2. Add Preprocessing
  3. Taylor expanded in x around inf 46.7%

    \[\leadsto \color{blue}{x \cdot y} + c \]
  4. Taylor expanded in x around 0 20.9%

    \[\leadsto \color{blue}{c} \]
  5. Final simplification20.9%

    \[\leadsto c \]
  6. Add Preprocessing

Reproduce

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