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

Percentage Accurate: 97.8% → 98.2%
Time: 11.8s
Alternatives: 13
Speedup: 1.0×

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 13 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.8% 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.2% accurate, 0.1× speedup?

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

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

    \[\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.8%

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

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

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

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

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

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

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

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

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

    \[\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. Add Preprocessing

Alternative 2: 65.1% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := c + a \cdot \left(b \cdot -0.25\right)\\ t_2 := c + x \cdot y\\ \mathbf{if}\;x \cdot y \leq -3.6 \cdot 10^{+124}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;x \cdot y \leq -5 \cdot 10^{-312}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \cdot y \leq 1.55 \cdot 10^{-191}:\\ \;\;\;\;c + z \cdot \left(t \cdot 0.0625\right)\\ \mathbf{elif}\;x \cdot y \leq 2 \cdot 10^{+193}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;t\_2\\ \end{array} \end{array} \]
(FPCore (x y z t a b c)
 :precision binary64
 (let* ((t_1 (+ c (* a (* b -0.25)))) (t_2 (+ c (* x y))))
   (if (<= (* x y) -3.6e+124)
     t_2
     (if (<= (* x y) -5e-312)
       t_1
       (if (<= (* x y) 1.55e-191)
         (+ c (* z (* t 0.0625)))
         (if (<= (* x y) 2e+193) t_1 t_2))))))
double code(double x, double y, double z, double t, double a, double b, double c) {
	double t_1 = c + (a * (b * -0.25));
	double t_2 = c + (x * y);
	double tmp;
	if ((x * y) <= -3.6e+124) {
		tmp = t_2;
	} else if ((x * y) <= -5e-312) {
		tmp = t_1;
	} else if ((x * y) <= 1.55e-191) {
		tmp = c + (z * (t * 0.0625));
	} else if ((x * y) <= 2e+193) {
		tmp = t_1;
	} else {
		tmp = t_2;
	}
	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 = c + (a * (b * (-0.25d0)))
    t_2 = c + (x * y)
    if ((x * y) <= (-3.6d+124)) then
        tmp = t_2
    else if ((x * y) <= (-5d-312)) then
        tmp = t_1
    else if ((x * y) <= 1.55d-191) then
        tmp = c + (z * (t * 0.0625d0))
    else if ((x * y) <= 2d+193) then
        tmp = t_1
    else
        tmp = t_2
    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 = c + (a * (b * -0.25));
	double t_2 = c + (x * y);
	double tmp;
	if ((x * y) <= -3.6e+124) {
		tmp = t_2;
	} else if ((x * y) <= -5e-312) {
		tmp = t_1;
	} else if ((x * y) <= 1.55e-191) {
		tmp = c + (z * (t * 0.0625));
	} else if ((x * y) <= 2e+193) {
		tmp = t_1;
	} else {
		tmp = t_2;
	}
	return tmp;
}
def code(x, y, z, t, a, b, c):
	t_1 = c + (a * (b * -0.25))
	t_2 = c + (x * y)
	tmp = 0
	if (x * y) <= -3.6e+124:
		tmp = t_2
	elif (x * y) <= -5e-312:
		tmp = t_1
	elif (x * y) <= 1.55e-191:
		tmp = c + (z * (t * 0.0625))
	elif (x * y) <= 2e+193:
		tmp = t_1
	else:
		tmp = t_2
	return tmp
function code(x, y, z, t, a, b, c)
	t_1 = Float64(c + Float64(a * Float64(b * -0.25)))
	t_2 = Float64(c + Float64(x * y))
	tmp = 0.0
	if (Float64(x * y) <= -3.6e+124)
		tmp = t_2;
	elseif (Float64(x * y) <= -5e-312)
		tmp = t_1;
	elseif (Float64(x * y) <= 1.55e-191)
		tmp = Float64(c + Float64(z * Float64(t * 0.0625)));
	elseif (Float64(x * y) <= 2e+193)
		tmp = t_1;
	else
		tmp = t_2;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a, b, c)
	t_1 = c + (a * (b * -0.25));
	t_2 = c + (x * y);
	tmp = 0.0;
	if ((x * y) <= -3.6e+124)
		tmp = t_2;
	elseif ((x * y) <= -5e-312)
		tmp = t_1;
	elseif ((x * y) <= 1.55e-191)
		tmp = c + (z * (t * 0.0625));
	elseif ((x * y) <= 2e+193)
		tmp = t_1;
	else
		tmp = t_2;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_, c_] := Block[{t$95$1 = N[(c + N[(a * N[(b * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(c + N[(x * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x * y), $MachinePrecision], -3.6e+124], t$95$2, If[LessEqual[N[(x * y), $MachinePrecision], -5e-312], t$95$1, If[LessEqual[N[(x * y), $MachinePrecision], 1.55e-191], N[(c + N[(z * N[(t * 0.0625), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 2e+193], t$95$1, t$95$2]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := c + a \cdot \left(b \cdot -0.25\right)\\
t_2 := c + x \cdot y\\
\mathbf{if}\;x \cdot y \leq -3.6 \cdot 10^{+124}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;x \cdot y \leq -5 \cdot 10^{-312}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \cdot y \leq 1.55 \cdot 10^{-191}:\\
\;\;\;\;c + z \cdot \left(t \cdot 0.0625\right)\\

\mathbf{elif}\;x \cdot y \leq 2 \cdot 10^{+193}:\\
\;\;\;\;t\_1\\

\mathbf{else}:\\
\;\;\;\;t\_2\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 x y) < -3.59999999999999986e124 or 2.00000000000000013e193 < (*.f64 x y)

    1. Initial program 94.3%

      \[\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-94.3%

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

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

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

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

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

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

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

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

        \[\leadsto \left(\mathsf{fma}\left(x, y, z \cdot \frac{t}{16}\right) - \color{blue}{a \cdot \frac{b}{4}}\right) + c \]
    3. Simplified97.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. Taylor expanded in x around inf 84.8%

      \[\leadsto \left(\color{blue}{x \cdot y} - a \cdot \frac{b}{4}\right) + c \]
    6. Taylor expanded in x around inf 80.7%

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

    if -3.59999999999999986e124 < (*.f64 x y) < -5.0000000000022e-312 or 1.5500000000000001e-191 < (*.f64 x y) < 2.00000000000000013e193

    1. Initial program 98.9%

      \[\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+98.9%

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

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

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

        \[\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-frac298.9%

        \[\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-eval98.9%

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

      \[\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. Taylor expanded in a around inf 70.9%

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

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

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

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

    if -5.0000000000022e-312 < (*.f64 x y) < 1.5500000000000001e-191

    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 x around 0 100.0%

      \[\leadsto \color{blue}{\left(0.0625 \cdot \left(t \cdot z\right) - 0.25 \cdot \left(a \cdot b\right)\right)} + c \]
    4. Taylor expanded in a around 0 84.2%

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

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

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

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

        \[\leadsto c + z \cdot \color{blue}{\left(0.0625 \cdot t\right)} \]
    6. Simplified84.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y \leq -3.6 \cdot 10^{+124}:\\ \;\;\;\;c + x \cdot y\\ \mathbf{elif}\;x \cdot y \leq -5 \cdot 10^{-312}:\\ \;\;\;\;c + a \cdot \left(b \cdot -0.25\right)\\ \mathbf{elif}\;x \cdot y \leq 1.55 \cdot 10^{-191}:\\ \;\;\;\;c + z \cdot \left(t \cdot 0.0625\right)\\ \mathbf{elif}\;x \cdot y \leq 2 \cdot 10^{+193}:\\ \;\;\;\;c + a \cdot \left(b \cdot -0.25\right)\\ \mathbf{else}:\\ \;\;\;\;c + x \cdot y\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 42.1% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := b \cdot \left(a \cdot -0.25\right)\\ \mathbf{if}\;x \cdot y \leq -4.7 \cdot 10^{+121}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;x \cdot y \leq -2.1 \cdot 10^{+34}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \cdot y \leq 1.15 \cdot 10^{-39}:\\ \;\;\;\;c\\ \mathbf{elif}\;x \cdot y \leq 2 \cdot 10^{+193}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \end{array} \]
(FPCore (x y z t a b c)
 :precision binary64
 (let* ((t_1 (* b (* a -0.25))))
   (if (<= (* x y) -4.7e+121)
     (* x y)
     (if (<= (* x y) -2.1e+34)
       t_1
       (if (<= (* x y) 1.15e-39) c (if (<= (* x y) 2e+193) t_1 (* x y)))))))
double code(double x, double y, double z, double t, double a, double b, double c) {
	double t_1 = b * (a * -0.25);
	double tmp;
	if ((x * y) <= -4.7e+121) {
		tmp = x * y;
	} else if ((x * y) <= -2.1e+34) {
		tmp = t_1;
	} else if ((x * y) <= 1.15e-39) {
		tmp = c;
	} else if ((x * y) <= 2e+193) {
		tmp = t_1;
	} 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) :: t_1
    real(8) :: tmp
    t_1 = b * (a * (-0.25d0))
    if ((x * y) <= (-4.7d+121)) then
        tmp = x * y
    else if ((x * y) <= (-2.1d+34)) then
        tmp = t_1
    else if ((x * y) <= 1.15d-39) then
        tmp = c
    else if ((x * y) <= 2d+193) then
        tmp = t_1
    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 t_1 = b * (a * -0.25);
	double tmp;
	if ((x * y) <= -4.7e+121) {
		tmp = x * y;
	} else if ((x * y) <= -2.1e+34) {
		tmp = t_1;
	} else if ((x * y) <= 1.15e-39) {
		tmp = c;
	} else if ((x * y) <= 2e+193) {
		tmp = t_1;
	} else {
		tmp = x * y;
	}
	return tmp;
}
def code(x, y, z, t, a, b, c):
	t_1 = b * (a * -0.25)
	tmp = 0
	if (x * y) <= -4.7e+121:
		tmp = x * y
	elif (x * y) <= -2.1e+34:
		tmp = t_1
	elif (x * y) <= 1.15e-39:
		tmp = c
	elif (x * y) <= 2e+193:
		tmp = t_1
	else:
		tmp = x * y
	return tmp
function code(x, y, z, t, a, b, c)
	t_1 = Float64(b * Float64(a * -0.25))
	tmp = 0.0
	if (Float64(x * y) <= -4.7e+121)
		tmp = Float64(x * y);
	elseif (Float64(x * y) <= -2.1e+34)
		tmp = t_1;
	elseif (Float64(x * y) <= 1.15e-39)
		tmp = c;
	elseif (Float64(x * y) <= 2e+193)
		tmp = t_1;
	else
		tmp = Float64(x * y);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a, b, c)
	t_1 = b * (a * -0.25);
	tmp = 0.0;
	if ((x * y) <= -4.7e+121)
		tmp = x * y;
	elseif ((x * y) <= -2.1e+34)
		tmp = t_1;
	elseif ((x * y) <= 1.15e-39)
		tmp = c;
	elseif ((x * y) <= 2e+193)
		tmp = t_1;
	else
		tmp = x * y;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_, c_] := Block[{t$95$1 = N[(b * N[(a * -0.25), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x * y), $MachinePrecision], -4.7e+121], N[(x * y), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], -2.1e+34], t$95$1, If[LessEqual[N[(x * y), $MachinePrecision], 1.15e-39], c, If[LessEqual[N[(x * y), $MachinePrecision], 2e+193], t$95$1, N[(x * y), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := b \cdot \left(a \cdot -0.25\right)\\
\mathbf{if}\;x \cdot y \leq -4.7 \cdot 10^{+121}:\\
\;\;\;\;x \cdot y\\

\mathbf{elif}\;x \cdot y \leq -2.1 \cdot 10^{+34}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \cdot y \leq 1.15 \cdot 10^{-39}:\\
\;\;\;\;c\\

\mathbf{elif}\;x \cdot y \leq 2 \cdot 10^{+193}:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 x y) < -4.70000000000000005e121 or 2.00000000000000013e193 < (*.f64 x y)

    1. Initial program 94.3%

      \[\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-94.3%

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

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

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

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

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

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

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

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

        \[\leadsto \left(\mathsf{fma}\left(x, y, z \cdot \frac{t}{16}\right) - \color{blue}{a \cdot \frac{b}{4}}\right) + c \]
    3. Simplified97.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. Taylor expanded in x around inf 84.8%

      \[\leadsto \left(\color{blue}{x \cdot y} - a \cdot \frac{b}{4}\right) + c \]
    6. Taylor expanded in x around inf 80.7%

      \[\leadsto \color{blue}{x \cdot y} + c \]
    7. Taylor expanded in x around inf 73.8%

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

    if -4.70000000000000005e121 < (*.f64 x y) < -2.10000000000000017e34 or 1.15000000000000004e-39 < (*.f64 x y) < 2.00000000000000013e193

    1. Initial program 98.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 b around inf 88.3%

      \[\leadsto \color{blue}{b \cdot \left(\left(0.0625 \cdot \frac{t \cdot z}{b} + \frac{x \cdot y}{b}\right) - 0.25 \cdot a\right)} + c \]
    4. Taylor expanded in t around inf 84.9%

      \[\leadsto b \cdot \left(\color{blue}{0.0625 \cdot \frac{t \cdot z}{b}} - 0.25 \cdot a\right) + c \]
    5. Step-by-step derivation
      1. associate-*r/84.9%

        \[\leadsto b \cdot \left(\color{blue}{\frac{0.0625 \cdot \left(t \cdot z\right)}{b}} - 0.25 \cdot a\right) + c \]
    6. Simplified84.9%

      \[\leadsto b \cdot \left(\color{blue}{\frac{0.0625 \cdot \left(t \cdot z\right)}{b}} - 0.25 \cdot a\right) + c \]
    7. Taylor expanded in c around 0 66.2%

      \[\leadsto \color{blue}{b \cdot \left(0.0625 \cdot \frac{t \cdot z}{b} - 0.25 \cdot a\right)} \]
    8. Taylor expanded in t around 0 52.7%

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

    if -2.10000000000000017e34 < (*.f64 x y) < 1.15000000000000004e-39

    1. Initial program 99.2%

      \[\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+99.2%

        \[\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. fmm-def99.2%

        \[\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.2%

        \[\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.2%

        \[\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.2%

      \[\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. Taylor expanded in a around inf 68.2%

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

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

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

      \[\leadsto \color{blue}{a \cdot \left(b \cdot -0.25\right)} + c \]
    8. Taylor expanded in a around 0 40.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y \leq -4.7 \cdot 10^{+121}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;x \cdot y \leq -2.1 \cdot 10^{+34}:\\ \;\;\;\;b \cdot \left(a \cdot -0.25\right)\\ \mathbf{elif}\;x \cdot y \leq 1.15 \cdot 10^{-39}:\\ \;\;\;\;c\\ \mathbf{elif}\;x \cdot y \leq 2 \cdot 10^{+193}:\\ \;\;\;\;b \cdot \left(a \cdot -0.25\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 89.5% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \cdot b \leq -4 \cdot 10^{+127}:\\ \;\;\;\;c + b \cdot \left(\frac{\left(z \cdot t\right) \cdot 0.0625}{b} - a \cdot 0.25\right)\\ \mathbf{elif}\;a \cdot b \leq 2 \cdot 10^{+107}:\\ \;\;\;\;c + \left(\left(x \cdot y + a \cdot \left(b \cdot 0.25\right)\right) + z \cdot \left(t \cdot 0.0625\right)\right)\\ \mathbf{else}:\\ \;\;\;\;c + \left(x \cdot y - a \cdot \frac{b}{4}\right)\\ \end{array} \end{array} \]
(FPCore (x y z t a b c)
 :precision binary64
 (if (<= (* a b) -4e+127)
   (+ c (* b (- (/ (* (* z t) 0.0625) b) (* a 0.25))))
   (if (<= (* a b) 2e+107)
     (+ c (+ (+ (* x y) (* a (* b 0.25))) (* z (* t 0.0625))))
     (+ c (- (* x y) (* a (/ b 4.0)))))))
double code(double x, double y, double z, double t, double a, double b, double c) {
	double tmp;
	if ((a * b) <= -4e+127) {
		tmp = c + (b * ((((z * t) * 0.0625) / b) - (a * 0.25)));
	} else if ((a * b) <= 2e+107) {
		tmp = c + (((x * y) + (a * (b * 0.25))) + (z * (t * 0.0625)));
	} else {
		tmp = c + ((x * y) - (a * (b / 4.0)));
	}
	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) <= (-4d+127)) then
        tmp = c + (b * ((((z * t) * 0.0625d0) / b) - (a * 0.25d0)))
    else if ((a * b) <= 2d+107) then
        tmp = c + (((x * y) + (a * (b * 0.25d0))) + (z * (t * 0.0625d0)))
    else
        tmp = c + ((x * y) - (a * (b / 4.0d0)))
    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) <= -4e+127) {
		tmp = c + (b * ((((z * t) * 0.0625) / b) - (a * 0.25)));
	} else if ((a * b) <= 2e+107) {
		tmp = c + (((x * y) + (a * (b * 0.25))) + (z * (t * 0.0625)));
	} else {
		tmp = c + ((x * y) - (a * (b / 4.0)));
	}
	return tmp;
}
def code(x, y, z, t, a, b, c):
	tmp = 0
	if (a * b) <= -4e+127:
		tmp = c + (b * ((((z * t) * 0.0625) / b) - (a * 0.25)))
	elif (a * b) <= 2e+107:
		tmp = c + (((x * y) + (a * (b * 0.25))) + (z * (t * 0.0625)))
	else:
		tmp = c + ((x * y) - (a * (b / 4.0)))
	return tmp
function code(x, y, z, t, a, b, c)
	tmp = 0.0
	if (Float64(a * b) <= -4e+127)
		tmp = Float64(c + Float64(b * Float64(Float64(Float64(Float64(z * t) * 0.0625) / b) - Float64(a * 0.25))));
	elseif (Float64(a * b) <= 2e+107)
		tmp = Float64(c + Float64(Float64(Float64(x * y) + Float64(a * Float64(b * 0.25))) + Float64(z * Float64(t * 0.0625))));
	else
		tmp = Float64(c + Float64(Float64(x * y) - Float64(a * Float64(b / 4.0))));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a, b, c)
	tmp = 0.0;
	if ((a * b) <= -4e+127)
		tmp = c + (b * ((((z * t) * 0.0625) / b) - (a * 0.25)));
	elseif ((a * b) <= 2e+107)
		tmp = c + (((x * y) + (a * (b * 0.25))) + (z * (t * 0.0625)));
	else
		tmp = c + ((x * y) - (a * (b / 4.0)));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_, c_] := If[LessEqual[N[(a * b), $MachinePrecision], -4e+127], N[(c + N[(b * N[(N[(N[(N[(z * t), $MachinePrecision] * 0.0625), $MachinePrecision] / b), $MachinePrecision] - N[(a * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 2e+107], N[(c + N[(N[(N[(x * y), $MachinePrecision] + N[(a * N[(b * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(z * N[(t * 0.0625), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c + N[(N[(x * y), $MachinePrecision] - N[(a * N[(b / 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -4 \cdot 10^{+127}:\\
\;\;\;\;c + b \cdot \left(\frac{\left(z \cdot t\right) \cdot 0.0625}{b} - a \cdot 0.25\right)\\

\mathbf{elif}\;a \cdot b \leq 2 \cdot 10^{+107}:\\
\;\;\;\;c + \left(\left(x \cdot y + a \cdot \left(b \cdot 0.25\right)\right) + z \cdot \left(t \cdot 0.0625\right)\right)\\

\mathbf{else}:\\
\;\;\;\;c + \left(x \cdot y - a \cdot \frac{b}{4}\right)\\


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

    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 b around inf 100.0%

      \[\leadsto \color{blue}{b \cdot \left(\left(0.0625 \cdot \frac{t \cdot z}{b} + \frac{x \cdot y}{b}\right) - 0.25 \cdot a\right)} + c \]
    4. Taylor expanded in t around inf 95.3%

      \[\leadsto b \cdot \left(\color{blue}{0.0625 \cdot \frac{t \cdot z}{b}} - 0.25 \cdot a\right) + c \]
    5. Step-by-step derivation
      1. associate-*r/95.3%

        \[\leadsto b \cdot \left(\color{blue}{\frac{0.0625 \cdot \left(t \cdot z\right)}{b}} - 0.25 \cdot a\right) + c \]
    6. Simplified95.3%

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

    if -3.99999999999999982e127 < (*.f64 a b) < 1.9999999999999999e107

    1. Initial program 98.9%

      \[\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+98.9%

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

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

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

        \[\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-frac2100.0%

        \[\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-eval100.0%

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

      \[\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. Step-by-step derivation
      1. fma-undefine99.4%

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

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

        \[\leadsto \left(x \cdot y + \left(\color{blue}{\frac{z \cdot t}{16}} + \frac{a \cdot b}{-4}\right)\right) + c \]
      4. add-sqr-sqrt58.8%

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

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

        \[\leadsto \left(x \cdot y + \left(\frac{z \cdot t}{16} + \sqrt{\color{blue}{\frac{\left(a \cdot b\right) \cdot \left(a \cdot b\right)}{-4 \cdot -4}}}\right)\right) + c \]
      7. metadata-eval96.5%

        \[\leadsto \left(x \cdot y + \left(\frac{z \cdot t}{16} + \sqrt{\frac{\left(a \cdot b\right) \cdot \left(a \cdot b\right)}{\color{blue}{16}}}\right)\right) + c \]
      8. metadata-eval96.5%

        \[\leadsto \left(x \cdot y + \left(\frac{z \cdot t}{16} + \sqrt{\frac{\left(a \cdot b\right) \cdot \left(a \cdot b\right)}{\color{blue}{4 \cdot 4}}}\right)\right) + c \]
      9. frac-times96.5%

        \[\leadsto \left(x \cdot y + \left(\frac{z \cdot t}{16} + \sqrt{\color{blue}{\frac{a \cdot b}{4} \cdot \frac{a \cdot b}{4}}}\right)\right) + c \]
      10. sqrt-unprod57.7%

        \[\leadsto \left(x \cdot y + \left(\frac{z \cdot t}{16} + \color{blue}{\sqrt{\frac{a \cdot b}{4}} \cdot \sqrt{\frac{a \cdot b}{4}}}\right)\right) + c \]
      11. add-sqr-sqrt94.5%

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

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

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

        \[\leadsto \color{blue}{\left(\frac{z \cdot t}{16} + \left(x \cdot y + \frac{a \cdot b}{4}\right)\right)} + c \]
      15. associate-*r/95.0%

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

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

        \[\leadsto \left(z \cdot \left(t \cdot \color{blue}{0.0625}\right) + \left(x \cdot y + \frac{a \cdot b}{4}\right)\right) + c \]
      18. div-inv95.0%

        \[\leadsto \left(z \cdot \left(t \cdot 0.0625\right) + \left(x \cdot y + \color{blue}{\left(a \cdot b\right) \cdot \frac{1}{4}}\right)\right) + c \]
      19. associate-*r*95.0%

        \[\leadsto \left(z \cdot \left(t \cdot 0.0625\right) + \left(x \cdot y + \color{blue}{a \cdot \left(b \cdot \frac{1}{4}\right)}\right)\right) + c \]
    6. Applied egg-rr95.0%

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

    if 1.9999999999999999e107 < (*.f64 a b)

    1. Initial program 94.0%

      \[\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-94.0%

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

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

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

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

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

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

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

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

        \[\leadsto \left(\mathsf{fma}\left(x, y, z \cdot \frac{t}{16}\right) - \color{blue}{a \cdot \frac{b}{4}}\right) + c \]
    3. Simplified94.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. Taylor expanded in x around inf 90.6%

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

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

Alternative 5: 89.7% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \cdot b \leq -4 \cdot 10^{+90} \lor \neg \left(a \cdot b \leq 2 \cdot 10^{+107}\right):\\ \;\;\;\;c + \left(x \cdot y - a \cdot \frac{b}{4}\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) -4e+90) (not (<= (* a b) 2e+107)))
   (+ c (- (* x y) (* a (/ b 4.0))))
   (+ 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) <= -4e+90) || !((a * b) <= 2e+107)) {
		tmp = c + ((x * y) - (a * (b / 4.0)));
	} 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) <= (-4d+90)) .or. (.not. ((a * b) <= 2d+107))) then
        tmp = c + ((x * y) - (a * (b / 4.0d0)))
    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) <= -4e+90) || !((a * b) <= 2e+107)) {
		tmp = c + ((x * y) - (a * (b / 4.0)));
	} 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) <= -4e+90) or not ((a * b) <= 2e+107):
		tmp = c + ((x * y) - (a * (b / 4.0)))
	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) <= -4e+90) || !(Float64(a * b) <= 2e+107))
		tmp = Float64(c + Float64(Float64(x * y) - Float64(a * Float64(b / 4.0))));
	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) <= -4e+90) || ~(((a * b) <= 2e+107)))
		tmp = c + ((x * y) - (a * (b / 4.0)));
	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], -4e+90], N[Not[LessEqual[N[(a * b), $MachinePrecision], 2e+107]], $MachinePrecision]], N[(c + N[(N[(x * y), $MachinePrecision] - N[(a * N[(b / 4.0), $MachinePrecision]), $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 -4 \cdot 10^{+90} \lor \neg \left(a \cdot b \leq 2 \cdot 10^{+107}\right):\\
\;\;\;\;c + \left(x \cdot y - a \cdot \frac{b}{4}\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) < -3.99999999999999987e90 or 1.9999999999999999e107 < (*.f64 a b)

    1. Initial program 96.2%

      \[\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-96.2%

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

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

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

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

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

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

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

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

        \[\leadsto \left(\mathsf{fma}\left(x, y, z \cdot \frac{t}{16}\right) - \color{blue}{a \cdot \frac{b}{4}}\right) + c \]
    3. Simplified97.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. Taylor expanded in x around inf 90.5%

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

    if -3.99999999999999987e90 < (*.f64 a b) < 1.9999999999999999e107

    1. Initial program 98.8%

      \[\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 b around inf 79.0%

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

      \[\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 simplification93.5%

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

Alternative 6: 89.6% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \left(z \cdot t\right) \cdot 0.0625\\ \mathbf{if}\;a \cdot b \leq -5 \cdot 10^{+146}:\\ \;\;\;\;c + b \cdot \left(\frac{t\_1}{b} - a \cdot 0.25\right)\\ \mathbf{elif}\;a \cdot b \leq 2 \cdot 10^{+107}:\\ \;\;\;\;c + \left(x \cdot y + t\_1\right)\\ \mathbf{else}:\\ \;\;\;\;c + \left(x \cdot y - a \cdot \frac{b}{4}\right)\\ \end{array} \end{array} \]
(FPCore (x y z t a b c)
 :precision binary64
 (let* ((t_1 (* (* z t) 0.0625)))
   (if (<= (* a b) -5e+146)
     (+ c (* b (- (/ t_1 b) (* a 0.25))))
     (if (<= (* a b) 2e+107)
       (+ c (+ (* x y) t_1))
       (+ c (- (* x y) (* a (/ b 4.0))))))))
double code(double x, double y, double z, double t, double a, double b, double c) {
	double t_1 = (z * t) * 0.0625;
	double tmp;
	if ((a * b) <= -5e+146) {
		tmp = c + (b * ((t_1 / b) - (a * 0.25)));
	} else if ((a * b) <= 2e+107) {
		tmp = c + ((x * y) + t_1);
	} else {
		tmp = c + ((x * y) - (a * (b / 4.0)));
	}
	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) :: tmp
    t_1 = (z * t) * 0.0625d0
    if ((a * b) <= (-5d+146)) then
        tmp = c + (b * ((t_1 / b) - (a * 0.25d0)))
    else if ((a * b) <= 2d+107) then
        tmp = c + ((x * y) + t_1)
    else
        tmp = c + ((x * y) - (a * (b / 4.0d0)))
    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 tmp;
	if ((a * b) <= -5e+146) {
		tmp = c + (b * ((t_1 / b) - (a * 0.25)));
	} else if ((a * b) <= 2e+107) {
		tmp = c + ((x * y) + t_1);
	} else {
		tmp = c + ((x * y) - (a * (b / 4.0)));
	}
	return tmp;
}
def code(x, y, z, t, a, b, c):
	t_1 = (z * t) * 0.0625
	tmp = 0
	if (a * b) <= -5e+146:
		tmp = c + (b * ((t_1 / b) - (a * 0.25)))
	elif (a * b) <= 2e+107:
		tmp = c + ((x * y) + t_1)
	else:
		tmp = c + ((x * y) - (a * (b / 4.0)))
	return tmp
function code(x, y, z, t, a, b, c)
	t_1 = Float64(Float64(z * t) * 0.0625)
	tmp = 0.0
	if (Float64(a * b) <= -5e+146)
		tmp = Float64(c + Float64(b * Float64(Float64(t_1 / b) - Float64(a * 0.25))));
	elseif (Float64(a * b) <= 2e+107)
		tmp = Float64(c + Float64(Float64(x * y) + t_1));
	else
		tmp = Float64(c + Float64(Float64(x * y) - Float64(a * Float64(b / 4.0))));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a, b, c)
	t_1 = (z * t) * 0.0625;
	tmp = 0.0;
	if ((a * b) <= -5e+146)
		tmp = c + (b * ((t_1 / b) - (a * 0.25)));
	elseif ((a * b) <= 2e+107)
		tmp = c + ((x * y) + t_1);
	else
		tmp = c + ((x * y) - (a * (b / 4.0)));
	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]}, If[LessEqual[N[(a * b), $MachinePrecision], -5e+146], N[(c + N[(b * N[(N[(t$95$1 / b), $MachinePrecision] - N[(a * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 2e+107], N[(c + N[(N[(x * y), $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision], N[(c + N[(N[(x * y), $MachinePrecision] - N[(a * N[(b / 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

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

\mathbf{elif}\;a \cdot b \leq 2 \cdot 10^{+107}:\\
\;\;\;\;c + \left(x \cdot y + t\_1\right)\\

\mathbf{else}:\\
\;\;\;\;c + \left(x \cdot y - a \cdot \frac{b}{4}\right)\\


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

    1. Initial program 97.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 b around inf 100.0%

      \[\leadsto \color{blue}{b \cdot \left(\left(0.0625 \cdot \frac{t \cdot z}{b} + \frac{x \cdot y}{b}\right) - 0.25 \cdot a\right)} + c \]
    4. Taylor expanded in t around inf 97.2%

      \[\leadsto b \cdot \left(\color{blue}{0.0625 \cdot \frac{t \cdot z}{b}} - 0.25 \cdot a\right) + c \]
    5. Step-by-step derivation
      1. associate-*r/97.2%

        \[\leadsto b \cdot \left(\color{blue}{\frac{0.0625 \cdot \left(t \cdot z\right)}{b}} - 0.25 \cdot a\right) + c \]
    6. Simplified97.2%

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

    if -4.9999999999999999e146 < (*.f64 a b) < 1.9999999999999999e107

    1. Initial program 98.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 b around inf 80.0%

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

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

    if 1.9999999999999999e107 < (*.f64 a b)

    1. Initial program 94.0%

      \[\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-94.0%

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

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

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

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

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

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

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

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

        \[\leadsto \left(\mathsf{fma}\left(x, y, z \cdot \frac{t}{16}\right) - \color{blue}{a \cdot \frac{b}{4}}\right) + c \]
    3. Simplified94.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. Taylor expanded in x around inf 90.6%

      \[\leadsto \left(\color{blue}{x \cdot y} - a \cdot \frac{b}{4}\right) + c \]
  3. Recombined 3 regimes into one program.
  4. Final simplification93.9%

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

Alternative 7: 89.4% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \left(z \cdot t\right) \cdot 0.0625\\ \mathbf{if}\;a \cdot b \leq -5 \cdot 10^{+146}:\\ \;\;\;\;c + \left(t\_1 - \left(a \cdot b\right) \cdot 0.25\right)\\ \mathbf{elif}\;a \cdot b \leq 2 \cdot 10^{+107}:\\ \;\;\;\;c + \left(x \cdot y + t\_1\right)\\ \mathbf{else}:\\ \;\;\;\;c + \left(x \cdot y - a \cdot \frac{b}{4}\right)\\ \end{array} \end{array} \]
(FPCore (x y z t a b c)
 :precision binary64
 (let* ((t_1 (* (* z t) 0.0625)))
   (if (<= (* a b) -5e+146)
     (+ c (- t_1 (* (* a b) 0.25)))
     (if (<= (* a b) 2e+107)
       (+ c (+ (* x y) t_1))
       (+ c (- (* x y) (* a (/ b 4.0))))))))
double code(double x, double y, double z, double t, double a, double b, double c) {
	double t_1 = (z * t) * 0.0625;
	double tmp;
	if ((a * b) <= -5e+146) {
		tmp = c + (t_1 - ((a * b) * 0.25));
	} else if ((a * b) <= 2e+107) {
		tmp = c + ((x * y) + t_1);
	} else {
		tmp = c + ((x * y) - (a * (b / 4.0)));
	}
	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) :: tmp
    t_1 = (z * t) * 0.0625d0
    if ((a * b) <= (-5d+146)) then
        tmp = c + (t_1 - ((a * b) * 0.25d0))
    else if ((a * b) <= 2d+107) then
        tmp = c + ((x * y) + t_1)
    else
        tmp = c + ((x * y) - (a * (b / 4.0d0)))
    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 tmp;
	if ((a * b) <= -5e+146) {
		tmp = c + (t_1 - ((a * b) * 0.25));
	} else if ((a * b) <= 2e+107) {
		tmp = c + ((x * y) + t_1);
	} else {
		tmp = c + ((x * y) - (a * (b / 4.0)));
	}
	return tmp;
}
def code(x, y, z, t, a, b, c):
	t_1 = (z * t) * 0.0625
	tmp = 0
	if (a * b) <= -5e+146:
		tmp = c + (t_1 - ((a * b) * 0.25))
	elif (a * b) <= 2e+107:
		tmp = c + ((x * y) + t_1)
	else:
		tmp = c + ((x * y) - (a * (b / 4.0)))
	return tmp
function code(x, y, z, t, a, b, c)
	t_1 = Float64(Float64(z * t) * 0.0625)
	tmp = 0.0
	if (Float64(a * b) <= -5e+146)
		tmp = Float64(c + Float64(t_1 - Float64(Float64(a * b) * 0.25)));
	elseif (Float64(a * b) <= 2e+107)
		tmp = Float64(c + Float64(Float64(x * y) + t_1));
	else
		tmp = Float64(c + Float64(Float64(x * y) - Float64(a * Float64(b / 4.0))));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a, b, c)
	t_1 = (z * t) * 0.0625;
	tmp = 0.0;
	if ((a * b) <= -5e+146)
		tmp = c + (t_1 - ((a * b) * 0.25));
	elseif ((a * b) <= 2e+107)
		tmp = c + ((x * y) + t_1);
	else
		tmp = c + ((x * y) - (a * (b / 4.0)));
	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]}, If[LessEqual[N[(a * b), $MachinePrecision], -5e+146], N[(c + N[(t$95$1 - N[(N[(a * b), $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 2e+107], N[(c + N[(N[(x * y), $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision], N[(c + N[(N[(x * y), $MachinePrecision] - N[(a * N[(b / 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

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

\mathbf{elif}\;a \cdot b \leq 2 \cdot 10^{+107}:\\
\;\;\;\;c + \left(x \cdot y + t\_1\right)\\

\mathbf{else}:\\
\;\;\;\;c + \left(x \cdot y - a \cdot \frac{b}{4}\right)\\


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

    1. Initial program 97.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 x around 0 95.2%

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

    if -4.9999999999999999e146 < (*.f64 a b) < 1.9999999999999999e107

    1. Initial program 98.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 b around inf 80.0%

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

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

    if 1.9999999999999999e107 < (*.f64 a b)

    1. Initial program 94.0%

      \[\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-94.0%

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

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

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

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

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

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

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

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

        \[\leadsto \left(\mathsf{fma}\left(x, y, z \cdot \frac{t}{16}\right) - \color{blue}{a \cdot \frac{b}{4}}\right) + c \]
    3. Simplified94.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. Taylor expanded in x around inf 90.6%

      \[\leadsto \left(\color{blue}{x \cdot y} - a \cdot \frac{b}{4}\right) + c \]
  3. Recombined 3 regimes into one program.
  4. Final simplification93.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \cdot b \leq -5 \cdot 10^{+146}:\\ \;\;\;\;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 2 \cdot 10^{+107}:\\ \;\;\;\;c + \left(x \cdot y + \left(z \cdot t\right) \cdot 0.0625\right)\\ \mathbf{else}:\\ \;\;\;\;c + \left(x \cdot y - a \cdot \frac{b}{4}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 74.8% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \leq -3 \cdot 10^{+189} \lor \neg \left(a \leq 4.6 \cdot 10^{-70}\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 (<= a -3e+189) (not (<= a 4.6e-70)))
   (+ 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 ((a <= -3e+189) || !(a <= 4.6e-70)) {
		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 ((a <= (-3d+189)) .or. (.not. (a <= 4.6d-70))) 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 ((a <= -3e+189) || !(a <= 4.6e-70)) {
		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 (a <= -3e+189) or not (a <= 4.6e-70):
		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 ((a <= -3e+189) || !(a <= 4.6e-70))
		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 ((a <= -3e+189) || ~((a <= 4.6e-70)))
		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[a, -3e+189], N[Not[LessEqual[a, 4.6e-70]], $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}\;a \leq -3 \cdot 10^{+189} \lor \neg \left(a \leq 4.6 \cdot 10^{-70}\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 a < -2.9999999999999998e189 or 4.60000000000000001e-70 < a

    1. Initial program 96.5%

      \[\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+96.5%

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

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

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

        \[\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-frac297.3%

        \[\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-eval97.3%

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

      \[\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. Taylor expanded in a around inf 69.2%

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

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

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

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

    if -2.9999999999999998e189 < a < 4.60000000000000001e-70

    1. Initial program 98.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 b around inf 86.3%

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

      \[\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 simplification78.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -3 \cdot 10^{+189} \lor \neg \left(a \leq 4.6 \cdot 10^{-70}\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: 65.9% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \cdot y \leq -2.6 \cdot 10^{+121} \lor \neg \left(x \cdot y \leq 6.4 \cdot 10^{+128}\right):\\ \;\;\;\;c + x \cdot y\\ \mathbf{else}:\\ \;\;\;\;c + z \cdot \left(t \cdot 0.0625\right)\\ \end{array} \end{array} \]
(FPCore (x y z t a b c)
 :precision binary64
 (if (or (<= (* x y) -2.6e+121) (not (<= (* x y) 6.4e+128)))
   (+ c (* x y))
   (+ c (* 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) <= -2.6e+121) || !((x * y) <= 6.4e+128)) {
		tmp = c + (x * y);
	} else {
		tmp = c + (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) <= (-2.6d+121)) .or. (.not. ((x * y) <= 6.4d+128))) then
        tmp = c + (x * y)
    else
        tmp = c + (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) <= -2.6e+121) || !((x * y) <= 6.4e+128)) {
		tmp = c + (x * y);
	} else {
		tmp = c + (z * (t * 0.0625));
	}
	return tmp;
}
def code(x, y, z, t, a, b, c):
	tmp = 0
	if ((x * y) <= -2.6e+121) or not ((x * y) <= 6.4e+128):
		tmp = c + (x * y)
	else:
		tmp = c + (z * (t * 0.0625))
	return tmp
function code(x, y, z, t, a, b, c)
	tmp = 0.0
	if ((Float64(x * y) <= -2.6e+121) || !(Float64(x * y) <= 6.4e+128))
		tmp = Float64(c + Float64(x * y));
	else
		tmp = Float64(c + Float64(z * Float64(t * 0.0625)));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a, b, c)
	tmp = 0.0;
	if (((x * y) <= -2.6e+121) || ~(((x * y) <= 6.4e+128)))
		tmp = c + (x * y);
	else
		tmp = c + (z * (t * 0.0625));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_, c_] := If[Or[LessEqual[N[(x * y), $MachinePrecision], -2.6e+121], N[Not[LessEqual[N[(x * y), $MachinePrecision], 6.4e+128]], $MachinePrecision]], N[(c + N[(x * y), $MachinePrecision]), $MachinePrecision], N[(c + N[(z * N[(t * 0.0625), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -2.6 \cdot 10^{+121} \lor \neg \left(x \cdot y \leq 6.4 \cdot 10^{+128}\right):\\
\;\;\;\;c + x \cdot y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 x y) < -2.5999999999999999e121 or 6.39999999999999971e128 < (*.f64 x y)

    1. Initial program 95.1%

      \[\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-95.1%

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

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

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

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

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

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

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

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

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

      \[\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. Taylor expanded in x around inf 86.9%

      \[\leadsto \left(\color{blue}{x \cdot y} - a \cdot \frac{b}{4}\right) + c \]
    6. Taylor expanded in x around inf 75.9%

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

    if -2.5999999999999999e121 < (*.f64 x y) < 6.39999999999999971e128

    1. Initial program 99.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 0 94.0%

      \[\leadsto \color{blue}{\left(0.0625 \cdot \left(t \cdot z\right) - 0.25 \cdot \left(a \cdot b\right)\right)} + c \]
    4. Taylor expanded in a around 0 61.9%

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

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

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

        \[\leadsto c + \color{blue}{z \cdot \left(t \cdot 0.0625\right)} \]
      4. *-commutative61.9%

        \[\leadsto c + z \cdot \color{blue}{\left(0.0625 \cdot t\right)} \]
    6. Simplified61.9%

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

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

Alternative 10: 40.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \cdot y \leq -2.3 \cdot 10^{+23} \lor \neg \left(x \cdot y \leq 2 \cdot 10^{+208}\right):\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \end{array} \]
(FPCore (x y z t a b c)
 :precision binary64
 (if (or (<= (* x y) -2.3e+23) (not (<= (* x y) 2e+208))) (* x y) c))
double code(double x, double y, double z, double t, double a, double b, double c) {
	double tmp;
	if (((x * y) <= -2.3e+23) || !((x * y) <= 2e+208)) {
		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 (((x * y) <= (-2.3d+23)) .or. (.not. ((x * y) <= 2d+208))) 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 (((x * y) <= -2.3e+23) || !((x * y) <= 2e+208)) {
		tmp = x * y;
	} else {
		tmp = c;
	}
	return tmp;
}
def code(x, y, z, t, a, b, c):
	tmp = 0
	if ((x * y) <= -2.3e+23) or not ((x * y) <= 2e+208):
		tmp = x * y
	else:
		tmp = c
	return tmp
function code(x, y, z, t, a, b, c)
	tmp = 0.0
	if ((Float64(x * y) <= -2.3e+23) || !(Float64(x * y) <= 2e+208))
		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 (((x * y) <= -2.3e+23) || ~(((x * y) <= 2e+208)))
		tmp = x * y;
	else
		tmp = c;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_, c_] := If[Or[LessEqual[N[(x * y), $MachinePrecision], -2.3e+23], N[Not[LessEqual[N[(x * y), $MachinePrecision], 2e+208]], $MachinePrecision]], N[(x * y), $MachinePrecision], c]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -2.3 \cdot 10^{+23} \lor \neg \left(x \cdot y \leq 2 \cdot 10^{+208}\right):\\
\;\;\;\;x \cdot y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 x y) < -2.3e23 or 2e208 < (*.f64 x y)

    1. Initial program 95.2%

      \[\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-95.2%

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

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

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

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

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

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

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

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

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

      \[\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. Taylor expanded in x around inf 82.4%

      \[\leadsto \left(\color{blue}{x \cdot y} - a \cdot \frac{b}{4}\right) + c \]
    6. Taylor expanded in x around inf 70.5%

      \[\leadsto \color{blue}{x \cdot y} + c \]
    7. Taylor expanded in x around inf 64.7%

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

    if -2.3e23 < (*.f64 x y) < 2e208

    1. Initial program 99.0%

      \[\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+99.0%

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

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

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

        \[\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.0%

        \[\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.0%

        \[\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.0%

      \[\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. Taylor expanded in a around inf 69.8%

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

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

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

      \[\leadsto \color{blue}{a \cdot \left(b \cdot -0.25\right)} + c \]
    8. Taylor expanded in a around 0 37.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y \leq -2.3 \cdot 10^{+23} \lor \neg \left(x \cdot y \leq 2 \cdot 10^{+208}\right):\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 97.8% accurate, 1.0× speedup?

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

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

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

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

Alternative 12: 54.3% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -3000000000 \lor \neg \left(b \leq 6.2 \cdot 10^{+151}\right):\\ \;\;\;\;b \cdot \left(a \cdot -0.25\right)\\ \mathbf{else}:\\ \;\;\;\;c + x \cdot y\\ \end{array} \end{array} \]
(FPCore (x y z t a b c)
 :precision binary64
 (if (or (<= b -3000000000.0) (not (<= b 6.2e+151)))
   (* b (* a -0.25))
   (+ c (* x y))))
double code(double x, double y, double z, double t, double a, double b, double c) {
	double tmp;
	if ((b <= -3000000000.0) || !(b <= 6.2e+151)) {
		tmp = b * (a * -0.25);
	} 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 ((b <= (-3000000000.0d0)) .or. (.not. (b <= 6.2d+151))) then
        tmp = b * (a * (-0.25d0))
    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 ((b <= -3000000000.0) || !(b <= 6.2e+151)) {
		tmp = b * (a * -0.25);
	} else {
		tmp = c + (x * y);
	}
	return tmp;
}
def code(x, y, z, t, a, b, c):
	tmp = 0
	if (b <= -3000000000.0) or not (b <= 6.2e+151):
		tmp = b * (a * -0.25)
	else:
		tmp = c + (x * y)
	return tmp
function code(x, y, z, t, a, b, c)
	tmp = 0.0
	if ((b <= -3000000000.0) || !(b <= 6.2e+151))
		tmp = Float64(b * Float64(a * -0.25));
	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 ((b <= -3000000000.0) || ~((b <= 6.2e+151)))
		tmp = b * (a * -0.25);
	else
		tmp = c + (x * y);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_, c_] := If[Or[LessEqual[b, -3000000000.0], N[Not[LessEqual[b, 6.2e+151]], $MachinePrecision]], N[(b * N[(a * -0.25), $MachinePrecision]), $MachinePrecision], N[(c + N[(x * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \leq -3000000000 \lor \neg \left(b \leq 6.2 \cdot 10^{+151}\right):\\
\;\;\;\;b \cdot \left(a \cdot -0.25\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < -3e9 or 6.2000000000000004e151 < b

    1. Initial program 97.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 b around inf 99.0%

      \[\leadsto \color{blue}{b \cdot \left(\left(0.0625 \cdot \frac{t \cdot z}{b} + \frac{x \cdot y}{b}\right) - 0.25 \cdot a\right)} + c \]
    4. Taylor expanded in t around inf 80.9%

      \[\leadsto b \cdot \left(\color{blue}{0.0625 \cdot \frac{t \cdot z}{b}} - 0.25 \cdot a\right) + c \]
    5. Step-by-step derivation
      1. associate-*r/80.9%

        \[\leadsto b \cdot \left(\color{blue}{\frac{0.0625 \cdot \left(t \cdot z\right)}{b}} - 0.25 \cdot a\right) + c \]
    6. Simplified80.9%

      \[\leadsto b \cdot \left(\color{blue}{\frac{0.0625 \cdot \left(t \cdot z\right)}{b}} - 0.25 \cdot a\right) + c \]
    7. Taylor expanded in c around 0 66.8%

      \[\leadsto \color{blue}{b \cdot \left(0.0625 \cdot \frac{t \cdot z}{b} - 0.25 \cdot a\right)} \]
    8. Taylor expanded in t around 0 47.4%

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

    if -3e9 < b < 6.2000000000000004e151

    1. Initial program 98.2%

      \[\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-98.2%

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

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

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

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

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

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

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

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

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

      \[\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. Taylor expanded in x around inf 74.2%

      \[\leadsto \left(\color{blue}{x \cdot y} - a \cdot \frac{b}{4}\right) + c \]
    6. Taylor expanded in x around inf 58.7%

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

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

Alternative 13: 22.5% 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.8%

    \[\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.8%

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

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

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

      \[\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-frac298.5%

      \[\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-eval98.5%

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

    \[\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. Taylor expanded in a around inf 55.2%

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

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

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

    \[\leadsto \color{blue}{a \cdot \left(b \cdot -0.25\right)} + c \]
  8. Taylor expanded in a around 0 28.0%

    \[\leadsto \color{blue}{c} \]
  9. Add Preprocessing

Reproduce

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