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

Percentage Accurate: 97.5% → 97.5%
Time: 2.3s
Alternatives: 10
Speedup: 1.0×

Specification

?
\[\mathsf{TRUE}\left(\right)\]
\[\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 10 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.5% 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: 97.5% 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}
Derivation
  1. Initial program 99.2%

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

Alternative 2: 87.9% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
t_1 := \frac{a \cdot b}{4}\\
t_2 := x \cdot y + \frac{z \cdot t}{16}\\
\mathbf{if}\;z \cdot t \leq -2.25 \cdot 10^{-82}:\\
\;\;\;\;t\_2 + c\\

\mathbf{elif}\;z \cdot t \leq 1.4 \cdot 10^{+75}:\\
\;\;\;\;\left(x \cdot y + c\right) - t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 z t) < -2.2499999999999999e-82

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

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

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

    if -2.2499999999999999e-82 < (*.f64 z t) < 1.40000000000000006e75

    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

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

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

      \[\leadsto \frac{1}{16} \cdot \left(t \cdot z\right) - \frac{\color{blue}{a \cdot b}}{4} \]
    6. Applied rewrites96.3%

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

    if 1.40000000000000006e75 < (*.f64 z t)

    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 0

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

      \[\leadsto \color{blue}{\left(x \cdot y + \frac{z \cdot t}{16}\right) - \frac{a \cdot b}{4}} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 3: 66.7% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x \cdot y + \frac{z \cdot t}{16}\\ \mathbf{if}\;z \cdot t \leq -2.25 \cdot 10^{-82}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \cdot t \leq 1.55 \cdot 10^{-8}:\\ \;\;\;\;x \cdot y - \frac{a \cdot b}{4}\\ \mathbf{elif}\;z \cdot t \leq 2 \cdot 10^{+75}:\\ \;\;\;\;x \cdot y + c\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t a b c)
 :precision binary64
 (let* ((t_1 (+ (* x y) (/ (* z t) 16.0))))
   (if (<= (* z t) -2.25e-82)
     t_1
     (if (<= (* z t) 1.55e-8)
       (- (* x y) (/ (* a b) 4.0))
       (if (<= (* z t) 2e+75) (+ (* x y) c) t_1)))))
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);
	double tmp;
	if ((z * t) <= -2.25e-82) {
		tmp = t_1;
	} else if ((z * t) <= 1.55e-8) {
		tmp = (x * y) - ((a * b) / 4.0);
	} else if ((z * t) <= 2e+75) {
		tmp = (x * y) + c;
	} else {
		tmp = 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) :: tmp
    t_1 = (x * y) + ((z * t) / 16.0d0)
    if ((z * t) <= (-2.25d-82)) then
        tmp = t_1
    else if ((z * t) <= 1.55d-8) then
        tmp = (x * y) - ((a * b) / 4.0d0)
    else if ((z * t) <= 2d+75) then
        tmp = (x * y) + c
    else
        tmp = 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 = (x * y) + ((z * t) / 16.0);
	double tmp;
	if ((z * t) <= -2.25e-82) {
		tmp = t_1;
	} else if ((z * t) <= 1.55e-8) {
		tmp = (x * y) - ((a * b) / 4.0);
	} else if ((z * t) <= 2e+75) {
		tmp = (x * y) + c;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t, a, b, c):
	t_1 = (x * y) + ((z * t) / 16.0)
	tmp = 0
	if (z * t) <= -2.25e-82:
		tmp = t_1
	elif (z * t) <= 1.55e-8:
		tmp = (x * y) - ((a * b) / 4.0)
	elif (z * t) <= 2e+75:
		tmp = (x * y) + c
	else:
		tmp = t_1
	return tmp
function code(x, y, z, t, a, b, c)
	t_1 = Float64(Float64(x * y) + Float64(Float64(z * t) / 16.0))
	tmp = 0.0
	if (Float64(z * t) <= -2.25e-82)
		tmp = t_1;
	elseif (Float64(z * t) <= 1.55e-8)
		tmp = Float64(Float64(x * y) - Float64(Float64(a * b) / 4.0));
	elseif (Float64(z * t) <= 2e+75)
		tmp = Float64(Float64(x * y) + c);
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a, b, c)
	t_1 = (x * y) + ((z * t) / 16.0);
	tmp = 0.0;
	if ((z * t) <= -2.25e-82)
		tmp = t_1;
	elseif ((z * t) <= 1.55e-8)
		tmp = (x * y) - ((a * b) / 4.0);
	elseif ((z * t) <= 2e+75)
		tmp = (x * y) + c;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_, c_] := Block[{t$95$1 = N[(N[(x * y), $MachinePrecision] + N[(N[(z * t), $MachinePrecision] / 16.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(z * t), $MachinePrecision], -2.25e-82], t$95$1, If[LessEqual[N[(z * t), $MachinePrecision], 1.55e-8], N[(N[(x * y), $MachinePrecision] - N[(N[(a * b), $MachinePrecision] / 4.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 2e+75], N[(N[(x * y), $MachinePrecision] + c), $MachinePrecision], t$95$1]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := x \cdot y + \frac{z \cdot t}{16}\\
\mathbf{if}\;z \cdot t \leq -2.25 \cdot 10^{-82}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;z \cdot t \leq 1.55 \cdot 10^{-8}:\\
\;\;\;\;x \cdot y - \frac{a \cdot b}{4}\\

\mathbf{elif}\;z \cdot t \leq 2 \cdot 10^{+75}:\\
\;\;\;\;x \cdot y + c\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 z t) < -2.2499999999999999e-82 or 1.99999999999999985e75 < (*.f64 z t)

    1. Initial program 98.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 0

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

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

      \[\leadsto \frac{1}{16} \cdot \left(t \cdot z\right) - \color{blue}{\frac{1}{4} \cdot \left(a \cdot b\right)} \]
    6. Applied rewrites78.1%

      \[\leadsto x \cdot y + \color{blue}{\frac{z \cdot t}{16}} \]

    if -2.2499999999999999e-82 < (*.f64 z t) < 1.55e-8

    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

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

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

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

      \[\leadsto x \cdot y - \frac{\color{blue}{a \cdot b}}{4} \]

    if 1.55e-8 < (*.f64 z t) < 1.99999999999999985e75

    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

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

      \[\leadsto \color{blue}{x \cdot y} + c \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 4: 87.0% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
t_1 := \left(x \cdot y + \frac{z \cdot t}{16}\right) + c\\
\mathbf{if}\;z \cdot t \leq -2.25 \cdot 10^{-82}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;z \cdot t \leq 2.55 \cdot 10^{+31}:\\
\;\;\;\;\left(x \cdot y + c\right) - \frac{a \cdot b}{4}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 z t) < -2.2499999999999999e-82 or 2.5499999999999998e31 < (*.f64 z t)

    1. Initial program 98.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 0

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

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

    if -2.2499999999999999e-82 < (*.f64 z t) < 2.5499999999999998e31

    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

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

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

      \[\leadsto \frac{1}{16} \cdot \left(t \cdot z\right) - \frac{\color{blue}{a \cdot b}}{4} \]
    6. Applied rewrites97.4%

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

Alternative 5: 86.0% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
t_1 := x \cdot y + \frac{z \cdot t}{16}\\
\mathbf{if}\;z \cdot t \leq -3.7 \cdot 10^{+211}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;z \cdot t \leq 3.8 \cdot 10^{+77}:\\
\;\;\;\;\left(x \cdot y + c\right) - \frac{a \cdot b}{4}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 z t) < -3.7000000000000001e211 or 3.8000000000000001e77 < (*.f64 z t)

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

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

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

      \[\leadsto \frac{1}{16} \cdot \left(t \cdot z\right) - \color{blue}{\frac{1}{4} \cdot \left(a \cdot b\right)} \]
    6. Applied rewrites88.0%

      \[\leadsto x \cdot y + \color{blue}{\frac{z \cdot t}{16}} \]

    if -3.7000000000000001e211 < (*.f64 z t) < 3.8000000000000001e77

    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

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

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

      \[\leadsto \frac{1}{16} \cdot \left(t \cdot z\right) - \frac{\color{blue}{a \cdot b}}{4} \]
    6. Applied rewrites90.8%

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

Alternative 6: 64.9% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
t_1 := x \cdot y + \frac{z \cdot t}{16}\\
\mathbf{if}\;z \cdot t \leq -1.12 \cdot 10^{-111}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;z \cdot t \leq 2 \cdot 10^{+75}:\\
\;\;\;\;x \cdot y + c\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 z t) < -1.12000000000000009e-111 or 1.99999999999999985e75 < (*.f64 z t)

    1. Initial program 98.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 0

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

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

      \[\leadsto \frac{1}{16} \cdot \left(t \cdot z\right) - \color{blue}{\frac{1}{4} \cdot \left(a \cdot b\right)} \]
    6. Applied rewrites76.7%

      \[\leadsto x \cdot y + \color{blue}{\frac{z \cdot t}{16}} \]

    if -1.12000000000000009e-111 < (*.f64 z t) < 1.99999999999999985e75

    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

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

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

Alternative 7: 39.8% accurate, 1.5× speedup?

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

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

\mathbf{elif}\;x \cdot y \leq 0.0092:\\
\;\;\;\;a \cdot b + c\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 x y) < -1.05999999999999994e-32 or 0.0091999999999999998 < (*.f64 x y)

    1. Initial program 98.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 0

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

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

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

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

    if -1.05999999999999994e-32 < (*.f64 x y) < 0.0091999999999999998

    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

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

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

      \[\leadsto \frac{1}{16} \cdot \color{blue}{\left(t \cdot z\right)} + c \]
    6. Applied rewrites9.3%

      \[\leadsto \left(x \cdot y + \color{blue}{c}\right) + c \]
    7. Taylor expanded in x around -inf

      \[\leadsto -1 \cdot \color{blue}{\left(x \cdot \left(-1 \cdot y + \frac{-1}{16} \cdot \frac{t \cdot z}{x}\right)\right)} + c \]
    8. Applied rewrites30.1%

      \[\leadsto a \cdot \color{blue}{b} + c \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 8: 48.4% accurate, 5.2× speedup?

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

\\
x \cdot y + c
\end{array}
Derivation
  1. Initial program 99.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 0

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

    \[\leadsto \color{blue}{x \cdot y} + c \]
  5. Add Preprocessing

Alternative 9: 28.1% accurate, 7.8× speedup?

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

\\
x \cdot y
\end{array}
Derivation
  1. Initial program 99.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 0

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

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

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

    \[\leadsto x \cdot \color{blue}{y} \]
  7. Add Preprocessing

Alternative 10: 2.7% accurate, 7.8× speedup?

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

\\
a \cdot b
\end{array}
Derivation
  1. Initial program 99.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 0

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

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

    \[\leadsto \frac{1}{16} \cdot \left(t \cdot z\right) - \frac{\color{blue}{a \cdot b}}{4} \]
  6. Applied rewrites73.3%

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

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

    \[\leadsto \frac{a \cdot b}{4} - \frac{\color{blue}{a \cdot b}}{4} \]
  9. Taylor expanded in y around inf

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

    \[\leadsto \color{blue}{a \cdot b} \]
  11. Add Preprocessing

Reproduce

?
herbie shell --seed 2024321 
(FPCore (x y z t a b c)
  :name "Diagrams.Solve.Polynomial:quartForm  from diagrams-solve-0.1, C"
  :precision binary64
  :pre (TRUE)
  (+ (- (+ (* x y) (/ (* z t) 16.0)) (/ (* a b) 4.0)) c))