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

Percentage Accurate: 90.9% → 96.7%
Time: 3.5s
Alternatives: 8
Speedup: 0.2×

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 8 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: 90.9% 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: 96.7% accurate, 0.0× speedup?

\[\begin{array}{l} t_1 := \frac{-z}{a} \cdot \left(t \cdot 4.5\right) + \frac{\mathsf{min}\left(x, y\right)}{a + a} \cdot \mathsf{max}\left(x, y\right)\\ t_2 := \mathsf{min}\left(x, y\right) \cdot \mathsf{max}\left(x, y\right) - \left(z \cdot 9\right) \cdot t\\ \mathbf{if}\;t\_2 \leq -\infty:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_2 \leq 5 \cdot 10^{+306}:\\ \;\;\;\;\frac{\mathsf{max}\left(x, y\right) \cdot \mathsf{min}\left(x, y\right) - 9 \cdot \left(z \cdot t\right)}{a + a}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \]
(FPCore (x y z t a)
  :precision binary64
  (let* ((t_1
        (+
         (* (/ (- z) a) (* t 4.5))
         (* (/ (fmin x y) (+ a a)) (fmax x y))))
       (t_2 (- (* (fmin x y) (fmax x y)) (* (* z 9.0) t))))
  (if (<= t_2 (- INFINITY))
    t_1
    (if (<= t_2 5e+306)
      (/ (- (* (fmax x y) (fmin x y)) (* 9.0 (* z t))) (+ a a))
      t_1))))
double code(double x, double y, double z, double t, double a) {
	double t_1 = ((-z / a) * (t * 4.5)) + ((fmin(x, y) / (a + a)) * fmax(x, y));
	double t_2 = (fmin(x, y) * fmax(x, y)) - ((z * 9.0) * t);
	double tmp;
	if (t_2 <= -((double) INFINITY)) {
		tmp = t_1;
	} else if (t_2 <= 5e+306) {
		tmp = ((fmax(x, y) * fmin(x, y)) - (9.0 * (z * t))) / (a + a);
	} else {
		tmp = t_1;
	}
	return tmp;
}
public static double code(double x, double y, double z, double t, double a) {
	double t_1 = ((-z / a) * (t * 4.5)) + ((fmin(x, y) / (a + a)) * fmax(x, y));
	double t_2 = (fmin(x, y) * fmax(x, y)) - ((z * 9.0) * t);
	double tmp;
	if (t_2 <= -Double.POSITIVE_INFINITY) {
		tmp = t_1;
	} else if (t_2 <= 5e+306) {
		tmp = ((fmax(x, y) * fmin(x, y)) - (9.0 * (z * t))) / (a + a);
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t, a):
	t_1 = ((-z / a) * (t * 4.5)) + ((fmin(x, y) / (a + a)) * fmax(x, y))
	t_2 = (fmin(x, y) * fmax(x, y)) - ((z * 9.0) * t)
	tmp = 0
	if t_2 <= -math.inf:
		tmp = t_1
	elif t_2 <= 5e+306:
		tmp = ((fmax(x, y) * fmin(x, y)) - (9.0 * (z * t))) / (a + a)
	else:
		tmp = t_1
	return tmp
function code(x, y, z, t, a)
	t_1 = Float64(Float64(Float64(Float64(-z) / a) * Float64(t * 4.5)) + Float64(Float64(fmin(x, y) / Float64(a + a)) * fmax(x, y)))
	t_2 = Float64(Float64(fmin(x, y) * fmax(x, y)) - Float64(Float64(z * 9.0) * t))
	tmp = 0.0
	if (t_2 <= Float64(-Inf))
		tmp = t_1;
	elseif (t_2 <= 5e+306)
		tmp = Float64(Float64(Float64(fmax(x, y) * fmin(x, y)) - Float64(9.0 * Float64(z * t))) / Float64(a + a));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a)
	t_1 = ((-z / a) * (t * 4.5)) + ((min(x, y) / (a + a)) * max(x, y));
	t_2 = (min(x, y) * max(x, y)) - ((z * 9.0) * t);
	tmp = 0.0;
	if (t_2 <= -Inf)
		tmp = t_1;
	elseif (t_2 <= 5e+306)
		tmp = ((max(x, y) * min(x, y)) - (9.0 * (z * t))) / (a + a);
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(N[((-z) / a), $MachinePrecision] * N[(t * 4.5), $MachinePrecision]), $MachinePrecision] + N[(N[(N[Min[x, y], $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision] * N[Max[x, y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Min[x, y], $MachinePrecision] * N[Max[x, y], $MachinePrecision]), $MachinePrecision] - N[(N[(z * 9.0), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], t$95$1, If[LessEqual[t$95$2, 5e+306], N[(N[(N[(N[Max[x, y], $MachinePrecision] * N[Min[x, y], $MachinePrecision]), $MachinePrecision] - N[(9.0 * N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
t_1 := \frac{-z}{a} \cdot \left(t \cdot 4.5\right) + \frac{\mathsf{min}\left(x, y\right)}{a + a} \cdot \mathsf{max}\left(x, y\right)\\
t_2 := \mathsf{min}\left(x, y\right) \cdot \mathsf{max}\left(x, y\right) - \left(z \cdot 9\right) \cdot t\\
\mathbf{if}\;t\_2 \leq -\infty:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{+306}:\\
\;\;\;\;\frac{\mathsf{max}\left(x, y\right) \cdot \mathsf{min}\left(x, y\right) - 9 \cdot \left(z \cdot t\right)}{a + a}\\

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


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (*.f64 x y) (*.f64 (*.f64 z #s(literal 9 binary64)) t)) < -inf.0 or 4.9999999999999999e306 < (-.f64 (*.f64 x y) (*.f64 (*.f64 z #s(literal 9 binary64)) t))

    1. Initial program 90.9%

      \[\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. lower-+.f64N/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}} \]
      7. distribute-neg-fracN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -inf.0 < (-.f64 (*.f64 x y) (*.f64 (*.f64 z #s(literal 9 binary64)) t)) < 4.9999999999999999e306

    1. Initial program 90.9%

      \[\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{x \cdot y - \color{blue}{\left(z \cdot 9\right) \cdot t}}{a \cdot 2} \]
      2. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{y \cdot x - t \cdot \left(9 \cdot z\right)}{\color{blue}{a + a}} \]
      19. lift-/.f6490.9%

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

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

Alternative 2: 94.8% accurate, 0.1× speedup?

\[\begin{array}{l} t_1 := \mathsf{min}\left(x, y\right) \cdot \mathsf{max}\left(x, y\right)\\ \mathbf{if}\;t\_1 \leq -5 \cdot 10^{+273}:\\ \;\;\;\;\frac{\mathsf{max}\left(x, y\right)}{a + a} \cdot \mathsf{min}\left(x, y\right)\\ \mathbf{elif}\;t\_1 \leq 10^{+268}:\\ \;\;\;\;\frac{\mathsf{max}\left(x, y\right) \cdot \mathsf{min}\left(x, y\right) - 9 \cdot \left(z \cdot t\right)}{a + a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{min}\left(x, y\right)}{a + a} \cdot \mathsf{max}\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 -5e+273)
    (* (/ (fmax x y) (+ a a)) (fmin x y))
    (if (<= t_1 1e+268)
      (/ (- (* (fmax x y) (fmin x y)) (* 9.0 (* z t))) (+ a a))
      (* (/ (fmin x y) (+ a a)) (fmax 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 <= -5e+273) {
		tmp = (fmax(x, y) / (a + a)) * fmin(x, y);
	} else if (t_1 <= 1e+268) {
		tmp = ((fmax(x, y) * fmin(x, y)) - (9.0 * (z * t))) / (a + a);
	} else {
		tmp = (fmin(x, y) / (a + a)) * fmax(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 <= (-5d+273)) then
        tmp = (fmax(x, y) / (a + a)) * fmin(x, y)
    else if (t_1 <= 1d+268) then
        tmp = ((fmax(x, y) * fmin(x, y)) - (9.0d0 * (z * t))) / (a + a)
    else
        tmp = (fmin(x, y) / (a + a)) * fmax(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 <= -5e+273) {
		tmp = (fmax(x, y) / (a + a)) * fmin(x, y);
	} else if (t_1 <= 1e+268) {
		tmp = ((fmax(x, y) * fmin(x, y)) - (9.0 * (z * t))) / (a + a);
	} else {
		tmp = (fmin(x, y) / (a + a)) * fmax(x, y);
	}
	return tmp;
}
def code(x, y, z, t, a):
	t_1 = fmin(x, y) * fmax(x, y)
	tmp = 0
	if t_1 <= -5e+273:
		tmp = (fmax(x, y) / (a + a)) * fmin(x, y)
	elif t_1 <= 1e+268:
		tmp = ((fmax(x, y) * fmin(x, y)) - (9.0 * (z * t))) / (a + a)
	else:
		tmp = (fmin(x, y) / (a + a)) * fmax(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 <= -5e+273)
		tmp = Float64(Float64(fmax(x, y) / Float64(a + a)) * fmin(x, y));
	elseif (t_1 <= 1e+268)
		tmp = Float64(Float64(Float64(fmax(x, y) * fmin(x, y)) - Float64(9.0 * Float64(z * t))) / Float64(a + a));
	else
		tmp = Float64(Float64(fmin(x, y) / Float64(a + a)) * fmax(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 <= -5e+273)
		tmp = (max(x, y) / (a + a)) * min(x, y);
	elseif (t_1 <= 1e+268)
		tmp = ((max(x, y) * min(x, y)) - (9.0 * (z * t))) / (a + a);
	else
		tmp = (min(x, y) / (a + a)) * max(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, -5e+273], N[(N[(N[Max[x, y], $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision] * N[Min[x, y], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e+268], N[(N[(N[(N[Max[x, y], $MachinePrecision] * N[Min[x, y], $MachinePrecision]), $MachinePrecision] - N[(9.0 * N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision], N[(N[(N[Min[x, y], $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision] * N[Max[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 -5 \cdot 10^{+273}:\\
\;\;\;\;\frac{\mathsf{max}\left(x, y\right)}{a + a} \cdot \mathsf{min}\left(x, y\right)\\

\mathbf{elif}\;t\_1 \leq 10^{+268}:\\
\;\;\;\;\frac{\mathsf{max}\left(x, y\right) \cdot \mathsf{min}\left(x, y\right) - 9 \cdot \left(z \cdot t\right)}{a + a}\\

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


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

    1. Initial program 90.9%

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

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

      \[\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. *-commutativeN/A

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

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

        \[\leadsto \frac{x \cdot y}{a} \cdot \frac{1}{2} \]
      5. associate-/l*N/A

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

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

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

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

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

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

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

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

        \[\leadsto \frac{y}{a + a} \cdot \color{blue}{x} \]
      14. lower-*.f64N/A

        \[\leadsto \frac{y}{a + a} \cdot \color{blue}{x} \]
      15. lower-/.f6451.6%

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

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

    if -4.9999999999999996e273 < (*.f64 x y) < 9.9999999999999997e267

    1. Initial program 90.9%

      \[\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{x \cdot y - \color{blue}{\left(z \cdot 9\right) \cdot t}}{a \cdot 2} \]
      2. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{y \cdot x - t \cdot \left(9 \cdot z\right)}{\color{blue}{a + a}} \]
      19. lift-/.f6490.9%

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

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

    if 9.9999999999999997e267 < (*.f64 x y)

    1. Initial program 90.9%

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

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

      \[\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. *-commutativeN/A

        \[\leadsto \frac{x \cdot y}{a} \cdot \color{blue}{\frac{1}{2}} \]
      3. metadata-evalN/A

        \[\leadsto \frac{x \cdot y}{a} \cdot \frac{1}{\color{blue}{2}} \]
      4. mult-flip-revN/A

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{x}{a + a} \cdot \color{blue}{y} \]
      15. lower-*.f64N/A

        \[\leadsto \frac{x}{a + a} \cdot \color{blue}{y} \]
      16. lower-/.f6451.0%

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

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

Alternative 3: 92.6% accurate, 0.2× speedup?

\[\begin{array}{l} t_1 := \left|a\right| + \left|a\right|\\ \mathsf{copysign}\left(1, a\right) \cdot \begin{array}{l} \mathbf{if}\;\left|a\right| \leq 5 \cdot 10^{-24}:\\ \;\;\;\;\frac{y \cdot x - 9 \cdot \left(z \cdot t\right)}{t\_1}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{t\_1} \cdot y - \frac{t \cdot z}{\left|a\right|} \cdot 4.5\\ \end{array} \end{array} \]
(FPCore (x y z t a)
  :precision binary64
  (let* ((t_1 (+ (fabs a) (fabs a))))
  (*
   (copysign 1.0 a)
   (if (<= (fabs a) 5e-24)
     (/ (- (* y x) (* 9.0 (* z t))) t_1)
     (- (* (/ x t_1) y) (* (/ (* t z) (fabs a)) 4.5))))))
double code(double x, double y, double z, double t, double a) {
	double t_1 = fabs(a) + fabs(a);
	double tmp;
	if (fabs(a) <= 5e-24) {
		tmp = ((y * x) - (9.0 * (z * t))) / t_1;
	} else {
		tmp = ((x / t_1) * y) - (((t * z) / fabs(a)) * 4.5);
	}
	return copysign(1.0, a) * tmp;
}
public static double code(double x, double y, double z, double t, double a) {
	double t_1 = Math.abs(a) + Math.abs(a);
	double tmp;
	if (Math.abs(a) <= 5e-24) {
		tmp = ((y * x) - (9.0 * (z * t))) / t_1;
	} else {
		tmp = ((x / t_1) * y) - (((t * z) / Math.abs(a)) * 4.5);
	}
	return Math.copySign(1.0, a) * tmp;
}
def code(x, y, z, t, a):
	t_1 = math.fabs(a) + math.fabs(a)
	tmp = 0
	if math.fabs(a) <= 5e-24:
		tmp = ((y * x) - (9.0 * (z * t))) / t_1
	else:
		tmp = ((x / t_1) * y) - (((t * z) / math.fabs(a)) * 4.5)
	return math.copysign(1.0, a) * tmp
function code(x, y, z, t, a)
	t_1 = Float64(abs(a) + abs(a))
	tmp = 0.0
	if (abs(a) <= 5e-24)
		tmp = Float64(Float64(Float64(y * x) - Float64(9.0 * Float64(z * t))) / t_1);
	else
		tmp = Float64(Float64(Float64(x / t_1) * y) - Float64(Float64(Float64(t * z) / abs(a)) * 4.5));
	end
	return Float64(copysign(1.0, a) * tmp)
end
function tmp_2 = code(x, y, z, t, a)
	t_1 = abs(a) + abs(a);
	tmp = 0.0;
	if (abs(a) <= 5e-24)
		tmp = ((y * x) - (9.0 * (z * t))) / t_1;
	else
		tmp = ((x / t_1) * y) - (((t * z) / abs(a)) * 4.5);
	end
	tmp_2 = (sign(a) * abs(1.0)) * tmp;
end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[Abs[a], $MachinePrecision] + N[Abs[a], $MachinePrecision]), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[Abs[a], $MachinePrecision], 5e-24], N[(N[(N[(y * x), $MachinePrecision] - N[(9.0 * N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision], N[(N[(N[(x / t$95$1), $MachinePrecision] * y), $MachinePrecision] - N[(N[(N[(t * z), $MachinePrecision] / N[Abs[a], $MachinePrecision]), $MachinePrecision] * 4.5), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
t_1 := \left|a\right| + \left|a\right|\\
\mathsf{copysign}\left(1, a\right) \cdot \begin{array}{l}
\mathbf{if}\;\left|a\right| \leq 5 \cdot 10^{-24}:\\
\;\;\;\;\frac{y \cdot x - 9 \cdot \left(z \cdot t\right)}{t\_1}\\

\mathbf{else}:\\
\;\;\;\;\frac{x}{t\_1} \cdot y - \frac{t \cdot z}{\left|a\right|} \cdot 4.5\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < 4.9999999999999998e-24

    1. Initial program 90.9%

      \[\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{x \cdot y - \color{blue}{\left(z \cdot 9\right) \cdot t}}{a \cdot 2} \]
      2. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{y \cdot x - t \cdot \left(9 \cdot z\right)}{\color{blue}{a + a}} \]
      19. lift-/.f6490.9%

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

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

    if 4.9999999999999998e-24 < a

    1. Initial program 90.9%

      \[\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. lower--.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{x}{a + a} \cdot y - \frac{\color{blue}{t \cdot z}}{a} \cdot \frac{9}{2} \]
      26. metadata-eval87.5%

        \[\leadsto \frac{x}{a + a} \cdot y - \frac{t \cdot z}{a} \cdot \color{blue}{4.5} \]
    3. Applied rewrites87.5%

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

Alternative 4: 92.5% accurate, 0.1× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < 1.0000000000000001e-30

    1. Initial program 90.9%

      \[\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{x \cdot y - \color{blue}{\left(z \cdot 9\right) \cdot t}}{a \cdot 2} \]
      2. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{y \cdot x - t \cdot \left(9 \cdot z\right)}{\color{blue}{a + a}} \]
      19. lift-/.f6490.9%

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

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

    if 1.0000000000000001e-30 < a

    1. Initial program 90.9%

      \[\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. lower--.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{x}{a + a} \cdot y - \frac{\color{blue}{t \cdot z}}{a} \cdot \frac{9}{2} \]
      26. metadata-eval87.5%

        \[\leadsto \frac{x}{a + a} \cdot y - \frac{t \cdot z}{a} \cdot \color{blue}{4.5} \]
    3. Applied rewrites87.5%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{x \cdot y}{a \cdot 2}} - \frac{t \cdot z}{a} \cdot \frac{9}{2} \]
      8. associate-/l*N/A

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

        \[\leadsto \color{blue}{x \cdot \frac{y}{a \cdot 2}} - \frac{t \cdot z}{a} \cdot \frac{9}{2} \]
      10. lower-/.f6487.6%

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

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

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

        \[\leadsto x \cdot \frac{y}{\color{blue}{a + a}} - \frac{t \cdot z}{a} \cdot \frac{9}{2} \]
      14. lift-+.f6487.6%

        \[\leadsto x \cdot \frac{y}{\color{blue}{a + a}} - \frac{t \cdot z}{a} \cdot 4.5 \]
    5. Applied rewrites87.6%

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

Alternative 5: 73.4% accurate, 0.1× speedup?

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

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

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


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 x y) < -9.9999999999999994e-68 or 6e-10 < (*.f64 x y)

    1. Initial program 90.9%

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

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

      \[\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. *-commutativeN/A

        \[\leadsto \frac{x \cdot y}{a} \cdot \color{blue}{\frac{1}{2}} \]
      3. metadata-evalN/A

        \[\leadsto \frac{x \cdot y}{a} \cdot \frac{1}{\color{blue}{2}} \]
      4. mult-flip-revN/A

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{x}{a + a} \cdot \color{blue}{y} \]
      15. lower-*.f64N/A

        \[\leadsto \frac{x}{a + a} \cdot \color{blue}{y} \]
      16. lower-/.f6451.0%

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

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

    if -9.9999999999999994e-68 < (*.f64 x y) < 6e-10

    1. Initial program 90.9%

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

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

      \[\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. mult-flipN/A

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

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

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

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

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

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

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

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

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

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

Alternative 6: 73.4% accurate, 0.1× speedup?

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

\mathbf{elif}\;t\_1 \leq 6 \cdot 10^{-10}:\\
\;\;\;\;-4.5 \cdot \frac{t \cdot z}{a}\\

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


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 x y) < -9.9999999999999994e-68 or 6e-10 < (*.f64 x y)

    1. Initial program 90.9%

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

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

      \[\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. *-commutativeN/A

        \[\leadsto \frac{x \cdot y}{a} \cdot \color{blue}{\frac{1}{2}} \]
      3. metadata-evalN/A

        \[\leadsto \frac{x \cdot y}{a} \cdot \frac{1}{\color{blue}{2}} \]
      4. mult-flip-revN/A

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{x}{a + a} \cdot \color{blue}{y} \]
      15. lower-*.f64N/A

        \[\leadsto \frac{x}{a + a} \cdot \color{blue}{y} \]
      16. lower-/.f6451.0%

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

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

    if -9.9999999999999994e-68 < (*.f64 x y) < 6e-10

    1. Initial program 90.9%

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

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

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

Alternative 7: 72.6% accurate, 0.1× speedup?

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

\mathbf{elif}\;t\_1 \leq 6 \cdot 10^{-10}:\\
\;\;\;\;-4.5 \cdot \left(\mathsf{min}\left(z, t\right) \cdot \frac{\mathsf{max}\left(z, t\right)}{a}\right)\\

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


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 x y) < -9.9999999999999994e-68 or 6e-10 < (*.f64 x y)

    1. Initial program 90.9%

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

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

      \[\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. *-commutativeN/A

        \[\leadsto \frac{x \cdot y}{a} \cdot \color{blue}{\frac{1}{2}} \]
      3. metadata-evalN/A

        \[\leadsto \frac{x \cdot y}{a} \cdot \frac{1}{\color{blue}{2}} \]
      4. mult-flip-revN/A

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{x}{a + a} \cdot \color{blue}{y} \]
      15. lower-*.f64N/A

        \[\leadsto \frac{x}{a + a} \cdot \color{blue}{y} \]
      16. lower-/.f6451.0%

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

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

    if -9.9999999999999994e-68 < (*.f64 x y) < 6e-10

    1. Initial program 90.9%

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

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

      \[\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. *-commutativeN/A

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

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

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

        \[\leadsto -4.5 \cdot \left(z \cdot \frac{t}{\color{blue}{a}}\right) \]
    6. Applied rewrites51.2%

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

Alternative 8: 51.3% accurate, 0.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 90.9%

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

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

    \[\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. *-commutativeN/A

      \[\leadsto \frac{x \cdot y}{a} \cdot \color{blue}{\frac{1}{2}} \]
    3. metadata-evalN/A

      \[\leadsto \frac{x \cdot y}{a} \cdot \frac{1}{\color{blue}{2}} \]
    4. mult-flip-revN/A

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{x}{a + a} \cdot \color{blue}{y} \]
    15. lower-*.f64N/A

      \[\leadsto \frac{x}{a + a} \cdot \color{blue}{y} \]
    16. lower-/.f6451.0%

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

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

Reproduce

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