Numeric.SpecFunctions:invIncompleteBetaWorker from math-functions-0.1.5.2, C

Percentage Accurate: 94.7% → 96.6%
Time: 11.0s
Alternatives: 14
Speedup: 0.5×

Specification

?
\[\begin{array}{l} \\ x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) \end{array} \]
(FPCore (x y z t) :precision binary64 (* x (- (/ y z) (/ t (- 1.0 z)))))
double code(double x, double y, double z, double t) {
	return x * ((y / z) - (t / (1.0 - z)));
}
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)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    code = x * ((y / z) - (t / (1.0d0 - z)))
end function
public static double code(double x, double y, double z, double t) {
	return x * ((y / z) - (t / (1.0 - z)));
}
def code(x, y, z, t):
	return x * ((y / z) - (t / (1.0 - z)))
function code(x, y, z, t)
	return Float64(x * Float64(Float64(y / z) - Float64(t / Float64(1.0 - z))))
end
function tmp = code(x, y, z, t)
	tmp = x * ((y / z) - (t / (1.0 - z)));
end
code[x_, y_, z_, t_] := N[(x * N[(N[(y / z), $MachinePrecision] - N[(t / N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)
\end{array}

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

\[\begin{array}{l} \\ x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) \end{array} \]
(FPCore (x y z t) :precision binary64 (* x (- (/ y z) (/ t (- 1.0 z)))))
double code(double x, double y, double z, double t) {
	return x * ((y / z) - (t / (1.0 - z)));
}
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)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    code = x * ((y / z) - (t / (1.0d0 - z)))
end function
public static double code(double x, double y, double z, double t) {
	return x * ((y / z) - (t / (1.0 - z)));
}
def code(x, y, z, t):
	return x * ((y / z) - (t / (1.0 - z)))
function code(x, y, z, t)
	return Float64(x * Float64(Float64(y / z) - Float64(t / Float64(1.0 - z))))
end
function tmp = code(x, y, z, t)
	tmp = x * ((y / z) - (t / (1.0 - z)));
end
code[x_, y_, z_, t_] := N[(x * N[(N[(y / z), $MachinePrecision] - N[(t / N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)
\end{array}

Alternative 1: 96.6% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{y}{z} - \frac{t}{1 - z}\\ \mathbf{if}\;t\_1 \leq 4 \cdot 10^{-323}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{z}{z - 1}, t, y\right) \cdot x}{z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (- (/ y z) (/ t (- 1.0 z)))))
   (if (<= t_1 4e-323) (/ (* (fma (/ z (- z 1.0)) t y) x) z) (* x t_1))))
double code(double x, double y, double z, double t) {
	double t_1 = (y / z) - (t / (1.0 - z));
	double tmp;
	if (t_1 <= 4e-323) {
		tmp = (fma((z / (z - 1.0)), t, y) * x) / z;
	} else {
		tmp = x * t_1;
	}
	return tmp;
}
function code(x, y, z, t)
	t_1 = Float64(Float64(y / z) - Float64(t / Float64(1.0 - z)))
	tmp = 0.0
	if (t_1 <= 4e-323)
		tmp = Float64(Float64(fma(Float64(z / Float64(z - 1.0)), t, y) * x) / z);
	else
		tmp = Float64(x * t_1);
	end
	return tmp
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(y / z), $MachinePrecision] - N[(t / N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 4e-323], N[(N[(N[(N[(z / N[(z - 1.0), $MachinePrecision]), $MachinePrecision] * t + y), $MachinePrecision] * x), $MachinePrecision] / z), $MachinePrecision], N[(x * t$95$1), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \frac{y}{z} - \frac{t}{1 - z}\\
\mathbf{if}\;t\_1 \leq 4 \cdot 10^{-323}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{z}{z - 1}, t, y\right) \cdot x}{z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (/.f64 y z) (/.f64 t (-.f64 #s(literal 1 binary64) z))) < 3.95253e-323

    1. Initial program 94.7%

      \[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) \]
    2. Applied rewrites91.4%

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

    if 3.95253e-323 < (-.f64 (/.f64 y z) (/.f64 t (-.f64 #s(literal 1 binary64) z)))

    1. Initial program 94.7%

      \[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 2: 93.7% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
t_1 := \frac{y}{z} - \frac{t}{1 - z}\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;\frac{x \cdot y}{z}\\

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


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

    1. Initial program 94.7%

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

      \[\leadsto \color{blue}{\frac{x \cdot y}{z}} \]
    3. Applied rewrites61.1%

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

    if -inf.0 < (-.f64 (/.f64 y z) (/.f64 t (-.f64 #s(literal 1 binary64) z)))

    1. Initial program 94.7%

      \[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 3: 93.6% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -19000000000:\\ \;\;\;\;x \cdot \frac{t + y}{z}\\ \mathbf{elif}\;z \leq 1:\\ \;\;\;\;\frac{\mathsf{fma}\left(-1 \cdot z, t, y\right) \cdot x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \left(y - -1 \cdot t\right)}{z}\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (<= z -19000000000.0)
   (* x (/ (+ t y) z))
   (if (<= z 1.0)
     (/ (* (fma (* -1.0 z) t y) x) z)
     (/ (* x (- y (* -1.0 t))) z))))
double code(double x, double y, double z, double t) {
	double tmp;
	if (z <= -19000000000.0) {
		tmp = x * ((t + y) / z);
	} else if (z <= 1.0) {
		tmp = (fma((-1.0 * z), t, y) * x) / z;
	} else {
		tmp = (x * (y - (-1.0 * t))) / z;
	}
	return tmp;
}
function code(x, y, z, t)
	tmp = 0.0
	if (z <= -19000000000.0)
		tmp = Float64(x * Float64(Float64(t + y) / z));
	elseif (z <= 1.0)
		tmp = Float64(Float64(fma(Float64(-1.0 * z), t, y) * x) / z);
	else
		tmp = Float64(Float64(x * Float64(y - Float64(-1.0 * t))) / z);
	end
	return tmp
end
code[x_, y_, z_, t_] := If[LessEqual[z, -19000000000.0], N[(x * N[(N[(t + y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.0], N[(N[(N[(N[(-1.0 * z), $MachinePrecision] * t + y), $MachinePrecision] * x), $MachinePrecision] / z), $MachinePrecision], N[(N[(x * N[(y - N[(-1.0 * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -19000000000:\\
\;\;\;\;x \cdot \frac{t + y}{z}\\

\mathbf{elif}\;z \leq 1:\\
\;\;\;\;\frac{\mathsf{fma}\left(-1 \cdot z, t, y\right) \cdot x}{z}\\

\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \left(y - -1 \cdot t\right)}{z}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -1.9e10

    1. Initial program 94.7%

      \[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) \]
    2. Applied rewrites94.7%

      \[\leadsto x \cdot \color{blue}{\mathsf{fma}\left(\frac{1}{z - 1}, t, \frac{y}{z}\right)} \]
    3. Taylor expanded in z around inf

      \[\leadsto x \cdot \color{blue}{\frac{t + y}{z}} \]
    4. Applied rewrites73.6%

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

    if -1.9e10 < z < 1

    1. Initial program 94.7%

      \[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) \]
    2. Applied rewrites91.4%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(\frac{z}{z - 1}, t, y\right) \cdot x}{z}} \]
    3. Taylor expanded in z around 0

      \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{-1 \cdot z}, t, y\right) \cdot x}{z} \]
    4. Applied rewrites64.4%

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

    if 1 < z

    1. Initial program 94.7%

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

      \[\leadsto \color{blue}{\frac{x \cdot \left(y - -1 \cdot t\right)}{z}} \]
    3. Applied rewrites71.6%

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

Alternative 4: 92.9% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -19000000000:\\ \;\;\;\;x \cdot \frac{t + y}{z}\\ \mathbf{elif}\;z \leq 480:\\ \;\;\;\;\mathsf{fma}\left(-z, t, y\right) \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \left(y - -1 \cdot t\right)}{z}\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (<= z -19000000000.0)
   (* x (/ (+ t y) z))
   (if (<= z 480.0) (* (fma (- z) t y) (/ x z)) (/ (* x (- y (* -1.0 t))) z))))
double code(double x, double y, double z, double t) {
	double tmp;
	if (z <= -19000000000.0) {
		tmp = x * ((t + y) / z);
	} else if (z <= 480.0) {
		tmp = fma(-z, t, y) * (x / z);
	} else {
		tmp = (x * (y - (-1.0 * t))) / z;
	}
	return tmp;
}
function code(x, y, z, t)
	tmp = 0.0
	if (z <= -19000000000.0)
		tmp = Float64(x * Float64(Float64(t + y) / z));
	elseif (z <= 480.0)
		tmp = Float64(fma(Float64(-z), t, y) * Float64(x / z));
	else
		tmp = Float64(Float64(x * Float64(y - Float64(-1.0 * t))) / z);
	end
	return tmp
end
code[x_, y_, z_, t_] := If[LessEqual[z, -19000000000.0], N[(x * N[(N[(t + y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 480.0], N[(N[((-z) * t + y), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[(y - N[(-1.0 * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -19000000000:\\
\;\;\;\;x \cdot \frac{t + y}{z}\\

\mathbf{elif}\;z \leq 480:\\
\;\;\;\;\mathsf{fma}\left(-z, t, y\right) \cdot \frac{x}{z}\\

\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \left(y - -1 \cdot t\right)}{z}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -1.9e10

    1. Initial program 94.7%

      \[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) \]
    2. Applied rewrites94.7%

      \[\leadsto x \cdot \color{blue}{\mathsf{fma}\left(\frac{1}{z - 1}, t, \frac{y}{z}\right)} \]
    3. Taylor expanded in z around inf

      \[\leadsto x \cdot \color{blue}{\frac{t + y}{z}} \]
    4. Applied rewrites73.6%

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

    if -1.9e10 < z < 480

    1. Initial program 94.7%

      \[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) \]
    2. Applied rewrites90.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{z}{z - 1}, t, y\right) \cdot \frac{x}{z}} \]
    3. Taylor expanded in z around 0

      \[\leadsto \mathsf{fma}\left(\color{blue}{-1 \cdot z}, t, y\right) \cdot \frac{x}{z} \]
    4. Applied rewrites65.5%

      \[\leadsto \mathsf{fma}\left(\color{blue}{-1 \cdot z}, t, y\right) \cdot \frac{x}{z} \]
    5. Applied rewrites65.5%

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

    if 480 < z

    1. Initial program 94.7%

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

      \[\leadsto \color{blue}{\frac{x \cdot \left(y - -1 \cdot t\right)}{z}} \]
    3. Applied rewrites71.6%

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

Alternative 5: 92.1% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -19000000000:\\ \;\;\;\;x \cdot \frac{t + y}{z}\\ \mathbf{elif}\;z \leq 480:\\ \;\;\;\;x \cdot \left(\frac{y}{z} - t\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \left(y - -1 \cdot t\right)}{z}\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (<= z -19000000000.0)
   (* x (/ (+ t y) z))
   (if (<= z 480.0) (* x (- (/ y z) t)) (/ (* x (- y (* -1.0 t))) z))))
double code(double x, double y, double z, double t) {
	double tmp;
	if (z <= -19000000000.0) {
		tmp = x * ((t + y) / z);
	} else if (z <= 480.0) {
		tmp = x * ((y / z) - t);
	} else {
		tmp = (x * (y - (-1.0 * t))) / z;
	}
	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)
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) :: tmp
    if (z <= (-19000000000.0d0)) then
        tmp = x * ((t + y) / z)
    else if (z <= 480.0d0) then
        tmp = x * ((y / z) - t)
    else
        tmp = (x * (y - ((-1.0d0) * t))) / z
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double tmp;
	if (z <= -19000000000.0) {
		tmp = x * ((t + y) / z);
	} else if (z <= 480.0) {
		tmp = x * ((y / z) - t);
	} else {
		tmp = (x * (y - (-1.0 * t))) / z;
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if z <= -19000000000.0:
		tmp = x * ((t + y) / z)
	elif z <= 480.0:
		tmp = x * ((y / z) - t)
	else:
		tmp = (x * (y - (-1.0 * t))) / z
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if (z <= -19000000000.0)
		tmp = Float64(x * Float64(Float64(t + y) / z));
	elseif (z <= 480.0)
		tmp = Float64(x * Float64(Float64(y / z) - t));
	else
		tmp = Float64(Float64(x * Float64(y - Float64(-1.0 * t))) / z);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (z <= -19000000000.0)
		tmp = x * ((t + y) / z);
	elseif (z <= 480.0)
		tmp = x * ((y / z) - t);
	else
		tmp = (x * (y - (-1.0 * t))) / z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[LessEqual[z, -19000000000.0], N[(x * N[(N[(t + y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 480.0], N[(x * N[(N[(y / z), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[(y - N[(-1.0 * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -19000000000:\\
\;\;\;\;x \cdot \frac{t + y}{z}\\

\mathbf{elif}\;z \leq 480:\\
\;\;\;\;x \cdot \left(\frac{y}{z} - t\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \left(y - -1 \cdot t\right)}{z}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -1.9e10

    1. Initial program 94.7%

      \[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) \]
    2. Applied rewrites94.7%

      \[\leadsto x \cdot \color{blue}{\mathsf{fma}\left(\frac{1}{z - 1}, t, \frac{y}{z}\right)} \]
    3. Taylor expanded in z around inf

      \[\leadsto x \cdot \color{blue}{\frac{t + y}{z}} \]
    4. Applied rewrites73.6%

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

    if -1.9e10 < z < 480

    1. Initial program 94.7%

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

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

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

    if 480 < z

    1. Initial program 94.7%

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

      \[\leadsto \color{blue}{\frac{x \cdot \left(y - -1 \cdot t\right)}{z}} \]
    3. Applied rewrites71.6%

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

Alternative 6: 91.3% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x \cdot \frac{t + y}{z}\\ \mathbf{if}\;z \leq -19000000000:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \leq 1:\\ \;\;\;\;x \cdot \left(\frac{y}{z} - t\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (* x (/ (+ t y) z))))
   (if (<= z -19000000000.0) t_1 (if (<= z 1.0) (* x (- (/ y z) t)) t_1))))
double code(double x, double y, double z, double t) {
	double t_1 = x * ((t + y) / z);
	double tmp;
	if (z <= -19000000000.0) {
		tmp = t_1;
	} else if (z <= 1.0) {
		tmp = x * ((y / z) - t);
	} 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)
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) :: t_1
    real(8) :: tmp
    t_1 = x * ((t + y) / z)
    if (z <= (-19000000000.0d0)) then
        tmp = t_1
    else if (z <= 1.0d0) then
        tmp = x * ((y / z) - t)
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double t_1 = x * ((t + y) / z);
	double tmp;
	if (z <= -19000000000.0) {
		tmp = t_1;
	} else if (z <= 1.0) {
		tmp = x * ((y / z) - t);
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = x * ((t + y) / z)
	tmp = 0
	if z <= -19000000000.0:
		tmp = t_1
	elif z <= 1.0:
		tmp = x * ((y / z) - t)
	else:
		tmp = t_1
	return tmp
function code(x, y, z, t)
	t_1 = Float64(x * Float64(Float64(t + y) / z))
	tmp = 0.0
	if (z <= -19000000000.0)
		tmp = t_1;
	elseif (z <= 1.0)
		tmp = Float64(x * Float64(Float64(y / z) - t));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = x * ((t + y) / z);
	tmp = 0.0;
	if (z <= -19000000000.0)
		tmp = t_1;
	elseif (z <= 1.0)
		tmp = x * ((y / z) - t);
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x * N[(N[(t + y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -19000000000.0], t$95$1, If[LessEqual[z, 1.0], N[(x * N[(N[(y / z), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := x \cdot \frac{t + y}{z}\\
\mathbf{if}\;z \leq -19000000000:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;z \leq 1:\\
\;\;\;\;x \cdot \left(\frac{y}{z} - t\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.9e10 or 1 < z

    1. Initial program 94.7%

      \[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) \]
    2. Applied rewrites94.7%

      \[\leadsto x \cdot \color{blue}{\mathsf{fma}\left(\frac{1}{z - 1}, t, \frac{y}{z}\right)} \]
    3. Taylor expanded in z around inf

      \[\leadsto x \cdot \color{blue}{\frac{t + y}{z}} \]
    4. Applied rewrites73.6%

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

    if -1.9e10 < z < 1

    1. Initial program 94.7%

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

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

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

Alternative 7: 74.4% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x \cdot \frac{t}{z - 1}\\ \mathbf{if}\;t \leq -14800000000000:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t \leq 3.7 \cdot 10^{+65}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (* x (/ t (- z 1.0)))))
   (if (<= t -14800000000000.0) t_1 (if (<= t 3.7e+65) (/ (* x y) z) t_1))))
double code(double x, double y, double z, double t) {
	double t_1 = x * (t / (z - 1.0));
	double tmp;
	if (t <= -14800000000000.0) {
		tmp = t_1;
	} else if (t <= 3.7e+65) {
		tmp = (x * y) / z;
	} 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)
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) :: t_1
    real(8) :: tmp
    t_1 = x * (t / (z - 1.0d0))
    if (t <= (-14800000000000.0d0)) then
        tmp = t_1
    else if (t <= 3.7d+65) then
        tmp = (x * y) / z
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double t_1 = x * (t / (z - 1.0));
	double tmp;
	if (t <= -14800000000000.0) {
		tmp = t_1;
	} else if (t <= 3.7e+65) {
		tmp = (x * y) / z;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = x * (t / (z - 1.0))
	tmp = 0
	if t <= -14800000000000.0:
		tmp = t_1
	elif t <= 3.7e+65:
		tmp = (x * y) / z
	else:
		tmp = t_1
	return tmp
function code(x, y, z, t)
	t_1 = Float64(x * Float64(t / Float64(z - 1.0)))
	tmp = 0.0
	if (t <= -14800000000000.0)
		tmp = t_1;
	elseif (t <= 3.7e+65)
		tmp = Float64(Float64(x * y) / z);
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = x * (t / (z - 1.0));
	tmp = 0.0;
	if (t <= -14800000000000.0)
		tmp = t_1;
	elseif (t <= 3.7e+65)
		tmp = (x * y) / z;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x * N[(t / N[(z - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t, -14800000000000.0], t$95$1, If[LessEqual[t, 3.7e+65], N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision], t$95$1]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := x \cdot \frac{t}{z - 1}\\
\mathbf{if}\;t \leq -14800000000000:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t \leq 3.7 \cdot 10^{+65}:\\
\;\;\;\;\frac{x \cdot y}{z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -1.48e13 or 3.69999999999999995e65 < t

    1. Initial program 94.7%

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

      \[\leadsto x \cdot \color{blue}{\left(-1 \cdot \frac{t}{1 - z}\right)} \]
    3. Applied rewrites45.7%

      \[\leadsto x \cdot \color{blue}{\left(-1 \cdot \frac{t}{1 - z}\right)} \]
    4. Applied rewrites45.7%

      \[\leadsto x \cdot \frac{t}{\color{blue}{z - 1}} \]

    if -1.48e13 < t < 3.69999999999999995e65

    1. Initial program 94.7%

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

      \[\leadsto \color{blue}{\frac{x \cdot y}{z}} \]
    3. Applied rewrites61.1%

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

Alternative 8: 71.6% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{t \cdot x}{z - 1}\\ \mathbf{if}\;t \leq -14800000000000:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t \leq 3.7 \cdot 10^{+65}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (/ (* t x) (- z 1.0))))
   (if (<= t -14800000000000.0) t_1 (if (<= t 3.7e+65) (/ (* x y) z) t_1))))
double code(double x, double y, double z, double t) {
	double t_1 = (t * x) / (z - 1.0);
	double tmp;
	if (t <= -14800000000000.0) {
		tmp = t_1;
	} else if (t <= 3.7e+65) {
		tmp = (x * y) / z;
	} 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)
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) :: t_1
    real(8) :: tmp
    t_1 = (t * x) / (z - 1.0d0)
    if (t <= (-14800000000000.0d0)) then
        tmp = t_1
    else if (t <= 3.7d+65) then
        tmp = (x * y) / z
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double t_1 = (t * x) / (z - 1.0);
	double tmp;
	if (t <= -14800000000000.0) {
		tmp = t_1;
	} else if (t <= 3.7e+65) {
		tmp = (x * y) / z;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = (t * x) / (z - 1.0)
	tmp = 0
	if t <= -14800000000000.0:
		tmp = t_1
	elif t <= 3.7e+65:
		tmp = (x * y) / z
	else:
		tmp = t_1
	return tmp
function code(x, y, z, t)
	t_1 = Float64(Float64(t * x) / Float64(z - 1.0))
	tmp = 0.0
	if (t <= -14800000000000.0)
		tmp = t_1;
	elseif (t <= 3.7e+65)
		tmp = Float64(Float64(x * y) / z);
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = (t * x) / (z - 1.0);
	tmp = 0.0;
	if (t <= -14800000000000.0)
		tmp = t_1;
	elseif (t <= 3.7e+65)
		tmp = (x * y) / z;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(t * x), $MachinePrecision] / N[(z - 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t, -14800000000000.0], t$95$1, If[LessEqual[t, 3.7e+65], N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision], t$95$1]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \frac{t \cdot x}{z - 1}\\
\mathbf{if}\;t \leq -14800000000000:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t \leq 3.7 \cdot 10^{+65}:\\
\;\;\;\;\frac{x \cdot y}{z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -1.48e13 or 3.69999999999999995e65 < t

    1. Initial program 94.7%

      \[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) \]
    2. Applied rewrites94.7%

      \[\leadsto x \cdot \color{blue}{\mathsf{fma}\left(\frac{1}{z - 1}, t, \frac{y}{z}\right)} \]
    3. Taylor expanded in y around 0

      \[\leadsto \color{blue}{\frac{t \cdot x}{z - 1}} \]
    4. Applied rewrites43.4%

      \[\leadsto \color{blue}{\frac{t \cdot x}{z - 1}} \]

    if -1.48e13 < t < 3.69999999999999995e65

    1. Initial program 94.7%

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

      \[\leadsto \color{blue}{\frac{x \cdot y}{z}} \]
    3. Applied rewrites61.1%

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

Alternative 9: 66.7% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x \cdot \frac{t}{z}\\ \mathbf{if}\;t \leq -1.92 \cdot 10^{+282}:\\ \;\;\;\;x \cdot \left(-1 \cdot t\right)\\ \mathbf{elif}\;t \leq -1.12 \cdot 10^{+46}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t \leq 4.5 \cdot 10^{+136}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (* x (/ t z))))
   (if (<= t -1.92e+282)
     (* x (* -1.0 t))
     (if (<= t -1.12e+46) t_1 (if (<= t 4.5e+136) (/ (* x y) z) t_1)))))
double code(double x, double y, double z, double t) {
	double t_1 = x * (t / z);
	double tmp;
	if (t <= -1.92e+282) {
		tmp = x * (-1.0 * t);
	} else if (t <= -1.12e+46) {
		tmp = t_1;
	} else if (t <= 4.5e+136) {
		tmp = (x * y) / z;
	} 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)
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) :: t_1
    real(8) :: tmp
    t_1 = x * (t / z)
    if (t <= (-1.92d+282)) then
        tmp = x * ((-1.0d0) * t)
    else if (t <= (-1.12d+46)) then
        tmp = t_1
    else if (t <= 4.5d+136) then
        tmp = (x * y) / z
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double t_1 = x * (t / z);
	double tmp;
	if (t <= -1.92e+282) {
		tmp = x * (-1.0 * t);
	} else if (t <= -1.12e+46) {
		tmp = t_1;
	} else if (t <= 4.5e+136) {
		tmp = (x * y) / z;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = x * (t / z)
	tmp = 0
	if t <= -1.92e+282:
		tmp = x * (-1.0 * t)
	elif t <= -1.12e+46:
		tmp = t_1
	elif t <= 4.5e+136:
		tmp = (x * y) / z
	else:
		tmp = t_1
	return tmp
function code(x, y, z, t)
	t_1 = Float64(x * Float64(t / z))
	tmp = 0.0
	if (t <= -1.92e+282)
		tmp = Float64(x * Float64(-1.0 * t));
	elseif (t <= -1.12e+46)
		tmp = t_1;
	elseif (t <= 4.5e+136)
		tmp = Float64(Float64(x * y) / z);
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = x * (t / z);
	tmp = 0.0;
	if (t <= -1.92e+282)
		tmp = x * (-1.0 * t);
	elseif (t <= -1.12e+46)
		tmp = t_1;
	elseif (t <= 4.5e+136)
		tmp = (x * y) / z;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x * N[(t / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t, -1.92e+282], N[(x * N[(-1.0 * t), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, -1.12e+46], t$95$1, If[LessEqual[t, 4.5e+136], N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision], t$95$1]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := x \cdot \frac{t}{z}\\
\mathbf{if}\;t \leq -1.92 \cdot 10^{+282}:\\
\;\;\;\;x \cdot \left(-1 \cdot t\right)\\

\mathbf{elif}\;t \leq -1.12 \cdot 10^{+46}:\\
\;\;\;\;t\_1\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if t < -1.9200000000000001e282

    1. Initial program 94.7%

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

      \[\leadsto x \cdot \color{blue}{\left(-1 \cdot \frac{t}{1 - z}\right)} \]
    3. Applied rewrites45.7%

      \[\leadsto x \cdot \color{blue}{\left(-1 \cdot \frac{t}{1 - z}\right)} \]
    4. Taylor expanded in z around 0

      \[\leadsto x \cdot \left(-1 \cdot t\right) \]
    5. Applied rewrites23.2%

      \[\leadsto x \cdot \left(-1 \cdot t\right) \]

    if -1.9200000000000001e282 < t < -1.12e46 or 4.4999999999999999e136 < t

    1. Initial program 94.7%

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

      \[\leadsto x \cdot \color{blue}{\left(-1 \cdot \frac{t}{1 - z}\right)} \]
    3. Applied rewrites45.7%

      \[\leadsto x \cdot \color{blue}{\left(-1 \cdot \frac{t}{1 - z}\right)} \]
    4. Taylor expanded in z around inf

      \[\leadsto x \cdot \frac{t}{\color{blue}{z}} \]
    5. Applied rewrites35.2%

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

    if -1.12e46 < t < 4.4999999999999999e136

    1. Initial program 94.7%

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

      \[\leadsto \color{blue}{\frac{x \cdot y}{z}} \]
    3. Applied rewrites61.1%

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

Alternative 10: 64.9% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x \cdot \left(-1 \cdot t\right)\\ \mathbf{if}\;t \leq -5.2 \cdot 10^{+194}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t \leq 4.1 \cdot 10^{+65}:\\ \;\;\;\;\frac{y}{z} \cdot x\\ \mathbf{elif}\;t \leq 3.7 \cdot 10^{+113}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;\frac{t \cdot x}{z}\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (* x (* -1.0 t))))
   (if (<= t -5.2e+194)
     t_1
     (if (<= t 4.1e+65)
       (* (/ y z) x)
       (if (<= t 3.7e+113) t_1 (/ (* t x) z))))))
double code(double x, double y, double z, double t) {
	double t_1 = x * (-1.0 * t);
	double tmp;
	if (t <= -5.2e+194) {
		tmp = t_1;
	} else if (t <= 4.1e+65) {
		tmp = (y / z) * x;
	} else if (t <= 3.7e+113) {
		tmp = t_1;
	} else {
		tmp = (t * x) / z;
	}
	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)
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) :: t_1
    real(8) :: tmp
    t_1 = x * ((-1.0d0) * t)
    if (t <= (-5.2d+194)) then
        tmp = t_1
    else if (t <= 4.1d+65) then
        tmp = (y / z) * x
    else if (t <= 3.7d+113) then
        tmp = t_1
    else
        tmp = (t * x) / z
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double t_1 = x * (-1.0 * t);
	double tmp;
	if (t <= -5.2e+194) {
		tmp = t_1;
	} else if (t <= 4.1e+65) {
		tmp = (y / z) * x;
	} else if (t <= 3.7e+113) {
		tmp = t_1;
	} else {
		tmp = (t * x) / z;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = x * (-1.0 * t)
	tmp = 0
	if t <= -5.2e+194:
		tmp = t_1
	elif t <= 4.1e+65:
		tmp = (y / z) * x
	elif t <= 3.7e+113:
		tmp = t_1
	else:
		tmp = (t * x) / z
	return tmp
function code(x, y, z, t)
	t_1 = Float64(x * Float64(-1.0 * t))
	tmp = 0.0
	if (t <= -5.2e+194)
		tmp = t_1;
	elseif (t <= 4.1e+65)
		tmp = Float64(Float64(y / z) * x);
	elseif (t <= 3.7e+113)
		tmp = t_1;
	else
		tmp = Float64(Float64(t * x) / z);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = x * (-1.0 * t);
	tmp = 0.0;
	if (t <= -5.2e+194)
		tmp = t_1;
	elseif (t <= 4.1e+65)
		tmp = (y / z) * x;
	elseif (t <= 3.7e+113)
		tmp = t_1;
	else
		tmp = (t * x) / z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x * N[(-1.0 * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t, -5.2e+194], t$95$1, If[LessEqual[t, 4.1e+65], N[(N[(y / z), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[t, 3.7e+113], t$95$1, N[(N[(t * x), $MachinePrecision] / z), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := x \cdot \left(-1 \cdot t\right)\\
\mathbf{if}\;t \leq -5.2 \cdot 10^{+194}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t \leq 4.1 \cdot 10^{+65}:\\
\;\;\;\;\frac{y}{z} \cdot x\\

\mathbf{elif}\;t \leq 3.7 \cdot 10^{+113}:\\
\;\;\;\;t\_1\\

\mathbf{else}:\\
\;\;\;\;\frac{t \cdot x}{z}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if t < -5.1999999999999998e194 or 4.1000000000000001e65 < t < 3.6999999999999998e113

    1. Initial program 94.7%

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

      \[\leadsto x \cdot \color{blue}{\left(-1 \cdot \frac{t}{1 - z}\right)} \]
    3. Applied rewrites45.7%

      \[\leadsto x \cdot \color{blue}{\left(-1 \cdot \frac{t}{1 - z}\right)} \]
    4. Taylor expanded in z around 0

      \[\leadsto x \cdot \left(-1 \cdot t\right) \]
    5. Applied rewrites23.2%

      \[\leadsto x \cdot \left(-1 \cdot t\right) \]

    if -5.1999999999999998e194 < t < 4.1000000000000001e65

    1. Initial program 94.7%

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

      \[\leadsto \color{blue}{\frac{x \cdot y}{z}} \]
    3. Applied rewrites61.1%

      \[\leadsto \color{blue}{\frac{x \cdot y}{z}} \]
    4. Applied rewrites61.0%

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

    if 3.6999999999999998e113 < t

    1. Initial program 94.7%

      \[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) \]
    2. Applied rewrites94.7%

      \[\leadsto x \cdot \color{blue}{\mathsf{fma}\left(\frac{1}{z - 1}, t, \frac{y}{z}\right)} \]
    3. Taylor expanded in y around 0

      \[\leadsto \color{blue}{\frac{t \cdot x}{z - 1}} \]
    4. Applied rewrites43.4%

      \[\leadsto \color{blue}{\frac{t \cdot x}{z - 1}} \]
    5. Taylor expanded in z around inf

      \[\leadsto \frac{t \cdot x}{\color{blue}{z}} \]
    6. Applied rewrites33.1%

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

Alternative 11: 64.5% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;t \leq -2 \cdot 10^{+217}:\\ \;\;\;\;x \cdot \left(-1 \cdot t\right)\\ \mathbf{elif}\;t \leq 1.1 \cdot 10^{+115}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{t \cdot x}{z}\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (<= t -2e+217)
   (* x (* -1.0 t))
   (if (<= t 1.1e+115) (/ (* x y) z) (/ (* t x) z))))
double code(double x, double y, double z, double t) {
	double tmp;
	if (t <= -2e+217) {
		tmp = x * (-1.0 * t);
	} else if (t <= 1.1e+115) {
		tmp = (x * y) / z;
	} else {
		tmp = (t * x) / z;
	}
	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)
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) :: tmp
    if (t <= (-2d+217)) then
        tmp = x * ((-1.0d0) * t)
    else if (t <= 1.1d+115) then
        tmp = (x * y) / z
    else
        tmp = (t * x) / z
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double tmp;
	if (t <= -2e+217) {
		tmp = x * (-1.0 * t);
	} else if (t <= 1.1e+115) {
		tmp = (x * y) / z;
	} else {
		tmp = (t * x) / z;
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if t <= -2e+217:
		tmp = x * (-1.0 * t)
	elif t <= 1.1e+115:
		tmp = (x * y) / z
	else:
		tmp = (t * x) / z
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if (t <= -2e+217)
		tmp = Float64(x * Float64(-1.0 * t));
	elseif (t <= 1.1e+115)
		tmp = Float64(Float64(x * y) / z);
	else
		tmp = Float64(Float64(t * x) / z);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (t <= -2e+217)
		tmp = x * (-1.0 * t);
	elseif (t <= 1.1e+115)
		tmp = (x * y) / z;
	else
		tmp = (t * x) / z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[LessEqual[t, -2e+217], N[(x * N[(-1.0 * t), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 1.1e+115], N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision], N[(N[(t * x), $MachinePrecision] / z), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;t \leq -2 \cdot 10^{+217}:\\
\;\;\;\;x \cdot \left(-1 \cdot t\right)\\

\mathbf{elif}\;t \leq 1.1 \cdot 10^{+115}:\\
\;\;\;\;\frac{x \cdot y}{z}\\

\mathbf{else}:\\
\;\;\;\;\frac{t \cdot x}{z}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if t < -1.99999999999999992e217

    1. Initial program 94.7%

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

      \[\leadsto x \cdot \color{blue}{\left(-1 \cdot \frac{t}{1 - z}\right)} \]
    3. Applied rewrites45.7%

      \[\leadsto x \cdot \color{blue}{\left(-1 \cdot \frac{t}{1 - z}\right)} \]
    4. Taylor expanded in z around 0

      \[\leadsto x \cdot \left(-1 \cdot t\right) \]
    5. Applied rewrites23.2%

      \[\leadsto x \cdot \left(-1 \cdot t\right) \]

    if -1.99999999999999992e217 < t < 1.1e115

    1. Initial program 94.7%

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

      \[\leadsto \color{blue}{\frac{x \cdot y}{z}} \]
    3. Applied rewrites61.1%

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

    if 1.1e115 < t

    1. Initial program 94.7%

      \[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) \]
    2. Applied rewrites94.7%

      \[\leadsto x \cdot \color{blue}{\mathsf{fma}\left(\frac{1}{z - 1}, t, \frac{y}{z}\right)} \]
    3. Taylor expanded in y around 0

      \[\leadsto \color{blue}{\frac{t \cdot x}{z - 1}} \]
    4. Applied rewrites43.4%

      \[\leadsto \color{blue}{\frac{t \cdot x}{z - 1}} \]
    5. Taylor expanded in z around inf

      \[\leadsto \frac{t \cdot x}{\color{blue}{z}} \]
    6. Applied rewrites33.1%

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

Alternative 12: 63.4% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x \cdot \left(-1 \cdot t\right)\\ \mathbf{if}\;t \leq -2 \cdot 10^{+217}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t \leq 4.1 \cdot 10^{+65}:\\ \;\;\;\;\frac{x}{z} \cdot y\\ \mathbf{elif}\;t \leq 3.7 \cdot 10^{+113}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;\frac{t \cdot x}{z}\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (* x (* -1.0 t))))
   (if (<= t -2e+217)
     t_1
     (if (<= t 4.1e+65)
       (* (/ x z) y)
       (if (<= t 3.7e+113) t_1 (/ (* t x) z))))))
double code(double x, double y, double z, double t) {
	double t_1 = x * (-1.0 * t);
	double tmp;
	if (t <= -2e+217) {
		tmp = t_1;
	} else if (t <= 4.1e+65) {
		tmp = (x / z) * y;
	} else if (t <= 3.7e+113) {
		tmp = t_1;
	} else {
		tmp = (t * x) / z;
	}
	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)
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) :: t_1
    real(8) :: tmp
    t_1 = x * ((-1.0d0) * t)
    if (t <= (-2d+217)) then
        tmp = t_1
    else if (t <= 4.1d+65) then
        tmp = (x / z) * y
    else if (t <= 3.7d+113) then
        tmp = t_1
    else
        tmp = (t * x) / z
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double t_1 = x * (-1.0 * t);
	double tmp;
	if (t <= -2e+217) {
		tmp = t_1;
	} else if (t <= 4.1e+65) {
		tmp = (x / z) * y;
	} else if (t <= 3.7e+113) {
		tmp = t_1;
	} else {
		tmp = (t * x) / z;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = x * (-1.0 * t)
	tmp = 0
	if t <= -2e+217:
		tmp = t_1
	elif t <= 4.1e+65:
		tmp = (x / z) * y
	elif t <= 3.7e+113:
		tmp = t_1
	else:
		tmp = (t * x) / z
	return tmp
function code(x, y, z, t)
	t_1 = Float64(x * Float64(-1.0 * t))
	tmp = 0.0
	if (t <= -2e+217)
		tmp = t_1;
	elseif (t <= 4.1e+65)
		tmp = Float64(Float64(x / z) * y);
	elseif (t <= 3.7e+113)
		tmp = t_1;
	else
		tmp = Float64(Float64(t * x) / z);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = x * (-1.0 * t);
	tmp = 0.0;
	if (t <= -2e+217)
		tmp = t_1;
	elseif (t <= 4.1e+65)
		tmp = (x / z) * y;
	elseif (t <= 3.7e+113)
		tmp = t_1;
	else
		tmp = (t * x) / z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x * N[(-1.0 * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t, -2e+217], t$95$1, If[LessEqual[t, 4.1e+65], N[(N[(x / z), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[t, 3.7e+113], t$95$1, N[(N[(t * x), $MachinePrecision] / z), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := x \cdot \left(-1 \cdot t\right)\\
\mathbf{if}\;t \leq -2 \cdot 10^{+217}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t \leq 4.1 \cdot 10^{+65}:\\
\;\;\;\;\frac{x}{z} \cdot y\\

\mathbf{elif}\;t \leq 3.7 \cdot 10^{+113}:\\
\;\;\;\;t\_1\\

\mathbf{else}:\\
\;\;\;\;\frac{t \cdot x}{z}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if t < -1.99999999999999992e217 or 4.1000000000000001e65 < t < 3.6999999999999998e113

    1. Initial program 94.7%

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

      \[\leadsto x \cdot \color{blue}{\left(-1 \cdot \frac{t}{1 - z}\right)} \]
    3. Applied rewrites45.7%

      \[\leadsto x \cdot \color{blue}{\left(-1 \cdot \frac{t}{1 - z}\right)} \]
    4. Taylor expanded in z around 0

      \[\leadsto x \cdot \left(-1 \cdot t\right) \]
    5. Applied rewrites23.2%

      \[\leadsto x \cdot \left(-1 \cdot t\right) \]

    if -1.99999999999999992e217 < t < 4.1000000000000001e65

    1. Initial program 94.7%

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

      \[\leadsto \color{blue}{\frac{x \cdot y}{z}} \]
    3. Applied rewrites61.1%

      \[\leadsto \color{blue}{\frac{x \cdot y}{z}} \]
    4. Applied rewrites60.8%

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

    if 3.6999999999999998e113 < t

    1. Initial program 94.7%

      \[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) \]
    2. Applied rewrites94.7%

      \[\leadsto x \cdot \color{blue}{\mathsf{fma}\left(\frac{1}{z - 1}, t, \frac{y}{z}\right)} \]
    3. Taylor expanded in y around 0

      \[\leadsto \color{blue}{\frac{t \cdot x}{z - 1}} \]
    4. Applied rewrites43.4%

      \[\leadsto \color{blue}{\frac{t \cdot x}{z - 1}} \]
    5. Taylor expanded in z around inf

      \[\leadsto \frac{t \cdot x}{\color{blue}{z}} \]
    6. Applied rewrites33.1%

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

Alternative 13: 42.0% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{t \cdot x}{z}\\ \mathbf{if}\;z \leq -19000000000:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \leq 1.2 \cdot 10^{+20}:\\ \;\;\;\;x \cdot \left(-1 \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (/ (* t x) z)))
   (if (<= z -19000000000.0) t_1 (if (<= z 1.2e+20) (* x (* -1.0 t)) t_1))))
double code(double x, double y, double z, double t) {
	double t_1 = (t * x) / z;
	double tmp;
	if (z <= -19000000000.0) {
		tmp = t_1;
	} else if (z <= 1.2e+20) {
		tmp = x * (-1.0 * t);
	} 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)
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) :: t_1
    real(8) :: tmp
    t_1 = (t * x) / z
    if (z <= (-19000000000.0d0)) then
        tmp = t_1
    else if (z <= 1.2d+20) then
        tmp = x * ((-1.0d0) * t)
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double t_1 = (t * x) / z;
	double tmp;
	if (z <= -19000000000.0) {
		tmp = t_1;
	} else if (z <= 1.2e+20) {
		tmp = x * (-1.0 * t);
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = (t * x) / z
	tmp = 0
	if z <= -19000000000.0:
		tmp = t_1
	elif z <= 1.2e+20:
		tmp = x * (-1.0 * t)
	else:
		tmp = t_1
	return tmp
function code(x, y, z, t)
	t_1 = Float64(Float64(t * x) / z)
	tmp = 0.0
	if (z <= -19000000000.0)
		tmp = t_1;
	elseif (z <= 1.2e+20)
		tmp = Float64(x * Float64(-1.0 * t));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = (t * x) / z;
	tmp = 0.0;
	if (z <= -19000000000.0)
		tmp = t_1;
	elseif (z <= 1.2e+20)
		tmp = x * (-1.0 * t);
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(t * x), $MachinePrecision] / z), $MachinePrecision]}, If[LessEqual[z, -19000000000.0], t$95$1, If[LessEqual[z, 1.2e+20], N[(x * N[(-1.0 * t), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \frac{t \cdot x}{z}\\
\mathbf{if}\;z \leq -19000000000:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;z \leq 1.2 \cdot 10^{+20}:\\
\;\;\;\;x \cdot \left(-1 \cdot t\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.9e10 or 1.2e20 < z

    1. Initial program 94.7%

      \[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) \]
    2. Applied rewrites94.7%

      \[\leadsto x \cdot \color{blue}{\mathsf{fma}\left(\frac{1}{z - 1}, t, \frac{y}{z}\right)} \]
    3. Taylor expanded in y around 0

      \[\leadsto \color{blue}{\frac{t \cdot x}{z - 1}} \]
    4. Applied rewrites43.4%

      \[\leadsto \color{blue}{\frac{t \cdot x}{z - 1}} \]
    5. Taylor expanded in z around inf

      \[\leadsto \frac{t \cdot x}{\color{blue}{z}} \]
    6. Applied rewrites33.1%

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

    if -1.9e10 < z < 1.2e20

    1. Initial program 94.7%

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

      \[\leadsto x \cdot \color{blue}{\left(-1 \cdot \frac{t}{1 - z}\right)} \]
    3. Applied rewrites45.7%

      \[\leadsto x \cdot \color{blue}{\left(-1 \cdot \frac{t}{1 - z}\right)} \]
    4. Taylor expanded in z around 0

      \[\leadsto x \cdot \left(-1 \cdot t\right) \]
    5. Applied rewrites23.2%

      \[\leadsto x \cdot \left(-1 \cdot t\right) \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 14: 23.2% accurate, 2.3× speedup?

\[\begin{array}{l} \\ x \cdot \left(-1 \cdot t\right) \end{array} \]
(FPCore (x y z t) :precision binary64 (* x (* -1.0 t)))
double code(double x, double y, double z, double t) {
	return x * (-1.0 * t);
}
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)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    code = x * ((-1.0d0) * t)
end function
public static double code(double x, double y, double z, double t) {
	return x * (-1.0 * t);
}
def code(x, y, z, t):
	return x * (-1.0 * t)
function code(x, y, z, t)
	return Float64(x * Float64(-1.0 * t))
end
function tmp = code(x, y, z, t)
	tmp = x * (-1.0 * t);
end
code[x_, y_, z_, t_] := N[(x * N[(-1.0 * t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x \cdot \left(-1 \cdot t\right)
\end{array}
Derivation
  1. Initial program 94.7%

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

    \[\leadsto x \cdot \color{blue}{\left(-1 \cdot \frac{t}{1 - z}\right)} \]
  3. Applied rewrites45.7%

    \[\leadsto x \cdot \color{blue}{\left(-1 \cdot \frac{t}{1 - z}\right)} \]
  4. Taylor expanded in z around 0

    \[\leadsto x \cdot \left(-1 \cdot t\right) \]
  5. Applied rewrites23.2%

    \[\leadsto x \cdot \left(-1 \cdot t\right) \]
  6. Add Preprocessing

Reproduce

?
herbie shell --seed 2025153 
(FPCore (x y z t)
  :name "Numeric.SpecFunctions:invIncompleteBetaWorker from math-functions-0.1.5.2, C"
  :precision binary64
  (* x (- (/ y z) (/ t (- 1.0 z)))))