Henrywood and Agarwal, Equation (3)

Percentage Accurate: 73.5% → 95.4%
Time: 4.3s
Alternatives: 7
Speedup: 0.8×

Specification

?
\[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
(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]
c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}

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 7 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.5% accurate, 1.0× speedup?

\[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
(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]
c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}

Alternative 1: 95.4% accurate, 0.3× speedup?

\[\begin{array}{l} t_0 := \mathsf{max}\left(\left|V\right|, \left|\ell\right|\right)\\ t_1 := \mathsf{min}\left(\left|V\right|, \left|\ell\right|\right)\\ \mathbf{if}\;\sqrt{\frac{\left|A\right|}{t\_1 \cdot t\_0}} \leq 1000:\\ \;\;\;\;c0 \cdot \frac{\sqrt{\frac{\left|A\right|}{t\_1}}}{\sqrt{t\_0}}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{\frac{\left|A\right|}{t\_0}}}{\sqrt{t\_1}}\\ \end{array} \]
(FPCore (c0 A V l)
 :precision binary64
 (let* ((t_0 (fmax (fabs V) (fabs l))) (t_1 (fmin (fabs V) (fabs l))))
   (if (<= (sqrt (/ (fabs A) (* t_1 t_0))) 1000.0)
     (* c0 (/ (sqrt (/ (fabs A) t_1)) (sqrt t_0)))
     (* c0 (/ (sqrt (/ (fabs A) t_0)) (sqrt t_1))))))
double code(double c0, double A, double V, double l) {
	double t_0 = fmax(fabs(V), fabs(l));
	double t_1 = fmin(fabs(V), fabs(l));
	double tmp;
	if (sqrt((fabs(A) / (t_1 * t_0))) <= 1000.0) {
		tmp = c0 * (sqrt((fabs(A) / t_1)) / sqrt(t_0));
	} else {
		tmp = c0 * (sqrt((fabs(A) / t_0)) / sqrt(t_1));
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(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
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = fmax(abs(v), abs(l))
    t_1 = fmin(abs(v), abs(l))
    if (sqrt((abs(a) / (t_1 * t_0))) <= 1000.0d0) then
        tmp = c0 * (sqrt((abs(a) / t_1)) / sqrt(t_0))
    else
        tmp = c0 * (sqrt((abs(a) / t_0)) / sqrt(t_1))
    end if
    code = tmp
end function
public static double code(double c0, double A, double V, double l) {
	double t_0 = fmax(Math.abs(V), Math.abs(l));
	double t_1 = fmin(Math.abs(V), Math.abs(l));
	double tmp;
	if (Math.sqrt((Math.abs(A) / (t_1 * t_0))) <= 1000.0) {
		tmp = c0 * (Math.sqrt((Math.abs(A) / t_1)) / Math.sqrt(t_0));
	} else {
		tmp = c0 * (Math.sqrt((Math.abs(A) / t_0)) / Math.sqrt(t_1));
	}
	return tmp;
}
def code(c0, A, V, l):
	t_0 = fmax(math.fabs(V), math.fabs(l))
	t_1 = fmin(math.fabs(V), math.fabs(l))
	tmp = 0
	if math.sqrt((math.fabs(A) / (t_1 * t_0))) <= 1000.0:
		tmp = c0 * (math.sqrt((math.fabs(A) / t_1)) / math.sqrt(t_0))
	else:
		tmp = c0 * (math.sqrt((math.fabs(A) / t_0)) / math.sqrt(t_1))
	return tmp
function code(c0, A, V, l)
	t_0 = fmax(abs(V), abs(l))
	t_1 = fmin(abs(V), abs(l))
	tmp = 0.0
	if (sqrt(Float64(abs(A) / Float64(t_1 * t_0))) <= 1000.0)
		tmp = Float64(c0 * Float64(sqrt(Float64(abs(A) / t_1)) / sqrt(t_0)));
	else
		tmp = Float64(c0 * Float64(sqrt(Float64(abs(A) / t_0)) / sqrt(t_1)));
	end
	return tmp
end
function tmp_2 = code(c0, A, V, l)
	t_0 = max(abs(V), abs(l));
	t_1 = min(abs(V), abs(l));
	tmp = 0.0;
	if (sqrt((abs(A) / (t_1 * t_0))) <= 1000.0)
		tmp = c0 * (sqrt((abs(A) / t_1)) / sqrt(t_0));
	else
		tmp = c0 * (sqrt((abs(A) / t_0)) / sqrt(t_1));
	end
	tmp_2 = tmp;
end
code[c0_, A_, V_, l_] := Block[{t$95$0 = N[Max[N[Abs[V], $MachinePrecision], N[Abs[l], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Min[N[Abs[V], $MachinePrecision], N[Abs[l], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Sqrt[N[(N[Abs[A], $MachinePrecision] / N[(t$95$1 * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 1000.0], N[(c0 * N[(N[Sqrt[N[(N[Abs[A], $MachinePrecision] / t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 * N[(N[Sqrt[N[(N[Abs[A], $MachinePrecision] / t$95$0), $MachinePrecision]], $MachinePrecision] / N[Sqrt[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
t_0 := \mathsf{max}\left(\left|V\right|, \left|\ell\right|\right)\\
t_1 := \mathsf{min}\left(\left|V\right|, \left|\ell\right|\right)\\
\mathbf{if}\;\sqrt{\frac{\left|A\right|}{t\_1 \cdot t\_0}} \leq 1000:\\
\;\;\;\;c0 \cdot \frac{\sqrt{\frac{\left|A\right|}{t\_1}}}{\sqrt{t\_0}}\\

\mathbf{else}:\\
\;\;\;\;c0 \cdot \frac{\sqrt{\frac{\left|A\right|}{t\_0}}}{\sqrt{t\_1}}\\


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

    1. Initial program 73.5%

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

        \[\leadsto c0 \cdot \color{blue}{\frac{\sqrt{\frac{A}{V}}}{\sqrt{\ell}}} \]
      7. lower-unsound-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-unsound-sqrt.f6441.4%

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

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

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

    1. Initial program 73.5%

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

        \[\leadsto c0 \cdot \color{blue}{\frac{\sqrt{\frac{A}{\ell}}}{\sqrt{V}}} \]
      8. lower-unsound-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-unsound-sqrt.f6441.8%

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

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

Alternative 2: 95.2% accurate, 0.2× speedup?

\[\begin{array}{l} t_0 := \mathsf{min}\left(\left|V\right|, \left|\ell\right|\right)\\ t_1 := \mathsf{max}\left(\left|V\right|, \left|\ell\right|\right)\\ t_2 := \sqrt{t\_1}\\ t_3 := t\_0 \cdot t\_1\\ t_4 := \sqrt{\frac{\left|A\right|}{t\_0}}\\ \mathbf{if}\;t\_3 \leq 5 \cdot 10^{-320}:\\ \;\;\;\;t\_4 \cdot \frac{c0}{t\_2}\\ \mathbf{elif}\;t\_3 \leq 10^{+257}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{\left|A\right|}}{\sqrt{t\_1 \cdot t\_0}}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \frac{t\_4}{t\_2}\\ \end{array} \]
(FPCore (c0 A V l)
 :precision binary64
 (let* ((t_0 (fmin (fabs V) (fabs l)))
        (t_1 (fmax (fabs V) (fabs l)))
        (t_2 (sqrt t_1))
        (t_3 (* t_0 t_1))
        (t_4 (sqrt (/ (fabs A) t_0))))
   (if (<= t_3 5e-320)
     (* t_4 (/ c0 t_2))
     (if (<= t_3 1e+257)
       (* c0 (/ (sqrt (fabs A)) (sqrt (* t_1 t_0))))
       (* c0 (/ t_4 t_2))))))
double code(double c0, double A, double V, double l) {
	double t_0 = fmin(fabs(V), fabs(l));
	double t_1 = fmax(fabs(V), fabs(l));
	double t_2 = sqrt(t_1);
	double t_3 = t_0 * t_1;
	double t_4 = sqrt((fabs(A) / t_0));
	double tmp;
	if (t_3 <= 5e-320) {
		tmp = t_4 * (c0 / t_2);
	} else if (t_3 <= 1e+257) {
		tmp = c0 * (sqrt(fabs(A)) / sqrt((t_1 * t_0)));
	} else {
		tmp = c0 * (t_4 / t_2);
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(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
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: t_3
    real(8) :: t_4
    real(8) :: tmp
    t_0 = fmin(abs(v), abs(l))
    t_1 = fmax(abs(v), abs(l))
    t_2 = sqrt(t_1)
    t_3 = t_0 * t_1
    t_4 = sqrt((abs(a) / t_0))
    if (t_3 <= 5d-320) then
        tmp = t_4 * (c0 / t_2)
    else if (t_3 <= 1d+257) then
        tmp = c0 * (sqrt(abs(a)) / sqrt((t_1 * t_0)))
    else
        tmp = c0 * (t_4 / t_2)
    end if
    code = tmp
end function
public static double code(double c0, double A, double V, double l) {
	double t_0 = fmin(Math.abs(V), Math.abs(l));
	double t_1 = fmax(Math.abs(V), Math.abs(l));
	double t_2 = Math.sqrt(t_1);
	double t_3 = t_0 * t_1;
	double t_4 = Math.sqrt((Math.abs(A) / t_0));
	double tmp;
	if (t_3 <= 5e-320) {
		tmp = t_4 * (c0 / t_2);
	} else if (t_3 <= 1e+257) {
		tmp = c0 * (Math.sqrt(Math.abs(A)) / Math.sqrt((t_1 * t_0)));
	} else {
		tmp = c0 * (t_4 / t_2);
	}
	return tmp;
}
def code(c0, A, V, l):
	t_0 = fmin(math.fabs(V), math.fabs(l))
	t_1 = fmax(math.fabs(V), math.fabs(l))
	t_2 = math.sqrt(t_1)
	t_3 = t_0 * t_1
	t_4 = math.sqrt((math.fabs(A) / t_0))
	tmp = 0
	if t_3 <= 5e-320:
		tmp = t_4 * (c0 / t_2)
	elif t_3 <= 1e+257:
		tmp = c0 * (math.sqrt(math.fabs(A)) / math.sqrt((t_1 * t_0)))
	else:
		tmp = c0 * (t_4 / t_2)
	return tmp
function code(c0, A, V, l)
	t_0 = fmin(abs(V), abs(l))
	t_1 = fmax(abs(V), abs(l))
	t_2 = sqrt(t_1)
	t_3 = Float64(t_0 * t_1)
	t_4 = sqrt(Float64(abs(A) / t_0))
	tmp = 0.0
	if (t_3 <= 5e-320)
		tmp = Float64(t_4 * Float64(c0 / t_2));
	elseif (t_3 <= 1e+257)
		tmp = Float64(c0 * Float64(sqrt(abs(A)) / sqrt(Float64(t_1 * t_0))));
	else
		tmp = Float64(c0 * Float64(t_4 / t_2));
	end
	return tmp
end
function tmp_2 = code(c0, A, V, l)
	t_0 = min(abs(V), abs(l));
	t_1 = max(abs(V), abs(l));
	t_2 = sqrt(t_1);
	t_3 = t_0 * t_1;
	t_4 = sqrt((abs(A) / t_0));
	tmp = 0.0;
	if (t_3 <= 5e-320)
		tmp = t_4 * (c0 / t_2);
	elseif (t_3 <= 1e+257)
		tmp = c0 * (sqrt(abs(A)) / sqrt((t_1 * t_0)));
	else
		tmp = c0 * (t_4 / t_2);
	end
	tmp_2 = tmp;
end
code[c0_, A_, V_, l_] := Block[{t$95$0 = N[Min[N[Abs[V], $MachinePrecision], N[Abs[l], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Max[N[Abs[V], $MachinePrecision], N[Abs[l], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[t$95$1], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$0 * t$95$1), $MachinePrecision]}, Block[{t$95$4 = N[Sqrt[N[(N[Abs[A], $MachinePrecision] / t$95$0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$3, 5e-320], N[(t$95$4 * N[(c0 / t$95$2), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 1e+257], N[(c0 * N[(N[Sqrt[N[Abs[A], $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$1 * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 * N[(t$95$4 / t$95$2), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
t_0 := \mathsf{min}\left(\left|V\right|, \left|\ell\right|\right)\\
t_1 := \mathsf{max}\left(\left|V\right|, \left|\ell\right|\right)\\
t_2 := \sqrt{t\_1}\\
t_3 := t\_0 \cdot t\_1\\
t_4 := \sqrt{\frac{\left|A\right|}{t\_0}}\\
\mathbf{if}\;t\_3 \leq 5 \cdot 10^{-320}:\\
\;\;\;\;t\_4 \cdot \frac{c0}{t\_2}\\

\mathbf{elif}\;t\_3 \leq 10^{+257}:\\
\;\;\;\;c0 \cdot \frac{\sqrt{\left|A\right|}}{\sqrt{t\_1 \cdot t\_0}}\\

\mathbf{else}:\\
\;\;\;\;c0 \cdot \frac{t\_4}{t\_2}\\


\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 V l) < 4.999944335913415e-320

    1. Initial program 73.5%

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

        \[\leadsto c0 \cdot \color{blue}{\frac{\sqrt{\frac{A}{V}}}{\sqrt{\ell}}} \]
      7. lower-unsound-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-unsound-sqrt.f6441.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.999944335913415e-320 < (*.f64 V l) < 1e257

    1. Initial program 73.5%

      \[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-/.f6473.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1e257 < (*.f64 V l)

    1. Initial program 73.5%

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

        \[\leadsto c0 \cdot \color{blue}{\frac{\sqrt{\frac{A}{V}}}{\sqrt{\ell}}} \]
      7. lower-unsound-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-unsound-sqrt.f6441.4%

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

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

Alternative 3: 94.8% accurate, 0.2× speedup?

\[\begin{array}{l} t_0 := \mathsf{min}\left(\left|V\right|, \left|\ell\right|\right)\\ t_1 := \mathsf{max}\left(\left|V\right|, \left|\ell\right|\right)\\ t_2 := t\_0 \cdot t\_1\\ t_3 := \sqrt{\frac{\left|A\right|}{t\_0}} \cdot \frac{c0}{\sqrt{t\_1}}\\ \mathbf{if}\;t\_2 \leq 5 \cdot 10^{-320}:\\ \;\;\;\;t\_3\\ \mathbf{elif}\;t\_2 \leq 10^{+257}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{\left|A\right|}}{\sqrt{t\_1 \cdot t\_0}}\\ \mathbf{else}:\\ \;\;\;\;t\_3\\ \end{array} \]
(FPCore (c0 A V l)
 :precision binary64
 (let* ((t_0 (fmin (fabs V) (fabs l)))
        (t_1 (fmax (fabs V) (fabs l)))
        (t_2 (* t_0 t_1))
        (t_3 (* (sqrt (/ (fabs A) t_0)) (/ c0 (sqrt t_1)))))
   (if (<= t_2 5e-320)
     t_3
     (if (<= t_2 1e+257) (* c0 (/ (sqrt (fabs A)) (sqrt (* t_1 t_0)))) t_3))))
double code(double c0, double A, double V, double l) {
	double t_0 = fmin(fabs(V), fabs(l));
	double t_1 = fmax(fabs(V), fabs(l));
	double t_2 = t_0 * t_1;
	double t_3 = sqrt((fabs(A) / t_0)) * (c0 / sqrt(t_1));
	double tmp;
	if (t_2 <= 5e-320) {
		tmp = t_3;
	} else if (t_2 <= 1e+257) {
		tmp = c0 * (sqrt(fabs(A)) / sqrt((t_1 * t_0)));
	} else {
		tmp = t_3;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(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
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: t_3
    real(8) :: tmp
    t_0 = fmin(abs(v), abs(l))
    t_1 = fmax(abs(v), abs(l))
    t_2 = t_0 * t_1
    t_3 = sqrt((abs(a) / t_0)) * (c0 / sqrt(t_1))
    if (t_2 <= 5d-320) then
        tmp = t_3
    else if (t_2 <= 1d+257) then
        tmp = c0 * (sqrt(abs(a)) / sqrt((t_1 * t_0)))
    else
        tmp = t_3
    end if
    code = tmp
end function
public static double code(double c0, double A, double V, double l) {
	double t_0 = fmin(Math.abs(V), Math.abs(l));
	double t_1 = fmax(Math.abs(V), Math.abs(l));
	double t_2 = t_0 * t_1;
	double t_3 = Math.sqrt((Math.abs(A) / t_0)) * (c0 / Math.sqrt(t_1));
	double tmp;
	if (t_2 <= 5e-320) {
		tmp = t_3;
	} else if (t_2 <= 1e+257) {
		tmp = c0 * (Math.sqrt(Math.abs(A)) / Math.sqrt((t_1 * t_0)));
	} else {
		tmp = t_3;
	}
	return tmp;
}
def code(c0, A, V, l):
	t_0 = fmin(math.fabs(V), math.fabs(l))
	t_1 = fmax(math.fabs(V), math.fabs(l))
	t_2 = t_0 * t_1
	t_3 = math.sqrt((math.fabs(A) / t_0)) * (c0 / math.sqrt(t_1))
	tmp = 0
	if t_2 <= 5e-320:
		tmp = t_3
	elif t_2 <= 1e+257:
		tmp = c0 * (math.sqrt(math.fabs(A)) / math.sqrt((t_1 * t_0)))
	else:
		tmp = t_3
	return tmp
function code(c0, A, V, l)
	t_0 = fmin(abs(V), abs(l))
	t_1 = fmax(abs(V), abs(l))
	t_2 = Float64(t_0 * t_1)
	t_3 = Float64(sqrt(Float64(abs(A) / t_0)) * Float64(c0 / sqrt(t_1)))
	tmp = 0.0
	if (t_2 <= 5e-320)
		tmp = t_3;
	elseif (t_2 <= 1e+257)
		tmp = Float64(c0 * Float64(sqrt(abs(A)) / sqrt(Float64(t_1 * t_0))));
	else
		tmp = t_3;
	end
	return tmp
end
function tmp_2 = code(c0, A, V, l)
	t_0 = min(abs(V), abs(l));
	t_1 = max(abs(V), abs(l));
	t_2 = t_0 * t_1;
	t_3 = sqrt((abs(A) / t_0)) * (c0 / sqrt(t_1));
	tmp = 0.0;
	if (t_2 <= 5e-320)
		tmp = t_3;
	elseif (t_2 <= 1e+257)
		tmp = c0 * (sqrt(abs(A)) / sqrt((t_1 * t_0)));
	else
		tmp = t_3;
	end
	tmp_2 = tmp;
end
code[c0_, A_, V_, l_] := Block[{t$95$0 = N[Min[N[Abs[V], $MachinePrecision], N[Abs[l], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Max[N[Abs[V], $MachinePrecision], N[Abs[l], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 * t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[(N[Sqrt[N[(N[Abs[A], $MachinePrecision] / t$95$0), $MachinePrecision]], $MachinePrecision] * N[(c0 / N[Sqrt[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, 5e-320], t$95$3, If[LessEqual[t$95$2, 1e+257], N[(c0 * N[(N[Sqrt[N[Abs[A], $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$1 * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$3]]]]]]
\begin{array}{l}
t_0 := \mathsf{min}\left(\left|V\right|, \left|\ell\right|\right)\\
t_1 := \mathsf{max}\left(\left|V\right|, \left|\ell\right|\right)\\
t_2 := t\_0 \cdot t\_1\\
t_3 := \sqrt{\frac{\left|A\right|}{t\_0}} \cdot \frac{c0}{\sqrt{t\_1}}\\
\mathbf{if}\;t\_2 \leq 5 \cdot 10^{-320}:\\
\;\;\;\;t\_3\\

\mathbf{elif}\;t\_2 \leq 10^{+257}:\\
\;\;\;\;c0 \cdot \frac{\sqrt{\left|A\right|}}{\sqrt{t\_1 \cdot t\_0}}\\

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


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

    1. Initial program 73.5%

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

        \[\leadsto c0 \cdot \color{blue}{\frac{\sqrt{\frac{A}{V}}}{\sqrt{\ell}}} \]
      7. lower-unsound-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-unsound-sqrt.f6441.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.999944335913415e-320 < (*.f64 V l) < 1e257

    1. Initial program 73.5%

      \[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-/.f6473.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 90.2% accurate, 0.2× speedup?

\[\begin{array}{l} t_0 := \mathsf{min}\left(\left|V\right|, \left|\ell\right|\right)\\ t_1 := \mathsf{max}\left(\left|V\right|, \left|\ell\right|\right)\\ t_2 := t\_0 \cdot t\_1\\ t_3 := c0 \cdot \sqrt{\frac{\frac{\left|A\right|}{t\_0}}{t\_1}}\\ \mathbf{if}\;t\_2 \leq 5 \cdot 10^{-320}:\\ \;\;\;\;t\_3\\ \mathbf{elif}\;t\_2 \leq 5 \cdot 10^{+306}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{\left|A\right|}}{\sqrt{t\_1 \cdot t\_0}}\\ \mathbf{else}:\\ \;\;\;\;t\_3\\ \end{array} \]
(FPCore (c0 A V l)
 :precision binary64
 (let* ((t_0 (fmin (fabs V) (fabs l)))
        (t_1 (fmax (fabs V) (fabs l)))
        (t_2 (* t_0 t_1))
        (t_3 (* c0 (sqrt (/ (/ (fabs A) t_0) t_1)))))
   (if (<= t_2 5e-320)
     t_3
     (if (<= t_2 5e+306) (* c0 (/ (sqrt (fabs A)) (sqrt (* t_1 t_0)))) t_3))))
double code(double c0, double A, double V, double l) {
	double t_0 = fmin(fabs(V), fabs(l));
	double t_1 = fmax(fabs(V), fabs(l));
	double t_2 = t_0 * t_1;
	double t_3 = c0 * sqrt(((fabs(A) / t_0) / t_1));
	double tmp;
	if (t_2 <= 5e-320) {
		tmp = t_3;
	} else if (t_2 <= 5e+306) {
		tmp = c0 * (sqrt(fabs(A)) / sqrt((t_1 * t_0)));
	} else {
		tmp = t_3;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(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
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: t_3
    real(8) :: tmp
    t_0 = fmin(abs(v), abs(l))
    t_1 = fmax(abs(v), abs(l))
    t_2 = t_0 * t_1
    t_3 = c0 * sqrt(((abs(a) / t_0) / t_1))
    if (t_2 <= 5d-320) then
        tmp = t_3
    else if (t_2 <= 5d+306) then
        tmp = c0 * (sqrt(abs(a)) / sqrt((t_1 * t_0)))
    else
        tmp = t_3
    end if
    code = tmp
end function
public static double code(double c0, double A, double V, double l) {
	double t_0 = fmin(Math.abs(V), Math.abs(l));
	double t_1 = fmax(Math.abs(V), Math.abs(l));
	double t_2 = t_0 * t_1;
	double t_3 = c0 * Math.sqrt(((Math.abs(A) / t_0) / t_1));
	double tmp;
	if (t_2 <= 5e-320) {
		tmp = t_3;
	} else if (t_2 <= 5e+306) {
		tmp = c0 * (Math.sqrt(Math.abs(A)) / Math.sqrt((t_1 * t_0)));
	} else {
		tmp = t_3;
	}
	return tmp;
}
def code(c0, A, V, l):
	t_0 = fmin(math.fabs(V), math.fabs(l))
	t_1 = fmax(math.fabs(V), math.fabs(l))
	t_2 = t_0 * t_1
	t_3 = c0 * math.sqrt(((math.fabs(A) / t_0) / t_1))
	tmp = 0
	if t_2 <= 5e-320:
		tmp = t_3
	elif t_2 <= 5e+306:
		tmp = c0 * (math.sqrt(math.fabs(A)) / math.sqrt((t_1 * t_0)))
	else:
		tmp = t_3
	return tmp
function code(c0, A, V, l)
	t_0 = fmin(abs(V), abs(l))
	t_1 = fmax(abs(V), abs(l))
	t_2 = Float64(t_0 * t_1)
	t_3 = Float64(c0 * sqrt(Float64(Float64(abs(A) / t_0) / t_1)))
	tmp = 0.0
	if (t_2 <= 5e-320)
		tmp = t_3;
	elseif (t_2 <= 5e+306)
		tmp = Float64(c0 * Float64(sqrt(abs(A)) / sqrt(Float64(t_1 * t_0))));
	else
		tmp = t_3;
	end
	return tmp
end
function tmp_2 = code(c0, A, V, l)
	t_0 = min(abs(V), abs(l));
	t_1 = max(abs(V), abs(l));
	t_2 = t_0 * t_1;
	t_3 = c0 * sqrt(((abs(A) / t_0) / t_1));
	tmp = 0.0;
	if (t_2 <= 5e-320)
		tmp = t_3;
	elseif (t_2 <= 5e+306)
		tmp = c0 * (sqrt(abs(A)) / sqrt((t_1 * t_0)));
	else
		tmp = t_3;
	end
	tmp_2 = tmp;
end
code[c0_, A_, V_, l_] := Block[{t$95$0 = N[Min[N[Abs[V], $MachinePrecision], N[Abs[l], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Max[N[Abs[V], $MachinePrecision], N[Abs[l], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 * t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[(c0 * N[Sqrt[N[(N[(N[Abs[A], $MachinePrecision] / t$95$0), $MachinePrecision] / t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, 5e-320], t$95$3, If[LessEqual[t$95$2, 5e+306], N[(c0 * N[(N[Sqrt[N[Abs[A], $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$1 * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$3]]]]]]
\begin{array}{l}
t_0 := \mathsf{min}\left(\left|V\right|, \left|\ell\right|\right)\\
t_1 := \mathsf{max}\left(\left|V\right|, \left|\ell\right|\right)\\
t_2 := t\_0 \cdot t\_1\\
t_3 := c0 \cdot \sqrt{\frac{\frac{\left|A\right|}{t\_0}}{t\_1}}\\
\mathbf{if}\;t\_2 \leq 5 \cdot 10^{-320}:\\
\;\;\;\;t\_3\\

\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{+306}:\\
\;\;\;\;c0 \cdot \frac{\sqrt{\left|A\right|}}{\sqrt{t\_1 \cdot t\_0}}\\

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


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 V l) < 4.999944335913415e-320 or 4.9999999999999999e306 < (*.f64 V l)

    1. Initial program 73.5%

      \[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-/.f6473.4%

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

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

    if 4.999944335913415e-320 < (*.f64 V l) < 4.9999999999999999e306

    1. Initial program 73.5%

      \[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-/.f6473.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 79.9% accurate, 0.3× speedup?

\[\begin{array}{l} t_0 := \mathsf{max}\left(\left|V\right|, \left|\ell\right|\right)\\ t_1 := \mathsf{min}\left(\left|V\right|, \left|\ell\right|\right)\\ \mathbf{if}\;\sqrt{\frac{\left|A\right|}{t\_1 \cdot t\_0}} \leq 6 \cdot 10^{+16}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{\left|A\right|}{t\_1}}{t\_0}}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{\left|A\right|}{t\_0}}{t\_1}}\\ \end{array} \]
(FPCore (c0 A V l)
 :precision binary64
 (let* ((t_0 (fmax (fabs V) (fabs l))) (t_1 (fmin (fabs V) (fabs l))))
   (if (<= (sqrt (/ (fabs A) (* t_1 t_0))) 6e+16)
     (* c0 (sqrt (/ (/ (fabs A) t_1) t_0)))
     (* c0 (sqrt (/ (/ (fabs A) t_0) t_1))))))
double code(double c0, double A, double V, double l) {
	double t_0 = fmax(fabs(V), fabs(l));
	double t_1 = fmin(fabs(V), fabs(l));
	double tmp;
	if (sqrt((fabs(A) / (t_1 * t_0))) <= 6e+16) {
		tmp = c0 * sqrt(((fabs(A) / t_1) / t_0));
	} else {
		tmp = c0 * sqrt(((fabs(A) / t_0) / t_1));
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(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
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = fmax(abs(v), abs(l))
    t_1 = fmin(abs(v), abs(l))
    if (sqrt((abs(a) / (t_1 * t_0))) <= 6d+16) then
        tmp = c0 * sqrt(((abs(a) / t_1) / t_0))
    else
        tmp = c0 * sqrt(((abs(a) / t_0) / t_1))
    end if
    code = tmp
end function
public static double code(double c0, double A, double V, double l) {
	double t_0 = fmax(Math.abs(V), Math.abs(l));
	double t_1 = fmin(Math.abs(V), Math.abs(l));
	double tmp;
	if (Math.sqrt((Math.abs(A) / (t_1 * t_0))) <= 6e+16) {
		tmp = c0 * Math.sqrt(((Math.abs(A) / t_1) / t_0));
	} else {
		tmp = c0 * Math.sqrt(((Math.abs(A) / t_0) / t_1));
	}
	return tmp;
}
def code(c0, A, V, l):
	t_0 = fmax(math.fabs(V), math.fabs(l))
	t_1 = fmin(math.fabs(V), math.fabs(l))
	tmp = 0
	if math.sqrt((math.fabs(A) / (t_1 * t_0))) <= 6e+16:
		tmp = c0 * math.sqrt(((math.fabs(A) / t_1) / t_0))
	else:
		tmp = c0 * math.sqrt(((math.fabs(A) / t_0) / t_1))
	return tmp
function code(c0, A, V, l)
	t_0 = fmax(abs(V), abs(l))
	t_1 = fmin(abs(V), abs(l))
	tmp = 0.0
	if (sqrt(Float64(abs(A) / Float64(t_1 * t_0))) <= 6e+16)
		tmp = Float64(c0 * sqrt(Float64(Float64(abs(A) / t_1) / t_0)));
	else
		tmp = Float64(c0 * sqrt(Float64(Float64(abs(A) / t_0) / t_1)));
	end
	return tmp
end
function tmp_2 = code(c0, A, V, l)
	t_0 = max(abs(V), abs(l));
	t_1 = min(abs(V), abs(l));
	tmp = 0.0;
	if (sqrt((abs(A) / (t_1 * t_0))) <= 6e+16)
		tmp = c0 * sqrt(((abs(A) / t_1) / t_0));
	else
		tmp = c0 * sqrt(((abs(A) / t_0) / t_1));
	end
	tmp_2 = tmp;
end
code[c0_, A_, V_, l_] := Block[{t$95$0 = N[Max[N[Abs[V], $MachinePrecision], N[Abs[l], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Min[N[Abs[V], $MachinePrecision], N[Abs[l], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Sqrt[N[(N[Abs[A], $MachinePrecision] / N[(t$95$1 * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 6e+16], N[(c0 * N[Sqrt[N[(N[(N[Abs[A], $MachinePrecision] / t$95$1), $MachinePrecision] / t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(c0 * N[Sqrt[N[(N[(N[Abs[A], $MachinePrecision] / t$95$0), $MachinePrecision] / t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
t_0 := \mathsf{max}\left(\left|V\right|, \left|\ell\right|\right)\\
t_1 := \mathsf{min}\left(\left|V\right|, \left|\ell\right|\right)\\
\mathbf{if}\;\sqrt{\frac{\left|A\right|}{t\_1 \cdot t\_0}} \leq 6 \cdot 10^{+16}:\\
\;\;\;\;c0 \cdot \sqrt{\frac{\frac{\left|A\right|}{t\_1}}{t\_0}}\\

\mathbf{else}:\\
\;\;\;\;c0 \cdot \sqrt{\frac{\frac{\left|A\right|}{t\_0}}{t\_1}}\\


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

    1. Initial program 73.5%

      \[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-/.f6473.4%

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

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

    if 6e16 < (sqrt.f64 (/.f64 A (*.f64 V l)))

    1. Initial program 73.5%

      \[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-/.f6473.2%

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

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

Alternative 6: 79.8% accurate, 0.2× speedup?

\[\begin{array}{l} t_0 := \mathsf{min}\left(\left|V\right|, \left|\ell\right|\right)\\ t_1 := \mathsf{max}\left(\left|V\right|, \left|\ell\right|\right)\\ t_2 := t\_0 \cdot t\_1\\ t_3 := c0 \cdot \sqrt{\frac{\frac{\left|A\right|}{t\_0}}{t\_1}}\\ \mathbf{if}\;t\_2 \leq 10^{-316}:\\ \;\;\;\;t\_3\\ \mathbf{elif}\;t\_2 \leq 4 \cdot 10^{+275}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\left|A\right|}{t\_2}}\\ \mathbf{else}:\\ \;\;\;\;t\_3\\ \end{array} \]
(FPCore (c0 A V l)
 :precision binary64
 (let* ((t_0 (fmin (fabs V) (fabs l)))
        (t_1 (fmax (fabs V) (fabs l)))
        (t_2 (* t_0 t_1))
        (t_3 (* c0 (sqrt (/ (/ (fabs A) t_0) t_1)))))
   (if (<= t_2 1e-316)
     t_3
     (if (<= t_2 4e+275) (* c0 (sqrt (/ (fabs A) t_2))) t_3))))
double code(double c0, double A, double V, double l) {
	double t_0 = fmin(fabs(V), fabs(l));
	double t_1 = fmax(fabs(V), fabs(l));
	double t_2 = t_0 * t_1;
	double t_3 = c0 * sqrt(((fabs(A) / t_0) / t_1));
	double tmp;
	if (t_2 <= 1e-316) {
		tmp = t_3;
	} else if (t_2 <= 4e+275) {
		tmp = c0 * sqrt((fabs(A) / t_2));
	} else {
		tmp = t_3;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(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
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: t_3
    real(8) :: tmp
    t_0 = fmin(abs(v), abs(l))
    t_1 = fmax(abs(v), abs(l))
    t_2 = t_0 * t_1
    t_3 = c0 * sqrt(((abs(a) / t_0) / t_1))
    if (t_2 <= 1d-316) then
        tmp = t_3
    else if (t_2 <= 4d+275) then
        tmp = c0 * sqrt((abs(a) / t_2))
    else
        tmp = t_3
    end if
    code = tmp
end function
public static double code(double c0, double A, double V, double l) {
	double t_0 = fmin(Math.abs(V), Math.abs(l));
	double t_1 = fmax(Math.abs(V), Math.abs(l));
	double t_2 = t_0 * t_1;
	double t_3 = c0 * Math.sqrt(((Math.abs(A) / t_0) / t_1));
	double tmp;
	if (t_2 <= 1e-316) {
		tmp = t_3;
	} else if (t_2 <= 4e+275) {
		tmp = c0 * Math.sqrt((Math.abs(A) / t_2));
	} else {
		tmp = t_3;
	}
	return tmp;
}
def code(c0, A, V, l):
	t_0 = fmin(math.fabs(V), math.fabs(l))
	t_1 = fmax(math.fabs(V), math.fabs(l))
	t_2 = t_0 * t_1
	t_3 = c0 * math.sqrt(((math.fabs(A) / t_0) / t_1))
	tmp = 0
	if t_2 <= 1e-316:
		tmp = t_3
	elif t_2 <= 4e+275:
		tmp = c0 * math.sqrt((math.fabs(A) / t_2))
	else:
		tmp = t_3
	return tmp
function code(c0, A, V, l)
	t_0 = fmin(abs(V), abs(l))
	t_1 = fmax(abs(V), abs(l))
	t_2 = Float64(t_0 * t_1)
	t_3 = Float64(c0 * sqrt(Float64(Float64(abs(A) / t_0) / t_1)))
	tmp = 0.0
	if (t_2 <= 1e-316)
		tmp = t_3;
	elseif (t_2 <= 4e+275)
		tmp = Float64(c0 * sqrt(Float64(abs(A) / t_2)));
	else
		tmp = t_3;
	end
	return tmp
end
function tmp_2 = code(c0, A, V, l)
	t_0 = min(abs(V), abs(l));
	t_1 = max(abs(V), abs(l));
	t_2 = t_0 * t_1;
	t_3 = c0 * sqrt(((abs(A) / t_0) / t_1));
	tmp = 0.0;
	if (t_2 <= 1e-316)
		tmp = t_3;
	elseif (t_2 <= 4e+275)
		tmp = c0 * sqrt((abs(A) / t_2));
	else
		tmp = t_3;
	end
	tmp_2 = tmp;
end
code[c0_, A_, V_, l_] := Block[{t$95$0 = N[Min[N[Abs[V], $MachinePrecision], N[Abs[l], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Max[N[Abs[V], $MachinePrecision], N[Abs[l], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 * t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[(c0 * N[Sqrt[N[(N[(N[Abs[A], $MachinePrecision] / t$95$0), $MachinePrecision] / t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, 1e-316], t$95$3, If[LessEqual[t$95$2, 4e+275], N[(c0 * N[Sqrt[N[(N[Abs[A], $MachinePrecision] / t$95$2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$3]]]]]]
\begin{array}{l}
t_0 := \mathsf{min}\left(\left|V\right|, \left|\ell\right|\right)\\
t_1 := \mathsf{max}\left(\left|V\right|, \left|\ell\right|\right)\\
t_2 := t\_0 \cdot t\_1\\
t_3 := c0 \cdot \sqrt{\frac{\frac{\left|A\right|}{t\_0}}{t\_1}}\\
\mathbf{if}\;t\_2 \leq 10^{-316}:\\
\;\;\;\;t\_3\\

\mathbf{elif}\;t\_2 \leq 4 \cdot 10^{+275}:\\
\;\;\;\;c0 \cdot \sqrt{\frac{\left|A\right|}{t\_2}}\\

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


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 V l) < 9.9999998365971443e-317 or 3.9999999999999998e275 < (*.f64 V l)

    1. Initial program 73.5%

      \[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-/.f6473.4%

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

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

    if 9.9999998365971443e-317 < (*.f64 V l) < 3.9999999999999998e275

    1. Initial program 73.5%

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

Alternative 7: 73.5% accurate, 0.8× speedup?

\[c0 \cdot \sqrt{\frac{\left|A\right|}{\left|V\right| \cdot \left|\ell\right|}} \]
(FPCore (c0 A V l)
 :precision binary64
 (* c0 (sqrt (/ (fabs A) (* (fabs V) (fabs l))))))
double code(double c0, double A, double V, double l) {
	return c0 * sqrt((fabs(A) / (fabs(V) * fabs(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((abs(a) / (abs(v) * abs(l))))
end function
public static double code(double c0, double A, double V, double l) {
	return c0 * Math.sqrt((Math.abs(A) / (Math.abs(V) * Math.abs(l))));
}
def code(c0, A, V, l):
	return c0 * math.sqrt((math.fabs(A) / (math.fabs(V) * math.fabs(l))))
function code(c0, A, V, l)
	return Float64(c0 * sqrt(Float64(abs(A) / Float64(abs(V) * abs(l)))))
end
function tmp = code(c0, A, V, l)
	tmp = c0 * sqrt((abs(A) / (abs(V) * abs(l))));
end
code[c0_, A_, V_, l_] := N[(c0 * N[Sqrt[N[(N[Abs[A], $MachinePrecision] / N[(N[Abs[V], $MachinePrecision] * N[Abs[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
c0 \cdot \sqrt{\frac{\left|A\right|}{\left|V\right| \cdot \left|\ell\right|}}
Derivation
  1. Initial program 73.5%

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

Reproduce

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