Rosa's DopplerBench

Percentage Accurate: 71.9% → 98.2%
Time: 3.2s
Alternatives: 15
Speedup: 0.8×

Specification

?
\[\begin{array}{l} \\ \frac{\left(-t1\right) \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \end{array} \]
(FPCore (u v t1) :precision binary64 (/ (* (- t1) v) (* (+ t1 u) (+ t1 u))))
double code(double u, double v, double t1) {
	return (-t1 * v) / ((t1 + u) * (t1 + u));
}
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(u, v, t1)
use fmin_fmax_functions
    real(8), intent (in) :: u
    real(8), intent (in) :: v
    real(8), intent (in) :: t1
    code = (-t1 * v) / ((t1 + u) * (t1 + u))
end function
public static double code(double u, double v, double t1) {
	return (-t1 * v) / ((t1 + u) * (t1 + u));
}
def code(u, v, t1):
	return (-t1 * v) / ((t1 + u) * (t1 + u))
function code(u, v, t1)
	return Float64(Float64(Float64(-t1) * v) / Float64(Float64(t1 + u) * Float64(t1 + u)))
end
function tmp = code(u, v, t1)
	tmp = (-t1 * v) / ((t1 + u) * (t1 + u));
end
code[u_, v_, t1_] := N[(N[((-t1) * v), $MachinePrecision] / N[(N[(t1 + u), $MachinePrecision] * N[(t1 + u), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{\left(-t1\right) \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)}
\end{array}

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 15 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: 71.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{\left(-t1\right) \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \end{array} \]
(FPCore (u v t1) :precision binary64 (/ (* (- t1) v) (* (+ t1 u) (+ t1 u))))
double code(double u, double v, double t1) {
	return (-t1 * v) / ((t1 + u) * (t1 + u));
}
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(u, v, t1)
use fmin_fmax_functions
    real(8), intent (in) :: u
    real(8), intent (in) :: v
    real(8), intent (in) :: t1
    code = (-t1 * v) / ((t1 + u) * (t1 + u))
end function
public static double code(double u, double v, double t1) {
	return (-t1 * v) / ((t1 + u) * (t1 + u));
}
def code(u, v, t1):
	return (-t1 * v) / ((t1 + u) * (t1 + u))
function code(u, v, t1)
	return Float64(Float64(Float64(-t1) * v) / Float64(Float64(t1 + u) * Float64(t1 + u)))
end
function tmp = code(u, v, t1)
	tmp = (-t1 * v) / ((t1 + u) * (t1 + u));
end
code[u_, v_, t1_] := N[(N[((-t1) * v), $MachinePrecision] / N[(N[(t1 + u), $MachinePrecision] * N[(t1 + u), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{\left(-t1\right) \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)}
\end{array}

Alternative 1: 98.2% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \frac{\frac{-t1}{u + t1} \cdot v}{u + t1} \end{array} \]
(FPCore (u v t1) :precision binary64 (/ (* (/ (- t1) (+ u t1)) v) (+ u t1)))
double code(double u, double v, double t1) {
	return ((-t1 / (u + t1)) * v) / (u + t1);
}
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(u, v, t1)
use fmin_fmax_functions
    real(8), intent (in) :: u
    real(8), intent (in) :: v
    real(8), intent (in) :: t1
    code = ((-t1 / (u + t1)) * v) / (u + t1)
end function
public static double code(double u, double v, double t1) {
	return ((-t1 / (u + t1)) * v) / (u + t1);
}
def code(u, v, t1):
	return ((-t1 / (u + t1)) * v) / (u + t1)
function code(u, v, t1)
	return Float64(Float64(Float64(Float64(-t1) / Float64(u + t1)) * v) / Float64(u + t1))
end
function tmp = code(u, v, t1)
	tmp = ((-t1 / (u + t1)) * v) / (u + t1);
end
code[u_, v_, t1_] := N[(N[(N[((-t1) / N[(u + t1), $MachinePrecision]), $MachinePrecision] * v), $MachinePrecision] / N[(u + t1), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{\frac{-t1}{u + t1} \cdot v}{u + t1}
\end{array}
Derivation
  1. Initial program 71.9%

    \[\frac{\left(-t1\right) \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
  2. Step-by-step derivation
    1. lift-/.f64N/A

      \[\leadsto \color{blue}{\frac{\left(-t1\right) \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)}} \]
    2. lift-neg.f64N/A

      \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(t1\right)\right)} \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
    3. lift-*.f64N/A

      \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
    4. lift-+.f64N/A

      \[\leadsto \frac{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}{\color{blue}{\left(t1 + u\right)} \cdot \left(t1 + u\right)} \]
    5. lift-+.f64N/A

      \[\leadsto \frac{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}{\left(t1 + u\right) \cdot \color{blue}{\left(t1 + u\right)}} \]
    6. lift-*.f64N/A

      \[\leadsto \frac{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}{\color{blue}{\left(t1 + u\right) \cdot \left(t1 + u\right)}} \]
    7. times-fracN/A

      \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(t1\right)}{t1 + u} \cdot \frac{v}{t1 + u}} \]
    8. lower-*.f64N/A

      \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(t1\right)}{t1 + u} \cdot \frac{v}{t1 + u}} \]
    9. lower-/.f64N/A

      \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(t1\right)}{t1 + u}} \cdot \frac{v}{t1 + u} \]
    10. lift-neg.f64N/A

      \[\leadsto \frac{\color{blue}{-t1}}{t1 + u} \cdot \frac{v}{t1 + u} \]
    11. +-commutativeN/A

      \[\leadsto \frac{-t1}{\color{blue}{u + t1}} \cdot \frac{v}{t1 + u} \]
    12. lower-+.f64N/A

      \[\leadsto \frac{-t1}{\color{blue}{u + t1}} \cdot \frac{v}{t1 + u} \]
    13. lower-/.f64N/A

      \[\leadsto \frac{-t1}{u + t1} \cdot \color{blue}{\frac{v}{t1 + u}} \]
    14. +-commutativeN/A

      \[\leadsto \frac{-t1}{u + t1} \cdot \frac{v}{\color{blue}{u + t1}} \]
    15. lower-+.f6497.9

      \[\leadsto \frac{-t1}{u + t1} \cdot \frac{v}{\color{blue}{u + t1}} \]
  3. Applied rewrites97.9%

    \[\leadsto \color{blue}{\frac{-t1}{u + t1} \cdot \frac{v}{u + t1}} \]
  4. Step-by-step derivation
    1. lift-*.f64N/A

      \[\leadsto \color{blue}{\frac{-t1}{u + t1} \cdot \frac{v}{u + t1}} \]
    2. lift-neg.f64N/A

      \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(t1\right)}}{u + t1} \cdot \frac{v}{u + t1} \]
    3. lift-+.f64N/A

      \[\leadsto \frac{\mathsf{neg}\left(t1\right)}{\color{blue}{u + t1}} \cdot \frac{v}{u + t1} \]
    4. lift-/.f64N/A

      \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(t1\right)}{u + t1}} \cdot \frac{v}{u + t1} \]
    5. lift-+.f64N/A

      \[\leadsto \frac{\mathsf{neg}\left(t1\right)}{u + t1} \cdot \frac{v}{\color{blue}{u + t1}} \]
    6. lift-/.f64N/A

      \[\leadsto \frac{\mathsf{neg}\left(t1\right)}{u + t1} \cdot \color{blue}{\frac{v}{u + t1}} \]
    7. associate-*r/N/A

      \[\leadsto \color{blue}{\frac{\frac{\mathsf{neg}\left(t1\right)}{u + t1} \cdot v}{u + t1}} \]
    8. +-commutativeN/A

      \[\leadsto \frac{\frac{\mathsf{neg}\left(t1\right)}{u + t1} \cdot v}{\color{blue}{t1 + u}} \]
    9. lower-/.f64N/A

      \[\leadsto \color{blue}{\frac{\frac{\mathsf{neg}\left(t1\right)}{u + t1} \cdot v}{t1 + u}} \]
    10. lower-*.f64N/A

      \[\leadsto \frac{\color{blue}{\frac{\mathsf{neg}\left(t1\right)}{u + t1} \cdot v}}{t1 + u} \]
    11. lift-/.f64N/A

      \[\leadsto \frac{\color{blue}{\frac{\mathsf{neg}\left(t1\right)}{u + t1}} \cdot v}{t1 + u} \]
    12. lift-neg.f64N/A

      \[\leadsto \frac{\frac{\color{blue}{-t1}}{u + t1} \cdot v}{t1 + u} \]
    13. lift-+.f64N/A

      \[\leadsto \frac{\frac{-t1}{\color{blue}{u + t1}} \cdot v}{t1 + u} \]
    14. +-commutativeN/A

      \[\leadsto \frac{\frac{-t1}{u + t1} \cdot v}{\color{blue}{u + t1}} \]
    15. lift-+.f6498.2

      \[\leadsto \frac{\frac{-t1}{u + t1} \cdot v}{\color{blue}{u + t1}} \]
  5. Applied rewrites98.2%

    \[\leadsto \color{blue}{\frac{\frac{-t1}{u + t1} \cdot v}{u + t1}} \]
  6. Add Preprocessing

Alternative 2: 88.6% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{v}{u + t1}\\ \mathbf{if}\;t1 \leq -6.5 \cdot 10^{+109}:\\ \;\;\;\;\left(\frac{u}{t1} - 1\right) \cdot t\_1\\ \mathbf{elif}\;t1 \leq -9.5 \cdot 10^{-261}:\\ \;\;\;\;\frac{\left(-t1\right) \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)}\\ \mathbf{elif}\;t1 \leq 2.85 \cdot 10^{-145}:\\ \;\;\;\;v \cdot \frac{\frac{-t1}{u}}{u}\\ \mathbf{elif}\;t1 \leq 6.6 \cdot 10^{+128}:\\ \;\;\;\;\left(-t1\right) \cdot \frac{t\_1}{u + t1}\\ \mathbf{else}:\\ \;\;\;\;\frac{-v}{t1}\\ \end{array} \end{array} \]
(FPCore (u v t1)
 :precision binary64
 (let* ((t_1 (/ v (+ u t1))))
   (if (<= t1 -6.5e+109)
     (* (- (/ u t1) 1.0) t_1)
     (if (<= t1 -9.5e-261)
       (/ (* (- t1) v) (* (+ t1 u) (+ t1 u)))
       (if (<= t1 2.85e-145)
         (* v (/ (/ (- t1) u) u))
         (if (<= t1 6.6e+128) (* (- t1) (/ t_1 (+ u t1))) (/ (- v) t1)))))))
double code(double u, double v, double t1) {
	double t_1 = v / (u + t1);
	double tmp;
	if (t1 <= -6.5e+109) {
		tmp = ((u / t1) - 1.0) * t_1;
	} else if (t1 <= -9.5e-261) {
		tmp = (-t1 * v) / ((t1 + u) * (t1 + u));
	} else if (t1 <= 2.85e-145) {
		tmp = v * ((-t1 / u) / u);
	} else if (t1 <= 6.6e+128) {
		tmp = -t1 * (t_1 / (u + t1));
	} else {
		tmp = -v / t1;
	}
	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(u, v, t1)
use fmin_fmax_functions
    real(8), intent (in) :: u
    real(8), intent (in) :: v
    real(8), intent (in) :: t1
    real(8) :: t_1
    real(8) :: tmp
    t_1 = v / (u + t1)
    if (t1 <= (-6.5d+109)) then
        tmp = ((u / t1) - 1.0d0) * t_1
    else if (t1 <= (-9.5d-261)) then
        tmp = (-t1 * v) / ((t1 + u) * (t1 + u))
    else if (t1 <= 2.85d-145) then
        tmp = v * ((-t1 / u) / u)
    else if (t1 <= 6.6d+128) then
        tmp = -t1 * (t_1 / (u + t1))
    else
        tmp = -v / t1
    end if
    code = tmp
end function
public static double code(double u, double v, double t1) {
	double t_1 = v / (u + t1);
	double tmp;
	if (t1 <= -6.5e+109) {
		tmp = ((u / t1) - 1.0) * t_1;
	} else if (t1 <= -9.5e-261) {
		tmp = (-t1 * v) / ((t1 + u) * (t1 + u));
	} else if (t1 <= 2.85e-145) {
		tmp = v * ((-t1 / u) / u);
	} else if (t1 <= 6.6e+128) {
		tmp = -t1 * (t_1 / (u + t1));
	} else {
		tmp = -v / t1;
	}
	return tmp;
}
def code(u, v, t1):
	t_1 = v / (u + t1)
	tmp = 0
	if t1 <= -6.5e+109:
		tmp = ((u / t1) - 1.0) * t_1
	elif t1 <= -9.5e-261:
		tmp = (-t1 * v) / ((t1 + u) * (t1 + u))
	elif t1 <= 2.85e-145:
		tmp = v * ((-t1 / u) / u)
	elif t1 <= 6.6e+128:
		tmp = -t1 * (t_1 / (u + t1))
	else:
		tmp = -v / t1
	return tmp
function code(u, v, t1)
	t_1 = Float64(v / Float64(u + t1))
	tmp = 0.0
	if (t1 <= -6.5e+109)
		tmp = Float64(Float64(Float64(u / t1) - 1.0) * t_1);
	elseif (t1 <= -9.5e-261)
		tmp = Float64(Float64(Float64(-t1) * v) / Float64(Float64(t1 + u) * Float64(t1 + u)));
	elseif (t1 <= 2.85e-145)
		tmp = Float64(v * Float64(Float64(Float64(-t1) / u) / u));
	elseif (t1 <= 6.6e+128)
		tmp = Float64(Float64(-t1) * Float64(t_1 / Float64(u + t1)));
	else
		tmp = Float64(Float64(-v) / t1);
	end
	return tmp
end
function tmp_2 = code(u, v, t1)
	t_1 = v / (u + t1);
	tmp = 0.0;
	if (t1 <= -6.5e+109)
		tmp = ((u / t1) - 1.0) * t_1;
	elseif (t1 <= -9.5e-261)
		tmp = (-t1 * v) / ((t1 + u) * (t1 + u));
	elseif (t1 <= 2.85e-145)
		tmp = v * ((-t1 / u) / u);
	elseif (t1 <= 6.6e+128)
		tmp = -t1 * (t_1 / (u + t1));
	else
		tmp = -v / t1;
	end
	tmp_2 = tmp;
end
code[u_, v_, t1_] := Block[{t$95$1 = N[(v / N[(u + t1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t1, -6.5e+109], N[(N[(N[(u / t1), $MachinePrecision] - 1.0), $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[t1, -9.5e-261], N[(N[((-t1) * v), $MachinePrecision] / N[(N[(t1 + u), $MachinePrecision] * N[(t1 + u), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t1, 2.85e-145], N[(v * N[(N[((-t1) / u), $MachinePrecision] / u), $MachinePrecision]), $MachinePrecision], If[LessEqual[t1, 6.6e+128], N[((-t1) * N[(t$95$1 / N[(u + t1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-v) / t1), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \frac{v}{u + t1}\\
\mathbf{if}\;t1 \leq -6.5 \cdot 10^{+109}:\\
\;\;\;\;\left(\frac{u}{t1} - 1\right) \cdot t\_1\\

\mathbf{elif}\;t1 \leq -9.5 \cdot 10^{-261}:\\
\;\;\;\;\frac{\left(-t1\right) \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)}\\

\mathbf{elif}\;t1 \leq 2.85 \cdot 10^{-145}:\\
\;\;\;\;v \cdot \frac{\frac{-t1}{u}}{u}\\

\mathbf{elif}\;t1 \leq 6.6 \cdot 10^{+128}:\\
\;\;\;\;\left(-t1\right) \cdot \frac{t\_1}{u + t1}\\

\mathbf{else}:\\
\;\;\;\;\frac{-v}{t1}\\


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if t1 < -6.5e109

    1. Initial program 45.6%

      \[\frac{\left(-t1\right) \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
    2. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{\left(-t1\right) \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)}} \]
      2. lift-neg.f64N/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(t1\right)\right)} \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
      3. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
      4. lift-+.f64N/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}{\color{blue}{\left(t1 + u\right)} \cdot \left(t1 + u\right)} \]
      5. lift-+.f64N/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}{\left(t1 + u\right) \cdot \color{blue}{\left(t1 + u\right)}} \]
      6. lift-*.f64N/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}{\color{blue}{\left(t1 + u\right) \cdot \left(t1 + u\right)}} \]
      7. times-fracN/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(t1\right)}{t1 + u} \cdot \frac{v}{t1 + u}} \]
      8. lower-*.f64N/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(t1\right)}{t1 + u} \cdot \frac{v}{t1 + u}} \]
      9. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(t1\right)}{t1 + u}} \cdot \frac{v}{t1 + u} \]
      10. lift-neg.f64N/A

        \[\leadsto \frac{\color{blue}{-t1}}{t1 + u} \cdot \frac{v}{t1 + u} \]
      11. +-commutativeN/A

        \[\leadsto \frac{-t1}{\color{blue}{u + t1}} \cdot \frac{v}{t1 + u} \]
      12. lower-+.f64N/A

        \[\leadsto \frac{-t1}{\color{blue}{u + t1}} \cdot \frac{v}{t1 + u} \]
      13. lower-/.f64N/A

        \[\leadsto \frac{-t1}{u + t1} \cdot \color{blue}{\frac{v}{t1 + u}} \]
      14. +-commutativeN/A

        \[\leadsto \frac{-t1}{u + t1} \cdot \frac{v}{\color{blue}{u + t1}} \]
      15. lower-+.f6499.9

        \[\leadsto \frac{-t1}{u + t1} \cdot \frac{v}{\color{blue}{u + t1}} \]
    3. Applied rewrites99.9%

      \[\leadsto \color{blue}{\frac{-t1}{u + t1} \cdot \frac{v}{u + t1}} \]
    4. Taylor expanded in u around 0

      \[\leadsto \color{blue}{\left(\frac{u}{t1} - 1\right)} \cdot \frac{v}{u + t1} \]
    5. Step-by-step derivation
      1. lower--.f64N/A

        \[\leadsto \left(\frac{u}{t1} - \color{blue}{1}\right) \cdot \frac{v}{u + t1} \]
      2. lower-/.f6490.4

        \[\leadsto \left(\frac{u}{t1} - 1\right) \cdot \frac{v}{u + t1} \]
    6. Applied rewrites90.4%

      \[\leadsto \color{blue}{\left(\frac{u}{t1} - 1\right)} \cdot \frac{v}{u + t1} \]

    if -6.5e109 < t1 < -9.5000000000000008e-261

    1. Initial program 84.3%

      \[\frac{\left(-t1\right) \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]

    if -9.5000000000000008e-261 < t1 < 2.85000000000000016e-145

    1. Initial program 77.5%

      \[\frac{\left(-t1\right) \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
    2. Taylor expanded in u around inf

      \[\leadsto \color{blue}{-1 \cdot \frac{t1 \cdot v}{{u}^{2}}} \]
    3. Step-by-step derivation
      1. associate-*r/N/A

        \[\leadsto \frac{-1 \cdot \left(t1 \cdot v\right)}{\color{blue}{{u}^{2}}} \]
      2. mul-1-negN/A

        \[\leadsto \frac{\mathsf{neg}\left(t1 \cdot v\right)}{{\color{blue}{u}}^{2}} \]
      3. distribute-lft-neg-outN/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}{{\color{blue}{u}}^{2}} \]
      4. *-commutativeN/A

        \[\leadsto \frac{v \cdot \left(\mathsf{neg}\left(t1\right)\right)}{{\color{blue}{u}}^{2}} \]
      5. unpow2N/A

        \[\leadsto \frac{v \cdot \left(\mathsf{neg}\left(t1\right)\right)}{u \cdot \color{blue}{u}} \]
      6. times-fracN/A

        \[\leadsto \frac{v}{u} \cdot \color{blue}{\frac{\mathsf{neg}\left(t1\right)}{u}} \]
      7. mul-1-negN/A

        \[\leadsto \frac{v}{u} \cdot \frac{-1 \cdot t1}{u} \]
      8. associate-*r/N/A

        \[\leadsto \frac{v}{u} \cdot \left(-1 \cdot \color{blue}{\frac{t1}{u}}\right) \]
      9. lower-*.f64N/A

        \[\leadsto \frac{v}{u} \cdot \color{blue}{\left(-1 \cdot \frac{t1}{u}\right)} \]
      10. lower-/.f64N/A

        \[\leadsto \frac{v}{u} \cdot \left(\color{blue}{-1} \cdot \frac{t1}{u}\right) \]
      11. associate-*r/N/A

        \[\leadsto \frac{v}{u} \cdot \frac{-1 \cdot t1}{\color{blue}{u}} \]
      12. mul-1-negN/A

        \[\leadsto \frac{v}{u} \cdot \frac{\mathsf{neg}\left(t1\right)}{u} \]
      13. lower-/.f64N/A

        \[\leadsto \frac{v}{u} \cdot \frac{\mathsf{neg}\left(t1\right)}{\color{blue}{u}} \]
      14. lift-neg.f6484.6

        \[\leadsto \frac{v}{u} \cdot \frac{-t1}{u} \]
    4. Applied rewrites84.6%

      \[\leadsto \color{blue}{\frac{v}{u} \cdot \frac{-t1}{u}} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{v}{u} \cdot \color{blue}{\frac{-t1}{u}} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{v}{u} \cdot \frac{\color{blue}{-t1}}{u} \]
      3. lift-neg.f64N/A

        \[\leadsto \frac{v}{u} \cdot \frac{\mathsf{neg}\left(t1\right)}{u} \]
      4. lift-/.f64N/A

        \[\leadsto \frac{v}{u} \cdot \frac{\mathsf{neg}\left(t1\right)}{\color{blue}{u}} \]
      5. distribute-frac-negN/A

        \[\leadsto \frac{v}{u} \cdot \left(\mathsf{neg}\left(\frac{t1}{u}\right)\right) \]
      6. mul-1-negN/A

        \[\leadsto \frac{v}{u} \cdot \left(-1 \cdot \color{blue}{\frac{t1}{u}}\right) \]
      7. associate-*l/N/A

        \[\leadsto \frac{v \cdot \left(-1 \cdot \frac{t1}{u}\right)}{\color{blue}{u}} \]
      8. lower-/.f64N/A

        \[\leadsto \frac{v \cdot \left(-1 \cdot \frac{t1}{u}\right)}{\color{blue}{u}} \]
      9. lower-*.f64N/A

        \[\leadsto \frac{v \cdot \left(-1 \cdot \frac{t1}{u}\right)}{u} \]
      10. mul-1-negN/A

        \[\leadsto \frac{v \cdot \left(\mathsf{neg}\left(\frac{t1}{u}\right)\right)}{u} \]
      11. distribute-frac-negN/A

        \[\leadsto \frac{v \cdot \frac{\mathsf{neg}\left(t1\right)}{u}}{u} \]
      12. lift-/.f64N/A

        \[\leadsto \frac{v \cdot \frac{\mathsf{neg}\left(t1\right)}{u}}{u} \]
      13. lift-neg.f6486.1

        \[\leadsto \frac{v \cdot \frac{-t1}{u}}{u} \]
    6. Applied rewrites86.1%

      \[\leadsto \frac{v \cdot \frac{-t1}{u}}{\color{blue}{u}} \]
    7. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \frac{v \cdot \frac{-t1}{u}}{\color{blue}{u}} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{v \cdot \frac{-t1}{u}}{u} \]
      3. lift-neg.f64N/A

        \[\leadsto \frac{v \cdot \frac{\mathsf{neg}\left(t1\right)}{u}}{u} \]
      4. lift-/.f64N/A

        \[\leadsto \frac{v \cdot \frac{\mathsf{neg}\left(t1\right)}{u}}{u} \]
      5. distribute-frac-negN/A

        \[\leadsto \frac{v \cdot \left(\mathsf{neg}\left(\frac{t1}{u}\right)\right)}{u} \]
      6. mul-1-negN/A

        \[\leadsto \frac{v \cdot \left(-1 \cdot \frac{t1}{u}\right)}{u} \]
      7. associate-/l*N/A

        \[\leadsto v \cdot \color{blue}{\frac{-1 \cdot \frac{t1}{u}}{u}} \]
      8. lower-*.f64N/A

        \[\leadsto v \cdot \color{blue}{\frac{-1 \cdot \frac{t1}{u}}{u}} \]
      9. lower-/.f64N/A

        \[\leadsto v \cdot \frac{-1 \cdot \frac{t1}{u}}{\color{blue}{u}} \]
      10. mul-1-negN/A

        \[\leadsto v \cdot \frac{\mathsf{neg}\left(\frac{t1}{u}\right)}{u} \]
      11. distribute-frac-negN/A

        \[\leadsto v \cdot \frac{\frac{\mathsf{neg}\left(t1\right)}{u}}{u} \]
      12. lift-/.f64N/A

        \[\leadsto v \cdot \frac{\frac{\mathsf{neg}\left(t1\right)}{u}}{u} \]
      13. lift-neg.f6486.9

        \[\leadsto v \cdot \frac{\frac{-t1}{u}}{u} \]
    8. Applied rewrites86.9%

      \[\leadsto v \cdot \color{blue}{\frac{\frac{-t1}{u}}{u}} \]

    if 2.85000000000000016e-145 < t1 < 6.6000000000000001e128

    1. Initial program 87.6%

      \[\frac{\left(-t1\right) \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
    2. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{\left(-t1\right) \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)}} \]
      2. lift-neg.f64N/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(t1\right)\right)} \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
      3. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
      4. lift-+.f64N/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}{\color{blue}{\left(t1 + u\right)} \cdot \left(t1 + u\right)} \]
      5. lift-+.f64N/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}{\left(t1 + u\right) \cdot \color{blue}{\left(t1 + u\right)}} \]
      6. lift-*.f64N/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}{\color{blue}{\left(t1 + u\right) \cdot \left(t1 + u\right)}} \]
      7. associate-/l*N/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(t1\right)\right) \cdot \frac{v}{\left(t1 + u\right) \cdot \left(t1 + u\right)}} \]
      8. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(t1\right)\right) \cdot \frac{v}{\left(t1 + u\right) \cdot \left(t1 + u\right)}} \]
      9. lift-neg.f64N/A

        \[\leadsto \color{blue}{\left(-t1\right)} \cdot \frac{v}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
      10. lower-/.f64N/A

        \[\leadsto \left(-t1\right) \cdot \color{blue}{\frac{v}{\left(t1 + u\right) \cdot \left(t1 + u\right)}} \]
      11. pow2N/A

        \[\leadsto \left(-t1\right) \cdot \frac{v}{\color{blue}{{\left(t1 + u\right)}^{2}}} \]
      12. lower-pow.f64N/A

        \[\leadsto \left(-t1\right) \cdot \frac{v}{\color{blue}{{\left(t1 + u\right)}^{2}}} \]
      13. +-commutativeN/A

        \[\leadsto \left(-t1\right) \cdot \frac{v}{{\color{blue}{\left(u + t1\right)}}^{2}} \]
      14. lower-+.f6487.3

        \[\leadsto \left(-t1\right) \cdot \frac{v}{{\color{blue}{\left(u + t1\right)}}^{2}} \]
    3. Applied rewrites87.3%

      \[\leadsto \color{blue}{\left(-t1\right) \cdot \frac{v}{{\left(u + t1\right)}^{2}}} \]
    4. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \left(-t1\right) \cdot \frac{v}{{\color{blue}{\left(u + t1\right)}}^{2}} \]
      2. +-commutativeN/A

        \[\leadsto \left(-t1\right) \cdot \frac{v}{{\color{blue}{\left(t1 + u\right)}}^{2}} \]
      3. lower-pow.f64N/A

        \[\leadsto \left(-t1\right) \cdot \frac{v}{\color{blue}{{\left(t1 + u\right)}^{2}}} \]
      4. pow2N/A

        \[\leadsto \left(-t1\right) \cdot \frac{v}{\color{blue}{\left(t1 + u\right) \cdot \left(t1 + u\right)}} \]
      5. lower-*.f64N/A

        \[\leadsto \left(-t1\right) \cdot \frac{v}{\color{blue}{\left(t1 + u\right) \cdot \left(t1 + u\right)}} \]
      6. +-commutativeN/A

        \[\leadsto \left(-t1\right) \cdot \frac{v}{\color{blue}{\left(u + t1\right)} \cdot \left(t1 + u\right)} \]
      7. lift-+.f64N/A

        \[\leadsto \left(-t1\right) \cdot \frac{v}{\color{blue}{\left(u + t1\right)} \cdot \left(t1 + u\right)} \]
      8. +-commutativeN/A

        \[\leadsto \left(-t1\right) \cdot \frac{v}{\left(u + t1\right) \cdot \color{blue}{\left(u + t1\right)}} \]
      9. lift-+.f6487.3

        \[\leadsto \left(-t1\right) \cdot \frac{v}{\left(u + t1\right) \cdot \color{blue}{\left(u + t1\right)}} \]
    5. Applied rewrites87.3%

      \[\leadsto \left(-t1\right) \cdot \frac{v}{\color{blue}{\left(u + t1\right) \cdot \left(u + t1\right)}} \]
    6. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \left(-t1\right) \cdot \color{blue}{\frac{v}{\left(u + t1\right) \cdot \left(u + t1\right)}} \]
      2. lift-+.f64N/A

        \[\leadsto \left(-t1\right) \cdot \frac{v}{\color{blue}{\left(u + t1\right)} \cdot \left(u + t1\right)} \]
      3. lift-+.f64N/A

        \[\leadsto \left(-t1\right) \cdot \frac{v}{\left(u + t1\right) \cdot \color{blue}{\left(u + t1\right)}} \]
      4. lift-*.f64N/A

        \[\leadsto \left(-t1\right) \cdot \frac{v}{\color{blue}{\left(u + t1\right) \cdot \left(u + t1\right)}} \]
      5. associate-/r*N/A

        \[\leadsto \left(-t1\right) \cdot \color{blue}{\frac{\frac{v}{u + t1}}{u + t1}} \]
      6. lower-/.f64N/A

        \[\leadsto \left(-t1\right) \cdot \color{blue}{\frac{\frac{v}{u + t1}}{u + t1}} \]
      7. lower-/.f64N/A

        \[\leadsto \left(-t1\right) \cdot \frac{\color{blue}{\frac{v}{u + t1}}}{u + t1} \]
      8. lift-+.f64N/A

        \[\leadsto \left(-t1\right) \cdot \frac{\frac{v}{\color{blue}{u + t1}}}{u + t1} \]
      9. lift-+.f6492.9

        \[\leadsto \left(-t1\right) \cdot \frac{\frac{v}{u + t1}}{\color{blue}{u + t1}} \]
    7. Applied rewrites92.9%

      \[\leadsto \left(-t1\right) \cdot \color{blue}{\frac{\frac{v}{u + t1}}{u + t1}} \]

    if 6.6000000000000001e128 < t1

    1. Initial program 45.0%

      \[\frac{\left(-t1\right) \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
    2. Taylor expanded in u around 0

      \[\leadsto \color{blue}{-1 \cdot \frac{v}{t1}} \]
    3. Step-by-step derivation
      1. associate-*r/N/A

        \[\leadsto \frac{-1 \cdot v}{\color{blue}{t1}} \]
      2. lower-/.f64N/A

        \[\leadsto \frac{-1 \cdot v}{\color{blue}{t1}} \]
      3. mul-1-negN/A

        \[\leadsto \frac{\mathsf{neg}\left(v\right)}{t1} \]
      4. lower-neg.f6490.9

        \[\leadsto \frac{-v}{t1} \]
    4. Applied rewrites90.9%

      \[\leadsto \color{blue}{\frac{-v}{t1}} \]
  3. Recombined 5 regimes into one program.
  4. Add Preprocessing

Alternative 3: 86.9% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \left(-t1\right) \cdot \frac{v}{\left(u + t1\right) \cdot \left(u + t1\right)}\\ \mathbf{if}\;t1 \leq -5.8 \cdot 10^{+101}:\\ \;\;\;\;\frac{-v}{u + t1}\\ \mathbf{elif}\;t1 \leq -5.5 \cdot 10^{-65}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t1 \leq 4.4 \cdot 10^{-148}:\\ \;\;\;\;\frac{v \cdot \frac{-t1}{u}}{u}\\ \mathbf{elif}\;t1 \leq 6.6 \cdot 10^{+128}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;\frac{-v}{t1}\\ \end{array} \end{array} \]
(FPCore (u v t1)
 :precision binary64
 (let* ((t_1 (* (- t1) (/ v (* (+ u t1) (+ u t1))))))
   (if (<= t1 -5.8e+101)
     (/ (- v) (+ u t1))
     (if (<= t1 -5.5e-65)
       t_1
       (if (<= t1 4.4e-148)
         (/ (* v (/ (- t1) u)) u)
         (if (<= t1 6.6e+128) t_1 (/ (- v) t1)))))))
double code(double u, double v, double t1) {
	double t_1 = -t1 * (v / ((u + t1) * (u + t1)));
	double tmp;
	if (t1 <= -5.8e+101) {
		tmp = -v / (u + t1);
	} else if (t1 <= -5.5e-65) {
		tmp = t_1;
	} else if (t1 <= 4.4e-148) {
		tmp = (v * (-t1 / u)) / u;
	} else if (t1 <= 6.6e+128) {
		tmp = t_1;
	} else {
		tmp = -v / t1;
	}
	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(u, v, t1)
use fmin_fmax_functions
    real(8), intent (in) :: u
    real(8), intent (in) :: v
    real(8), intent (in) :: t1
    real(8) :: t_1
    real(8) :: tmp
    t_1 = -t1 * (v / ((u + t1) * (u + t1)))
    if (t1 <= (-5.8d+101)) then
        tmp = -v / (u + t1)
    else if (t1 <= (-5.5d-65)) then
        tmp = t_1
    else if (t1 <= 4.4d-148) then
        tmp = (v * (-t1 / u)) / u
    else if (t1 <= 6.6d+128) then
        tmp = t_1
    else
        tmp = -v / t1
    end if
    code = tmp
end function
public static double code(double u, double v, double t1) {
	double t_1 = -t1 * (v / ((u + t1) * (u + t1)));
	double tmp;
	if (t1 <= -5.8e+101) {
		tmp = -v / (u + t1);
	} else if (t1 <= -5.5e-65) {
		tmp = t_1;
	} else if (t1 <= 4.4e-148) {
		tmp = (v * (-t1 / u)) / u;
	} else if (t1 <= 6.6e+128) {
		tmp = t_1;
	} else {
		tmp = -v / t1;
	}
	return tmp;
}
def code(u, v, t1):
	t_1 = -t1 * (v / ((u + t1) * (u + t1)))
	tmp = 0
	if t1 <= -5.8e+101:
		tmp = -v / (u + t1)
	elif t1 <= -5.5e-65:
		tmp = t_1
	elif t1 <= 4.4e-148:
		tmp = (v * (-t1 / u)) / u
	elif t1 <= 6.6e+128:
		tmp = t_1
	else:
		tmp = -v / t1
	return tmp
function code(u, v, t1)
	t_1 = Float64(Float64(-t1) * Float64(v / Float64(Float64(u + t1) * Float64(u + t1))))
	tmp = 0.0
	if (t1 <= -5.8e+101)
		tmp = Float64(Float64(-v) / Float64(u + t1));
	elseif (t1 <= -5.5e-65)
		tmp = t_1;
	elseif (t1 <= 4.4e-148)
		tmp = Float64(Float64(v * Float64(Float64(-t1) / u)) / u);
	elseif (t1 <= 6.6e+128)
		tmp = t_1;
	else
		tmp = Float64(Float64(-v) / t1);
	end
	return tmp
end
function tmp_2 = code(u, v, t1)
	t_1 = -t1 * (v / ((u + t1) * (u + t1)));
	tmp = 0.0;
	if (t1 <= -5.8e+101)
		tmp = -v / (u + t1);
	elseif (t1 <= -5.5e-65)
		tmp = t_1;
	elseif (t1 <= 4.4e-148)
		tmp = (v * (-t1 / u)) / u;
	elseif (t1 <= 6.6e+128)
		tmp = t_1;
	else
		tmp = -v / t1;
	end
	tmp_2 = tmp;
end
code[u_, v_, t1_] := Block[{t$95$1 = N[((-t1) * N[(v / N[(N[(u + t1), $MachinePrecision] * N[(u + t1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t1, -5.8e+101], N[((-v) / N[(u + t1), $MachinePrecision]), $MachinePrecision], If[LessEqual[t1, -5.5e-65], t$95$1, If[LessEqual[t1, 4.4e-148], N[(N[(v * N[((-t1) / u), $MachinePrecision]), $MachinePrecision] / u), $MachinePrecision], If[LessEqual[t1, 6.6e+128], t$95$1, N[((-v) / t1), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \left(-t1\right) \cdot \frac{v}{\left(u + t1\right) \cdot \left(u + t1\right)}\\
\mathbf{if}\;t1 \leq -5.8 \cdot 10^{+101}:\\
\;\;\;\;\frac{-v}{u + t1}\\

\mathbf{elif}\;t1 \leq -5.5 \cdot 10^{-65}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t1 \leq 4.4 \cdot 10^{-148}:\\
\;\;\;\;\frac{v \cdot \frac{-t1}{u}}{u}\\

\mathbf{elif}\;t1 \leq 6.6 \cdot 10^{+128}:\\
\;\;\;\;t\_1\\

\mathbf{else}:\\
\;\;\;\;\frac{-v}{t1}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if t1 < -5.79999999999999974e101

    1. Initial program 47.1%

      \[\frac{\left(-t1\right) \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
    2. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{\left(-t1\right) \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)}} \]
      2. lift-neg.f64N/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(t1\right)\right)} \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
      3. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
      4. lift-+.f64N/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}{\color{blue}{\left(t1 + u\right)} \cdot \left(t1 + u\right)} \]
      5. lift-+.f64N/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}{\left(t1 + u\right) \cdot \color{blue}{\left(t1 + u\right)}} \]
      6. lift-*.f64N/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}{\color{blue}{\left(t1 + u\right) \cdot \left(t1 + u\right)}} \]
      7. times-fracN/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(t1\right)}{t1 + u} \cdot \frac{v}{t1 + u}} \]
      8. lower-*.f64N/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(t1\right)}{t1 + u} \cdot \frac{v}{t1 + u}} \]
      9. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(t1\right)}{t1 + u}} \cdot \frac{v}{t1 + u} \]
      10. lift-neg.f64N/A

        \[\leadsto \frac{\color{blue}{-t1}}{t1 + u} \cdot \frac{v}{t1 + u} \]
      11. +-commutativeN/A

        \[\leadsto \frac{-t1}{\color{blue}{u + t1}} \cdot \frac{v}{t1 + u} \]
      12. lower-+.f64N/A

        \[\leadsto \frac{-t1}{\color{blue}{u + t1}} \cdot \frac{v}{t1 + u} \]
      13. lower-/.f64N/A

        \[\leadsto \frac{-t1}{u + t1} \cdot \color{blue}{\frac{v}{t1 + u}} \]
      14. +-commutativeN/A

        \[\leadsto \frac{-t1}{u + t1} \cdot \frac{v}{\color{blue}{u + t1}} \]
      15. lower-+.f6499.9

        \[\leadsto \frac{-t1}{u + t1} \cdot \frac{v}{\color{blue}{u + t1}} \]
    3. Applied rewrites99.9%

      \[\leadsto \color{blue}{\frac{-t1}{u + t1} \cdot \frac{v}{u + t1}} \]
    4. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{\frac{-t1}{u + t1} \cdot \frac{v}{u + t1}} \]
      2. lift-neg.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(t1\right)}}{u + t1} \cdot \frac{v}{u + t1} \]
      3. lift-+.f64N/A

        \[\leadsto \frac{\mathsf{neg}\left(t1\right)}{\color{blue}{u + t1}} \cdot \frac{v}{u + t1} \]
      4. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(t1\right)}{u + t1}} \cdot \frac{v}{u + t1} \]
      5. lift-+.f64N/A

        \[\leadsto \frac{\mathsf{neg}\left(t1\right)}{u + t1} \cdot \frac{v}{\color{blue}{u + t1}} \]
      6. lift-/.f64N/A

        \[\leadsto \frac{\mathsf{neg}\left(t1\right)}{u + t1} \cdot \color{blue}{\frac{v}{u + t1}} \]
      7. associate-*r/N/A

        \[\leadsto \color{blue}{\frac{\frac{\mathsf{neg}\left(t1\right)}{u + t1} \cdot v}{u + t1}} \]
      8. +-commutativeN/A

        \[\leadsto \frac{\frac{\mathsf{neg}\left(t1\right)}{u + t1} \cdot v}{\color{blue}{t1 + u}} \]
      9. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{\frac{\mathsf{neg}\left(t1\right)}{u + t1} \cdot v}{t1 + u}} \]
      10. lower-*.f64N/A

        \[\leadsto \frac{\color{blue}{\frac{\mathsf{neg}\left(t1\right)}{u + t1} \cdot v}}{t1 + u} \]
      11. lift-/.f64N/A

        \[\leadsto \frac{\color{blue}{\frac{\mathsf{neg}\left(t1\right)}{u + t1}} \cdot v}{t1 + u} \]
      12. lift-neg.f64N/A

        \[\leadsto \frac{\frac{\color{blue}{-t1}}{u + t1} \cdot v}{t1 + u} \]
      13. lift-+.f64N/A

        \[\leadsto \frac{\frac{-t1}{\color{blue}{u + t1}} \cdot v}{t1 + u} \]
      14. +-commutativeN/A

        \[\leadsto \frac{\frac{-t1}{u + t1} \cdot v}{\color{blue}{u + t1}} \]
      15. lift-+.f6499.9

        \[\leadsto \frac{\frac{-t1}{u + t1} \cdot v}{\color{blue}{u + t1}} \]
    5. Applied rewrites99.9%

      \[\leadsto \color{blue}{\frac{\frac{-t1}{u + t1} \cdot v}{u + t1}} \]
    6. Taylor expanded in u around 0

      \[\leadsto \frac{\color{blue}{-1 \cdot v}}{u + t1} \]
    7. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \frac{\mathsf{neg}\left(v\right)}{u + t1} \]
      2. lower-neg.f6489.9

        \[\leadsto \frac{-v}{u + t1} \]
    8. Applied rewrites89.9%

      \[\leadsto \frac{\color{blue}{-v}}{u + t1} \]

    if -5.79999999999999974e101 < t1 < -5.4999999999999999e-65 or 4.40000000000000034e-148 < t1 < 6.6000000000000001e128

    1. Initial program 87.6%

      \[\frac{\left(-t1\right) \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
    2. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{\left(-t1\right) \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)}} \]
      2. lift-neg.f64N/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(t1\right)\right)} \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
      3. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
      4. lift-+.f64N/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}{\color{blue}{\left(t1 + u\right)} \cdot \left(t1 + u\right)} \]
      5. lift-+.f64N/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}{\left(t1 + u\right) \cdot \color{blue}{\left(t1 + u\right)}} \]
      6. lift-*.f64N/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}{\color{blue}{\left(t1 + u\right) \cdot \left(t1 + u\right)}} \]
      7. associate-/l*N/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(t1\right)\right) \cdot \frac{v}{\left(t1 + u\right) \cdot \left(t1 + u\right)}} \]
      8. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(t1\right)\right) \cdot \frac{v}{\left(t1 + u\right) \cdot \left(t1 + u\right)}} \]
      9. lift-neg.f64N/A

        \[\leadsto \color{blue}{\left(-t1\right)} \cdot \frac{v}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
      10. lower-/.f64N/A

        \[\leadsto \left(-t1\right) \cdot \color{blue}{\frac{v}{\left(t1 + u\right) \cdot \left(t1 + u\right)}} \]
      11. pow2N/A

        \[\leadsto \left(-t1\right) \cdot \frac{v}{\color{blue}{{\left(t1 + u\right)}^{2}}} \]
      12. lower-pow.f64N/A

        \[\leadsto \left(-t1\right) \cdot \frac{v}{\color{blue}{{\left(t1 + u\right)}^{2}}} \]
      13. +-commutativeN/A

        \[\leadsto \left(-t1\right) \cdot \frac{v}{{\color{blue}{\left(u + t1\right)}}^{2}} \]
      14. lower-+.f6487.9

        \[\leadsto \left(-t1\right) \cdot \frac{v}{{\color{blue}{\left(u + t1\right)}}^{2}} \]
    3. Applied rewrites87.9%

      \[\leadsto \color{blue}{\left(-t1\right) \cdot \frac{v}{{\left(u + t1\right)}^{2}}} \]
    4. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \left(-t1\right) \cdot \frac{v}{{\color{blue}{\left(u + t1\right)}}^{2}} \]
      2. +-commutativeN/A

        \[\leadsto \left(-t1\right) \cdot \frac{v}{{\color{blue}{\left(t1 + u\right)}}^{2}} \]
      3. lower-pow.f64N/A

        \[\leadsto \left(-t1\right) \cdot \frac{v}{\color{blue}{{\left(t1 + u\right)}^{2}}} \]
      4. pow2N/A

        \[\leadsto \left(-t1\right) \cdot \frac{v}{\color{blue}{\left(t1 + u\right) \cdot \left(t1 + u\right)}} \]
      5. lower-*.f64N/A

        \[\leadsto \left(-t1\right) \cdot \frac{v}{\color{blue}{\left(t1 + u\right) \cdot \left(t1 + u\right)}} \]
      6. +-commutativeN/A

        \[\leadsto \left(-t1\right) \cdot \frac{v}{\color{blue}{\left(u + t1\right)} \cdot \left(t1 + u\right)} \]
      7. lift-+.f64N/A

        \[\leadsto \left(-t1\right) \cdot \frac{v}{\color{blue}{\left(u + t1\right)} \cdot \left(t1 + u\right)} \]
      8. +-commutativeN/A

        \[\leadsto \left(-t1\right) \cdot \frac{v}{\left(u + t1\right) \cdot \color{blue}{\left(u + t1\right)}} \]
      9. lift-+.f6487.9

        \[\leadsto \left(-t1\right) \cdot \frac{v}{\left(u + t1\right) \cdot \color{blue}{\left(u + t1\right)}} \]
    5. Applied rewrites87.9%

      \[\leadsto \left(-t1\right) \cdot \frac{v}{\color{blue}{\left(u + t1\right) \cdot \left(u + t1\right)}} \]

    if -5.4999999999999999e-65 < t1 < 4.40000000000000034e-148

    1. Initial program 79.5%

      \[\frac{\left(-t1\right) \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
    2. Taylor expanded in u around inf

      \[\leadsto \color{blue}{-1 \cdot \frac{t1 \cdot v}{{u}^{2}}} \]
    3. Step-by-step derivation
      1. associate-*r/N/A

        \[\leadsto \frac{-1 \cdot \left(t1 \cdot v\right)}{\color{blue}{{u}^{2}}} \]
      2. mul-1-negN/A

        \[\leadsto \frac{\mathsf{neg}\left(t1 \cdot v\right)}{{\color{blue}{u}}^{2}} \]
      3. distribute-lft-neg-outN/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}{{\color{blue}{u}}^{2}} \]
      4. *-commutativeN/A

        \[\leadsto \frac{v \cdot \left(\mathsf{neg}\left(t1\right)\right)}{{\color{blue}{u}}^{2}} \]
      5. unpow2N/A

        \[\leadsto \frac{v \cdot \left(\mathsf{neg}\left(t1\right)\right)}{u \cdot \color{blue}{u}} \]
      6. times-fracN/A

        \[\leadsto \frac{v}{u} \cdot \color{blue}{\frac{\mathsf{neg}\left(t1\right)}{u}} \]
      7. mul-1-negN/A

        \[\leadsto \frac{v}{u} \cdot \frac{-1 \cdot t1}{u} \]
      8. associate-*r/N/A

        \[\leadsto \frac{v}{u} \cdot \left(-1 \cdot \color{blue}{\frac{t1}{u}}\right) \]
      9. lower-*.f64N/A

        \[\leadsto \frac{v}{u} \cdot \color{blue}{\left(-1 \cdot \frac{t1}{u}\right)} \]
      10. lower-/.f64N/A

        \[\leadsto \frac{v}{u} \cdot \left(\color{blue}{-1} \cdot \frac{t1}{u}\right) \]
      11. associate-*r/N/A

        \[\leadsto \frac{v}{u} \cdot \frac{-1 \cdot t1}{\color{blue}{u}} \]
      12. mul-1-negN/A

        \[\leadsto \frac{v}{u} \cdot \frac{\mathsf{neg}\left(t1\right)}{u} \]
      13. lower-/.f64N/A

        \[\leadsto \frac{v}{u} \cdot \frac{\mathsf{neg}\left(t1\right)}{\color{blue}{u}} \]
      14. lift-neg.f6481.6

        \[\leadsto \frac{v}{u} \cdot \frac{-t1}{u} \]
    4. Applied rewrites81.6%

      \[\leadsto \color{blue}{\frac{v}{u} \cdot \frac{-t1}{u}} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{v}{u} \cdot \color{blue}{\frac{-t1}{u}} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{v}{u} \cdot \frac{\color{blue}{-t1}}{u} \]
      3. lift-neg.f64N/A

        \[\leadsto \frac{v}{u} \cdot \frac{\mathsf{neg}\left(t1\right)}{u} \]
      4. lift-/.f64N/A

        \[\leadsto \frac{v}{u} \cdot \frac{\mathsf{neg}\left(t1\right)}{\color{blue}{u}} \]
      5. distribute-frac-negN/A

        \[\leadsto \frac{v}{u} \cdot \left(\mathsf{neg}\left(\frac{t1}{u}\right)\right) \]
      6. mul-1-negN/A

        \[\leadsto \frac{v}{u} \cdot \left(-1 \cdot \color{blue}{\frac{t1}{u}}\right) \]
      7. associate-*l/N/A

        \[\leadsto \frac{v \cdot \left(-1 \cdot \frac{t1}{u}\right)}{\color{blue}{u}} \]
      8. lower-/.f64N/A

        \[\leadsto \frac{v \cdot \left(-1 \cdot \frac{t1}{u}\right)}{\color{blue}{u}} \]
      9. lower-*.f64N/A

        \[\leadsto \frac{v \cdot \left(-1 \cdot \frac{t1}{u}\right)}{u} \]
      10. mul-1-negN/A

        \[\leadsto \frac{v \cdot \left(\mathsf{neg}\left(\frac{t1}{u}\right)\right)}{u} \]
      11. distribute-frac-negN/A

        \[\leadsto \frac{v \cdot \frac{\mathsf{neg}\left(t1\right)}{u}}{u} \]
      12. lift-/.f64N/A

        \[\leadsto \frac{v \cdot \frac{\mathsf{neg}\left(t1\right)}{u}}{u} \]
      13. lift-neg.f6482.6

        \[\leadsto \frac{v \cdot \frac{-t1}{u}}{u} \]
    6. Applied rewrites82.6%

      \[\leadsto \frac{v \cdot \frac{-t1}{u}}{\color{blue}{u}} \]

    if 6.6000000000000001e128 < t1

    1. Initial program 45.0%

      \[\frac{\left(-t1\right) \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
    2. Taylor expanded in u around 0

      \[\leadsto \color{blue}{-1 \cdot \frac{v}{t1}} \]
    3. Step-by-step derivation
      1. associate-*r/N/A

        \[\leadsto \frac{-1 \cdot v}{\color{blue}{t1}} \]
      2. lower-/.f64N/A

        \[\leadsto \frac{-1 \cdot v}{\color{blue}{t1}} \]
      3. mul-1-negN/A

        \[\leadsto \frac{\mathsf{neg}\left(v\right)}{t1} \]
      4. lower-neg.f6490.9

        \[\leadsto \frac{-v}{t1} \]
    4. Applied rewrites90.9%

      \[\leadsto \color{blue}{\frac{-v}{t1}} \]
  3. Recombined 4 regimes into one program.
  4. Add Preprocessing

Alternative 4: 85.8% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;t1 \leq -6.5 \cdot 10^{+109}:\\ \;\;\;\;\left(\frac{u}{t1} - 1\right) \cdot \frac{v}{u + t1}\\ \mathbf{elif}\;t1 \leq 1.92 \cdot 10^{+93}:\\ \;\;\;\;\frac{\left(-t1\right) \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{-v}{t1}\\ \end{array} \end{array} \]
(FPCore (u v t1)
 :precision binary64
 (if (<= t1 -6.5e+109)
   (* (- (/ u t1) 1.0) (/ v (+ u t1)))
   (if (<= t1 1.92e+93) (/ (* (- t1) v) (* (+ t1 u) (+ t1 u))) (/ (- v) t1))))
double code(double u, double v, double t1) {
	double tmp;
	if (t1 <= -6.5e+109) {
		tmp = ((u / t1) - 1.0) * (v / (u + t1));
	} else if (t1 <= 1.92e+93) {
		tmp = (-t1 * v) / ((t1 + u) * (t1 + u));
	} else {
		tmp = -v / t1;
	}
	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(u, v, t1)
use fmin_fmax_functions
    real(8), intent (in) :: u
    real(8), intent (in) :: v
    real(8), intent (in) :: t1
    real(8) :: tmp
    if (t1 <= (-6.5d+109)) then
        tmp = ((u / t1) - 1.0d0) * (v / (u + t1))
    else if (t1 <= 1.92d+93) then
        tmp = (-t1 * v) / ((t1 + u) * (t1 + u))
    else
        tmp = -v / t1
    end if
    code = tmp
end function
public static double code(double u, double v, double t1) {
	double tmp;
	if (t1 <= -6.5e+109) {
		tmp = ((u / t1) - 1.0) * (v / (u + t1));
	} else if (t1 <= 1.92e+93) {
		tmp = (-t1 * v) / ((t1 + u) * (t1 + u));
	} else {
		tmp = -v / t1;
	}
	return tmp;
}
def code(u, v, t1):
	tmp = 0
	if t1 <= -6.5e+109:
		tmp = ((u / t1) - 1.0) * (v / (u + t1))
	elif t1 <= 1.92e+93:
		tmp = (-t1 * v) / ((t1 + u) * (t1 + u))
	else:
		tmp = -v / t1
	return tmp
function code(u, v, t1)
	tmp = 0.0
	if (t1 <= -6.5e+109)
		tmp = Float64(Float64(Float64(u / t1) - 1.0) * Float64(v / Float64(u + t1)));
	elseif (t1 <= 1.92e+93)
		tmp = Float64(Float64(Float64(-t1) * v) / Float64(Float64(t1 + u) * Float64(t1 + u)));
	else
		tmp = Float64(Float64(-v) / t1);
	end
	return tmp
end
function tmp_2 = code(u, v, t1)
	tmp = 0.0;
	if (t1 <= -6.5e+109)
		tmp = ((u / t1) - 1.0) * (v / (u + t1));
	elseif (t1 <= 1.92e+93)
		tmp = (-t1 * v) / ((t1 + u) * (t1 + u));
	else
		tmp = -v / t1;
	end
	tmp_2 = tmp;
end
code[u_, v_, t1_] := If[LessEqual[t1, -6.5e+109], N[(N[(N[(u / t1), $MachinePrecision] - 1.0), $MachinePrecision] * N[(v / N[(u + t1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t1, 1.92e+93], N[(N[((-t1) * v), $MachinePrecision] / N[(N[(t1 + u), $MachinePrecision] * N[(t1 + u), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-v) / t1), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;t1 \leq -6.5 \cdot 10^{+109}:\\
\;\;\;\;\left(\frac{u}{t1} - 1\right) \cdot \frac{v}{u + t1}\\

\mathbf{elif}\;t1 \leq 1.92 \cdot 10^{+93}:\\
\;\;\;\;\frac{\left(-t1\right) \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{-v}{t1}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if t1 < -6.5e109

    1. Initial program 45.6%

      \[\frac{\left(-t1\right) \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
    2. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{\left(-t1\right) \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)}} \]
      2. lift-neg.f64N/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(t1\right)\right)} \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
      3. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
      4. lift-+.f64N/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}{\color{blue}{\left(t1 + u\right)} \cdot \left(t1 + u\right)} \]
      5. lift-+.f64N/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}{\left(t1 + u\right) \cdot \color{blue}{\left(t1 + u\right)}} \]
      6. lift-*.f64N/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}{\color{blue}{\left(t1 + u\right) \cdot \left(t1 + u\right)}} \]
      7. times-fracN/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(t1\right)}{t1 + u} \cdot \frac{v}{t1 + u}} \]
      8. lower-*.f64N/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(t1\right)}{t1 + u} \cdot \frac{v}{t1 + u}} \]
      9. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(t1\right)}{t1 + u}} \cdot \frac{v}{t1 + u} \]
      10. lift-neg.f64N/A

        \[\leadsto \frac{\color{blue}{-t1}}{t1 + u} \cdot \frac{v}{t1 + u} \]
      11. +-commutativeN/A

        \[\leadsto \frac{-t1}{\color{blue}{u + t1}} \cdot \frac{v}{t1 + u} \]
      12. lower-+.f64N/A

        \[\leadsto \frac{-t1}{\color{blue}{u + t1}} \cdot \frac{v}{t1 + u} \]
      13. lower-/.f64N/A

        \[\leadsto \frac{-t1}{u + t1} \cdot \color{blue}{\frac{v}{t1 + u}} \]
      14. +-commutativeN/A

        \[\leadsto \frac{-t1}{u + t1} \cdot \frac{v}{\color{blue}{u + t1}} \]
      15. lower-+.f6499.9

        \[\leadsto \frac{-t1}{u + t1} \cdot \frac{v}{\color{blue}{u + t1}} \]
    3. Applied rewrites99.9%

      \[\leadsto \color{blue}{\frac{-t1}{u + t1} \cdot \frac{v}{u + t1}} \]
    4. Taylor expanded in u around 0

      \[\leadsto \color{blue}{\left(\frac{u}{t1} - 1\right)} \cdot \frac{v}{u + t1} \]
    5. Step-by-step derivation
      1. lower--.f64N/A

        \[\leadsto \left(\frac{u}{t1} - \color{blue}{1}\right) \cdot \frac{v}{u + t1} \]
      2. lower-/.f6490.4

        \[\leadsto \left(\frac{u}{t1} - 1\right) \cdot \frac{v}{u + t1} \]
    6. Applied rewrites90.4%

      \[\leadsto \color{blue}{\left(\frac{u}{t1} - 1\right)} \cdot \frac{v}{u + t1} \]

    if -6.5e109 < t1 < 1.92000000000000004e93

    1. Initial program 84.0%

      \[\frac{\left(-t1\right) \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]

    if 1.92000000000000004e93 < t1

    1. Initial program 50.3%

      \[\frac{\left(-t1\right) \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
    2. Taylor expanded in u around 0

      \[\leadsto \color{blue}{-1 \cdot \frac{v}{t1}} \]
    3. Step-by-step derivation
      1. associate-*r/N/A

        \[\leadsto \frac{-1 \cdot v}{\color{blue}{t1}} \]
      2. lower-/.f64N/A

        \[\leadsto \frac{-1 \cdot v}{\color{blue}{t1}} \]
      3. mul-1-negN/A

        \[\leadsto \frac{\mathsf{neg}\left(v\right)}{t1} \]
      4. lower-neg.f6488.4

        \[\leadsto \frac{-v}{t1} \]
    4. Applied rewrites88.4%

      \[\leadsto \color{blue}{\frac{-v}{t1}} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 5: 85.8% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;t1 \leq -1.15 \cdot 10^{+109}:\\ \;\;\;\;\frac{-v}{u + t1}\\ \mathbf{elif}\;t1 \leq 1.92 \cdot 10^{+93}:\\ \;\;\;\;\frac{\left(-t1\right) \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{-v}{t1}\\ \end{array} \end{array} \]
(FPCore (u v t1)
 :precision binary64
 (if (<= t1 -1.15e+109)
   (/ (- v) (+ u t1))
   (if (<= t1 1.92e+93) (/ (* (- t1) v) (* (+ t1 u) (+ t1 u))) (/ (- v) t1))))
double code(double u, double v, double t1) {
	double tmp;
	if (t1 <= -1.15e+109) {
		tmp = -v / (u + t1);
	} else if (t1 <= 1.92e+93) {
		tmp = (-t1 * v) / ((t1 + u) * (t1 + u));
	} else {
		tmp = -v / t1;
	}
	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(u, v, t1)
use fmin_fmax_functions
    real(8), intent (in) :: u
    real(8), intent (in) :: v
    real(8), intent (in) :: t1
    real(8) :: tmp
    if (t1 <= (-1.15d+109)) then
        tmp = -v / (u + t1)
    else if (t1 <= 1.92d+93) then
        tmp = (-t1 * v) / ((t1 + u) * (t1 + u))
    else
        tmp = -v / t1
    end if
    code = tmp
end function
public static double code(double u, double v, double t1) {
	double tmp;
	if (t1 <= -1.15e+109) {
		tmp = -v / (u + t1);
	} else if (t1 <= 1.92e+93) {
		tmp = (-t1 * v) / ((t1 + u) * (t1 + u));
	} else {
		tmp = -v / t1;
	}
	return tmp;
}
def code(u, v, t1):
	tmp = 0
	if t1 <= -1.15e+109:
		tmp = -v / (u + t1)
	elif t1 <= 1.92e+93:
		tmp = (-t1 * v) / ((t1 + u) * (t1 + u))
	else:
		tmp = -v / t1
	return tmp
function code(u, v, t1)
	tmp = 0.0
	if (t1 <= -1.15e+109)
		tmp = Float64(Float64(-v) / Float64(u + t1));
	elseif (t1 <= 1.92e+93)
		tmp = Float64(Float64(Float64(-t1) * v) / Float64(Float64(t1 + u) * Float64(t1 + u)));
	else
		tmp = Float64(Float64(-v) / t1);
	end
	return tmp
end
function tmp_2 = code(u, v, t1)
	tmp = 0.0;
	if (t1 <= -1.15e+109)
		tmp = -v / (u + t1);
	elseif (t1 <= 1.92e+93)
		tmp = (-t1 * v) / ((t1 + u) * (t1 + u));
	else
		tmp = -v / t1;
	end
	tmp_2 = tmp;
end
code[u_, v_, t1_] := If[LessEqual[t1, -1.15e+109], N[((-v) / N[(u + t1), $MachinePrecision]), $MachinePrecision], If[LessEqual[t1, 1.92e+93], N[(N[((-t1) * v), $MachinePrecision] / N[(N[(t1 + u), $MachinePrecision] * N[(t1 + u), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-v) / t1), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;t1 \leq -1.15 \cdot 10^{+109}:\\
\;\;\;\;\frac{-v}{u + t1}\\

\mathbf{elif}\;t1 \leq 1.92 \cdot 10^{+93}:\\
\;\;\;\;\frac{\left(-t1\right) \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{-v}{t1}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if t1 < -1.15000000000000005e109

    1. Initial program 45.8%

      \[\frac{\left(-t1\right) \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
    2. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{\left(-t1\right) \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)}} \]
      2. lift-neg.f64N/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(t1\right)\right)} \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
      3. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
      4. lift-+.f64N/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}{\color{blue}{\left(t1 + u\right)} \cdot \left(t1 + u\right)} \]
      5. lift-+.f64N/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}{\left(t1 + u\right) \cdot \color{blue}{\left(t1 + u\right)}} \]
      6. lift-*.f64N/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}{\color{blue}{\left(t1 + u\right) \cdot \left(t1 + u\right)}} \]
      7. times-fracN/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(t1\right)}{t1 + u} \cdot \frac{v}{t1 + u}} \]
      8. lower-*.f64N/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(t1\right)}{t1 + u} \cdot \frac{v}{t1 + u}} \]
      9. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(t1\right)}{t1 + u}} \cdot \frac{v}{t1 + u} \]
      10. lift-neg.f64N/A

        \[\leadsto \frac{\color{blue}{-t1}}{t1 + u} \cdot \frac{v}{t1 + u} \]
      11. +-commutativeN/A

        \[\leadsto \frac{-t1}{\color{blue}{u + t1}} \cdot \frac{v}{t1 + u} \]
      12. lower-+.f64N/A

        \[\leadsto \frac{-t1}{\color{blue}{u + t1}} \cdot \frac{v}{t1 + u} \]
      13. lower-/.f64N/A

        \[\leadsto \frac{-t1}{u + t1} \cdot \color{blue}{\frac{v}{t1 + u}} \]
      14. +-commutativeN/A

        \[\leadsto \frac{-t1}{u + t1} \cdot \frac{v}{\color{blue}{u + t1}} \]
      15. lower-+.f6499.9

        \[\leadsto \frac{-t1}{u + t1} \cdot \frac{v}{\color{blue}{u + t1}} \]
    3. Applied rewrites99.9%

      \[\leadsto \color{blue}{\frac{-t1}{u + t1} \cdot \frac{v}{u + t1}} \]
    4. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{\frac{-t1}{u + t1} \cdot \frac{v}{u + t1}} \]
      2. lift-neg.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(t1\right)}}{u + t1} \cdot \frac{v}{u + t1} \]
      3. lift-+.f64N/A

        \[\leadsto \frac{\mathsf{neg}\left(t1\right)}{\color{blue}{u + t1}} \cdot \frac{v}{u + t1} \]
      4. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(t1\right)}{u + t1}} \cdot \frac{v}{u + t1} \]
      5. lift-+.f64N/A

        \[\leadsto \frac{\mathsf{neg}\left(t1\right)}{u + t1} \cdot \frac{v}{\color{blue}{u + t1}} \]
      6. lift-/.f64N/A

        \[\leadsto \frac{\mathsf{neg}\left(t1\right)}{u + t1} \cdot \color{blue}{\frac{v}{u + t1}} \]
      7. associate-*r/N/A

        \[\leadsto \color{blue}{\frac{\frac{\mathsf{neg}\left(t1\right)}{u + t1} \cdot v}{u + t1}} \]
      8. +-commutativeN/A

        \[\leadsto \frac{\frac{\mathsf{neg}\left(t1\right)}{u + t1} \cdot v}{\color{blue}{t1 + u}} \]
      9. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{\frac{\mathsf{neg}\left(t1\right)}{u + t1} \cdot v}{t1 + u}} \]
      10. lower-*.f64N/A

        \[\leadsto \frac{\color{blue}{\frac{\mathsf{neg}\left(t1\right)}{u + t1} \cdot v}}{t1 + u} \]
      11. lift-/.f64N/A

        \[\leadsto \frac{\color{blue}{\frac{\mathsf{neg}\left(t1\right)}{u + t1}} \cdot v}{t1 + u} \]
      12. lift-neg.f64N/A

        \[\leadsto \frac{\frac{\color{blue}{-t1}}{u + t1} \cdot v}{t1 + u} \]
      13. lift-+.f64N/A

        \[\leadsto \frac{\frac{-t1}{\color{blue}{u + t1}} \cdot v}{t1 + u} \]
      14. +-commutativeN/A

        \[\leadsto \frac{\frac{-t1}{u + t1} \cdot v}{\color{blue}{u + t1}} \]
      15. lift-+.f6499.9

        \[\leadsto \frac{\frac{-t1}{u + t1} \cdot v}{\color{blue}{u + t1}} \]
    5. Applied rewrites99.9%

      \[\leadsto \color{blue}{\frac{\frac{-t1}{u + t1} \cdot v}{u + t1}} \]
    6. Taylor expanded in u around 0

      \[\leadsto \frac{\color{blue}{-1 \cdot v}}{u + t1} \]
    7. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \frac{\mathsf{neg}\left(v\right)}{u + t1} \]
      2. lower-neg.f6490.2

        \[\leadsto \frac{-v}{u + t1} \]
    8. Applied rewrites90.2%

      \[\leadsto \frac{\color{blue}{-v}}{u + t1} \]

    if -1.15000000000000005e109 < t1 < 1.92000000000000004e93

    1. Initial program 84.1%

      \[\frac{\left(-t1\right) \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]

    if 1.92000000000000004e93 < t1

    1. Initial program 50.3%

      \[\frac{\left(-t1\right) \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
    2. Taylor expanded in u around 0

      \[\leadsto \color{blue}{-1 \cdot \frac{v}{t1}} \]
    3. Step-by-step derivation
      1. associate-*r/N/A

        \[\leadsto \frac{-1 \cdot v}{\color{blue}{t1}} \]
      2. lower-/.f64N/A

        \[\leadsto \frac{-1 \cdot v}{\color{blue}{t1}} \]
      3. mul-1-negN/A

        \[\leadsto \frac{\mathsf{neg}\left(v\right)}{t1} \]
      4. lower-neg.f6488.4

        \[\leadsto \frac{-v}{t1} \]
    4. Applied rewrites88.4%

      \[\leadsto \color{blue}{\frac{-v}{t1}} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 6: 78.8% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{-v}{u + t1}\\ \mathbf{if}\;t1 \leq -8.8 \cdot 10^{+52}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t1 \leq 5.2 \cdot 10^{-84}:\\ \;\;\;\;\frac{v \cdot \frac{-t1}{u}}{u}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (u v t1)
 :precision binary64
 (let* ((t_1 (/ (- v) (+ u t1))))
   (if (<= t1 -8.8e+52)
     t_1
     (if (<= t1 5.2e-84) (/ (* v (/ (- t1) u)) u) t_1))))
double code(double u, double v, double t1) {
	double t_1 = -v / (u + t1);
	double tmp;
	if (t1 <= -8.8e+52) {
		tmp = t_1;
	} else if (t1 <= 5.2e-84) {
		tmp = (v * (-t1 / u)) / u;
	} else {
		tmp = t_1;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(u, v, t1)
use fmin_fmax_functions
    real(8), intent (in) :: u
    real(8), intent (in) :: v
    real(8), intent (in) :: t1
    real(8) :: t_1
    real(8) :: tmp
    t_1 = -v / (u + t1)
    if (t1 <= (-8.8d+52)) then
        tmp = t_1
    else if (t1 <= 5.2d-84) then
        tmp = (v * (-t1 / u)) / u
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double u, double v, double t1) {
	double t_1 = -v / (u + t1);
	double tmp;
	if (t1 <= -8.8e+52) {
		tmp = t_1;
	} else if (t1 <= 5.2e-84) {
		tmp = (v * (-t1 / u)) / u;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(u, v, t1):
	t_1 = -v / (u + t1)
	tmp = 0
	if t1 <= -8.8e+52:
		tmp = t_1
	elif t1 <= 5.2e-84:
		tmp = (v * (-t1 / u)) / u
	else:
		tmp = t_1
	return tmp
function code(u, v, t1)
	t_1 = Float64(Float64(-v) / Float64(u + t1))
	tmp = 0.0
	if (t1 <= -8.8e+52)
		tmp = t_1;
	elseif (t1 <= 5.2e-84)
		tmp = Float64(Float64(v * Float64(Float64(-t1) / u)) / u);
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(u, v, t1)
	t_1 = -v / (u + t1);
	tmp = 0.0;
	if (t1 <= -8.8e+52)
		tmp = t_1;
	elseif (t1 <= 5.2e-84)
		tmp = (v * (-t1 / u)) / u;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[u_, v_, t1_] := Block[{t$95$1 = N[((-v) / N[(u + t1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t1, -8.8e+52], t$95$1, If[LessEqual[t1, 5.2e-84], N[(N[(v * N[((-t1) / u), $MachinePrecision]), $MachinePrecision] / u), $MachinePrecision], t$95$1]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \frac{-v}{u + t1}\\
\mathbf{if}\;t1 \leq -8.8 \cdot 10^{+52}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t1 \leq 5.2 \cdot 10^{-84}:\\
\;\;\;\;\frac{v \cdot \frac{-t1}{u}}{u}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t1 < -8.7999999999999999e52 or 5.2e-84 < t1

    1. Initial program 62.2%

      \[\frac{\left(-t1\right) \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
    2. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{\left(-t1\right) \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)}} \]
      2. lift-neg.f64N/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(t1\right)\right)} \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
      3. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
      4. lift-+.f64N/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}{\color{blue}{\left(t1 + u\right)} \cdot \left(t1 + u\right)} \]
      5. lift-+.f64N/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}{\left(t1 + u\right) \cdot \color{blue}{\left(t1 + u\right)}} \]
      6. lift-*.f64N/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}{\color{blue}{\left(t1 + u\right) \cdot \left(t1 + u\right)}} \]
      7. times-fracN/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(t1\right)}{t1 + u} \cdot \frac{v}{t1 + u}} \]
      8. lower-*.f64N/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(t1\right)}{t1 + u} \cdot \frac{v}{t1 + u}} \]
      9. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(t1\right)}{t1 + u}} \cdot \frac{v}{t1 + u} \]
      10. lift-neg.f64N/A

        \[\leadsto \frac{\color{blue}{-t1}}{t1 + u} \cdot \frac{v}{t1 + u} \]
      11. +-commutativeN/A

        \[\leadsto \frac{-t1}{\color{blue}{u + t1}} \cdot \frac{v}{t1 + u} \]
      12. lower-+.f64N/A

        \[\leadsto \frac{-t1}{\color{blue}{u + t1}} \cdot \frac{v}{t1 + u} \]
      13. lower-/.f64N/A

        \[\leadsto \frac{-t1}{u + t1} \cdot \color{blue}{\frac{v}{t1 + u}} \]
      14. +-commutativeN/A

        \[\leadsto \frac{-t1}{u + t1} \cdot \frac{v}{\color{blue}{u + t1}} \]
      15. lower-+.f6499.9

        \[\leadsto \frac{-t1}{u + t1} \cdot \frac{v}{\color{blue}{u + t1}} \]
    3. Applied rewrites99.9%

      \[\leadsto \color{blue}{\frac{-t1}{u + t1} \cdot \frac{v}{u + t1}} \]
    4. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{\frac{-t1}{u + t1} \cdot \frac{v}{u + t1}} \]
      2. lift-neg.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(t1\right)}}{u + t1} \cdot \frac{v}{u + t1} \]
      3. lift-+.f64N/A

        \[\leadsto \frac{\mathsf{neg}\left(t1\right)}{\color{blue}{u + t1}} \cdot \frac{v}{u + t1} \]
      4. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(t1\right)}{u + t1}} \cdot \frac{v}{u + t1} \]
      5. lift-+.f64N/A

        \[\leadsto \frac{\mathsf{neg}\left(t1\right)}{u + t1} \cdot \frac{v}{\color{blue}{u + t1}} \]
      6. lift-/.f64N/A

        \[\leadsto \frac{\mathsf{neg}\left(t1\right)}{u + t1} \cdot \color{blue}{\frac{v}{u + t1}} \]
      7. associate-*r/N/A

        \[\leadsto \color{blue}{\frac{\frac{\mathsf{neg}\left(t1\right)}{u + t1} \cdot v}{u + t1}} \]
      8. +-commutativeN/A

        \[\leadsto \frac{\frac{\mathsf{neg}\left(t1\right)}{u + t1} \cdot v}{\color{blue}{t1 + u}} \]
      9. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{\frac{\mathsf{neg}\left(t1\right)}{u + t1} \cdot v}{t1 + u}} \]
      10. lower-*.f64N/A

        \[\leadsto \frac{\color{blue}{\frac{\mathsf{neg}\left(t1\right)}{u + t1} \cdot v}}{t1 + u} \]
      11. lift-/.f64N/A

        \[\leadsto \frac{\color{blue}{\frac{\mathsf{neg}\left(t1\right)}{u + t1}} \cdot v}{t1 + u} \]
      12. lift-neg.f64N/A

        \[\leadsto \frac{\frac{\color{blue}{-t1}}{u + t1} \cdot v}{t1 + u} \]
      13. lift-+.f64N/A

        \[\leadsto \frac{\frac{-t1}{\color{blue}{u + t1}} \cdot v}{t1 + u} \]
      14. +-commutativeN/A

        \[\leadsto \frac{\frac{-t1}{u + t1} \cdot v}{\color{blue}{u + t1}} \]
      15. lift-+.f6499.9

        \[\leadsto \frac{\frac{-t1}{u + t1} \cdot v}{\color{blue}{u + t1}} \]
    5. Applied rewrites99.9%

      \[\leadsto \color{blue}{\frac{\frac{-t1}{u + t1} \cdot v}{u + t1}} \]
    6. Taylor expanded in u around 0

      \[\leadsto \frac{\color{blue}{-1 \cdot v}}{u + t1} \]
    7. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \frac{\mathsf{neg}\left(v\right)}{u + t1} \]
      2. lower-neg.f6481.9

        \[\leadsto \frac{-v}{u + t1} \]
    8. Applied rewrites81.9%

      \[\leadsto \frac{\color{blue}{-v}}{u + t1} \]

    if -8.7999999999999999e52 < t1 < 5.2e-84

    1. Initial program 82.8%

      \[\frac{\left(-t1\right) \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
    2. Taylor expanded in u around inf

      \[\leadsto \color{blue}{-1 \cdot \frac{t1 \cdot v}{{u}^{2}}} \]
    3. Step-by-step derivation
      1. associate-*r/N/A

        \[\leadsto \frac{-1 \cdot \left(t1 \cdot v\right)}{\color{blue}{{u}^{2}}} \]
      2. mul-1-negN/A

        \[\leadsto \frac{\mathsf{neg}\left(t1 \cdot v\right)}{{\color{blue}{u}}^{2}} \]
      3. distribute-lft-neg-outN/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}{{\color{blue}{u}}^{2}} \]
      4. *-commutativeN/A

        \[\leadsto \frac{v \cdot \left(\mathsf{neg}\left(t1\right)\right)}{{\color{blue}{u}}^{2}} \]
      5. unpow2N/A

        \[\leadsto \frac{v \cdot \left(\mathsf{neg}\left(t1\right)\right)}{u \cdot \color{blue}{u}} \]
      6. times-fracN/A

        \[\leadsto \frac{v}{u} \cdot \color{blue}{\frac{\mathsf{neg}\left(t1\right)}{u}} \]
      7. mul-1-negN/A

        \[\leadsto \frac{v}{u} \cdot \frac{-1 \cdot t1}{u} \]
      8. associate-*r/N/A

        \[\leadsto \frac{v}{u} \cdot \left(-1 \cdot \color{blue}{\frac{t1}{u}}\right) \]
      9. lower-*.f64N/A

        \[\leadsto \frac{v}{u} \cdot \color{blue}{\left(-1 \cdot \frac{t1}{u}\right)} \]
      10. lower-/.f64N/A

        \[\leadsto \frac{v}{u} \cdot \left(\color{blue}{-1} \cdot \frac{t1}{u}\right) \]
      11. associate-*r/N/A

        \[\leadsto \frac{v}{u} \cdot \frac{-1 \cdot t1}{\color{blue}{u}} \]
      12. mul-1-negN/A

        \[\leadsto \frac{v}{u} \cdot \frac{\mathsf{neg}\left(t1\right)}{u} \]
      13. lower-/.f64N/A

        \[\leadsto \frac{v}{u} \cdot \frac{\mathsf{neg}\left(t1\right)}{\color{blue}{u}} \]
      14. lift-neg.f6474.7

        \[\leadsto \frac{v}{u} \cdot \frac{-t1}{u} \]
    4. Applied rewrites74.7%

      \[\leadsto \color{blue}{\frac{v}{u} \cdot \frac{-t1}{u}} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{v}{u} \cdot \color{blue}{\frac{-t1}{u}} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{v}{u} \cdot \frac{\color{blue}{-t1}}{u} \]
      3. lift-neg.f64N/A

        \[\leadsto \frac{v}{u} \cdot \frac{\mathsf{neg}\left(t1\right)}{u} \]
      4. lift-/.f64N/A

        \[\leadsto \frac{v}{u} \cdot \frac{\mathsf{neg}\left(t1\right)}{\color{blue}{u}} \]
      5. distribute-frac-negN/A

        \[\leadsto \frac{v}{u} \cdot \left(\mathsf{neg}\left(\frac{t1}{u}\right)\right) \]
      6. mul-1-negN/A

        \[\leadsto \frac{v}{u} \cdot \left(-1 \cdot \color{blue}{\frac{t1}{u}}\right) \]
      7. associate-*l/N/A

        \[\leadsto \frac{v \cdot \left(-1 \cdot \frac{t1}{u}\right)}{\color{blue}{u}} \]
      8. lower-/.f64N/A

        \[\leadsto \frac{v \cdot \left(-1 \cdot \frac{t1}{u}\right)}{\color{blue}{u}} \]
      9. lower-*.f64N/A

        \[\leadsto \frac{v \cdot \left(-1 \cdot \frac{t1}{u}\right)}{u} \]
      10. mul-1-negN/A

        \[\leadsto \frac{v \cdot \left(\mathsf{neg}\left(\frac{t1}{u}\right)\right)}{u} \]
      11. distribute-frac-negN/A

        \[\leadsto \frac{v \cdot \frac{\mathsf{neg}\left(t1\right)}{u}}{u} \]
      12. lift-/.f64N/A

        \[\leadsto \frac{v \cdot \frac{\mathsf{neg}\left(t1\right)}{u}}{u} \]
      13. lift-neg.f6475.4

        \[\leadsto \frac{v \cdot \frac{-t1}{u}}{u} \]
    6. Applied rewrites75.4%

      \[\leadsto \frac{v \cdot \frac{-t1}{u}}{\color{blue}{u}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 7: 78.5% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{-v}{u + t1}\\ \mathbf{if}\;t1 \leq -8.8 \cdot 10^{+52}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t1 \leq 5.2 \cdot 10^{-84}:\\ \;\;\;\;\frac{v}{u} \cdot \frac{-t1}{u}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (u v t1)
 :precision binary64
 (let* ((t_1 (/ (- v) (+ u t1))))
   (if (<= t1 -8.8e+52)
     t_1
     (if (<= t1 5.2e-84) (* (/ v u) (/ (- t1) u)) t_1))))
double code(double u, double v, double t1) {
	double t_1 = -v / (u + t1);
	double tmp;
	if (t1 <= -8.8e+52) {
		tmp = t_1;
	} else if (t1 <= 5.2e-84) {
		tmp = (v / u) * (-t1 / u);
	} else {
		tmp = t_1;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(u, v, t1)
use fmin_fmax_functions
    real(8), intent (in) :: u
    real(8), intent (in) :: v
    real(8), intent (in) :: t1
    real(8) :: t_1
    real(8) :: tmp
    t_1 = -v / (u + t1)
    if (t1 <= (-8.8d+52)) then
        tmp = t_1
    else if (t1 <= 5.2d-84) then
        tmp = (v / u) * (-t1 / u)
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double u, double v, double t1) {
	double t_1 = -v / (u + t1);
	double tmp;
	if (t1 <= -8.8e+52) {
		tmp = t_1;
	} else if (t1 <= 5.2e-84) {
		tmp = (v / u) * (-t1 / u);
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(u, v, t1):
	t_1 = -v / (u + t1)
	tmp = 0
	if t1 <= -8.8e+52:
		tmp = t_1
	elif t1 <= 5.2e-84:
		tmp = (v / u) * (-t1 / u)
	else:
		tmp = t_1
	return tmp
function code(u, v, t1)
	t_1 = Float64(Float64(-v) / Float64(u + t1))
	tmp = 0.0
	if (t1 <= -8.8e+52)
		tmp = t_1;
	elseif (t1 <= 5.2e-84)
		tmp = Float64(Float64(v / u) * Float64(Float64(-t1) / u));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(u, v, t1)
	t_1 = -v / (u + t1);
	tmp = 0.0;
	if (t1 <= -8.8e+52)
		tmp = t_1;
	elseif (t1 <= 5.2e-84)
		tmp = (v / u) * (-t1 / u);
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[u_, v_, t1_] := Block[{t$95$1 = N[((-v) / N[(u + t1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t1, -8.8e+52], t$95$1, If[LessEqual[t1, 5.2e-84], N[(N[(v / u), $MachinePrecision] * N[((-t1) / u), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \frac{-v}{u + t1}\\
\mathbf{if}\;t1 \leq -8.8 \cdot 10^{+52}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t1 \leq 5.2 \cdot 10^{-84}:\\
\;\;\;\;\frac{v}{u} \cdot \frac{-t1}{u}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t1 < -8.7999999999999999e52 or 5.2e-84 < t1

    1. Initial program 62.2%

      \[\frac{\left(-t1\right) \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
    2. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{\left(-t1\right) \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)}} \]
      2. lift-neg.f64N/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(t1\right)\right)} \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
      3. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
      4. lift-+.f64N/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}{\color{blue}{\left(t1 + u\right)} \cdot \left(t1 + u\right)} \]
      5. lift-+.f64N/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}{\left(t1 + u\right) \cdot \color{blue}{\left(t1 + u\right)}} \]
      6. lift-*.f64N/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}{\color{blue}{\left(t1 + u\right) \cdot \left(t1 + u\right)}} \]
      7. times-fracN/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(t1\right)}{t1 + u} \cdot \frac{v}{t1 + u}} \]
      8. lower-*.f64N/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(t1\right)}{t1 + u} \cdot \frac{v}{t1 + u}} \]
      9. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(t1\right)}{t1 + u}} \cdot \frac{v}{t1 + u} \]
      10. lift-neg.f64N/A

        \[\leadsto \frac{\color{blue}{-t1}}{t1 + u} \cdot \frac{v}{t1 + u} \]
      11. +-commutativeN/A

        \[\leadsto \frac{-t1}{\color{blue}{u + t1}} \cdot \frac{v}{t1 + u} \]
      12. lower-+.f64N/A

        \[\leadsto \frac{-t1}{\color{blue}{u + t1}} \cdot \frac{v}{t1 + u} \]
      13. lower-/.f64N/A

        \[\leadsto \frac{-t1}{u + t1} \cdot \color{blue}{\frac{v}{t1 + u}} \]
      14. +-commutativeN/A

        \[\leadsto \frac{-t1}{u + t1} \cdot \frac{v}{\color{blue}{u + t1}} \]
      15. lower-+.f6499.9

        \[\leadsto \frac{-t1}{u + t1} \cdot \frac{v}{\color{blue}{u + t1}} \]
    3. Applied rewrites99.9%

      \[\leadsto \color{blue}{\frac{-t1}{u + t1} \cdot \frac{v}{u + t1}} \]
    4. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{\frac{-t1}{u + t1} \cdot \frac{v}{u + t1}} \]
      2. lift-neg.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(t1\right)}}{u + t1} \cdot \frac{v}{u + t1} \]
      3. lift-+.f64N/A

        \[\leadsto \frac{\mathsf{neg}\left(t1\right)}{\color{blue}{u + t1}} \cdot \frac{v}{u + t1} \]
      4. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(t1\right)}{u + t1}} \cdot \frac{v}{u + t1} \]
      5. lift-+.f64N/A

        \[\leadsto \frac{\mathsf{neg}\left(t1\right)}{u + t1} \cdot \frac{v}{\color{blue}{u + t1}} \]
      6. lift-/.f64N/A

        \[\leadsto \frac{\mathsf{neg}\left(t1\right)}{u + t1} \cdot \color{blue}{\frac{v}{u + t1}} \]
      7. associate-*r/N/A

        \[\leadsto \color{blue}{\frac{\frac{\mathsf{neg}\left(t1\right)}{u + t1} \cdot v}{u + t1}} \]
      8. +-commutativeN/A

        \[\leadsto \frac{\frac{\mathsf{neg}\left(t1\right)}{u + t1} \cdot v}{\color{blue}{t1 + u}} \]
      9. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{\frac{\mathsf{neg}\left(t1\right)}{u + t1} \cdot v}{t1 + u}} \]
      10. lower-*.f64N/A

        \[\leadsto \frac{\color{blue}{\frac{\mathsf{neg}\left(t1\right)}{u + t1} \cdot v}}{t1 + u} \]
      11. lift-/.f64N/A

        \[\leadsto \frac{\color{blue}{\frac{\mathsf{neg}\left(t1\right)}{u + t1}} \cdot v}{t1 + u} \]
      12. lift-neg.f64N/A

        \[\leadsto \frac{\frac{\color{blue}{-t1}}{u + t1} \cdot v}{t1 + u} \]
      13. lift-+.f64N/A

        \[\leadsto \frac{\frac{-t1}{\color{blue}{u + t1}} \cdot v}{t1 + u} \]
      14. +-commutativeN/A

        \[\leadsto \frac{\frac{-t1}{u + t1} \cdot v}{\color{blue}{u + t1}} \]
      15. lift-+.f6499.9

        \[\leadsto \frac{\frac{-t1}{u + t1} \cdot v}{\color{blue}{u + t1}} \]
    5. Applied rewrites99.9%

      \[\leadsto \color{blue}{\frac{\frac{-t1}{u + t1} \cdot v}{u + t1}} \]
    6. Taylor expanded in u around 0

      \[\leadsto \frac{\color{blue}{-1 \cdot v}}{u + t1} \]
    7. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \frac{\mathsf{neg}\left(v\right)}{u + t1} \]
      2. lower-neg.f6481.9

        \[\leadsto \frac{-v}{u + t1} \]
    8. Applied rewrites81.9%

      \[\leadsto \frac{\color{blue}{-v}}{u + t1} \]

    if -8.7999999999999999e52 < t1 < 5.2e-84

    1. Initial program 82.8%

      \[\frac{\left(-t1\right) \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
    2. Taylor expanded in u around inf

      \[\leadsto \color{blue}{-1 \cdot \frac{t1 \cdot v}{{u}^{2}}} \]
    3. Step-by-step derivation
      1. associate-*r/N/A

        \[\leadsto \frac{-1 \cdot \left(t1 \cdot v\right)}{\color{blue}{{u}^{2}}} \]
      2. mul-1-negN/A

        \[\leadsto \frac{\mathsf{neg}\left(t1 \cdot v\right)}{{\color{blue}{u}}^{2}} \]
      3. distribute-lft-neg-outN/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}{{\color{blue}{u}}^{2}} \]
      4. *-commutativeN/A

        \[\leadsto \frac{v \cdot \left(\mathsf{neg}\left(t1\right)\right)}{{\color{blue}{u}}^{2}} \]
      5. unpow2N/A

        \[\leadsto \frac{v \cdot \left(\mathsf{neg}\left(t1\right)\right)}{u \cdot \color{blue}{u}} \]
      6. times-fracN/A

        \[\leadsto \frac{v}{u} \cdot \color{blue}{\frac{\mathsf{neg}\left(t1\right)}{u}} \]
      7. mul-1-negN/A

        \[\leadsto \frac{v}{u} \cdot \frac{-1 \cdot t1}{u} \]
      8. associate-*r/N/A

        \[\leadsto \frac{v}{u} \cdot \left(-1 \cdot \color{blue}{\frac{t1}{u}}\right) \]
      9. lower-*.f64N/A

        \[\leadsto \frac{v}{u} \cdot \color{blue}{\left(-1 \cdot \frac{t1}{u}\right)} \]
      10. lower-/.f64N/A

        \[\leadsto \frac{v}{u} \cdot \left(\color{blue}{-1} \cdot \frac{t1}{u}\right) \]
      11. associate-*r/N/A

        \[\leadsto \frac{v}{u} \cdot \frac{-1 \cdot t1}{\color{blue}{u}} \]
      12. mul-1-negN/A

        \[\leadsto \frac{v}{u} \cdot \frac{\mathsf{neg}\left(t1\right)}{u} \]
      13. lower-/.f64N/A

        \[\leadsto \frac{v}{u} \cdot \frac{\mathsf{neg}\left(t1\right)}{\color{blue}{u}} \]
      14. lift-neg.f6474.7

        \[\leadsto \frac{v}{u} \cdot \frac{-t1}{u} \]
    4. Applied rewrites74.7%

      \[\leadsto \color{blue}{\frac{v}{u} \cdot \frac{-t1}{u}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 8: 77.6% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{-v}{u + t1}\\ \mathbf{if}\;t1 \leq -8.8 \cdot 10^{+52}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t1 \leq 5.2 \cdot 10^{-84}:\\ \;\;\;\;v \cdot \frac{\frac{-t1}{u}}{u}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (u v t1)
 :precision binary64
 (let* ((t_1 (/ (- v) (+ u t1))))
   (if (<= t1 -8.8e+52)
     t_1
     (if (<= t1 5.2e-84) (* v (/ (/ (- t1) u) u)) t_1))))
double code(double u, double v, double t1) {
	double t_1 = -v / (u + t1);
	double tmp;
	if (t1 <= -8.8e+52) {
		tmp = t_1;
	} else if (t1 <= 5.2e-84) {
		tmp = v * ((-t1 / u) / u);
	} else {
		tmp = t_1;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(u, v, t1)
use fmin_fmax_functions
    real(8), intent (in) :: u
    real(8), intent (in) :: v
    real(8), intent (in) :: t1
    real(8) :: t_1
    real(8) :: tmp
    t_1 = -v / (u + t1)
    if (t1 <= (-8.8d+52)) then
        tmp = t_1
    else if (t1 <= 5.2d-84) then
        tmp = v * ((-t1 / u) / u)
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double u, double v, double t1) {
	double t_1 = -v / (u + t1);
	double tmp;
	if (t1 <= -8.8e+52) {
		tmp = t_1;
	} else if (t1 <= 5.2e-84) {
		tmp = v * ((-t1 / u) / u);
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(u, v, t1):
	t_1 = -v / (u + t1)
	tmp = 0
	if t1 <= -8.8e+52:
		tmp = t_1
	elif t1 <= 5.2e-84:
		tmp = v * ((-t1 / u) / u)
	else:
		tmp = t_1
	return tmp
function code(u, v, t1)
	t_1 = Float64(Float64(-v) / Float64(u + t1))
	tmp = 0.0
	if (t1 <= -8.8e+52)
		tmp = t_1;
	elseif (t1 <= 5.2e-84)
		tmp = Float64(v * Float64(Float64(Float64(-t1) / u) / u));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(u, v, t1)
	t_1 = -v / (u + t1);
	tmp = 0.0;
	if (t1 <= -8.8e+52)
		tmp = t_1;
	elseif (t1 <= 5.2e-84)
		tmp = v * ((-t1 / u) / u);
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[u_, v_, t1_] := Block[{t$95$1 = N[((-v) / N[(u + t1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t1, -8.8e+52], t$95$1, If[LessEqual[t1, 5.2e-84], N[(v * N[(N[((-t1) / u), $MachinePrecision] / u), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \frac{-v}{u + t1}\\
\mathbf{if}\;t1 \leq -8.8 \cdot 10^{+52}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t1 \leq 5.2 \cdot 10^{-84}:\\
\;\;\;\;v \cdot \frac{\frac{-t1}{u}}{u}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t1 < -8.7999999999999999e52 or 5.2e-84 < t1

    1. Initial program 62.2%

      \[\frac{\left(-t1\right) \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
    2. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{\left(-t1\right) \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)}} \]
      2. lift-neg.f64N/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(t1\right)\right)} \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
      3. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
      4. lift-+.f64N/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}{\color{blue}{\left(t1 + u\right)} \cdot \left(t1 + u\right)} \]
      5. lift-+.f64N/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}{\left(t1 + u\right) \cdot \color{blue}{\left(t1 + u\right)}} \]
      6. lift-*.f64N/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}{\color{blue}{\left(t1 + u\right) \cdot \left(t1 + u\right)}} \]
      7. times-fracN/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(t1\right)}{t1 + u} \cdot \frac{v}{t1 + u}} \]
      8. lower-*.f64N/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(t1\right)}{t1 + u} \cdot \frac{v}{t1 + u}} \]
      9. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(t1\right)}{t1 + u}} \cdot \frac{v}{t1 + u} \]
      10. lift-neg.f64N/A

        \[\leadsto \frac{\color{blue}{-t1}}{t1 + u} \cdot \frac{v}{t1 + u} \]
      11. +-commutativeN/A

        \[\leadsto \frac{-t1}{\color{blue}{u + t1}} \cdot \frac{v}{t1 + u} \]
      12. lower-+.f64N/A

        \[\leadsto \frac{-t1}{\color{blue}{u + t1}} \cdot \frac{v}{t1 + u} \]
      13. lower-/.f64N/A

        \[\leadsto \frac{-t1}{u + t1} \cdot \color{blue}{\frac{v}{t1 + u}} \]
      14. +-commutativeN/A

        \[\leadsto \frac{-t1}{u + t1} \cdot \frac{v}{\color{blue}{u + t1}} \]
      15. lower-+.f6499.9

        \[\leadsto \frac{-t1}{u + t1} \cdot \frac{v}{\color{blue}{u + t1}} \]
    3. Applied rewrites99.9%

      \[\leadsto \color{blue}{\frac{-t1}{u + t1} \cdot \frac{v}{u + t1}} \]
    4. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{\frac{-t1}{u + t1} \cdot \frac{v}{u + t1}} \]
      2. lift-neg.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(t1\right)}}{u + t1} \cdot \frac{v}{u + t1} \]
      3. lift-+.f64N/A

        \[\leadsto \frac{\mathsf{neg}\left(t1\right)}{\color{blue}{u + t1}} \cdot \frac{v}{u + t1} \]
      4. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(t1\right)}{u + t1}} \cdot \frac{v}{u + t1} \]
      5. lift-+.f64N/A

        \[\leadsto \frac{\mathsf{neg}\left(t1\right)}{u + t1} \cdot \frac{v}{\color{blue}{u + t1}} \]
      6. lift-/.f64N/A

        \[\leadsto \frac{\mathsf{neg}\left(t1\right)}{u + t1} \cdot \color{blue}{\frac{v}{u + t1}} \]
      7. associate-*r/N/A

        \[\leadsto \color{blue}{\frac{\frac{\mathsf{neg}\left(t1\right)}{u + t1} \cdot v}{u + t1}} \]
      8. +-commutativeN/A

        \[\leadsto \frac{\frac{\mathsf{neg}\left(t1\right)}{u + t1} \cdot v}{\color{blue}{t1 + u}} \]
      9. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{\frac{\mathsf{neg}\left(t1\right)}{u + t1} \cdot v}{t1 + u}} \]
      10. lower-*.f64N/A

        \[\leadsto \frac{\color{blue}{\frac{\mathsf{neg}\left(t1\right)}{u + t1} \cdot v}}{t1 + u} \]
      11. lift-/.f64N/A

        \[\leadsto \frac{\color{blue}{\frac{\mathsf{neg}\left(t1\right)}{u + t1}} \cdot v}{t1 + u} \]
      12. lift-neg.f64N/A

        \[\leadsto \frac{\frac{\color{blue}{-t1}}{u + t1} \cdot v}{t1 + u} \]
      13. lift-+.f64N/A

        \[\leadsto \frac{\frac{-t1}{\color{blue}{u + t1}} \cdot v}{t1 + u} \]
      14. +-commutativeN/A

        \[\leadsto \frac{\frac{-t1}{u + t1} \cdot v}{\color{blue}{u + t1}} \]
      15. lift-+.f6499.9

        \[\leadsto \frac{\frac{-t1}{u + t1} \cdot v}{\color{blue}{u + t1}} \]
    5. Applied rewrites99.9%

      \[\leadsto \color{blue}{\frac{\frac{-t1}{u + t1} \cdot v}{u + t1}} \]
    6. Taylor expanded in u around 0

      \[\leadsto \frac{\color{blue}{-1 \cdot v}}{u + t1} \]
    7. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \frac{\mathsf{neg}\left(v\right)}{u + t1} \]
      2. lower-neg.f6481.9

        \[\leadsto \frac{-v}{u + t1} \]
    8. Applied rewrites81.9%

      \[\leadsto \frac{\color{blue}{-v}}{u + t1} \]

    if -8.7999999999999999e52 < t1 < 5.2e-84

    1. Initial program 82.8%

      \[\frac{\left(-t1\right) \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
    2. Taylor expanded in u around inf

      \[\leadsto \color{blue}{-1 \cdot \frac{t1 \cdot v}{{u}^{2}}} \]
    3. Step-by-step derivation
      1. associate-*r/N/A

        \[\leadsto \frac{-1 \cdot \left(t1 \cdot v\right)}{\color{blue}{{u}^{2}}} \]
      2. mul-1-negN/A

        \[\leadsto \frac{\mathsf{neg}\left(t1 \cdot v\right)}{{\color{blue}{u}}^{2}} \]
      3. distribute-lft-neg-outN/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}{{\color{blue}{u}}^{2}} \]
      4. *-commutativeN/A

        \[\leadsto \frac{v \cdot \left(\mathsf{neg}\left(t1\right)\right)}{{\color{blue}{u}}^{2}} \]
      5. unpow2N/A

        \[\leadsto \frac{v \cdot \left(\mathsf{neg}\left(t1\right)\right)}{u \cdot \color{blue}{u}} \]
      6. times-fracN/A

        \[\leadsto \frac{v}{u} \cdot \color{blue}{\frac{\mathsf{neg}\left(t1\right)}{u}} \]
      7. mul-1-negN/A

        \[\leadsto \frac{v}{u} \cdot \frac{-1 \cdot t1}{u} \]
      8. associate-*r/N/A

        \[\leadsto \frac{v}{u} \cdot \left(-1 \cdot \color{blue}{\frac{t1}{u}}\right) \]
      9. lower-*.f64N/A

        \[\leadsto \frac{v}{u} \cdot \color{blue}{\left(-1 \cdot \frac{t1}{u}\right)} \]
      10. lower-/.f64N/A

        \[\leadsto \frac{v}{u} \cdot \left(\color{blue}{-1} \cdot \frac{t1}{u}\right) \]
      11. associate-*r/N/A

        \[\leadsto \frac{v}{u} \cdot \frac{-1 \cdot t1}{\color{blue}{u}} \]
      12. mul-1-negN/A

        \[\leadsto \frac{v}{u} \cdot \frac{\mathsf{neg}\left(t1\right)}{u} \]
      13. lower-/.f64N/A

        \[\leadsto \frac{v}{u} \cdot \frac{\mathsf{neg}\left(t1\right)}{\color{blue}{u}} \]
      14. lift-neg.f6474.7

        \[\leadsto \frac{v}{u} \cdot \frac{-t1}{u} \]
    4. Applied rewrites74.7%

      \[\leadsto \color{blue}{\frac{v}{u} \cdot \frac{-t1}{u}} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{v}{u} \cdot \color{blue}{\frac{-t1}{u}} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{v}{u} \cdot \frac{\color{blue}{-t1}}{u} \]
      3. lift-neg.f64N/A

        \[\leadsto \frac{v}{u} \cdot \frac{\mathsf{neg}\left(t1\right)}{u} \]
      4. lift-/.f64N/A

        \[\leadsto \frac{v}{u} \cdot \frac{\mathsf{neg}\left(t1\right)}{\color{blue}{u}} \]
      5. distribute-frac-negN/A

        \[\leadsto \frac{v}{u} \cdot \left(\mathsf{neg}\left(\frac{t1}{u}\right)\right) \]
      6. mul-1-negN/A

        \[\leadsto \frac{v}{u} \cdot \left(-1 \cdot \color{blue}{\frac{t1}{u}}\right) \]
      7. associate-*l/N/A

        \[\leadsto \frac{v \cdot \left(-1 \cdot \frac{t1}{u}\right)}{\color{blue}{u}} \]
      8. lower-/.f64N/A

        \[\leadsto \frac{v \cdot \left(-1 \cdot \frac{t1}{u}\right)}{\color{blue}{u}} \]
      9. lower-*.f64N/A

        \[\leadsto \frac{v \cdot \left(-1 \cdot \frac{t1}{u}\right)}{u} \]
      10. mul-1-negN/A

        \[\leadsto \frac{v \cdot \left(\mathsf{neg}\left(\frac{t1}{u}\right)\right)}{u} \]
      11. distribute-frac-negN/A

        \[\leadsto \frac{v \cdot \frac{\mathsf{neg}\left(t1\right)}{u}}{u} \]
      12. lift-/.f64N/A

        \[\leadsto \frac{v \cdot \frac{\mathsf{neg}\left(t1\right)}{u}}{u} \]
      13. lift-neg.f6475.4

        \[\leadsto \frac{v \cdot \frac{-t1}{u}}{u} \]
    6. Applied rewrites75.4%

      \[\leadsto \frac{v \cdot \frac{-t1}{u}}{\color{blue}{u}} \]
    7. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \frac{v \cdot \frac{-t1}{u}}{\color{blue}{u}} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{v \cdot \frac{-t1}{u}}{u} \]
      3. lift-neg.f64N/A

        \[\leadsto \frac{v \cdot \frac{\mathsf{neg}\left(t1\right)}{u}}{u} \]
      4. lift-/.f64N/A

        \[\leadsto \frac{v \cdot \frac{\mathsf{neg}\left(t1\right)}{u}}{u} \]
      5. distribute-frac-negN/A

        \[\leadsto \frac{v \cdot \left(\mathsf{neg}\left(\frac{t1}{u}\right)\right)}{u} \]
      6. mul-1-negN/A

        \[\leadsto \frac{v \cdot \left(-1 \cdot \frac{t1}{u}\right)}{u} \]
      7. associate-/l*N/A

        \[\leadsto v \cdot \color{blue}{\frac{-1 \cdot \frac{t1}{u}}{u}} \]
      8. lower-*.f64N/A

        \[\leadsto v \cdot \color{blue}{\frac{-1 \cdot \frac{t1}{u}}{u}} \]
      9. lower-/.f64N/A

        \[\leadsto v \cdot \frac{-1 \cdot \frac{t1}{u}}{\color{blue}{u}} \]
      10. mul-1-negN/A

        \[\leadsto v \cdot \frac{\mathsf{neg}\left(\frac{t1}{u}\right)}{u} \]
      11. distribute-frac-negN/A

        \[\leadsto v \cdot \frac{\frac{\mathsf{neg}\left(t1\right)}{u}}{u} \]
      12. lift-/.f64N/A

        \[\leadsto v \cdot \frac{\frac{\mathsf{neg}\left(t1\right)}{u}}{u} \]
      13. lift-neg.f6472.8

        \[\leadsto v \cdot \frac{\frac{-t1}{u}}{u} \]
    8. Applied rewrites72.8%

      \[\leadsto v \cdot \color{blue}{\frac{\frac{-t1}{u}}{u}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 9: 77.1% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{-v}{u + t1}\\ \mathbf{if}\;t1 \leq -1.2 \cdot 10^{-47}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t1 \leq 5.2 \cdot 10^{-84}:\\ \;\;\;\;\frac{\left(-t1\right) \cdot v}{u \cdot u}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (u v t1)
 :precision binary64
 (let* ((t_1 (/ (- v) (+ u t1))))
   (if (<= t1 -1.2e-47)
     t_1
     (if (<= t1 5.2e-84) (/ (* (- t1) v) (* u u)) t_1))))
double code(double u, double v, double t1) {
	double t_1 = -v / (u + t1);
	double tmp;
	if (t1 <= -1.2e-47) {
		tmp = t_1;
	} else if (t1 <= 5.2e-84) {
		tmp = (-t1 * v) / (u * u);
	} else {
		tmp = t_1;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(u, v, t1)
use fmin_fmax_functions
    real(8), intent (in) :: u
    real(8), intent (in) :: v
    real(8), intent (in) :: t1
    real(8) :: t_1
    real(8) :: tmp
    t_1 = -v / (u + t1)
    if (t1 <= (-1.2d-47)) then
        tmp = t_1
    else if (t1 <= 5.2d-84) then
        tmp = (-t1 * v) / (u * u)
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double u, double v, double t1) {
	double t_1 = -v / (u + t1);
	double tmp;
	if (t1 <= -1.2e-47) {
		tmp = t_1;
	} else if (t1 <= 5.2e-84) {
		tmp = (-t1 * v) / (u * u);
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(u, v, t1):
	t_1 = -v / (u + t1)
	tmp = 0
	if t1 <= -1.2e-47:
		tmp = t_1
	elif t1 <= 5.2e-84:
		tmp = (-t1 * v) / (u * u)
	else:
		tmp = t_1
	return tmp
function code(u, v, t1)
	t_1 = Float64(Float64(-v) / Float64(u + t1))
	tmp = 0.0
	if (t1 <= -1.2e-47)
		tmp = t_1;
	elseif (t1 <= 5.2e-84)
		tmp = Float64(Float64(Float64(-t1) * v) / Float64(u * u));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(u, v, t1)
	t_1 = -v / (u + t1);
	tmp = 0.0;
	if (t1 <= -1.2e-47)
		tmp = t_1;
	elseif (t1 <= 5.2e-84)
		tmp = (-t1 * v) / (u * u);
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[u_, v_, t1_] := Block[{t$95$1 = N[((-v) / N[(u + t1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t1, -1.2e-47], t$95$1, If[LessEqual[t1, 5.2e-84], N[(N[((-t1) * v), $MachinePrecision] / N[(u * u), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \frac{-v}{u + t1}\\
\mathbf{if}\;t1 \leq -1.2 \cdot 10^{-47}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t1 \leq 5.2 \cdot 10^{-84}:\\
\;\;\;\;\frac{\left(-t1\right) \cdot v}{u \cdot u}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t1 < -1.2e-47 or 5.2e-84 < t1

    1. Initial program 65.9%

      \[\frac{\left(-t1\right) \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
    2. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{\left(-t1\right) \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)}} \]
      2. lift-neg.f64N/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(t1\right)\right)} \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
      3. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
      4. lift-+.f64N/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}{\color{blue}{\left(t1 + u\right)} \cdot \left(t1 + u\right)} \]
      5. lift-+.f64N/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}{\left(t1 + u\right) \cdot \color{blue}{\left(t1 + u\right)}} \]
      6. lift-*.f64N/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}{\color{blue}{\left(t1 + u\right) \cdot \left(t1 + u\right)}} \]
      7. times-fracN/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(t1\right)}{t1 + u} \cdot \frac{v}{t1 + u}} \]
      8. lower-*.f64N/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(t1\right)}{t1 + u} \cdot \frac{v}{t1 + u}} \]
      9. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(t1\right)}{t1 + u}} \cdot \frac{v}{t1 + u} \]
      10. lift-neg.f64N/A

        \[\leadsto \frac{\color{blue}{-t1}}{t1 + u} \cdot \frac{v}{t1 + u} \]
      11. +-commutativeN/A

        \[\leadsto \frac{-t1}{\color{blue}{u + t1}} \cdot \frac{v}{t1 + u} \]
      12. lower-+.f64N/A

        \[\leadsto \frac{-t1}{\color{blue}{u + t1}} \cdot \frac{v}{t1 + u} \]
      13. lower-/.f64N/A

        \[\leadsto \frac{-t1}{u + t1} \cdot \color{blue}{\frac{v}{t1 + u}} \]
      14. +-commutativeN/A

        \[\leadsto \frac{-t1}{u + t1} \cdot \frac{v}{\color{blue}{u + t1}} \]
      15. lower-+.f6499.9

        \[\leadsto \frac{-t1}{u + t1} \cdot \frac{v}{\color{blue}{u + t1}} \]
    3. Applied rewrites99.9%

      \[\leadsto \color{blue}{\frac{-t1}{u + t1} \cdot \frac{v}{u + t1}} \]
    4. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{\frac{-t1}{u + t1} \cdot \frac{v}{u + t1}} \]
      2. lift-neg.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(t1\right)}}{u + t1} \cdot \frac{v}{u + t1} \]
      3. lift-+.f64N/A

        \[\leadsto \frac{\mathsf{neg}\left(t1\right)}{\color{blue}{u + t1}} \cdot \frac{v}{u + t1} \]
      4. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(t1\right)}{u + t1}} \cdot \frac{v}{u + t1} \]
      5. lift-+.f64N/A

        \[\leadsto \frac{\mathsf{neg}\left(t1\right)}{u + t1} \cdot \frac{v}{\color{blue}{u + t1}} \]
      6. lift-/.f64N/A

        \[\leadsto \frac{\mathsf{neg}\left(t1\right)}{u + t1} \cdot \color{blue}{\frac{v}{u + t1}} \]
      7. associate-*r/N/A

        \[\leadsto \color{blue}{\frac{\frac{\mathsf{neg}\left(t1\right)}{u + t1} \cdot v}{u + t1}} \]
      8. +-commutativeN/A

        \[\leadsto \frac{\frac{\mathsf{neg}\left(t1\right)}{u + t1} \cdot v}{\color{blue}{t1 + u}} \]
      9. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{\frac{\mathsf{neg}\left(t1\right)}{u + t1} \cdot v}{t1 + u}} \]
      10. lower-*.f64N/A

        \[\leadsto \frac{\color{blue}{\frac{\mathsf{neg}\left(t1\right)}{u + t1} \cdot v}}{t1 + u} \]
      11. lift-/.f64N/A

        \[\leadsto \frac{\color{blue}{\frac{\mathsf{neg}\left(t1\right)}{u + t1}} \cdot v}{t1 + u} \]
      12. lift-neg.f64N/A

        \[\leadsto \frac{\frac{\color{blue}{-t1}}{u + t1} \cdot v}{t1 + u} \]
      13. lift-+.f64N/A

        \[\leadsto \frac{\frac{-t1}{\color{blue}{u + t1}} \cdot v}{t1 + u} \]
      14. +-commutativeN/A

        \[\leadsto \frac{\frac{-t1}{u + t1} \cdot v}{\color{blue}{u + t1}} \]
      15. lift-+.f6499.8

        \[\leadsto \frac{\frac{-t1}{u + t1} \cdot v}{\color{blue}{u + t1}} \]
    5. Applied rewrites99.8%

      \[\leadsto \color{blue}{\frac{\frac{-t1}{u + t1} \cdot v}{u + t1}} \]
    6. Taylor expanded in u around 0

      \[\leadsto \frac{\color{blue}{-1 \cdot v}}{u + t1} \]
    7. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \frac{\mathsf{neg}\left(v\right)}{u + t1} \]
      2. lower-neg.f6479.7

        \[\leadsto \frac{-v}{u + t1} \]
    8. Applied rewrites79.7%

      \[\leadsto \frac{\color{blue}{-v}}{u + t1} \]

    if -1.2e-47 < t1 < 5.2e-84

    1. Initial program 81.2%

      \[\frac{\left(-t1\right) \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
    2. Taylor expanded in u around inf

      \[\leadsto \frac{\left(-t1\right) \cdot v}{\color{blue}{{u}^{2}}} \]
    3. Step-by-step derivation
      1. unpow2N/A

        \[\leadsto \frac{\left(-t1\right) \cdot v}{u \cdot \color{blue}{u}} \]
      2. lower-*.f6473.2

        \[\leadsto \frac{\left(-t1\right) \cdot v}{u \cdot \color{blue}{u}} \]
    4. Applied rewrites73.2%

      \[\leadsto \frac{\left(-t1\right) \cdot v}{\color{blue}{u \cdot u}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 10: 76.5% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{-v}{u + t1}\\ \mathbf{if}\;t1 \leq -2.6 \cdot 10^{-117}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t1 \leq 5.2 \cdot 10^{-84}:\\ \;\;\;\;\left(-t1\right) \cdot \frac{v}{u \cdot u}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (u v t1)
 :precision binary64
 (let* ((t_1 (/ (- v) (+ u t1))))
   (if (<= t1 -2.6e-117)
     t_1
     (if (<= t1 5.2e-84) (* (- t1) (/ v (* u u))) t_1))))
double code(double u, double v, double t1) {
	double t_1 = -v / (u + t1);
	double tmp;
	if (t1 <= -2.6e-117) {
		tmp = t_1;
	} else if (t1 <= 5.2e-84) {
		tmp = -t1 * (v / (u * u));
	} else {
		tmp = t_1;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(u, v, t1)
use fmin_fmax_functions
    real(8), intent (in) :: u
    real(8), intent (in) :: v
    real(8), intent (in) :: t1
    real(8) :: t_1
    real(8) :: tmp
    t_1 = -v / (u + t1)
    if (t1 <= (-2.6d-117)) then
        tmp = t_1
    else if (t1 <= 5.2d-84) then
        tmp = -t1 * (v / (u * u))
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double u, double v, double t1) {
	double t_1 = -v / (u + t1);
	double tmp;
	if (t1 <= -2.6e-117) {
		tmp = t_1;
	} else if (t1 <= 5.2e-84) {
		tmp = -t1 * (v / (u * u));
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(u, v, t1):
	t_1 = -v / (u + t1)
	tmp = 0
	if t1 <= -2.6e-117:
		tmp = t_1
	elif t1 <= 5.2e-84:
		tmp = -t1 * (v / (u * u))
	else:
		tmp = t_1
	return tmp
function code(u, v, t1)
	t_1 = Float64(Float64(-v) / Float64(u + t1))
	tmp = 0.0
	if (t1 <= -2.6e-117)
		tmp = t_1;
	elseif (t1 <= 5.2e-84)
		tmp = Float64(Float64(-t1) * Float64(v / Float64(u * u)));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(u, v, t1)
	t_1 = -v / (u + t1);
	tmp = 0.0;
	if (t1 <= -2.6e-117)
		tmp = t_1;
	elseif (t1 <= 5.2e-84)
		tmp = -t1 * (v / (u * u));
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[u_, v_, t1_] := Block[{t$95$1 = N[((-v) / N[(u + t1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t1, -2.6e-117], t$95$1, If[LessEqual[t1, 5.2e-84], N[((-t1) * N[(v / N[(u * u), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \frac{-v}{u + t1}\\
\mathbf{if}\;t1 \leq -2.6 \cdot 10^{-117}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t1 \leq 5.2 \cdot 10^{-84}:\\
\;\;\;\;\left(-t1\right) \cdot \frac{v}{u \cdot u}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t1 < -2.59999999999999983e-117 or 5.2e-84 < t1

    1. Initial program 67.7%

      \[\frac{\left(-t1\right) \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
    2. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{\left(-t1\right) \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)}} \]
      2. lift-neg.f64N/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(t1\right)\right)} \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
      3. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
      4. lift-+.f64N/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}{\color{blue}{\left(t1 + u\right)} \cdot \left(t1 + u\right)} \]
      5. lift-+.f64N/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}{\left(t1 + u\right) \cdot \color{blue}{\left(t1 + u\right)}} \]
      6. lift-*.f64N/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}{\color{blue}{\left(t1 + u\right) \cdot \left(t1 + u\right)}} \]
      7. times-fracN/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(t1\right)}{t1 + u} \cdot \frac{v}{t1 + u}} \]
      8. lower-*.f64N/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(t1\right)}{t1 + u} \cdot \frac{v}{t1 + u}} \]
      9. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(t1\right)}{t1 + u}} \cdot \frac{v}{t1 + u} \]
      10. lift-neg.f64N/A

        \[\leadsto \frac{\color{blue}{-t1}}{t1 + u} \cdot \frac{v}{t1 + u} \]
      11. +-commutativeN/A

        \[\leadsto \frac{-t1}{\color{blue}{u + t1}} \cdot \frac{v}{t1 + u} \]
      12. lower-+.f64N/A

        \[\leadsto \frac{-t1}{\color{blue}{u + t1}} \cdot \frac{v}{t1 + u} \]
      13. lower-/.f64N/A

        \[\leadsto \frac{-t1}{u + t1} \cdot \color{blue}{\frac{v}{t1 + u}} \]
      14. +-commutativeN/A

        \[\leadsto \frac{-t1}{u + t1} \cdot \frac{v}{\color{blue}{u + t1}} \]
      15. lower-+.f6499.8

        \[\leadsto \frac{-t1}{u + t1} \cdot \frac{v}{\color{blue}{u + t1}} \]
    3. Applied rewrites99.8%

      \[\leadsto \color{blue}{\frac{-t1}{u + t1} \cdot \frac{v}{u + t1}} \]
    4. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{\frac{-t1}{u + t1} \cdot \frac{v}{u + t1}} \]
      2. lift-neg.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(t1\right)}}{u + t1} \cdot \frac{v}{u + t1} \]
      3. lift-+.f64N/A

        \[\leadsto \frac{\mathsf{neg}\left(t1\right)}{\color{blue}{u + t1}} \cdot \frac{v}{u + t1} \]
      4. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(t1\right)}{u + t1}} \cdot \frac{v}{u + t1} \]
      5. lift-+.f64N/A

        \[\leadsto \frac{\mathsf{neg}\left(t1\right)}{u + t1} \cdot \frac{v}{\color{blue}{u + t1}} \]
      6. lift-/.f64N/A

        \[\leadsto \frac{\mathsf{neg}\left(t1\right)}{u + t1} \cdot \color{blue}{\frac{v}{u + t1}} \]
      7. associate-*r/N/A

        \[\leadsto \color{blue}{\frac{\frac{\mathsf{neg}\left(t1\right)}{u + t1} \cdot v}{u + t1}} \]
      8. +-commutativeN/A

        \[\leadsto \frac{\frac{\mathsf{neg}\left(t1\right)}{u + t1} \cdot v}{\color{blue}{t1 + u}} \]
      9. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{\frac{\mathsf{neg}\left(t1\right)}{u + t1} \cdot v}{t1 + u}} \]
      10. lower-*.f64N/A

        \[\leadsto \frac{\color{blue}{\frac{\mathsf{neg}\left(t1\right)}{u + t1} \cdot v}}{t1 + u} \]
      11. lift-/.f64N/A

        \[\leadsto \frac{\color{blue}{\frac{\mathsf{neg}\left(t1\right)}{u + t1}} \cdot v}{t1 + u} \]
      12. lift-neg.f64N/A

        \[\leadsto \frac{\frac{\color{blue}{-t1}}{u + t1} \cdot v}{t1 + u} \]
      13. lift-+.f64N/A

        \[\leadsto \frac{\frac{-t1}{\color{blue}{u + t1}} \cdot v}{t1 + u} \]
      14. +-commutativeN/A

        \[\leadsto \frac{\frac{-t1}{u + t1} \cdot v}{\color{blue}{u + t1}} \]
      15. lift-+.f6499.8

        \[\leadsto \frac{\frac{-t1}{u + t1} \cdot v}{\color{blue}{u + t1}} \]
    5. Applied rewrites99.8%

      \[\leadsto \color{blue}{\frac{\frac{-t1}{u + t1} \cdot v}{u + t1}} \]
    6. Taylor expanded in u around 0

      \[\leadsto \frac{\color{blue}{-1 \cdot v}}{u + t1} \]
    7. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \frac{\mathsf{neg}\left(v\right)}{u + t1} \]
      2. lower-neg.f6477.3

        \[\leadsto \frac{-v}{u + t1} \]
    8. Applied rewrites77.3%

      \[\leadsto \frac{\color{blue}{-v}}{u + t1} \]

    if -2.59999999999999983e-117 < t1 < 5.2e-84

    1. Initial program 80.2%

      \[\frac{\left(-t1\right) \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
    2. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{\left(-t1\right) \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)}} \]
      2. lift-neg.f64N/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(t1\right)\right)} \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
      3. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
      4. lift-+.f64N/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}{\color{blue}{\left(t1 + u\right)} \cdot \left(t1 + u\right)} \]
      5. lift-+.f64N/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}{\left(t1 + u\right) \cdot \color{blue}{\left(t1 + u\right)}} \]
      6. lift-*.f64N/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}{\color{blue}{\left(t1 + u\right) \cdot \left(t1 + u\right)}} \]
      7. associate-/l*N/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(t1\right)\right) \cdot \frac{v}{\left(t1 + u\right) \cdot \left(t1 + u\right)}} \]
      8. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(t1\right)\right) \cdot \frac{v}{\left(t1 + u\right) \cdot \left(t1 + u\right)}} \]
      9. lift-neg.f64N/A

        \[\leadsto \color{blue}{\left(-t1\right)} \cdot \frac{v}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
      10. lower-/.f64N/A

        \[\leadsto \left(-t1\right) \cdot \color{blue}{\frac{v}{\left(t1 + u\right) \cdot \left(t1 + u\right)}} \]
      11. pow2N/A

        \[\leadsto \left(-t1\right) \cdot \frac{v}{\color{blue}{{\left(t1 + u\right)}^{2}}} \]
      12. lower-pow.f64N/A

        \[\leadsto \left(-t1\right) \cdot \frac{v}{\color{blue}{{\left(t1 + u\right)}^{2}}} \]
      13. +-commutativeN/A

        \[\leadsto \left(-t1\right) \cdot \frac{v}{{\color{blue}{\left(u + t1\right)}}^{2}} \]
      14. lower-+.f6480.3

        \[\leadsto \left(-t1\right) \cdot \frac{v}{{\color{blue}{\left(u + t1\right)}}^{2}} \]
    3. Applied rewrites80.3%

      \[\leadsto \color{blue}{\left(-t1\right) \cdot \frac{v}{{\left(u + t1\right)}^{2}}} \]
    4. Taylor expanded in u around inf

      \[\leadsto \left(-t1\right) \cdot \color{blue}{\frac{v}{{u}^{2}}} \]
    5. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \left(-t1\right) \cdot \frac{v}{\color{blue}{{u}^{2}}} \]
      2. unpow2N/A

        \[\leadsto \left(-t1\right) \cdot \frac{v}{u \cdot \color{blue}{u}} \]
      3. lower-*.f6475.1

        \[\leadsto \left(-t1\right) \cdot \frac{v}{u \cdot \color{blue}{u}} \]
    6. Applied rewrites75.1%

      \[\leadsto \left(-t1\right) \cdot \color{blue}{\frac{v}{u \cdot u}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 11: 98.0% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \frac{\left(-t1\right) \cdot \frac{v}{u + t1}}{u + t1} \end{array} \]
(FPCore (u v t1) :precision binary64 (/ (* (- t1) (/ v (+ u t1))) (+ u t1)))
double code(double u, double v, double t1) {
	return (-t1 * (v / (u + t1))) / (u + t1);
}
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(u, v, t1)
use fmin_fmax_functions
    real(8), intent (in) :: u
    real(8), intent (in) :: v
    real(8), intent (in) :: t1
    code = (-t1 * (v / (u + t1))) / (u + t1)
end function
public static double code(double u, double v, double t1) {
	return (-t1 * (v / (u + t1))) / (u + t1);
}
def code(u, v, t1):
	return (-t1 * (v / (u + t1))) / (u + t1)
function code(u, v, t1)
	return Float64(Float64(Float64(-t1) * Float64(v / Float64(u + t1))) / Float64(u + t1))
end
function tmp = code(u, v, t1)
	tmp = (-t1 * (v / (u + t1))) / (u + t1);
end
code[u_, v_, t1_] := N[(N[((-t1) * N[(v / N[(u + t1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(u + t1), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{\left(-t1\right) \cdot \frac{v}{u + t1}}{u + t1}
\end{array}
Derivation
  1. Initial program 71.9%

    \[\frac{\left(-t1\right) \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
  2. Step-by-step derivation
    1. lift-/.f64N/A

      \[\leadsto \color{blue}{\frac{\left(-t1\right) \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)}} \]
    2. lift-neg.f64N/A

      \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(t1\right)\right)} \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
    3. lift-*.f64N/A

      \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
    4. lift-+.f64N/A

      \[\leadsto \frac{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}{\color{blue}{\left(t1 + u\right)} \cdot \left(t1 + u\right)} \]
    5. lift-+.f64N/A

      \[\leadsto \frac{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}{\left(t1 + u\right) \cdot \color{blue}{\left(t1 + u\right)}} \]
    6. lift-*.f64N/A

      \[\leadsto \frac{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}{\color{blue}{\left(t1 + u\right) \cdot \left(t1 + u\right)}} \]
    7. times-fracN/A

      \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(t1\right)}{t1 + u} \cdot \frac{v}{t1 + u}} \]
    8. lower-*.f64N/A

      \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(t1\right)}{t1 + u} \cdot \frac{v}{t1 + u}} \]
    9. lower-/.f64N/A

      \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(t1\right)}{t1 + u}} \cdot \frac{v}{t1 + u} \]
    10. lift-neg.f64N/A

      \[\leadsto \frac{\color{blue}{-t1}}{t1 + u} \cdot \frac{v}{t1 + u} \]
    11. +-commutativeN/A

      \[\leadsto \frac{-t1}{\color{blue}{u + t1}} \cdot \frac{v}{t1 + u} \]
    12. lower-+.f64N/A

      \[\leadsto \frac{-t1}{\color{blue}{u + t1}} \cdot \frac{v}{t1 + u} \]
    13. lower-/.f64N/A

      \[\leadsto \frac{-t1}{u + t1} \cdot \color{blue}{\frac{v}{t1 + u}} \]
    14. +-commutativeN/A

      \[\leadsto \frac{-t1}{u + t1} \cdot \frac{v}{\color{blue}{u + t1}} \]
    15. lower-+.f6497.9

      \[\leadsto \frac{-t1}{u + t1} \cdot \frac{v}{\color{blue}{u + t1}} \]
  3. Applied rewrites97.9%

    \[\leadsto \color{blue}{\frac{-t1}{u + t1} \cdot \frac{v}{u + t1}} \]
  4. Step-by-step derivation
    1. lift-*.f64N/A

      \[\leadsto \color{blue}{\frac{-t1}{u + t1} \cdot \frac{v}{u + t1}} \]
    2. lift-neg.f64N/A

      \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(t1\right)}}{u + t1} \cdot \frac{v}{u + t1} \]
    3. lift-+.f64N/A

      \[\leadsto \frac{\mathsf{neg}\left(t1\right)}{\color{blue}{u + t1}} \cdot \frac{v}{u + t1} \]
    4. lift-/.f64N/A

      \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(t1\right)}{u + t1}} \cdot \frac{v}{u + t1} \]
    5. lift-+.f64N/A

      \[\leadsto \frac{\mathsf{neg}\left(t1\right)}{u + t1} \cdot \frac{v}{\color{blue}{u + t1}} \]
    6. lift-/.f64N/A

      \[\leadsto \frac{\mathsf{neg}\left(t1\right)}{u + t1} \cdot \color{blue}{\frac{v}{u + t1}} \]
    7. associate-*l/N/A

      \[\leadsto \color{blue}{\frac{\left(\mathsf{neg}\left(t1\right)\right) \cdot \frac{v}{u + t1}}{u + t1}} \]
    8. +-commutativeN/A

      \[\leadsto \frac{\left(\mathsf{neg}\left(t1\right)\right) \cdot \frac{v}{u + t1}}{\color{blue}{t1 + u}} \]
    9. lower-/.f64N/A

      \[\leadsto \color{blue}{\frac{\left(\mathsf{neg}\left(t1\right)\right) \cdot \frac{v}{u + t1}}{t1 + u}} \]
    10. lower-*.f64N/A

      \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(t1\right)\right) \cdot \frac{v}{u + t1}}}{t1 + u} \]
    11. lift-neg.f64N/A

      \[\leadsto \frac{\color{blue}{\left(-t1\right)} \cdot \frac{v}{u + t1}}{t1 + u} \]
    12. lift-/.f64N/A

      \[\leadsto \frac{\left(-t1\right) \cdot \color{blue}{\frac{v}{u + t1}}}{t1 + u} \]
    13. lift-+.f64N/A

      \[\leadsto \frac{\left(-t1\right) \cdot \frac{v}{\color{blue}{u + t1}}}{t1 + u} \]
    14. +-commutativeN/A

      \[\leadsto \frac{\left(-t1\right) \cdot \frac{v}{u + t1}}{\color{blue}{u + t1}} \]
    15. lift-+.f6498.0

      \[\leadsto \frac{\left(-t1\right) \cdot \frac{v}{u + t1}}{\color{blue}{u + t1}} \]
  5. Applied rewrites98.0%

    \[\leadsto \color{blue}{\frac{\left(-t1\right) \cdot \frac{v}{u + t1}}{u + t1}} \]
  6. Add Preprocessing

Alternative 12: 97.9% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \frac{-t1}{u + t1} \cdot \frac{v}{u + t1} \end{array} \]
(FPCore (u v t1) :precision binary64 (* (/ (- t1) (+ u t1)) (/ v (+ u t1))))
double code(double u, double v, double t1) {
	return (-t1 / (u + t1)) * (v / (u + t1));
}
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(u, v, t1)
use fmin_fmax_functions
    real(8), intent (in) :: u
    real(8), intent (in) :: v
    real(8), intent (in) :: t1
    code = (-t1 / (u + t1)) * (v / (u + t1))
end function
public static double code(double u, double v, double t1) {
	return (-t1 / (u + t1)) * (v / (u + t1));
}
def code(u, v, t1):
	return (-t1 / (u + t1)) * (v / (u + t1))
function code(u, v, t1)
	return Float64(Float64(Float64(-t1) / Float64(u + t1)) * Float64(v / Float64(u + t1)))
end
function tmp = code(u, v, t1)
	tmp = (-t1 / (u + t1)) * (v / (u + t1));
end
code[u_, v_, t1_] := N[(N[((-t1) / N[(u + t1), $MachinePrecision]), $MachinePrecision] * N[(v / N[(u + t1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{-t1}{u + t1} \cdot \frac{v}{u + t1}
\end{array}
Derivation
  1. Initial program 71.9%

    \[\frac{\left(-t1\right) \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
  2. Step-by-step derivation
    1. lift-/.f64N/A

      \[\leadsto \color{blue}{\frac{\left(-t1\right) \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)}} \]
    2. lift-neg.f64N/A

      \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(t1\right)\right)} \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
    3. lift-*.f64N/A

      \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
    4. lift-+.f64N/A

      \[\leadsto \frac{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}{\color{blue}{\left(t1 + u\right)} \cdot \left(t1 + u\right)} \]
    5. lift-+.f64N/A

      \[\leadsto \frac{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}{\left(t1 + u\right) \cdot \color{blue}{\left(t1 + u\right)}} \]
    6. lift-*.f64N/A

      \[\leadsto \frac{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}{\color{blue}{\left(t1 + u\right) \cdot \left(t1 + u\right)}} \]
    7. times-fracN/A

      \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(t1\right)}{t1 + u} \cdot \frac{v}{t1 + u}} \]
    8. lower-*.f64N/A

      \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(t1\right)}{t1 + u} \cdot \frac{v}{t1 + u}} \]
    9. lower-/.f64N/A

      \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(t1\right)}{t1 + u}} \cdot \frac{v}{t1 + u} \]
    10. lift-neg.f64N/A

      \[\leadsto \frac{\color{blue}{-t1}}{t1 + u} \cdot \frac{v}{t1 + u} \]
    11. +-commutativeN/A

      \[\leadsto \frac{-t1}{\color{blue}{u + t1}} \cdot \frac{v}{t1 + u} \]
    12. lower-+.f64N/A

      \[\leadsto \frac{-t1}{\color{blue}{u + t1}} \cdot \frac{v}{t1 + u} \]
    13. lower-/.f64N/A

      \[\leadsto \frac{-t1}{u + t1} \cdot \color{blue}{\frac{v}{t1 + u}} \]
    14. +-commutativeN/A

      \[\leadsto \frac{-t1}{u + t1} \cdot \frac{v}{\color{blue}{u + t1}} \]
    15. lower-+.f6497.9

      \[\leadsto \frac{-t1}{u + t1} \cdot \frac{v}{\color{blue}{u + t1}} \]
  3. Applied rewrites97.9%

    \[\leadsto \color{blue}{\frac{-t1}{u + t1} \cdot \frac{v}{u + t1}} \]
  4. Add Preprocessing

Alternative 13: 56.7% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;u \leq 3.8 \cdot 10^{+177}:\\ \;\;\;\;\frac{-v}{t1}\\ \mathbf{else}:\\ \;\;\;\;-1 \cdot \frac{v}{u}\\ \end{array} \end{array} \]
(FPCore (u v t1)
 :precision binary64
 (if (<= u 3.8e+177) (/ (- v) t1) (* -1.0 (/ v u))))
double code(double u, double v, double t1) {
	double tmp;
	if (u <= 3.8e+177) {
		tmp = -v / t1;
	} else {
		tmp = -1.0 * (v / u);
	}
	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(u, v, t1)
use fmin_fmax_functions
    real(8), intent (in) :: u
    real(8), intent (in) :: v
    real(8), intent (in) :: t1
    real(8) :: tmp
    if (u <= 3.8d+177) then
        tmp = -v / t1
    else
        tmp = (-1.0d0) * (v / u)
    end if
    code = tmp
end function
public static double code(double u, double v, double t1) {
	double tmp;
	if (u <= 3.8e+177) {
		tmp = -v / t1;
	} else {
		tmp = -1.0 * (v / u);
	}
	return tmp;
}
def code(u, v, t1):
	tmp = 0
	if u <= 3.8e+177:
		tmp = -v / t1
	else:
		tmp = -1.0 * (v / u)
	return tmp
function code(u, v, t1)
	tmp = 0.0
	if (u <= 3.8e+177)
		tmp = Float64(Float64(-v) / t1);
	else
		tmp = Float64(-1.0 * Float64(v / u));
	end
	return tmp
end
function tmp_2 = code(u, v, t1)
	tmp = 0.0;
	if (u <= 3.8e+177)
		tmp = -v / t1;
	else
		tmp = -1.0 * (v / u);
	end
	tmp_2 = tmp;
end
code[u_, v_, t1_] := If[LessEqual[u, 3.8e+177], N[((-v) / t1), $MachinePrecision], N[(-1.0 * N[(v / u), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;u \leq 3.8 \cdot 10^{+177}:\\
\;\;\;\;\frac{-v}{t1}\\

\mathbf{else}:\\
\;\;\;\;-1 \cdot \frac{v}{u}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if u < 3.7999999999999998e177

    1. Initial program 71.6%

      \[\frac{\left(-t1\right) \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
    2. Taylor expanded in u around 0

      \[\leadsto \color{blue}{-1 \cdot \frac{v}{t1}} \]
    3. Step-by-step derivation
      1. associate-*r/N/A

        \[\leadsto \frac{-1 \cdot v}{\color{blue}{t1}} \]
      2. lower-/.f64N/A

        \[\leadsto \frac{-1 \cdot v}{\color{blue}{t1}} \]
      3. mul-1-negN/A

        \[\leadsto \frac{\mathsf{neg}\left(v\right)}{t1} \]
      4. lower-neg.f6458.3

        \[\leadsto \frac{-v}{t1} \]
    4. Applied rewrites58.3%

      \[\leadsto \color{blue}{\frac{-v}{t1}} \]

    if 3.7999999999999998e177 < u

    1. Initial program 75.0%

      \[\frac{\left(-t1\right) \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
    2. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{\left(-t1\right) \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)}} \]
      2. lift-neg.f64N/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(t1\right)\right)} \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
      3. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
      4. lift-+.f64N/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}{\color{blue}{\left(t1 + u\right)} \cdot \left(t1 + u\right)} \]
      5. lift-+.f64N/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}{\left(t1 + u\right) \cdot \color{blue}{\left(t1 + u\right)}} \]
      6. lift-*.f64N/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}{\color{blue}{\left(t1 + u\right) \cdot \left(t1 + u\right)}} \]
      7. times-fracN/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(t1\right)}{t1 + u} \cdot \frac{v}{t1 + u}} \]
      8. lower-*.f64N/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(t1\right)}{t1 + u} \cdot \frac{v}{t1 + u}} \]
      9. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(t1\right)}{t1 + u}} \cdot \frac{v}{t1 + u} \]
      10. lift-neg.f64N/A

        \[\leadsto \frac{\color{blue}{-t1}}{t1 + u} \cdot \frac{v}{t1 + u} \]
      11. +-commutativeN/A

        \[\leadsto \frac{-t1}{\color{blue}{u + t1}} \cdot \frac{v}{t1 + u} \]
      12. lower-+.f64N/A

        \[\leadsto \frac{-t1}{\color{blue}{u + t1}} \cdot \frac{v}{t1 + u} \]
      13. lower-/.f64N/A

        \[\leadsto \frac{-t1}{u + t1} \cdot \color{blue}{\frac{v}{t1 + u}} \]
      14. +-commutativeN/A

        \[\leadsto \frac{-t1}{u + t1} \cdot \frac{v}{\color{blue}{u + t1}} \]
      15. lower-+.f6499.1

        \[\leadsto \frac{-t1}{u + t1} \cdot \frac{v}{\color{blue}{u + t1}} \]
    3. Applied rewrites99.1%

      \[\leadsto \color{blue}{\frac{-t1}{u + t1} \cdot \frac{v}{u + t1}} \]
    4. Taylor expanded in u around 0

      \[\leadsto \color{blue}{-1} \cdot \frac{v}{u + t1} \]
    5. Step-by-step derivation
      1. Applied rewrites50.4%

        \[\leadsto \color{blue}{-1} \cdot \frac{v}{u + t1} \]
      2. Taylor expanded in u around inf

        \[\leadsto -1 \cdot \frac{v}{\color{blue}{u}} \]
      3. Step-by-step derivation
        1. Applied rewrites42.9%

          \[\leadsto -1 \cdot \frac{v}{\color{blue}{u}} \]
      4. Recombined 2 regimes into one program.
      5. Add Preprocessing

      Alternative 14: 62.0% accurate, 1.8× speedup?

      \[\begin{array}{l} \\ \frac{-v}{u + t1} \end{array} \]
      (FPCore (u v t1) :precision binary64 (/ (- v) (+ u t1)))
      double code(double u, double v, double t1) {
      	return -v / (u + t1);
      }
      
      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(u, v, t1)
      use fmin_fmax_functions
          real(8), intent (in) :: u
          real(8), intent (in) :: v
          real(8), intent (in) :: t1
          code = -v / (u + t1)
      end function
      
      public static double code(double u, double v, double t1) {
      	return -v / (u + t1);
      }
      
      def code(u, v, t1):
      	return -v / (u + t1)
      
      function code(u, v, t1)
      	return Float64(Float64(-v) / Float64(u + t1))
      end
      
      function tmp = code(u, v, t1)
      	tmp = -v / (u + t1);
      end
      
      code[u_, v_, t1_] := N[((-v) / N[(u + t1), $MachinePrecision]), $MachinePrecision]
      
      \begin{array}{l}
      
      \\
      \frac{-v}{u + t1}
      \end{array}
      
      Derivation
      1. Initial program 71.9%

        \[\frac{\left(-t1\right) \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
      2. Step-by-step derivation
        1. lift-/.f64N/A

          \[\leadsto \color{blue}{\frac{\left(-t1\right) \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)}} \]
        2. lift-neg.f64N/A

          \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(t1\right)\right)} \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
        3. lift-*.f64N/A

          \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
        4. lift-+.f64N/A

          \[\leadsto \frac{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}{\color{blue}{\left(t1 + u\right)} \cdot \left(t1 + u\right)} \]
        5. lift-+.f64N/A

          \[\leadsto \frac{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}{\left(t1 + u\right) \cdot \color{blue}{\left(t1 + u\right)}} \]
        6. lift-*.f64N/A

          \[\leadsto \frac{\left(\mathsf{neg}\left(t1\right)\right) \cdot v}{\color{blue}{\left(t1 + u\right) \cdot \left(t1 + u\right)}} \]
        7. times-fracN/A

          \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(t1\right)}{t1 + u} \cdot \frac{v}{t1 + u}} \]
        8. lower-*.f64N/A

          \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(t1\right)}{t1 + u} \cdot \frac{v}{t1 + u}} \]
        9. lower-/.f64N/A

          \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(t1\right)}{t1 + u}} \cdot \frac{v}{t1 + u} \]
        10. lift-neg.f64N/A

          \[\leadsto \frac{\color{blue}{-t1}}{t1 + u} \cdot \frac{v}{t1 + u} \]
        11. +-commutativeN/A

          \[\leadsto \frac{-t1}{\color{blue}{u + t1}} \cdot \frac{v}{t1 + u} \]
        12. lower-+.f64N/A

          \[\leadsto \frac{-t1}{\color{blue}{u + t1}} \cdot \frac{v}{t1 + u} \]
        13. lower-/.f64N/A

          \[\leadsto \frac{-t1}{u + t1} \cdot \color{blue}{\frac{v}{t1 + u}} \]
        14. +-commutativeN/A

          \[\leadsto \frac{-t1}{u + t1} \cdot \frac{v}{\color{blue}{u + t1}} \]
        15. lower-+.f6497.9

          \[\leadsto \frac{-t1}{u + t1} \cdot \frac{v}{\color{blue}{u + t1}} \]
      3. Applied rewrites97.9%

        \[\leadsto \color{blue}{\frac{-t1}{u + t1} \cdot \frac{v}{u + t1}} \]
      4. Step-by-step derivation
        1. lift-*.f64N/A

          \[\leadsto \color{blue}{\frac{-t1}{u + t1} \cdot \frac{v}{u + t1}} \]
        2. lift-neg.f64N/A

          \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(t1\right)}}{u + t1} \cdot \frac{v}{u + t1} \]
        3. lift-+.f64N/A

          \[\leadsto \frac{\mathsf{neg}\left(t1\right)}{\color{blue}{u + t1}} \cdot \frac{v}{u + t1} \]
        4. lift-/.f64N/A

          \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(t1\right)}{u + t1}} \cdot \frac{v}{u + t1} \]
        5. lift-+.f64N/A

          \[\leadsto \frac{\mathsf{neg}\left(t1\right)}{u + t1} \cdot \frac{v}{\color{blue}{u + t1}} \]
        6. lift-/.f64N/A

          \[\leadsto \frac{\mathsf{neg}\left(t1\right)}{u + t1} \cdot \color{blue}{\frac{v}{u + t1}} \]
        7. associate-*r/N/A

          \[\leadsto \color{blue}{\frac{\frac{\mathsf{neg}\left(t1\right)}{u + t1} \cdot v}{u + t1}} \]
        8. +-commutativeN/A

          \[\leadsto \frac{\frac{\mathsf{neg}\left(t1\right)}{u + t1} \cdot v}{\color{blue}{t1 + u}} \]
        9. lower-/.f64N/A

          \[\leadsto \color{blue}{\frac{\frac{\mathsf{neg}\left(t1\right)}{u + t1} \cdot v}{t1 + u}} \]
        10. lower-*.f64N/A

          \[\leadsto \frac{\color{blue}{\frac{\mathsf{neg}\left(t1\right)}{u + t1} \cdot v}}{t1 + u} \]
        11. lift-/.f64N/A

          \[\leadsto \frac{\color{blue}{\frac{\mathsf{neg}\left(t1\right)}{u + t1}} \cdot v}{t1 + u} \]
        12. lift-neg.f64N/A

          \[\leadsto \frac{\frac{\color{blue}{-t1}}{u + t1} \cdot v}{t1 + u} \]
        13. lift-+.f64N/A

          \[\leadsto \frac{\frac{-t1}{\color{blue}{u + t1}} \cdot v}{t1 + u} \]
        14. +-commutativeN/A

          \[\leadsto \frac{\frac{-t1}{u + t1} \cdot v}{\color{blue}{u + t1}} \]
        15. lift-+.f6498.2

          \[\leadsto \frac{\frac{-t1}{u + t1} \cdot v}{\color{blue}{u + t1}} \]
      5. Applied rewrites98.2%

        \[\leadsto \color{blue}{\frac{\frac{-t1}{u + t1} \cdot v}{u + t1}} \]
      6. Taylor expanded in u around 0

        \[\leadsto \frac{\color{blue}{-1 \cdot v}}{u + t1} \]
      7. Step-by-step derivation
        1. mul-1-negN/A

          \[\leadsto \frac{\mathsf{neg}\left(v\right)}{u + t1} \]
        2. lower-neg.f6462.0

          \[\leadsto \frac{-v}{u + t1} \]
      8. Applied rewrites62.0%

        \[\leadsto \frac{\color{blue}{-v}}{u + t1} \]
      9. Add Preprocessing

      Alternative 15: 54.6% accurate, 2.1× speedup?

      \[\begin{array}{l} \\ \frac{-v}{t1} \end{array} \]
      (FPCore (u v t1) :precision binary64 (/ (- v) t1))
      double code(double u, double v, double t1) {
      	return -v / t1;
      }
      
      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(u, v, t1)
      use fmin_fmax_functions
          real(8), intent (in) :: u
          real(8), intent (in) :: v
          real(8), intent (in) :: t1
          code = -v / t1
      end function
      
      public static double code(double u, double v, double t1) {
      	return -v / t1;
      }
      
      def code(u, v, t1):
      	return -v / t1
      
      function code(u, v, t1)
      	return Float64(Float64(-v) / t1)
      end
      
      function tmp = code(u, v, t1)
      	tmp = -v / t1;
      end
      
      code[u_, v_, t1_] := N[((-v) / t1), $MachinePrecision]
      
      \begin{array}{l}
      
      \\
      \frac{-v}{t1}
      \end{array}
      
      Derivation
      1. Initial program 71.9%

        \[\frac{\left(-t1\right) \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
      2. Taylor expanded in u around 0

        \[\leadsto \color{blue}{-1 \cdot \frac{v}{t1}} \]
      3. Step-by-step derivation
        1. associate-*r/N/A

          \[\leadsto \frac{-1 \cdot v}{\color{blue}{t1}} \]
        2. lower-/.f64N/A

          \[\leadsto \frac{-1 \cdot v}{\color{blue}{t1}} \]
        3. mul-1-negN/A

          \[\leadsto \frac{\mathsf{neg}\left(v\right)}{t1} \]
        4. lower-neg.f6454.6

          \[\leadsto \frac{-v}{t1} \]
      4. Applied rewrites54.6%

        \[\leadsto \color{blue}{\frac{-v}{t1}} \]
      5. Add Preprocessing

      Reproduce

      ?
      herbie shell --seed 2025099 
      (FPCore (u v t1)
        :name "Rosa's DopplerBench"
        :precision binary64
        (/ (* (- t1) v) (* (+ t1 u) (+ t1 u))))