Henrywood and Agarwal, Equation (3)

Percentage Accurate: 73.7% → 91.1%
Time: 7.5s
Alternatives: 11
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)));
}
real(8) function code(c0, a, v, l)
    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}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 11 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 73.7% 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)));
}
real(8) function code(c0, a, v, l)
    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: 91.1% accurate, 0.3× speedup?

\[\begin{array}{l} [c0, A, V, l] = \mathsf{sort}([c0, A, V, l])\\ \\ \begin{array}{l} \mathbf{if}\;V \cdot \ell \leq -\infty:\\ \;\;\;\;\frac{c0 \cdot \sqrt{\frac{A}{-\ell}}}{\sqrt{-V}}\\ \mathbf{elif}\;V \cdot \ell \leq -5 \cdot 10^{-245}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{-A}}{\sqrt{V \cdot \left(-\ell\right)}}\\ \mathbf{elif}\;V \cdot \ell \leq 0:\\ \;\;\;\;c0 \cdot \frac{\sqrt{\frac{1}{\ell}}}{\sqrt{\frac{V}{A}}}\\ \mathbf{elif}\;V \cdot \ell \leq 2 \cdot 10^{+236}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{A}}{\sqrt{V \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{V}}{\ell}}\\ \end{array} \end{array} \]
NOTE: c0, A, V, and l should be sorted in increasing order before calling this function.
(FPCore (c0 A V l)
 :precision binary64
 (if (<= (* V l) (- INFINITY))
   (/ (* c0 (sqrt (/ A (- l)))) (sqrt (- V)))
   (if (<= (* V l) -5e-245)
     (* c0 (/ (sqrt (- A)) (sqrt (* V (- l)))))
     (if (<= (* V l) 0.0)
       (* c0 (/ (sqrt (/ 1.0 l)) (sqrt (/ V A))))
       (if (<= (* V l) 2e+236)
         (* c0 (/ (sqrt A) (sqrt (* V l))))
         (* c0 (sqrt (/ (/ A V) l))))))))
assert(c0 < A && A < V && V < l);
double code(double c0, double A, double V, double l) {
	double tmp;
	if ((V * l) <= -((double) INFINITY)) {
		tmp = (c0 * sqrt((A / -l))) / sqrt(-V);
	} else if ((V * l) <= -5e-245) {
		tmp = c0 * (sqrt(-A) / sqrt((V * -l)));
	} else if ((V * l) <= 0.0) {
		tmp = c0 * (sqrt((1.0 / l)) / sqrt((V / A)));
	} else if ((V * l) <= 2e+236) {
		tmp = c0 * (sqrt(A) / sqrt((V * l)));
	} else {
		tmp = c0 * sqrt(((A / V) / l));
	}
	return tmp;
}
assert c0 < A && A < V && V < l;
public static double code(double c0, double A, double V, double l) {
	double tmp;
	if ((V * l) <= -Double.POSITIVE_INFINITY) {
		tmp = (c0 * Math.sqrt((A / -l))) / Math.sqrt(-V);
	} else if ((V * l) <= -5e-245) {
		tmp = c0 * (Math.sqrt(-A) / Math.sqrt((V * -l)));
	} else if ((V * l) <= 0.0) {
		tmp = c0 * (Math.sqrt((1.0 / l)) / Math.sqrt((V / A)));
	} else if ((V * l) <= 2e+236) {
		tmp = c0 * (Math.sqrt(A) / Math.sqrt((V * l)));
	} else {
		tmp = c0 * Math.sqrt(((A / V) / l));
	}
	return tmp;
}
[c0, A, V, l] = sort([c0, A, V, l])
def code(c0, A, V, l):
	tmp = 0
	if (V * l) <= -math.inf:
		tmp = (c0 * math.sqrt((A / -l))) / math.sqrt(-V)
	elif (V * l) <= -5e-245:
		tmp = c0 * (math.sqrt(-A) / math.sqrt((V * -l)))
	elif (V * l) <= 0.0:
		tmp = c0 * (math.sqrt((1.0 / l)) / math.sqrt((V / A)))
	elif (V * l) <= 2e+236:
		tmp = c0 * (math.sqrt(A) / math.sqrt((V * l)))
	else:
		tmp = c0 * math.sqrt(((A / V) / l))
	return tmp
c0, A, V, l = sort([c0, A, V, l])
function code(c0, A, V, l)
	tmp = 0.0
	if (Float64(V * l) <= Float64(-Inf))
		tmp = Float64(Float64(c0 * sqrt(Float64(A / Float64(-l)))) / sqrt(Float64(-V)));
	elseif (Float64(V * l) <= -5e-245)
		tmp = Float64(c0 * Float64(sqrt(Float64(-A)) / sqrt(Float64(V * Float64(-l)))));
	elseif (Float64(V * l) <= 0.0)
		tmp = Float64(c0 * Float64(sqrt(Float64(1.0 / l)) / sqrt(Float64(V / A))));
	elseif (Float64(V * l) <= 2e+236)
		tmp = Float64(c0 * Float64(sqrt(A) / sqrt(Float64(V * l))));
	else
		tmp = Float64(c0 * sqrt(Float64(Float64(A / V) / l)));
	end
	return tmp
end
c0, A, V, l = num2cell(sort([c0, A, V, l])){:}
function tmp_2 = code(c0, A, V, l)
	tmp = 0.0;
	if ((V * l) <= -Inf)
		tmp = (c0 * sqrt((A / -l))) / sqrt(-V);
	elseif ((V * l) <= -5e-245)
		tmp = c0 * (sqrt(-A) / sqrt((V * -l)));
	elseif ((V * l) <= 0.0)
		tmp = c0 * (sqrt((1.0 / l)) / sqrt((V / A)));
	elseif ((V * l) <= 2e+236)
		tmp = c0 * (sqrt(A) / sqrt((V * l)));
	else
		tmp = c0 * sqrt(((A / V) / l));
	end
	tmp_2 = tmp;
end
NOTE: c0, A, V, and l should be sorted in increasing order before calling this function.
code[c0_, A_, V_, l_] := If[LessEqual[N[(V * l), $MachinePrecision], (-Infinity)], N[(N[(c0 * N[Sqrt[N[(A / (-l)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[Sqrt[(-V)], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(V * l), $MachinePrecision], -5e-245], N[(c0 * N[(N[Sqrt[(-A)], $MachinePrecision] / N[Sqrt[N[(V * (-l)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(V * l), $MachinePrecision], 0.0], N[(c0 * N[(N[Sqrt[N[(1.0 / l), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(V / A), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(V * l), $MachinePrecision], 2e+236], N[(c0 * N[(N[Sqrt[A], $MachinePrecision] / N[Sqrt[N[(V * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 * N[Sqrt[N[(N[(A / V), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
[c0, A, V, l] = \mathsf{sort}([c0, A, V, l])\\
\\
\begin{array}{l}
\mathbf{if}\;V \cdot \ell \leq -\infty:\\
\;\;\;\;\frac{c0 \cdot \sqrt{\frac{A}{-\ell}}}{\sqrt{-V}}\\

\mathbf{elif}\;V \cdot \ell \leq -5 \cdot 10^{-245}:\\
\;\;\;\;c0 \cdot \frac{\sqrt{-A}}{\sqrt{V \cdot \left(-\ell\right)}}\\

\mathbf{elif}\;V \cdot \ell \leq 0:\\
\;\;\;\;c0 \cdot \frac{\sqrt{\frac{1}{\ell}}}{\sqrt{\frac{V}{A}}}\\

\mathbf{elif}\;V \cdot \ell \leq 2 \cdot 10^{+236}:\\
\;\;\;\;c0 \cdot \frac{\sqrt{A}}{\sqrt{V \cdot \ell}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if (*.f64 V l) < -inf.0

    1. Initial program 49.6%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Add Preprocessing
    3. 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-/l/N/A

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{\color{blue}{\frac{\mathsf{neg}\left(\frac{A}{\ell}\right)}{\mathsf{neg}\left(V\right)}}} \cdot c0 \]
      6. sqrt-divN/A

        \[\leadsto \color{blue}{\frac{\sqrt{\mathsf{neg}\left(\frac{A}{\ell}\right)}}{\sqrt{\mathsf{neg}\left(V\right)}}} \cdot c0 \]
      7. associate-*l/N/A

        \[\leadsto \color{blue}{\frac{\sqrt{\mathsf{neg}\left(\frac{A}{\ell}\right)} \cdot c0}{\sqrt{\mathsf{neg}\left(V\right)}}} \]
      8. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{\sqrt{\mathsf{neg}\left(\frac{A}{\ell}\right)} \cdot c0}{\sqrt{\mathsf{neg}\left(V\right)}}} \]
      9. lower-*.f64N/A

        \[\leadsto \frac{\color{blue}{\sqrt{\mathsf{neg}\left(\frac{A}{\ell}\right)} \cdot c0}}{\sqrt{\mathsf{neg}\left(V\right)}} \]
      10. lower-sqrt.f64N/A

        \[\leadsto \frac{\color{blue}{\sqrt{\mathsf{neg}\left(\frac{A}{\ell}\right)}} \cdot c0}{\sqrt{\mathsf{neg}\left(V\right)}} \]
      11. lift-/.f64N/A

        \[\leadsto \frac{\sqrt{\mathsf{neg}\left(\color{blue}{\frac{A}{\ell}}\right)} \cdot c0}{\sqrt{\mathsf{neg}\left(V\right)}} \]
      12. distribute-neg-frac2N/A

        \[\leadsto \frac{\sqrt{\color{blue}{\frac{A}{\mathsf{neg}\left(\ell\right)}}} \cdot c0}{\sqrt{\mathsf{neg}\left(V\right)}} \]
      13. lower-/.f64N/A

        \[\leadsto \frac{\sqrt{\color{blue}{\frac{A}{\mathsf{neg}\left(\ell\right)}}} \cdot c0}{\sqrt{\mathsf{neg}\left(V\right)}} \]
      14. lower-neg.f64N/A

        \[\leadsto \frac{\sqrt{\frac{A}{\color{blue}{\mathsf{neg}\left(\ell\right)}}} \cdot c0}{\sqrt{\mathsf{neg}\left(V\right)}} \]
      15. lower-sqrt.f64N/A

        \[\leadsto \frac{\sqrt{\frac{A}{\mathsf{neg}\left(\ell\right)}} \cdot c0}{\color{blue}{\sqrt{\mathsf{neg}\left(V\right)}}} \]
      16. lower-neg.f6447.3

        \[\leadsto \frac{\sqrt{\frac{A}{-\ell}} \cdot c0}{\sqrt{\color{blue}{-V}}} \]
    6. Applied rewrites47.3%

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

    if -inf.0 < (*.f64 V l) < -4.9999999999999997e-245

    1. Initial program 82.9%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Add Preprocessing
    3. 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-/l/N/A

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

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

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

      \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{A}{\ell}}{V}}} \]
    5. 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}{V \cdot \ell}}} \]
      5. lift-*.f64N/A

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

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\mathsf{neg}\left(A\right)}{\mathsf{neg}\left(V \cdot \ell\right)}}} \]
      7. sqrt-divN/A

        \[\leadsto c0 \cdot \color{blue}{\frac{\sqrt{\mathsf{neg}\left(A\right)}}{\sqrt{\mathsf{neg}\left(V \cdot \ell\right)}}} \]
      8. lower-/.f64N/A

        \[\leadsto c0 \cdot \color{blue}{\frac{\sqrt{\mathsf{neg}\left(A\right)}}{\sqrt{\mathsf{neg}\left(V \cdot \ell\right)}}} \]
      9. lower-sqrt.f64N/A

        \[\leadsto c0 \cdot \frac{\color{blue}{\sqrt{\mathsf{neg}\left(A\right)}}}{\sqrt{\mathsf{neg}\left(V \cdot \ell\right)}} \]
      10. lower-neg.f64N/A

        \[\leadsto c0 \cdot \frac{\sqrt{\color{blue}{\mathsf{neg}\left(A\right)}}}{\sqrt{\mathsf{neg}\left(V \cdot \ell\right)}} \]
      11. lower-sqrt.f64N/A

        \[\leadsto c0 \cdot \frac{\sqrt{\mathsf{neg}\left(A\right)}}{\color{blue}{\sqrt{\mathsf{neg}\left(V \cdot \ell\right)}}} \]
      12. lift-*.f64N/A

        \[\leadsto c0 \cdot \frac{\sqrt{\mathsf{neg}\left(A\right)}}{\sqrt{\mathsf{neg}\left(\color{blue}{V \cdot \ell}\right)}} \]
      13. *-commutativeN/A

        \[\leadsto c0 \cdot \frac{\sqrt{\mathsf{neg}\left(A\right)}}{\sqrt{\mathsf{neg}\left(\color{blue}{\ell \cdot V}\right)}} \]
      14. distribute-rgt-neg-inN/A

        \[\leadsto c0 \cdot \frac{\sqrt{\mathsf{neg}\left(A\right)}}{\sqrt{\color{blue}{\ell \cdot \left(\mathsf{neg}\left(V\right)\right)}}} \]
      15. lower-*.f64N/A

        \[\leadsto c0 \cdot \frac{\sqrt{\mathsf{neg}\left(A\right)}}{\sqrt{\color{blue}{\ell \cdot \left(\mathsf{neg}\left(V\right)\right)}}} \]
      16. lower-neg.f6499.5

        \[\leadsto c0 \cdot \frac{\sqrt{-A}}{\sqrt{\ell \cdot \color{blue}{\left(-V\right)}}} \]
    6. Applied rewrites99.5%

      \[\leadsto c0 \cdot \color{blue}{\frac{\sqrt{-A}}{\sqrt{\ell \cdot \left(-V\right)}}} \]

    if -4.9999999999999997e-245 < (*.f64 V l) < 0.0

    1. Initial program 52.9%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Add Preprocessing
    3. Applied rewrites50.1%

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

    if 0.0 < (*.f64 V l) < 2.00000000000000011e236

    1. Initial program 80.7%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Add Preprocessing
    3. 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.f6498.6

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

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

    if 2.00000000000000011e236 < (*.f64 V l)

    1. Initial program 55.2%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Add Preprocessing
    3. 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-/.f6479.5

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

      \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{A}{V}}{\ell}}} \]
  3. Recombined 5 regimes into one program.
  4. Final simplification89.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;V \cdot \ell \leq -\infty:\\ \;\;\;\;\frac{c0 \cdot \sqrt{\frac{A}{-\ell}}}{\sqrt{-V}}\\ \mathbf{elif}\;V \cdot \ell \leq -5 \cdot 10^{-245}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{-A}}{\sqrt{V \cdot \left(-\ell\right)}}\\ \mathbf{elif}\;V \cdot \ell \leq 0:\\ \;\;\;\;c0 \cdot \frac{\sqrt{\frac{1}{\ell}}}{\sqrt{\frac{V}{A}}}\\ \mathbf{elif}\;V \cdot \ell \leq 2 \cdot 10^{+236}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{A}}{\sqrt{V \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{V}}{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 77.0% accurate, 0.3× speedup?

\[\begin{array}{l} [c0, A, V, l] = \mathsf{sort}([c0, A, V, l])\\ \\ \begin{array}{l} t_0 := c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}\\ \mathbf{if}\;t\_0 \leq 0:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{V}}{\ell}}\\ \mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+269}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{c0}{\sqrt{\ell \cdot \frac{V}{A}}}\\ \end{array} \end{array} \]
NOTE: c0, A, V, and l should be sorted in increasing order before calling this function.
(FPCore (c0 A V l)
 :precision binary64
 (let* ((t_0 (* c0 (sqrt (/ A (* V l))))))
   (if (<= t_0 0.0)
     (* c0 (sqrt (/ (/ A V) l)))
     (if (<= t_0 2e+269) t_0 (/ c0 (sqrt (* l (/ V A))))))))
assert(c0 < A && A < V && V < l);
double code(double c0, double A, double V, double l) {
	double t_0 = c0 * sqrt((A / (V * l)));
	double tmp;
	if (t_0 <= 0.0) {
		tmp = c0 * sqrt(((A / V) / l));
	} else if (t_0 <= 2e+269) {
		tmp = t_0;
	} else {
		tmp = c0 / sqrt((l * (V / A)));
	}
	return tmp;
}
NOTE: c0, A, V, and l should be sorted in increasing order before calling this function.
real(8) function code(c0, a, v, l)
    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) :: tmp
    t_0 = c0 * sqrt((a / (v * l)))
    if (t_0 <= 0.0d0) then
        tmp = c0 * sqrt(((a / v) / l))
    else if (t_0 <= 2d+269) then
        tmp = t_0
    else
        tmp = c0 / sqrt((l * (v / a)))
    end if
    code = tmp
end function
assert c0 < A && A < V && V < l;
public static double code(double c0, double A, double V, double l) {
	double t_0 = c0 * Math.sqrt((A / (V * l)));
	double tmp;
	if (t_0 <= 0.0) {
		tmp = c0 * Math.sqrt(((A / V) / l));
	} else if (t_0 <= 2e+269) {
		tmp = t_0;
	} else {
		tmp = c0 / Math.sqrt((l * (V / A)));
	}
	return tmp;
}
[c0, A, V, l] = sort([c0, A, V, l])
def code(c0, A, V, l):
	t_0 = c0 * math.sqrt((A / (V * l)))
	tmp = 0
	if t_0 <= 0.0:
		tmp = c0 * math.sqrt(((A / V) / l))
	elif t_0 <= 2e+269:
		tmp = t_0
	else:
		tmp = c0 / math.sqrt((l * (V / A)))
	return tmp
c0, A, V, l = sort([c0, A, V, l])
function code(c0, A, V, l)
	t_0 = Float64(c0 * sqrt(Float64(A / Float64(V * l))))
	tmp = 0.0
	if (t_0 <= 0.0)
		tmp = Float64(c0 * sqrt(Float64(Float64(A / V) / l)));
	elseif (t_0 <= 2e+269)
		tmp = t_0;
	else
		tmp = Float64(c0 / sqrt(Float64(l * Float64(V / A))));
	end
	return tmp
end
c0, A, V, l = num2cell(sort([c0, A, V, l])){:}
function tmp_2 = code(c0, A, V, l)
	t_0 = c0 * sqrt((A / (V * l)));
	tmp = 0.0;
	if (t_0 <= 0.0)
		tmp = c0 * sqrt(((A / V) / l));
	elseif (t_0 <= 2e+269)
		tmp = t_0;
	else
		tmp = c0 / sqrt((l * (V / A)));
	end
	tmp_2 = tmp;
end
NOTE: c0, A, V, and l should be sorted in increasing order before calling this function.
code[c0_, A_, V_, l_] := Block[{t$95$0 = N[(c0 * N[Sqrt[N[(A / N[(V * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.0], N[(c0 * N[Sqrt[N[(N[(A / V), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 2e+269], t$95$0, N[(c0 / N[Sqrt[N[(l * N[(V / A), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[c0, A, V, l] = \mathsf{sort}([c0, A, V, l])\\
\\
\begin{array}{l}
t_0 := c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}\\
\mathbf{if}\;t\_0 \leq 0:\\
\;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{V}}{\ell}}\\

\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+269}:\\
\;\;\;\;t\_0\\

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


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

    1. Initial program 68.1%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Add Preprocessing
    3. 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-/.f6472.5

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

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

    if 0.0 < (*.f64 c0 (sqrt.f64 (/.f64 A (*.f64 V l)))) < 2.0000000000000001e269

    1. Initial program 98.9%

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

    if 2.0000000000000001e269 < (*.f64 c0 (sqrt.f64 (/.f64 A (*.f64 V l))))

    1. Initial program 43.5%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Add Preprocessing
    3. 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-/l/N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{\sqrt{\frac{\color{blue}{\ell \cdot V}}{A}}} \]
      17. lower-*.f6443.5

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \leq 0:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{V}}{\ell}}\\ \mathbf{elif}\;c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \leq 2 \cdot 10^{+269}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c0}{\sqrt{\ell \cdot \frac{V}{A}}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 91.1% accurate, 0.4× speedup?

\[\begin{array}{l} [c0, A, V, l] = \mathsf{sort}([c0, A, V, l])\\ \\ \begin{array}{l} \mathbf{if}\;V \cdot \ell \leq -\infty:\\ \;\;\;\;\frac{c0 \cdot \sqrt{\frac{A}{-\ell}}}{\sqrt{-V}}\\ \mathbf{elif}\;V \cdot \ell \leq -5 \cdot 10^{-245}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{-A}}{\sqrt{V \cdot \left(-\ell\right)}}\\ \mathbf{elif}\;V \cdot \ell \leq 0:\\ \;\;\;\;\frac{c0}{\sqrt{\ell} \cdot \sqrt{\frac{V}{A}}}\\ \mathbf{elif}\;V \cdot \ell \leq 2 \cdot 10^{+236}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{A}}{\sqrt{V \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{V}}{\ell}}\\ \end{array} \end{array} \]
NOTE: c0, A, V, and l should be sorted in increasing order before calling this function.
(FPCore (c0 A V l)
 :precision binary64
 (if (<= (* V l) (- INFINITY))
   (/ (* c0 (sqrt (/ A (- l)))) (sqrt (- V)))
   (if (<= (* V l) -5e-245)
     (* c0 (/ (sqrt (- A)) (sqrt (* V (- l)))))
     (if (<= (* V l) 0.0)
       (/ c0 (* (sqrt l) (sqrt (/ V A))))
       (if (<= (* V l) 2e+236)
         (* c0 (/ (sqrt A) (sqrt (* V l))))
         (* c0 (sqrt (/ (/ A V) l))))))))
assert(c0 < A && A < V && V < l);
double code(double c0, double A, double V, double l) {
	double tmp;
	if ((V * l) <= -((double) INFINITY)) {
		tmp = (c0 * sqrt((A / -l))) / sqrt(-V);
	} else if ((V * l) <= -5e-245) {
		tmp = c0 * (sqrt(-A) / sqrt((V * -l)));
	} else if ((V * l) <= 0.0) {
		tmp = c0 / (sqrt(l) * sqrt((V / A)));
	} else if ((V * l) <= 2e+236) {
		tmp = c0 * (sqrt(A) / sqrt((V * l)));
	} else {
		tmp = c0 * sqrt(((A / V) / l));
	}
	return tmp;
}
assert c0 < A && A < V && V < l;
public static double code(double c0, double A, double V, double l) {
	double tmp;
	if ((V * l) <= -Double.POSITIVE_INFINITY) {
		tmp = (c0 * Math.sqrt((A / -l))) / Math.sqrt(-V);
	} else if ((V * l) <= -5e-245) {
		tmp = c0 * (Math.sqrt(-A) / Math.sqrt((V * -l)));
	} else if ((V * l) <= 0.0) {
		tmp = c0 / (Math.sqrt(l) * Math.sqrt((V / A)));
	} else if ((V * l) <= 2e+236) {
		tmp = c0 * (Math.sqrt(A) / Math.sqrt((V * l)));
	} else {
		tmp = c0 * Math.sqrt(((A / V) / l));
	}
	return tmp;
}
[c0, A, V, l] = sort([c0, A, V, l])
def code(c0, A, V, l):
	tmp = 0
	if (V * l) <= -math.inf:
		tmp = (c0 * math.sqrt((A / -l))) / math.sqrt(-V)
	elif (V * l) <= -5e-245:
		tmp = c0 * (math.sqrt(-A) / math.sqrt((V * -l)))
	elif (V * l) <= 0.0:
		tmp = c0 / (math.sqrt(l) * math.sqrt((V / A)))
	elif (V * l) <= 2e+236:
		tmp = c0 * (math.sqrt(A) / math.sqrt((V * l)))
	else:
		tmp = c0 * math.sqrt(((A / V) / l))
	return tmp
c0, A, V, l = sort([c0, A, V, l])
function code(c0, A, V, l)
	tmp = 0.0
	if (Float64(V * l) <= Float64(-Inf))
		tmp = Float64(Float64(c0 * sqrt(Float64(A / Float64(-l)))) / sqrt(Float64(-V)));
	elseif (Float64(V * l) <= -5e-245)
		tmp = Float64(c0 * Float64(sqrt(Float64(-A)) / sqrt(Float64(V * Float64(-l)))));
	elseif (Float64(V * l) <= 0.0)
		tmp = Float64(c0 / Float64(sqrt(l) * sqrt(Float64(V / A))));
	elseif (Float64(V * l) <= 2e+236)
		tmp = Float64(c0 * Float64(sqrt(A) / sqrt(Float64(V * l))));
	else
		tmp = Float64(c0 * sqrt(Float64(Float64(A / V) / l)));
	end
	return tmp
end
c0, A, V, l = num2cell(sort([c0, A, V, l])){:}
function tmp_2 = code(c0, A, V, l)
	tmp = 0.0;
	if ((V * l) <= -Inf)
		tmp = (c0 * sqrt((A / -l))) / sqrt(-V);
	elseif ((V * l) <= -5e-245)
		tmp = c0 * (sqrt(-A) / sqrt((V * -l)));
	elseif ((V * l) <= 0.0)
		tmp = c0 / (sqrt(l) * sqrt((V / A)));
	elseif ((V * l) <= 2e+236)
		tmp = c0 * (sqrt(A) / sqrt((V * l)));
	else
		tmp = c0 * sqrt(((A / V) / l));
	end
	tmp_2 = tmp;
end
NOTE: c0, A, V, and l should be sorted in increasing order before calling this function.
code[c0_, A_, V_, l_] := If[LessEqual[N[(V * l), $MachinePrecision], (-Infinity)], N[(N[(c0 * N[Sqrt[N[(A / (-l)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[Sqrt[(-V)], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(V * l), $MachinePrecision], -5e-245], N[(c0 * N[(N[Sqrt[(-A)], $MachinePrecision] / N[Sqrt[N[(V * (-l)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(V * l), $MachinePrecision], 0.0], N[(c0 / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[N[(V / A), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(V * l), $MachinePrecision], 2e+236], N[(c0 * N[(N[Sqrt[A], $MachinePrecision] / N[Sqrt[N[(V * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 * N[Sqrt[N[(N[(A / V), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
[c0, A, V, l] = \mathsf{sort}([c0, A, V, l])\\
\\
\begin{array}{l}
\mathbf{if}\;V \cdot \ell \leq -\infty:\\
\;\;\;\;\frac{c0 \cdot \sqrt{\frac{A}{-\ell}}}{\sqrt{-V}}\\

\mathbf{elif}\;V \cdot \ell \leq -5 \cdot 10^{-245}:\\
\;\;\;\;c0 \cdot \frac{\sqrt{-A}}{\sqrt{V \cdot \left(-\ell\right)}}\\

\mathbf{elif}\;V \cdot \ell \leq 0:\\
\;\;\;\;\frac{c0}{\sqrt{\ell} \cdot \sqrt{\frac{V}{A}}}\\

\mathbf{elif}\;V \cdot \ell \leq 2 \cdot 10^{+236}:\\
\;\;\;\;c0 \cdot \frac{\sqrt{A}}{\sqrt{V \cdot \ell}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if (*.f64 V l) < -inf.0

    1. Initial program 49.6%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Add Preprocessing
    3. 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-/l/N/A

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{\color{blue}{\frac{\mathsf{neg}\left(\frac{A}{\ell}\right)}{\mathsf{neg}\left(V\right)}}} \cdot c0 \]
      6. sqrt-divN/A

        \[\leadsto \color{blue}{\frac{\sqrt{\mathsf{neg}\left(\frac{A}{\ell}\right)}}{\sqrt{\mathsf{neg}\left(V\right)}}} \cdot c0 \]
      7. associate-*l/N/A

        \[\leadsto \color{blue}{\frac{\sqrt{\mathsf{neg}\left(\frac{A}{\ell}\right)} \cdot c0}{\sqrt{\mathsf{neg}\left(V\right)}}} \]
      8. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{\sqrt{\mathsf{neg}\left(\frac{A}{\ell}\right)} \cdot c0}{\sqrt{\mathsf{neg}\left(V\right)}}} \]
      9. lower-*.f64N/A

        \[\leadsto \frac{\color{blue}{\sqrt{\mathsf{neg}\left(\frac{A}{\ell}\right)} \cdot c0}}{\sqrt{\mathsf{neg}\left(V\right)}} \]
      10. lower-sqrt.f64N/A

        \[\leadsto \frac{\color{blue}{\sqrt{\mathsf{neg}\left(\frac{A}{\ell}\right)}} \cdot c0}{\sqrt{\mathsf{neg}\left(V\right)}} \]
      11. lift-/.f64N/A

        \[\leadsto \frac{\sqrt{\mathsf{neg}\left(\color{blue}{\frac{A}{\ell}}\right)} \cdot c0}{\sqrt{\mathsf{neg}\left(V\right)}} \]
      12. distribute-neg-frac2N/A

        \[\leadsto \frac{\sqrt{\color{blue}{\frac{A}{\mathsf{neg}\left(\ell\right)}}} \cdot c0}{\sqrt{\mathsf{neg}\left(V\right)}} \]
      13. lower-/.f64N/A

        \[\leadsto \frac{\sqrt{\color{blue}{\frac{A}{\mathsf{neg}\left(\ell\right)}}} \cdot c0}{\sqrt{\mathsf{neg}\left(V\right)}} \]
      14. lower-neg.f64N/A

        \[\leadsto \frac{\sqrt{\frac{A}{\color{blue}{\mathsf{neg}\left(\ell\right)}}} \cdot c0}{\sqrt{\mathsf{neg}\left(V\right)}} \]
      15. lower-sqrt.f64N/A

        \[\leadsto \frac{\sqrt{\frac{A}{\mathsf{neg}\left(\ell\right)}} \cdot c0}{\color{blue}{\sqrt{\mathsf{neg}\left(V\right)}}} \]
      16. lower-neg.f6447.3

        \[\leadsto \frac{\sqrt{\frac{A}{-\ell}} \cdot c0}{\sqrt{\color{blue}{-V}}} \]
    6. Applied rewrites47.3%

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

    if -inf.0 < (*.f64 V l) < -4.9999999999999997e-245

    1. Initial program 82.9%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Add Preprocessing
    3. 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-/l/N/A

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

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

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

      \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{A}{\ell}}{V}}} \]
    5. 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}{V \cdot \ell}}} \]
      5. lift-*.f64N/A

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

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\mathsf{neg}\left(A\right)}{\mathsf{neg}\left(V \cdot \ell\right)}}} \]
      7. sqrt-divN/A

        \[\leadsto c0 \cdot \color{blue}{\frac{\sqrt{\mathsf{neg}\left(A\right)}}{\sqrt{\mathsf{neg}\left(V \cdot \ell\right)}}} \]
      8. lower-/.f64N/A

        \[\leadsto c0 \cdot \color{blue}{\frac{\sqrt{\mathsf{neg}\left(A\right)}}{\sqrt{\mathsf{neg}\left(V \cdot \ell\right)}}} \]
      9. lower-sqrt.f64N/A

        \[\leadsto c0 \cdot \frac{\color{blue}{\sqrt{\mathsf{neg}\left(A\right)}}}{\sqrt{\mathsf{neg}\left(V \cdot \ell\right)}} \]
      10. lower-neg.f64N/A

        \[\leadsto c0 \cdot \frac{\sqrt{\color{blue}{\mathsf{neg}\left(A\right)}}}{\sqrt{\mathsf{neg}\left(V \cdot \ell\right)}} \]
      11. lower-sqrt.f64N/A

        \[\leadsto c0 \cdot \frac{\sqrt{\mathsf{neg}\left(A\right)}}{\color{blue}{\sqrt{\mathsf{neg}\left(V \cdot \ell\right)}}} \]
      12. lift-*.f64N/A

        \[\leadsto c0 \cdot \frac{\sqrt{\mathsf{neg}\left(A\right)}}{\sqrt{\mathsf{neg}\left(\color{blue}{V \cdot \ell}\right)}} \]
      13. *-commutativeN/A

        \[\leadsto c0 \cdot \frac{\sqrt{\mathsf{neg}\left(A\right)}}{\sqrt{\mathsf{neg}\left(\color{blue}{\ell \cdot V}\right)}} \]
      14. distribute-rgt-neg-inN/A

        \[\leadsto c0 \cdot \frac{\sqrt{\mathsf{neg}\left(A\right)}}{\sqrt{\color{blue}{\ell \cdot \left(\mathsf{neg}\left(V\right)\right)}}} \]
      15. lower-*.f64N/A

        \[\leadsto c0 \cdot \frac{\sqrt{\mathsf{neg}\left(A\right)}}{\sqrt{\color{blue}{\ell \cdot \left(\mathsf{neg}\left(V\right)\right)}}} \]
      16. lower-neg.f6499.5

        \[\leadsto c0 \cdot \frac{\sqrt{-A}}{\sqrt{\ell \cdot \color{blue}{\left(-V\right)}}} \]
    6. Applied rewrites99.5%

      \[\leadsto c0 \cdot \color{blue}{\frac{\sqrt{-A}}{\sqrt{\ell \cdot \left(-V\right)}}} \]

    if -4.9999999999999997e-245 < (*.f64 V l) < 0.0

    1. Initial program 52.9%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Add Preprocessing
    3. 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-/l/N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{c0}{\sqrt{\frac{\ell \cdot V}{A}}}} \]
    7. Applied rewrites50.1%

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

    if 0.0 < (*.f64 V l) < 2.00000000000000011e236

    1. Initial program 80.7%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Add Preprocessing
    3. 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.f6498.6

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

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

    if 2.00000000000000011e236 < (*.f64 V l)

    1. Initial program 55.2%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Add Preprocessing
    3. 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-/.f6479.5

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

      \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{A}{V}}{\ell}}} \]
  3. Recombined 5 regimes into one program.
  4. Final simplification89.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;V \cdot \ell \leq -\infty:\\ \;\;\;\;\frac{c0 \cdot \sqrt{\frac{A}{-\ell}}}{\sqrt{-V}}\\ \mathbf{elif}\;V \cdot \ell \leq -5 \cdot 10^{-245}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{-A}}{\sqrt{V \cdot \left(-\ell\right)}}\\ \mathbf{elif}\;V \cdot \ell \leq 0:\\ \;\;\;\;\frac{c0}{\sqrt{\ell} \cdot \sqrt{\frac{V}{A}}}\\ \mathbf{elif}\;V \cdot \ell \leq 2 \cdot 10^{+236}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{A}}{\sqrt{V \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{V}}{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 91.0% accurate, 0.4× speedup?

\[\begin{array}{l} [c0, A, V, l] = \mathsf{sort}([c0, A, V, l])\\ \\ \begin{array}{l} t_0 := \frac{c0}{\sqrt{\ell} \cdot \sqrt{\frac{V}{A}}}\\ \mathbf{if}\;V \cdot \ell \leq -\infty:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;V \cdot \ell \leq -5 \cdot 10^{-245}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{-A}}{\sqrt{V \cdot \left(-\ell\right)}}\\ \mathbf{elif}\;V \cdot \ell \leq 0:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;V \cdot \ell \leq 2 \cdot 10^{+236}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{A}}{\sqrt{V \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{V}}{\ell}}\\ \end{array} \end{array} \]
NOTE: c0, A, V, and l should be sorted in increasing order before calling this function.
(FPCore (c0 A V l)
 :precision binary64
 (let* ((t_0 (/ c0 (* (sqrt l) (sqrt (/ V A))))))
   (if (<= (* V l) (- INFINITY))
     t_0
     (if (<= (* V l) -5e-245)
       (* c0 (/ (sqrt (- A)) (sqrt (* V (- l)))))
       (if (<= (* V l) 0.0)
         t_0
         (if (<= (* V l) 2e+236)
           (* c0 (/ (sqrt A) (sqrt (* V l))))
           (* c0 (sqrt (/ (/ A V) l)))))))))
assert(c0 < A && A < V && V < l);
double code(double c0, double A, double V, double l) {
	double t_0 = c0 / (sqrt(l) * sqrt((V / A)));
	double tmp;
	if ((V * l) <= -((double) INFINITY)) {
		tmp = t_0;
	} else if ((V * l) <= -5e-245) {
		tmp = c0 * (sqrt(-A) / sqrt((V * -l)));
	} else if ((V * l) <= 0.0) {
		tmp = t_0;
	} else if ((V * l) <= 2e+236) {
		tmp = c0 * (sqrt(A) / sqrt((V * l)));
	} else {
		tmp = c0 * sqrt(((A / V) / l));
	}
	return tmp;
}
assert c0 < A && A < V && V < l;
public static double code(double c0, double A, double V, double l) {
	double t_0 = c0 / (Math.sqrt(l) * Math.sqrt((V / A)));
	double tmp;
	if ((V * l) <= -Double.POSITIVE_INFINITY) {
		tmp = t_0;
	} else if ((V * l) <= -5e-245) {
		tmp = c0 * (Math.sqrt(-A) / Math.sqrt((V * -l)));
	} else if ((V * l) <= 0.0) {
		tmp = t_0;
	} else if ((V * l) <= 2e+236) {
		tmp = c0 * (Math.sqrt(A) / Math.sqrt((V * l)));
	} else {
		tmp = c0 * Math.sqrt(((A / V) / l));
	}
	return tmp;
}
[c0, A, V, l] = sort([c0, A, V, l])
def code(c0, A, V, l):
	t_0 = c0 / (math.sqrt(l) * math.sqrt((V / A)))
	tmp = 0
	if (V * l) <= -math.inf:
		tmp = t_0
	elif (V * l) <= -5e-245:
		tmp = c0 * (math.sqrt(-A) / math.sqrt((V * -l)))
	elif (V * l) <= 0.0:
		tmp = t_0
	elif (V * l) <= 2e+236:
		tmp = c0 * (math.sqrt(A) / math.sqrt((V * l)))
	else:
		tmp = c0 * math.sqrt(((A / V) / l))
	return tmp
c0, A, V, l = sort([c0, A, V, l])
function code(c0, A, V, l)
	t_0 = Float64(c0 / Float64(sqrt(l) * sqrt(Float64(V / A))))
	tmp = 0.0
	if (Float64(V * l) <= Float64(-Inf))
		tmp = t_0;
	elseif (Float64(V * l) <= -5e-245)
		tmp = Float64(c0 * Float64(sqrt(Float64(-A)) / sqrt(Float64(V * Float64(-l)))));
	elseif (Float64(V * l) <= 0.0)
		tmp = t_0;
	elseif (Float64(V * l) <= 2e+236)
		tmp = Float64(c0 * Float64(sqrt(A) / sqrt(Float64(V * l))));
	else
		tmp = Float64(c0 * sqrt(Float64(Float64(A / V) / l)));
	end
	return tmp
end
c0, A, V, l = num2cell(sort([c0, A, V, l])){:}
function tmp_2 = code(c0, A, V, l)
	t_0 = c0 / (sqrt(l) * sqrt((V / A)));
	tmp = 0.0;
	if ((V * l) <= -Inf)
		tmp = t_0;
	elseif ((V * l) <= -5e-245)
		tmp = c0 * (sqrt(-A) / sqrt((V * -l)));
	elseif ((V * l) <= 0.0)
		tmp = t_0;
	elseif ((V * l) <= 2e+236)
		tmp = c0 * (sqrt(A) / sqrt((V * l)));
	else
		tmp = c0 * sqrt(((A / V) / l));
	end
	tmp_2 = tmp;
end
NOTE: c0, A, V, and l should be sorted in increasing order before calling this function.
code[c0_, A_, V_, l_] := Block[{t$95$0 = N[(c0 / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[N[(V / A), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(V * l), $MachinePrecision], (-Infinity)], t$95$0, If[LessEqual[N[(V * l), $MachinePrecision], -5e-245], N[(c0 * N[(N[Sqrt[(-A)], $MachinePrecision] / N[Sqrt[N[(V * (-l)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(V * l), $MachinePrecision], 0.0], t$95$0, If[LessEqual[N[(V * l), $MachinePrecision], 2e+236], N[(c0 * N[(N[Sqrt[A], $MachinePrecision] / N[Sqrt[N[(V * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 * N[Sqrt[N[(N[(A / V), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
[c0, A, V, l] = \mathsf{sort}([c0, A, V, l])\\
\\
\begin{array}{l}
t_0 := \frac{c0}{\sqrt{\ell} \cdot \sqrt{\frac{V}{A}}}\\
\mathbf{if}\;V \cdot \ell \leq -\infty:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;V \cdot \ell \leq -5 \cdot 10^{-245}:\\
\;\;\;\;c0 \cdot \frac{\sqrt{-A}}{\sqrt{V \cdot \left(-\ell\right)}}\\

\mathbf{elif}\;V \cdot \ell \leq 0:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;V \cdot \ell \leq 2 \cdot 10^{+236}:\\
\;\;\;\;c0 \cdot \frac{\sqrt{A}}{\sqrt{V \cdot \ell}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (*.f64 V l) < -inf.0 or -4.9999999999999997e-245 < (*.f64 V l) < 0.0

    1. Initial program 51.6%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Add Preprocessing
    3. 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-/l/N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{\sqrt{\frac{\color{blue}{\ell \cdot V}}{A}}} \]
      17. lower-*.f6451.6

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

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

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

    if -inf.0 < (*.f64 V l) < -4.9999999999999997e-245

    1. Initial program 82.9%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Add Preprocessing
    3. 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-/l/N/A

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

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

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

      \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{A}{\ell}}{V}}} \]
    5. 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}{V \cdot \ell}}} \]
      5. lift-*.f64N/A

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

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\mathsf{neg}\left(A\right)}{\mathsf{neg}\left(V \cdot \ell\right)}}} \]
      7. sqrt-divN/A

        \[\leadsto c0 \cdot \color{blue}{\frac{\sqrt{\mathsf{neg}\left(A\right)}}{\sqrt{\mathsf{neg}\left(V \cdot \ell\right)}}} \]
      8. lower-/.f64N/A

        \[\leadsto c0 \cdot \color{blue}{\frac{\sqrt{\mathsf{neg}\left(A\right)}}{\sqrt{\mathsf{neg}\left(V \cdot \ell\right)}}} \]
      9. lower-sqrt.f64N/A

        \[\leadsto c0 \cdot \frac{\color{blue}{\sqrt{\mathsf{neg}\left(A\right)}}}{\sqrt{\mathsf{neg}\left(V \cdot \ell\right)}} \]
      10. lower-neg.f64N/A

        \[\leadsto c0 \cdot \frac{\sqrt{\color{blue}{\mathsf{neg}\left(A\right)}}}{\sqrt{\mathsf{neg}\left(V \cdot \ell\right)}} \]
      11. lower-sqrt.f64N/A

        \[\leadsto c0 \cdot \frac{\sqrt{\mathsf{neg}\left(A\right)}}{\color{blue}{\sqrt{\mathsf{neg}\left(V \cdot \ell\right)}}} \]
      12. lift-*.f64N/A

        \[\leadsto c0 \cdot \frac{\sqrt{\mathsf{neg}\left(A\right)}}{\sqrt{\mathsf{neg}\left(\color{blue}{V \cdot \ell}\right)}} \]
      13. *-commutativeN/A

        \[\leadsto c0 \cdot \frac{\sqrt{\mathsf{neg}\left(A\right)}}{\sqrt{\mathsf{neg}\left(\color{blue}{\ell \cdot V}\right)}} \]
      14. distribute-rgt-neg-inN/A

        \[\leadsto c0 \cdot \frac{\sqrt{\mathsf{neg}\left(A\right)}}{\sqrt{\color{blue}{\ell \cdot \left(\mathsf{neg}\left(V\right)\right)}}} \]
      15. lower-*.f64N/A

        \[\leadsto c0 \cdot \frac{\sqrt{\mathsf{neg}\left(A\right)}}{\sqrt{\color{blue}{\ell \cdot \left(\mathsf{neg}\left(V\right)\right)}}} \]
      16. lower-neg.f6499.5

        \[\leadsto c0 \cdot \frac{\sqrt{-A}}{\sqrt{\ell \cdot \color{blue}{\left(-V\right)}}} \]
    6. Applied rewrites99.5%

      \[\leadsto c0 \cdot \color{blue}{\frac{\sqrt{-A}}{\sqrt{\ell \cdot \left(-V\right)}}} \]

    if 0.0 < (*.f64 V l) < 2.00000000000000011e236

    1. Initial program 80.7%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Add Preprocessing
    3. 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.f6498.6

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

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

    if 2.00000000000000011e236 < (*.f64 V l)

    1. Initial program 55.2%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Add Preprocessing
    3. 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-/.f6479.5

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

      \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{A}{V}}{\ell}}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification88.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;V \cdot \ell \leq -\infty:\\ \;\;\;\;\frac{c0}{\sqrt{\ell} \cdot \sqrt{\frac{V}{A}}}\\ \mathbf{elif}\;V \cdot \ell \leq -5 \cdot 10^{-245}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{-A}}{\sqrt{V \cdot \left(-\ell\right)}}\\ \mathbf{elif}\;V \cdot \ell \leq 0:\\ \;\;\;\;\frac{c0}{\sqrt{\ell} \cdot \sqrt{\frac{V}{A}}}\\ \mathbf{elif}\;V \cdot \ell \leq 2 \cdot 10^{+236}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{A}}{\sqrt{V \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{V}}{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 91.0% accurate, 0.4× speedup?

\[\begin{array}{l} [c0, A, V, l] = \mathsf{sort}([c0, A, V, l])\\ \\ \begin{array}{l} t_0 := c0 \cdot \frac{\sqrt{\frac{A}{V}}}{\sqrt{\ell}}\\ \mathbf{if}\;V \cdot \ell \leq -\infty:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;V \cdot \ell \leq -5 \cdot 10^{-246}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{-A}}{\sqrt{V \cdot \left(-\ell\right)}}\\ \mathbf{elif}\;V \cdot \ell \leq 0:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;V \cdot \ell \leq 2 \cdot 10^{+236}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{A}}{\sqrt{V \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{V}}{\ell}}\\ \end{array} \end{array} \]
NOTE: c0, A, V, and l should be sorted in increasing order before calling this function.
(FPCore (c0 A V l)
 :precision binary64
 (let* ((t_0 (* c0 (/ (sqrt (/ A V)) (sqrt l)))))
   (if (<= (* V l) (- INFINITY))
     t_0
     (if (<= (* V l) -5e-246)
       (* c0 (/ (sqrt (- A)) (sqrt (* V (- l)))))
       (if (<= (* V l) 0.0)
         t_0
         (if (<= (* V l) 2e+236)
           (* c0 (/ (sqrt A) (sqrt (* V l))))
           (* c0 (sqrt (/ (/ A V) l)))))))))
assert(c0 < A && A < V && V < l);
double code(double c0, double A, double V, double l) {
	double t_0 = c0 * (sqrt((A / V)) / sqrt(l));
	double tmp;
	if ((V * l) <= -((double) INFINITY)) {
		tmp = t_0;
	} else if ((V * l) <= -5e-246) {
		tmp = c0 * (sqrt(-A) / sqrt((V * -l)));
	} else if ((V * l) <= 0.0) {
		tmp = t_0;
	} else if ((V * l) <= 2e+236) {
		tmp = c0 * (sqrt(A) / sqrt((V * l)));
	} else {
		tmp = c0 * sqrt(((A / V) / l));
	}
	return tmp;
}
assert c0 < A && A < V && V < l;
public static double code(double c0, double A, double V, double l) {
	double t_0 = c0 * (Math.sqrt((A / V)) / Math.sqrt(l));
	double tmp;
	if ((V * l) <= -Double.POSITIVE_INFINITY) {
		tmp = t_0;
	} else if ((V * l) <= -5e-246) {
		tmp = c0 * (Math.sqrt(-A) / Math.sqrt((V * -l)));
	} else if ((V * l) <= 0.0) {
		tmp = t_0;
	} else if ((V * l) <= 2e+236) {
		tmp = c0 * (Math.sqrt(A) / Math.sqrt((V * l)));
	} else {
		tmp = c0 * Math.sqrt(((A / V) / l));
	}
	return tmp;
}
[c0, A, V, l] = sort([c0, A, V, l])
def code(c0, A, V, l):
	t_0 = c0 * (math.sqrt((A / V)) / math.sqrt(l))
	tmp = 0
	if (V * l) <= -math.inf:
		tmp = t_0
	elif (V * l) <= -5e-246:
		tmp = c0 * (math.sqrt(-A) / math.sqrt((V * -l)))
	elif (V * l) <= 0.0:
		tmp = t_0
	elif (V * l) <= 2e+236:
		tmp = c0 * (math.sqrt(A) / math.sqrt((V * l)))
	else:
		tmp = c0 * math.sqrt(((A / V) / l))
	return tmp
c0, A, V, l = sort([c0, A, V, l])
function code(c0, A, V, l)
	t_0 = Float64(c0 * Float64(sqrt(Float64(A / V)) / sqrt(l)))
	tmp = 0.0
	if (Float64(V * l) <= Float64(-Inf))
		tmp = t_0;
	elseif (Float64(V * l) <= -5e-246)
		tmp = Float64(c0 * Float64(sqrt(Float64(-A)) / sqrt(Float64(V * Float64(-l)))));
	elseif (Float64(V * l) <= 0.0)
		tmp = t_0;
	elseif (Float64(V * l) <= 2e+236)
		tmp = Float64(c0 * Float64(sqrt(A) / sqrt(Float64(V * l))));
	else
		tmp = Float64(c0 * sqrt(Float64(Float64(A / V) / l)));
	end
	return tmp
end
c0, A, V, l = num2cell(sort([c0, A, V, l])){:}
function tmp_2 = code(c0, A, V, l)
	t_0 = c0 * (sqrt((A / V)) / sqrt(l));
	tmp = 0.0;
	if ((V * l) <= -Inf)
		tmp = t_0;
	elseif ((V * l) <= -5e-246)
		tmp = c0 * (sqrt(-A) / sqrt((V * -l)));
	elseif ((V * l) <= 0.0)
		tmp = t_0;
	elseif ((V * l) <= 2e+236)
		tmp = c0 * (sqrt(A) / sqrt((V * l)));
	else
		tmp = c0 * sqrt(((A / V) / l));
	end
	tmp_2 = tmp;
end
NOTE: c0, A, V, and l should be sorted in increasing order before calling this function.
code[c0_, A_, V_, l_] := Block[{t$95$0 = N[(c0 * N[(N[Sqrt[N[(A / V), $MachinePrecision]], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(V * l), $MachinePrecision], (-Infinity)], t$95$0, If[LessEqual[N[(V * l), $MachinePrecision], -5e-246], N[(c0 * N[(N[Sqrt[(-A)], $MachinePrecision] / N[Sqrt[N[(V * (-l)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(V * l), $MachinePrecision], 0.0], t$95$0, If[LessEqual[N[(V * l), $MachinePrecision], 2e+236], N[(c0 * N[(N[Sqrt[A], $MachinePrecision] / N[Sqrt[N[(V * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 * N[Sqrt[N[(N[(A / V), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
[c0, A, V, l] = \mathsf{sort}([c0, A, V, l])\\
\\
\begin{array}{l}
t_0 := c0 \cdot \frac{\sqrt{\frac{A}{V}}}{\sqrt{\ell}}\\
\mathbf{if}\;V \cdot \ell \leq -\infty:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;V \cdot \ell \leq -5 \cdot 10^{-246}:\\
\;\;\;\;c0 \cdot \frac{\sqrt{-A}}{\sqrt{V \cdot \left(-\ell\right)}}\\

\mathbf{elif}\;V \cdot \ell \leq 0:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;V \cdot \ell \leq 2 \cdot 10^{+236}:\\
\;\;\;\;c0 \cdot \frac{\sqrt{A}}{\sqrt{V \cdot \ell}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (*.f64 V l) < -inf.0 or -4.9999999999999997e-246 < (*.f64 V l) < 0.0

    1. Initial program 50.5%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Add Preprocessing
    3. 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.f6447.0

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

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

    if -inf.0 < (*.f64 V l) < -4.9999999999999997e-246

    1. Initial program 83.1%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Add Preprocessing
    3. 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-/l/N/A

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

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

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

      \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{A}{\ell}}{V}}} \]
    5. 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}{V \cdot \ell}}} \]
      5. lift-*.f64N/A

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

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\mathsf{neg}\left(A\right)}{\mathsf{neg}\left(V \cdot \ell\right)}}} \]
      7. sqrt-divN/A

        \[\leadsto c0 \cdot \color{blue}{\frac{\sqrt{\mathsf{neg}\left(A\right)}}{\sqrt{\mathsf{neg}\left(V \cdot \ell\right)}}} \]
      8. lower-/.f64N/A

        \[\leadsto c0 \cdot \color{blue}{\frac{\sqrt{\mathsf{neg}\left(A\right)}}{\sqrt{\mathsf{neg}\left(V \cdot \ell\right)}}} \]
      9. lower-sqrt.f64N/A

        \[\leadsto c0 \cdot \frac{\color{blue}{\sqrt{\mathsf{neg}\left(A\right)}}}{\sqrt{\mathsf{neg}\left(V \cdot \ell\right)}} \]
      10. lower-neg.f64N/A

        \[\leadsto c0 \cdot \frac{\sqrt{\color{blue}{\mathsf{neg}\left(A\right)}}}{\sqrt{\mathsf{neg}\left(V \cdot \ell\right)}} \]
      11. lower-sqrt.f64N/A

        \[\leadsto c0 \cdot \frac{\sqrt{\mathsf{neg}\left(A\right)}}{\color{blue}{\sqrt{\mathsf{neg}\left(V \cdot \ell\right)}}} \]
      12. lift-*.f64N/A

        \[\leadsto c0 \cdot \frac{\sqrt{\mathsf{neg}\left(A\right)}}{\sqrt{\mathsf{neg}\left(\color{blue}{V \cdot \ell}\right)}} \]
      13. *-commutativeN/A

        \[\leadsto c0 \cdot \frac{\sqrt{\mathsf{neg}\left(A\right)}}{\sqrt{\mathsf{neg}\left(\color{blue}{\ell \cdot V}\right)}} \]
      14. distribute-rgt-neg-inN/A

        \[\leadsto c0 \cdot \frac{\sqrt{\mathsf{neg}\left(A\right)}}{\sqrt{\color{blue}{\ell \cdot \left(\mathsf{neg}\left(V\right)\right)}}} \]
      15. lower-*.f64N/A

        \[\leadsto c0 \cdot \frac{\sqrt{\mathsf{neg}\left(A\right)}}{\sqrt{\color{blue}{\ell \cdot \left(\mathsf{neg}\left(V\right)\right)}}} \]
      16. lower-neg.f6499.5

        \[\leadsto c0 \cdot \frac{\sqrt{-A}}{\sqrt{\ell \cdot \color{blue}{\left(-V\right)}}} \]
    6. Applied rewrites99.5%

      \[\leadsto c0 \cdot \color{blue}{\frac{\sqrt{-A}}{\sqrt{\ell \cdot \left(-V\right)}}} \]

    if 0.0 < (*.f64 V l) < 2.00000000000000011e236

    1. Initial program 80.7%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Add Preprocessing
    3. 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.f6498.6

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

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

    if 2.00000000000000011e236 < (*.f64 V l)

    1. Initial program 55.2%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Add Preprocessing
    3. 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-/.f6479.5

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

      \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{A}{V}}{\ell}}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification88.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;V \cdot \ell \leq -\infty:\\ \;\;\;\;c0 \cdot \frac{\sqrt{\frac{A}{V}}}{\sqrt{\ell}}\\ \mathbf{elif}\;V \cdot \ell \leq -5 \cdot 10^{-246}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{-A}}{\sqrt{V \cdot \left(-\ell\right)}}\\ \mathbf{elif}\;V \cdot \ell \leq 0:\\ \;\;\;\;c0 \cdot \frac{\sqrt{\frac{A}{V}}}{\sqrt{\ell}}\\ \mathbf{elif}\;V \cdot \ell \leq 2 \cdot 10^{+236}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{A}}{\sqrt{V \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{V}}{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 90.1% accurate, 0.4× speedup?

\[\begin{array}{l} [c0, A, V, l] = \mathsf{sort}([c0, A, V, l])\\ \\ \begin{array}{l} t_0 := c0 \cdot \sqrt{\frac{\frac{A}{V}}{\ell}}\\ \mathbf{if}\;V \cdot \ell \leq -\infty:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;V \cdot \ell \leq -1 \cdot 10^{-312}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{-A}}{\sqrt{V \cdot \left(-\ell\right)}}\\ \mathbf{elif}\;V \cdot \ell \leq 0:\\ \;\;\;\;\frac{c0}{\sqrt{\ell \cdot \frac{V}{A}}}\\ \mathbf{elif}\;V \cdot \ell \leq 2 \cdot 10^{+236}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{A}}{\sqrt{V \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
NOTE: c0, A, V, and l should be sorted in increasing order before calling this function.
(FPCore (c0 A V l)
 :precision binary64
 (let* ((t_0 (* c0 (sqrt (/ (/ A V) l)))))
   (if (<= (* V l) (- INFINITY))
     t_0
     (if (<= (* V l) -1e-312)
       (* c0 (/ (sqrt (- A)) (sqrt (* V (- l)))))
       (if (<= (* V l) 0.0)
         (/ c0 (sqrt (* l (/ V A))))
         (if (<= (* V l) 2e+236) (* c0 (/ (sqrt A) (sqrt (* V l)))) t_0))))))
assert(c0 < A && A < V && V < l);
double code(double c0, double A, double V, double l) {
	double t_0 = c0 * sqrt(((A / V) / l));
	double tmp;
	if ((V * l) <= -((double) INFINITY)) {
		tmp = t_0;
	} else if ((V * l) <= -1e-312) {
		tmp = c0 * (sqrt(-A) / sqrt((V * -l)));
	} else if ((V * l) <= 0.0) {
		tmp = c0 / sqrt((l * (V / A)));
	} else if ((V * l) <= 2e+236) {
		tmp = c0 * (sqrt(A) / sqrt((V * l)));
	} else {
		tmp = t_0;
	}
	return tmp;
}
assert c0 < A && A < V && V < l;
public static double code(double c0, double A, double V, double l) {
	double t_0 = c0 * Math.sqrt(((A / V) / l));
	double tmp;
	if ((V * l) <= -Double.POSITIVE_INFINITY) {
		tmp = t_0;
	} else if ((V * l) <= -1e-312) {
		tmp = c0 * (Math.sqrt(-A) / Math.sqrt((V * -l)));
	} else if ((V * l) <= 0.0) {
		tmp = c0 / Math.sqrt((l * (V / A)));
	} else if ((V * l) <= 2e+236) {
		tmp = c0 * (Math.sqrt(A) / Math.sqrt((V * l)));
	} else {
		tmp = t_0;
	}
	return tmp;
}
[c0, A, V, l] = sort([c0, A, V, l])
def code(c0, A, V, l):
	t_0 = c0 * math.sqrt(((A / V) / l))
	tmp = 0
	if (V * l) <= -math.inf:
		tmp = t_0
	elif (V * l) <= -1e-312:
		tmp = c0 * (math.sqrt(-A) / math.sqrt((V * -l)))
	elif (V * l) <= 0.0:
		tmp = c0 / math.sqrt((l * (V / A)))
	elif (V * l) <= 2e+236:
		tmp = c0 * (math.sqrt(A) / math.sqrt((V * l)))
	else:
		tmp = t_0
	return tmp
c0, A, V, l = sort([c0, A, V, l])
function code(c0, A, V, l)
	t_0 = Float64(c0 * sqrt(Float64(Float64(A / V) / l)))
	tmp = 0.0
	if (Float64(V * l) <= Float64(-Inf))
		tmp = t_0;
	elseif (Float64(V * l) <= -1e-312)
		tmp = Float64(c0 * Float64(sqrt(Float64(-A)) / sqrt(Float64(V * Float64(-l)))));
	elseif (Float64(V * l) <= 0.0)
		tmp = Float64(c0 / sqrt(Float64(l * Float64(V / A))));
	elseif (Float64(V * l) <= 2e+236)
		tmp = Float64(c0 * Float64(sqrt(A) / sqrt(Float64(V * l))));
	else
		tmp = t_0;
	end
	return tmp
end
c0, A, V, l = num2cell(sort([c0, A, V, l])){:}
function tmp_2 = code(c0, A, V, l)
	t_0 = c0 * sqrt(((A / V) / l));
	tmp = 0.0;
	if ((V * l) <= -Inf)
		tmp = t_0;
	elseif ((V * l) <= -1e-312)
		tmp = c0 * (sqrt(-A) / sqrt((V * -l)));
	elseif ((V * l) <= 0.0)
		tmp = c0 / sqrt((l * (V / A)));
	elseif ((V * l) <= 2e+236)
		tmp = c0 * (sqrt(A) / sqrt((V * l)));
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
NOTE: c0, A, V, and l should be sorted in increasing order before calling this function.
code[c0_, A_, V_, l_] := Block[{t$95$0 = N[(c0 * N[Sqrt[N[(N[(A / V), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(V * l), $MachinePrecision], (-Infinity)], t$95$0, If[LessEqual[N[(V * l), $MachinePrecision], -1e-312], N[(c0 * N[(N[Sqrt[(-A)], $MachinePrecision] / N[Sqrt[N[(V * (-l)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(V * l), $MachinePrecision], 0.0], N[(c0 / N[Sqrt[N[(l * N[(V / A), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(V * l), $MachinePrecision], 2e+236], N[(c0 * N[(N[Sqrt[A], $MachinePrecision] / N[Sqrt[N[(V * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
[c0, A, V, l] = \mathsf{sort}([c0, A, V, l])\\
\\
\begin{array}{l}
t_0 := c0 \cdot \sqrt{\frac{\frac{A}{V}}{\ell}}\\
\mathbf{if}\;V \cdot \ell \leq -\infty:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;V \cdot \ell \leq -1 \cdot 10^{-312}:\\
\;\;\;\;c0 \cdot \frac{\sqrt{-A}}{\sqrt{V \cdot \left(-\ell\right)}}\\

\mathbf{elif}\;V \cdot \ell \leq 0:\\
\;\;\;\;\frac{c0}{\sqrt{\ell \cdot \frac{V}{A}}}\\

\mathbf{elif}\;V \cdot \ell \leq 2 \cdot 10^{+236}:\\
\;\;\;\;c0 \cdot \frac{\sqrt{A}}{\sqrt{V \cdot \ell}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (*.f64 V l) < -inf.0 or 2.00000000000000011e236 < (*.f64 V l)

    1. Initial program 52.6%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Add Preprocessing
    3. 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-/.f6477.4

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

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

    if -inf.0 < (*.f64 V l) < -9.9999999999847e-313

    1. Initial program 81.9%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Add Preprocessing
    3. 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-/l/N/A

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

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

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

      \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{A}{\ell}}{V}}} \]
    5. 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}{V \cdot \ell}}} \]
      5. lift-*.f64N/A

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

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\mathsf{neg}\left(A\right)}{\mathsf{neg}\left(V \cdot \ell\right)}}} \]
      7. sqrt-divN/A

        \[\leadsto c0 \cdot \color{blue}{\frac{\sqrt{\mathsf{neg}\left(A\right)}}{\sqrt{\mathsf{neg}\left(V \cdot \ell\right)}}} \]
      8. lower-/.f64N/A

        \[\leadsto c0 \cdot \color{blue}{\frac{\sqrt{\mathsf{neg}\left(A\right)}}{\sqrt{\mathsf{neg}\left(V \cdot \ell\right)}}} \]
      9. lower-sqrt.f64N/A

        \[\leadsto c0 \cdot \frac{\color{blue}{\sqrt{\mathsf{neg}\left(A\right)}}}{\sqrt{\mathsf{neg}\left(V \cdot \ell\right)}} \]
      10. lower-neg.f64N/A

        \[\leadsto c0 \cdot \frac{\sqrt{\color{blue}{\mathsf{neg}\left(A\right)}}}{\sqrt{\mathsf{neg}\left(V \cdot \ell\right)}} \]
      11. lower-sqrt.f64N/A

        \[\leadsto c0 \cdot \frac{\sqrt{\mathsf{neg}\left(A\right)}}{\color{blue}{\sqrt{\mathsf{neg}\left(V \cdot \ell\right)}}} \]
      12. lift-*.f64N/A

        \[\leadsto c0 \cdot \frac{\sqrt{\mathsf{neg}\left(A\right)}}{\sqrt{\mathsf{neg}\left(\color{blue}{V \cdot \ell}\right)}} \]
      13. *-commutativeN/A

        \[\leadsto c0 \cdot \frac{\sqrt{\mathsf{neg}\left(A\right)}}{\sqrt{\mathsf{neg}\left(\color{blue}{\ell \cdot V}\right)}} \]
      14. distribute-rgt-neg-inN/A

        \[\leadsto c0 \cdot \frac{\sqrt{\mathsf{neg}\left(A\right)}}{\sqrt{\color{blue}{\ell \cdot \left(\mathsf{neg}\left(V\right)\right)}}} \]
      15. lower-*.f64N/A

        \[\leadsto c0 \cdot \frac{\sqrt{\mathsf{neg}\left(A\right)}}{\sqrt{\color{blue}{\ell \cdot \left(\mathsf{neg}\left(V\right)\right)}}} \]
      16. lower-neg.f6499.4

        \[\leadsto c0 \cdot \frac{\sqrt{-A}}{\sqrt{\ell \cdot \color{blue}{\left(-V\right)}}} \]
    6. Applied rewrites99.4%

      \[\leadsto c0 \cdot \color{blue}{\frac{\sqrt{-A}}{\sqrt{\ell \cdot \left(-V\right)}}} \]

    if -9.9999999999847e-313 < (*.f64 V l) < 0.0

    1. Initial program 50.9%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Add Preprocessing
    3. 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-/l/N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.0 < (*.f64 V l) < 2.00000000000000011e236

    1. Initial program 80.7%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Add Preprocessing
    3. 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.f6498.6

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;V \cdot \ell \leq -\infty:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{V}}{\ell}}\\ \mathbf{elif}\;V \cdot \ell \leq -1 \cdot 10^{-312}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{-A}}{\sqrt{V \cdot \left(-\ell\right)}}\\ \mathbf{elif}\;V \cdot \ell \leq 0:\\ \;\;\;\;\frac{c0}{\sqrt{\ell \cdot \frac{V}{A}}}\\ \mathbf{elif}\;V \cdot \ell \leq 2 \cdot 10^{+236}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{A}}{\sqrt{V \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{V}}{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 75.6% accurate, 0.4× speedup?

\[\begin{array}{l} [c0, A, V, l] = \mathsf{sort}([c0, A, V, l])\\ \\ \begin{array}{l} t_0 := c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}\\ \mathbf{if}\;t\_0 \leq 0:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{V}}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
NOTE: c0, A, V, and l should be sorted in increasing order before calling this function.
(FPCore (c0 A V l)
 :precision binary64
 (let* ((t_0 (* c0 (sqrt (/ A (* V l))))))
   (if (<= t_0 0.0) (* c0 (sqrt (/ (/ A V) l))) t_0)))
assert(c0 < A && A < V && V < l);
double code(double c0, double A, double V, double l) {
	double t_0 = c0 * sqrt((A / (V * l)));
	double tmp;
	if (t_0 <= 0.0) {
		tmp = c0 * sqrt(((A / V) / l));
	} else {
		tmp = t_0;
	}
	return tmp;
}
NOTE: c0, A, V, and l should be sorted in increasing order before calling this function.
real(8) function code(c0, a, v, l)
    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) :: tmp
    t_0 = c0 * sqrt((a / (v * l)))
    if (t_0 <= 0.0d0) then
        tmp = c0 * sqrt(((a / v) / l))
    else
        tmp = t_0
    end if
    code = tmp
end function
assert c0 < A && A < V && V < l;
public static double code(double c0, double A, double V, double l) {
	double t_0 = c0 * Math.sqrt((A / (V * l)));
	double tmp;
	if (t_0 <= 0.0) {
		tmp = c0 * Math.sqrt(((A / V) / l));
	} else {
		tmp = t_0;
	}
	return tmp;
}
[c0, A, V, l] = sort([c0, A, V, l])
def code(c0, A, V, l):
	t_0 = c0 * math.sqrt((A / (V * l)))
	tmp = 0
	if t_0 <= 0.0:
		tmp = c0 * math.sqrt(((A / V) / l))
	else:
		tmp = t_0
	return tmp
c0, A, V, l = sort([c0, A, V, l])
function code(c0, A, V, l)
	t_0 = Float64(c0 * sqrt(Float64(A / Float64(V * l))))
	tmp = 0.0
	if (t_0 <= 0.0)
		tmp = Float64(c0 * sqrt(Float64(Float64(A / V) / l)));
	else
		tmp = t_0;
	end
	return tmp
end
c0, A, V, l = num2cell(sort([c0, A, V, l])){:}
function tmp_2 = code(c0, A, V, l)
	t_0 = c0 * sqrt((A / (V * l)));
	tmp = 0.0;
	if (t_0 <= 0.0)
		tmp = c0 * sqrt(((A / V) / l));
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
NOTE: c0, A, V, and l should be sorted in increasing order before calling this function.
code[c0_, A_, V_, l_] := Block[{t$95$0 = N[(c0 * N[Sqrt[N[(A / N[(V * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.0], N[(c0 * N[Sqrt[N[(N[(A / V), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$0]]
\begin{array}{l}
[c0, A, V, l] = \mathsf{sort}([c0, A, V, l])\\
\\
\begin{array}{l}
t_0 := c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}\\
\mathbf{if}\;t\_0 \leq 0:\\
\;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{V}}{\ell}}\\

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


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

    1. Initial program 68.1%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Add Preprocessing
    3. 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-/.f6472.5

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

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

    if 0.0 < (*.f64 c0 (sqrt.f64 (/.f64 A (*.f64 V l))))

    1. Initial program 86.0%

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

Alternative 8: 88.9% accurate, 0.5× speedup?

\[\begin{array}{l} [c0, A, V, l] = \mathsf{sort}([c0, A, V, l])\\ \\ \begin{array}{l} \mathbf{if}\;A \leq -2 \cdot 10^{-310}:\\ \;\;\;\;\frac{\frac{\sqrt{-A} \cdot c0}{\sqrt{-V}}}{\sqrt{\ell}}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{A}}{\sqrt{V \cdot \ell}}\\ \end{array} \end{array} \]
NOTE: c0, A, V, and l should be sorted in increasing order before calling this function.
(FPCore (c0 A V l)
 :precision binary64
 (if (<= A -2e-310)
   (/ (/ (* (sqrt (- A)) c0) (sqrt (- V))) (sqrt l))
   (* c0 (/ (sqrt A) (sqrt (* V l))))))
assert(c0 < A && A < V && V < l);
double code(double c0, double A, double V, double l) {
	double tmp;
	if (A <= -2e-310) {
		tmp = ((sqrt(-A) * c0) / sqrt(-V)) / sqrt(l);
	} else {
		tmp = c0 * (sqrt(A) / sqrt((V * l)));
	}
	return tmp;
}
NOTE: c0, A, V, and l should be sorted in increasing order before calling this function.
real(8) function code(c0, a, v, l)
    real(8), intent (in) :: c0
    real(8), intent (in) :: a
    real(8), intent (in) :: v
    real(8), intent (in) :: l
    real(8) :: tmp
    if (a <= (-2d-310)) then
        tmp = ((sqrt(-a) * c0) / sqrt(-v)) / sqrt(l)
    else
        tmp = c0 * (sqrt(a) / sqrt((v * l)))
    end if
    code = tmp
end function
assert c0 < A && A < V && V < l;
public static double code(double c0, double A, double V, double l) {
	double tmp;
	if (A <= -2e-310) {
		tmp = ((Math.sqrt(-A) * c0) / Math.sqrt(-V)) / Math.sqrt(l);
	} else {
		tmp = c0 * (Math.sqrt(A) / Math.sqrt((V * l)));
	}
	return tmp;
}
[c0, A, V, l] = sort([c0, A, V, l])
def code(c0, A, V, l):
	tmp = 0
	if A <= -2e-310:
		tmp = ((math.sqrt(-A) * c0) / math.sqrt(-V)) / math.sqrt(l)
	else:
		tmp = c0 * (math.sqrt(A) / math.sqrt((V * l)))
	return tmp
c0, A, V, l = sort([c0, A, V, l])
function code(c0, A, V, l)
	tmp = 0.0
	if (A <= -2e-310)
		tmp = Float64(Float64(Float64(sqrt(Float64(-A)) * c0) / sqrt(Float64(-V))) / sqrt(l));
	else
		tmp = Float64(c0 * Float64(sqrt(A) / sqrt(Float64(V * l))));
	end
	return tmp
end
c0, A, V, l = num2cell(sort([c0, A, V, l])){:}
function tmp_2 = code(c0, A, V, l)
	tmp = 0.0;
	if (A <= -2e-310)
		tmp = ((sqrt(-A) * c0) / sqrt(-V)) / sqrt(l);
	else
		tmp = c0 * (sqrt(A) / sqrt((V * l)));
	end
	tmp_2 = tmp;
end
NOTE: c0, A, V, and l should be sorted in increasing order before calling this function.
code[c0_, A_, V_, l_] := If[LessEqual[A, -2e-310], N[(N[(N[(N[Sqrt[(-A)], $MachinePrecision] * c0), $MachinePrecision] / N[Sqrt[(-V)], $MachinePrecision]), $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision], N[(c0 * N[(N[Sqrt[A], $MachinePrecision] / N[Sqrt[N[(V * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[c0, A, V, l] = \mathsf{sort}([c0, A, V, l])\\
\\
\begin{array}{l}
\mathbf{if}\;A \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\frac{\frac{\sqrt{-A} \cdot c0}{\sqrt{-V}}}{\sqrt{\ell}}\\

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


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

    1. Initial program 74.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\sqrt{\color{blue}{\frac{\mathsf{neg}\left(A\right)}{\mathsf{neg}\left(V\right)}}} \cdot c0}{\sqrt{\ell}} \]
      6. sqrt-divN/A

        \[\leadsto \frac{\color{blue}{\frac{\sqrt{\mathsf{neg}\left(A\right)}}{\sqrt{\mathsf{neg}\left(V\right)}}} \cdot c0}{\sqrt{\ell}} \]
      7. associate-*l/N/A

        \[\leadsto \frac{\color{blue}{\frac{\sqrt{\mathsf{neg}\left(A\right)} \cdot c0}{\sqrt{\mathsf{neg}\left(V\right)}}}}{\sqrt{\ell}} \]
      8. lower-/.f64N/A

        \[\leadsto \frac{\color{blue}{\frac{\sqrt{\mathsf{neg}\left(A\right)} \cdot c0}{\sqrt{\mathsf{neg}\left(V\right)}}}}{\sqrt{\ell}} \]
      9. lower-*.f64N/A

        \[\leadsto \frac{\frac{\color{blue}{\sqrt{\mathsf{neg}\left(A\right)} \cdot c0}}{\sqrt{\mathsf{neg}\left(V\right)}}}{\sqrt{\ell}} \]
      10. lower-sqrt.f64N/A

        \[\leadsto \frac{\frac{\color{blue}{\sqrt{\mathsf{neg}\left(A\right)}} \cdot c0}{\sqrt{\mathsf{neg}\left(V\right)}}}{\sqrt{\ell}} \]
      11. lower-neg.f64N/A

        \[\leadsto \frac{\frac{\sqrt{\color{blue}{\mathsf{neg}\left(A\right)}} \cdot c0}{\sqrt{\mathsf{neg}\left(V\right)}}}{\sqrt{\ell}} \]
      12. lower-sqrt.f64N/A

        \[\leadsto \frac{\frac{\sqrt{\mathsf{neg}\left(A\right)} \cdot c0}{\color{blue}{\sqrt{\mathsf{neg}\left(V\right)}}}}{\sqrt{\ell}} \]
      13. lower-neg.f6445.8

        \[\leadsto \frac{\frac{\sqrt{-A} \cdot c0}{\sqrt{\color{blue}{-V}}}}{\sqrt{\ell}} \]
    6. Applied rewrites45.8%

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

    if -1.999999999999994e-310 < A

    1. Initial program 75.1%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Add Preprocessing
    3. 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.f6488.9

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

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

Alternative 9: 81.6% accurate, 0.5× speedup?

\[\begin{array}{l} [c0, A, V, l] = \mathsf{sort}([c0, A, V, l])\\ \\ \begin{array}{l} \mathbf{if}\;V \cdot \ell \leq 0:\\ \;\;\;\;\frac{c0}{\sqrt{V \cdot \frac{\ell}{A}}}\\ \mathbf{elif}\;V \cdot \ell \leq 2 \cdot 10^{+236}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{A}}{\sqrt{V \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{V}}{\ell}}\\ \end{array} \end{array} \]
NOTE: c0, A, V, and l should be sorted in increasing order before calling this function.
(FPCore (c0 A V l)
 :precision binary64
 (if (<= (* V l) 0.0)
   (/ c0 (sqrt (* V (/ l A))))
   (if (<= (* V l) 2e+236)
     (* c0 (/ (sqrt A) (sqrt (* V l))))
     (* c0 (sqrt (/ (/ A V) l))))))
assert(c0 < A && A < V && V < l);
double code(double c0, double A, double V, double l) {
	double tmp;
	if ((V * l) <= 0.0) {
		tmp = c0 / sqrt((V * (l / A)));
	} else if ((V * l) <= 2e+236) {
		tmp = c0 * (sqrt(A) / sqrt((V * l)));
	} else {
		tmp = c0 * sqrt(((A / V) / l));
	}
	return tmp;
}
NOTE: c0, A, V, and l should be sorted in increasing order before calling this function.
real(8) function code(c0, a, v, l)
    real(8), intent (in) :: c0
    real(8), intent (in) :: a
    real(8), intent (in) :: v
    real(8), intent (in) :: l
    real(8) :: tmp
    if ((v * l) <= 0.0d0) then
        tmp = c0 / sqrt((v * (l / a)))
    else if ((v * l) <= 2d+236) then
        tmp = c0 * (sqrt(a) / sqrt((v * l)))
    else
        tmp = c0 * sqrt(((a / v) / l))
    end if
    code = tmp
end function
assert c0 < A && A < V && V < l;
public static double code(double c0, double A, double V, double l) {
	double tmp;
	if ((V * l) <= 0.0) {
		tmp = c0 / Math.sqrt((V * (l / A)));
	} else if ((V * l) <= 2e+236) {
		tmp = c0 * (Math.sqrt(A) / Math.sqrt((V * l)));
	} else {
		tmp = c0 * Math.sqrt(((A / V) / l));
	}
	return tmp;
}
[c0, A, V, l] = sort([c0, A, V, l])
def code(c0, A, V, l):
	tmp = 0
	if (V * l) <= 0.0:
		tmp = c0 / math.sqrt((V * (l / A)))
	elif (V * l) <= 2e+236:
		tmp = c0 * (math.sqrt(A) / math.sqrt((V * l)))
	else:
		tmp = c0 * math.sqrt(((A / V) / l))
	return tmp
c0, A, V, l = sort([c0, A, V, l])
function code(c0, A, V, l)
	tmp = 0.0
	if (Float64(V * l) <= 0.0)
		tmp = Float64(c0 / sqrt(Float64(V * Float64(l / A))));
	elseif (Float64(V * l) <= 2e+236)
		tmp = Float64(c0 * Float64(sqrt(A) / sqrt(Float64(V * l))));
	else
		tmp = Float64(c0 * sqrt(Float64(Float64(A / V) / l)));
	end
	return tmp
end
c0, A, V, l = num2cell(sort([c0, A, V, l])){:}
function tmp_2 = code(c0, A, V, l)
	tmp = 0.0;
	if ((V * l) <= 0.0)
		tmp = c0 / sqrt((V * (l / A)));
	elseif ((V * l) <= 2e+236)
		tmp = c0 * (sqrt(A) / sqrt((V * l)));
	else
		tmp = c0 * sqrt(((A / V) / l));
	end
	tmp_2 = tmp;
end
NOTE: c0, A, V, and l should be sorted in increasing order before calling this function.
code[c0_, A_, V_, l_] := If[LessEqual[N[(V * l), $MachinePrecision], 0.0], N[(c0 / N[Sqrt[N[(V * N[(l / A), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(V * l), $MachinePrecision], 2e+236], N[(c0 * N[(N[Sqrt[A], $MachinePrecision] / N[Sqrt[N[(V * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 * N[Sqrt[N[(N[(A / V), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[c0, A, V, l] = \mathsf{sort}([c0, A, V, l])\\
\\
\begin{array}{l}
\mathbf{if}\;V \cdot \ell \leq 0:\\
\;\;\;\;\frac{c0}{\sqrt{V \cdot \frac{\ell}{A}}}\\

\mathbf{elif}\;V \cdot \ell \leq 2 \cdot 10^{+236}:\\
\;\;\;\;c0 \cdot \frac{\sqrt{A}}{\sqrt{V \cdot \ell}}\\

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


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

    1. Initial program 73.2%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Add Preprocessing
    3. 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-/l/N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{\sqrt{\frac{\color{blue}{\ell \cdot V}}{A}}} \]
      17. lower-*.f6473.4

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

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

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

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

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

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

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

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

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

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

    if 0.0 < (*.f64 V l) < 2.00000000000000011e236

    1. Initial program 80.7%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Add Preprocessing
    3. 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.f6498.6

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

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

    if 2.00000000000000011e236 < (*.f64 V l)

    1. Initial program 55.2%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Add Preprocessing
    3. 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-/.f6479.5

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

      \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{A}{V}}{\ell}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification83.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;V \cdot \ell \leq 0:\\ \;\;\;\;\frac{c0}{\sqrt{V \cdot \frac{\ell}{A}}}\\ \mathbf{elif}\;V \cdot \ell \leq 2 \cdot 10^{+236}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{A}}{\sqrt{V \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{V}}{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 77.4% accurate, 0.5× speedup?

\[\begin{array}{l} [c0, A, V, l] = \mathsf{sort}([c0, A, V, l])\\ \\ \begin{array}{l} \mathbf{if}\;\frac{A}{V \cdot \ell} \leq 4 \cdot 10^{-317}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{V}}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c0}{\sqrt{\frac{V \cdot \ell}{A}}}\\ \end{array} \end{array} \]
NOTE: c0, A, V, and l should be sorted in increasing order before calling this function.
(FPCore (c0 A V l)
 :precision binary64
 (if (<= (/ A (* V l)) 4e-317)
   (* c0 (sqrt (/ (/ A V) l)))
   (/ c0 (sqrt (/ (* V l) A)))))
assert(c0 < A && A < V && V < l);
double code(double c0, double A, double V, double l) {
	double tmp;
	if ((A / (V * l)) <= 4e-317) {
		tmp = c0 * sqrt(((A / V) / l));
	} else {
		tmp = c0 / sqrt(((V * l) / A));
	}
	return tmp;
}
NOTE: c0, A, V, and l should be sorted in increasing order before calling this function.
real(8) function code(c0, a, v, l)
    real(8), intent (in) :: c0
    real(8), intent (in) :: a
    real(8), intent (in) :: v
    real(8), intent (in) :: l
    real(8) :: tmp
    if ((a / (v * l)) <= 4d-317) then
        tmp = c0 * sqrt(((a / v) / l))
    else
        tmp = c0 / sqrt(((v * l) / a))
    end if
    code = tmp
end function
assert c0 < A && A < V && V < l;
public static double code(double c0, double A, double V, double l) {
	double tmp;
	if ((A / (V * l)) <= 4e-317) {
		tmp = c0 * Math.sqrt(((A / V) / l));
	} else {
		tmp = c0 / Math.sqrt(((V * l) / A));
	}
	return tmp;
}
[c0, A, V, l] = sort([c0, A, V, l])
def code(c0, A, V, l):
	tmp = 0
	if (A / (V * l)) <= 4e-317:
		tmp = c0 * math.sqrt(((A / V) / l))
	else:
		tmp = c0 / math.sqrt(((V * l) / A))
	return tmp
c0, A, V, l = sort([c0, A, V, l])
function code(c0, A, V, l)
	tmp = 0.0
	if (Float64(A / Float64(V * l)) <= 4e-317)
		tmp = Float64(c0 * sqrt(Float64(Float64(A / V) / l)));
	else
		tmp = Float64(c0 / sqrt(Float64(Float64(V * l) / A)));
	end
	return tmp
end
c0, A, V, l = num2cell(sort([c0, A, V, l])){:}
function tmp_2 = code(c0, A, V, l)
	tmp = 0.0;
	if ((A / (V * l)) <= 4e-317)
		tmp = c0 * sqrt(((A / V) / l));
	else
		tmp = c0 / sqrt(((V * l) / A));
	end
	tmp_2 = tmp;
end
NOTE: c0, A, V, and l should be sorted in increasing order before calling this function.
code[c0_, A_, V_, l_] := If[LessEqual[N[(A / N[(V * l), $MachinePrecision]), $MachinePrecision], 4e-317], N[(c0 * N[Sqrt[N[(N[(A / V), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(c0 / N[Sqrt[N[(N[(V * l), $MachinePrecision] / A), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[c0, A, V, l] = \mathsf{sort}([c0, A, V, l])\\
\\
\begin{array}{l}
\mathbf{if}\;\frac{A}{V \cdot \ell} \leq 4 \cdot 10^{-317}:\\
\;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{V}}{\ell}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 A (*.f64 V l)) < 3.99999993e-317

    1. Initial program 46.3%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Add Preprocessing
    3. 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-/.f6461.0

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

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

    if 3.99999993e-317 < (/.f64 A (*.f64 V l))

    1. Initial program 82.4%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 73.7% accurate, 1.0× speedup?

\[\begin{array}{l} [c0, A, V, l] = \mathsf{sort}([c0, A, V, l])\\ \\ c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \end{array} \]
NOTE: c0, A, V, and l should be sorted in increasing order before calling this function.
(FPCore (c0 A V l) :precision binary64 (* c0 (sqrt (/ A (* V l)))))
assert(c0 < A && A < V && V < l);
double code(double c0, double A, double V, double l) {
	return c0 * sqrt((A / (V * l)));
}
NOTE: c0, A, V, and l should be sorted in increasing order before calling this function.
real(8) function code(c0, a, v, l)
    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
assert c0 < A && A < V && V < l;
public static double code(double c0, double A, double V, double l) {
	return c0 * Math.sqrt((A / (V * l)));
}
[c0, A, V, l] = sort([c0, A, V, l])
def code(c0, A, V, l):
	return c0 * math.sqrt((A / (V * l)))
c0, A, V, l = sort([c0, A, V, l])
function code(c0, A, V, l)
	return Float64(c0 * sqrt(Float64(A / Float64(V * l))))
end
c0, A, V, l = num2cell(sort([c0, A, V, l])){:}
function tmp = code(c0, A, V, l)
	tmp = c0 * sqrt((A / (V * l)));
end
NOTE: c0, A, V, and l should be sorted in increasing order before calling this function.
code[c0_, A_, V_, l_] := N[(c0 * N[Sqrt[N[(A / N[(V * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[c0, A, V, l] = \mathsf{sort}([c0, A, V, l])\\
\\
c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}
\end{array}
Derivation
  1. Initial program 74.6%

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

Reproduce

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