Graphics.Rendering.Chart.SparkLine:renderSparkLine from Chart-1.5.3

Percentage Accurate: 97.2% → 99.7%
Time: 17.5s
Alternatives: 13
Speedup: 1.1×

Specification

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

\\
x - \frac{y - z}{\frac{\left(t - z\right) + 1}{a}}
\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 13 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 97.2% accurate, 1.0× speedup?

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

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

Alternative 1: 99.7% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(\frac{z - y}{1 - \left(z - t\right)}, a, x\right) \end{array} \]
(FPCore (x y z t a) :precision binary64 (fma (/ (- z y) (- 1.0 (- z t))) a x))
double code(double x, double y, double z, double t, double a) {
	return fma(((z - y) / (1.0 - (z - t))), a, x);
}
function code(x, y, z, t, a)
	return fma(Float64(Float64(z - y) / Float64(1.0 - Float64(z - t))), a, x)
end
code[x_, y_, z_, t_, a_] := N[(N[(N[(z - y), $MachinePrecision] / N[(1.0 - N[(z - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * a + x), $MachinePrecision]
\begin{array}{l}

\\
\mathsf{fma}\left(\frac{z - y}{1 - \left(z - t\right)}, a, x\right)
\end{array}
Derivation
  1. Initial program 97.2%

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{z - y}{1 - \left(z - t\right)}, a, x\right)} \]
  3. Add Preprocessing

Alternative 2: 97.5% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(\frac{a}{\left(z - 1\right) - t}, y - z, x\right) \end{array} \]
(FPCore (x y z t a) :precision binary64 (fma (/ a (- (- z 1.0) t)) (- y z) x))
double code(double x, double y, double z, double t, double a) {
	return fma((a / ((z - 1.0) - t)), (y - z), x);
}
function code(x, y, z, t, a)
	return fma(Float64(a / Float64(Float64(z - 1.0) - t)), Float64(y - z), x)
end
code[x_, y_, z_, t_, a_] := N[(N[(a / N[(N[(z - 1.0), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision] * N[(y - z), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}

\\
\mathsf{fma}\left(\frac{a}{\left(z - 1\right) - t}, y - z, x\right)
\end{array}
Derivation
  1. Initial program 97.2%

    \[x - \frac{y - z}{\frac{\left(t - z\right) + 1}{a}} \]
  2. Applied rewrites97.5%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{a}{\left(z - 1\right) - t}, y - z, x\right)} \]
  3. Add Preprocessing

Alternative 3: 91.6% accurate, 0.8× speedup?

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

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

\mathbf{elif}\;t \leq 3.85 \cdot 10^{+68}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z - y}{1 - z}, a, x\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -1.18000000000000002e98 or 3.8499999999999999e68 < t

    1. Initial program 97.2%

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

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

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

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

    if -1.18000000000000002e98 < t < 3.8499999999999999e68

    1. Initial program 97.2%

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

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

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

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

Alternative 4: 90.4% accurate, 0.8× speedup?

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

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

\mathbf{elif}\;t \leq 3.85 \cdot 10^{+68}:\\
\;\;\;\;\mathsf{fma}\left(\frac{a}{z - 1}, y - z, x\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -1.18000000000000002e98 or 3.8499999999999999e68 < t

    1. Initial program 97.2%

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

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

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

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

    if -1.18000000000000002e98 < t < 3.8499999999999999e68

    1. Initial program 97.2%

      \[x - \frac{y - z}{\frac{\left(t - z\right) + 1}{a}} \]
    2. Applied rewrites97.5%

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

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

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

Alternative 5: 87.2% accurate, 0.9× speedup?

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

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

\mathbf{elif}\;z \leq 6.7 \cdot 10^{+38}:\\
\;\;\;\;x - \frac{a}{1 + t} \cdot y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.25999999999999995e26 or 6.70000000000000025e38 < z

    1. Initial program 97.2%

      \[x - \frac{y - z}{\frac{\left(t - z\right) + 1}{a}} \]
    2. Applied rewrites97.5%

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{a}{z}}, y - z, x\right) \]
    4. Applied rewrites57.7%

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

    if -1.25999999999999995e26 < z < 6.70000000000000025e38

    1. Initial program 97.2%

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

      \[\leadsto x - \color{blue}{\frac{a \cdot y}{1 + t}} \]
    3. Applied rewrites69.4%

      \[\leadsto x - \color{blue}{\frac{a \cdot y}{1 + t}} \]
    4. Applied rewrites71.8%

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

Alternative 6: 79.1% accurate, 0.9× speedup?

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

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

\mathbf{elif}\;t \leq 255:\\
\;\;\;\;x - \frac{y}{1 - z} \cdot a\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -1.1499999999999999e35 or 255 < t

    1. Initial program 97.2%

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

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

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

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

    if -1.1499999999999999e35 < t < 255

    1. Initial program 97.2%

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

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

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

      \[\leadsto x - \frac{a \cdot y}{\color{blue}{1 - z}} \]
    5. Applied rewrites64.1%

      \[\leadsto x - \frac{a \cdot y}{\color{blue}{1 - z}} \]
    6. Applied rewrites65.6%

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

Alternative 7: 77.9% accurate, 0.8× speedup?

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

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

\mathbf{elif}\;z \leq 6.2 \cdot 10^{-85}:\\
\;\;\;\;\mathsf{fma}\left(-1 \cdot a, y - z, x\right)\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -1 or 8.4999999999999997e38 < z

    1. Initial program 97.2%

      \[x - \frac{y - z}{\frac{\left(t - z\right) + 1}{a}} \]
    2. Applied rewrites97.5%

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{a}{z}}, y - z, x\right) \]
    4. Applied rewrites57.7%

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

    if -1 < z < 6.2000000000000005e-85

    1. Initial program 97.2%

      \[x - \frac{y - z}{\frac{\left(t - z\right) + 1}{a}} \]
    2. Applied rewrites97.5%

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

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

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

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

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

    if 6.2000000000000005e-85 < z < 8.4999999999999997e38

    1. Initial program 97.2%

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

      \[\leadsto x - \color{blue}{\frac{a \cdot y}{1 + t}} \]
    3. Applied rewrites69.4%

      \[\leadsto x - \color{blue}{\frac{a \cdot y}{1 + t}} \]
    4. Taylor expanded in t around inf

      \[\leadsto x - \frac{a \cdot y}{\color{blue}{t}} \]
    5. Applied rewrites54.1%

      \[\leadsto x - \frac{a \cdot y}{\color{blue}{t}} \]
    6. Applied rewrites55.8%

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

Alternative 8: 74.9% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -900000:\\
\;\;\;\;x - a\\

\mathbf{elif}\;z \leq 6.2 \cdot 10^{-85}:\\
\;\;\;\;\mathsf{fma}\left(-1 \cdot a, y - z, x\right)\\

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

\mathbf{else}:\\
\;\;\;\;x - a\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -9e5 or 3.2999999999999999e38 < z

    1. Initial program 97.2%

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

      \[\leadsto x - \color{blue}{a} \]
    3. Applied rewrites60.0%

      \[\leadsto x - \color{blue}{a} \]

    if -9e5 < z < 6.2000000000000005e-85

    1. Initial program 97.2%

      \[x - \frac{y - z}{\frac{\left(t - z\right) + 1}{a}} \]
    2. Applied rewrites97.5%

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

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

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

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

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

    if 6.2000000000000005e-85 < z < 3.2999999999999999e38

    1. Initial program 97.2%

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

      \[\leadsto x - \color{blue}{\frac{a \cdot y}{1 + t}} \]
    3. Applied rewrites69.4%

      \[\leadsto x - \color{blue}{\frac{a \cdot y}{1 + t}} \]
    4. Taylor expanded in t around inf

      \[\leadsto x - \frac{a \cdot y}{\color{blue}{t}} \]
    5. Applied rewrites54.1%

      \[\leadsto x - \frac{a \cdot y}{\color{blue}{t}} \]
    6. Applied rewrites55.8%

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

Alternative 9: 74.0% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -1050000:\\
\;\;\;\;x - a\\

\mathbf{elif}\;z \leq 6.2 \cdot 10^{-85}:\\
\;\;\;\;x - a \cdot y\\

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

\mathbf{else}:\\
\;\;\;\;x - a\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -1.05e6 or 3.2999999999999999e38 < z

    1. Initial program 97.2%

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

      \[\leadsto x - \color{blue}{a} \]
    3. Applied rewrites60.0%

      \[\leadsto x - \color{blue}{a} \]

    if -1.05e6 < z < 6.2000000000000005e-85

    1. Initial program 97.2%

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

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

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

      \[\leadsto x - \frac{a \cdot y}{\color{blue}{1 - z}} \]
    5. Applied rewrites64.1%

      \[\leadsto x - \frac{a \cdot y}{\color{blue}{1 - z}} \]
    6. Applied rewrites65.6%

      \[\leadsto x - \frac{y}{1 - z} \cdot a \]
    7. Taylor expanded in z around 0

      \[\leadsto x - a \cdot \color{blue}{y} \]
    8. Applied rewrites57.4%

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

    if 6.2000000000000005e-85 < z < 3.2999999999999999e38

    1. Initial program 97.2%

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

      \[\leadsto x - \color{blue}{\frac{a \cdot y}{1 + t}} \]
    3. Applied rewrites69.4%

      \[\leadsto x - \color{blue}{\frac{a \cdot y}{1 + t}} \]
    4. Taylor expanded in t around inf

      \[\leadsto x - \frac{a \cdot y}{\color{blue}{t}} \]
    5. Applied rewrites54.1%

      \[\leadsto x - \frac{a \cdot y}{\color{blue}{t}} \]
    6. Applied rewrites55.8%

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

Alternative 10: 74.0% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -1050000:\\
\;\;\;\;x - a\\

\mathbf{elif}\;z \leq 6.2 \cdot 10^{-85}:\\
\;\;\;\;x - a \cdot y\\

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

\mathbf{else}:\\
\;\;\;\;x - a\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -1.05e6 or 3.2999999999999999e38 < z

    1. Initial program 97.2%

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

      \[\leadsto x - \color{blue}{a} \]
    3. Applied rewrites60.0%

      \[\leadsto x - \color{blue}{a} \]

    if -1.05e6 < z < 6.2000000000000005e-85

    1. Initial program 97.2%

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

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

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

      \[\leadsto x - \frac{a \cdot y}{\color{blue}{1 - z}} \]
    5. Applied rewrites64.1%

      \[\leadsto x - \frac{a \cdot y}{\color{blue}{1 - z}} \]
    6. Applied rewrites65.6%

      \[\leadsto x - \frac{y}{1 - z} \cdot a \]
    7. Taylor expanded in z around 0

      \[\leadsto x - a \cdot \color{blue}{y} \]
    8. Applied rewrites57.4%

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

    if 6.2000000000000005e-85 < z < 3.2999999999999999e38

    1. Initial program 97.2%

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

      \[\leadsto x - \color{blue}{\frac{a \cdot y}{1 + t}} \]
    3. Applied rewrites69.4%

      \[\leadsto x - \color{blue}{\frac{a \cdot y}{1 + t}} \]
    4. Taylor expanded in t around inf

      \[\leadsto x - \frac{a \cdot y}{\color{blue}{t}} \]
    5. Applied rewrites54.1%

      \[\leadsto x - \frac{a \cdot y}{\color{blue}{t}} \]
    6. Applied rewrites55.6%

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

Alternative 11: 73.7% accurate, 1.3× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -1050000:\\
\;\;\;\;x - a\\

\mathbf{elif}\;z \leq 9.2 \cdot 10^{+16}:\\
\;\;\;\;x - a \cdot y\\

\mathbf{else}:\\
\;\;\;\;x - a\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.05e6 or 9.2e16 < z

    1. Initial program 97.2%

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

      \[\leadsto x - \color{blue}{a} \]
    3. Applied rewrites60.0%

      \[\leadsto x - \color{blue}{a} \]

    if -1.05e6 < z < 9.2e16

    1. Initial program 97.2%

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

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

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

      \[\leadsto x - \frac{a \cdot y}{\color{blue}{1 - z}} \]
    5. Applied rewrites64.1%

      \[\leadsto x - \frac{a \cdot y}{\color{blue}{1 - z}} \]
    6. Applied rewrites65.6%

      \[\leadsto x - \frac{y}{1 - z} \cdot a \]
    7. Taylor expanded in z around 0

      \[\leadsto x - a \cdot \color{blue}{y} \]
    8. Applied rewrites57.4%

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

Alternative 12: 66.1% accurate, 1.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -8 \cdot 10^{-59}:\\
\;\;\;\;x - a\\

\mathbf{elif}\;z \leq 1.02 \cdot 10^{+17}:\\
\;\;\;\;x \cdot 1\\

\mathbf{else}:\\
\;\;\;\;x - a\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -8.0000000000000002e-59 or 1.02e17 < z

    1. Initial program 97.2%

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

      \[\leadsto x - \color{blue}{a} \]
    3. Applied rewrites60.0%

      \[\leadsto x - \color{blue}{a} \]

    if -8.0000000000000002e-59 < z < 1.02e17

    1. Initial program 97.2%

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

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

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

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

      \[\leadsto x \cdot 1 \]
    6. Applied rewrites53.8%

      \[\leadsto x \cdot 1 \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 13: 60.0% accurate, 5.1× speedup?

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

\\
x - a
\end{array}
Derivation
  1. Initial program 97.2%

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

    \[\leadsto x - \color{blue}{a} \]
  3. Applied rewrites60.0%

    \[\leadsto x - \color{blue}{a} \]
  4. Add Preprocessing

Reproduce

?
herbie shell --seed 2025153 
(FPCore (x y z t a)
  :name "Graphics.Rendering.Chart.SparkLine:renderSparkLine from Chart-1.5.3"
  :precision binary64
  (- x (/ (- y z) (/ (+ (- t z) 1.0) a))))