Rosa's DopplerBench

Percentage Accurate: 72.2% → 97.5%
Time: 3.3s
Alternatives: 9
Speedup: 0.9×

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 9 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: 72.2% 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: 97.5% accurate, 0.5× speedup?

\[\begin{array}{l} v\_m = \left|v\right| \\ v\_s = \mathsf{copysign}\left(1, v\right) \\ v\_s \cdot \begin{array}{l} \mathbf{if}\;\frac{\left(-t1\right) \cdot v\_m}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \leq -5 \cdot 10^{-286}:\\ \;\;\;\;\frac{\frac{v\_m \cdot \left(-t1\right)}{u + t1}}{u + t1}\\ \mathbf{else}:\\ \;\;\;\;\frac{-t1}{u + t1} \cdot \frac{v\_m}{u + t1}\\ \end{array} \end{array} \]
v\_m = (fabs.f64 v)
v\_s = (copysign.f64 #s(literal 1 binary64) v)
(FPCore (v_s u v_m t1)
 :precision binary64
 (*
  v_s
  (if (<= (/ (* (- t1) v_m) (* (+ t1 u) (+ t1 u))) -5e-286)
    (/ (/ (* v_m (- t1)) (+ u t1)) (+ u t1))
    (* (/ (- t1) (+ u t1)) (/ v_m (+ u t1))))))
v\_m = fabs(v);
v\_s = copysign(1.0, v);
double code(double v_s, double u, double v_m, double t1) {
	double tmp;
	if (((-t1 * v_m) / ((t1 + u) * (t1 + u))) <= -5e-286) {
		tmp = ((v_m * -t1) / (u + t1)) / (u + t1);
	} else {
		tmp = (-t1 / (u + t1)) * (v_m / (u + t1));
	}
	return v_s * tmp;
}
v\_m =     private
v\_s =     private
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(v_s, u, v_m, t1)
use fmin_fmax_functions
    real(8), intent (in) :: v_s
    real(8), intent (in) :: u
    real(8), intent (in) :: v_m
    real(8), intent (in) :: t1
    real(8) :: tmp
    if (((-t1 * v_m) / ((t1 + u) * (t1 + u))) <= (-5d-286)) then
        tmp = ((v_m * -t1) / (u + t1)) / (u + t1)
    else
        tmp = (-t1 / (u + t1)) * (v_m / (u + t1))
    end if
    code = v_s * tmp
end function
v\_m = Math.abs(v);
v\_s = Math.copySign(1.0, v);
public static double code(double v_s, double u, double v_m, double t1) {
	double tmp;
	if (((-t1 * v_m) / ((t1 + u) * (t1 + u))) <= -5e-286) {
		tmp = ((v_m * -t1) / (u + t1)) / (u + t1);
	} else {
		tmp = (-t1 / (u + t1)) * (v_m / (u + t1));
	}
	return v_s * tmp;
}
v\_m = math.fabs(v)
v\_s = math.copysign(1.0, v)
def code(v_s, u, v_m, t1):
	tmp = 0
	if ((-t1 * v_m) / ((t1 + u) * (t1 + u))) <= -5e-286:
		tmp = ((v_m * -t1) / (u + t1)) / (u + t1)
	else:
		tmp = (-t1 / (u + t1)) * (v_m / (u + t1))
	return v_s * tmp
v\_m = abs(v)
v\_s = copysign(1.0, v)
function code(v_s, u, v_m, t1)
	tmp = 0.0
	if (Float64(Float64(Float64(-t1) * v_m) / Float64(Float64(t1 + u) * Float64(t1 + u))) <= -5e-286)
		tmp = Float64(Float64(Float64(v_m * Float64(-t1)) / Float64(u + t1)) / Float64(u + t1));
	else
		tmp = Float64(Float64(Float64(-t1) / Float64(u + t1)) * Float64(v_m / Float64(u + t1)));
	end
	return Float64(v_s * tmp)
end
v\_m = abs(v);
v\_s = sign(v) * abs(1.0);
function tmp_2 = code(v_s, u, v_m, t1)
	tmp = 0.0;
	if (((-t1 * v_m) / ((t1 + u) * (t1 + u))) <= -5e-286)
		tmp = ((v_m * -t1) / (u + t1)) / (u + t1);
	else
		tmp = (-t1 / (u + t1)) * (v_m / (u + t1));
	end
	tmp_2 = v_s * tmp;
end
v\_m = N[Abs[v], $MachinePrecision]
v\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[v]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[v$95$s_, u_, v$95$m_, t1_] := N[(v$95$s * If[LessEqual[N[(N[((-t1) * v$95$m), $MachinePrecision] / N[(N[(t1 + u), $MachinePrecision] * N[(t1 + u), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -5e-286], N[(N[(N[(v$95$m * (-t1)), $MachinePrecision] / N[(u + t1), $MachinePrecision]), $MachinePrecision] / N[(u + t1), $MachinePrecision]), $MachinePrecision], N[(N[((-t1) / N[(u + t1), $MachinePrecision]), $MachinePrecision] * N[(v$95$m / N[(u + t1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
v\_m = \left|v\right|
\\
v\_s = \mathsf{copysign}\left(1, v\right)

\\
v\_s \cdot \begin{array}{l}
\mathbf{if}\;\frac{\left(-t1\right) \cdot v\_m}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \leq -5 \cdot 10^{-286}:\\
\;\;\;\;\frac{\frac{v\_m \cdot \left(-t1\right)}{u + t1}}{u + t1}\\

\mathbf{else}:\\
\;\;\;\;\frac{-t1}{u + t1} \cdot \frac{v\_m}{u + t1}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (*.f64 (neg.f64 t1) v) (*.f64 (+.f64 t1 u) (+.f64 t1 u))) < -5.00000000000000037e-286

    1. Initial program 72.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-*.f64N/A

        \[\leadsto \frac{\color{blue}{\left(-t1\right) \cdot v}}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
      3. 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)} \]
      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}{\color{blue}{\left(t1 + u\right)} \cdot \left(t1 + u\right)} \]
      6. 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)}} \]
      7. distribute-lft-neg-outN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.00000000000000037e-286 < (/.f64 (*.f64 (neg.f64 t1) v) (*.f64 (+.f64 t1 u) (+.f64 t1 u)))

    1. Initial program 72.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-*.f64N/A

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{-t1}{u + t1} \cdot \frac{v}{\color{blue}{u + t1}} \]
      13. lower-+.f6498.0

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

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

Alternative 2: 96.4% accurate, 0.5× speedup?

\[\begin{array}{l} v\_m = \left|v\right| \\ v\_s = \mathsf{copysign}\left(1, v\right) \\ \begin{array}{l} t_1 := \frac{\left(-t1\right) \cdot v\_m}{\left(t1 + u\right) \cdot \left(t1 + u\right)}\\ v\_s \cdot \begin{array}{l} \mathbf{if}\;t\_1 \leq -5 \cdot 10^{-286}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;\frac{-t1}{u + t1} \cdot \frac{v\_m}{u + t1}\\ \end{array} \end{array} \end{array} \]
v\_m = (fabs.f64 v)
v\_s = (copysign.f64 #s(literal 1 binary64) v)
(FPCore (v_s u v_m t1)
 :precision binary64
 (let* ((t_1 (/ (* (- t1) v_m) (* (+ t1 u) (+ t1 u)))))
   (* v_s (if (<= t_1 -5e-286) t_1 (* (/ (- t1) (+ u t1)) (/ v_m (+ u t1)))))))
v\_m = fabs(v);
v\_s = copysign(1.0, v);
double code(double v_s, double u, double v_m, double t1) {
	double t_1 = (-t1 * v_m) / ((t1 + u) * (t1 + u));
	double tmp;
	if (t_1 <= -5e-286) {
		tmp = t_1;
	} else {
		tmp = (-t1 / (u + t1)) * (v_m / (u + t1));
	}
	return v_s * tmp;
}
v\_m =     private
v\_s =     private
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(v_s, u, v_m, t1)
use fmin_fmax_functions
    real(8), intent (in) :: v_s
    real(8), intent (in) :: u
    real(8), intent (in) :: v_m
    real(8), intent (in) :: t1
    real(8) :: t_1
    real(8) :: tmp
    t_1 = (-t1 * v_m) / ((t1 + u) * (t1 + u))
    if (t_1 <= (-5d-286)) then
        tmp = t_1
    else
        tmp = (-t1 / (u + t1)) * (v_m / (u + t1))
    end if
    code = v_s * tmp
end function
v\_m = Math.abs(v);
v\_s = Math.copySign(1.0, v);
public static double code(double v_s, double u, double v_m, double t1) {
	double t_1 = (-t1 * v_m) / ((t1 + u) * (t1 + u));
	double tmp;
	if (t_1 <= -5e-286) {
		tmp = t_1;
	} else {
		tmp = (-t1 / (u + t1)) * (v_m / (u + t1));
	}
	return v_s * tmp;
}
v\_m = math.fabs(v)
v\_s = math.copysign(1.0, v)
def code(v_s, u, v_m, t1):
	t_1 = (-t1 * v_m) / ((t1 + u) * (t1 + u))
	tmp = 0
	if t_1 <= -5e-286:
		tmp = t_1
	else:
		tmp = (-t1 / (u + t1)) * (v_m / (u + t1))
	return v_s * tmp
v\_m = abs(v)
v\_s = copysign(1.0, v)
function code(v_s, u, v_m, t1)
	t_1 = Float64(Float64(Float64(-t1) * v_m) / Float64(Float64(t1 + u) * Float64(t1 + u)))
	tmp = 0.0
	if (t_1 <= -5e-286)
		tmp = t_1;
	else
		tmp = Float64(Float64(Float64(-t1) / Float64(u + t1)) * Float64(v_m / Float64(u + t1)));
	end
	return Float64(v_s * tmp)
end
v\_m = abs(v);
v\_s = sign(v) * abs(1.0);
function tmp_2 = code(v_s, u, v_m, t1)
	t_1 = (-t1 * v_m) / ((t1 + u) * (t1 + u));
	tmp = 0.0;
	if (t_1 <= -5e-286)
		tmp = t_1;
	else
		tmp = (-t1 / (u + t1)) * (v_m / (u + t1));
	end
	tmp_2 = v_s * tmp;
end
v\_m = N[Abs[v], $MachinePrecision]
v\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[v]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[v$95$s_, u_, v$95$m_, t1_] := Block[{t$95$1 = N[(N[((-t1) * v$95$m), $MachinePrecision] / N[(N[(t1 + u), $MachinePrecision] * N[(t1 + u), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(v$95$s * If[LessEqual[t$95$1, -5e-286], t$95$1, N[(N[((-t1) / N[(u + t1), $MachinePrecision]), $MachinePrecision] * N[(v$95$m / N[(u + t1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
v\_m = \left|v\right|
\\
v\_s = \mathsf{copysign}\left(1, v\right)

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

\mathbf{else}:\\
\;\;\;\;\frac{-t1}{u + t1} \cdot \frac{v\_m}{u + t1}\\


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (*.f64 (neg.f64 t1) v) (*.f64 (+.f64 t1 u) (+.f64 t1 u))) < -5.00000000000000037e-286

    1. Initial program 72.2%

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

    if -5.00000000000000037e-286 < (/.f64 (*.f64 (neg.f64 t1) v) (*.f64 (+.f64 t1 u) (+.f64 t1 u)))

    1. Initial program 72.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-*.f64N/A

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{-t1}{u + t1} \cdot \frac{v}{\color{blue}{u + t1}} \]
      13. lower-+.f6498.0

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

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

Alternative 3: 85.5% accurate, 0.7× speedup?

\[\begin{array}{l} v\_m = \left|v\right| \\ v\_s = \mathsf{copysign}\left(1, v\right) \\ \begin{array}{l} t_1 := \frac{u}{t1} - 1\\ v\_s \cdot \begin{array}{l} \mathbf{if}\;t1 \leq -1.95 \cdot 10^{+65}:\\ \;\;\;\;t\_1 \cdot \frac{v\_m}{u + t1}\\ \mathbf{elif}\;t1 \leq 2.6 \cdot 10^{+150}:\\ \;\;\;\;\frac{\left(-t1\right) \cdot v\_m}{\left(t1 + u\right) \cdot \left(t1 + u\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{t\_1 \cdot v\_m}{u + t1}\\ \end{array} \end{array} \end{array} \]
v\_m = (fabs.f64 v)
v\_s = (copysign.f64 #s(literal 1 binary64) v)
(FPCore (v_s u v_m t1)
 :precision binary64
 (let* ((t_1 (- (/ u t1) 1.0)))
   (*
    v_s
    (if (<= t1 -1.95e+65)
      (* t_1 (/ v_m (+ u t1)))
      (if (<= t1 2.6e+150)
        (/ (* (- t1) v_m) (* (+ t1 u) (+ t1 u)))
        (/ (* t_1 v_m) (+ u t1)))))))
v\_m = fabs(v);
v\_s = copysign(1.0, v);
double code(double v_s, double u, double v_m, double t1) {
	double t_1 = (u / t1) - 1.0;
	double tmp;
	if (t1 <= -1.95e+65) {
		tmp = t_1 * (v_m / (u + t1));
	} else if (t1 <= 2.6e+150) {
		tmp = (-t1 * v_m) / ((t1 + u) * (t1 + u));
	} else {
		tmp = (t_1 * v_m) / (u + t1);
	}
	return v_s * tmp;
}
v\_m =     private
v\_s =     private
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(v_s, u, v_m, t1)
use fmin_fmax_functions
    real(8), intent (in) :: v_s
    real(8), intent (in) :: u
    real(8), intent (in) :: v_m
    real(8), intent (in) :: t1
    real(8) :: t_1
    real(8) :: tmp
    t_1 = (u / t1) - 1.0d0
    if (t1 <= (-1.95d+65)) then
        tmp = t_1 * (v_m / (u + t1))
    else if (t1 <= 2.6d+150) then
        tmp = (-t1 * v_m) / ((t1 + u) * (t1 + u))
    else
        tmp = (t_1 * v_m) / (u + t1)
    end if
    code = v_s * tmp
end function
v\_m = Math.abs(v);
v\_s = Math.copySign(1.0, v);
public static double code(double v_s, double u, double v_m, double t1) {
	double t_1 = (u / t1) - 1.0;
	double tmp;
	if (t1 <= -1.95e+65) {
		tmp = t_1 * (v_m / (u + t1));
	} else if (t1 <= 2.6e+150) {
		tmp = (-t1 * v_m) / ((t1 + u) * (t1 + u));
	} else {
		tmp = (t_1 * v_m) / (u + t1);
	}
	return v_s * tmp;
}
v\_m = math.fabs(v)
v\_s = math.copysign(1.0, v)
def code(v_s, u, v_m, t1):
	t_1 = (u / t1) - 1.0
	tmp = 0
	if t1 <= -1.95e+65:
		tmp = t_1 * (v_m / (u + t1))
	elif t1 <= 2.6e+150:
		tmp = (-t1 * v_m) / ((t1 + u) * (t1 + u))
	else:
		tmp = (t_1 * v_m) / (u + t1)
	return v_s * tmp
v\_m = abs(v)
v\_s = copysign(1.0, v)
function code(v_s, u, v_m, t1)
	t_1 = Float64(Float64(u / t1) - 1.0)
	tmp = 0.0
	if (t1 <= -1.95e+65)
		tmp = Float64(t_1 * Float64(v_m / Float64(u + t1)));
	elseif (t1 <= 2.6e+150)
		tmp = Float64(Float64(Float64(-t1) * v_m) / Float64(Float64(t1 + u) * Float64(t1 + u)));
	else
		tmp = Float64(Float64(t_1 * v_m) / Float64(u + t1));
	end
	return Float64(v_s * tmp)
end
v\_m = abs(v);
v\_s = sign(v) * abs(1.0);
function tmp_2 = code(v_s, u, v_m, t1)
	t_1 = (u / t1) - 1.0;
	tmp = 0.0;
	if (t1 <= -1.95e+65)
		tmp = t_1 * (v_m / (u + t1));
	elseif (t1 <= 2.6e+150)
		tmp = (-t1 * v_m) / ((t1 + u) * (t1 + u));
	else
		tmp = (t_1 * v_m) / (u + t1);
	end
	tmp_2 = v_s * tmp;
end
v\_m = N[Abs[v], $MachinePrecision]
v\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[v]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[v$95$s_, u_, v$95$m_, t1_] := Block[{t$95$1 = N[(N[(u / t1), $MachinePrecision] - 1.0), $MachinePrecision]}, N[(v$95$s * If[LessEqual[t1, -1.95e+65], N[(t$95$1 * N[(v$95$m / N[(u + t1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t1, 2.6e+150], N[(N[((-t1) * v$95$m), $MachinePrecision] / N[(N[(t1 + u), $MachinePrecision] * N[(t1 + u), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$1 * v$95$m), $MachinePrecision] / N[(u + t1), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]]
\begin{array}{l}
v\_m = \left|v\right|
\\
v\_s = \mathsf{copysign}\left(1, v\right)

\\
\begin{array}{l}
t_1 := \frac{u}{t1} - 1\\
v\_s \cdot \begin{array}{l}
\mathbf{if}\;t1 \leq -1.95 \cdot 10^{+65}:\\
\;\;\;\;t\_1 \cdot \frac{v\_m}{u + t1}\\

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

\mathbf{else}:\\
\;\;\;\;\frac{t\_1 \cdot v\_m}{u + t1}\\


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

    1. Initial program 72.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-*.f64N/A

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{-t1}{u + t1} \cdot \frac{v}{\color{blue}{u + t1}} \]
      13. lower-+.f6498.0

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

      \[\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-/.f6456.5

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

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

    if -1.9499999999999999e65 < t1 < 2.60000000000000006e150

    1. Initial program 72.2%

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

    if 2.60000000000000006e150 < t1

    1. Initial program 72.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-*.f64N/A

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{-t1}{u + t1} \cdot \frac{v}{\color{blue}{u + t1}} \]
      13. lower-+.f6498.0

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

      \[\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-/.f6456.5

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(\frac{u}{t1} - 1\right) \cdot v}{\color{blue}{u + t1}} \]
    8. Applied rewrites53.4%

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

Alternative 4: 85.2% accurate, 0.7× speedup?

\[\begin{array}{l} v\_m = \left|v\right| \\ v\_s = \mathsf{copysign}\left(1, v\right) \\ \begin{array}{l} t_1 := \left(\frac{u}{t1} - 1\right) \cdot \frac{v\_m}{u + t1}\\ v\_s \cdot \begin{array}{l} \mathbf{if}\;t1 \leq -1.05 \cdot 10^{+71}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t1 \leq 1.26 \cdot 10^{+79}:\\ \;\;\;\;\left(-t1\right) \cdot \frac{v\_m}{\left(u + t1\right) \cdot \left(u + t1\right)}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \end{array} \]
v\_m = (fabs.f64 v)
v\_s = (copysign.f64 #s(literal 1 binary64) v)
(FPCore (v_s u v_m t1)
 :precision binary64
 (let* ((t_1 (* (- (/ u t1) 1.0) (/ v_m (+ u t1)))))
   (*
    v_s
    (if (<= t1 -1.05e+71)
      t_1
      (if (<= t1 1.26e+79) (* (- t1) (/ v_m (* (+ u t1) (+ u t1)))) t_1)))))
v\_m = fabs(v);
v\_s = copysign(1.0, v);
double code(double v_s, double u, double v_m, double t1) {
	double t_1 = ((u / t1) - 1.0) * (v_m / (u + t1));
	double tmp;
	if (t1 <= -1.05e+71) {
		tmp = t_1;
	} else if (t1 <= 1.26e+79) {
		tmp = -t1 * (v_m / ((u + t1) * (u + t1)));
	} else {
		tmp = t_1;
	}
	return v_s * tmp;
}
v\_m =     private
v\_s =     private
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(v_s, u, v_m, t1)
use fmin_fmax_functions
    real(8), intent (in) :: v_s
    real(8), intent (in) :: u
    real(8), intent (in) :: v_m
    real(8), intent (in) :: t1
    real(8) :: t_1
    real(8) :: tmp
    t_1 = ((u / t1) - 1.0d0) * (v_m / (u + t1))
    if (t1 <= (-1.05d+71)) then
        tmp = t_1
    else if (t1 <= 1.26d+79) then
        tmp = -t1 * (v_m / ((u + t1) * (u + t1)))
    else
        tmp = t_1
    end if
    code = v_s * tmp
end function
v\_m = Math.abs(v);
v\_s = Math.copySign(1.0, v);
public static double code(double v_s, double u, double v_m, double t1) {
	double t_1 = ((u / t1) - 1.0) * (v_m / (u + t1));
	double tmp;
	if (t1 <= -1.05e+71) {
		tmp = t_1;
	} else if (t1 <= 1.26e+79) {
		tmp = -t1 * (v_m / ((u + t1) * (u + t1)));
	} else {
		tmp = t_1;
	}
	return v_s * tmp;
}
v\_m = math.fabs(v)
v\_s = math.copysign(1.0, v)
def code(v_s, u, v_m, t1):
	t_1 = ((u / t1) - 1.0) * (v_m / (u + t1))
	tmp = 0
	if t1 <= -1.05e+71:
		tmp = t_1
	elif t1 <= 1.26e+79:
		tmp = -t1 * (v_m / ((u + t1) * (u + t1)))
	else:
		tmp = t_1
	return v_s * tmp
v\_m = abs(v)
v\_s = copysign(1.0, v)
function code(v_s, u, v_m, t1)
	t_1 = Float64(Float64(Float64(u / t1) - 1.0) * Float64(v_m / Float64(u + t1)))
	tmp = 0.0
	if (t1 <= -1.05e+71)
		tmp = t_1;
	elseif (t1 <= 1.26e+79)
		tmp = Float64(Float64(-t1) * Float64(v_m / Float64(Float64(u + t1) * Float64(u + t1))));
	else
		tmp = t_1;
	end
	return Float64(v_s * tmp)
end
v\_m = abs(v);
v\_s = sign(v) * abs(1.0);
function tmp_2 = code(v_s, u, v_m, t1)
	t_1 = ((u / t1) - 1.0) * (v_m / (u + t1));
	tmp = 0.0;
	if (t1 <= -1.05e+71)
		tmp = t_1;
	elseif (t1 <= 1.26e+79)
		tmp = -t1 * (v_m / ((u + t1) * (u + t1)));
	else
		tmp = t_1;
	end
	tmp_2 = v_s * tmp;
end
v\_m = N[Abs[v], $MachinePrecision]
v\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[v]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[v$95$s_, u_, v$95$m_, t1_] := Block[{t$95$1 = N[(N[(N[(u / t1), $MachinePrecision] - 1.0), $MachinePrecision] * N[(v$95$m / N[(u + t1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(v$95$s * If[LessEqual[t1, -1.05e+71], t$95$1, If[LessEqual[t1, 1.26e+79], N[((-t1) * N[(v$95$m / N[(N[(u + t1), $MachinePrecision] * N[(u + t1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]), $MachinePrecision]]
\begin{array}{l}
v\_m = \left|v\right|
\\
v\_s = \mathsf{copysign}\left(1, v\right)

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

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

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


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t1 < -1.04999999999999995e71 or 1.26e79 < t1

    1. Initial program 72.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-*.f64N/A

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{-t1}{u + t1} \cdot \frac{v}{\color{blue}{u + t1}} \]
      13. lower-+.f6498.0

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

      \[\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-/.f6456.5

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

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

    if -1.04999999999999995e71 < t1 < 1.26e79

    1. Initial program 72.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-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 78.2% accurate, 0.8× speedup?

\[\begin{array}{l} v\_m = \left|v\right| \\ v\_s = \mathsf{copysign}\left(1, v\right) \\ \begin{array}{l} t_1 := \frac{-v\_m}{u + t1}\\ v\_s \cdot \begin{array}{l} \mathbf{if}\;t1 \leq -1.95 \cdot 10^{-91}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t1 \leq 5.5 \cdot 10^{-14}:\\ \;\;\;\;\left(t1 \cdot \frac{v\_m}{u}\right) \cdot \frac{-1}{u}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \end{array} \]
v\_m = (fabs.f64 v)
v\_s = (copysign.f64 #s(literal 1 binary64) v)
(FPCore (v_s u v_m t1)
 :precision binary64
 (let* ((t_1 (/ (- v_m) (+ u t1))))
   (*
    v_s
    (if (<= t1 -1.95e-91)
      t_1
      (if (<= t1 5.5e-14) (* (* t1 (/ v_m u)) (/ -1.0 u)) t_1)))))
v\_m = fabs(v);
v\_s = copysign(1.0, v);
double code(double v_s, double u, double v_m, double t1) {
	double t_1 = -v_m / (u + t1);
	double tmp;
	if (t1 <= -1.95e-91) {
		tmp = t_1;
	} else if (t1 <= 5.5e-14) {
		tmp = (t1 * (v_m / u)) * (-1.0 / u);
	} else {
		tmp = t_1;
	}
	return v_s * tmp;
}
v\_m =     private
v\_s =     private
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(v_s, u, v_m, t1)
use fmin_fmax_functions
    real(8), intent (in) :: v_s
    real(8), intent (in) :: u
    real(8), intent (in) :: v_m
    real(8), intent (in) :: t1
    real(8) :: t_1
    real(8) :: tmp
    t_1 = -v_m / (u + t1)
    if (t1 <= (-1.95d-91)) then
        tmp = t_1
    else if (t1 <= 5.5d-14) then
        tmp = (t1 * (v_m / u)) * ((-1.0d0) / u)
    else
        tmp = t_1
    end if
    code = v_s * tmp
end function
v\_m = Math.abs(v);
v\_s = Math.copySign(1.0, v);
public static double code(double v_s, double u, double v_m, double t1) {
	double t_1 = -v_m / (u + t1);
	double tmp;
	if (t1 <= -1.95e-91) {
		tmp = t_1;
	} else if (t1 <= 5.5e-14) {
		tmp = (t1 * (v_m / u)) * (-1.0 / u);
	} else {
		tmp = t_1;
	}
	return v_s * tmp;
}
v\_m = math.fabs(v)
v\_s = math.copysign(1.0, v)
def code(v_s, u, v_m, t1):
	t_1 = -v_m / (u + t1)
	tmp = 0
	if t1 <= -1.95e-91:
		tmp = t_1
	elif t1 <= 5.5e-14:
		tmp = (t1 * (v_m / u)) * (-1.0 / u)
	else:
		tmp = t_1
	return v_s * tmp
v\_m = abs(v)
v\_s = copysign(1.0, v)
function code(v_s, u, v_m, t1)
	t_1 = Float64(Float64(-v_m) / Float64(u + t1))
	tmp = 0.0
	if (t1 <= -1.95e-91)
		tmp = t_1;
	elseif (t1 <= 5.5e-14)
		tmp = Float64(Float64(t1 * Float64(v_m / u)) * Float64(-1.0 / u));
	else
		tmp = t_1;
	end
	return Float64(v_s * tmp)
end
v\_m = abs(v);
v\_s = sign(v) * abs(1.0);
function tmp_2 = code(v_s, u, v_m, t1)
	t_1 = -v_m / (u + t1);
	tmp = 0.0;
	if (t1 <= -1.95e-91)
		tmp = t_1;
	elseif (t1 <= 5.5e-14)
		tmp = (t1 * (v_m / u)) * (-1.0 / u);
	else
		tmp = t_1;
	end
	tmp_2 = v_s * tmp;
end
v\_m = N[Abs[v], $MachinePrecision]
v\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[v]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[v$95$s_, u_, v$95$m_, t1_] := Block[{t$95$1 = N[((-v$95$m) / N[(u + t1), $MachinePrecision]), $MachinePrecision]}, N[(v$95$s * If[LessEqual[t1, -1.95e-91], t$95$1, If[LessEqual[t1, 5.5e-14], N[(N[(t1 * N[(v$95$m / u), $MachinePrecision]), $MachinePrecision] * N[(-1.0 / u), $MachinePrecision]), $MachinePrecision], t$95$1]]), $MachinePrecision]]
\begin{array}{l}
v\_m = \left|v\right|
\\
v\_s = \mathsf{copysign}\left(1, v\right)

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

\mathbf{elif}\;t1 \leq 5.5 \cdot 10^{-14}:\\
\;\;\;\;\left(t1 \cdot \frac{v\_m}{u}\right) \cdot \frac{-1}{u}\\

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


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t1 < -1.94999999999999997e-91 or 5.49999999999999991e-14 < t1

    1. Initial program 72.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-*.f64N/A

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{-t1}{u + t1} \cdot \frac{v}{\color{blue}{u + t1}} \]
      13. lower-+.f6498.0

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

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

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

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

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

        \[\leadsto \frac{-t1}{u + t1} \cdot \color{blue}{\frac{v}{u + t1}} \]
      6. associate-*l/N/A

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\left(-t1\right) \cdot \frac{v}{u + t1}}{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} \]

    if -1.94999999999999997e-91 < t1 < 5.49999999999999991e-14

    1. Initial program 72.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-*.f64N/A

        \[\leadsto \frac{\color{blue}{\left(-t1\right) \cdot v}}{\left(t1 + u\right) \cdot \left(t1 + u\right)} \]
      3. 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)} \]
      4. distribute-lft-neg-outN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{v \cdot t1}{u + t1} \cdot \frac{-1}{\color{blue}{u + t1}} \]
      19. lower-+.f6483.0

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

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

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

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

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

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

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

      \[\leadsto \left(t1 \cdot \frac{v}{u}\right) \cdot \color{blue}{\frac{-1}{u}} \]
    8. Step-by-step derivation
      1. lower-/.f6452.3

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

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

Alternative 6: 75.8% accurate, 0.9× speedup?

\[\begin{array}{l} v\_m = \left|v\right| \\ v\_s = \mathsf{copysign}\left(1, v\right) \\ \begin{array}{l} t_1 := \frac{-v\_m}{u + t1}\\ v\_s \cdot \begin{array}{l} \mathbf{if}\;t1 \leq -1.95 \cdot 10^{-91}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t1 \leq 5.5 \cdot 10^{-14}:\\ \;\;\;\;\frac{\left(-t1\right) \cdot v\_m}{u \cdot u}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \end{array} \]
v\_m = (fabs.f64 v)
v\_s = (copysign.f64 #s(literal 1 binary64) v)
(FPCore (v_s u v_m t1)
 :precision binary64
 (let* ((t_1 (/ (- v_m) (+ u t1))))
   (*
    v_s
    (if (<= t1 -1.95e-91)
      t_1
      (if (<= t1 5.5e-14) (/ (* (- t1) v_m) (* u u)) t_1)))))
v\_m = fabs(v);
v\_s = copysign(1.0, v);
double code(double v_s, double u, double v_m, double t1) {
	double t_1 = -v_m / (u + t1);
	double tmp;
	if (t1 <= -1.95e-91) {
		tmp = t_1;
	} else if (t1 <= 5.5e-14) {
		tmp = (-t1 * v_m) / (u * u);
	} else {
		tmp = t_1;
	}
	return v_s * tmp;
}
v\_m =     private
v\_s =     private
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(v_s, u, v_m, t1)
use fmin_fmax_functions
    real(8), intent (in) :: v_s
    real(8), intent (in) :: u
    real(8), intent (in) :: v_m
    real(8), intent (in) :: t1
    real(8) :: t_1
    real(8) :: tmp
    t_1 = -v_m / (u + t1)
    if (t1 <= (-1.95d-91)) then
        tmp = t_1
    else if (t1 <= 5.5d-14) then
        tmp = (-t1 * v_m) / (u * u)
    else
        tmp = t_1
    end if
    code = v_s * tmp
end function
v\_m = Math.abs(v);
v\_s = Math.copySign(1.0, v);
public static double code(double v_s, double u, double v_m, double t1) {
	double t_1 = -v_m / (u + t1);
	double tmp;
	if (t1 <= -1.95e-91) {
		tmp = t_1;
	} else if (t1 <= 5.5e-14) {
		tmp = (-t1 * v_m) / (u * u);
	} else {
		tmp = t_1;
	}
	return v_s * tmp;
}
v\_m = math.fabs(v)
v\_s = math.copysign(1.0, v)
def code(v_s, u, v_m, t1):
	t_1 = -v_m / (u + t1)
	tmp = 0
	if t1 <= -1.95e-91:
		tmp = t_1
	elif t1 <= 5.5e-14:
		tmp = (-t1 * v_m) / (u * u)
	else:
		tmp = t_1
	return v_s * tmp
v\_m = abs(v)
v\_s = copysign(1.0, v)
function code(v_s, u, v_m, t1)
	t_1 = Float64(Float64(-v_m) / Float64(u + t1))
	tmp = 0.0
	if (t1 <= -1.95e-91)
		tmp = t_1;
	elseif (t1 <= 5.5e-14)
		tmp = Float64(Float64(Float64(-t1) * v_m) / Float64(u * u));
	else
		tmp = t_1;
	end
	return Float64(v_s * tmp)
end
v\_m = abs(v);
v\_s = sign(v) * abs(1.0);
function tmp_2 = code(v_s, u, v_m, t1)
	t_1 = -v_m / (u + t1);
	tmp = 0.0;
	if (t1 <= -1.95e-91)
		tmp = t_1;
	elseif (t1 <= 5.5e-14)
		tmp = (-t1 * v_m) / (u * u);
	else
		tmp = t_1;
	end
	tmp_2 = v_s * tmp;
end
v\_m = N[Abs[v], $MachinePrecision]
v\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[v]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[v$95$s_, u_, v$95$m_, t1_] := Block[{t$95$1 = N[((-v$95$m) / N[(u + t1), $MachinePrecision]), $MachinePrecision]}, N[(v$95$s * If[LessEqual[t1, -1.95e-91], t$95$1, If[LessEqual[t1, 5.5e-14], N[(N[((-t1) * v$95$m), $MachinePrecision] / N[(u * u), $MachinePrecision]), $MachinePrecision], t$95$1]]), $MachinePrecision]]
\begin{array}{l}
v\_m = \left|v\right|
\\
v\_s = \mathsf{copysign}\left(1, v\right)

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

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

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


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t1 < -1.94999999999999997e-91 or 5.49999999999999991e-14 < t1

    1. Initial program 72.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-*.f64N/A

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{-t1}{u + t1} \cdot \frac{v}{\color{blue}{u + t1}} \]
      13. lower-+.f6498.0

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

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

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

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

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

        \[\leadsto \frac{-t1}{u + t1} \cdot \color{blue}{\frac{v}{u + t1}} \]
      6. associate-*l/N/A

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\left(-t1\right) \cdot \frac{v}{u + t1}}{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} \]

    if -1.94999999999999997e-91 < t1 < 5.49999999999999991e-14

    1. Initial program 72.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-*.f6444.8

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

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

Alternative 7: 75.6% accurate, 0.9× speedup?

\[\begin{array}{l} v\_m = \left|v\right| \\ v\_s = \mathsf{copysign}\left(1, v\right) \\ \begin{array}{l} t_1 := \frac{-v\_m}{u + t1}\\ v\_s \cdot \begin{array}{l} \mathbf{if}\;t1 \leq -1.95 \cdot 10^{-91}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t1 \leq 5.5 \cdot 10^{-14}:\\ \;\;\;\;\left(-t1\right) \cdot \frac{v\_m}{u \cdot u}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \end{array} \]
v\_m = (fabs.f64 v)
v\_s = (copysign.f64 #s(literal 1 binary64) v)
(FPCore (v_s u v_m t1)
 :precision binary64
 (let* ((t_1 (/ (- v_m) (+ u t1))))
   (*
    v_s
    (if (<= t1 -1.95e-91)
      t_1
      (if (<= t1 5.5e-14) (* (- t1) (/ v_m (* u u))) t_1)))))
v\_m = fabs(v);
v\_s = copysign(1.0, v);
double code(double v_s, double u, double v_m, double t1) {
	double t_1 = -v_m / (u + t1);
	double tmp;
	if (t1 <= -1.95e-91) {
		tmp = t_1;
	} else if (t1 <= 5.5e-14) {
		tmp = -t1 * (v_m / (u * u));
	} else {
		tmp = t_1;
	}
	return v_s * tmp;
}
v\_m =     private
v\_s =     private
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(v_s, u, v_m, t1)
use fmin_fmax_functions
    real(8), intent (in) :: v_s
    real(8), intent (in) :: u
    real(8), intent (in) :: v_m
    real(8), intent (in) :: t1
    real(8) :: t_1
    real(8) :: tmp
    t_1 = -v_m / (u + t1)
    if (t1 <= (-1.95d-91)) then
        tmp = t_1
    else if (t1 <= 5.5d-14) then
        tmp = -t1 * (v_m / (u * u))
    else
        tmp = t_1
    end if
    code = v_s * tmp
end function
v\_m = Math.abs(v);
v\_s = Math.copySign(1.0, v);
public static double code(double v_s, double u, double v_m, double t1) {
	double t_1 = -v_m / (u + t1);
	double tmp;
	if (t1 <= -1.95e-91) {
		tmp = t_1;
	} else if (t1 <= 5.5e-14) {
		tmp = -t1 * (v_m / (u * u));
	} else {
		tmp = t_1;
	}
	return v_s * tmp;
}
v\_m = math.fabs(v)
v\_s = math.copysign(1.0, v)
def code(v_s, u, v_m, t1):
	t_1 = -v_m / (u + t1)
	tmp = 0
	if t1 <= -1.95e-91:
		tmp = t_1
	elif t1 <= 5.5e-14:
		tmp = -t1 * (v_m / (u * u))
	else:
		tmp = t_1
	return v_s * tmp
v\_m = abs(v)
v\_s = copysign(1.0, v)
function code(v_s, u, v_m, t1)
	t_1 = Float64(Float64(-v_m) / Float64(u + t1))
	tmp = 0.0
	if (t1 <= -1.95e-91)
		tmp = t_1;
	elseif (t1 <= 5.5e-14)
		tmp = Float64(Float64(-t1) * Float64(v_m / Float64(u * u)));
	else
		tmp = t_1;
	end
	return Float64(v_s * tmp)
end
v\_m = abs(v);
v\_s = sign(v) * abs(1.0);
function tmp_2 = code(v_s, u, v_m, t1)
	t_1 = -v_m / (u + t1);
	tmp = 0.0;
	if (t1 <= -1.95e-91)
		tmp = t_1;
	elseif (t1 <= 5.5e-14)
		tmp = -t1 * (v_m / (u * u));
	else
		tmp = t_1;
	end
	tmp_2 = v_s * tmp;
end
v\_m = N[Abs[v], $MachinePrecision]
v\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[v]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[v$95$s_, u_, v$95$m_, t1_] := Block[{t$95$1 = N[((-v$95$m) / N[(u + t1), $MachinePrecision]), $MachinePrecision]}, N[(v$95$s * If[LessEqual[t1, -1.95e-91], t$95$1, If[LessEqual[t1, 5.5e-14], N[((-t1) * N[(v$95$m / N[(u * u), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]), $MachinePrecision]]
\begin{array}{l}
v\_m = \left|v\right|
\\
v\_s = \mathsf{copysign}\left(1, v\right)

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

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

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


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t1 < -1.94999999999999997e-91 or 5.49999999999999991e-14 < t1

    1. Initial program 72.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-*.f64N/A

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{-t1}{u + t1} \cdot \frac{v}{\color{blue}{u + t1}} \]
      13. lower-+.f6498.0

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

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

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

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

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

        \[\leadsto \frac{-t1}{u + t1} \cdot \color{blue}{\frac{v}{u + t1}} \]
      6. associate-*l/N/A

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\left(-t1\right) \cdot \frac{v}{u + t1}}{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} \]

    if -1.94999999999999997e-91 < t1 < 5.49999999999999991e-14

    1. Initial program 72.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-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(-t1\right) \cdot \frac{v}{\left(u + t1\right) \cdot \left(u + t1\right)}} \]
    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-*.f6446.1

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

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

Alternative 8: 62.0% accurate, 2.1× speedup?

\[\begin{array}{l} v\_m = \left|v\right| \\ v\_s = \mathsf{copysign}\left(1, v\right) \\ v\_s \cdot \frac{-v\_m}{u + t1} \end{array} \]
v\_m = (fabs.f64 v)
v\_s = (copysign.f64 #s(literal 1 binary64) v)
(FPCore (v_s u v_m t1) :precision binary64 (* v_s (/ (- v_m) (+ u t1))))
v\_m = fabs(v);
v\_s = copysign(1.0, v);
double code(double v_s, double u, double v_m, double t1) {
	return v_s * (-v_m / (u + t1));
}
v\_m =     private
v\_s =     private
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(v_s, u, v_m, t1)
use fmin_fmax_functions
    real(8), intent (in) :: v_s
    real(8), intent (in) :: u
    real(8), intent (in) :: v_m
    real(8), intent (in) :: t1
    code = v_s * (-v_m / (u + t1))
end function
v\_m = Math.abs(v);
v\_s = Math.copySign(1.0, v);
public static double code(double v_s, double u, double v_m, double t1) {
	return v_s * (-v_m / (u + t1));
}
v\_m = math.fabs(v)
v\_s = math.copysign(1.0, v)
def code(v_s, u, v_m, t1):
	return v_s * (-v_m / (u + t1))
v\_m = abs(v)
v\_s = copysign(1.0, v)
function code(v_s, u, v_m, t1)
	return Float64(v_s * Float64(Float64(-v_m) / Float64(u + t1)))
end
v\_m = abs(v);
v\_s = sign(v) * abs(1.0);
function tmp = code(v_s, u, v_m, t1)
	tmp = v_s * (-v_m / (u + t1));
end
v\_m = N[Abs[v], $MachinePrecision]
v\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[v]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[v$95$s_, u_, v$95$m_, t1_] := N[(v$95$s * N[((-v$95$m) / N[(u + t1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
v\_m = \left|v\right|
\\
v\_s = \mathsf{copysign}\left(1, v\right)

\\
v\_s \cdot \frac{-v\_m}{u + t1}
\end{array}
Derivation
  1. Initial program 72.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-*.f64N/A

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{-t1}{u + t1} \cdot \frac{v}{\color{blue}{u + t1}} \]
    13. lower-+.f6498.0

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

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

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

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

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

      \[\leadsto \frac{-t1}{u + t1} \cdot \color{blue}{\frac{v}{u + t1}} \]
    6. associate-*l/N/A

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{\left(-t1\right) \cdot \frac{v}{u + t1}}{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 9: 54.9% accurate, 3.1× speedup?

\[\begin{array}{l} v\_m = \left|v\right| \\ v\_s = \mathsf{copysign}\left(1, v\right) \\ v\_s \cdot \frac{-v\_m}{t1} \end{array} \]
v\_m = (fabs.f64 v)
v\_s = (copysign.f64 #s(literal 1 binary64) v)
(FPCore (v_s u v_m t1) :precision binary64 (* v_s (/ (- v_m) t1)))
v\_m = fabs(v);
v\_s = copysign(1.0, v);
double code(double v_s, double u, double v_m, double t1) {
	return v_s * (-v_m / t1);
}
v\_m =     private
v\_s =     private
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(v_s, u, v_m, t1)
use fmin_fmax_functions
    real(8), intent (in) :: v_s
    real(8), intent (in) :: u
    real(8), intent (in) :: v_m
    real(8), intent (in) :: t1
    code = v_s * (-v_m / t1)
end function
v\_m = Math.abs(v);
v\_s = Math.copySign(1.0, v);
public static double code(double v_s, double u, double v_m, double t1) {
	return v_s * (-v_m / t1);
}
v\_m = math.fabs(v)
v\_s = math.copysign(1.0, v)
def code(v_s, u, v_m, t1):
	return v_s * (-v_m / t1)
v\_m = abs(v)
v\_s = copysign(1.0, v)
function code(v_s, u, v_m, t1)
	return Float64(v_s * Float64(Float64(-v_m) / t1))
end
v\_m = abs(v);
v\_s = sign(v) * abs(1.0);
function tmp = code(v_s, u, v_m, t1)
	tmp = v_s * (-v_m / t1);
end
v\_m = N[Abs[v], $MachinePrecision]
v\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[v]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[v$95$s_, u_, v$95$m_, t1_] := N[(v$95$s * N[((-v$95$m) / t1), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
v\_m = \left|v\right|
\\
v\_s = \mathsf{copysign}\left(1, v\right)

\\
v\_s \cdot \frac{-v\_m}{t1}
\end{array}
Derivation
  1. Initial program 72.2%

    \[\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.9

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

    \[\leadsto \color{blue}{\frac{-v}{t1}} \]
  5. Add Preprocessing

Reproduce

?
herbie shell --seed 2025138 
(FPCore (u v t1)
  :name "Rosa's DopplerBench"
  :precision binary64
  (/ (* (- t1) v) (* (+ t1 u) (+ t1 u))))