Diagrams.Solve.Polynomial:cubForm from diagrams-solve-0.1, I

Percentage Accurate: 91.2% → 95.1%
Time: 4.3s
Alternatives: 10
Speedup: 0.5×

Specification

?
\[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2} \]
(FPCore (x y z t a)
 :precision binary64
 (/ (- (* x y) (* (* z 9.0) t)) (* a 2.0)))
double code(double x, double y, double z, double t, double a) {
	return ((x * y) - ((z * 9.0) * t)) / (a * 2.0);
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, y, z, t, a)
use fmin_fmax_functions
    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
    code = ((x * y) - ((z * 9.0d0) * t)) / (a * 2.0d0)
end function
public static double code(double x, double y, double z, double t, double a) {
	return ((x * y) - ((z * 9.0) * t)) / (a * 2.0);
}
def code(x, y, z, t, a):
	return ((x * y) - ((z * 9.0) * t)) / (a * 2.0)
function code(x, y, z, t, a)
	return Float64(Float64(Float64(x * y) - Float64(Float64(z * 9.0) * t)) / Float64(a * 2.0))
end
function tmp = code(x, y, z, t, a)
	tmp = ((x * y) - ((z * 9.0) * t)) / (a * 2.0);
end
code[x_, y_, z_, t_, a_] := N[(N[(N[(x * y), $MachinePrecision] - N[(N[(z * 9.0), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]
\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}

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: 91.2% accurate, 1.0× speedup?

\[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2} \]
(FPCore (x y z t a)
 :precision binary64
 (/ (- (* x y) (* (* z 9.0) t)) (* a 2.0)))
double code(double x, double y, double z, double t, double a) {
	return ((x * y) - ((z * 9.0) * t)) / (a * 2.0);
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, y, z, t, a)
use fmin_fmax_functions
    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
    code = ((x * y) - ((z * 9.0d0) * t)) / (a * 2.0d0)
end function
public static double code(double x, double y, double z, double t, double a) {
	return ((x * y) - ((z * 9.0) * t)) / (a * 2.0);
}
def code(x, y, z, t, a):
	return ((x * y) - ((z * 9.0) * t)) / (a * 2.0)
function code(x, y, z, t, a)
	return Float64(Float64(Float64(x * y) - Float64(Float64(z * 9.0) * t)) / Float64(a * 2.0))
end
function tmp = code(x, y, z, t, a)
	tmp = ((x * y) - ((z * 9.0) * t)) / (a * 2.0);
end
code[x_, y_, z_, t_, a_] := N[(N[(N[(x * y), $MachinePrecision] - N[(N[(z * 9.0), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]
\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}

Alternative 1: 95.1% accurate, 0.4× speedup?

\[\mathsf{copysign}\left(1, a\right) \cdot \begin{array}{l} \mathbf{if}\;\left|a\right| \leq 10^{+67}:\\ \;\;\;\;\frac{\mathsf{fma}\left(-9 \cdot \mathsf{min}\left(z, t\right), \mathsf{max}\left(z, t\right), \mathsf{max}\left(x, y\right) \cdot \mathsf{min}\left(x, y\right)\right)}{\left|a\right| \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-\mathsf{min}\left(z, t\right), 4.5 \cdot \frac{\mathsf{max}\left(z, t\right)}{\left|a\right|}, \frac{\mathsf{min}\left(x, y\right)}{\left|a\right| + \left|a\right|} \cdot \mathsf{max}\left(x, y\right)\right)\\ \end{array} \]
(FPCore (x y z t a)
 :precision binary64
 (*
  (copysign 1.0 a)
  (if (<= (fabs a) 1e+67)
    (/
     (fma (* -9.0 (fmin z t)) (fmax z t) (* (fmax x y) (fmin x y)))
     (* (fabs a) 2.0))
    (fma
     (- (fmin z t))
     (* 4.5 (/ (fmax z t) (fabs a)))
     (* (/ (fmin x y) (+ (fabs a) (fabs a))) (fmax x y))))))
double code(double x, double y, double z, double t, double a) {
	double tmp;
	if (fabs(a) <= 1e+67) {
		tmp = fma((-9.0 * fmin(z, t)), fmax(z, t), (fmax(x, y) * fmin(x, y))) / (fabs(a) * 2.0);
	} else {
		tmp = fma(-fmin(z, t), (4.5 * (fmax(z, t) / fabs(a))), ((fmin(x, y) / (fabs(a) + fabs(a))) * fmax(x, y)));
	}
	return copysign(1.0, a) * tmp;
}
function code(x, y, z, t, a)
	tmp = 0.0
	if (abs(a) <= 1e+67)
		tmp = Float64(fma(Float64(-9.0 * fmin(z, t)), fmax(z, t), Float64(fmax(x, y) * fmin(x, y))) / Float64(abs(a) * 2.0));
	else
		tmp = fma(Float64(-fmin(z, t)), Float64(4.5 * Float64(fmax(z, t) / abs(a))), Float64(Float64(fmin(x, y) / Float64(abs(a) + abs(a))) * fmax(x, y)));
	end
	return Float64(copysign(1.0, a) * tmp)
end
code[x_, y_, z_, t_, a_] := N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[Abs[a], $MachinePrecision], 1e+67], N[(N[(N[(-9.0 * N[Min[z, t], $MachinePrecision]), $MachinePrecision] * N[Max[z, t], $MachinePrecision] + N[(N[Max[x, y], $MachinePrecision] * N[Min[x, y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Abs[a], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision], N[((-N[Min[z, t], $MachinePrecision]) * N[(4.5 * N[(N[Max[z, t], $MachinePrecision] / N[Abs[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[Min[x, y], $MachinePrecision] / N[(N[Abs[a], $MachinePrecision] + N[Abs[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Max[x, y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\mathsf{copysign}\left(1, a\right) \cdot \begin{array}{l}
\mathbf{if}\;\left|a\right| \leq 10^{+67}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-9 \cdot \mathsf{min}\left(z, t\right), \mathsf{max}\left(z, t\right), \mathsf{max}\left(x, y\right) \cdot \mathsf{min}\left(x, y\right)\right)}{\left|a\right| \cdot 2}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-\mathsf{min}\left(z, t\right), 4.5 \cdot \frac{\mathsf{max}\left(z, t\right)}{\left|a\right|}, \frac{\mathsf{min}\left(x, y\right)}{\left|a\right| + \left|a\right|} \cdot \mathsf{max}\left(x, y\right)\right)\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < 9.9999999999999998e66

    1. Initial program 91.2%

      \[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2} \]
    2. Step-by-step derivation
      1. lift--.f64N/A

        \[\leadsto \frac{\color{blue}{x \cdot y - \left(z \cdot 9\right) \cdot t}}{a \cdot 2} \]
      2. sub-flipN/A

        \[\leadsto \frac{\color{blue}{x \cdot y + \left(\mathsf{neg}\left(\left(z \cdot 9\right) \cdot t\right)\right)}}{a \cdot 2} \]
      3. +-commutativeN/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(\left(z \cdot 9\right) \cdot t\right)\right) + x \cdot y}}{a \cdot 2} \]
      4. lift-*.f64N/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(\color{blue}{\left(z \cdot 9\right) \cdot t}\right)\right) + x \cdot y}{a \cdot 2} \]
      5. distribute-lft-neg-outN/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(z \cdot 9\right)\right) \cdot t} + x \cdot y}{a \cdot 2} \]
      6. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(z \cdot 9\right), t, x \cdot y\right)}}{a \cdot 2} \]
      7. lift-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\mathsf{neg}\left(\color{blue}{z \cdot 9}\right), t, x \cdot y\right)}{a \cdot 2} \]
      8. *-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(\mathsf{neg}\left(\color{blue}{9 \cdot z}\right), t, x \cdot y\right)}{a \cdot 2} \]
      9. distribute-lft-neg-inN/A

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{\left(\mathsf{neg}\left(9\right)\right) \cdot z}, t, x \cdot y\right)}{a \cdot 2} \]
      10. lower-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{\left(\mathsf{neg}\left(9\right)\right) \cdot z}, t, x \cdot y\right)}{a \cdot 2} \]
      11. metadata-eval91.5%

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{-9} \cdot z, t, x \cdot y\right)}{a \cdot 2} \]
      12. lift-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(-9 \cdot z, t, \color{blue}{x \cdot y}\right)}{a \cdot 2} \]
      13. *-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(-9 \cdot z, t, \color{blue}{y \cdot x}\right)}{a \cdot 2} \]
      14. lower-*.f6491.5%

        \[\leadsto \frac{\mathsf{fma}\left(-9 \cdot z, t, \color{blue}{y \cdot x}\right)}{a \cdot 2} \]
    3. Applied rewrites91.5%

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

    if 9.9999999999999998e66 < a

    1. Initial program 91.2%

      \[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2} \]
    2. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}} \]
      2. lift--.f64N/A

        \[\leadsto \frac{\color{blue}{x \cdot y - \left(z \cdot 9\right) \cdot t}}{a \cdot 2} \]
      3. div-subN/A

        \[\leadsto \color{blue}{\frac{x \cdot y}{a \cdot 2} - \frac{\left(z \cdot 9\right) \cdot t}{a \cdot 2}} \]
      4. sub-flipN/A

        \[\leadsto \color{blue}{\frac{x \cdot y}{a \cdot 2} + \left(\mathsf{neg}\left(\frac{\left(z \cdot 9\right) \cdot t}{a \cdot 2}\right)\right)} \]
      5. +-commutativeN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\frac{\left(z \cdot 9\right) \cdot t}{a \cdot 2}\right)\right) + \frac{x \cdot y}{a \cdot 2}} \]
      6. lift-*.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\frac{\color{blue}{\left(z \cdot 9\right) \cdot t}}{a \cdot 2}\right)\right) + \frac{x \cdot y}{a \cdot 2} \]
      7. lift-*.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\frac{\color{blue}{\left(z \cdot 9\right)} \cdot t}{a \cdot 2}\right)\right) + \frac{x \cdot y}{a \cdot 2} \]
      8. associate-*l*N/A

        \[\leadsto \left(\mathsf{neg}\left(\frac{\color{blue}{z \cdot \left(9 \cdot t\right)}}{a \cdot 2}\right)\right) + \frac{x \cdot y}{a \cdot 2} \]
      9. associate-/l*N/A

        \[\leadsto \left(\mathsf{neg}\left(\color{blue}{z \cdot \frac{9 \cdot t}{a \cdot 2}}\right)\right) + \frac{x \cdot y}{a \cdot 2} \]
      10. distribute-lft-neg-inN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(z\right)\right) \cdot \frac{9 \cdot t}{a \cdot 2}} + \frac{x \cdot y}{a \cdot 2} \]
      11. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(z\right), \frac{9 \cdot t}{a \cdot 2}, \frac{x \cdot y}{a \cdot 2}\right)} \]
      12. lower-neg.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{-z}, \frac{9 \cdot t}{a \cdot 2}, \frac{x \cdot y}{a \cdot 2}\right) \]
      13. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(-z, \frac{9 \cdot t}{\color{blue}{a \cdot 2}}, \frac{x \cdot y}{a \cdot 2}\right) \]
      14. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(-z, \frac{9 \cdot t}{\color{blue}{2 \cdot a}}, \frac{x \cdot y}{a \cdot 2}\right) \]
      15. times-fracN/A

        \[\leadsto \mathsf{fma}\left(-z, \color{blue}{\frac{9}{2} \cdot \frac{t}{a}}, \frac{x \cdot y}{a \cdot 2}\right) \]
      16. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(-z, \color{blue}{\frac{9}{2} \cdot \frac{t}{a}}, \frac{x \cdot y}{a \cdot 2}\right) \]
      17. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(-z, \color{blue}{\frac{9}{2}} \cdot \frac{t}{a}, \frac{x \cdot y}{a \cdot 2}\right) \]
      18. lower-/.f64N/A

        \[\leadsto \mathsf{fma}\left(-z, \frac{9}{2} \cdot \color{blue}{\frac{t}{a}}, \frac{x \cdot y}{a \cdot 2}\right) \]
      19. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(-z, \frac{9}{2} \cdot \frac{t}{a}, \frac{\color{blue}{x \cdot y}}{a \cdot 2}\right) \]
      20. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(-z, \frac{9}{2} \cdot \frac{t}{a}, \frac{\color{blue}{y \cdot x}}{a \cdot 2}\right) \]
      21. associate-/l*N/A

        \[\leadsto \mathsf{fma}\left(-z, \frac{9}{2} \cdot \frac{t}{a}, \color{blue}{y \cdot \frac{x}{a \cdot 2}}\right) \]
      22. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(-z, \frac{9}{2} \cdot \frac{t}{a}, \color{blue}{\frac{x}{a \cdot 2} \cdot y}\right) \]
      23. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(-z, \frac{9}{2} \cdot \frac{t}{a}, \color{blue}{\frac{x}{a \cdot 2} \cdot y}\right) \]
    3. Applied rewrites88.3%

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

Alternative 2: 95.1% accurate, 0.4× speedup?

\[\mathsf{copysign}\left(1, a\right) \cdot \begin{array}{l} \mathbf{if}\;\left|a\right| \leq 3.4 \cdot 10^{+78}:\\ \;\;\;\;\frac{\mathsf{fma}\left(-9 \cdot \mathsf{min}\left(z, t\right), \mathsf{max}\left(z, t\right), \mathsf{max}\left(x, y\right) \cdot \mathsf{min}\left(x, y\right)\right)}{\left|a\right| \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{\mathsf{min}\left(x, y\right)}{\left|a\right| + \left|a\right|}, \mathsf{max}\left(x, y\right), \left(\mathsf{min}\left(z, t\right) \cdot \frac{\mathsf{max}\left(z, t\right)}{\left|a\right|}\right) \cdot -4.5\right)\\ \end{array} \]
(FPCore (x y z t a)
 :precision binary64
 (*
  (copysign 1.0 a)
  (if (<= (fabs a) 3.4e+78)
    (/
     (fma (* -9.0 (fmin z t)) (fmax z t) (* (fmax x y) (fmin x y)))
     (* (fabs a) 2.0))
    (fma
     (/ (fmin x y) (+ (fabs a) (fabs a)))
     (fmax x y)
     (* (* (fmin z t) (/ (fmax z t) (fabs a))) -4.5)))))
double code(double x, double y, double z, double t, double a) {
	double tmp;
	if (fabs(a) <= 3.4e+78) {
		tmp = fma((-9.0 * fmin(z, t)), fmax(z, t), (fmax(x, y) * fmin(x, y))) / (fabs(a) * 2.0);
	} else {
		tmp = fma((fmin(x, y) / (fabs(a) + fabs(a))), fmax(x, y), ((fmin(z, t) * (fmax(z, t) / fabs(a))) * -4.5));
	}
	return copysign(1.0, a) * tmp;
}
function code(x, y, z, t, a)
	tmp = 0.0
	if (abs(a) <= 3.4e+78)
		tmp = Float64(fma(Float64(-9.0 * fmin(z, t)), fmax(z, t), Float64(fmax(x, y) * fmin(x, y))) / Float64(abs(a) * 2.0));
	else
		tmp = fma(Float64(fmin(x, y) / Float64(abs(a) + abs(a))), fmax(x, y), Float64(Float64(fmin(z, t) * Float64(fmax(z, t) / abs(a))) * -4.5));
	end
	return Float64(copysign(1.0, a) * tmp)
end
code[x_, y_, z_, t_, a_] := N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[Abs[a], $MachinePrecision], 3.4e+78], N[(N[(N[(-9.0 * N[Min[z, t], $MachinePrecision]), $MachinePrecision] * N[Max[z, t], $MachinePrecision] + N[(N[Max[x, y], $MachinePrecision] * N[Min[x, y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Abs[a], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[Min[x, y], $MachinePrecision] / N[(N[Abs[a], $MachinePrecision] + N[Abs[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Max[x, y], $MachinePrecision] + N[(N[(N[Min[z, t], $MachinePrecision] * N[(N[Max[z, t], $MachinePrecision] / N[Abs[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -4.5), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\mathsf{copysign}\left(1, a\right) \cdot \begin{array}{l}
\mathbf{if}\;\left|a\right| \leq 3.4 \cdot 10^{+78}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-9 \cdot \mathsf{min}\left(z, t\right), \mathsf{max}\left(z, t\right), \mathsf{max}\left(x, y\right) \cdot \mathsf{min}\left(x, y\right)\right)}{\left|a\right| \cdot 2}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\mathsf{min}\left(x, y\right)}{\left|a\right| + \left|a\right|}, \mathsf{max}\left(x, y\right), \left(\mathsf{min}\left(z, t\right) \cdot \frac{\mathsf{max}\left(z, t\right)}{\left|a\right|}\right) \cdot -4.5\right)\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < 3.4000000000000001e78

    1. Initial program 91.2%

      \[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2} \]
    2. Step-by-step derivation
      1. lift--.f64N/A

        \[\leadsto \frac{\color{blue}{x \cdot y - \left(z \cdot 9\right) \cdot t}}{a \cdot 2} \]
      2. sub-flipN/A

        \[\leadsto \frac{\color{blue}{x \cdot y + \left(\mathsf{neg}\left(\left(z \cdot 9\right) \cdot t\right)\right)}}{a \cdot 2} \]
      3. +-commutativeN/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(\left(z \cdot 9\right) \cdot t\right)\right) + x \cdot y}}{a \cdot 2} \]
      4. lift-*.f64N/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(\color{blue}{\left(z \cdot 9\right) \cdot t}\right)\right) + x \cdot y}{a \cdot 2} \]
      5. distribute-lft-neg-outN/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(z \cdot 9\right)\right) \cdot t} + x \cdot y}{a \cdot 2} \]
      6. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(z \cdot 9\right), t, x \cdot y\right)}}{a \cdot 2} \]
      7. lift-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\mathsf{neg}\left(\color{blue}{z \cdot 9}\right), t, x \cdot y\right)}{a \cdot 2} \]
      8. *-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(\mathsf{neg}\left(\color{blue}{9 \cdot z}\right), t, x \cdot y\right)}{a \cdot 2} \]
      9. distribute-lft-neg-inN/A

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{\left(\mathsf{neg}\left(9\right)\right) \cdot z}, t, x \cdot y\right)}{a \cdot 2} \]
      10. lower-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{\left(\mathsf{neg}\left(9\right)\right) \cdot z}, t, x \cdot y\right)}{a \cdot 2} \]
      11. metadata-eval91.5%

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{-9} \cdot z, t, x \cdot y\right)}{a \cdot 2} \]
      12. lift-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(-9 \cdot z, t, \color{blue}{x \cdot y}\right)}{a \cdot 2} \]
      13. *-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(-9 \cdot z, t, \color{blue}{y \cdot x}\right)}{a \cdot 2} \]
      14. lower-*.f6491.5%

        \[\leadsto \frac{\mathsf{fma}\left(-9 \cdot z, t, \color{blue}{y \cdot x}\right)}{a \cdot 2} \]
    3. Applied rewrites91.5%

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

    if 3.4000000000000001e78 < a

    1. Initial program 91.2%

      \[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2} \]
    2. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}} \]
      2. lift--.f64N/A

        \[\leadsto \frac{\color{blue}{x \cdot y - \left(z \cdot 9\right) \cdot t}}{a \cdot 2} \]
      3. div-subN/A

        \[\leadsto \color{blue}{\frac{x \cdot y}{a \cdot 2} - \frac{\left(z \cdot 9\right) \cdot t}{a \cdot 2}} \]
      4. sub-flipN/A

        \[\leadsto \color{blue}{\frac{x \cdot y}{a \cdot 2} + \left(\mathsf{neg}\left(\frac{\left(z \cdot 9\right) \cdot t}{a \cdot 2}\right)\right)} \]
      5. +-commutativeN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\frac{\left(z \cdot 9\right) \cdot t}{a \cdot 2}\right)\right) + \frac{x \cdot y}{a \cdot 2}} \]
      6. lift-*.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\frac{\color{blue}{\left(z \cdot 9\right) \cdot t}}{a \cdot 2}\right)\right) + \frac{x \cdot y}{a \cdot 2} \]
      7. lift-*.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\frac{\color{blue}{\left(z \cdot 9\right)} \cdot t}{a \cdot 2}\right)\right) + \frac{x \cdot y}{a \cdot 2} \]
      8. associate-*l*N/A

        \[\leadsto \left(\mathsf{neg}\left(\frac{\color{blue}{z \cdot \left(9 \cdot t\right)}}{a \cdot 2}\right)\right) + \frac{x \cdot y}{a \cdot 2} \]
      9. associate-/l*N/A

        \[\leadsto \left(\mathsf{neg}\left(\color{blue}{z \cdot \frac{9 \cdot t}{a \cdot 2}}\right)\right) + \frac{x \cdot y}{a \cdot 2} \]
      10. distribute-lft-neg-inN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(z\right)\right) \cdot \frac{9 \cdot t}{a \cdot 2}} + \frac{x \cdot y}{a \cdot 2} \]
      11. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(z\right), \frac{9 \cdot t}{a \cdot 2}, \frac{x \cdot y}{a \cdot 2}\right)} \]
      12. lower-neg.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{-z}, \frac{9 \cdot t}{a \cdot 2}, \frac{x \cdot y}{a \cdot 2}\right) \]
      13. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(-z, \frac{9 \cdot t}{\color{blue}{a \cdot 2}}, \frac{x \cdot y}{a \cdot 2}\right) \]
      14. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(-z, \frac{9 \cdot t}{\color{blue}{2 \cdot a}}, \frac{x \cdot y}{a \cdot 2}\right) \]
      15. times-fracN/A

        \[\leadsto \mathsf{fma}\left(-z, \color{blue}{\frac{9}{2} \cdot \frac{t}{a}}, \frac{x \cdot y}{a \cdot 2}\right) \]
      16. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(-z, \color{blue}{\frac{9}{2} \cdot \frac{t}{a}}, \frac{x \cdot y}{a \cdot 2}\right) \]
      17. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(-z, \color{blue}{\frac{9}{2}} \cdot \frac{t}{a}, \frac{x \cdot y}{a \cdot 2}\right) \]
      18. lower-/.f64N/A

        \[\leadsto \mathsf{fma}\left(-z, \frac{9}{2} \cdot \color{blue}{\frac{t}{a}}, \frac{x \cdot y}{a \cdot 2}\right) \]
      19. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(-z, \frac{9}{2} \cdot \frac{t}{a}, \frac{\color{blue}{x \cdot y}}{a \cdot 2}\right) \]
      20. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(-z, \frac{9}{2} \cdot \frac{t}{a}, \frac{\color{blue}{y \cdot x}}{a \cdot 2}\right) \]
      21. associate-/l*N/A

        \[\leadsto \mathsf{fma}\left(-z, \frac{9}{2} \cdot \frac{t}{a}, \color{blue}{y \cdot \frac{x}{a \cdot 2}}\right) \]
      22. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(-z, \frac{9}{2} \cdot \frac{t}{a}, \color{blue}{\frac{x}{a \cdot 2} \cdot y}\right) \]
      23. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(-z, \frac{9}{2} \cdot \frac{t}{a}, \color{blue}{\frac{x}{a \cdot 2} \cdot y}\right) \]
    3. Applied rewrites88.3%

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

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

Alternative 3: 95.0% accurate, 0.5× speedup?

\[\mathsf{copysign}\left(1, a\right) \cdot \begin{array}{l} \mathbf{if}\;\left|a\right| \leq 3.4 \cdot 10^{+78}:\\ \;\;\;\;\frac{\mathsf{fma}\left(-9 \cdot \mathsf{min}\left(z, t\right), \mathsf{max}\left(z, t\right), y \cdot x\right)}{\left|a\right| \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{min}\left(z, t\right) \cdot \frac{\mathsf{max}\left(z, t\right)}{\left|a\right|}, -4.5, x \cdot \frac{y}{\left|a\right| + \left|a\right|}\right)\\ \end{array} \]
(FPCore (x y z t a)
 :precision binary64
 (*
  (copysign 1.0 a)
  (if (<= (fabs a) 3.4e+78)
    (/ (fma (* -9.0 (fmin z t)) (fmax z t) (* y x)) (* (fabs a) 2.0))
    (fma
     (* (fmin z t) (/ (fmax z t) (fabs a)))
     -4.5
     (* x (/ y (+ (fabs a) (fabs a))))))))
double code(double x, double y, double z, double t, double a) {
	double tmp;
	if (fabs(a) <= 3.4e+78) {
		tmp = fma((-9.0 * fmin(z, t)), fmax(z, t), (y * x)) / (fabs(a) * 2.0);
	} else {
		tmp = fma((fmin(z, t) * (fmax(z, t) / fabs(a))), -4.5, (x * (y / (fabs(a) + fabs(a)))));
	}
	return copysign(1.0, a) * tmp;
}
function code(x, y, z, t, a)
	tmp = 0.0
	if (abs(a) <= 3.4e+78)
		tmp = Float64(fma(Float64(-9.0 * fmin(z, t)), fmax(z, t), Float64(y * x)) / Float64(abs(a) * 2.0));
	else
		tmp = fma(Float64(fmin(z, t) * Float64(fmax(z, t) / abs(a))), -4.5, Float64(x * Float64(y / Float64(abs(a) + abs(a)))));
	end
	return Float64(copysign(1.0, a) * tmp)
end
code[x_, y_, z_, t_, a_] := N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[Abs[a], $MachinePrecision], 3.4e+78], N[(N[(N[(-9.0 * N[Min[z, t], $MachinePrecision]), $MachinePrecision] * N[Max[z, t], $MachinePrecision] + N[(y * x), $MachinePrecision]), $MachinePrecision] / N[(N[Abs[a], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[Min[z, t], $MachinePrecision] * N[(N[Max[z, t], $MachinePrecision] / N[Abs[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -4.5 + N[(x * N[(y / N[(N[Abs[a], $MachinePrecision] + N[Abs[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\mathsf{copysign}\left(1, a\right) \cdot \begin{array}{l}
\mathbf{if}\;\left|a\right| \leq 3.4 \cdot 10^{+78}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-9 \cdot \mathsf{min}\left(z, t\right), \mathsf{max}\left(z, t\right), y \cdot x\right)}{\left|a\right| \cdot 2}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{min}\left(z, t\right) \cdot \frac{\mathsf{max}\left(z, t\right)}{\left|a\right|}, -4.5, x \cdot \frac{y}{\left|a\right| + \left|a\right|}\right)\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < 3.4000000000000001e78

    1. Initial program 91.2%

      \[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2} \]
    2. Step-by-step derivation
      1. lift--.f64N/A

        \[\leadsto \frac{\color{blue}{x \cdot y - \left(z \cdot 9\right) \cdot t}}{a \cdot 2} \]
      2. sub-flipN/A

        \[\leadsto \frac{\color{blue}{x \cdot y + \left(\mathsf{neg}\left(\left(z \cdot 9\right) \cdot t\right)\right)}}{a \cdot 2} \]
      3. +-commutativeN/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(\left(z \cdot 9\right) \cdot t\right)\right) + x \cdot y}}{a \cdot 2} \]
      4. lift-*.f64N/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(\color{blue}{\left(z \cdot 9\right) \cdot t}\right)\right) + x \cdot y}{a \cdot 2} \]
      5. distribute-lft-neg-outN/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(z \cdot 9\right)\right) \cdot t} + x \cdot y}{a \cdot 2} \]
      6. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(z \cdot 9\right), t, x \cdot y\right)}}{a \cdot 2} \]
      7. lift-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\mathsf{neg}\left(\color{blue}{z \cdot 9}\right), t, x \cdot y\right)}{a \cdot 2} \]
      8. *-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(\mathsf{neg}\left(\color{blue}{9 \cdot z}\right), t, x \cdot y\right)}{a \cdot 2} \]
      9. distribute-lft-neg-inN/A

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{\left(\mathsf{neg}\left(9\right)\right) \cdot z}, t, x \cdot y\right)}{a \cdot 2} \]
      10. lower-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{\left(\mathsf{neg}\left(9\right)\right) \cdot z}, t, x \cdot y\right)}{a \cdot 2} \]
      11. metadata-eval91.5%

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{-9} \cdot z, t, x \cdot y\right)}{a \cdot 2} \]
      12. lift-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(-9 \cdot z, t, \color{blue}{x \cdot y}\right)}{a \cdot 2} \]
      13. *-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(-9 \cdot z, t, \color{blue}{y \cdot x}\right)}{a \cdot 2} \]
      14. lower-*.f6491.5%

        \[\leadsto \frac{\mathsf{fma}\left(-9 \cdot z, t, \color{blue}{y \cdot x}\right)}{a \cdot 2} \]
    3. Applied rewrites91.5%

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

    if 3.4000000000000001e78 < a

    1. Initial program 91.2%

      \[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2} \]
    2. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}} \]
      2. lift--.f64N/A

        \[\leadsto \frac{\color{blue}{x \cdot y - \left(z \cdot 9\right) \cdot t}}{a \cdot 2} \]
      3. div-subN/A

        \[\leadsto \color{blue}{\frac{x \cdot y}{a \cdot 2} - \frac{\left(z \cdot 9\right) \cdot t}{a \cdot 2}} \]
      4. sub-flipN/A

        \[\leadsto \color{blue}{\frac{x \cdot y}{a \cdot 2} + \left(\mathsf{neg}\left(\frac{\left(z \cdot 9\right) \cdot t}{a \cdot 2}\right)\right)} \]
      5. +-commutativeN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\frac{\left(z \cdot 9\right) \cdot t}{a \cdot 2}\right)\right) + \frac{x \cdot y}{a \cdot 2}} \]
      6. lift-*.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\frac{\color{blue}{\left(z \cdot 9\right) \cdot t}}{a \cdot 2}\right)\right) + \frac{x \cdot y}{a \cdot 2} \]
      7. lift-*.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\frac{\color{blue}{\left(z \cdot 9\right)} \cdot t}{a \cdot 2}\right)\right) + \frac{x \cdot y}{a \cdot 2} \]
      8. associate-*l*N/A

        \[\leadsto \left(\mathsf{neg}\left(\frac{\color{blue}{z \cdot \left(9 \cdot t\right)}}{a \cdot 2}\right)\right) + \frac{x \cdot y}{a \cdot 2} \]
      9. associate-/l*N/A

        \[\leadsto \left(\mathsf{neg}\left(\color{blue}{z \cdot \frac{9 \cdot t}{a \cdot 2}}\right)\right) + \frac{x \cdot y}{a \cdot 2} \]
      10. distribute-lft-neg-inN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(z\right)\right) \cdot \frac{9 \cdot t}{a \cdot 2}} + \frac{x \cdot y}{a \cdot 2} \]
      11. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(z\right), \frac{9 \cdot t}{a \cdot 2}, \frac{x \cdot y}{a \cdot 2}\right)} \]
      12. lower-neg.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{-z}, \frac{9 \cdot t}{a \cdot 2}, \frac{x \cdot y}{a \cdot 2}\right) \]
      13. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(-z, \frac{9 \cdot t}{\color{blue}{a \cdot 2}}, \frac{x \cdot y}{a \cdot 2}\right) \]
      14. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(-z, \frac{9 \cdot t}{\color{blue}{2 \cdot a}}, \frac{x \cdot y}{a \cdot 2}\right) \]
      15. times-fracN/A

        \[\leadsto \mathsf{fma}\left(-z, \color{blue}{\frac{9}{2} \cdot \frac{t}{a}}, \frac{x \cdot y}{a \cdot 2}\right) \]
      16. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(-z, \color{blue}{\frac{9}{2} \cdot \frac{t}{a}}, \frac{x \cdot y}{a \cdot 2}\right) \]
      17. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(-z, \color{blue}{\frac{9}{2}} \cdot \frac{t}{a}, \frac{x \cdot y}{a \cdot 2}\right) \]
      18. lower-/.f64N/A

        \[\leadsto \mathsf{fma}\left(-z, \frac{9}{2} \cdot \color{blue}{\frac{t}{a}}, \frac{x \cdot y}{a \cdot 2}\right) \]
      19. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(-z, \frac{9}{2} \cdot \frac{t}{a}, \frac{\color{blue}{x \cdot y}}{a \cdot 2}\right) \]
      20. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(-z, \frac{9}{2} \cdot \frac{t}{a}, \frac{\color{blue}{y \cdot x}}{a \cdot 2}\right) \]
      21. associate-/l*N/A

        \[\leadsto \mathsf{fma}\left(-z, \frac{9}{2} \cdot \frac{t}{a}, \color{blue}{y \cdot \frac{x}{a \cdot 2}}\right) \]
      22. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(-z, \frac{9}{2} \cdot \frac{t}{a}, \color{blue}{\frac{x}{a \cdot 2} \cdot y}\right) \]
      23. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(-z, \frac{9}{2} \cdot \frac{t}{a}, \color{blue}{\frac{x}{a \cdot 2} \cdot y}\right) \]
    3. Applied rewrites88.3%

      \[\leadsto \color{blue}{\mathsf{fma}\left(-z, 4.5 \cdot \frac{t}{a}, \frac{x}{a + a} \cdot y\right)} \]
    4. Applied rewrites87.8%

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

Alternative 4: 93.2% accurate, 0.4× speedup?

\[\begin{array}{l} \mathbf{if}\;\mathsf{min}\left(x, y\right) \cdot \mathsf{max}\left(x, y\right) \leq -5 \cdot 10^{+239}:\\ \;\;\;\;\frac{\mathsf{max}\left(x, y\right)}{a + a} \cdot \mathsf{min}\left(x, y\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(-9 \cdot \mathsf{min}\left(z, t\right), \mathsf{max}\left(z, t\right), \mathsf{max}\left(x, y\right) \cdot \mathsf{min}\left(x, y\right)\right)}{a \cdot 2}\\ \end{array} \]
(FPCore (x y z t a)
 :precision binary64
 (if (<= (* (fmin x y) (fmax x y)) -5e+239)
   (* (/ (fmax x y) (+ a a)) (fmin x y))
   (/
    (fma (* -9.0 (fmin z t)) (fmax z t) (* (fmax x y) (fmin x y)))
    (* a 2.0))))
double code(double x, double y, double z, double t, double a) {
	double tmp;
	if ((fmin(x, y) * fmax(x, y)) <= -5e+239) {
		tmp = (fmax(x, y) / (a + a)) * fmin(x, y);
	} else {
		tmp = fma((-9.0 * fmin(z, t)), fmax(z, t), (fmax(x, y) * fmin(x, y))) / (a * 2.0);
	}
	return tmp;
}
function code(x, y, z, t, a)
	tmp = 0.0
	if (Float64(fmin(x, y) * fmax(x, y)) <= -5e+239)
		tmp = Float64(Float64(fmax(x, y) / Float64(a + a)) * fmin(x, y));
	else
		tmp = Float64(fma(Float64(-9.0 * fmin(z, t)), fmax(z, t), Float64(fmax(x, y) * fmin(x, y))) / Float64(a * 2.0));
	end
	return tmp
end
code[x_, y_, z_, t_, a_] := If[LessEqual[N[(N[Min[x, y], $MachinePrecision] * N[Max[x, y], $MachinePrecision]), $MachinePrecision], -5e+239], N[(N[(N[Max[x, y], $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision] * N[Min[x, y], $MachinePrecision]), $MachinePrecision], N[(N[(N[(-9.0 * N[Min[z, t], $MachinePrecision]), $MachinePrecision] * N[Max[z, t], $MachinePrecision] + N[(N[Max[x, y], $MachinePrecision] * N[Min[x, y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\mathsf{min}\left(x, y\right) \cdot \mathsf{max}\left(x, y\right) \leq -5 \cdot 10^{+239}:\\
\;\;\;\;\frac{\mathsf{max}\left(x, y\right)}{a + a} \cdot \mathsf{min}\left(x, y\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-9 \cdot \mathsf{min}\left(z, t\right), \mathsf{max}\left(z, t\right), \mathsf{max}\left(x, y\right) \cdot \mathsf{min}\left(x, y\right)\right)}{a \cdot 2}\\


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

    1. Initial program 91.2%

      \[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2} \]
    2. Taylor expanded in x around inf

      \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{x \cdot y}{a}} \]
    3. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \frac{1}{2} \cdot \color{blue}{\frac{x \cdot y}{a}} \]
      2. lower-/.f64N/A

        \[\leadsto \frac{1}{2} \cdot \frac{x \cdot y}{\color{blue}{a}} \]
      3. lower-*.f6451.3%

        \[\leadsto 0.5 \cdot \frac{x \cdot y}{a} \]
    4. Applied rewrites51.3%

      \[\leadsto \color{blue}{0.5 \cdot \frac{x \cdot y}{a}} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{1}{2} \cdot \color{blue}{\frac{x \cdot y}{a}} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{1}{2} \cdot \frac{x \cdot y}{\color{blue}{a}} \]
      3. associate-*r/N/A

        \[\leadsto \frac{\frac{1}{2} \cdot \left(x \cdot y\right)}{\color{blue}{a}} \]
      4. *-commutativeN/A

        \[\leadsto \frac{\left(x \cdot y\right) \cdot \frac{1}{2}}{a} \]
      5. metadata-evalN/A

        \[\leadsto \frac{\left(x \cdot y\right) \cdot \frac{1}{2}}{a} \]
      6. mult-flip-revN/A

        \[\leadsto \frac{\frac{x \cdot y}{2}}{a} \]
      7. associate-/r*N/A

        \[\leadsto \frac{x \cdot y}{\color{blue}{2 \cdot a}} \]
      8. lift-*.f64N/A

        \[\leadsto \frac{x \cdot y}{\color{blue}{2} \cdot a} \]
      9. count-2N/A

        \[\leadsto \frac{x \cdot y}{a + \color{blue}{a}} \]
      10. lift-+.f64N/A

        \[\leadsto \frac{x \cdot y}{a + \color{blue}{a}} \]
      11. associate-/l*N/A

        \[\leadsto x \cdot \color{blue}{\frac{y}{a + a}} \]
      12. lift-/.f64N/A

        \[\leadsto x \cdot \frac{y}{\color{blue}{a + a}} \]
      13. *-commutativeN/A

        \[\leadsto \frac{y}{a + a} \cdot \color{blue}{x} \]
      14. lower-*.f6452.3%

        \[\leadsto \frac{y}{a + a} \cdot \color{blue}{x} \]
    6. Applied rewrites52.3%

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

    if -5.0000000000000001e239 < (*.f64 x y)

    1. Initial program 91.2%

      \[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2} \]
    2. Step-by-step derivation
      1. lift--.f64N/A

        \[\leadsto \frac{\color{blue}{x \cdot y - \left(z \cdot 9\right) \cdot t}}{a \cdot 2} \]
      2. sub-flipN/A

        \[\leadsto \frac{\color{blue}{x \cdot y + \left(\mathsf{neg}\left(\left(z \cdot 9\right) \cdot t\right)\right)}}{a \cdot 2} \]
      3. +-commutativeN/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(\left(z \cdot 9\right) \cdot t\right)\right) + x \cdot y}}{a \cdot 2} \]
      4. lift-*.f64N/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(\color{blue}{\left(z \cdot 9\right) \cdot t}\right)\right) + x \cdot y}{a \cdot 2} \]
      5. distribute-lft-neg-outN/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(z \cdot 9\right)\right) \cdot t} + x \cdot y}{a \cdot 2} \]
      6. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(z \cdot 9\right), t, x \cdot y\right)}}{a \cdot 2} \]
      7. lift-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\mathsf{neg}\left(\color{blue}{z \cdot 9}\right), t, x \cdot y\right)}{a \cdot 2} \]
      8. *-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(\mathsf{neg}\left(\color{blue}{9 \cdot z}\right), t, x \cdot y\right)}{a \cdot 2} \]
      9. distribute-lft-neg-inN/A

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{\left(\mathsf{neg}\left(9\right)\right) \cdot z}, t, x \cdot y\right)}{a \cdot 2} \]
      10. lower-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{\left(\mathsf{neg}\left(9\right)\right) \cdot z}, t, x \cdot y\right)}{a \cdot 2} \]
      11. metadata-eval91.5%

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{-9} \cdot z, t, x \cdot y\right)}{a \cdot 2} \]
      12. lift-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(-9 \cdot z, t, \color{blue}{x \cdot y}\right)}{a \cdot 2} \]
      13. *-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(-9 \cdot z, t, \color{blue}{y \cdot x}\right)}{a \cdot 2} \]
      14. lower-*.f6491.5%

        \[\leadsto \frac{\mathsf{fma}\left(-9 \cdot z, t, \color{blue}{y \cdot x}\right)}{a \cdot 2} \]
    3. Applied rewrites91.5%

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(-9 \cdot z, t, y \cdot x\right)}}{a \cdot 2} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 5: 93.2% accurate, 0.5× speedup?

\[\begin{array}{l} \mathbf{if}\;\mathsf{min}\left(x, y\right) \cdot \mathsf{max}\left(x, y\right) \leq -5 \cdot 10^{+239}:\\ \;\;\;\;\frac{\mathsf{max}\left(x, y\right)}{a + a} \cdot \mathsf{min}\left(x, y\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(-9 \cdot t, z, \mathsf{max}\left(x, y\right) \cdot \mathsf{min}\left(x, y\right)\right)}{a \cdot 2}\\ \end{array} \]
(FPCore (x y z t a)
 :precision binary64
 (if (<= (* (fmin x y) (fmax x y)) -5e+239)
   (* (/ (fmax x y) (+ a a)) (fmin x y))
   (/ (fma (* -9.0 t) z (* (fmax x y) (fmin x y))) (* a 2.0))))
double code(double x, double y, double z, double t, double a) {
	double tmp;
	if ((fmin(x, y) * fmax(x, y)) <= -5e+239) {
		tmp = (fmax(x, y) / (a + a)) * fmin(x, y);
	} else {
		tmp = fma((-9.0 * t), z, (fmax(x, y) * fmin(x, y))) / (a * 2.0);
	}
	return tmp;
}
function code(x, y, z, t, a)
	tmp = 0.0
	if (Float64(fmin(x, y) * fmax(x, y)) <= -5e+239)
		tmp = Float64(Float64(fmax(x, y) / Float64(a + a)) * fmin(x, y));
	else
		tmp = Float64(fma(Float64(-9.0 * t), z, Float64(fmax(x, y) * fmin(x, y))) / Float64(a * 2.0));
	end
	return tmp
end
code[x_, y_, z_, t_, a_] := If[LessEqual[N[(N[Min[x, y], $MachinePrecision] * N[Max[x, y], $MachinePrecision]), $MachinePrecision], -5e+239], N[(N[(N[Max[x, y], $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision] * N[Min[x, y], $MachinePrecision]), $MachinePrecision], N[(N[(N[(-9.0 * t), $MachinePrecision] * z + N[(N[Max[x, y], $MachinePrecision] * N[Min[x, y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\mathsf{min}\left(x, y\right) \cdot \mathsf{max}\left(x, y\right) \leq -5 \cdot 10^{+239}:\\
\;\;\;\;\frac{\mathsf{max}\left(x, y\right)}{a + a} \cdot \mathsf{min}\left(x, y\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-9 \cdot t, z, \mathsf{max}\left(x, y\right) \cdot \mathsf{min}\left(x, y\right)\right)}{a \cdot 2}\\


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

    1. Initial program 91.2%

      \[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2} \]
    2. Taylor expanded in x around inf

      \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{x \cdot y}{a}} \]
    3. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \frac{1}{2} \cdot \color{blue}{\frac{x \cdot y}{a}} \]
      2. lower-/.f64N/A

        \[\leadsto \frac{1}{2} \cdot \frac{x \cdot y}{\color{blue}{a}} \]
      3. lower-*.f6451.3%

        \[\leadsto 0.5 \cdot \frac{x \cdot y}{a} \]
    4. Applied rewrites51.3%

      \[\leadsto \color{blue}{0.5 \cdot \frac{x \cdot y}{a}} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{1}{2} \cdot \color{blue}{\frac{x \cdot y}{a}} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{1}{2} \cdot \frac{x \cdot y}{\color{blue}{a}} \]
      3. associate-*r/N/A

        \[\leadsto \frac{\frac{1}{2} \cdot \left(x \cdot y\right)}{\color{blue}{a}} \]
      4. *-commutativeN/A

        \[\leadsto \frac{\left(x \cdot y\right) \cdot \frac{1}{2}}{a} \]
      5. metadata-evalN/A

        \[\leadsto \frac{\left(x \cdot y\right) \cdot \frac{1}{2}}{a} \]
      6. mult-flip-revN/A

        \[\leadsto \frac{\frac{x \cdot y}{2}}{a} \]
      7. associate-/r*N/A

        \[\leadsto \frac{x \cdot y}{\color{blue}{2 \cdot a}} \]
      8. lift-*.f64N/A

        \[\leadsto \frac{x \cdot y}{\color{blue}{2} \cdot a} \]
      9. count-2N/A

        \[\leadsto \frac{x \cdot y}{a + \color{blue}{a}} \]
      10. lift-+.f64N/A

        \[\leadsto \frac{x \cdot y}{a + \color{blue}{a}} \]
      11. associate-/l*N/A

        \[\leadsto x \cdot \color{blue}{\frac{y}{a + a}} \]
      12. lift-/.f64N/A

        \[\leadsto x \cdot \frac{y}{\color{blue}{a + a}} \]
      13. *-commutativeN/A

        \[\leadsto \frac{y}{a + a} \cdot \color{blue}{x} \]
      14. lower-*.f6452.3%

        \[\leadsto \frac{y}{a + a} \cdot \color{blue}{x} \]
    6. Applied rewrites52.3%

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

    if -5.0000000000000001e239 < (*.f64 x y)

    1. Initial program 91.2%

      \[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2} \]
    2. Step-by-step derivation
      1. lift--.f64N/A

        \[\leadsto \frac{\color{blue}{x \cdot y - \left(z \cdot 9\right) \cdot t}}{a \cdot 2} \]
      2. sub-flipN/A

        \[\leadsto \frac{\color{blue}{x \cdot y + \left(\mathsf{neg}\left(\left(z \cdot 9\right) \cdot t\right)\right)}}{a \cdot 2} \]
      3. +-commutativeN/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(\left(z \cdot 9\right) \cdot t\right)\right) + x \cdot y}}{a \cdot 2} \]
      4. lift-*.f64N/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(\color{blue}{\left(z \cdot 9\right) \cdot t}\right)\right) + x \cdot y}{a \cdot 2} \]
      5. lift-*.f64N/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(\color{blue}{\left(z \cdot 9\right)} \cdot t\right)\right) + x \cdot y}{a \cdot 2} \]
      6. associate-*l*N/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(\color{blue}{z \cdot \left(9 \cdot t\right)}\right)\right) + x \cdot y}{a \cdot 2} \]
      7. *-commutativeN/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(\color{blue}{\left(9 \cdot t\right) \cdot z}\right)\right) + x \cdot y}{a \cdot 2} \]
      8. distribute-lft-neg-inN/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(9 \cdot t\right)\right) \cdot z} + x \cdot y}{a \cdot 2} \]
      9. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(9 \cdot t\right), z, x \cdot y\right)}}{a \cdot 2} \]
      10. distribute-lft-neg-inN/A

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{\left(\mathsf{neg}\left(9\right)\right) \cdot t}, z, x \cdot y\right)}{a \cdot 2} \]
      11. lower-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{\left(\mathsf{neg}\left(9\right)\right) \cdot t}, z, x \cdot y\right)}{a \cdot 2} \]
      12. metadata-eval91.5%

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{-9} \cdot t, z, x \cdot y\right)}{a \cdot 2} \]
      13. lift-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(-9 \cdot t, z, \color{blue}{x \cdot y}\right)}{a \cdot 2} \]
      14. *-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(-9 \cdot t, z, \color{blue}{y \cdot x}\right)}{a \cdot 2} \]
      15. lower-*.f6491.5%

        \[\leadsto \frac{\mathsf{fma}\left(-9 \cdot t, z, \color{blue}{y \cdot x}\right)}{a \cdot 2} \]
    3. Applied rewrites91.5%

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(-9 \cdot t, z, y \cdot x\right)}}{a \cdot 2} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 6: 93.1% accurate, 0.5× speedup?

\[\begin{array}{l} \mathbf{if}\;\left(\mathsf{min}\left(z, t\right) \cdot 9\right) \cdot \mathsf{max}\left(z, t\right) \leq 5 \cdot 10^{+282}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\mathsf{max}\left(z, t\right) \cdot \mathsf{min}\left(z, t\right), -9, y \cdot x\right)}{a + a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{max}\left(z, t\right) \cdot \left(\frac{-4.5}{a} \cdot \mathsf{min}\left(z, t\right)\right)\\ \end{array} \]
(FPCore (x y z t a)
 :precision binary64
 (if (<= (* (* (fmin z t) 9.0) (fmax z t)) 5e+282)
   (/ (fma (* (fmax z t) (fmin z t)) -9.0 (* y x)) (+ a a))
   (* (fmax z t) (* (/ -4.5 a) (fmin z t)))))
double code(double x, double y, double z, double t, double a) {
	double tmp;
	if (((fmin(z, t) * 9.0) * fmax(z, t)) <= 5e+282) {
		tmp = fma((fmax(z, t) * fmin(z, t)), -9.0, (y * x)) / (a + a);
	} else {
		tmp = fmax(z, t) * ((-4.5 / a) * fmin(z, t));
	}
	return tmp;
}
function code(x, y, z, t, a)
	tmp = 0.0
	if (Float64(Float64(fmin(z, t) * 9.0) * fmax(z, t)) <= 5e+282)
		tmp = Float64(fma(Float64(fmax(z, t) * fmin(z, t)), -9.0, Float64(y * x)) / Float64(a + a));
	else
		tmp = Float64(fmax(z, t) * Float64(Float64(-4.5 / a) * fmin(z, t)));
	end
	return tmp
end
code[x_, y_, z_, t_, a_] := If[LessEqual[N[(N[(N[Min[z, t], $MachinePrecision] * 9.0), $MachinePrecision] * N[Max[z, t], $MachinePrecision]), $MachinePrecision], 5e+282], N[(N[(N[(N[Max[z, t], $MachinePrecision] * N[Min[z, t], $MachinePrecision]), $MachinePrecision] * -9.0 + N[(y * x), $MachinePrecision]), $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision], N[(N[Max[z, t], $MachinePrecision] * N[(N[(-4.5 / a), $MachinePrecision] * N[Min[z, t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left(\mathsf{min}\left(z, t\right) \cdot 9\right) \cdot \mathsf{max}\left(z, t\right) \leq 5 \cdot 10^{+282}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\mathsf{max}\left(z, t\right) \cdot \mathsf{min}\left(z, t\right), -9, y \cdot x\right)}{a + a}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{max}\left(z, t\right) \cdot \left(\frac{-4.5}{a} \cdot \mathsf{min}\left(z, t\right)\right)\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 (*.f64 z #s(literal 9 binary64)) t) < 4.9999999999999998e282

    1. Initial program 91.2%

      \[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2} \]
    2. Step-by-step derivation
      1. lift--.f64N/A

        \[\leadsto \frac{\color{blue}{x \cdot y - \left(z \cdot 9\right) \cdot t}}{a \cdot 2} \]
      2. sub-flipN/A

        \[\leadsto \frac{\color{blue}{x \cdot y + \left(\mathsf{neg}\left(\left(z \cdot 9\right) \cdot t\right)\right)}}{a \cdot 2} \]
      3. +-commutativeN/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(\left(z \cdot 9\right) \cdot t\right)\right) + x \cdot y}}{a \cdot 2} \]
      4. lift-*.f64N/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(\color{blue}{\left(z \cdot 9\right) \cdot t}\right)\right) + x \cdot y}{a \cdot 2} \]
      5. *-commutativeN/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(\color{blue}{t \cdot \left(z \cdot 9\right)}\right)\right) + x \cdot y}{a \cdot 2} \]
      6. lift-*.f64N/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(t \cdot \color{blue}{\left(z \cdot 9\right)}\right)\right) + x \cdot y}{a \cdot 2} \]
      7. associate-*r*N/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(\color{blue}{\left(t \cdot z\right) \cdot 9}\right)\right) + x \cdot y}{a \cdot 2} \]
      8. distribute-rgt-neg-inN/A

        \[\leadsto \frac{\color{blue}{\left(t \cdot z\right) \cdot \left(\mathsf{neg}\left(9\right)\right)} + x \cdot y}{a \cdot 2} \]
      9. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(t \cdot z, \mathsf{neg}\left(9\right), x \cdot y\right)}}{a \cdot 2} \]
      10. lower-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{t \cdot z}, \mathsf{neg}\left(9\right), x \cdot y\right)}{a \cdot 2} \]
      11. metadata-eval91.3%

        \[\leadsto \frac{\mathsf{fma}\left(t \cdot z, \color{blue}{-9}, x \cdot y\right)}{a \cdot 2} \]
      12. lift-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(t \cdot z, -9, \color{blue}{x \cdot y}\right)}{a \cdot 2} \]
      13. *-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(t \cdot z, -9, \color{blue}{y \cdot x}\right)}{a \cdot 2} \]
      14. lower-*.f6491.3%

        \[\leadsto \frac{\mathsf{fma}\left(t \cdot z, -9, \color{blue}{y \cdot x}\right)}{a \cdot 2} \]
      15. lift-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(t \cdot z, -9, y \cdot x\right)}{\color{blue}{a \cdot 2}} \]
      16. *-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(t \cdot z, -9, y \cdot x\right)}{\color{blue}{2 \cdot a}} \]
      17. count-2-revN/A

        \[\leadsto \frac{\mathsf{fma}\left(t \cdot z, -9, y \cdot x\right)}{\color{blue}{a + a}} \]
      18. lower-+.f6491.3%

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(t \cdot z, -9, y \cdot x\right)}{a + a}} \]

    if 4.9999999999999998e282 < (*.f64 (*.f64 z #s(literal 9 binary64)) t)

    1. Initial program 91.2%

      \[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2} \]
    2. Taylor expanded in x around 0

      \[\leadsto \color{blue}{\frac{-9}{2} \cdot \frac{t \cdot z}{a}} \]
    3. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \frac{-9}{2} \cdot \color{blue}{\frac{t \cdot z}{a}} \]
      2. lower-/.f64N/A

        \[\leadsto \frac{-9}{2} \cdot \frac{t \cdot z}{\color{blue}{a}} \]
      3. lower-*.f6450.3%

        \[\leadsto -4.5 \cdot \frac{t \cdot z}{a} \]
    4. Applied rewrites50.3%

      \[\leadsto \color{blue}{-4.5 \cdot \frac{t \cdot z}{a}} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{-9}{2} \cdot \color{blue}{\frac{t \cdot z}{a}} \]
      2. *-commutativeN/A

        \[\leadsto \frac{t \cdot z}{a} \cdot \color{blue}{\frac{-9}{2}} \]
      3. lift-/.f64N/A

        \[\leadsto \frac{t \cdot z}{a} \cdot \frac{-9}{2} \]
      4. lift-*.f64N/A

        \[\leadsto \frac{t \cdot z}{a} \cdot \frac{-9}{2} \]
      5. associate-/l*N/A

        \[\leadsto \left(t \cdot \frac{z}{a}\right) \cdot \frac{-9}{2} \]
      6. associate-*l*N/A

        \[\leadsto t \cdot \color{blue}{\left(\frac{z}{a} \cdot \frac{-9}{2}\right)} \]
      7. lower-*.f64N/A

        \[\leadsto t \cdot \color{blue}{\left(\frac{z}{a} \cdot \frac{-9}{2}\right)} \]
      8. lower-*.f64N/A

        \[\leadsto t \cdot \left(\frac{z}{a} \cdot \color{blue}{\frac{-9}{2}}\right) \]
      9. lower-/.f6450.9%

        \[\leadsto t \cdot \left(\frac{z}{a} \cdot -4.5\right) \]
    6. Applied rewrites50.9%

      \[\leadsto t \cdot \color{blue}{\left(\frac{z}{a} \cdot -4.5\right)} \]
    7. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto t \cdot \left(\frac{z}{a} \cdot \color{blue}{\frac{-9}{2}}\right) \]
      2. lift-/.f64N/A

        \[\leadsto t \cdot \left(\frac{z}{a} \cdot \frac{-9}{2}\right) \]
      3. mult-flipN/A

        \[\leadsto t \cdot \left(\left(z \cdot \frac{1}{a}\right) \cdot \frac{-9}{2}\right) \]
      4. associate-*l*N/A

        \[\leadsto t \cdot \left(z \cdot \color{blue}{\left(\frac{1}{a} \cdot \frac{-9}{2}\right)}\right) \]
      5. *-commutativeN/A

        \[\leadsto t \cdot \left(\left(\frac{1}{a} \cdot \frac{-9}{2}\right) \cdot \color{blue}{z}\right) \]
      6. lower-*.f64N/A

        \[\leadsto t \cdot \left(\left(\frac{1}{a} \cdot \frac{-9}{2}\right) \cdot \color{blue}{z}\right) \]
      7. associate-*l/N/A

        \[\leadsto t \cdot \left(\frac{1 \cdot \frac{-9}{2}}{a} \cdot z\right) \]
      8. metadata-evalN/A

        \[\leadsto t \cdot \left(\frac{\frac{-9}{2}}{a} \cdot z\right) \]
      9. lower-/.f6450.9%

        \[\leadsto t \cdot \left(\frac{-4.5}{a} \cdot z\right) \]
    8. Applied rewrites50.9%

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

Alternative 7: 93.0% accurate, 0.5× speedup?

\[\begin{array}{l} \mathbf{if}\;\left(\mathsf{min}\left(z, t\right) \cdot 9\right) \cdot \mathsf{max}\left(z, t\right) \leq 5 \cdot 10^{+282}:\\ \;\;\;\;\frac{\mathsf{fma}\left(y, x, \left(-9 \cdot \mathsf{max}\left(z, t\right)\right) \cdot \mathsf{min}\left(z, t\right)\right)}{a + a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{max}\left(z, t\right) \cdot \left(\frac{-4.5}{a} \cdot \mathsf{min}\left(z, t\right)\right)\\ \end{array} \]
(FPCore (x y z t a)
 :precision binary64
 (if (<= (* (* (fmin z t) 9.0) (fmax z t)) 5e+282)
   (/ (fma y x (* (* -9.0 (fmax z t)) (fmin z t))) (+ a a))
   (* (fmax z t) (* (/ -4.5 a) (fmin z t)))))
double code(double x, double y, double z, double t, double a) {
	double tmp;
	if (((fmin(z, t) * 9.0) * fmax(z, t)) <= 5e+282) {
		tmp = fma(y, x, ((-9.0 * fmax(z, t)) * fmin(z, t))) / (a + a);
	} else {
		tmp = fmax(z, t) * ((-4.5 / a) * fmin(z, t));
	}
	return tmp;
}
function code(x, y, z, t, a)
	tmp = 0.0
	if (Float64(Float64(fmin(z, t) * 9.0) * fmax(z, t)) <= 5e+282)
		tmp = Float64(fma(y, x, Float64(Float64(-9.0 * fmax(z, t)) * fmin(z, t))) / Float64(a + a));
	else
		tmp = Float64(fmax(z, t) * Float64(Float64(-4.5 / a) * fmin(z, t)));
	end
	return tmp
end
code[x_, y_, z_, t_, a_] := If[LessEqual[N[(N[(N[Min[z, t], $MachinePrecision] * 9.0), $MachinePrecision] * N[Max[z, t], $MachinePrecision]), $MachinePrecision], 5e+282], N[(N[(y * x + N[(N[(-9.0 * N[Max[z, t], $MachinePrecision]), $MachinePrecision] * N[Min[z, t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision], N[(N[Max[z, t], $MachinePrecision] * N[(N[(-4.5 / a), $MachinePrecision] * N[Min[z, t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left(\mathsf{min}\left(z, t\right) \cdot 9\right) \cdot \mathsf{max}\left(z, t\right) \leq 5 \cdot 10^{+282}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y, x, \left(-9 \cdot \mathsf{max}\left(z, t\right)\right) \cdot \mathsf{min}\left(z, t\right)\right)}{a + a}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{max}\left(z, t\right) \cdot \left(\frac{-4.5}{a} \cdot \mathsf{min}\left(z, t\right)\right)\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 (*.f64 z #s(literal 9 binary64)) t) < 4.9999999999999998e282

    1. Initial program 91.2%

      \[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2} \]
    2. Step-by-step derivation
      1. lift--.f64N/A

        \[\leadsto \frac{\color{blue}{x \cdot y - \left(z \cdot 9\right) \cdot t}}{a \cdot 2} \]
      2. sub-flipN/A

        \[\leadsto \frac{\color{blue}{x \cdot y + \left(\mathsf{neg}\left(\left(z \cdot 9\right) \cdot t\right)\right)}}{a \cdot 2} \]
      3. +-commutativeN/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(\left(z \cdot 9\right) \cdot t\right)\right) + x \cdot y}}{a \cdot 2} \]
      4. lift-*.f64N/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(\color{blue}{\left(z \cdot 9\right) \cdot t}\right)\right) + x \cdot y}{a \cdot 2} \]
      5. *-commutativeN/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(\color{blue}{t \cdot \left(z \cdot 9\right)}\right)\right) + x \cdot y}{a \cdot 2} \]
      6. lift-*.f64N/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(t \cdot \color{blue}{\left(z \cdot 9\right)}\right)\right) + x \cdot y}{a \cdot 2} \]
      7. associate-*r*N/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(\color{blue}{\left(t \cdot z\right) \cdot 9}\right)\right) + x \cdot y}{a \cdot 2} \]
      8. distribute-rgt-neg-inN/A

        \[\leadsto \frac{\color{blue}{\left(t \cdot z\right) \cdot \left(\mathsf{neg}\left(9\right)\right)} + x \cdot y}{a \cdot 2} \]
      9. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(t \cdot z, \mathsf{neg}\left(9\right), x \cdot y\right)}}{a \cdot 2} \]
      10. lower-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{t \cdot z}, \mathsf{neg}\left(9\right), x \cdot y\right)}{a \cdot 2} \]
      11. metadata-eval91.3%

        \[\leadsto \frac{\mathsf{fma}\left(t \cdot z, \color{blue}{-9}, x \cdot y\right)}{a \cdot 2} \]
      12. lift-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(t \cdot z, -9, \color{blue}{x \cdot y}\right)}{a \cdot 2} \]
      13. *-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(t \cdot z, -9, \color{blue}{y \cdot x}\right)}{a \cdot 2} \]
      14. lower-*.f6491.3%

        \[\leadsto \frac{\mathsf{fma}\left(t \cdot z, -9, \color{blue}{y \cdot x}\right)}{a \cdot 2} \]
      15. lift-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(t \cdot z, -9, y \cdot x\right)}{\color{blue}{a \cdot 2}} \]
      16. *-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(t \cdot z, -9, y \cdot x\right)}{\color{blue}{2 \cdot a}} \]
      17. count-2-revN/A

        \[\leadsto \frac{\mathsf{fma}\left(t \cdot z, -9, y \cdot x\right)}{\color{blue}{a + a}} \]
      18. lower-+.f6491.3%

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(t \cdot z, -9, y \cdot x\right)}{a + a}} \]
    4. Step-by-step derivation
      1. lift-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\left(t \cdot z\right) \cdot -9 + y \cdot x}}{a + a} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{\left(t \cdot z\right) \cdot -9 + \color{blue}{y \cdot x}}{a + a} \]
      3. *-commutativeN/A

        \[\leadsto \frac{\left(t \cdot z\right) \cdot -9 + \color{blue}{x \cdot y}}{a + a} \]
      4. lift-*.f64N/A

        \[\leadsto \frac{\left(t \cdot z\right) \cdot -9 + \color{blue}{x \cdot y}}{a + a} \]
      5. +-commutativeN/A

        \[\leadsto \frac{\color{blue}{x \cdot y + \left(t \cdot z\right) \cdot -9}}{a + a} \]
      6. lift-*.f64N/A

        \[\leadsto \frac{x \cdot y + \color{blue}{\left(t \cdot z\right)} \cdot -9}{a + a} \]
      7. associate-*l*N/A

        \[\leadsto \frac{x \cdot y + \color{blue}{t \cdot \left(z \cdot -9\right)}}{a + a} \]
      8. *-commutativeN/A

        \[\leadsto \frac{x \cdot y + \color{blue}{\left(z \cdot -9\right) \cdot t}}{a + a} \]
      9. metadata-evalN/A

        \[\leadsto \frac{x \cdot y + \left(z \cdot \color{blue}{\left(\mathsf{neg}\left(9\right)\right)}\right) \cdot t}{a + a} \]
      10. distribute-rgt-neg-inN/A

        \[\leadsto \frac{x \cdot y + \color{blue}{\left(\mathsf{neg}\left(z \cdot 9\right)\right)} \cdot t}{a + a} \]
      11. distribute-lft-neg-inN/A

        \[\leadsto \frac{x \cdot y + \color{blue}{\left(\mathsf{neg}\left(\left(z \cdot 9\right) \cdot t\right)\right)}}{a + a} \]
      12. *-commutativeN/A

        \[\leadsto \frac{x \cdot y + \left(\mathsf{neg}\left(\color{blue}{t \cdot \left(z \cdot 9\right)}\right)\right)}{a + a} \]
      13. distribute-lft-neg-inN/A

        \[\leadsto \frac{x \cdot y + \color{blue}{\left(\mathsf{neg}\left(t\right)\right) \cdot \left(z \cdot 9\right)}}{a + a} \]
      14. fp-cancel-sub-sign-invN/A

        \[\leadsto \frac{\color{blue}{x \cdot y - t \cdot \left(z \cdot 9\right)}}{a + a} \]
      15. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{x \cdot y} - t \cdot \left(z \cdot 9\right)}{a + a} \]
      16. *-commutativeN/A

        \[\leadsto \frac{x \cdot y - \color{blue}{\left(z \cdot 9\right) \cdot t}}{a + a} \]
      17. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{x \cdot y} - \left(z \cdot 9\right) \cdot t}{a + a} \]
      18. associate-*l*N/A

        \[\leadsto \frac{x \cdot y - \color{blue}{z \cdot \left(9 \cdot t\right)}}{a + a} \]
      19. fp-cancel-sub-sign-invN/A

        \[\leadsto \frac{\color{blue}{x \cdot y + \left(\mathsf{neg}\left(z\right)\right) \cdot \left(9 \cdot t\right)}}{a + a} \]
      20. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{x \cdot y} + \left(\mathsf{neg}\left(z\right)\right) \cdot \left(9 \cdot t\right)}{a + a} \]
      21. *-commutativeN/A

        \[\leadsto \frac{\color{blue}{y \cdot x} + \left(\mathsf{neg}\left(z\right)\right) \cdot \left(9 \cdot t\right)}{a + a} \]
      22. distribute-lft-neg-inN/A

        \[\leadsto \frac{y \cdot x + \color{blue}{\left(\mathsf{neg}\left(z \cdot \left(9 \cdot t\right)\right)\right)}}{a + a} \]
      23. associate-*l*N/A

        \[\leadsto \frac{y \cdot x + \left(\mathsf{neg}\left(\color{blue}{\left(z \cdot 9\right) \cdot t}\right)\right)}{a + a} \]
      24. distribute-lft-neg-inN/A

        \[\leadsto \frac{y \cdot x + \color{blue}{\left(\mathsf{neg}\left(z \cdot 9\right)\right) \cdot t}}{a + a} \]
      25. distribute-rgt-neg-inN/A

        \[\leadsto \frac{y \cdot x + \color{blue}{\left(z \cdot \left(\mathsf{neg}\left(9\right)\right)\right)} \cdot t}{a + a} \]
      26. metadata-evalN/A

        \[\leadsto \frac{y \cdot x + \left(z \cdot \color{blue}{-9}\right) \cdot t}{a + a} \]
      27. *-commutativeN/A

        \[\leadsto \frac{y \cdot x + \color{blue}{t \cdot \left(z \cdot -9\right)}}{a + a} \]
      28. associate-*l*N/A

        \[\leadsto \frac{y \cdot x + \color{blue}{\left(t \cdot z\right) \cdot -9}}{a + a} \]
      29. lift-*.f64N/A

        \[\leadsto \frac{y \cdot x + \color{blue}{\left(t \cdot z\right)} \cdot -9}{a + a} \]
    5. Applied rewrites91.5%

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(y, x, \left(-9 \cdot t\right) \cdot z\right)}}{a + a} \]

    if 4.9999999999999998e282 < (*.f64 (*.f64 z #s(literal 9 binary64)) t)

    1. Initial program 91.2%

      \[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2} \]
    2. Taylor expanded in x around 0

      \[\leadsto \color{blue}{\frac{-9}{2} \cdot \frac{t \cdot z}{a}} \]
    3. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \frac{-9}{2} \cdot \color{blue}{\frac{t \cdot z}{a}} \]
      2. lower-/.f64N/A

        \[\leadsto \frac{-9}{2} \cdot \frac{t \cdot z}{\color{blue}{a}} \]
      3. lower-*.f6450.3%

        \[\leadsto -4.5 \cdot \frac{t \cdot z}{a} \]
    4. Applied rewrites50.3%

      \[\leadsto \color{blue}{-4.5 \cdot \frac{t \cdot z}{a}} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{-9}{2} \cdot \color{blue}{\frac{t \cdot z}{a}} \]
      2. *-commutativeN/A

        \[\leadsto \frac{t \cdot z}{a} \cdot \color{blue}{\frac{-9}{2}} \]
      3. lift-/.f64N/A

        \[\leadsto \frac{t \cdot z}{a} \cdot \frac{-9}{2} \]
      4. lift-*.f64N/A

        \[\leadsto \frac{t \cdot z}{a} \cdot \frac{-9}{2} \]
      5. associate-/l*N/A

        \[\leadsto \left(t \cdot \frac{z}{a}\right) \cdot \frac{-9}{2} \]
      6. associate-*l*N/A

        \[\leadsto t \cdot \color{blue}{\left(\frac{z}{a} \cdot \frac{-9}{2}\right)} \]
      7. lower-*.f64N/A

        \[\leadsto t \cdot \color{blue}{\left(\frac{z}{a} \cdot \frac{-9}{2}\right)} \]
      8. lower-*.f64N/A

        \[\leadsto t \cdot \left(\frac{z}{a} \cdot \color{blue}{\frac{-9}{2}}\right) \]
      9. lower-/.f6450.9%

        \[\leadsto t \cdot \left(\frac{z}{a} \cdot -4.5\right) \]
    6. Applied rewrites50.9%

      \[\leadsto t \cdot \color{blue}{\left(\frac{z}{a} \cdot -4.5\right)} \]
    7. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto t \cdot \left(\frac{z}{a} \cdot \color{blue}{\frac{-9}{2}}\right) \]
      2. lift-/.f64N/A

        \[\leadsto t \cdot \left(\frac{z}{a} \cdot \frac{-9}{2}\right) \]
      3. mult-flipN/A

        \[\leadsto t \cdot \left(\left(z \cdot \frac{1}{a}\right) \cdot \frac{-9}{2}\right) \]
      4. associate-*l*N/A

        \[\leadsto t \cdot \left(z \cdot \color{blue}{\left(\frac{1}{a} \cdot \frac{-9}{2}\right)}\right) \]
      5. *-commutativeN/A

        \[\leadsto t \cdot \left(\left(\frac{1}{a} \cdot \frac{-9}{2}\right) \cdot \color{blue}{z}\right) \]
      6. lower-*.f64N/A

        \[\leadsto t \cdot \left(\left(\frac{1}{a} \cdot \frac{-9}{2}\right) \cdot \color{blue}{z}\right) \]
      7. associate-*l/N/A

        \[\leadsto t \cdot \left(\frac{1 \cdot \frac{-9}{2}}{a} \cdot z\right) \]
      8. metadata-evalN/A

        \[\leadsto t \cdot \left(\frac{\frac{-9}{2}}{a} \cdot z\right) \]
      9. lower-/.f6450.9%

        \[\leadsto t \cdot \left(\frac{-4.5}{a} \cdot z\right) \]
    8. Applied rewrites50.9%

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

Alternative 8: 74.6% accurate, 0.8× speedup?

\[\begin{array}{l} t_1 := \frac{x}{a + a} \cdot y\\ \mathbf{if}\;x \cdot y \leq -2 \cdot 10^{+27}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \cdot y \leq 10^{+43}:\\ \;\;\;\;-4.5 \cdot \frac{t \cdot z}{a}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \]
(FPCore (x y z t a)
 :precision binary64
 (let* ((t_1 (* (/ x (+ a a)) y)))
   (if (<= (* x y) -2e+27)
     t_1
     (if (<= (* x y) 1e+43) (* -4.5 (/ (* t z) a)) t_1))))
double code(double x, double y, double z, double t, double a) {
	double t_1 = (x / (a + a)) * y;
	double tmp;
	if ((x * y) <= -2e+27) {
		tmp = t_1;
	} else if ((x * y) <= 1e+43) {
		tmp = -4.5 * ((t * z) / a);
	} else {
		tmp = t_1;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, y, z, t, a)
use fmin_fmax_functions
    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) :: t_1
    real(8) :: tmp
    t_1 = (x / (a + a)) * y
    if ((x * y) <= (-2d+27)) then
        tmp = t_1
    else if ((x * y) <= 1d+43) then
        tmp = (-4.5d0) * ((t * z) / a)
    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 t_1 = (x / (a + a)) * y;
	double tmp;
	if ((x * y) <= -2e+27) {
		tmp = t_1;
	} else if ((x * y) <= 1e+43) {
		tmp = -4.5 * ((t * z) / a);
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t, a):
	t_1 = (x / (a + a)) * y
	tmp = 0
	if (x * y) <= -2e+27:
		tmp = t_1
	elif (x * y) <= 1e+43:
		tmp = -4.5 * ((t * z) / a)
	else:
		tmp = t_1
	return tmp
function code(x, y, z, t, a)
	t_1 = Float64(Float64(x / Float64(a + a)) * y)
	tmp = 0.0
	if (Float64(x * y) <= -2e+27)
		tmp = t_1;
	elseif (Float64(x * y) <= 1e+43)
		tmp = Float64(-4.5 * Float64(Float64(t * z) / a));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a)
	t_1 = (x / (a + a)) * y;
	tmp = 0.0;
	if ((x * y) <= -2e+27)
		tmp = t_1;
	elseif ((x * y) <= 1e+43)
		tmp = -4.5 * ((t * z) / a);
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(x / N[(a + a), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[N[(x * y), $MachinePrecision], -2e+27], t$95$1, If[LessEqual[N[(x * y), $MachinePrecision], 1e+43], N[(-4.5 * N[(N[(t * z), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
t_1 := \frac{x}{a + a} \cdot y\\
\mathbf{if}\;x \cdot y \leq -2 \cdot 10^{+27}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \cdot y \leq 10^{+43}:\\
\;\;\;\;-4.5 \cdot \frac{t \cdot z}{a}\\

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


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

    1. Initial program 91.2%

      \[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2} \]
    2. Taylor expanded in x around inf

      \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{x \cdot y}{a}} \]
    3. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \frac{1}{2} \cdot \color{blue}{\frac{x \cdot y}{a}} \]
      2. lower-/.f64N/A

        \[\leadsto \frac{1}{2} \cdot \frac{x \cdot y}{\color{blue}{a}} \]
      3. lower-*.f6451.3%

        \[\leadsto 0.5 \cdot \frac{x \cdot y}{a} \]
    4. Applied rewrites51.3%

      \[\leadsto \color{blue}{0.5 \cdot \frac{x \cdot y}{a}} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{1}{2} \cdot \color{blue}{\frac{x \cdot y}{a}} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{1}{2} \cdot \frac{x \cdot y}{\color{blue}{a}} \]
      3. associate-*r/N/A

        \[\leadsto \frac{\frac{1}{2} \cdot \left(x \cdot y\right)}{\color{blue}{a}} \]
      4. associate-*l/N/A

        \[\leadsto \frac{\frac{1}{2}}{a} \cdot \color{blue}{\left(x \cdot y\right)} \]
      5. lift-/.f64N/A

        \[\leadsto \frac{\frac{1}{2}}{a} \cdot \left(\color{blue}{x} \cdot y\right) \]
      6. lift-*.f64N/A

        \[\leadsto \frac{\frac{1}{2}}{a} \cdot \left(x \cdot \color{blue}{y}\right) \]
      7. associate-*l*N/A

        \[\leadsto \left(\frac{\frac{1}{2}}{a} \cdot x\right) \cdot \color{blue}{y} \]
      8. lift-*.f64N/A

        \[\leadsto \left(\frac{\frac{1}{2}}{a} \cdot x\right) \cdot y \]
      9. lower-*.f6452.1%

        \[\leadsto \left(\frac{0.5}{a} \cdot x\right) \cdot \color{blue}{y} \]
      10. lift-/.f64N/A

        \[\leadsto \left(\frac{\frac{1}{2}}{a} \cdot x\right) \cdot y \]
      11. metadata-evalN/A

        \[\leadsto \left(\frac{\frac{1}{2}}{a} \cdot x\right) \cdot y \]
      12. associate-/r*N/A

        \[\leadsto \left(\frac{1}{2 \cdot a} \cdot x\right) \cdot y \]
      13. count-2N/A

        \[\leadsto \left(\frac{1}{a + a} \cdot x\right) \cdot y \]
      14. lift-+.f64N/A

        \[\leadsto \left(\frac{1}{a + a} \cdot x\right) \cdot y \]
      15. lower-*.f64N/A

        \[\leadsto \left(\frac{1}{a + a} \cdot x\right) \cdot y \]
      16. *-commutativeN/A

        \[\leadsto \left(x \cdot \frac{1}{a + a}\right) \cdot y \]
      17. mult-flip-revN/A

        \[\leadsto \frac{x}{a + a} \cdot y \]
      18. lower-/.f6452.2%

        \[\leadsto \frac{x}{a + a} \cdot y \]
    6. Applied rewrites52.2%

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

    if -2e27 < (*.f64 x y) < 1e43

    1. Initial program 91.2%

      \[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2} \]
    2. Taylor expanded in x around 0

      \[\leadsto \color{blue}{\frac{-9}{2} \cdot \frac{t \cdot z}{a}} \]
    3. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \frac{-9}{2} \cdot \color{blue}{\frac{t \cdot z}{a}} \]
      2. lower-/.f64N/A

        \[\leadsto \frac{-9}{2} \cdot \frac{t \cdot z}{\color{blue}{a}} \]
      3. lower-*.f6450.3%

        \[\leadsto -4.5 \cdot \frac{t \cdot z}{a} \]
    4. Applied rewrites50.3%

      \[\leadsto \color{blue}{-4.5 \cdot \frac{t \cdot z}{a}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 9: 73.2% accurate, 0.5× speedup?

\[\begin{array}{l} t_1 := \mathsf{min}\left(x, y\right) \cdot \mathsf{max}\left(x, y\right)\\ \mathbf{if}\;t\_1 \leq -2 \cdot 10^{+59}:\\ \;\;\;\;\frac{\mathsf{min}\left(x, y\right)}{a + a} \cdot \mathsf{max}\left(x, y\right)\\ \mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-5}:\\ \;\;\;\;-4.5 \cdot \left(\frac{z}{a} \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{max}\left(x, y\right)}{a + a} \cdot \mathsf{min}\left(x, y\right)\\ \end{array} \]
(FPCore (x y z t a)
 :precision binary64
 (let* ((t_1 (* (fmin x y) (fmax x y))))
   (if (<= t_1 -2e+59)
     (* (/ (fmin x y) (+ a a)) (fmax x y))
     (if (<= t_1 5e-5)
       (* -4.5 (* (/ z a) t))
       (* (/ (fmax x y) (+ a a)) (fmin x y))))))
double code(double x, double y, double z, double t, double a) {
	double t_1 = fmin(x, y) * fmax(x, y);
	double tmp;
	if (t_1 <= -2e+59) {
		tmp = (fmin(x, y) / (a + a)) * fmax(x, y);
	} else if (t_1 <= 5e-5) {
		tmp = -4.5 * ((z / a) * t);
	} else {
		tmp = (fmax(x, y) / (a + a)) * fmin(x, y);
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, y, z, t, a)
use fmin_fmax_functions
    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) :: t_1
    real(8) :: tmp
    t_1 = fmin(x, y) * fmax(x, y)
    if (t_1 <= (-2d+59)) then
        tmp = (fmin(x, y) / (a + a)) * fmax(x, y)
    else if (t_1 <= 5d-5) then
        tmp = (-4.5d0) * ((z / a) * t)
    else
        tmp = (fmax(x, y) / (a + a)) * fmin(x, y)
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
	double t_1 = fmin(x, y) * fmax(x, y);
	double tmp;
	if (t_1 <= -2e+59) {
		tmp = (fmin(x, y) / (a + a)) * fmax(x, y);
	} else if (t_1 <= 5e-5) {
		tmp = -4.5 * ((z / a) * t);
	} else {
		tmp = (fmax(x, y) / (a + a)) * fmin(x, y);
	}
	return tmp;
}
def code(x, y, z, t, a):
	t_1 = fmin(x, y) * fmax(x, y)
	tmp = 0
	if t_1 <= -2e+59:
		tmp = (fmin(x, y) / (a + a)) * fmax(x, y)
	elif t_1 <= 5e-5:
		tmp = -4.5 * ((z / a) * t)
	else:
		tmp = (fmax(x, y) / (a + a)) * fmin(x, y)
	return tmp
function code(x, y, z, t, a)
	t_1 = Float64(fmin(x, y) * fmax(x, y))
	tmp = 0.0
	if (t_1 <= -2e+59)
		tmp = Float64(Float64(fmin(x, y) / Float64(a + a)) * fmax(x, y));
	elseif (t_1 <= 5e-5)
		tmp = Float64(-4.5 * Float64(Float64(z / a) * t));
	else
		tmp = Float64(Float64(fmax(x, y) / Float64(a + a)) * fmin(x, y));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a)
	t_1 = min(x, y) * max(x, y);
	tmp = 0.0;
	if (t_1 <= -2e+59)
		tmp = (min(x, y) / (a + a)) * max(x, y);
	elseif (t_1 <= 5e-5)
		tmp = -4.5 * ((z / a) * t);
	else
		tmp = (max(x, y) / (a + a)) * min(x, y);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[Min[x, y], $MachinePrecision] * N[Max[x, y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -2e+59], N[(N[(N[Min[x, y], $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision] * N[Max[x, y], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e-5], N[(-4.5 * N[(N[(z / a), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision], N[(N[(N[Max[x, y], $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision] * N[Min[x, y], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
t_1 := \mathsf{min}\left(x, y\right) \cdot \mathsf{max}\left(x, y\right)\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{+59}:\\
\;\;\;\;\frac{\mathsf{min}\left(x, y\right)}{a + a} \cdot \mathsf{max}\left(x, y\right)\\

\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-5}:\\
\;\;\;\;-4.5 \cdot \left(\frac{z}{a} \cdot t\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{max}\left(x, y\right)}{a + a} \cdot \mathsf{min}\left(x, y\right)\\


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

    1. Initial program 91.2%

      \[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2} \]
    2. Taylor expanded in x around inf

      \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{x \cdot y}{a}} \]
    3. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \frac{1}{2} \cdot \color{blue}{\frac{x \cdot y}{a}} \]
      2. lower-/.f64N/A

        \[\leadsto \frac{1}{2} \cdot \frac{x \cdot y}{\color{blue}{a}} \]
      3. lower-*.f6451.3%

        \[\leadsto 0.5 \cdot \frac{x \cdot y}{a} \]
    4. Applied rewrites51.3%

      \[\leadsto \color{blue}{0.5 \cdot \frac{x \cdot y}{a}} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{1}{2} \cdot \color{blue}{\frac{x \cdot y}{a}} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{1}{2} \cdot \frac{x \cdot y}{\color{blue}{a}} \]
      3. associate-*r/N/A

        \[\leadsto \frac{\frac{1}{2} \cdot \left(x \cdot y\right)}{\color{blue}{a}} \]
      4. associate-*l/N/A

        \[\leadsto \frac{\frac{1}{2}}{a} \cdot \color{blue}{\left(x \cdot y\right)} \]
      5. lift-/.f64N/A

        \[\leadsto \frac{\frac{1}{2}}{a} \cdot \left(\color{blue}{x} \cdot y\right) \]
      6. lift-*.f64N/A

        \[\leadsto \frac{\frac{1}{2}}{a} \cdot \left(x \cdot \color{blue}{y}\right) \]
      7. associate-*l*N/A

        \[\leadsto \left(\frac{\frac{1}{2}}{a} \cdot x\right) \cdot \color{blue}{y} \]
      8. lift-*.f64N/A

        \[\leadsto \left(\frac{\frac{1}{2}}{a} \cdot x\right) \cdot y \]
      9. lower-*.f6452.1%

        \[\leadsto \left(\frac{0.5}{a} \cdot x\right) \cdot \color{blue}{y} \]
      10. lift-/.f64N/A

        \[\leadsto \left(\frac{\frac{1}{2}}{a} \cdot x\right) \cdot y \]
      11. metadata-evalN/A

        \[\leadsto \left(\frac{\frac{1}{2}}{a} \cdot x\right) \cdot y \]
      12. associate-/r*N/A

        \[\leadsto \left(\frac{1}{2 \cdot a} \cdot x\right) \cdot y \]
      13. count-2N/A

        \[\leadsto \left(\frac{1}{a + a} \cdot x\right) \cdot y \]
      14. lift-+.f64N/A

        \[\leadsto \left(\frac{1}{a + a} \cdot x\right) \cdot y \]
      15. lower-*.f64N/A

        \[\leadsto \left(\frac{1}{a + a} \cdot x\right) \cdot y \]
      16. *-commutativeN/A

        \[\leadsto \left(x \cdot \frac{1}{a + a}\right) \cdot y \]
      17. mult-flip-revN/A

        \[\leadsto \frac{x}{a + a} \cdot y \]
      18. lower-/.f6452.2%

        \[\leadsto \frac{x}{a + a} \cdot y \]
    6. Applied rewrites52.2%

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

    if -1.9999999999999999e59 < (*.f64 x y) < 5.0000000000000002e-5

    1. Initial program 91.2%

      \[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2} \]
    2. Taylor expanded in x around 0

      \[\leadsto \color{blue}{\frac{-9}{2} \cdot \frac{t \cdot z}{a}} \]
    3. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \frac{-9}{2} \cdot \color{blue}{\frac{t \cdot z}{a}} \]
      2. lower-/.f64N/A

        \[\leadsto \frac{-9}{2} \cdot \frac{t \cdot z}{\color{blue}{a}} \]
      3. lower-*.f6450.3%

        \[\leadsto -4.5 \cdot \frac{t \cdot z}{a} \]
    4. Applied rewrites50.3%

      \[\leadsto \color{blue}{-4.5 \cdot \frac{t \cdot z}{a}} \]
    5. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \frac{-9}{2} \cdot \frac{t \cdot z}{\color{blue}{a}} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{-9}{2} \cdot \frac{t \cdot z}{a} \]
      3. associate-/l*N/A

        \[\leadsto \frac{-9}{2} \cdot \left(t \cdot \color{blue}{\frac{z}{a}}\right) \]
      4. *-commutativeN/A

        \[\leadsto \frac{-9}{2} \cdot \left(\frac{z}{a} \cdot \color{blue}{t}\right) \]
      5. lower-*.f64N/A

        \[\leadsto \frac{-9}{2} \cdot \left(\frac{z}{a} \cdot \color{blue}{t}\right) \]
      6. lower-/.f6450.9%

        \[\leadsto -4.5 \cdot \left(\frac{z}{a} \cdot t\right) \]
    6. Applied rewrites50.9%

      \[\leadsto -4.5 \cdot \left(\frac{z}{a} \cdot \color{blue}{t}\right) \]

    if 5.0000000000000002e-5 < (*.f64 x y)

    1. Initial program 91.2%

      \[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2} \]
    2. Taylor expanded in x around inf

      \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{x \cdot y}{a}} \]
    3. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \frac{1}{2} \cdot \color{blue}{\frac{x \cdot y}{a}} \]
      2. lower-/.f64N/A

        \[\leadsto \frac{1}{2} \cdot \frac{x \cdot y}{\color{blue}{a}} \]
      3. lower-*.f6451.3%

        \[\leadsto 0.5 \cdot \frac{x \cdot y}{a} \]
    4. Applied rewrites51.3%

      \[\leadsto \color{blue}{0.5 \cdot \frac{x \cdot y}{a}} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{1}{2} \cdot \color{blue}{\frac{x \cdot y}{a}} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{1}{2} \cdot \frac{x \cdot y}{\color{blue}{a}} \]
      3. associate-*r/N/A

        \[\leadsto \frac{\frac{1}{2} \cdot \left(x \cdot y\right)}{\color{blue}{a}} \]
      4. *-commutativeN/A

        \[\leadsto \frac{\left(x \cdot y\right) \cdot \frac{1}{2}}{a} \]
      5. metadata-evalN/A

        \[\leadsto \frac{\left(x \cdot y\right) \cdot \frac{1}{2}}{a} \]
      6. mult-flip-revN/A

        \[\leadsto \frac{\frac{x \cdot y}{2}}{a} \]
      7. associate-/r*N/A

        \[\leadsto \frac{x \cdot y}{\color{blue}{2 \cdot a}} \]
      8. lift-*.f64N/A

        \[\leadsto \frac{x \cdot y}{\color{blue}{2} \cdot a} \]
      9. count-2N/A

        \[\leadsto \frac{x \cdot y}{a + \color{blue}{a}} \]
      10. lift-+.f64N/A

        \[\leadsto \frac{x \cdot y}{a + \color{blue}{a}} \]
      11. associate-/l*N/A

        \[\leadsto x \cdot \color{blue}{\frac{y}{a + a}} \]
      12. lift-/.f64N/A

        \[\leadsto x \cdot \frac{y}{\color{blue}{a + a}} \]
      13. *-commutativeN/A

        \[\leadsto \frac{y}{a + a} \cdot \color{blue}{x} \]
      14. lower-*.f6452.3%

        \[\leadsto \frac{y}{a + a} \cdot \color{blue}{x} \]
    6. Applied rewrites52.3%

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

Alternative 10: 52.1% accurate, 1.2× speedup?

\[\frac{\mathsf{min}\left(x, y\right)}{a + a} \cdot \mathsf{max}\left(x, y\right) \]
(FPCore (x y z t a) :precision binary64 (* (/ (fmin x y) (+ a a)) (fmax x y)))
double code(double x, double y, double z, double t, double a) {
	return (fmin(x, y) / (a + a)) * fmax(x, y);
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, y, z, t, a)
use fmin_fmax_functions
    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
    code = (fmin(x, y) / (a + a)) * fmax(x, y)
end function
public static double code(double x, double y, double z, double t, double a) {
	return (fmin(x, y) / (a + a)) * fmax(x, y);
}
def code(x, y, z, t, a):
	return (fmin(x, y) / (a + a)) * fmax(x, y)
function code(x, y, z, t, a)
	return Float64(Float64(fmin(x, y) / Float64(a + a)) * fmax(x, y))
end
function tmp = code(x, y, z, t, a)
	tmp = (min(x, y) / (a + a)) * max(x, y);
end
code[x_, y_, z_, t_, a_] := N[(N[(N[Min[x, y], $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision] * N[Max[x, y], $MachinePrecision]), $MachinePrecision]
\frac{\mathsf{min}\left(x, y\right)}{a + a} \cdot \mathsf{max}\left(x, y\right)
Derivation
  1. Initial program 91.2%

    \[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2} \]
  2. Taylor expanded in x around inf

    \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{x \cdot y}{a}} \]
  3. Step-by-step derivation
    1. lower-*.f64N/A

      \[\leadsto \frac{1}{2} \cdot \color{blue}{\frac{x \cdot y}{a}} \]
    2. lower-/.f64N/A

      \[\leadsto \frac{1}{2} \cdot \frac{x \cdot y}{\color{blue}{a}} \]
    3. lower-*.f6451.3%

      \[\leadsto 0.5 \cdot \frac{x \cdot y}{a} \]
  4. Applied rewrites51.3%

    \[\leadsto \color{blue}{0.5 \cdot \frac{x \cdot y}{a}} \]
  5. Step-by-step derivation
    1. lift-*.f64N/A

      \[\leadsto \frac{1}{2} \cdot \color{blue}{\frac{x \cdot y}{a}} \]
    2. lift-/.f64N/A

      \[\leadsto \frac{1}{2} \cdot \frac{x \cdot y}{\color{blue}{a}} \]
    3. associate-*r/N/A

      \[\leadsto \frac{\frac{1}{2} \cdot \left(x \cdot y\right)}{\color{blue}{a}} \]
    4. associate-*l/N/A

      \[\leadsto \frac{\frac{1}{2}}{a} \cdot \color{blue}{\left(x \cdot y\right)} \]
    5. lift-/.f64N/A

      \[\leadsto \frac{\frac{1}{2}}{a} \cdot \left(\color{blue}{x} \cdot y\right) \]
    6. lift-*.f64N/A

      \[\leadsto \frac{\frac{1}{2}}{a} \cdot \left(x \cdot \color{blue}{y}\right) \]
    7. associate-*l*N/A

      \[\leadsto \left(\frac{\frac{1}{2}}{a} \cdot x\right) \cdot \color{blue}{y} \]
    8. lift-*.f64N/A

      \[\leadsto \left(\frac{\frac{1}{2}}{a} \cdot x\right) \cdot y \]
    9. lower-*.f6452.1%

      \[\leadsto \left(\frac{0.5}{a} \cdot x\right) \cdot \color{blue}{y} \]
    10. lift-/.f64N/A

      \[\leadsto \left(\frac{\frac{1}{2}}{a} \cdot x\right) \cdot y \]
    11. metadata-evalN/A

      \[\leadsto \left(\frac{\frac{1}{2}}{a} \cdot x\right) \cdot y \]
    12. associate-/r*N/A

      \[\leadsto \left(\frac{1}{2 \cdot a} \cdot x\right) \cdot y \]
    13. count-2N/A

      \[\leadsto \left(\frac{1}{a + a} \cdot x\right) \cdot y \]
    14. lift-+.f64N/A

      \[\leadsto \left(\frac{1}{a + a} \cdot x\right) \cdot y \]
    15. lower-*.f64N/A

      \[\leadsto \left(\frac{1}{a + a} \cdot x\right) \cdot y \]
    16. *-commutativeN/A

      \[\leadsto \left(x \cdot \frac{1}{a + a}\right) \cdot y \]
    17. mult-flip-revN/A

      \[\leadsto \frac{x}{a + a} \cdot y \]
    18. lower-/.f6452.2%

      \[\leadsto \frac{x}{a + a} \cdot y \]
  6. Applied rewrites52.2%

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

Reproduce

?
herbie shell --seed 2025205 
(FPCore (x y z t a)
  :name "Diagrams.Solve.Polynomial:cubForm  from diagrams-solve-0.1, I"
  :precision binary64
  (/ (- (* x y) (* (* z 9.0) t)) (* a 2.0)))