Henrywood and Agarwal, Equation (3)

Percentage Accurate: 73.9% → 97.9%
Time: 4.3s
Alternatives: 9
Speedup: 1.0×

Specification

?
\[\begin{array}{l} \\ c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \end{array} \]
(FPCore (c0 A V l) :precision binary64 (* c0 (sqrt (/ A (* V l)))))
double code(double c0, double A, double V, double l) {
	return c0 * sqrt((A / (V * l)));
}
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(c0, a, v, l)
use fmin_fmax_functions
    real(8), intent (in) :: c0
    real(8), intent (in) :: a
    real(8), intent (in) :: v
    real(8), intent (in) :: l
    code = c0 * sqrt((a / (v * l)))
end function
public static double code(double c0, double A, double V, double l) {
	return c0 * Math.sqrt((A / (V * l)));
}
def code(c0, A, V, l):
	return c0 * math.sqrt((A / (V * l)))
function code(c0, A, V, l)
	return Float64(c0 * sqrt(Float64(A / Float64(V * l))))
end
function tmp = code(c0, A, V, l)
	tmp = c0 * sqrt((A / (V * l)));
end
code[c0_, A_, V_, l_] := N[(c0 * N[Sqrt[N[(A / N[(V * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}
\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: 73.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \end{array} \]
(FPCore (c0 A V l) :precision binary64 (* c0 (sqrt (/ A (* V l)))))
double code(double c0, double A, double V, double l) {
	return c0 * sqrt((A / (V * l)));
}
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(c0, a, v, l)
use fmin_fmax_functions
    real(8), intent (in) :: c0
    real(8), intent (in) :: a
    real(8), intent (in) :: v
    real(8), intent (in) :: l
    code = c0 * sqrt((a / (v * l)))
end function
public static double code(double c0, double A, double V, double l) {
	return c0 * Math.sqrt((A / (V * l)));
}
def code(c0, A, V, l):
	return c0 * math.sqrt((A / (V * l)))
function code(c0, A, V, l)
	return Float64(c0 * sqrt(Float64(A / Float64(V * l))))
end
function tmp = code(c0, A, V, l)
	tmp = c0 * sqrt((A / (V * l)));
end
code[c0_, A_, V_, l_] := N[(c0 * N[Sqrt[N[(A / N[(V * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}
\end{array}

Alternative 1: 97.9% accurate, 0.6× speedup?

\[\begin{array}{l} A_m = \left|A\right| \\ V_m = \left|V\right| \\ l_m = \left|\ell\right| \\ c0\_m = \left|c0\right| \\ c0\_s = \mathsf{copysign}\left(1, c0\right) \\ [c0_m, A_m, V_m, l_m] = \mathsf{sort}([c0_m, A_m, V_m, l_m])\\ \\ c0\_s \cdot \begin{array}{l} \mathbf{if}\;c0\_m \leq 8 \cdot 10^{+159}:\\ \;\;\;\;\frac{\sqrt{A\_m}}{\sqrt{l\_m}} \cdot \frac{c0\_m}{\sqrt{V\_m}}\\ \mathbf{else}:\\ \;\;\;\;c0\_m \cdot \frac{\sqrt{\frac{A\_m}{V\_m}}}{\sqrt{l\_m}}\\ \end{array} \end{array} \]
A_m = (fabs.f64 A)
V_m = (fabs.f64 V)
l_m = (fabs.f64 l)
c0\_m = (fabs.f64 c0)
c0\_s = (copysign.f64 #s(literal 1 binary64) c0)
NOTE: c0_m, A_m, V_m, and l_m should be sorted in increasing order before calling this function.
(FPCore (c0_s c0_m A_m V_m l_m)
 :precision binary64
 (*
  c0_s
  (if (<= c0_m 8e+159)
    (* (/ (sqrt A_m) (sqrt l_m)) (/ c0_m (sqrt V_m)))
    (* c0_m (/ (sqrt (/ A_m V_m)) (sqrt l_m))))))
A_m = fabs(A);
V_m = fabs(V);
l_m = fabs(l);
c0\_m = fabs(c0);
c0\_s = copysign(1.0, c0);
assert(c0_m < A_m && A_m < V_m && V_m < l_m);
double code(double c0_s, double c0_m, double A_m, double V_m, double l_m) {
	double tmp;
	if (c0_m <= 8e+159) {
		tmp = (sqrt(A_m) / sqrt(l_m)) * (c0_m / sqrt(V_m));
	} else {
		tmp = c0_m * (sqrt((A_m / V_m)) / sqrt(l_m));
	}
	return c0_s * tmp;
}
A_m =     private
V_m =     private
l_m =     private
c0\_m =     private
c0\_s =     private
NOTE: c0_m, A_m, V_m, and l_m should be sorted in increasing order before calling this function.
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(c0_s, c0_m, a_m, v_m, l_m)
use fmin_fmax_functions
    real(8), intent (in) :: c0_s
    real(8), intent (in) :: c0_m
    real(8), intent (in) :: a_m
    real(8), intent (in) :: v_m
    real(8), intent (in) :: l_m
    real(8) :: tmp
    if (c0_m <= 8d+159) then
        tmp = (sqrt(a_m) / sqrt(l_m)) * (c0_m / sqrt(v_m))
    else
        tmp = c0_m * (sqrt((a_m / v_m)) / sqrt(l_m))
    end if
    code = c0_s * tmp
end function
A_m = Math.abs(A);
V_m = Math.abs(V);
l_m = Math.abs(l);
c0\_m = Math.abs(c0);
c0\_s = Math.copySign(1.0, c0);
assert c0_m < A_m && A_m < V_m && V_m < l_m;
public static double code(double c0_s, double c0_m, double A_m, double V_m, double l_m) {
	double tmp;
	if (c0_m <= 8e+159) {
		tmp = (Math.sqrt(A_m) / Math.sqrt(l_m)) * (c0_m / Math.sqrt(V_m));
	} else {
		tmp = c0_m * (Math.sqrt((A_m / V_m)) / Math.sqrt(l_m));
	}
	return c0_s * tmp;
}
A_m = math.fabs(A)
V_m = math.fabs(V)
l_m = math.fabs(l)
c0\_m = math.fabs(c0)
c0\_s = math.copysign(1.0, c0)
[c0_m, A_m, V_m, l_m] = sort([c0_m, A_m, V_m, l_m])
def code(c0_s, c0_m, A_m, V_m, l_m):
	tmp = 0
	if c0_m <= 8e+159:
		tmp = (math.sqrt(A_m) / math.sqrt(l_m)) * (c0_m / math.sqrt(V_m))
	else:
		tmp = c0_m * (math.sqrt((A_m / V_m)) / math.sqrt(l_m))
	return c0_s * tmp
A_m = abs(A)
V_m = abs(V)
l_m = abs(l)
c0\_m = abs(c0)
c0\_s = copysign(1.0, c0)
c0_m, A_m, V_m, l_m = sort([c0_m, A_m, V_m, l_m])
function code(c0_s, c0_m, A_m, V_m, l_m)
	tmp = 0.0
	if (c0_m <= 8e+159)
		tmp = Float64(Float64(sqrt(A_m) / sqrt(l_m)) * Float64(c0_m / sqrt(V_m)));
	else
		tmp = Float64(c0_m * Float64(sqrt(Float64(A_m / V_m)) / sqrt(l_m)));
	end
	return Float64(c0_s * tmp)
end
A_m = abs(A);
V_m = abs(V);
l_m = abs(l);
c0\_m = abs(c0);
c0\_s = sign(c0) * abs(1.0);
c0_m, A_m, V_m, l_m = num2cell(sort([c0_m, A_m, V_m, l_m])){:}
function tmp_2 = code(c0_s, c0_m, A_m, V_m, l_m)
	tmp = 0.0;
	if (c0_m <= 8e+159)
		tmp = (sqrt(A_m) / sqrt(l_m)) * (c0_m / sqrt(V_m));
	else
		tmp = c0_m * (sqrt((A_m / V_m)) / sqrt(l_m));
	end
	tmp_2 = c0_s * tmp;
end
A_m = N[Abs[A], $MachinePrecision]
V_m = N[Abs[V], $MachinePrecision]
l_m = N[Abs[l], $MachinePrecision]
c0\_m = N[Abs[c0], $MachinePrecision]
c0\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[c0]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: c0_m, A_m, V_m, and l_m should be sorted in increasing order before calling this function.
code[c0$95$s_, c0$95$m_, A$95$m_, V$95$m_, l$95$m_] := N[(c0$95$s * If[LessEqual[c0$95$m, 8e+159], N[(N[(N[Sqrt[A$95$m], $MachinePrecision] / N[Sqrt[l$95$m], $MachinePrecision]), $MachinePrecision] * N[(c0$95$m / N[Sqrt[V$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0$95$m * N[(N[Sqrt[N[(A$95$m / V$95$m), $MachinePrecision]], $MachinePrecision] / N[Sqrt[l$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
A_m = \left|A\right|
\\
V_m = \left|V\right|
\\
l_m = \left|\ell\right|
\\
c0\_m = \left|c0\right|
\\
c0\_s = \mathsf{copysign}\left(1, c0\right)
\\
[c0_m, A_m, V_m, l_m] = \mathsf{sort}([c0_m, A_m, V_m, l_m])\\
\\
c0\_s \cdot \begin{array}{l}
\mathbf{if}\;c0\_m \leq 8 \cdot 10^{+159}:\\
\;\;\;\;\frac{\sqrt{A\_m}}{\sqrt{l\_m}} \cdot \frac{c0\_m}{\sqrt{V\_m}}\\

\mathbf{else}:\\
\;\;\;\;c0\_m \cdot \frac{\sqrt{\frac{A\_m}{V\_m}}}{\sqrt{l\_m}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c0 < 7.9999999999999994e159

    1. Initial program 73.9%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}} \]
      2. *-commutativeN/A

        \[\leadsto \color{blue}{\sqrt{\frac{A}{V \cdot \ell}} \cdot c0} \]
      3. lift-sqrt.f64N/A

        \[\leadsto \color{blue}{\sqrt{\frac{A}{V \cdot \ell}}} \cdot c0 \]
      4. lift-/.f64N/A

        \[\leadsto \sqrt{\color{blue}{\frac{A}{V \cdot \ell}}} \cdot c0 \]
      5. sqrt-divN/A

        \[\leadsto \color{blue}{\frac{\sqrt{A}}{\sqrt{V \cdot \ell}}} \cdot c0 \]
      6. associate-*l/N/A

        \[\leadsto \color{blue}{\frac{\sqrt{A} \cdot c0}{\sqrt{V \cdot \ell}}} \]
      7. lift-*.f64N/A

        \[\leadsto \frac{\sqrt{A} \cdot c0}{\sqrt{\color{blue}{V \cdot \ell}}} \]
      8. *-commutativeN/A

        \[\leadsto \frac{\sqrt{A} \cdot c0}{\sqrt{\color{blue}{\ell \cdot V}}} \]
      9. sqrt-prodN/A

        \[\leadsto \frac{\sqrt{A} \cdot c0}{\color{blue}{\sqrt{\ell} \cdot \sqrt{V}}} \]
      10. times-fracN/A

        \[\leadsto \color{blue}{\frac{\sqrt{A}}{\sqrt{\ell}} \cdot \frac{c0}{\sqrt{V}}} \]
      11. lower-*.f64N/A

        \[\leadsto \color{blue}{\frac{\sqrt{A}}{\sqrt{\ell}} \cdot \frac{c0}{\sqrt{V}}} \]
      12. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{\sqrt{A}}{\sqrt{\ell}}} \cdot \frac{c0}{\sqrt{V}} \]
      13. lower-sqrt.f64N/A

        \[\leadsto \frac{\color{blue}{\sqrt{A}}}{\sqrt{\ell}} \cdot \frac{c0}{\sqrt{V}} \]
      14. lower-sqrt.f64N/A

        \[\leadsto \frac{\sqrt{A}}{\color{blue}{\sqrt{\ell}}} \cdot \frac{c0}{\sqrt{V}} \]
      15. lower-/.f64N/A

        \[\leadsto \frac{\sqrt{A}}{\sqrt{\ell}} \cdot \color{blue}{\frac{c0}{\sqrt{V}}} \]
      16. lower-sqrt.f6494.9

        \[\leadsto \frac{\sqrt{A}}{\sqrt{\ell}} \cdot \frac{c0}{\color{blue}{\sqrt{V}}} \]
    3. Applied rewrites94.9%

      \[\leadsto \color{blue}{\frac{\sqrt{A}}{\sqrt{\ell}} \cdot \frac{c0}{\sqrt{V}}} \]

    if 7.9999999999999994e159 < c0

    1. Initial program 73.9%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Step-by-step derivation
      1. lift-sqrt.f64N/A

        \[\leadsto c0 \cdot \color{blue}{\sqrt{\frac{A}{V \cdot \ell}}} \]
      2. lift-/.f64N/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{A}{V \cdot \ell}}} \]
      3. lift-*.f64N/A

        \[\leadsto c0 \cdot \sqrt{\frac{A}{\color{blue}{V \cdot \ell}}} \]
      4. associate-/r*N/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{A}{V}}{\ell}}} \]
      5. sqrt-divN/A

        \[\leadsto c0 \cdot \color{blue}{\frac{\sqrt{\frac{A}{V}}}{\sqrt{\ell}}} \]
      6. lower-/.f64N/A

        \[\leadsto c0 \cdot \color{blue}{\frac{\sqrt{\frac{A}{V}}}{\sqrt{\ell}}} \]
      7. lower-sqrt.f64N/A

        \[\leadsto c0 \cdot \frac{\color{blue}{\sqrt{\frac{A}{V}}}}{\sqrt{\ell}} \]
      8. lower-/.f64N/A

        \[\leadsto c0 \cdot \frac{\sqrt{\color{blue}{\frac{A}{V}}}}{\sqrt{\ell}} \]
      9. lower-sqrt.f6484.4

        \[\leadsto c0 \cdot \frac{\sqrt{\frac{A}{V}}}{\color{blue}{\sqrt{\ell}}} \]
    3. Applied rewrites84.4%

      \[\leadsto c0 \cdot \color{blue}{\frac{\sqrt{\frac{A}{V}}}{\sqrt{\ell}}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 2: 95.9% accurate, 0.4× speedup?

\[\begin{array}{l} A_m = \left|A\right| \\ V_m = \left|V\right| \\ l_m = \left|\ell\right| \\ c0\_m = \left|c0\right| \\ c0\_s = \mathsf{copysign}\left(1, c0\right) \\ [c0_m, A_m, V_m, l_m] = \mathsf{sort}([c0_m, A_m, V_m, l_m])\\ \\ \begin{array}{l} t_0 := c0\_m \cdot \frac{\sqrt{\frac{A\_m}{V\_m}}}{\sqrt{l\_m}}\\ c0\_s \cdot \begin{array}{l} \mathbf{if}\;V\_m \cdot l\_m \leq 5 \cdot 10^{-314}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;V\_m \cdot l\_m \leq 10^{+238}:\\ \;\;\;\;c0\_m \cdot \frac{\sqrt{A\_m}}{\sqrt{l\_m \cdot V\_m}}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \end{array} \]
A_m = (fabs.f64 A)
V_m = (fabs.f64 V)
l_m = (fabs.f64 l)
c0\_m = (fabs.f64 c0)
c0\_s = (copysign.f64 #s(literal 1 binary64) c0)
NOTE: c0_m, A_m, V_m, and l_m should be sorted in increasing order before calling this function.
(FPCore (c0_s c0_m A_m V_m l_m)
 :precision binary64
 (let* ((t_0 (* c0_m (/ (sqrt (/ A_m V_m)) (sqrt l_m)))))
   (*
    c0_s
    (if (<= (* V_m l_m) 5e-314)
      t_0
      (if (<= (* V_m l_m) 1e+238)
        (* c0_m (/ (sqrt A_m) (sqrt (* l_m V_m))))
        t_0)))))
A_m = fabs(A);
V_m = fabs(V);
l_m = fabs(l);
c0\_m = fabs(c0);
c0\_s = copysign(1.0, c0);
assert(c0_m < A_m && A_m < V_m && V_m < l_m);
double code(double c0_s, double c0_m, double A_m, double V_m, double l_m) {
	double t_0 = c0_m * (sqrt((A_m / V_m)) / sqrt(l_m));
	double tmp;
	if ((V_m * l_m) <= 5e-314) {
		tmp = t_0;
	} else if ((V_m * l_m) <= 1e+238) {
		tmp = c0_m * (sqrt(A_m) / sqrt((l_m * V_m)));
	} else {
		tmp = t_0;
	}
	return c0_s * tmp;
}
A_m =     private
V_m =     private
l_m =     private
c0\_m =     private
c0\_s =     private
NOTE: c0_m, A_m, V_m, and l_m should be sorted in increasing order before calling this function.
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(c0_s, c0_m, a_m, v_m, l_m)
use fmin_fmax_functions
    real(8), intent (in) :: c0_s
    real(8), intent (in) :: c0_m
    real(8), intent (in) :: a_m
    real(8), intent (in) :: v_m
    real(8), intent (in) :: l_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = c0_m * (sqrt((a_m / v_m)) / sqrt(l_m))
    if ((v_m * l_m) <= 5d-314) then
        tmp = t_0
    else if ((v_m * l_m) <= 1d+238) then
        tmp = c0_m * (sqrt(a_m) / sqrt((l_m * v_m)))
    else
        tmp = t_0
    end if
    code = c0_s * tmp
end function
A_m = Math.abs(A);
V_m = Math.abs(V);
l_m = Math.abs(l);
c0\_m = Math.abs(c0);
c0\_s = Math.copySign(1.0, c0);
assert c0_m < A_m && A_m < V_m && V_m < l_m;
public static double code(double c0_s, double c0_m, double A_m, double V_m, double l_m) {
	double t_0 = c0_m * (Math.sqrt((A_m / V_m)) / Math.sqrt(l_m));
	double tmp;
	if ((V_m * l_m) <= 5e-314) {
		tmp = t_0;
	} else if ((V_m * l_m) <= 1e+238) {
		tmp = c0_m * (Math.sqrt(A_m) / Math.sqrt((l_m * V_m)));
	} else {
		tmp = t_0;
	}
	return c0_s * tmp;
}
A_m = math.fabs(A)
V_m = math.fabs(V)
l_m = math.fabs(l)
c0\_m = math.fabs(c0)
c0\_s = math.copysign(1.0, c0)
[c0_m, A_m, V_m, l_m] = sort([c0_m, A_m, V_m, l_m])
def code(c0_s, c0_m, A_m, V_m, l_m):
	t_0 = c0_m * (math.sqrt((A_m / V_m)) / math.sqrt(l_m))
	tmp = 0
	if (V_m * l_m) <= 5e-314:
		tmp = t_0
	elif (V_m * l_m) <= 1e+238:
		tmp = c0_m * (math.sqrt(A_m) / math.sqrt((l_m * V_m)))
	else:
		tmp = t_0
	return c0_s * tmp
A_m = abs(A)
V_m = abs(V)
l_m = abs(l)
c0\_m = abs(c0)
c0\_s = copysign(1.0, c0)
c0_m, A_m, V_m, l_m = sort([c0_m, A_m, V_m, l_m])
function code(c0_s, c0_m, A_m, V_m, l_m)
	t_0 = Float64(c0_m * Float64(sqrt(Float64(A_m / V_m)) / sqrt(l_m)))
	tmp = 0.0
	if (Float64(V_m * l_m) <= 5e-314)
		tmp = t_0;
	elseif (Float64(V_m * l_m) <= 1e+238)
		tmp = Float64(c0_m * Float64(sqrt(A_m) / sqrt(Float64(l_m * V_m))));
	else
		tmp = t_0;
	end
	return Float64(c0_s * tmp)
end
A_m = abs(A);
V_m = abs(V);
l_m = abs(l);
c0\_m = abs(c0);
c0\_s = sign(c0) * abs(1.0);
c0_m, A_m, V_m, l_m = num2cell(sort([c0_m, A_m, V_m, l_m])){:}
function tmp_2 = code(c0_s, c0_m, A_m, V_m, l_m)
	t_0 = c0_m * (sqrt((A_m / V_m)) / sqrt(l_m));
	tmp = 0.0;
	if ((V_m * l_m) <= 5e-314)
		tmp = t_0;
	elseif ((V_m * l_m) <= 1e+238)
		tmp = c0_m * (sqrt(A_m) / sqrt((l_m * V_m)));
	else
		tmp = t_0;
	end
	tmp_2 = c0_s * tmp;
end
A_m = N[Abs[A], $MachinePrecision]
V_m = N[Abs[V], $MachinePrecision]
l_m = N[Abs[l], $MachinePrecision]
c0\_m = N[Abs[c0], $MachinePrecision]
c0\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[c0]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: c0_m, A_m, V_m, and l_m should be sorted in increasing order before calling this function.
code[c0$95$s_, c0$95$m_, A$95$m_, V$95$m_, l$95$m_] := Block[{t$95$0 = N[(c0$95$m * N[(N[Sqrt[N[(A$95$m / V$95$m), $MachinePrecision]], $MachinePrecision] / N[Sqrt[l$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(c0$95$s * If[LessEqual[N[(V$95$m * l$95$m), $MachinePrecision], 5e-314], t$95$0, If[LessEqual[N[(V$95$m * l$95$m), $MachinePrecision], 1e+238], N[(c0$95$m * N[(N[Sqrt[A$95$m], $MachinePrecision] / N[Sqrt[N[(l$95$m * V$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]), $MachinePrecision]]
\begin{array}{l}
A_m = \left|A\right|
\\
V_m = \left|V\right|
\\
l_m = \left|\ell\right|
\\
c0\_m = \left|c0\right|
\\
c0\_s = \mathsf{copysign}\left(1, c0\right)
\\
[c0_m, A_m, V_m, l_m] = \mathsf{sort}([c0_m, A_m, V_m, l_m])\\
\\
\begin{array}{l}
t_0 := c0\_m \cdot \frac{\sqrt{\frac{A\_m}{V\_m}}}{\sqrt{l\_m}}\\
c0\_s \cdot \begin{array}{l}
\mathbf{if}\;V\_m \cdot l\_m \leq 5 \cdot 10^{-314}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;V\_m \cdot l\_m \leq 10^{+238}:\\
\;\;\;\;c0\_m \cdot \frac{\sqrt{A\_m}}{\sqrt{l\_m \cdot V\_m}}\\

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


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 V l) < 4.99999999982e-314 or 1e238 < (*.f64 V l)

    1. Initial program 73.9%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Step-by-step derivation
      1. lift-sqrt.f64N/A

        \[\leadsto c0 \cdot \color{blue}{\sqrt{\frac{A}{V \cdot \ell}}} \]
      2. lift-/.f64N/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{A}{V \cdot \ell}}} \]
      3. lift-*.f64N/A

        \[\leadsto c0 \cdot \sqrt{\frac{A}{\color{blue}{V \cdot \ell}}} \]
      4. associate-/r*N/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{A}{V}}{\ell}}} \]
      5. sqrt-divN/A

        \[\leadsto c0 \cdot \color{blue}{\frac{\sqrt{\frac{A}{V}}}{\sqrt{\ell}}} \]
      6. lower-/.f64N/A

        \[\leadsto c0 \cdot \color{blue}{\frac{\sqrt{\frac{A}{V}}}{\sqrt{\ell}}} \]
      7. lower-sqrt.f64N/A

        \[\leadsto c0 \cdot \frac{\color{blue}{\sqrt{\frac{A}{V}}}}{\sqrt{\ell}} \]
      8. lower-/.f64N/A

        \[\leadsto c0 \cdot \frac{\sqrt{\color{blue}{\frac{A}{V}}}}{\sqrt{\ell}} \]
      9. lower-sqrt.f6484.4

        \[\leadsto c0 \cdot \frac{\sqrt{\frac{A}{V}}}{\color{blue}{\sqrt{\ell}}} \]
    3. Applied rewrites84.4%

      \[\leadsto c0 \cdot \color{blue}{\frac{\sqrt{\frac{A}{V}}}{\sqrt{\ell}}} \]

    if 4.99999999982e-314 < (*.f64 V l) < 1e238

    1. Initial program 73.9%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Step-by-step derivation
      1. lift-sqrt.f64N/A

        \[\leadsto c0 \cdot \color{blue}{\sqrt{\frac{A}{V \cdot \ell}}} \]
      2. lift-/.f64N/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{A}{V \cdot \ell}}} \]
      3. sqrt-divN/A

        \[\leadsto c0 \cdot \color{blue}{\frac{\sqrt{A}}{\sqrt{V \cdot \ell}}} \]
      4. lower-/.f64N/A

        \[\leadsto c0 \cdot \color{blue}{\frac{\sqrt{A}}{\sqrt{V \cdot \ell}}} \]
      5. lower-sqrt.f64N/A

        \[\leadsto c0 \cdot \frac{\color{blue}{\sqrt{A}}}{\sqrt{V \cdot \ell}} \]
      6. lower-sqrt.f6483.8

        \[\leadsto c0 \cdot \frac{\sqrt{A}}{\color{blue}{\sqrt{V \cdot \ell}}} \]
      7. lift-*.f64N/A

        \[\leadsto c0 \cdot \frac{\sqrt{A}}{\sqrt{\color{blue}{V \cdot \ell}}} \]
      8. *-commutativeN/A

        \[\leadsto c0 \cdot \frac{\sqrt{A}}{\sqrt{\color{blue}{\ell \cdot V}}} \]
      9. lower-*.f6483.8

        \[\leadsto c0 \cdot \frac{\sqrt{A}}{\sqrt{\color{blue}{\ell \cdot V}}} \]
    3. Applied rewrites83.8%

      \[\leadsto c0 \cdot \color{blue}{\frac{\sqrt{A}}{\sqrt{\ell \cdot V}}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 3: 95.6% accurate, 0.5× speedup?

\[\begin{array}{l} A_m = \left|A\right| \\ V_m = \left|V\right| \\ l_m = \left|\ell\right| \\ c0\_m = \left|c0\right| \\ c0\_s = \mathsf{copysign}\left(1, c0\right) \\ [c0_m, A_m, V_m, l_m] = \mathsf{sort}([c0_m, A_m, V_m, l_m])\\ \\ c0\_s \cdot \begin{array}{l} \mathbf{if}\;\sqrt{\frac{A\_m}{V\_m \cdot l\_m}} \leq 10^{+20}:\\ \;\;\;\;c0\_m \cdot \frac{\sqrt{\frac{A\_m}{V\_m}}}{\sqrt{l\_m}}\\ \mathbf{else}:\\ \;\;\;\;c0\_m \cdot \frac{\sqrt{\frac{A\_m}{l\_m}}}{\sqrt{V\_m}}\\ \end{array} \end{array} \]
A_m = (fabs.f64 A)
V_m = (fabs.f64 V)
l_m = (fabs.f64 l)
c0\_m = (fabs.f64 c0)
c0\_s = (copysign.f64 #s(literal 1 binary64) c0)
NOTE: c0_m, A_m, V_m, and l_m should be sorted in increasing order before calling this function.
(FPCore (c0_s c0_m A_m V_m l_m)
 :precision binary64
 (*
  c0_s
  (if (<= (sqrt (/ A_m (* V_m l_m))) 1e+20)
    (* c0_m (/ (sqrt (/ A_m V_m)) (sqrt l_m)))
    (* c0_m (/ (sqrt (/ A_m l_m)) (sqrt V_m))))))
A_m = fabs(A);
V_m = fabs(V);
l_m = fabs(l);
c0\_m = fabs(c0);
c0\_s = copysign(1.0, c0);
assert(c0_m < A_m && A_m < V_m && V_m < l_m);
double code(double c0_s, double c0_m, double A_m, double V_m, double l_m) {
	double tmp;
	if (sqrt((A_m / (V_m * l_m))) <= 1e+20) {
		tmp = c0_m * (sqrt((A_m / V_m)) / sqrt(l_m));
	} else {
		tmp = c0_m * (sqrt((A_m / l_m)) / sqrt(V_m));
	}
	return c0_s * tmp;
}
A_m =     private
V_m =     private
l_m =     private
c0\_m =     private
c0\_s =     private
NOTE: c0_m, A_m, V_m, and l_m should be sorted in increasing order before calling this function.
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(c0_s, c0_m, a_m, v_m, l_m)
use fmin_fmax_functions
    real(8), intent (in) :: c0_s
    real(8), intent (in) :: c0_m
    real(8), intent (in) :: a_m
    real(8), intent (in) :: v_m
    real(8), intent (in) :: l_m
    real(8) :: tmp
    if (sqrt((a_m / (v_m * l_m))) <= 1d+20) then
        tmp = c0_m * (sqrt((a_m / v_m)) / sqrt(l_m))
    else
        tmp = c0_m * (sqrt((a_m / l_m)) / sqrt(v_m))
    end if
    code = c0_s * tmp
end function
A_m = Math.abs(A);
V_m = Math.abs(V);
l_m = Math.abs(l);
c0\_m = Math.abs(c0);
c0\_s = Math.copySign(1.0, c0);
assert c0_m < A_m && A_m < V_m && V_m < l_m;
public static double code(double c0_s, double c0_m, double A_m, double V_m, double l_m) {
	double tmp;
	if (Math.sqrt((A_m / (V_m * l_m))) <= 1e+20) {
		tmp = c0_m * (Math.sqrt((A_m / V_m)) / Math.sqrt(l_m));
	} else {
		tmp = c0_m * (Math.sqrt((A_m / l_m)) / Math.sqrt(V_m));
	}
	return c0_s * tmp;
}
A_m = math.fabs(A)
V_m = math.fabs(V)
l_m = math.fabs(l)
c0\_m = math.fabs(c0)
c0\_s = math.copysign(1.0, c0)
[c0_m, A_m, V_m, l_m] = sort([c0_m, A_m, V_m, l_m])
def code(c0_s, c0_m, A_m, V_m, l_m):
	tmp = 0
	if math.sqrt((A_m / (V_m * l_m))) <= 1e+20:
		tmp = c0_m * (math.sqrt((A_m / V_m)) / math.sqrt(l_m))
	else:
		tmp = c0_m * (math.sqrt((A_m / l_m)) / math.sqrt(V_m))
	return c0_s * tmp
A_m = abs(A)
V_m = abs(V)
l_m = abs(l)
c0\_m = abs(c0)
c0\_s = copysign(1.0, c0)
c0_m, A_m, V_m, l_m = sort([c0_m, A_m, V_m, l_m])
function code(c0_s, c0_m, A_m, V_m, l_m)
	tmp = 0.0
	if (sqrt(Float64(A_m / Float64(V_m * l_m))) <= 1e+20)
		tmp = Float64(c0_m * Float64(sqrt(Float64(A_m / V_m)) / sqrt(l_m)));
	else
		tmp = Float64(c0_m * Float64(sqrt(Float64(A_m / l_m)) / sqrt(V_m)));
	end
	return Float64(c0_s * tmp)
end
A_m = abs(A);
V_m = abs(V);
l_m = abs(l);
c0\_m = abs(c0);
c0\_s = sign(c0) * abs(1.0);
c0_m, A_m, V_m, l_m = num2cell(sort([c0_m, A_m, V_m, l_m])){:}
function tmp_2 = code(c0_s, c0_m, A_m, V_m, l_m)
	tmp = 0.0;
	if (sqrt((A_m / (V_m * l_m))) <= 1e+20)
		tmp = c0_m * (sqrt((A_m / V_m)) / sqrt(l_m));
	else
		tmp = c0_m * (sqrt((A_m / l_m)) / sqrt(V_m));
	end
	tmp_2 = c0_s * tmp;
end
A_m = N[Abs[A], $MachinePrecision]
V_m = N[Abs[V], $MachinePrecision]
l_m = N[Abs[l], $MachinePrecision]
c0\_m = N[Abs[c0], $MachinePrecision]
c0\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[c0]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: c0_m, A_m, V_m, and l_m should be sorted in increasing order before calling this function.
code[c0$95$s_, c0$95$m_, A$95$m_, V$95$m_, l$95$m_] := N[(c0$95$s * If[LessEqual[N[Sqrt[N[(A$95$m / N[(V$95$m * l$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 1e+20], N[(c0$95$m * N[(N[Sqrt[N[(A$95$m / V$95$m), $MachinePrecision]], $MachinePrecision] / N[Sqrt[l$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0$95$m * N[(N[Sqrt[N[(A$95$m / l$95$m), $MachinePrecision]], $MachinePrecision] / N[Sqrt[V$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
A_m = \left|A\right|
\\
V_m = \left|V\right|
\\
l_m = \left|\ell\right|
\\
c0\_m = \left|c0\right|
\\
c0\_s = \mathsf{copysign}\left(1, c0\right)
\\
[c0_m, A_m, V_m, l_m] = \mathsf{sort}([c0_m, A_m, V_m, l_m])\\
\\
c0\_s \cdot \begin{array}{l}
\mathbf{if}\;\sqrt{\frac{A\_m}{V\_m \cdot l\_m}} \leq 10^{+20}:\\
\;\;\;\;c0\_m \cdot \frac{\sqrt{\frac{A\_m}{V\_m}}}{\sqrt{l\_m}}\\

\mathbf{else}:\\
\;\;\;\;c0\_m \cdot \frac{\sqrt{\frac{A\_m}{l\_m}}}{\sqrt{V\_m}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (sqrt.f64 (/.f64 A (*.f64 V l))) < 1e20

    1. Initial program 73.9%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Step-by-step derivation
      1. lift-sqrt.f64N/A

        \[\leadsto c0 \cdot \color{blue}{\sqrt{\frac{A}{V \cdot \ell}}} \]
      2. lift-/.f64N/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{A}{V \cdot \ell}}} \]
      3. lift-*.f64N/A

        \[\leadsto c0 \cdot \sqrt{\frac{A}{\color{blue}{V \cdot \ell}}} \]
      4. associate-/r*N/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{A}{V}}{\ell}}} \]
      5. sqrt-divN/A

        \[\leadsto c0 \cdot \color{blue}{\frac{\sqrt{\frac{A}{V}}}{\sqrt{\ell}}} \]
      6. lower-/.f64N/A

        \[\leadsto c0 \cdot \color{blue}{\frac{\sqrt{\frac{A}{V}}}{\sqrt{\ell}}} \]
      7. lower-sqrt.f64N/A

        \[\leadsto c0 \cdot \frac{\color{blue}{\sqrt{\frac{A}{V}}}}{\sqrt{\ell}} \]
      8. lower-/.f64N/A

        \[\leadsto c0 \cdot \frac{\sqrt{\color{blue}{\frac{A}{V}}}}{\sqrt{\ell}} \]
      9. lower-sqrt.f6484.4

        \[\leadsto c0 \cdot \frac{\sqrt{\frac{A}{V}}}{\color{blue}{\sqrt{\ell}}} \]
    3. Applied rewrites84.4%

      \[\leadsto c0 \cdot \color{blue}{\frac{\sqrt{\frac{A}{V}}}{\sqrt{\ell}}} \]

    if 1e20 < (sqrt.f64 (/.f64 A (*.f64 V l)))

    1. Initial program 73.9%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Step-by-step derivation
      1. lift-sqrt.f64N/A

        \[\leadsto c0 \cdot \color{blue}{\sqrt{\frac{A}{V \cdot \ell}}} \]
      2. lift-/.f64N/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{A}{V \cdot \ell}}} \]
      3. lift-*.f64N/A

        \[\leadsto c0 \cdot \sqrt{\frac{A}{\color{blue}{V \cdot \ell}}} \]
      4. *-commutativeN/A

        \[\leadsto c0 \cdot \sqrt{\frac{A}{\color{blue}{\ell \cdot V}}} \]
      5. associate-/r*N/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{A}{\ell}}{V}}} \]
      6. sqrt-divN/A

        \[\leadsto c0 \cdot \color{blue}{\frac{\sqrt{\frac{A}{\ell}}}{\sqrt{V}}} \]
      7. lower-/.f64N/A

        \[\leadsto c0 \cdot \color{blue}{\frac{\sqrt{\frac{A}{\ell}}}{\sqrt{V}}} \]
      8. lower-sqrt.f64N/A

        \[\leadsto c0 \cdot \frac{\color{blue}{\sqrt{\frac{A}{\ell}}}}{\sqrt{V}} \]
      9. lower-/.f64N/A

        \[\leadsto c0 \cdot \frac{\sqrt{\color{blue}{\frac{A}{\ell}}}}{\sqrt{V}} \]
      10. lower-sqrt.f6484.8

        \[\leadsto c0 \cdot \frac{\sqrt{\frac{A}{\ell}}}{\color{blue}{\sqrt{V}}} \]
    3. Applied rewrites84.8%

      \[\leadsto c0 \cdot \color{blue}{\frac{\sqrt{\frac{A}{\ell}}}{\sqrt{V}}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 4: 90.6% accurate, 0.4× speedup?

\[\begin{array}{l} A_m = \left|A\right| \\ V_m = \left|V\right| \\ l_m = \left|\ell\right| \\ c0\_m = \left|c0\right| \\ c0\_s = \mathsf{copysign}\left(1, c0\right) \\ [c0_m, A_m, V_m, l_m] = \mathsf{sort}([c0_m, A_m, V_m, l_m])\\ \\ \begin{array}{l} t_0 := \frac{c0\_m}{\sqrt{\frac{l\_m}{\frac{A\_m}{V\_m}}}}\\ c0\_s \cdot \begin{array}{l} \mathbf{if}\;V\_m \cdot l\_m \leq 5 \cdot 10^{-316}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;V\_m \cdot l\_m \leq 4 \cdot 10^{+297}:\\ \;\;\;\;c0\_m \cdot \frac{\sqrt{A\_m}}{\sqrt{l\_m \cdot V\_m}}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \end{array} \]
A_m = (fabs.f64 A)
V_m = (fabs.f64 V)
l_m = (fabs.f64 l)
c0\_m = (fabs.f64 c0)
c0\_s = (copysign.f64 #s(literal 1 binary64) c0)
NOTE: c0_m, A_m, V_m, and l_m should be sorted in increasing order before calling this function.
(FPCore (c0_s c0_m A_m V_m l_m)
 :precision binary64
 (let* ((t_0 (/ c0_m (sqrt (/ l_m (/ A_m V_m))))))
   (*
    c0_s
    (if (<= (* V_m l_m) 5e-316)
      t_0
      (if (<= (* V_m l_m) 4e+297)
        (* c0_m (/ (sqrt A_m) (sqrt (* l_m V_m))))
        t_0)))))
A_m = fabs(A);
V_m = fabs(V);
l_m = fabs(l);
c0\_m = fabs(c0);
c0\_s = copysign(1.0, c0);
assert(c0_m < A_m && A_m < V_m && V_m < l_m);
double code(double c0_s, double c0_m, double A_m, double V_m, double l_m) {
	double t_0 = c0_m / sqrt((l_m / (A_m / V_m)));
	double tmp;
	if ((V_m * l_m) <= 5e-316) {
		tmp = t_0;
	} else if ((V_m * l_m) <= 4e+297) {
		tmp = c0_m * (sqrt(A_m) / sqrt((l_m * V_m)));
	} else {
		tmp = t_0;
	}
	return c0_s * tmp;
}
A_m =     private
V_m =     private
l_m =     private
c0\_m =     private
c0\_s =     private
NOTE: c0_m, A_m, V_m, and l_m should be sorted in increasing order before calling this function.
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(c0_s, c0_m, a_m, v_m, l_m)
use fmin_fmax_functions
    real(8), intent (in) :: c0_s
    real(8), intent (in) :: c0_m
    real(8), intent (in) :: a_m
    real(8), intent (in) :: v_m
    real(8), intent (in) :: l_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = c0_m / sqrt((l_m / (a_m / v_m)))
    if ((v_m * l_m) <= 5d-316) then
        tmp = t_0
    else if ((v_m * l_m) <= 4d+297) then
        tmp = c0_m * (sqrt(a_m) / sqrt((l_m * v_m)))
    else
        tmp = t_0
    end if
    code = c0_s * tmp
end function
A_m = Math.abs(A);
V_m = Math.abs(V);
l_m = Math.abs(l);
c0\_m = Math.abs(c0);
c0\_s = Math.copySign(1.0, c0);
assert c0_m < A_m && A_m < V_m && V_m < l_m;
public static double code(double c0_s, double c0_m, double A_m, double V_m, double l_m) {
	double t_0 = c0_m / Math.sqrt((l_m / (A_m / V_m)));
	double tmp;
	if ((V_m * l_m) <= 5e-316) {
		tmp = t_0;
	} else if ((V_m * l_m) <= 4e+297) {
		tmp = c0_m * (Math.sqrt(A_m) / Math.sqrt((l_m * V_m)));
	} else {
		tmp = t_0;
	}
	return c0_s * tmp;
}
A_m = math.fabs(A)
V_m = math.fabs(V)
l_m = math.fabs(l)
c0\_m = math.fabs(c0)
c0\_s = math.copysign(1.0, c0)
[c0_m, A_m, V_m, l_m] = sort([c0_m, A_m, V_m, l_m])
def code(c0_s, c0_m, A_m, V_m, l_m):
	t_0 = c0_m / math.sqrt((l_m / (A_m / V_m)))
	tmp = 0
	if (V_m * l_m) <= 5e-316:
		tmp = t_0
	elif (V_m * l_m) <= 4e+297:
		tmp = c0_m * (math.sqrt(A_m) / math.sqrt((l_m * V_m)))
	else:
		tmp = t_0
	return c0_s * tmp
A_m = abs(A)
V_m = abs(V)
l_m = abs(l)
c0\_m = abs(c0)
c0\_s = copysign(1.0, c0)
c0_m, A_m, V_m, l_m = sort([c0_m, A_m, V_m, l_m])
function code(c0_s, c0_m, A_m, V_m, l_m)
	t_0 = Float64(c0_m / sqrt(Float64(l_m / Float64(A_m / V_m))))
	tmp = 0.0
	if (Float64(V_m * l_m) <= 5e-316)
		tmp = t_0;
	elseif (Float64(V_m * l_m) <= 4e+297)
		tmp = Float64(c0_m * Float64(sqrt(A_m) / sqrt(Float64(l_m * V_m))));
	else
		tmp = t_0;
	end
	return Float64(c0_s * tmp)
end
A_m = abs(A);
V_m = abs(V);
l_m = abs(l);
c0\_m = abs(c0);
c0\_s = sign(c0) * abs(1.0);
c0_m, A_m, V_m, l_m = num2cell(sort([c0_m, A_m, V_m, l_m])){:}
function tmp_2 = code(c0_s, c0_m, A_m, V_m, l_m)
	t_0 = c0_m / sqrt((l_m / (A_m / V_m)));
	tmp = 0.0;
	if ((V_m * l_m) <= 5e-316)
		tmp = t_0;
	elseif ((V_m * l_m) <= 4e+297)
		tmp = c0_m * (sqrt(A_m) / sqrt((l_m * V_m)));
	else
		tmp = t_0;
	end
	tmp_2 = c0_s * tmp;
end
A_m = N[Abs[A], $MachinePrecision]
V_m = N[Abs[V], $MachinePrecision]
l_m = N[Abs[l], $MachinePrecision]
c0\_m = N[Abs[c0], $MachinePrecision]
c0\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[c0]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: c0_m, A_m, V_m, and l_m should be sorted in increasing order before calling this function.
code[c0$95$s_, c0$95$m_, A$95$m_, V$95$m_, l$95$m_] := Block[{t$95$0 = N[(c0$95$m / N[Sqrt[N[(l$95$m / N[(A$95$m / V$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, N[(c0$95$s * If[LessEqual[N[(V$95$m * l$95$m), $MachinePrecision], 5e-316], t$95$0, If[LessEqual[N[(V$95$m * l$95$m), $MachinePrecision], 4e+297], N[(c0$95$m * N[(N[Sqrt[A$95$m], $MachinePrecision] / N[Sqrt[N[(l$95$m * V$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]), $MachinePrecision]]
\begin{array}{l}
A_m = \left|A\right|
\\
V_m = \left|V\right|
\\
l_m = \left|\ell\right|
\\
c0\_m = \left|c0\right|
\\
c0\_s = \mathsf{copysign}\left(1, c0\right)
\\
[c0_m, A_m, V_m, l_m] = \mathsf{sort}([c0_m, A_m, V_m, l_m])\\
\\
\begin{array}{l}
t_0 := \frac{c0\_m}{\sqrt{\frac{l\_m}{\frac{A\_m}{V\_m}}}}\\
c0\_s \cdot \begin{array}{l}
\mathbf{if}\;V\_m \cdot l\_m \leq 5 \cdot 10^{-316}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;V\_m \cdot l\_m \leq 4 \cdot 10^{+297}:\\
\;\;\;\;c0\_m \cdot \frac{\sqrt{A\_m}}{\sqrt{l\_m \cdot V\_m}}\\

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


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 V l) < 5.000000017e-316 or 4.0000000000000001e297 < (*.f64 V l)

    1. Initial program 73.9%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}} \]
      2. *-commutativeN/A

        \[\leadsto \color{blue}{\sqrt{\frac{A}{V \cdot \ell}} \cdot c0} \]
      3. lift-sqrt.f64N/A

        \[\leadsto \color{blue}{\sqrt{\frac{A}{V \cdot \ell}}} \cdot c0 \]
      4. lift-/.f64N/A

        \[\leadsto \sqrt{\color{blue}{\frac{A}{V \cdot \ell}}} \cdot c0 \]
      5. sqrt-divN/A

        \[\leadsto \color{blue}{\frac{\sqrt{A}}{\sqrt{V \cdot \ell}}} \cdot c0 \]
      6. associate-*l/N/A

        \[\leadsto \color{blue}{\frac{\sqrt{A} \cdot c0}{\sqrt{V \cdot \ell}}} \]
      7. lift-*.f64N/A

        \[\leadsto \frac{\sqrt{A} \cdot c0}{\sqrt{\color{blue}{V \cdot \ell}}} \]
      8. *-commutativeN/A

        \[\leadsto \frac{\sqrt{A} \cdot c0}{\sqrt{\color{blue}{\ell \cdot V}}} \]
      9. sqrt-prodN/A

        \[\leadsto \frac{\sqrt{A} \cdot c0}{\color{blue}{\sqrt{\ell} \cdot \sqrt{V}}} \]
      10. times-fracN/A

        \[\leadsto \color{blue}{\frac{\sqrt{A}}{\sqrt{\ell}} \cdot \frac{c0}{\sqrt{V}}} \]
      11. lower-*.f64N/A

        \[\leadsto \color{blue}{\frac{\sqrt{A}}{\sqrt{\ell}} \cdot \frac{c0}{\sqrt{V}}} \]
      12. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{\sqrt{A}}{\sqrt{\ell}}} \cdot \frac{c0}{\sqrt{V}} \]
      13. lower-sqrt.f64N/A

        \[\leadsto \frac{\color{blue}{\sqrt{A}}}{\sqrt{\ell}} \cdot \frac{c0}{\sqrt{V}} \]
      14. lower-sqrt.f64N/A

        \[\leadsto \frac{\sqrt{A}}{\color{blue}{\sqrt{\ell}}} \cdot \frac{c0}{\sqrt{V}} \]
      15. lower-/.f64N/A

        \[\leadsto \frac{\sqrt{A}}{\sqrt{\ell}} \cdot \color{blue}{\frac{c0}{\sqrt{V}}} \]
      16. lower-sqrt.f6494.9

        \[\leadsto \frac{\sqrt{A}}{\sqrt{\ell}} \cdot \frac{c0}{\color{blue}{\sqrt{V}}} \]
    3. Applied rewrites94.9%

      \[\leadsto \color{blue}{\frac{\sqrt{A}}{\sqrt{\ell}} \cdot \frac{c0}{\sqrt{V}}} \]
    4. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{\frac{\sqrt{A}}{\sqrt{\ell}} \cdot \frac{c0}{\sqrt{V}}} \]
      2. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{\sqrt{A}}{\sqrt{\ell}}} \cdot \frac{c0}{\sqrt{V}} \]
      3. lift-/.f64N/A

        \[\leadsto \frac{\sqrt{A}}{\sqrt{\ell}} \cdot \color{blue}{\frac{c0}{\sqrt{V}}} \]
      4. frac-timesN/A

        \[\leadsto \color{blue}{\frac{\sqrt{A} \cdot c0}{\sqrt{\ell} \cdot \sqrt{V}}} \]
      5. *-commutativeN/A

        \[\leadsto \frac{\color{blue}{c0 \cdot \sqrt{A}}}{\sqrt{\ell} \cdot \sqrt{V}} \]
      6. times-fracN/A

        \[\leadsto \color{blue}{\frac{c0}{\sqrt{\ell}} \cdot \frac{\sqrt{A}}{\sqrt{V}}} \]
      7. lift-sqrt.f64N/A

        \[\leadsto \frac{c0}{\sqrt{\ell}} \cdot \frac{\color{blue}{\sqrt{A}}}{\sqrt{V}} \]
      8. lift-sqrt.f64N/A

        \[\leadsto \frac{c0}{\sqrt{\ell}} \cdot \frac{\sqrt{A}}{\color{blue}{\sqrt{V}}} \]
      9. sqrt-divN/A

        \[\leadsto \frac{c0}{\sqrt{\ell}} \cdot \color{blue}{\sqrt{\frac{A}{V}}} \]
      10. lift-/.f64N/A

        \[\leadsto \frac{c0}{\sqrt{\ell}} \cdot \sqrt{\color{blue}{\frac{A}{V}}} \]
      11. lift-sqrt.f64N/A

        \[\leadsto \frac{c0}{\sqrt{\ell}} \cdot \color{blue}{\sqrt{\frac{A}{V}}} \]
      12. associate-*l/N/A

        \[\leadsto \color{blue}{\frac{c0 \cdot \sqrt{\frac{A}{V}}}{\sqrt{\ell}}} \]
      13. associate-/l*N/A

        \[\leadsto \color{blue}{c0 \cdot \frac{\sqrt{\frac{A}{V}}}{\sqrt{\ell}}} \]
      14. div-flipN/A

        \[\leadsto c0 \cdot \color{blue}{\frac{1}{\frac{\sqrt{\ell}}{\sqrt{\frac{A}{V}}}}} \]
      15. mult-flip-revN/A

        \[\leadsto \color{blue}{\frac{c0}{\frac{\sqrt{\ell}}{\sqrt{\frac{A}{V}}}}} \]
      16. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{c0}{\frac{\sqrt{\ell}}{\sqrt{\frac{A}{V}}}}} \]
      17. lift-sqrt.f64N/A

        \[\leadsto \frac{c0}{\frac{\color{blue}{\sqrt{\ell}}}{\sqrt{\frac{A}{V}}}} \]
      18. lift-sqrt.f64N/A

        \[\leadsto \frac{c0}{\frac{\sqrt{\ell}}{\color{blue}{\sqrt{\frac{A}{V}}}}} \]
      19. sqrt-divN/A

        \[\leadsto \frac{c0}{\color{blue}{\sqrt{\frac{\ell}{\frac{A}{V}}}}} \]
      20. lower-sqrt.f64N/A

        \[\leadsto \frac{c0}{\color{blue}{\sqrt{\frac{\ell}{\frac{A}{V}}}}} \]
      21. mult-flipN/A

        \[\leadsto \frac{c0}{\sqrt{\color{blue}{\ell \cdot \frac{1}{\frac{A}{V}}}}} \]
      22. lift-/.f64N/A

        \[\leadsto \frac{c0}{\sqrt{\ell \cdot \frac{1}{\color{blue}{\frac{A}{V}}}}} \]
      23. div-flipN/A

        \[\leadsto \frac{c0}{\sqrt{\ell \cdot \color{blue}{\frac{V}{A}}}} \]
      24. *-commutativeN/A

        \[\leadsto \frac{c0}{\sqrt{\color{blue}{\frac{V}{A} \cdot \ell}}} \]
      25. lower-*.f64N/A

        \[\leadsto \frac{c0}{\sqrt{\color{blue}{\frac{V}{A} \cdot \ell}}} \]
      26. lower-/.f6474.6

        \[\leadsto \frac{c0}{\sqrt{\color{blue}{\frac{V}{A}} \cdot \ell}} \]
    5. Applied rewrites74.6%

      \[\leadsto \color{blue}{\frac{c0}{\sqrt{\frac{V}{A} \cdot \ell}}} \]
    6. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{c0}{\sqrt{\color{blue}{\frac{V}{A} \cdot \ell}}} \]
      2. *-commutativeN/A

        \[\leadsto \frac{c0}{\sqrt{\color{blue}{\ell \cdot \frac{V}{A}}}} \]
      3. lift-/.f64N/A

        \[\leadsto \frac{c0}{\sqrt{\ell \cdot \color{blue}{\frac{V}{A}}}} \]
      4. div-flipN/A

        \[\leadsto \frac{c0}{\sqrt{\ell \cdot \color{blue}{\frac{1}{\frac{A}{V}}}}} \]
      5. mult-flip-revN/A

        \[\leadsto \frac{c0}{\sqrt{\color{blue}{\frac{\ell}{\frac{A}{V}}}}} \]
      6. lower-/.f64N/A

        \[\leadsto \frac{c0}{\sqrt{\color{blue}{\frac{\ell}{\frac{A}{V}}}}} \]
      7. lower-/.f6474.0

        \[\leadsto \frac{c0}{\sqrt{\frac{\ell}{\color{blue}{\frac{A}{V}}}}} \]
    7. Applied rewrites74.0%

      \[\leadsto \frac{c0}{\sqrt{\color{blue}{\frac{\ell}{\frac{A}{V}}}}} \]

    if 5.000000017e-316 < (*.f64 V l) < 4.0000000000000001e297

    1. Initial program 73.9%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Step-by-step derivation
      1. lift-sqrt.f64N/A

        \[\leadsto c0 \cdot \color{blue}{\sqrt{\frac{A}{V \cdot \ell}}} \]
      2. lift-/.f64N/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{A}{V \cdot \ell}}} \]
      3. sqrt-divN/A

        \[\leadsto c0 \cdot \color{blue}{\frac{\sqrt{A}}{\sqrt{V \cdot \ell}}} \]
      4. lower-/.f64N/A

        \[\leadsto c0 \cdot \color{blue}{\frac{\sqrt{A}}{\sqrt{V \cdot \ell}}} \]
      5. lower-sqrt.f64N/A

        \[\leadsto c0 \cdot \frac{\color{blue}{\sqrt{A}}}{\sqrt{V \cdot \ell}} \]
      6. lower-sqrt.f6483.8

        \[\leadsto c0 \cdot \frac{\sqrt{A}}{\color{blue}{\sqrt{V \cdot \ell}}} \]
      7. lift-*.f64N/A

        \[\leadsto c0 \cdot \frac{\sqrt{A}}{\sqrt{\color{blue}{V \cdot \ell}}} \]
      8. *-commutativeN/A

        \[\leadsto c0 \cdot \frac{\sqrt{A}}{\sqrt{\color{blue}{\ell \cdot V}}} \]
      9. lower-*.f6483.8

        \[\leadsto c0 \cdot \frac{\sqrt{A}}{\sqrt{\color{blue}{\ell \cdot V}}} \]
    3. Applied rewrites83.8%

      \[\leadsto c0 \cdot \color{blue}{\frac{\sqrt{A}}{\sqrt{\ell \cdot V}}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 5: 81.0% accurate, 0.5× speedup?

\[\begin{array}{l} A_m = \left|A\right| \\ V_m = \left|V\right| \\ l_m = \left|\ell\right| \\ c0\_m = \left|c0\right| \\ c0\_s = \mathsf{copysign}\left(1, c0\right) \\ [c0_m, A_m, V_m, l_m] = \mathsf{sort}([c0_m, A_m, V_m, l_m])\\ \\ c0\_s \cdot \begin{array}{l} \mathbf{if}\;\sqrt{\frac{A\_m}{V\_m \cdot l\_m}} \leq 3.6 \cdot 10^{+31}:\\ \;\;\;\;c0\_m \cdot \sqrt{\frac{\frac{A\_m}{V\_m}}{l\_m}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c0\_m}{\sqrt{\frac{V\_m}{\frac{A\_m}{l\_m}}}}\\ \end{array} \end{array} \]
A_m = (fabs.f64 A)
V_m = (fabs.f64 V)
l_m = (fabs.f64 l)
c0\_m = (fabs.f64 c0)
c0\_s = (copysign.f64 #s(literal 1 binary64) c0)
NOTE: c0_m, A_m, V_m, and l_m should be sorted in increasing order before calling this function.
(FPCore (c0_s c0_m A_m V_m l_m)
 :precision binary64
 (*
  c0_s
  (if (<= (sqrt (/ A_m (* V_m l_m))) 3.6e+31)
    (* c0_m (sqrt (/ (/ A_m V_m) l_m)))
    (/ c0_m (sqrt (/ V_m (/ A_m l_m)))))))
A_m = fabs(A);
V_m = fabs(V);
l_m = fabs(l);
c0\_m = fabs(c0);
c0\_s = copysign(1.0, c0);
assert(c0_m < A_m && A_m < V_m && V_m < l_m);
double code(double c0_s, double c0_m, double A_m, double V_m, double l_m) {
	double tmp;
	if (sqrt((A_m / (V_m * l_m))) <= 3.6e+31) {
		tmp = c0_m * sqrt(((A_m / V_m) / l_m));
	} else {
		tmp = c0_m / sqrt((V_m / (A_m / l_m)));
	}
	return c0_s * tmp;
}
A_m =     private
V_m =     private
l_m =     private
c0\_m =     private
c0\_s =     private
NOTE: c0_m, A_m, V_m, and l_m should be sorted in increasing order before calling this function.
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(c0_s, c0_m, a_m, v_m, l_m)
use fmin_fmax_functions
    real(8), intent (in) :: c0_s
    real(8), intent (in) :: c0_m
    real(8), intent (in) :: a_m
    real(8), intent (in) :: v_m
    real(8), intent (in) :: l_m
    real(8) :: tmp
    if (sqrt((a_m / (v_m * l_m))) <= 3.6d+31) then
        tmp = c0_m * sqrt(((a_m / v_m) / l_m))
    else
        tmp = c0_m / sqrt((v_m / (a_m / l_m)))
    end if
    code = c0_s * tmp
end function
A_m = Math.abs(A);
V_m = Math.abs(V);
l_m = Math.abs(l);
c0\_m = Math.abs(c0);
c0\_s = Math.copySign(1.0, c0);
assert c0_m < A_m && A_m < V_m && V_m < l_m;
public static double code(double c0_s, double c0_m, double A_m, double V_m, double l_m) {
	double tmp;
	if (Math.sqrt((A_m / (V_m * l_m))) <= 3.6e+31) {
		tmp = c0_m * Math.sqrt(((A_m / V_m) / l_m));
	} else {
		tmp = c0_m / Math.sqrt((V_m / (A_m / l_m)));
	}
	return c0_s * tmp;
}
A_m = math.fabs(A)
V_m = math.fabs(V)
l_m = math.fabs(l)
c0\_m = math.fabs(c0)
c0\_s = math.copysign(1.0, c0)
[c0_m, A_m, V_m, l_m] = sort([c0_m, A_m, V_m, l_m])
def code(c0_s, c0_m, A_m, V_m, l_m):
	tmp = 0
	if math.sqrt((A_m / (V_m * l_m))) <= 3.6e+31:
		tmp = c0_m * math.sqrt(((A_m / V_m) / l_m))
	else:
		tmp = c0_m / math.sqrt((V_m / (A_m / l_m)))
	return c0_s * tmp
A_m = abs(A)
V_m = abs(V)
l_m = abs(l)
c0\_m = abs(c0)
c0\_s = copysign(1.0, c0)
c0_m, A_m, V_m, l_m = sort([c0_m, A_m, V_m, l_m])
function code(c0_s, c0_m, A_m, V_m, l_m)
	tmp = 0.0
	if (sqrt(Float64(A_m / Float64(V_m * l_m))) <= 3.6e+31)
		tmp = Float64(c0_m * sqrt(Float64(Float64(A_m / V_m) / l_m)));
	else
		tmp = Float64(c0_m / sqrt(Float64(V_m / Float64(A_m / l_m))));
	end
	return Float64(c0_s * tmp)
end
A_m = abs(A);
V_m = abs(V);
l_m = abs(l);
c0\_m = abs(c0);
c0\_s = sign(c0) * abs(1.0);
c0_m, A_m, V_m, l_m = num2cell(sort([c0_m, A_m, V_m, l_m])){:}
function tmp_2 = code(c0_s, c0_m, A_m, V_m, l_m)
	tmp = 0.0;
	if (sqrt((A_m / (V_m * l_m))) <= 3.6e+31)
		tmp = c0_m * sqrt(((A_m / V_m) / l_m));
	else
		tmp = c0_m / sqrt((V_m / (A_m / l_m)));
	end
	tmp_2 = c0_s * tmp;
end
A_m = N[Abs[A], $MachinePrecision]
V_m = N[Abs[V], $MachinePrecision]
l_m = N[Abs[l], $MachinePrecision]
c0\_m = N[Abs[c0], $MachinePrecision]
c0\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[c0]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: c0_m, A_m, V_m, and l_m should be sorted in increasing order before calling this function.
code[c0$95$s_, c0$95$m_, A$95$m_, V$95$m_, l$95$m_] := N[(c0$95$s * If[LessEqual[N[Sqrt[N[(A$95$m / N[(V$95$m * l$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 3.6e+31], N[(c0$95$m * N[Sqrt[N[(N[(A$95$m / V$95$m), $MachinePrecision] / l$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(c0$95$m / N[Sqrt[N[(V$95$m / N[(A$95$m / l$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
A_m = \left|A\right|
\\
V_m = \left|V\right|
\\
l_m = \left|\ell\right|
\\
c0\_m = \left|c0\right|
\\
c0\_s = \mathsf{copysign}\left(1, c0\right)
\\
[c0_m, A_m, V_m, l_m] = \mathsf{sort}([c0_m, A_m, V_m, l_m])\\
\\
c0\_s \cdot \begin{array}{l}
\mathbf{if}\;\sqrt{\frac{A\_m}{V\_m \cdot l\_m}} \leq 3.6 \cdot 10^{+31}:\\
\;\;\;\;c0\_m \cdot \sqrt{\frac{\frac{A\_m}{V\_m}}{l\_m}}\\

\mathbf{else}:\\
\;\;\;\;\frac{c0\_m}{\sqrt{\frac{V\_m}{\frac{A\_m}{l\_m}}}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (sqrt.f64 (/.f64 A (*.f64 V l))) < 3.59999999999999996e31

    1. Initial program 73.9%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{A}{V \cdot \ell}}} \]
      2. lift-*.f64N/A

        \[\leadsto c0 \cdot \sqrt{\frac{A}{\color{blue}{V \cdot \ell}}} \]
      3. associate-/r*N/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{A}{V}}{\ell}}} \]
      4. lower-/.f64N/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{A}{V}}{\ell}}} \]
      5. lower-/.f6474.4

        \[\leadsto c0 \cdot \sqrt{\frac{\color{blue}{\frac{A}{V}}}{\ell}} \]
    3. Applied rewrites74.4%

      \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{A}{V}}{\ell}}} \]

    if 3.59999999999999996e31 < (sqrt.f64 (/.f64 A (*.f64 V l)))

    1. Initial program 73.9%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}} \]
      2. *-commutativeN/A

        \[\leadsto \color{blue}{\sqrt{\frac{A}{V \cdot \ell}} \cdot c0} \]
      3. lift-sqrt.f64N/A

        \[\leadsto \color{blue}{\sqrt{\frac{A}{V \cdot \ell}}} \cdot c0 \]
      4. lift-/.f64N/A

        \[\leadsto \sqrt{\color{blue}{\frac{A}{V \cdot \ell}}} \cdot c0 \]
      5. sqrt-divN/A

        \[\leadsto \color{blue}{\frac{\sqrt{A}}{\sqrt{V \cdot \ell}}} \cdot c0 \]
      6. associate-*l/N/A

        \[\leadsto \color{blue}{\frac{\sqrt{A} \cdot c0}{\sqrt{V \cdot \ell}}} \]
      7. lift-*.f64N/A

        \[\leadsto \frac{\sqrt{A} \cdot c0}{\sqrt{\color{blue}{V \cdot \ell}}} \]
      8. *-commutativeN/A

        \[\leadsto \frac{\sqrt{A} \cdot c0}{\sqrt{\color{blue}{\ell \cdot V}}} \]
      9. sqrt-prodN/A

        \[\leadsto \frac{\sqrt{A} \cdot c0}{\color{blue}{\sqrt{\ell} \cdot \sqrt{V}}} \]
      10. times-fracN/A

        \[\leadsto \color{blue}{\frac{\sqrt{A}}{\sqrt{\ell}} \cdot \frac{c0}{\sqrt{V}}} \]
      11. lower-*.f64N/A

        \[\leadsto \color{blue}{\frac{\sqrt{A}}{\sqrt{\ell}} \cdot \frac{c0}{\sqrt{V}}} \]
      12. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{\sqrt{A}}{\sqrt{\ell}}} \cdot \frac{c0}{\sqrt{V}} \]
      13. lower-sqrt.f64N/A

        \[\leadsto \frac{\color{blue}{\sqrt{A}}}{\sqrt{\ell}} \cdot \frac{c0}{\sqrt{V}} \]
      14. lower-sqrt.f64N/A

        \[\leadsto \frac{\sqrt{A}}{\color{blue}{\sqrt{\ell}}} \cdot \frac{c0}{\sqrt{V}} \]
      15. lower-/.f64N/A

        \[\leadsto \frac{\sqrt{A}}{\sqrt{\ell}} \cdot \color{blue}{\frac{c0}{\sqrt{V}}} \]
      16. lower-sqrt.f6494.9

        \[\leadsto \frac{\sqrt{A}}{\sqrt{\ell}} \cdot \frac{c0}{\color{blue}{\sqrt{V}}} \]
    3. Applied rewrites94.9%

      \[\leadsto \color{blue}{\frac{\sqrt{A}}{\sqrt{\ell}} \cdot \frac{c0}{\sqrt{V}}} \]
    4. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{\frac{\sqrt{A}}{\sqrt{\ell}} \cdot \frac{c0}{\sqrt{V}}} \]
      2. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{\sqrt{A}}{\sqrt{\ell}}} \cdot \frac{c0}{\sqrt{V}} \]
      3. lift-/.f64N/A

        \[\leadsto \frac{\sqrt{A}}{\sqrt{\ell}} \cdot \color{blue}{\frac{c0}{\sqrt{V}}} \]
      4. frac-timesN/A

        \[\leadsto \color{blue}{\frac{\sqrt{A} \cdot c0}{\sqrt{\ell} \cdot \sqrt{V}}} \]
      5. *-commutativeN/A

        \[\leadsto \frac{\color{blue}{c0 \cdot \sqrt{A}}}{\sqrt{\ell} \cdot \sqrt{V}} \]
      6. times-fracN/A

        \[\leadsto \color{blue}{\frac{c0}{\sqrt{\ell}} \cdot \frac{\sqrt{A}}{\sqrt{V}}} \]
      7. lift-sqrt.f64N/A

        \[\leadsto \frac{c0}{\sqrt{\ell}} \cdot \frac{\color{blue}{\sqrt{A}}}{\sqrt{V}} \]
      8. lift-sqrt.f64N/A

        \[\leadsto \frac{c0}{\sqrt{\ell}} \cdot \frac{\sqrt{A}}{\color{blue}{\sqrt{V}}} \]
      9. sqrt-divN/A

        \[\leadsto \frac{c0}{\sqrt{\ell}} \cdot \color{blue}{\sqrt{\frac{A}{V}}} \]
      10. lift-/.f64N/A

        \[\leadsto \frac{c0}{\sqrt{\ell}} \cdot \sqrt{\color{blue}{\frac{A}{V}}} \]
      11. lift-sqrt.f64N/A

        \[\leadsto \frac{c0}{\sqrt{\ell}} \cdot \color{blue}{\sqrt{\frac{A}{V}}} \]
      12. associate-*l/N/A

        \[\leadsto \color{blue}{\frac{c0 \cdot \sqrt{\frac{A}{V}}}{\sqrt{\ell}}} \]
      13. associate-/l*N/A

        \[\leadsto \color{blue}{c0 \cdot \frac{\sqrt{\frac{A}{V}}}{\sqrt{\ell}}} \]
      14. div-flipN/A

        \[\leadsto c0 \cdot \color{blue}{\frac{1}{\frac{\sqrt{\ell}}{\sqrt{\frac{A}{V}}}}} \]
      15. mult-flip-revN/A

        \[\leadsto \color{blue}{\frac{c0}{\frac{\sqrt{\ell}}{\sqrt{\frac{A}{V}}}}} \]
      16. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{c0}{\frac{\sqrt{\ell}}{\sqrt{\frac{A}{V}}}}} \]
      17. lift-sqrt.f64N/A

        \[\leadsto \frac{c0}{\frac{\color{blue}{\sqrt{\ell}}}{\sqrt{\frac{A}{V}}}} \]
      18. lift-sqrt.f64N/A

        \[\leadsto \frac{c0}{\frac{\sqrt{\ell}}{\color{blue}{\sqrt{\frac{A}{V}}}}} \]
      19. sqrt-divN/A

        \[\leadsto \frac{c0}{\color{blue}{\sqrt{\frac{\ell}{\frac{A}{V}}}}} \]
      20. lower-sqrt.f64N/A

        \[\leadsto \frac{c0}{\color{blue}{\sqrt{\frac{\ell}{\frac{A}{V}}}}} \]
      21. mult-flipN/A

        \[\leadsto \frac{c0}{\sqrt{\color{blue}{\ell \cdot \frac{1}{\frac{A}{V}}}}} \]
      22. lift-/.f64N/A

        \[\leadsto \frac{c0}{\sqrt{\ell \cdot \frac{1}{\color{blue}{\frac{A}{V}}}}} \]
      23. div-flipN/A

        \[\leadsto \frac{c0}{\sqrt{\ell \cdot \color{blue}{\frac{V}{A}}}} \]
      24. *-commutativeN/A

        \[\leadsto \frac{c0}{\sqrt{\color{blue}{\frac{V}{A} \cdot \ell}}} \]
      25. lower-*.f64N/A

        \[\leadsto \frac{c0}{\sqrt{\color{blue}{\frac{V}{A} \cdot \ell}}} \]
      26. lower-/.f6474.6

        \[\leadsto \frac{c0}{\sqrt{\color{blue}{\frac{V}{A}} \cdot \ell}} \]
    5. Applied rewrites74.6%

      \[\leadsto \color{blue}{\frac{c0}{\sqrt{\frac{V}{A} \cdot \ell}}} \]
    6. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{c0}{\sqrt{\color{blue}{\frac{V}{A} \cdot \ell}}} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{c0}{\sqrt{\color{blue}{\frac{V}{A}} \cdot \ell}} \]
      3. associate-*l/N/A

        \[\leadsto \frac{c0}{\sqrt{\color{blue}{\frac{V \cdot \ell}{A}}}} \]
      4. associate-/l*N/A

        \[\leadsto \frac{c0}{\sqrt{\color{blue}{V \cdot \frac{\ell}{A}}}} \]
      5. div-flipN/A

        \[\leadsto \frac{c0}{\sqrt{V \cdot \color{blue}{\frac{1}{\frac{A}{\ell}}}}} \]
      6. lift-/.f64N/A

        \[\leadsto \frac{c0}{\sqrt{V \cdot \frac{1}{\color{blue}{\frac{A}{\ell}}}}} \]
      7. mult-flip-revN/A

        \[\leadsto \frac{c0}{\sqrt{\color{blue}{\frac{V}{\frac{A}{\ell}}}}} \]
      8. lower-/.f6474.6

        \[\leadsto \frac{c0}{\sqrt{\color{blue}{\frac{V}{\frac{A}{\ell}}}}} \]
    7. Applied rewrites74.6%

      \[\leadsto \frac{c0}{\sqrt{\color{blue}{\frac{V}{\frac{A}{\ell}}}}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 6: 81.0% accurate, 0.7× speedup?

\[\begin{array}{l} A_m = \left|A\right| \\ V_m = \left|V\right| \\ l_m = \left|\ell\right| \\ c0\_m = \left|c0\right| \\ c0\_s = \mathsf{copysign}\left(1, c0\right) \\ [c0_m, A_m, V_m, l_m] = \mathsf{sort}([c0_m, A_m, V_m, l_m])\\ \\ c0\_s \cdot \begin{array}{l} \mathbf{if}\;A\_m \leq 2 \cdot 10^{-38}:\\ \;\;\;\;\frac{c0\_m}{\sqrt{\frac{V\_m}{A\_m} \cdot l\_m}}\\ \mathbf{else}:\\ \;\;\;\;c0\_m \cdot \sqrt{\frac{\frac{A\_m}{l\_m}}{V\_m}}\\ \end{array} \end{array} \]
A_m = (fabs.f64 A)
V_m = (fabs.f64 V)
l_m = (fabs.f64 l)
c0\_m = (fabs.f64 c0)
c0\_s = (copysign.f64 #s(literal 1 binary64) c0)
NOTE: c0_m, A_m, V_m, and l_m should be sorted in increasing order before calling this function.
(FPCore (c0_s c0_m A_m V_m l_m)
 :precision binary64
 (*
  c0_s
  (if (<= A_m 2e-38)
    (/ c0_m (sqrt (* (/ V_m A_m) l_m)))
    (* c0_m (sqrt (/ (/ A_m l_m) V_m))))))
A_m = fabs(A);
V_m = fabs(V);
l_m = fabs(l);
c0\_m = fabs(c0);
c0\_s = copysign(1.0, c0);
assert(c0_m < A_m && A_m < V_m && V_m < l_m);
double code(double c0_s, double c0_m, double A_m, double V_m, double l_m) {
	double tmp;
	if (A_m <= 2e-38) {
		tmp = c0_m / sqrt(((V_m / A_m) * l_m));
	} else {
		tmp = c0_m * sqrt(((A_m / l_m) / V_m));
	}
	return c0_s * tmp;
}
A_m =     private
V_m =     private
l_m =     private
c0\_m =     private
c0\_s =     private
NOTE: c0_m, A_m, V_m, and l_m should be sorted in increasing order before calling this function.
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(c0_s, c0_m, a_m, v_m, l_m)
use fmin_fmax_functions
    real(8), intent (in) :: c0_s
    real(8), intent (in) :: c0_m
    real(8), intent (in) :: a_m
    real(8), intent (in) :: v_m
    real(8), intent (in) :: l_m
    real(8) :: tmp
    if (a_m <= 2d-38) then
        tmp = c0_m / sqrt(((v_m / a_m) * l_m))
    else
        tmp = c0_m * sqrt(((a_m / l_m) / v_m))
    end if
    code = c0_s * tmp
end function
A_m = Math.abs(A);
V_m = Math.abs(V);
l_m = Math.abs(l);
c0\_m = Math.abs(c0);
c0\_s = Math.copySign(1.0, c0);
assert c0_m < A_m && A_m < V_m && V_m < l_m;
public static double code(double c0_s, double c0_m, double A_m, double V_m, double l_m) {
	double tmp;
	if (A_m <= 2e-38) {
		tmp = c0_m / Math.sqrt(((V_m / A_m) * l_m));
	} else {
		tmp = c0_m * Math.sqrt(((A_m / l_m) / V_m));
	}
	return c0_s * tmp;
}
A_m = math.fabs(A)
V_m = math.fabs(V)
l_m = math.fabs(l)
c0\_m = math.fabs(c0)
c0\_s = math.copysign(1.0, c0)
[c0_m, A_m, V_m, l_m] = sort([c0_m, A_m, V_m, l_m])
def code(c0_s, c0_m, A_m, V_m, l_m):
	tmp = 0
	if A_m <= 2e-38:
		tmp = c0_m / math.sqrt(((V_m / A_m) * l_m))
	else:
		tmp = c0_m * math.sqrt(((A_m / l_m) / V_m))
	return c0_s * tmp
A_m = abs(A)
V_m = abs(V)
l_m = abs(l)
c0\_m = abs(c0)
c0\_s = copysign(1.0, c0)
c0_m, A_m, V_m, l_m = sort([c0_m, A_m, V_m, l_m])
function code(c0_s, c0_m, A_m, V_m, l_m)
	tmp = 0.0
	if (A_m <= 2e-38)
		tmp = Float64(c0_m / sqrt(Float64(Float64(V_m / A_m) * l_m)));
	else
		tmp = Float64(c0_m * sqrt(Float64(Float64(A_m / l_m) / V_m)));
	end
	return Float64(c0_s * tmp)
end
A_m = abs(A);
V_m = abs(V);
l_m = abs(l);
c0\_m = abs(c0);
c0\_s = sign(c0) * abs(1.0);
c0_m, A_m, V_m, l_m = num2cell(sort([c0_m, A_m, V_m, l_m])){:}
function tmp_2 = code(c0_s, c0_m, A_m, V_m, l_m)
	tmp = 0.0;
	if (A_m <= 2e-38)
		tmp = c0_m / sqrt(((V_m / A_m) * l_m));
	else
		tmp = c0_m * sqrt(((A_m / l_m) / V_m));
	end
	tmp_2 = c0_s * tmp;
end
A_m = N[Abs[A], $MachinePrecision]
V_m = N[Abs[V], $MachinePrecision]
l_m = N[Abs[l], $MachinePrecision]
c0\_m = N[Abs[c0], $MachinePrecision]
c0\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[c0]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: c0_m, A_m, V_m, and l_m should be sorted in increasing order before calling this function.
code[c0$95$s_, c0$95$m_, A$95$m_, V$95$m_, l$95$m_] := N[(c0$95$s * If[LessEqual[A$95$m, 2e-38], N[(c0$95$m / N[Sqrt[N[(N[(V$95$m / A$95$m), $MachinePrecision] * l$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(c0$95$m * N[Sqrt[N[(N[(A$95$m / l$95$m), $MachinePrecision] / V$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
A_m = \left|A\right|
\\
V_m = \left|V\right|
\\
l_m = \left|\ell\right|
\\
c0\_m = \left|c0\right|
\\
c0\_s = \mathsf{copysign}\left(1, c0\right)
\\
[c0_m, A_m, V_m, l_m] = \mathsf{sort}([c0_m, A_m, V_m, l_m])\\
\\
c0\_s \cdot \begin{array}{l}
\mathbf{if}\;A\_m \leq 2 \cdot 10^{-38}:\\
\;\;\;\;\frac{c0\_m}{\sqrt{\frac{V\_m}{A\_m} \cdot l\_m}}\\

\mathbf{else}:\\
\;\;\;\;c0\_m \cdot \sqrt{\frac{\frac{A\_m}{l\_m}}{V\_m}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if A < 1.9999999999999999e-38

    1. Initial program 73.9%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}} \]
      2. *-commutativeN/A

        \[\leadsto \color{blue}{\sqrt{\frac{A}{V \cdot \ell}} \cdot c0} \]
      3. lift-sqrt.f64N/A

        \[\leadsto \color{blue}{\sqrt{\frac{A}{V \cdot \ell}}} \cdot c0 \]
      4. lift-/.f64N/A

        \[\leadsto \sqrt{\color{blue}{\frac{A}{V \cdot \ell}}} \cdot c0 \]
      5. sqrt-divN/A

        \[\leadsto \color{blue}{\frac{\sqrt{A}}{\sqrt{V \cdot \ell}}} \cdot c0 \]
      6. associate-*l/N/A

        \[\leadsto \color{blue}{\frac{\sqrt{A} \cdot c0}{\sqrt{V \cdot \ell}}} \]
      7. lift-*.f64N/A

        \[\leadsto \frac{\sqrt{A} \cdot c0}{\sqrt{\color{blue}{V \cdot \ell}}} \]
      8. *-commutativeN/A

        \[\leadsto \frac{\sqrt{A} \cdot c0}{\sqrt{\color{blue}{\ell \cdot V}}} \]
      9. sqrt-prodN/A

        \[\leadsto \frac{\sqrt{A} \cdot c0}{\color{blue}{\sqrt{\ell} \cdot \sqrt{V}}} \]
      10. times-fracN/A

        \[\leadsto \color{blue}{\frac{\sqrt{A}}{\sqrt{\ell}} \cdot \frac{c0}{\sqrt{V}}} \]
      11. lower-*.f64N/A

        \[\leadsto \color{blue}{\frac{\sqrt{A}}{\sqrt{\ell}} \cdot \frac{c0}{\sqrt{V}}} \]
      12. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{\sqrt{A}}{\sqrt{\ell}}} \cdot \frac{c0}{\sqrt{V}} \]
      13. lower-sqrt.f64N/A

        \[\leadsto \frac{\color{blue}{\sqrt{A}}}{\sqrt{\ell}} \cdot \frac{c0}{\sqrt{V}} \]
      14. lower-sqrt.f64N/A

        \[\leadsto \frac{\sqrt{A}}{\color{blue}{\sqrt{\ell}}} \cdot \frac{c0}{\sqrt{V}} \]
      15. lower-/.f64N/A

        \[\leadsto \frac{\sqrt{A}}{\sqrt{\ell}} \cdot \color{blue}{\frac{c0}{\sqrt{V}}} \]
      16. lower-sqrt.f6494.9

        \[\leadsto \frac{\sqrt{A}}{\sqrt{\ell}} \cdot \frac{c0}{\color{blue}{\sqrt{V}}} \]
    3. Applied rewrites94.9%

      \[\leadsto \color{blue}{\frac{\sqrt{A}}{\sqrt{\ell}} \cdot \frac{c0}{\sqrt{V}}} \]
    4. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{\frac{\sqrt{A}}{\sqrt{\ell}} \cdot \frac{c0}{\sqrt{V}}} \]
      2. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{\sqrt{A}}{\sqrt{\ell}}} \cdot \frac{c0}{\sqrt{V}} \]
      3. lift-/.f64N/A

        \[\leadsto \frac{\sqrt{A}}{\sqrt{\ell}} \cdot \color{blue}{\frac{c0}{\sqrt{V}}} \]
      4. frac-timesN/A

        \[\leadsto \color{blue}{\frac{\sqrt{A} \cdot c0}{\sqrt{\ell} \cdot \sqrt{V}}} \]
      5. *-commutativeN/A

        \[\leadsto \frac{\color{blue}{c0 \cdot \sqrt{A}}}{\sqrt{\ell} \cdot \sqrt{V}} \]
      6. times-fracN/A

        \[\leadsto \color{blue}{\frac{c0}{\sqrt{\ell}} \cdot \frac{\sqrt{A}}{\sqrt{V}}} \]
      7. lift-sqrt.f64N/A

        \[\leadsto \frac{c0}{\sqrt{\ell}} \cdot \frac{\color{blue}{\sqrt{A}}}{\sqrt{V}} \]
      8. lift-sqrt.f64N/A

        \[\leadsto \frac{c0}{\sqrt{\ell}} \cdot \frac{\sqrt{A}}{\color{blue}{\sqrt{V}}} \]
      9. sqrt-divN/A

        \[\leadsto \frac{c0}{\sqrt{\ell}} \cdot \color{blue}{\sqrt{\frac{A}{V}}} \]
      10. lift-/.f64N/A

        \[\leadsto \frac{c0}{\sqrt{\ell}} \cdot \sqrt{\color{blue}{\frac{A}{V}}} \]
      11. lift-sqrt.f64N/A

        \[\leadsto \frac{c0}{\sqrt{\ell}} \cdot \color{blue}{\sqrt{\frac{A}{V}}} \]
      12. associate-*l/N/A

        \[\leadsto \color{blue}{\frac{c0 \cdot \sqrt{\frac{A}{V}}}{\sqrt{\ell}}} \]
      13. associate-/l*N/A

        \[\leadsto \color{blue}{c0 \cdot \frac{\sqrt{\frac{A}{V}}}{\sqrt{\ell}}} \]
      14. div-flipN/A

        \[\leadsto c0 \cdot \color{blue}{\frac{1}{\frac{\sqrt{\ell}}{\sqrt{\frac{A}{V}}}}} \]
      15. mult-flip-revN/A

        \[\leadsto \color{blue}{\frac{c0}{\frac{\sqrt{\ell}}{\sqrt{\frac{A}{V}}}}} \]
      16. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{c0}{\frac{\sqrt{\ell}}{\sqrt{\frac{A}{V}}}}} \]
      17. lift-sqrt.f64N/A

        \[\leadsto \frac{c0}{\frac{\color{blue}{\sqrt{\ell}}}{\sqrt{\frac{A}{V}}}} \]
      18. lift-sqrt.f64N/A

        \[\leadsto \frac{c0}{\frac{\sqrt{\ell}}{\color{blue}{\sqrt{\frac{A}{V}}}}} \]
      19. sqrt-divN/A

        \[\leadsto \frac{c0}{\color{blue}{\sqrt{\frac{\ell}{\frac{A}{V}}}}} \]
      20. lower-sqrt.f64N/A

        \[\leadsto \frac{c0}{\color{blue}{\sqrt{\frac{\ell}{\frac{A}{V}}}}} \]
      21. mult-flipN/A

        \[\leadsto \frac{c0}{\sqrt{\color{blue}{\ell \cdot \frac{1}{\frac{A}{V}}}}} \]
      22. lift-/.f64N/A

        \[\leadsto \frac{c0}{\sqrt{\ell \cdot \frac{1}{\color{blue}{\frac{A}{V}}}}} \]
      23. div-flipN/A

        \[\leadsto \frac{c0}{\sqrt{\ell \cdot \color{blue}{\frac{V}{A}}}} \]
      24. *-commutativeN/A

        \[\leadsto \frac{c0}{\sqrt{\color{blue}{\frac{V}{A} \cdot \ell}}} \]
      25. lower-*.f64N/A

        \[\leadsto \frac{c0}{\sqrt{\color{blue}{\frac{V}{A} \cdot \ell}}} \]
      26. lower-/.f6474.6

        \[\leadsto \frac{c0}{\sqrt{\color{blue}{\frac{V}{A}} \cdot \ell}} \]
    5. Applied rewrites74.6%

      \[\leadsto \color{blue}{\frac{c0}{\sqrt{\frac{V}{A} \cdot \ell}}} \]

    if 1.9999999999999999e-38 < A

    1. Initial program 73.9%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{A}{V \cdot \ell}}} \]
      2. lift-*.f64N/A

        \[\leadsto c0 \cdot \sqrt{\frac{A}{\color{blue}{V \cdot \ell}}} \]
      3. *-commutativeN/A

        \[\leadsto c0 \cdot \sqrt{\frac{A}{\color{blue}{\ell \cdot V}}} \]
      4. associate-/r*N/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{A}{\ell}}{V}}} \]
      5. lower-/.f64N/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{A}{\ell}}{V}}} \]
      6. lower-/.f6474.5

        \[\leadsto c0 \cdot \sqrt{\frac{\color{blue}{\frac{A}{\ell}}}{V}} \]
    3. Applied rewrites74.5%

      \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{A}{\ell}}{V}}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 7: 80.8% accurate, 0.7× speedup?

\[\begin{array}{l} A_m = \left|A\right| \\ V_m = \left|V\right| \\ l_m = \left|\ell\right| \\ c0\_m = \left|c0\right| \\ c0\_s = \mathsf{copysign}\left(1, c0\right) \\ [c0_m, A_m, V_m, l_m] = \mathsf{sort}([c0_m, A_m, V_m, l_m])\\ \\ c0\_s \cdot \begin{array}{l} \mathbf{if}\;A\_m \leq 2.8 \cdot 10^{-34}:\\ \;\;\;\;c0\_m \cdot \sqrt{\frac{\frac{A\_m}{V\_m}}{l\_m}}\\ \mathbf{else}:\\ \;\;\;\;c0\_m \cdot \sqrt{\frac{\frac{A\_m}{l\_m}}{V\_m}}\\ \end{array} \end{array} \]
A_m = (fabs.f64 A)
V_m = (fabs.f64 V)
l_m = (fabs.f64 l)
c0\_m = (fabs.f64 c0)
c0\_s = (copysign.f64 #s(literal 1 binary64) c0)
NOTE: c0_m, A_m, V_m, and l_m should be sorted in increasing order before calling this function.
(FPCore (c0_s c0_m A_m V_m l_m)
 :precision binary64
 (*
  c0_s
  (if (<= A_m 2.8e-34)
    (* c0_m (sqrt (/ (/ A_m V_m) l_m)))
    (* c0_m (sqrt (/ (/ A_m l_m) V_m))))))
A_m = fabs(A);
V_m = fabs(V);
l_m = fabs(l);
c0\_m = fabs(c0);
c0\_s = copysign(1.0, c0);
assert(c0_m < A_m && A_m < V_m && V_m < l_m);
double code(double c0_s, double c0_m, double A_m, double V_m, double l_m) {
	double tmp;
	if (A_m <= 2.8e-34) {
		tmp = c0_m * sqrt(((A_m / V_m) / l_m));
	} else {
		tmp = c0_m * sqrt(((A_m / l_m) / V_m));
	}
	return c0_s * tmp;
}
A_m =     private
V_m =     private
l_m =     private
c0\_m =     private
c0\_s =     private
NOTE: c0_m, A_m, V_m, and l_m should be sorted in increasing order before calling this function.
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(c0_s, c0_m, a_m, v_m, l_m)
use fmin_fmax_functions
    real(8), intent (in) :: c0_s
    real(8), intent (in) :: c0_m
    real(8), intent (in) :: a_m
    real(8), intent (in) :: v_m
    real(8), intent (in) :: l_m
    real(8) :: tmp
    if (a_m <= 2.8d-34) then
        tmp = c0_m * sqrt(((a_m / v_m) / l_m))
    else
        tmp = c0_m * sqrt(((a_m / l_m) / v_m))
    end if
    code = c0_s * tmp
end function
A_m = Math.abs(A);
V_m = Math.abs(V);
l_m = Math.abs(l);
c0\_m = Math.abs(c0);
c0\_s = Math.copySign(1.0, c0);
assert c0_m < A_m && A_m < V_m && V_m < l_m;
public static double code(double c0_s, double c0_m, double A_m, double V_m, double l_m) {
	double tmp;
	if (A_m <= 2.8e-34) {
		tmp = c0_m * Math.sqrt(((A_m / V_m) / l_m));
	} else {
		tmp = c0_m * Math.sqrt(((A_m / l_m) / V_m));
	}
	return c0_s * tmp;
}
A_m = math.fabs(A)
V_m = math.fabs(V)
l_m = math.fabs(l)
c0\_m = math.fabs(c0)
c0\_s = math.copysign(1.0, c0)
[c0_m, A_m, V_m, l_m] = sort([c0_m, A_m, V_m, l_m])
def code(c0_s, c0_m, A_m, V_m, l_m):
	tmp = 0
	if A_m <= 2.8e-34:
		tmp = c0_m * math.sqrt(((A_m / V_m) / l_m))
	else:
		tmp = c0_m * math.sqrt(((A_m / l_m) / V_m))
	return c0_s * tmp
A_m = abs(A)
V_m = abs(V)
l_m = abs(l)
c0\_m = abs(c0)
c0\_s = copysign(1.0, c0)
c0_m, A_m, V_m, l_m = sort([c0_m, A_m, V_m, l_m])
function code(c0_s, c0_m, A_m, V_m, l_m)
	tmp = 0.0
	if (A_m <= 2.8e-34)
		tmp = Float64(c0_m * sqrt(Float64(Float64(A_m / V_m) / l_m)));
	else
		tmp = Float64(c0_m * sqrt(Float64(Float64(A_m / l_m) / V_m)));
	end
	return Float64(c0_s * tmp)
end
A_m = abs(A);
V_m = abs(V);
l_m = abs(l);
c0\_m = abs(c0);
c0\_s = sign(c0) * abs(1.0);
c0_m, A_m, V_m, l_m = num2cell(sort([c0_m, A_m, V_m, l_m])){:}
function tmp_2 = code(c0_s, c0_m, A_m, V_m, l_m)
	tmp = 0.0;
	if (A_m <= 2.8e-34)
		tmp = c0_m * sqrt(((A_m / V_m) / l_m));
	else
		tmp = c0_m * sqrt(((A_m / l_m) / V_m));
	end
	tmp_2 = c0_s * tmp;
end
A_m = N[Abs[A], $MachinePrecision]
V_m = N[Abs[V], $MachinePrecision]
l_m = N[Abs[l], $MachinePrecision]
c0\_m = N[Abs[c0], $MachinePrecision]
c0\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[c0]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: c0_m, A_m, V_m, and l_m should be sorted in increasing order before calling this function.
code[c0$95$s_, c0$95$m_, A$95$m_, V$95$m_, l$95$m_] := N[(c0$95$s * If[LessEqual[A$95$m, 2.8e-34], N[(c0$95$m * N[Sqrt[N[(N[(A$95$m / V$95$m), $MachinePrecision] / l$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(c0$95$m * N[Sqrt[N[(N[(A$95$m / l$95$m), $MachinePrecision] / V$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
A_m = \left|A\right|
\\
V_m = \left|V\right|
\\
l_m = \left|\ell\right|
\\
c0\_m = \left|c0\right|
\\
c0\_s = \mathsf{copysign}\left(1, c0\right)
\\
[c0_m, A_m, V_m, l_m] = \mathsf{sort}([c0_m, A_m, V_m, l_m])\\
\\
c0\_s \cdot \begin{array}{l}
\mathbf{if}\;A\_m \leq 2.8 \cdot 10^{-34}:\\
\;\;\;\;c0\_m \cdot \sqrt{\frac{\frac{A\_m}{V\_m}}{l\_m}}\\

\mathbf{else}:\\
\;\;\;\;c0\_m \cdot \sqrt{\frac{\frac{A\_m}{l\_m}}{V\_m}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if A < 2.79999999999999997e-34

    1. Initial program 73.9%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{A}{V \cdot \ell}}} \]
      2. lift-*.f64N/A

        \[\leadsto c0 \cdot \sqrt{\frac{A}{\color{blue}{V \cdot \ell}}} \]
      3. associate-/r*N/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{A}{V}}{\ell}}} \]
      4. lower-/.f64N/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{A}{V}}{\ell}}} \]
      5. lower-/.f6474.4

        \[\leadsto c0 \cdot \sqrt{\frac{\color{blue}{\frac{A}{V}}}{\ell}} \]
    3. Applied rewrites74.4%

      \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{A}{V}}{\ell}}} \]

    if 2.79999999999999997e-34 < A

    1. Initial program 73.9%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{A}{V \cdot \ell}}} \]
      2. lift-*.f64N/A

        \[\leadsto c0 \cdot \sqrt{\frac{A}{\color{blue}{V \cdot \ell}}} \]
      3. *-commutativeN/A

        \[\leadsto c0 \cdot \sqrt{\frac{A}{\color{blue}{\ell \cdot V}}} \]
      4. associate-/r*N/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{A}{\ell}}{V}}} \]
      5. lower-/.f64N/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{A}{\ell}}{V}}} \]
      6. lower-/.f6474.5

        \[\leadsto c0 \cdot \sqrt{\frac{\color{blue}{\frac{A}{\ell}}}{V}} \]
    3. Applied rewrites74.5%

      \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{A}{\ell}}{V}}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 8: 80.6% accurate, 0.5× speedup?

\[\begin{array}{l} A_m = \left|A\right| \\ V_m = \left|V\right| \\ l_m = \left|\ell\right| \\ c0\_m = \left|c0\right| \\ c0\_s = \mathsf{copysign}\left(1, c0\right) \\ [c0_m, A_m, V_m, l_m] = \mathsf{sort}([c0_m, A_m, V_m, l_m])\\ \\ \begin{array}{l} t_0 := c0\_m \cdot \sqrt{\frac{\frac{A\_m}{V\_m}}{l\_m}}\\ c0\_s \cdot \begin{array}{l} \mathbf{if}\;V\_m \cdot l\_m \leq 4 \cdot 10^{-219}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;V\_m \cdot l\_m \leq 5 \cdot 10^{+187}:\\ \;\;\;\;c0\_m \cdot \sqrt{\frac{A\_m}{V\_m \cdot l\_m}}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \end{array} \]
A_m = (fabs.f64 A)
V_m = (fabs.f64 V)
l_m = (fabs.f64 l)
c0\_m = (fabs.f64 c0)
c0\_s = (copysign.f64 #s(literal 1 binary64) c0)
NOTE: c0_m, A_m, V_m, and l_m should be sorted in increasing order before calling this function.
(FPCore (c0_s c0_m A_m V_m l_m)
 :precision binary64
 (let* ((t_0 (* c0_m (sqrt (/ (/ A_m V_m) l_m)))))
   (*
    c0_s
    (if (<= (* V_m l_m) 4e-219)
      t_0
      (if (<= (* V_m l_m) 5e+187) (* c0_m (sqrt (/ A_m (* V_m l_m)))) t_0)))))
A_m = fabs(A);
V_m = fabs(V);
l_m = fabs(l);
c0\_m = fabs(c0);
c0\_s = copysign(1.0, c0);
assert(c0_m < A_m && A_m < V_m && V_m < l_m);
double code(double c0_s, double c0_m, double A_m, double V_m, double l_m) {
	double t_0 = c0_m * sqrt(((A_m / V_m) / l_m));
	double tmp;
	if ((V_m * l_m) <= 4e-219) {
		tmp = t_0;
	} else if ((V_m * l_m) <= 5e+187) {
		tmp = c0_m * sqrt((A_m / (V_m * l_m)));
	} else {
		tmp = t_0;
	}
	return c0_s * tmp;
}
A_m =     private
V_m =     private
l_m =     private
c0\_m =     private
c0\_s =     private
NOTE: c0_m, A_m, V_m, and l_m should be sorted in increasing order before calling this function.
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(c0_s, c0_m, a_m, v_m, l_m)
use fmin_fmax_functions
    real(8), intent (in) :: c0_s
    real(8), intent (in) :: c0_m
    real(8), intent (in) :: a_m
    real(8), intent (in) :: v_m
    real(8), intent (in) :: l_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = c0_m * sqrt(((a_m / v_m) / l_m))
    if ((v_m * l_m) <= 4d-219) then
        tmp = t_0
    else if ((v_m * l_m) <= 5d+187) then
        tmp = c0_m * sqrt((a_m / (v_m * l_m)))
    else
        tmp = t_0
    end if
    code = c0_s * tmp
end function
A_m = Math.abs(A);
V_m = Math.abs(V);
l_m = Math.abs(l);
c0\_m = Math.abs(c0);
c0\_s = Math.copySign(1.0, c0);
assert c0_m < A_m && A_m < V_m && V_m < l_m;
public static double code(double c0_s, double c0_m, double A_m, double V_m, double l_m) {
	double t_0 = c0_m * Math.sqrt(((A_m / V_m) / l_m));
	double tmp;
	if ((V_m * l_m) <= 4e-219) {
		tmp = t_0;
	} else if ((V_m * l_m) <= 5e+187) {
		tmp = c0_m * Math.sqrt((A_m / (V_m * l_m)));
	} else {
		tmp = t_0;
	}
	return c0_s * tmp;
}
A_m = math.fabs(A)
V_m = math.fabs(V)
l_m = math.fabs(l)
c0\_m = math.fabs(c0)
c0\_s = math.copysign(1.0, c0)
[c0_m, A_m, V_m, l_m] = sort([c0_m, A_m, V_m, l_m])
def code(c0_s, c0_m, A_m, V_m, l_m):
	t_0 = c0_m * math.sqrt(((A_m / V_m) / l_m))
	tmp = 0
	if (V_m * l_m) <= 4e-219:
		tmp = t_0
	elif (V_m * l_m) <= 5e+187:
		tmp = c0_m * math.sqrt((A_m / (V_m * l_m)))
	else:
		tmp = t_0
	return c0_s * tmp
A_m = abs(A)
V_m = abs(V)
l_m = abs(l)
c0\_m = abs(c0)
c0\_s = copysign(1.0, c0)
c0_m, A_m, V_m, l_m = sort([c0_m, A_m, V_m, l_m])
function code(c0_s, c0_m, A_m, V_m, l_m)
	t_0 = Float64(c0_m * sqrt(Float64(Float64(A_m / V_m) / l_m)))
	tmp = 0.0
	if (Float64(V_m * l_m) <= 4e-219)
		tmp = t_0;
	elseif (Float64(V_m * l_m) <= 5e+187)
		tmp = Float64(c0_m * sqrt(Float64(A_m / Float64(V_m * l_m))));
	else
		tmp = t_0;
	end
	return Float64(c0_s * tmp)
end
A_m = abs(A);
V_m = abs(V);
l_m = abs(l);
c0\_m = abs(c0);
c0\_s = sign(c0) * abs(1.0);
c0_m, A_m, V_m, l_m = num2cell(sort([c0_m, A_m, V_m, l_m])){:}
function tmp_2 = code(c0_s, c0_m, A_m, V_m, l_m)
	t_0 = c0_m * sqrt(((A_m / V_m) / l_m));
	tmp = 0.0;
	if ((V_m * l_m) <= 4e-219)
		tmp = t_0;
	elseif ((V_m * l_m) <= 5e+187)
		tmp = c0_m * sqrt((A_m / (V_m * l_m)));
	else
		tmp = t_0;
	end
	tmp_2 = c0_s * tmp;
end
A_m = N[Abs[A], $MachinePrecision]
V_m = N[Abs[V], $MachinePrecision]
l_m = N[Abs[l], $MachinePrecision]
c0\_m = N[Abs[c0], $MachinePrecision]
c0\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[c0]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: c0_m, A_m, V_m, and l_m should be sorted in increasing order before calling this function.
code[c0$95$s_, c0$95$m_, A$95$m_, V$95$m_, l$95$m_] := Block[{t$95$0 = N[(c0$95$m * N[Sqrt[N[(N[(A$95$m / V$95$m), $MachinePrecision] / l$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, N[(c0$95$s * If[LessEqual[N[(V$95$m * l$95$m), $MachinePrecision], 4e-219], t$95$0, If[LessEqual[N[(V$95$m * l$95$m), $MachinePrecision], 5e+187], N[(c0$95$m * N[Sqrt[N[(A$95$m / N[(V$95$m * l$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$0]]), $MachinePrecision]]
\begin{array}{l}
A_m = \left|A\right|
\\
V_m = \left|V\right|
\\
l_m = \left|\ell\right|
\\
c0\_m = \left|c0\right|
\\
c0\_s = \mathsf{copysign}\left(1, c0\right)
\\
[c0_m, A_m, V_m, l_m] = \mathsf{sort}([c0_m, A_m, V_m, l_m])\\
\\
\begin{array}{l}
t_0 := c0\_m \cdot \sqrt{\frac{\frac{A\_m}{V\_m}}{l\_m}}\\
c0\_s \cdot \begin{array}{l}
\mathbf{if}\;V\_m \cdot l\_m \leq 4 \cdot 10^{-219}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;V\_m \cdot l\_m \leq 5 \cdot 10^{+187}:\\
\;\;\;\;c0\_m \cdot \sqrt{\frac{A\_m}{V\_m \cdot l\_m}}\\

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


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 V l) < 4.0000000000000001e-219 or 5.0000000000000001e187 < (*.f64 V l)

    1. Initial program 73.9%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{A}{V \cdot \ell}}} \]
      2. lift-*.f64N/A

        \[\leadsto c0 \cdot \sqrt{\frac{A}{\color{blue}{V \cdot \ell}}} \]
      3. associate-/r*N/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{A}{V}}{\ell}}} \]
      4. lower-/.f64N/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{A}{V}}{\ell}}} \]
      5. lower-/.f6474.4

        \[\leadsto c0 \cdot \sqrt{\frac{\color{blue}{\frac{A}{V}}}{\ell}} \]
    3. Applied rewrites74.4%

      \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{A}{V}}{\ell}}} \]

    if 4.0000000000000001e-219 < (*.f64 V l) < 5.0000000000000001e187

    1. Initial program 73.9%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 9: 73.9% accurate, 1.0× speedup?

\[\begin{array}{l} A_m = \left|A\right| \\ V_m = \left|V\right| \\ l_m = \left|\ell\right| \\ c0\_m = \left|c0\right| \\ c0\_s = \mathsf{copysign}\left(1, c0\right) \\ [c0_m, A_m, V_m, l_m] = \mathsf{sort}([c0_m, A_m, V_m, l_m])\\ \\ c0\_s \cdot \left(c0\_m \cdot \sqrt{\frac{A\_m}{V\_m \cdot l\_m}}\right) \end{array} \]
A_m = (fabs.f64 A)
V_m = (fabs.f64 V)
l_m = (fabs.f64 l)
c0\_m = (fabs.f64 c0)
c0\_s = (copysign.f64 #s(literal 1 binary64) c0)
NOTE: c0_m, A_m, V_m, and l_m should be sorted in increasing order before calling this function.
(FPCore (c0_s c0_m A_m V_m l_m)
 :precision binary64
 (* c0_s (* c0_m (sqrt (/ A_m (* V_m l_m))))))
A_m = fabs(A);
V_m = fabs(V);
l_m = fabs(l);
c0\_m = fabs(c0);
c0\_s = copysign(1.0, c0);
assert(c0_m < A_m && A_m < V_m && V_m < l_m);
double code(double c0_s, double c0_m, double A_m, double V_m, double l_m) {
	return c0_s * (c0_m * sqrt((A_m / (V_m * l_m))));
}
A_m =     private
V_m =     private
l_m =     private
c0\_m =     private
c0\_s =     private
NOTE: c0_m, A_m, V_m, and l_m should be sorted in increasing order before calling this function.
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(c0_s, c0_m, a_m, v_m, l_m)
use fmin_fmax_functions
    real(8), intent (in) :: c0_s
    real(8), intent (in) :: c0_m
    real(8), intent (in) :: a_m
    real(8), intent (in) :: v_m
    real(8), intent (in) :: l_m
    code = c0_s * (c0_m * sqrt((a_m / (v_m * l_m))))
end function
A_m = Math.abs(A);
V_m = Math.abs(V);
l_m = Math.abs(l);
c0\_m = Math.abs(c0);
c0\_s = Math.copySign(1.0, c0);
assert c0_m < A_m && A_m < V_m && V_m < l_m;
public static double code(double c0_s, double c0_m, double A_m, double V_m, double l_m) {
	return c0_s * (c0_m * Math.sqrt((A_m / (V_m * l_m))));
}
A_m = math.fabs(A)
V_m = math.fabs(V)
l_m = math.fabs(l)
c0\_m = math.fabs(c0)
c0\_s = math.copysign(1.0, c0)
[c0_m, A_m, V_m, l_m] = sort([c0_m, A_m, V_m, l_m])
def code(c0_s, c0_m, A_m, V_m, l_m):
	return c0_s * (c0_m * math.sqrt((A_m / (V_m * l_m))))
A_m = abs(A)
V_m = abs(V)
l_m = abs(l)
c0\_m = abs(c0)
c0\_s = copysign(1.0, c0)
c0_m, A_m, V_m, l_m = sort([c0_m, A_m, V_m, l_m])
function code(c0_s, c0_m, A_m, V_m, l_m)
	return Float64(c0_s * Float64(c0_m * sqrt(Float64(A_m / Float64(V_m * l_m)))))
end
A_m = abs(A);
V_m = abs(V);
l_m = abs(l);
c0\_m = abs(c0);
c0\_s = sign(c0) * abs(1.0);
c0_m, A_m, V_m, l_m = num2cell(sort([c0_m, A_m, V_m, l_m])){:}
function tmp = code(c0_s, c0_m, A_m, V_m, l_m)
	tmp = c0_s * (c0_m * sqrt((A_m / (V_m * l_m))));
end
A_m = N[Abs[A], $MachinePrecision]
V_m = N[Abs[V], $MachinePrecision]
l_m = N[Abs[l], $MachinePrecision]
c0\_m = N[Abs[c0], $MachinePrecision]
c0\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[c0]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: c0_m, A_m, V_m, and l_m should be sorted in increasing order before calling this function.
code[c0$95$s_, c0$95$m_, A$95$m_, V$95$m_, l$95$m_] := N[(c0$95$s * N[(c0$95$m * N[Sqrt[N[(A$95$m / N[(V$95$m * l$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
A_m = \left|A\right|
\\
V_m = \left|V\right|
\\
l_m = \left|\ell\right|
\\
c0\_m = \left|c0\right|
\\
c0\_s = \mathsf{copysign}\left(1, c0\right)
\\
[c0_m, A_m, V_m, l_m] = \mathsf{sort}([c0_m, A_m, V_m, l_m])\\
\\
c0\_s \cdot \left(c0\_m \cdot \sqrt{\frac{A\_m}{V\_m \cdot l\_m}}\right)
\end{array}
Derivation
  1. Initial program 73.9%

    \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
  2. Add Preprocessing

Reproduce

?
herbie shell --seed 2025144 
(FPCore (c0 A V l)
  :name "Henrywood and Agarwal, Equation (3)"
  :precision binary64
  (* c0 (sqrt (/ A (* V l)))))