Graphics.Rendering.Chart.Plot.AreaSpots:renderAreaSpots4D from Chart-1.5.3

Percentage Accurate: 84.1% → 97.2%
Time: 16.5s
Alternatives: 11
Speedup: 1.0×

Specification

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

\\
\frac{x \cdot \left(y - z\right)}{t - z}
\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 11 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: 84.1% accurate, 1.0× speedup?

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

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

Alternative 1: 97.2% accurate, 0.4× speedup?

\[\begin{array}{l} x\_m = \left|x\right| \\ x\_s = \mathsf{copysign}\left(1, x\right) \\ \begin{array}{l} t_1 := \frac{x\_m \cdot \left(y - z\right)}{t - z}\\ x\_s \cdot \begin{array}{l} \mathbf{if}\;t\_1 \leq 5 \cdot 10^{+193}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;\frac{z - y}{z - t} \cdot x\_m\\ \end{array} \end{array} \end{array} \]
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
(FPCore (x_s x_m y z t)
 :precision binary64
 (let* ((t_1 (/ (* x_m (- y z)) (- t z))))
   (* x_s (if (<= t_1 5e+193) t_1 (* (/ (- z y) (- z t)) x_m)))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z, double t) {
	double t_1 = (x_m * (y - z)) / (t - z);
	double tmp;
	if (t_1 <= 5e+193) {
		tmp = t_1;
	} else {
		tmp = ((z - y) / (z - t)) * x_m;
	}
	return x_s * tmp;
}
x\_m =     private
x\_s =     private
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_s, x_m, y, z, t)
use fmin_fmax_functions
    real(8), intent (in) :: x_s
    real(8), intent (in) :: x_m
    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_m * (y - z)) / (t - z)
    if (t_1 <= 5d+193) then
        tmp = t_1
    else
        tmp = ((z - y) / (z - t)) * x_m
    end if
    code = x_s * tmp
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z, double t) {
	double t_1 = (x_m * (y - z)) / (t - z);
	double tmp;
	if (t_1 <= 5e+193) {
		tmp = t_1;
	} else {
		tmp = ((z - y) / (z - t)) * x_m;
	}
	return x_s * tmp;
}
x\_m = math.fabs(x)
x\_s = math.copysign(1.0, x)
def code(x_s, x_m, y, z, t):
	t_1 = (x_m * (y - z)) / (t - z)
	tmp = 0
	if t_1 <= 5e+193:
		tmp = t_1
	else:
		tmp = ((z - y) / (z - t)) * x_m
	return x_s * tmp
x\_m = abs(x)
x\_s = copysign(1.0, x)
function code(x_s, x_m, y, z, t)
	t_1 = Float64(Float64(x_m * Float64(y - z)) / Float64(t - z))
	tmp = 0.0
	if (t_1 <= 5e+193)
		tmp = t_1;
	else
		tmp = Float64(Float64(Float64(z - y) / Float64(z - t)) * x_m);
	end
	return Float64(x_s * tmp)
end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
function tmp_2 = code(x_s, x_m, y, z, t)
	t_1 = (x_m * (y - z)) / (t - z);
	tmp = 0.0;
	if (t_1 <= 5e+193)
		tmp = t_1;
	else
		tmp = ((z - y) / (z - t)) * x_m;
	end
	tmp_2 = x_s * tmp;
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x$95$m * N[(y - z), $MachinePrecision]), $MachinePrecision] / N[(t - z), $MachinePrecision]), $MachinePrecision]}, N[(x$95$s * If[LessEqual[t$95$1, 5e+193], t$95$1, N[(N[(N[(z - y), $MachinePrecision] / N[(z - t), $MachinePrecision]), $MachinePrecision] * x$95$m), $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)

\\
\begin{array}{l}
t_1 := \frac{x\_m \cdot \left(y - z\right)}{t - z}\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_1 \leq 5 \cdot 10^{+193}:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (*.f64 x (-.f64 y z)) (-.f64 t z)) < 4.99999999999999972e193

    1. Initial program 84.1%

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

    if 4.99999999999999972e193 < (/.f64 (*.f64 x (-.f64 y z)) (-.f64 t z))

    1. Initial program 84.1%

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

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

Alternative 2: 94.9% accurate, 1.0× speedup?

\[\begin{array}{l} x\_m = \left|x\right| \\ x\_s = \mathsf{copysign}\left(1, x\right) \\ x\_s \cdot \left(\frac{z - y}{z - t} \cdot x\_m\right) \end{array} \]
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
(FPCore (x_s x_m y z t)
 :precision binary64
 (* x_s (* (/ (- z y) (- z t)) x_m)))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z, double t) {
	return x_s * (((z - y) / (z - t)) * x_m);
}
x\_m =     private
x\_s =     private
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_s, x_m, y, z, t)
use fmin_fmax_functions
    real(8), intent (in) :: x_s
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    code = x_s * (((z - y) / (z - t)) * x_m)
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z, double t) {
	return x_s * (((z - y) / (z - t)) * x_m);
}
x\_m = math.fabs(x)
x\_s = math.copysign(1.0, x)
def code(x_s, x_m, y, z, t):
	return x_s * (((z - y) / (z - t)) * x_m)
x\_m = abs(x)
x\_s = copysign(1.0, x)
function code(x_s, x_m, y, z, t)
	return Float64(x_s * Float64(Float64(Float64(z - y) / Float64(z - t)) * x_m))
end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
function tmp = code(x_s, x_m, y, z, t)
	tmp = x_s * (((z - y) / (z - t)) * x_m);
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_, t_] := N[(x$95$s * N[(N[(N[(z - y), $MachinePrecision] / N[(z - t), $MachinePrecision]), $MachinePrecision] * x$95$m), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)

\\
x\_s \cdot \left(\frac{z - y}{z - t} \cdot x\_m\right)
\end{array}
Derivation
  1. Initial program 84.1%

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

    \[\leadsto \color{blue}{\frac{z - y}{z - t} \cdot x} \]
  3. Add Preprocessing

Alternative 3: 89.7% accurate, 0.6× speedup?

\[\begin{array}{l} x\_m = \left|x\right| \\ x\_s = \mathsf{copysign}\left(1, x\right) \\ \begin{array}{l} t_1 := \frac{z - y}{z} \cdot x\_m\\ x\_s \cdot \begin{array}{l} \mathbf{if}\;z \leq -1.35 \cdot 10^{+141}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \leq 1.8 \cdot 10^{+129}:\\ \;\;\;\;\frac{x\_m}{z - t} \cdot \left(z - y\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \end{array} \]
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
(FPCore (x_s x_m y z t)
 :precision binary64
 (let* ((t_1 (* (/ (- z y) z) x_m)))
   (*
    x_s
    (if (<= z -1.35e+141)
      t_1
      (if (<= z 1.8e+129) (* (/ x_m (- z t)) (- z y)) t_1)))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z, double t) {
	double t_1 = ((z - y) / z) * x_m;
	double tmp;
	if (z <= -1.35e+141) {
		tmp = t_1;
	} else if (z <= 1.8e+129) {
		tmp = (x_m / (z - t)) * (z - y);
	} else {
		tmp = t_1;
	}
	return x_s * tmp;
}
x\_m =     private
x\_s =     private
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_s, x_m, y, z, t)
use fmin_fmax_functions
    real(8), intent (in) :: x_s
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: t_1
    real(8) :: tmp
    t_1 = ((z - y) / z) * x_m
    if (z <= (-1.35d+141)) then
        tmp = t_1
    else if (z <= 1.8d+129) then
        tmp = (x_m / (z - t)) * (z - y)
    else
        tmp = t_1
    end if
    code = x_s * tmp
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z, double t) {
	double t_1 = ((z - y) / z) * x_m;
	double tmp;
	if (z <= -1.35e+141) {
		tmp = t_1;
	} else if (z <= 1.8e+129) {
		tmp = (x_m / (z - t)) * (z - y);
	} else {
		tmp = t_1;
	}
	return x_s * tmp;
}
x\_m = math.fabs(x)
x\_s = math.copysign(1.0, x)
def code(x_s, x_m, y, z, t):
	t_1 = ((z - y) / z) * x_m
	tmp = 0
	if z <= -1.35e+141:
		tmp = t_1
	elif z <= 1.8e+129:
		tmp = (x_m / (z - t)) * (z - y)
	else:
		tmp = t_1
	return x_s * tmp
x\_m = abs(x)
x\_s = copysign(1.0, x)
function code(x_s, x_m, y, z, t)
	t_1 = Float64(Float64(Float64(z - y) / z) * x_m)
	tmp = 0.0
	if (z <= -1.35e+141)
		tmp = t_1;
	elseif (z <= 1.8e+129)
		tmp = Float64(Float64(x_m / Float64(z - t)) * Float64(z - y));
	else
		tmp = t_1;
	end
	return Float64(x_s * tmp)
end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
function tmp_2 = code(x_s, x_m, y, z, t)
	t_1 = ((z - y) / z) * x_m;
	tmp = 0.0;
	if (z <= -1.35e+141)
		tmp = t_1;
	elseif (z <= 1.8e+129)
		tmp = (x_m / (z - t)) * (z - y);
	else
		tmp = t_1;
	end
	tmp_2 = x_s * tmp;
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_, t_] := Block[{t$95$1 = N[(N[(N[(z - y), $MachinePrecision] / z), $MachinePrecision] * x$95$m), $MachinePrecision]}, N[(x$95$s * If[LessEqual[z, -1.35e+141], t$95$1, If[LessEqual[z, 1.8e+129], N[(N[(x$95$m / N[(z - t), $MachinePrecision]), $MachinePrecision] * N[(z - y), $MachinePrecision]), $MachinePrecision], t$95$1]]), $MachinePrecision]]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)

\\
\begin{array}{l}
t_1 := \frac{z - y}{z} \cdot x\_m\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq -1.35 \cdot 10^{+141}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;z \leq 1.8 \cdot 10^{+129}:\\
\;\;\;\;\frac{x\_m}{z - t} \cdot \left(z - y\right)\\

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


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.35e141 or 1.8000000000000001e129 < z

    1. Initial program 84.1%

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

      \[\leadsto \color{blue}{\frac{z - y}{z - t} \cdot x} \]
    3. Taylor expanded in t around 0

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

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

    if -1.35e141 < z < 1.8000000000000001e129

    1. Initial program 84.1%

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

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

Alternative 4: 74.8% accurate, 0.6× speedup?

\[\begin{array}{l} x\_m = \left|x\right| \\ x\_s = \mathsf{copysign}\left(1, x\right) \\ x\_s \cdot \begin{array}{l} \mathbf{if}\;z \leq -6 \cdot 10^{+58}:\\ \;\;\;\;\frac{z}{z - t} \cdot x\_m\\ \mathbf{elif}\;z \leq -1.9 \cdot 10^{-122}:\\ \;\;\;\;\frac{x\_m \cdot \left(y - z\right)}{t}\\ \mathbf{elif}\;z \leq 1.4 \cdot 10^{+16}:\\ \;\;\;\;\frac{x\_m \cdot y}{t - z}\\ \mathbf{else}:\\ \;\;\;\;\frac{z - y}{z} \cdot x\_m\\ \end{array} \end{array} \]
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
(FPCore (x_s x_m y z t)
 :precision binary64
 (*
  x_s
  (if (<= z -6e+58)
    (* (/ z (- z t)) x_m)
    (if (<= z -1.9e-122)
      (/ (* x_m (- y z)) t)
      (if (<= z 1.4e+16) (/ (* x_m y) (- t z)) (* (/ (- z y) z) x_m))))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z, double t) {
	double tmp;
	if (z <= -6e+58) {
		tmp = (z / (z - t)) * x_m;
	} else if (z <= -1.9e-122) {
		tmp = (x_m * (y - z)) / t;
	} else if (z <= 1.4e+16) {
		tmp = (x_m * y) / (t - z);
	} else {
		tmp = ((z - y) / z) * x_m;
	}
	return x_s * tmp;
}
x\_m =     private
x\_s =     private
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_s, x_m, y, z, t)
use fmin_fmax_functions
    real(8), intent (in) :: x_s
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: tmp
    if (z <= (-6d+58)) then
        tmp = (z / (z - t)) * x_m
    else if (z <= (-1.9d-122)) then
        tmp = (x_m * (y - z)) / t
    else if (z <= 1.4d+16) then
        tmp = (x_m * y) / (t - z)
    else
        tmp = ((z - y) / z) * x_m
    end if
    code = x_s * tmp
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z, double t) {
	double tmp;
	if (z <= -6e+58) {
		tmp = (z / (z - t)) * x_m;
	} else if (z <= -1.9e-122) {
		tmp = (x_m * (y - z)) / t;
	} else if (z <= 1.4e+16) {
		tmp = (x_m * y) / (t - z);
	} else {
		tmp = ((z - y) / z) * x_m;
	}
	return x_s * tmp;
}
x\_m = math.fabs(x)
x\_s = math.copysign(1.0, x)
def code(x_s, x_m, y, z, t):
	tmp = 0
	if z <= -6e+58:
		tmp = (z / (z - t)) * x_m
	elif z <= -1.9e-122:
		tmp = (x_m * (y - z)) / t
	elif z <= 1.4e+16:
		tmp = (x_m * y) / (t - z)
	else:
		tmp = ((z - y) / z) * x_m
	return x_s * tmp
x\_m = abs(x)
x\_s = copysign(1.0, x)
function code(x_s, x_m, y, z, t)
	tmp = 0.0
	if (z <= -6e+58)
		tmp = Float64(Float64(z / Float64(z - t)) * x_m);
	elseif (z <= -1.9e-122)
		tmp = Float64(Float64(x_m * Float64(y - z)) / t);
	elseif (z <= 1.4e+16)
		tmp = Float64(Float64(x_m * y) / Float64(t - z));
	else
		tmp = Float64(Float64(Float64(z - y) / z) * x_m);
	end
	return Float64(x_s * tmp)
end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
function tmp_2 = code(x_s, x_m, y, z, t)
	tmp = 0.0;
	if (z <= -6e+58)
		tmp = (z / (z - t)) * x_m;
	elseif (z <= -1.9e-122)
		tmp = (x_m * (y - z)) / t;
	elseif (z <= 1.4e+16)
		tmp = (x_m * y) / (t - z);
	else
		tmp = ((z - y) / z) * x_m;
	end
	tmp_2 = x_s * tmp;
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_, t_] := N[(x$95$s * If[LessEqual[z, -6e+58], N[(N[(z / N[(z - t), $MachinePrecision]), $MachinePrecision] * x$95$m), $MachinePrecision], If[LessEqual[z, -1.9e-122], N[(N[(x$95$m * N[(y - z), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision], If[LessEqual[z, 1.4e+16], N[(N[(x$95$m * y), $MachinePrecision] / N[(t - z), $MachinePrecision]), $MachinePrecision], N[(N[(N[(z - y), $MachinePrecision] / z), $MachinePrecision] * x$95$m), $MachinePrecision]]]]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)

\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq -6 \cdot 10^{+58}:\\
\;\;\;\;\frac{z}{z - t} \cdot x\_m\\

\mathbf{elif}\;z \leq -1.9 \cdot 10^{-122}:\\
\;\;\;\;\frac{x\_m \cdot \left(y - z\right)}{t}\\

\mathbf{elif}\;z \leq 1.4 \cdot 10^{+16}:\\
\;\;\;\;\frac{x\_m \cdot y}{t - z}\\

\mathbf{else}:\\
\;\;\;\;\frac{z - y}{z} \cdot x\_m\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if z < -6.0000000000000005e58

    1. Initial program 84.1%

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

      \[\leadsto \color{blue}{\frac{z - y}{z - t} \cdot x} \]
    3. Taylor expanded in y around 0

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

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

    if -6.0000000000000005e58 < z < -1.9e-122

    1. Initial program 84.1%

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

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

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

    if -1.9e-122 < z < 1.4e16

    1. Initial program 84.1%

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

      \[\leadsto \frac{\color{blue}{x \cdot y}}{t - z} \]
    3. Applied rewrites49.7%

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

    if 1.4e16 < z

    1. Initial program 84.1%

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

      \[\leadsto \color{blue}{\frac{z - y}{z - t} \cdot x} \]
    3. Taylor expanded in t around 0

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

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

Alternative 5: 74.3% accurate, 0.7× speedup?

\[\begin{array}{l} x\_m = \left|x\right| \\ x\_s = \mathsf{copysign}\left(1, x\right) \\ x\_s \cdot \begin{array}{l} \mathbf{if}\;z \leq -4.4 \cdot 10^{+58}:\\ \;\;\;\;\frac{z}{z - t} \cdot x\_m\\ \mathbf{elif}\;z \leq 1.4 \cdot 10^{+16}:\\ \;\;\;\;\frac{x\_m \cdot y}{t - z}\\ \mathbf{else}:\\ \;\;\;\;\frac{z - y}{z} \cdot x\_m\\ \end{array} \end{array} \]
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
(FPCore (x_s x_m y z t)
 :precision binary64
 (*
  x_s
  (if (<= z -4.4e+58)
    (* (/ z (- z t)) x_m)
    (if (<= z 1.4e+16) (/ (* x_m y) (- t z)) (* (/ (- z y) z) x_m)))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z, double t) {
	double tmp;
	if (z <= -4.4e+58) {
		tmp = (z / (z - t)) * x_m;
	} else if (z <= 1.4e+16) {
		tmp = (x_m * y) / (t - z);
	} else {
		tmp = ((z - y) / z) * x_m;
	}
	return x_s * tmp;
}
x\_m =     private
x\_s =     private
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_s, x_m, y, z, t)
use fmin_fmax_functions
    real(8), intent (in) :: x_s
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: tmp
    if (z <= (-4.4d+58)) then
        tmp = (z / (z - t)) * x_m
    else if (z <= 1.4d+16) then
        tmp = (x_m * y) / (t - z)
    else
        tmp = ((z - y) / z) * x_m
    end if
    code = x_s * tmp
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z, double t) {
	double tmp;
	if (z <= -4.4e+58) {
		tmp = (z / (z - t)) * x_m;
	} else if (z <= 1.4e+16) {
		tmp = (x_m * y) / (t - z);
	} else {
		tmp = ((z - y) / z) * x_m;
	}
	return x_s * tmp;
}
x\_m = math.fabs(x)
x\_s = math.copysign(1.0, x)
def code(x_s, x_m, y, z, t):
	tmp = 0
	if z <= -4.4e+58:
		tmp = (z / (z - t)) * x_m
	elif z <= 1.4e+16:
		tmp = (x_m * y) / (t - z)
	else:
		tmp = ((z - y) / z) * x_m
	return x_s * tmp
x\_m = abs(x)
x\_s = copysign(1.0, x)
function code(x_s, x_m, y, z, t)
	tmp = 0.0
	if (z <= -4.4e+58)
		tmp = Float64(Float64(z / Float64(z - t)) * x_m);
	elseif (z <= 1.4e+16)
		tmp = Float64(Float64(x_m * y) / Float64(t - z));
	else
		tmp = Float64(Float64(Float64(z - y) / z) * x_m);
	end
	return Float64(x_s * tmp)
end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
function tmp_2 = code(x_s, x_m, y, z, t)
	tmp = 0.0;
	if (z <= -4.4e+58)
		tmp = (z / (z - t)) * x_m;
	elseif (z <= 1.4e+16)
		tmp = (x_m * y) / (t - z);
	else
		tmp = ((z - y) / z) * x_m;
	end
	tmp_2 = x_s * tmp;
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_, t_] := N[(x$95$s * If[LessEqual[z, -4.4e+58], N[(N[(z / N[(z - t), $MachinePrecision]), $MachinePrecision] * x$95$m), $MachinePrecision], If[LessEqual[z, 1.4e+16], N[(N[(x$95$m * y), $MachinePrecision] / N[(t - z), $MachinePrecision]), $MachinePrecision], N[(N[(N[(z - y), $MachinePrecision] / z), $MachinePrecision] * x$95$m), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)

\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq -4.4 \cdot 10^{+58}:\\
\;\;\;\;\frac{z}{z - t} \cdot x\_m\\

\mathbf{elif}\;z \leq 1.4 \cdot 10^{+16}:\\
\;\;\;\;\frac{x\_m \cdot y}{t - z}\\

\mathbf{else}:\\
\;\;\;\;\frac{z - y}{z} \cdot x\_m\\


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

    1. Initial program 84.1%

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

      \[\leadsto \color{blue}{\frac{z - y}{z - t} \cdot x} \]
    3. Taylor expanded in y around 0

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

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

    if -4.4000000000000001e58 < z < 1.4e16

    1. Initial program 84.1%

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

      \[\leadsto \frac{\color{blue}{x \cdot y}}{t - z} \]
    3. Applied rewrites49.7%

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

    if 1.4e16 < z

    1. Initial program 84.1%

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

      \[\leadsto \color{blue}{\frac{z - y}{z - t} \cdot x} \]
    3. Taylor expanded in t around 0

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

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

Alternative 6: 66.3% accurate, 0.7× speedup?

\[\begin{array}{l} x\_m = \left|x\right| \\ x\_s = \mathsf{copysign}\left(1, x\right) \\ x\_s \cdot \begin{array}{l} \mathbf{if}\;z \leq -5 \cdot 10^{-121}:\\ \;\;\;\;\frac{z}{z - t} \cdot x\_m\\ \mathbf{elif}\;z \leq 2.5 \cdot 10^{-189}:\\ \;\;\;\;\frac{x\_m \cdot y}{t}\\ \mathbf{else}:\\ \;\;\;\;\frac{z - y}{z} \cdot x\_m\\ \end{array} \end{array} \]
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
(FPCore (x_s x_m y z t)
 :precision binary64
 (*
  x_s
  (if (<= z -5e-121)
    (* (/ z (- z t)) x_m)
    (if (<= z 2.5e-189) (/ (* x_m y) t) (* (/ (- z y) z) x_m)))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z, double t) {
	double tmp;
	if (z <= -5e-121) {
		tmp = (z / (z - t)) * x_m;
	} else if (z <= 2.5e-189) {
		tmp = (x_m * y) / t;
	} else {
		tmp = ((z - y) / z) * x_m;
	}
	return x_s * tmp;
}
x\_m =     private
x\_s =     private
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_s, x_m, y, z, t)
use fmin_fmax_functions
    real(8), intent (in) :: x_s
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: tmp
    if (z <= (-5d-121)) then
        tmp = (z / (z - t)) * x_m
    else if (z <= 2.5d-189) then
        tmp = (x_m * y) / t
    else
        tmp = ((z - y) / z) * x_m
    end if
    code = x_s * tmp
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z, double t) {
	double tmp;
	if (z <= -5e-121) {
		tmp = (z / (z - t)) * x_m;
	} else if (z <= 2.5e-189) {
		tmp = (x_m * y) / t;
	} else {
		tmp = ((z - y) / z) * x_m;
	}
	return x_s * tmp;
}
x\_m = math.fabs(x)
x\_s = math.copysign(1.0, x)
def code(x_s, x_m, y, z, t):
	tmp = 0
	if z <= -5e-121:
		tmp = (z / (z - t)) * x_m
	elif z <= 2.5e-189:
		tmp = (x_m * y) / t
	else:
		tmp = ((z - y) / z) * x_m
	return x_s * tmp
x\_m = abs(x)
x\_s = copysign(1.0, x)
function code(x_s, x_m, y, z, t)
	tmp = 0.0
	if (z <= -5e-121)
		tmp = Float64(Float64(z / Float64(z - t)) * x_m);
	elseif (z <= 2.5e-189)
		tmp = Float64(Float64(x_m * y) / t);
	else
		tmp = Float64(Float64(Float64(z - y) / z) * x_m);
	end
	return Float64(x_s * tmp)
end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
function tmp_2 = code(x_s, x_m, y, z, t)
	tmp = 0.0;
	if (z <= -5e-121)
		tmp = (z / (z - t)) * x_m;
	elseif (z <= 2.5e-189)
		tmp = (x_m * y) / t;
	else
		tmp = ((z - y) / z) * x_m;
	end
	tmp_2 = x_s * tmp;
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_, t_] := N[(x$95$s * If[LessEqual[z, -5e-121], N[(N[(z / N[(z - t), $MachinePrecision]), $MachinePrecision] * x$95$m), $MachinePrecision], If[LessEqual[z, 2.5e-189], N[(N[(x$95$m * y), $MachinePrecision] / t), $MachinePrecision], N[(N[(N[(z - y), $MachinePrecision] / z), $MachinePrecision] * x$95$m), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)

\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq -5 \cdot 10^{-121}:\\
\;\;\;\;\frac{z}{z - t} \cdot x\_m\\

\mathbf{elif}\;z \leq 2.5 \cdot 10^{-189}:\\
\;\;\;\;\frac{x\_m \cdot y}{t}\\

\mathbf{else}:\\
\;\;\;\;\frac{z - y}{z} \cdot x\_m\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -4.99999999999999989e-121

    1. Initial program 84.1%

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

      \[\leadsto \color{blue}{\frac{z - y}{z - t} \cdot x} \]
    3. Taylor expanded in y around 0

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

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

    if -4.99999999999999989e-121 < z < 2.4999999999999999e-189

    1. Initial program 84.1%

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

      \[\leadsto \color{blue}{\frac{x \cdot y}{t}} \]
    3. Applied rewrites37.2%

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

    if 2.4999999999999999e-189 < z

    1. Initial program 84.1%

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

      \[\leadsto \color{blue}{\frac{z - y}{z - t} \cdot x} \]
    3. Taylor expanded in t around 0

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

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

Alternative 7: 66.1% accurate, 0.7× speedup?

\[\begin{array}{l} x\_m = \left|x\right| \\ x\_s = \mathsf{copysign}\left(1, x\right) \\ \begin{array}{l} t_1 := \frac{z - y}{z} \cdot x\_m\\ x\_s \cdot \begin{array}{l} \mathbf{if}\;z \leq -2.65 \cdot 10^{+51}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \leq 2.5 \cdot 10^{-189}:\\ \;\;\;\;\frac{x\_m}{t} \cdot y\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \end{array} \]
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
(FPCore (x_s x_m y z t)
 :precision binary64
 (let* ((t_1 (* (/ (- z y) z) x_m)))
   (* x_s (if (<= z -2.65e+51) t_1 (if (<= z 2.5e-189) (* (/ x_m t) y) t_1)))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z, double t) {
	double t_1 = ((z - y) / z) * x_m;
	double tmp;
	if (z <= -2.65e+51) {
		tmp = t_1;
	} else if (z <= 2.5e-189) {
		tmp = (x_m / t) * y;
	} else {
		tmp = t_1;
	}
	return x_s * tmp;
}
x\_m =     private
x\_s =     private
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_s, x_m, y, z, t)
use fmin_fmax_functions
    real(8), intent (in) :: x_s
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: t_1
    real(8) :: tmp
    t_1 = ((z - y) / z) * x_m
    if (z <= (-2.65d+51)) then
        tmp = t_1
    else if (z <= 2.5d-189) then
        tmp = (x_m / t) * y
    else
        tmp = t_1
    end if
    code = x_s * tmp
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z, double t) {
	double t_1 = ((z - y) / z) * x_m;
	double tmp;
	if (z <= -2.65e+51) {
		tmp = t_1;
	} else if (z <= 2.5e-189) {
		tmp = (x_m / t) * y;
	} else {
		tmp = t_1;
	}
	return x_s * tmp;
}
x\_m = math.fabs(x)
x\_s = math.copysign(1.0, x)
def code(x_s, x_m, y, z, t):
	t_1 = ((z - y) / z) * x_m
	tmp = 0
	if z <= -2.65e+51:
		tmp = t_1
	elif z <= 2.5e-189:
		tmp = (x_m / t) * y
	else:
		tmp = t_1
	return x_s * tmp
x\_m = abs(x)
x\_s = copysign(1.0, x)
function code(x_s, x_m, y, z, t)
	t_1 = Float64(Float64(Float64(z - y) / z) * x_m)
	tmp = 0.0
	if (z <= -2.65e+51)
		tmp = t_1;
	elseif (z <= 2.5e-189)
		tmp = Float64(Float64(x_m / t) * y);
	else
		tmp = t_1;
	end
	return Float64(x_s * tmp)
end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
function tmp_2 = code(x_s, x_m, y, z, t)
	t_1 = ((z - y) / z) * x_m;
	tmp = 0.0;
	if (z <= -2.65e+51)
		tmp = t_1;
	elseif (z <= 2.5e-189)
		tmp = (x_m / t) * y;
	else
		tmp = t_1;
	end
	tmp_2 = x_s * tmp;
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_, t_] := Block[{t$95$1 = N[(N[(N[(z - y), $MachinePrecision] / z), $MachinePrecision] * x$95$m), $MachinePrecision]}, N[(x$95$s * If[LessEqual[z, -2.65e+51], t$95$1, If[LessEqual[z, 2.5e-189], N[(N[(x$95$m / t), $MachinePrecision] * y), $MachinePrecision], t$95$1]]), $MachinePrecision]]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)

\\
\begin{array}{l}
t_1 := \frac{z - y}{z} \cdot x\_m\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq -2.65 \cdot 10^{+51}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;z \leq 2.5 \cdot 10^{-189}:\\
\;\;\;\;\frac{x\_m}{t} \cdot y\\

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


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -2.6499999999999998e51 or 2.4999999999999999e-189 < z

    1. Initial program 84.1%

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

      \[\leadsto \color{blue}{\frac{z - y}{z - t} \cdot x} \]
    3. Taylor expanded in t around 0

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

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

    if -2.6499999999999998e51 < z < 2.4999999999999999e-189

    1. Initial program 84.1%

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

      \[\leadsto \color{blue}{\frac{x \cdot y}{t}} \]
    3. Applied rewrites37.2%

      \[\leadsto \color{blue}{\frac{x \cdot y}{t}} \]
    4. Applied rewrites37.2%

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

Alternative 8: 60.6% accurate, 0.3× speedup?

\[\begin{array}{l} x\_m = \left|x\right| \\ x\_s = \mathsf{copysign}\left(1, x\right) \\ \begin{array}{l} t_1 := \frac{x\_m \cdot \left(y - z\right)}{t - z}\\ x\_s \cdot \begin{array}{l} \mathbf{if}\;t\_1 \leq 4 \cdot 10^{-282}:\\ \;\;\;\;\frac{x\_m \cdot y}{t}\\ \mathbf{elif}\;t\_1 \leq 10^{-80}:\\ \;\;\;\;1 \cdot x\_m\\ \mathbf{else}:\\ \;\;\;\;\frac{x\_m}{z} \cdot \left(z - y\right)\\ \end{array} \end{array} \end{array} \]
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
(FPCore (x_s x_m y z t)
 :precision binary64
 (let* ((t_1 (/ (* x_m (- y z)) (- t z))))
   (*
    x_s
    (if (<= t_1 4e-282)
      (/ (* x_m y) t)
      (if (<= t_1 1e-80) (* 1.0 x_m) (* (/ x_m z) (- z y)))))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z, double t) {
	double t_1 = (x_m * (y - z)) / (t - z);
	double tmp;
	if (t_1 <= 4e-282) {
		tmp = (x_m * y) / t;
	} else if (t_1 <= 1e-80) {
		tmp = 1.0 * x_m;
	} else {
		tmp = (x_m / z) * (z - y);
	}
	return x_s * tmp;
}
x\_m =     private
x\_s =     private
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_s, x_m, y, z, t)
use fmin_fmax_functions
    real(8), intent (in) :: x_s
    real(8), intent (in) :: x_m
    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_m * (y - z)) / (t - z)
    if (t_1 <= 4d-282) then
        tmp = (x_m * y) / t
    else if (t_1 <= 1d-80) then
        tmp = 1.0d0 * x_m
    else
        tmp = (x_m / z) * (z - y)
    end if
    code = x_s * tmp
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z, double t) {
	double t_1 = (x_m * (y - z)) / (t - z);
	double tmp;
	if (t_1 <= 4e-282) {
		tmp = (x_m * y) / t;
	} else if (t_1 <= 1e-80) {
		tmp = 1.0 * x_m;
	} else {
		tmp = (x_m / z) * (z - y);
	}
	return x_s * tmp;
}
x\_m = math.fabs(x)
x\_s = math.copysign(1.0, x)
def code(x_s, x_m, y, z, t):
	t_1 = (x_m * (y - z)) / (t - z)
	tmp = 0
	if t_1 <= 4e-282:
		tmp = (x_m * y) / t
	elif t_1 <= 1e-80:
		tmp = 1.0 * x_m
	else:
		tmp = (x_m / z) * (z - y)
	return x_s * tmp
x\_m = abs(x)
x\_s = copysign(1.0, x)
function code(x_s, x_m, y, z, t)
	t_1 = Float64(Float64(x_m * Float64(y - z)) / Float64(t - z))
	tmp = 0.0
	if (t_1 <= 4e-282)
		tmp = Float64(Float64(x_m * y) / t);
	elseif (t_1 <= 1e-80)
		tmp = Float64(1.0 * x_m);
	else
		tmp = Float64(Float64(x_m / z) * Float64(z - y));
	end
	return Float64(x_s * tmp)
end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
function tmp_2 = code(x_s, x_m, y, z, t)
	t_1 = (x_m * (y - z)) / (t - z);
	tmp = 0.0;
	if (t_1 <= 4e-282)
		tmp = (x_m * y) / t;
	elseif (t_1 <= 1e-80)
		tmp = 1.0 * x_m;
	else
		tmp = (x_m / z) * (z - y);
	end
	tmp_2 = x_s * tmp;
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x$95$m * N[(y - z), $MachinePrecision]), $MachinePrecision] / N[(t - z), $MachinePrecision]), $MachinePrecision]}, N[(x$95$s * If[LessEqual[t$95$1, 4e-282], N[(N[(x$95$m * y), $MachinePrecision] / t), $MachinePrecision], If[LessEqual[t$95$1, 1e-80], N[(1.0 * x$95$m), $MachinePrecision], N[(N[(x$95$m / z), $MachinePrecision] * N[(z - y), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)

\\
\begin{array}{l}
t_1 := \frac{x\_m \cdot \left(y - z\right)}{t - z}\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_1 \leq 4 \cdot 10^{-282}:\\
\;\;\;\;\frac{x\_m \cdot y}{t}\\

\mathbf{elif}\;t\_1 \leq 10^{-80}:\\
\;\;\;\;1 \cdot x\_m\\

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


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 (*.f64 x (-.f64 y z)) (-.f64 t z)) < 4.0000000000000001e-282

    1. Initial program 84.1%

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

      \[\leadsto \color{blue}{\frac{x \cdot y}{t}} \]
    3. Applied rewrites37.2%

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

    if 4.0000000000000001e-282 < (/.f64 (*.f64 x (-.f64 y z)) (-.f64 t z)) < 9.99999999999999961e-81

    1. Initial program 84.1%

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

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

      \[\leadsto \color{blue}{1} \cdot x \]
    4. Applied rewrites35.3%

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

    if 9.99999999999999961e-81 < (/.f64 (*.f64 x (-.f64 y z)) (-.f64 t z))

    1. Initial program 84.1%

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

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

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

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

Alternative 9: 60.2% accurate, 0.8× speedup?

\[\begin{array}{l} x\_m = \left|x\right| \\ x\_s = \mathsf{copysign}\left(1, x\right) \\ x\_s \cdot \begin{array}{l} \mathbf{if}\;z \leq -4.4 \cdot 10^{+58}:\\ \;\;\;\;1 \cdot x\_m\\ \mathbf{elif}\;z \leq 1.55 \cdot 10^{+16}:\\ \;\;\;\;\frac{x\_m}{t} \cdot y\\ \mathbf{else}:\\ \;\;\;\;1 \cdot x\_m\\ \end{array} \end{array} \]
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
(FPCore (x_s x_m y z t)
 :precision binary64
 (*
  x_s
  (if (<= z -4.4e+58)
    (* 1.0 x_m)
    (if (<= z 1.55e+16) (* (/ x_m t) y) (* 1.0 x_m)))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z, double t) {
	double tmp;
	if (z <= -4.4e+58) {
		tmp = 1.0 * x_m;
	} else if (z <= 1.55e+16) {
		tmp = (x_m / t) * y;
	} else {
		tmp = 1.0 * x_m;
	}
	return x_s * tmp;
}
x\_m =     private
x\_s =     private
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_s, x_m, y, z, t)
use fmin_fmax_functions
    real(8), intent (in) :: x_s
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: tmp
    if (z <= (-4.4d+58)) then
        tmp = 1.0d0 * x_m
    else if (z <= 1.55d+16) then
        tmp = (x_m / t) * y
    else
        tmp = 1.0d0 * x_m
    end if
    code = x_s * tmp
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z, double t) {
	double tmp;
	if (z <= -4.4e+58) {
		tmp = 1.0 * x_m;
	} else if (z <= 1.55e+16) {
		tmp = (x_m / t) * y;
	} else {
		tmp = 1.0 * x_m;
	}
	return x_s * tmp;
}
x\_m = math.fabs(x)
x\_s = math.copysign(1.0, x)
def code(x_s, x_m, y, z, t):
	tmp = 0
	if z <= -4.4e+58:
		tmp = 1.0 * x_m
	elif z <= 1.55e+16:
		tmp = (x_m / t) * y
	else:
		tmp = 1.0 * x_m
	return x_s * tmp
x\_m = abs(x)
x\_s = copysign(1.0, x)
function code(x_s, x_m, y, z, t)
	tmp = 0.0
	if (z <= -4.4e+58)
		tmp = Float64(1.0 * x_m);
	elseif (z <= 1.55e+16)
		tmp = Float64(Float64(x_m / t) * y);
	else
		tmp = Float64(1.0 * x_m);
	end
	return Float64(x_s * tmp)
end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
function tmp_2 = code(x_s, x_m, y, z, t)
	tmp = 0.0;
	if (z <= -4.4e+58)
		tmp = 1.0 * x_m;
	elseif (z <= 1.55e+16)
		tmp = (x_m / t) * y;
	else
		tmp = 1.0 * x_m;
	end
	tmp_2 = x_s * tmp;
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_, t_] := N[(x$95$s * If[LessEqual[z, -4.4e+58], N[(1.0 * x$95$m), $MachinePrecision], If[LessEqual[z, 1.55e+16], N[(N[(x$95$m / t), $MachinePrecision] * y), $MachinePrecision], N[(1.0 * x$95$m), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)

\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq -4.4 \cdot 10^{+58}:\\
\;\;\;\;1 \cdot x\_m\\

\mathbf{elif}\;z \leq 1.55 \cdot 10^{+16}:\\
\;\;\;\;\frac{x\_m}{t} \cdot y\\

\mathbf{else}:\\
\;\;\;\;1 \cdot x\_m\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -4.4000000000000001e58 or 1.55e16 < z

    1. Initial program 84.1%

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

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

      \[\leadsto \color{blue}{1} \cdot x \]
    4. Applied rewrites35.3%

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

    if -4.4000000000000001e58 < z < 1.55e16

    1. Initial program 84.1%

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

      \[\leadsto \color{blue}{\frac{x \cdot y}{t}} \]
    3. Applied rewrites37.2%

      \[\leadsto \color{blue}{\frac{x \cdot y}{t}} \]
    4. Applied rewrites37.2%

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

Alternative 10: 54.3% accurate, 0.6× speedup?

\[\begin{array}{l} x\_m = \left|x\right| \\ x\_s = \mathsf{copysign}\left(1, x\right) \\ x\_s \cdot \begin{array}{l} \mathbf{if}\;\frac{x\_m \cdot \left(y - z\right)}{t - z} \leq 4 \cdot 10^{-282}:\\ \;\;\;\;\frac{x\_m \cdot y}{t}\\ \mathbf{else}:\\ \;\;\;\;1 \cdot x\_m\\ \end{array} \end{array} \]
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
(FPCore (x_s x_m y z t)
 :precision binary64
 (*
  x_s
  (if (<= (/ (* x_m (- y z)) (- t z)) 4e-282) (/ (* x_m y) t) (* 1.0 x_m))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z, double t) {
	double tmp;
	if (((x_m * (y - z)) / (t - z)) <= 4e-282) {
		tmp = (x_m * y) / t;
	} else {
		tmp = 1.0 * x_m;
	}
	return x_s * tmp;
}
x\_m =     private
x\_s =     private
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_s, x_m, y, z, t)
use fmin_fmax_functions
    real(8), intent (in) :: x_s
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: tmp
    if (((x_m * (y - z)) / (t - z)) <= 4d-282) then
        tmp = (x_m * y) / t
    else
        tmp = 1.0d0 * x_m
    end if
    code = x_s * tmp
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z, double t) {
	double tmp;
	if (((x_m * (y - z)) / (t - z)) <= 4e-282) {
		tmp = (x_m * y) / t;
	} else {
		tmp = 1.0 * x_m;
	}
	return x_s * tmp;
}
x\_m = math.fabs(x)
x\_s = math.copysign(1.0, x)
def code(x_s, x_m, y, z, t):
	tmp = 0
	if ((x_m * (y - z)) / (t - z)) <= 4e-282:
		tmp = (x_m * y) / t
	else:
		tmp = 1.0 * x_m
	return x_s * tmp
x\_m = abs(x)
x\_s = copysign(1.0, x)
function code(x_s, x_m, y, z, t)
	tmp = 0.0
	if (Float64(Float64(x_m * Float64(y - z)) / Float64(t - z)) <= 4e-282)
		tmp = Float64(Float64(x_m * y) / t);
	else
		tmp = Float64(1.0 * x_m);
	end
	return Float64(x_s * tmp)
end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
function tmp_2 = code(x_s, x_m, y, z, t)
	tmp = 0.0;
	if (((x_m * (y - z)) / (t - z)) <= 4e-282)
		tmp = (x_m * y) / t;
	else
		tmp = 1.0 * x_m;
	end
	tmp_2 = x_s * tmp;
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_, t_] := N[(x$95$s * If[LessEqual[N[(N[(x$95$m * N[(y - z), $MachinePrecision]), $MachinePrecision] / N[(t - z), $MachinePrecision]), $MachinePrecision], 4e-282], N[(N[(x$95$m * y), $MachinePrecision] / t), $MachinePrecision], N[(1.0 * x$95$m), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)

\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;\frac{x\_m \cdot \left(y - z\right)}{t - z} \leq 4 \cdot 10^{-282}:\\
\;\;\;\;\frac{x\_m \cdot y}{t}\\

\mathbf{else}:\\
\;\;\;\;1 \cdot x\_m\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (*.f64 x (-.f64 y z)) (-.f64 t z)) < 4.0000000000000001e-282

    1. Initial program 84.1%

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

      \[\leadsto \color{blue}{\frac{x \cdot y}{t}} \]
    3. Applied rewrites37.2%

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

    if 4.0000000000000001e-282 < (/.f64 (*.f64 x (-.f64 y z)) (-.f64 t z))

    1. Initial program 84.1%

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

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

      \[\leadsto \color{blue}{1} \cdot x \]
    4. Applied rewrites35.3%

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

Alternative 11: 35.3% accurate, 3.2× speedup?

\[\begin{array}{l} x\_m = \left|x\right| \\ x\_s = \mathsf{copysign}\left(1, x\right) \\ x\_s \cdot \left(1 \cdot x\_m\right) \end{array} \]
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
(FPCore (x_s x_m y z t) :precision binary64 (* x_s (* 1.0 x_m)))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z, double t) {
	return x_s * (1.0 * x_m);
}
x\_m =     private
x\_s =     private
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_s, x_m, y, z, t)
use fmin_fmax_functions
    real(8), intent (in) :: x_s
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    code = x_s * (1.0d0 * x_m)
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z, double t) {
	return x_s * (1.0 * x_m);
}
x\_m = math.fabs(x)
x\_s = math.copysign(1.0, x)
def code(x_s, x_m, y, z, t):
	return x_s * (1.0 * x_m)
x\_m = abs(x)
x\_s = copysign(1.0, x)
function code(x_s, x_m, y, z, t)
	return Float64(x_s * Float64(1.0 * x_m))
end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
function tmp = code(x_s, x_m, y, z, t)
	tmp = x_s * (1.0 * x_m);
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_, t_] := N[(x$95$s * N[(1.0 * x$95$m), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)

\\
x\_s \cdot \left(1 \cdot x\_m\right)
\end{array}
Derivation
  1. Initial program 84.1%

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

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

    \[\leadsto \color{blue}{1} \cdot x \]
  4. Applied rewrites35.3%

    \[\leadsto \color{blue}{1} \cdot x \]
  5. Add Preprocessing

Reproduce

?
herbie shell --seed 2025153 
(FPCore (x y z t)
  :name "Graphics.Rendering.Chart.Plot.AreaSpots:renderAreaSpots4D from Chart-1.5.3"
  :precision binary64
  (/ (* x (- y z)) (- t z)))