Henrywood and Agarwal, Equation (3)

Percentage Accurate: 73.6% → 90.7%
Time: 15.9s
Alternatives: 13
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 13 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.6% 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: 90.7% accurate, 0.3× speedup?

\[\begin{array}{l} [c0, A, V, l] = \mathsf{sort}([c0, A, V, l])\\ \\ \begin{array}{l} \mathbf{if}\;A \leq -5 \cdot 10^{-310}:\\ \;\;\;\;\frac{c0}{\frac{\sqrt{\ell}}{\frac{\sqrt{-A}}{\sqrt{-V}}}}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \left(\sqrt{A} \cdot \sqrt{\frac{\frac{1}{V}}{\ell}}\right)\\ \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 -5e-310)
   (/ c0 (/ (sqrt l) (/ (sqrt (- A)) (sqrt (- V)))))
   (* c0 (* (sqrt A) (sqrt (/ (/ 1.0 V) l))))))
assert(c0 < A && A < V && V < l);
double code(double c0, double A, double V, double l) {
	double tmp;
	if (A <= -5e-310) {
		tmp = c0 / (sqrt(l) / (sqrt(-A) / sqrt(-V)));
	} else {
		tmp = c0 * (sqrt(A) * sqrt(((1.0 / 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 <= (-5d-310)) then
        tmp = c0 / (sqrt(l) / (sqrt(-a) / sqrt(-v)))
    else
        tmp = c0 * (sqrt(a) * sqrt(((1.0d0 / 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 <= -5e-310) {
		tmp = c0 / (Math.sqrt(l) / (Math.sqrt(-A) / Math.sqrt(-V)));
	} else {
		tmp = c0 * (Math.sqrt(A) * Math.sqrt(((1.0 / V) / l)));
	}
	return tmp;
}
[c0, A, V, l] = sort([c0, A, V, l])
def code(c0, A, V, l):
	tmp = 0
	if A <= -5e-310:
		tmp = c0 / (math.sqrt(l) / (math.sqrt(-A) / math.sqrt(-V)))
	else:
		tmp = c0 * (math.sqrt(A) * math.sqrt(((1.0 / V) / l)))
	return tmp
c0, A, V, l = sort([c0, A, V, l])
function code(c0, A, V, l)
	tmp = 0.0
	if (A <= -5e-310)
		tmp = Float64(c0 / Float64(sqrt(l) / Float64(sqrt(Float64(-A)) / sqrt(Float64(-V)))));
	else
		tmp = Float64(c0 * Float64(sqrt(A) * sqrt(Float64(Float64(1.0 / 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 <= -5e-310)
		tmp = c0 / (sqrt(l) / (sqrt(-A) / sqrt(-V)));
	else
		tmp = c0 * (sqrt(A) * sqrt(((1.0 / 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, -5e-310], N[(c0 / N[(N[Sqrt[l], $MachinePrecision] / N[(N[Sqrt[(-A)], $MachinePrecision] / N[Sqrt[(-V)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 * N[(N[Sqrt[A], $MachinePrecision] * N[Sqrt[N[(N[(1.0 / V), $MachinePrecision] / 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 -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{c0}{\frac{\sqrt{\ell}}{\frac{\sqrt{-A}}{\sqrt{-V}}}}\\

\mathbf{else}:\\
\;\;\;\;c0 \cdot \left(\sqrt{A} \cdot \sqrt{\frac{\frac{1}{V}}{\ell}}\right)\\


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

    1. Initial program 75.7%

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

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

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

        \[\leadsto \color{blue}{\frac{c0 \cdot \sqrt{\frac{A}{V}}}{\sqrt{\ell}}} \]
    4. Applied egg-rr41.1%

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

        \[\leadsto \color{blue}{\frac{c0}{\frac{\sqrt{\ell}}{\sqrt{\frac{A}{V}}}}} \]
    6. Simplified43.1%

      \[\leadsto \color{blue}{\frac{c0}{\frac{\sqrt{\ell}}{\sqrt{\frac{A}{V}}}}} \]
    7. Step-by-step derivation
      1. frac-2neg43.1%

        \[\leadsto \frac{c0}{\frac{\sqrt{\ell}}{\sqrt{\color{blue}{\frac{-A}{-V}}}}} \]
      2. sqrt-div50.8%

        \[\leadsto \frac{c0}{\frac{\sqrt{\ell}}{\color{blue}{\frac{\sqrt{-A}}{\sqrt{-V}}}}} \]
    8. Applied egg-rr50.8%

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

    if -4.999999999999985e-310 < A

    1. Initial program 72.8%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. div-inv72.2%

        \[\leadsto c0 \cdot \sqrt{\color{blue}{A \cdot \frac{1}{V \cdot \ell}}} \]
      2. sqrt-prod85.0%

        \[\leadsto c0 \cdot \color{blue}{\left(\sqrt{A} \cdot \sqrt{\frac{1}{V \cdot \ell}}\right)} \]
      3. associate-/r*85.5%

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

      \[\leadsto c0 \cdot \color{blue}{\left(\sqrt{A} \cdot \sqrt{\frac{\frac{1}{V}}{\ell}}\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification67.6%

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

Alternative 2: 87.7% accurate, 0.3× speedup?

\[\begin{array}{l} [c0, A, V, l] = \mathsf{sort}([c0, A, V, l])\\ \\ \begin{array}{l} \mathbf{if}\;V \leq -5 \cdot 10^{-310}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{\frac{-1}{V}}}{\sqrt{\frac{-\ell}{A}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c0 \cdot \sqrt{A}}{\frac{\sqrt{\ell}}{{V}^{-0.5}}}\\ \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 -5e-310)
   (* c0 (/ (sqrt (/ -1.0 V)) (sqrt (/ (- l) A))))
   (/ (* c0 (sqrt A)) (/ (sqrt l) (pow V -0.5)))))
assert(c0 < A && A < V && V < l);
double code(double c0, double A, double V, double l) {
	double tmp;
	if (V <= -5e-310) {
		tmp = c0 * (sqrt((-1.0 / V)) / sqrt((-l / A)));
	} else {
		tmp = (c0 * sqrt(A)) / (sqrt(l) / pow(V, -0.5));
	}
	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 <= (-5d-310)) then
        tmp = c0 * (sqrt(((-1.0d0) / v)) / sqrt((-l / a)))
    else
        tmp = (c0 * sqrt(a)) / (sqrt(l) / (v ** (-0.5d0)))
    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 <= -5e-310) {
		tmp = c0 * (Math.sqrt((-1.0 / V)) / Math.sqrt((-l / A)));
	} else {
		tmp = (c0 * Math.sqrt(A)) / (Math.sqrt(l) / Math.pow(V, -0.5));
	}
	return tmp;
}
[c0, A, V, l] = sort([c0, A, V, l])
def code(c0, A, V, l):
	tmp = 0
	if V <= -5e-310:
		tmp = c0 * (math.sqrt((-1.0 / V)) / math.sqrt((-l / A)))
	else:
		tmp = (c0 * math.sqrt(A)) / (math.sqrt(l) / math.pow(V, -0.5))
	return tmp
c0, A, V, l = sort([c0, A, V, l])
function code(c0, A, V, l)
	tmp = 0.0
	if (V <= -5e-310)
		tmp = Float64(c0 * Float64(sqrt(Float64(-1.0 / V)) / sqrt(Float64(Float64(-l) / A))));
	else
		tmp = Float64(Float64(c0 * sqrt(A)) / Float64(sqrt(l) / (V ^ -0.5)));
	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 <= -5e-310)
		tmp = c0 * (sqrt((-1.0 / V)) / sqrt((-l / A)));
	else
		tmp = (c0 * sqrt(A)) / (sqrt(l) / (V ^ -0.5));
	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[V, -5e-310], N[(c0 * N[(N[Sqrt[N[(-1.0 / V), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[((-l) / A), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c0 * N[Sqrt[A], $MachinePrecision]), $MachinePrecision] / N[(N[Sqrt[l], $MachinePrecision] / N[Power[V, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[c0, A, V, l] = \mathsf{sort}([c0, A, V, l])\\
\\
\begin{array}{l}
\mathbf{if}\;V \leq -5 \cdot 10^{-310}:\\
\;\;\;\;c0 \cdot \frac{\sqrt{\frac{-1}{V}}}{\sqrt{\frac{-\ell}{A}}}\\

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


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

    1. Initial program 72.6%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. clear-num71.9%

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{1}{\frac{V \cdot \ell}{A}}}} \]
      2. associate-/r/72.5%

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

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

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

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{1}{V} \cdot A}{\ell}}} \]
      2. associate-*r/70.9%

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

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{1 \cdot \frac{A}{\ell}}{V}}} \]
      4. *-un-lft-identity70.9%

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

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

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{A}{V \cdot \ell}}} \]
      2. *-un-lft-identity72.6%

        \[\leadsto c0 \cdot \sqrt{\frac{\color{blue}{1 \cdot A}}{V \cdot \ell}} \]
      3. frac-times70.9%

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{1}{V} \cdot \frac{A}{\ell}}} \]
      4. clear-num70.9%

        \[\leadsto c0 \cdot \sqrt{\frac{1}{V} \cdot \color{blue}{\frac{1}{\frac{\ell}{A}}}} \]
      5. div-inv70.9%

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{1}{V}}{\frac{\ell}{A}}}} \]
      6. frac-2neg70.9%

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{-\frac{1}{V}}{-\frac{\ell}{A}}}} \]
      7. sqrt-div82.8%

        \[\leadsto c0 \cdot \color{blue}{\frac{\sqrt{-\frac{1}{V}}}{\sqrt{-\frac{\ell}{A}}}} \]
      8. distribute-neg-frac82.8%

        \[\leadsto c0 \cdot \frac{\sqrt{\color{blue}{\frac{-1}{V}}}}{\sqrt{-\frac{\ell}{A}}} \]
      9. metadata-eval82.8%

        \[\leadsto c0 \cdot \frac{\sqrt{\frac{\color{blue}{-1}}{V}}}{\sqrt{-\frac{\ell}{A}}} \]
      10. distribute-neg-frac82.8%

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

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

    if -4.999999999999985e-310 < V

    1. Initial program 76.0%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. clear-num75.8%

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{1}{\frac{V \cdot \ell}{A}}}} \]
      2. associate-/r/75.4%

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

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

      \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{1}{V}}{\ell} \cdot A}} \]
    5. Step-by-step derivation
      1. sqrt-prod44.0%

        \[\leadsto c0 \cdot \color{blue}{\left(\sqrt{\frac{\frac{1}{V}}{\ell}} \cdot \sqrt{A}\right)} \]
      2. *-commutative44.0%

        \[\leadsto c0 \cdot \color{blue}{\left(\sqrt{A} \cdot \sqrt{\frac{\frac{1}{V}}{\ell}}\right)} \]
      3. associate-*r*41.9%

        \[\leadsto \color{blue}{\left(c0 \cdot \sqrt{A}\right) \cdot \sqrt{\frac{\frac{1}{V}}{\ell}}} \]
      4. *-commutative41.9%

        \[\leadsto \color{blue}{\left(\sqrt{A} \cdot c0\right)} \cdot \sqrt{\frac{\frac{1}{V}}{\ell}} \]
      5. sqrt-div47.9%

        \[\leadsto \left(\sqrt{A} \cdot c0\right) \cdot \color{blue}{\frac{\sqrt{\frac{1}{V}}}{\sqrt{\ell}}} \]
      6. associate-*r/47.2%

        \[\leadsto \color{blue}{\frac{\left(\sqrt{A} \cdot c0\right) \cdot \sqrt{\frac{1}{V}}}{\sqrt{\ell}}} \]
      7. *-commutative47.2%

        \[\leadsto \frac{\color{blue}{\left(c0 \cdot \sqrt{A}\right)} \cdot \sqrt{\frac{1}{V}}}{\sqrt{\ell}} \]
      8. inv-pow47.2%

        \[\leadsto \frac{\left(c0 \cdot \sqrt{A}\right) \cdot \sqrt{\color{blue}{{V}^{-1}}}}{\sqrt{\ell}} \]
      9. sqrt-pow147.2%

        \[\leadsto \frac{\left(c0 \cdot \sqrt{A}\right) \cdot \color{blue}{{V}^{\left(\frac{-1}{2}\right)}}}{\sqrt{\ell}} \]
      10. metadata-eval47.2%

        \[\leadsto \frac{\left(c0 \cdot \sqrt{A}\right) \cdot {V}^{\color{blue}{-0.5}}}{\sqrt{\ell}} \]
    6. Applied egg-rr47.2%

      \[\leadsto \color{blue}{\frac{\left(c0 \cdot \sqrt{A}\right) \cdot {V}^{-0.5}}{\sqrt{\ell}}} \]
    7. Step-by-step derivation
      1. associate-/l*47.9%

        \[\leadsto \color{blue}{\frac{c0 \cdot \sqrt{A}}{\frac{\sqrt{\ell}}{{V}^{-0.5}}}} \]
    8. Simplified47.9%

      \[\leadsto \color{blue}{\frac{c0 \cdot \sqrt{A}}{\frac{\sqrt{\ell}}{{V}^{-0.5}}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification65.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;V \leq -5 \cdot 10^{-310}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{\frac{-1}{V}}}{\sqrt{\frac{-\ell}{A}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c0 \cdot \sqrt{A}}{\frac{\sqrt{\ell}}{{V}^{-0.5}}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 85.0% accurate, 0.5× speedup?

\[\begin{array}{l} [c0, A, V, l] = \mathsf{sort}([c0, A, V, l])\\ \\ \begin{array}{l} \mathbf{if}\;\ell \cdot V \leq -\infty:\\ \;\;\;\;c0 \cdot \frac{\sqrt{\frac{A}{V}}}{\sqrt{\ell}}\\ \mathbf{elif}\;\ell \cdot V \leq -5 \cdot 10^{-297}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{-A}}{\sqrt{\ell \cdot \left(-V\right)}}\\ \mathbf{elif}\;\ell \cdot V \leq 10^{-302}:\\ \;\;\;\;\sqrt{\frac{A}{\ell} \cdot \frac{{c0}^{2}}{V}}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \left(\sqrt{A} \cdot \sqrt{\frac{\frac{1}{V}}{\ell}}\right)\\ \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 (<= (* l V) (- INFINITY))
   (* c0 (/ (sqrt (/ A V)) (sqrt l)))
   (if (<= (* l V) -5e-297)
     (* c0 (/ (sqrt (- A)) (sqrt (* l (- V)))))
     (if (<= (* l V) 1e-302)
       (sqrt (* (/ A l) (/ (pow c0 2.0) V)))
       (* c0 (* (sqrt A) (sqrt (/ (/ 1.0 V) l))))))))
assert(c0 < A && A < V && V < l);
double code(double c0, double A, double V, double l) {
	double tmp;
	if ((l * V) <= -((double) INFINITY)) {
		tmp = c0 * (sqrt((A / V)) / sqrt(l));
	} else if ((l * V) <= -5e-297) {
		tmp = c0 * (sqrt(-A) / sqrt((l * -V)));
	} else if ((l * V) <= 1e-302) {
		tmp = sqrt(((A / l) * (pow(c0, 2.0) / V)));
	} else {
		tmp = c0 * (sqrt(A) * sqrt(((1.0 / 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 ((l * V) <= -Double.POSITIVE_INFINITY) {
		tmp = c0 * (Math.sqrt((A / V)) / Math.sqrt(l));
	} else if ((l * V) <= -5e-297) {
		tmp = c0 * (Math.sqrt(-A) / Math.sqrt((l * -V)));
	} else if ((l * V) <= 1e-302) {
		tmp = Math.sqrt(((A / l) * (Math.pow(c0, 2.0) / V)));
	} else {
		tmp = c0 * (Math.sqrt(A) * Math.sqrt(((1.0 / V) / l)));
	}
	return tmp;
}
[c0, A, V, l] = sort([c0, A, V, l])
def code(c0, A, V, l):
	tmp = 0
	if (l * V) <= -math.inf:
		tmp = c0 * (math.sqrt((A / V)) / math.sqrt(l))
	elif (l * V) <= -5e-297:
		tmp = c0 * (math.sqrt(-A) / math.sqrt((l * -V)))
	elif (l * V) <= 1e-302:
		tmp = math.sqrt(((A / l) * (math.pow(c0, 2.0) / V)))
	else:
		tmp = c0 * (math.sqrt(A) * math.sqrt(((1.0 / V) / l)))
	return tmp
c0, A, V, l = sort([c0, A, V, l])
function code(c0, A, V, l)
	tmp = 0.0
	if (Float64(l * V) <= Float64(-Inf))
		tmp = Float64(c0 * Float64(sqrt(Float64(A / V)) / sqrt(l)));
	elseif (Float64(l * V) <= -5e-297)
		tmp = Float64(c0 * Float64(sqrt(Float64(-A)) / sqrt(Float64(l * Float64(-V)))));
	elseif (Float64(l * V) <= 1e-302)
		tmp = sqrt(Float64(Float64(A / l) * Float64((c0 ^ 2.0) / V)));
	else
		tmp = Float64(c0 * Float64(sqrt(A) * sqrt(Float64(Float64(1.0 / 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 ((l * V) <= -Inf)
		tmp = c0 * (sqrt((A / V)) / sqrt(l));
	elseif ((l * V) <= -5e-297)
		tmp = c0 * (sqrt(-A) / sqrt((l * -V)));
	elseif ((l * V) <= 1e-302)
		tmp = sqrt(((A / l) * ((c0 ^ 2.0) / V)));
	else
		tmp = c0 * (sqrt(A) * sqrt(((1.0 / 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[(l * V), $MachinePrecision], (-Infinity)], N[(c0 * N[(N[Sqrt[N[(A / V), $MachinePrecision]], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(l * V), $MachinePrecision], -5e-297], N[(c0 * N[(N[Sqrt[(-A)], $MachinePrecision] / N[Sqrt[N[(l * (-V)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(l * V), $MachinePrecision], 1e-302], N[Sqrt[N[(N[(A / l), $MachinePrecision] * N[(N[Power[c0, 2.0], $MachinePrecision] / V), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(c0 * N[(N[Sqrt[A], $MachinePrecision] * N[Sqrt[N[(N[(1.0 / V), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[c0, A, V, l] = \mathsf{sort}([c0, A, V, l])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \cdot V \leq -\infty:\\
\;\;\;\;c0 \cdot \frac{\sqrt{\frac{A}{V}}}{\sqrt{\ell}}\\

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

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

\mathbf{else}:\\
\;\;\;\;c0 \cdot \left(\sqrt{A} \cdot \sqrt{\frac{\frac{1}{V}}{\ell}}\right)\\


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

    1. Initial program 36.6%

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

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

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

        \[\leadsto \color{blue}{\frac{c0 \cdot \sqrt{\frac{A}{V}}}{\sqrt{\ell}}} \]
    4. Applied egg-rr52.1%

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

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

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

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

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

    if -inf.0 < (*.f64 V l) < -5e-297

    1. Initial program 86.3%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. frac-2neg86.3%

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

        \[\leadsto c0 \cdot \color{blue}{\frac{\sqrt{-A}}{\sqrt{-V \cdot \ell}}} \]
      3. distribute-rgt-neg-in99.4%

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

      \[\leadsto c0 \cdot \color{blue}{\frac{\sqrt{-A}}{\sqrt{V \cdot \left(-\ell\right)}}} \]
    5. Step-by-step derivation
      1. distribute-rgt-neg-out99.4%

        \[\leadsto c0 \cdot \frac{\sqrt{-A}}{\sqrt{\color{blue}{-V \cdot \ell}}} \]
      2. *-commutative99.4%

        \[\leadsto c0 \cdot \frac{\sqrt{-A}}{\sqrt{-\color{blue}{\ell \cdot V}}} \]
      3. distribute-rgt-neg-in99.4%

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

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

    if -5e-297 < (*.f64 V l) < 9.9999999999999996e-303

    1. Initial program 54.6%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. clear-num54.6%

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{1}{\frac{V \cdot \ell}{A}}}} \]
      2. associate-/r/52.2%

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

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

      \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{1}{V}}{\ell} \cdot A}} \]
    5. Step-by-step derivation
      1. sqrt-prod34.6%

        \[\leadsto c0 \cdot \color{blue}{\left(\sqrt{\frac{\frac{1}{V}}{\ell}} \cdot \sqrt{A}\right)} \]
      2. *-commutative34.6%

        \[\leadsto c0 \cdot \color{blue}{\left(\sqrt{A} \cdot \sqrt{\frac{\frac{1}{V}}{\ell}}\right)} \]
      3. add-sqr-sqrt20.3%

        \[\leadsto \color{blue}{\sqrt{c0 \cdot \left(\sqrt{A} \cdot \sqrt{\frac{\frac{1}{V}}{\ell}}\right)} \cdot \sqrt{c0 \cdot \left(\sqrt{A} \cdot \sqrt{\frac{\frac{1}{V}}{\ell}}\right)}} \]
      4. sqrt-unprod20.5%

        \[\leadsto \color{blue}{\sqrt{\left(c0 \cdot \left(\sqrt{A} \cdot \sqrt{\frac{\frac{1}{V}}{\ell}}\right)\right) \cdot \left(c0 \cdot \left(\sqrt{A} \cdot \sqrt{\frac{\frac{1}{V}}{\ell}}\right)\right)}} \]
      5. *-commutative20.5%

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

        \[\leadsto \sqrt{\left(\left(\sqrt{A} \cdot \sqrt{\frac{\frac{1}{V}}{\ell}}\right) \cdot c0\right) \cdot \color{blue}{\left(\left(\sqrt{A} \cdot \sqrt{\frac{\frac{1}{V}}{\ell}}\right) \cdot c0\right)}} \]
      7. swap-sqr20.2%

        \[\leadsto \sqrt{\color{blue}{\left(\left(\sqrt{A} \cdot \sqrt{\frac{\frac{1}{V}}{\ell}}\right) \cdot \left(\sqrt{A} \cdot \sqrt{\frac{\frac{1}{V}}{\ell}}\right)\right) \cdot \left(c0 \cdot c0\right)}} \]
      8. swap-sqr20.2%

        \[\leadsto \sqrt{\color{blue}{\left(\left(\sqrt{A} \cdot \sqrt{A}\right) \cdot \left(\sqrt{\frac{\frac{1}{V}}{\ell}} \cdot \sqrt{\frac{\frac{1}{V}}{\ell}}\right)\right)} \cdot \left(c0 \cdot c0\right)} \]
      9. add-sqr-sqrt20.2%

        \[\leadsto \sqrt{\left(\color{blue}{A} \cdot \left(\sqrt{\frac{\frac{1}{V}}{\ell}} \cdot \sqrt{\frac{\frac{1}{V}}{\ell}}\right)\right) \cdot \left(c0 \cdot c0\right)} \]
      10. add-sqr-sqrt36.9%

        \[\leadsto \sqrt{\left(A \cdot \color{blue}{\frac{\frac{1}{V}}{\ell}}\right) \cdot \left(c0 \cdot c0\right)} \]
      11. associate-/r*36.9%

        \[\leadsto \sqrt{\left(A \cdot \color{blue}{\frac{1}{V \cdot \ell}}\right) \cdot \left(c0 \cdot c0\right)} \]
      12. div-inv39.3%

        \[\leadsto \sqrt{\color{blue}{\frac{A}{V \cdot \ell}} \cdot \left(c0 \cdot c0\right)} \]
      13. pow239.3%

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

      \[\leadsto \color{blue}{\sqrt{\frac{A}{V \cdot \ell} \cdot {c0}^{2}}} \]
    7. Step-by-step derivation
      1. associate-*l/39.4%

        \[\leadsto \sqrt{\color{blue}{\frac{A \cdot {c0}^{2}}{V \cdot \ell}}} \]
      2. *-commutative39.4%

        \[\leadsto \sqrt{\frac{A \cdot {c0}^{2}}{\color{blue}{\ell \cdot V}}} \]
      3. times-frac40.3%

        \[\leadsto \sqrt{\color{blue}{\frac{A}{\ell} \cdot \frac{{c0}^{2}}{V}}} \]
    8. Simplified40.3%

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

    if 9.9999999999999996e-303 < (*.f64 V l)

    1. Initial program 75.6%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. div-inv75.6%

        \[\leadsto c0 \cdot \sqrt{\color{blue}{A \cdot \frac{1}{V \cdot \ell}}} \]
      2. sqrt-prod89.6%

        \[\leadsto c0 \cdot \color{blue}{\left(\sqrt{A} \cdot \sqrt{\frac{1}{V \cdot \ell}}\right)} \]
      3. associate-/r*90.3%

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

      \[\leadsto c0 \cdot \color{blue}{\left(\sqrt{A} \cdot \sqrt{\frac{\frac{1}{V}}{\ell}}\right)} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification85.0%

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

Alternative 4: 82.4% accurate, 0.5× speedup?

\[\begin{array}{l} [c0, A, V, l] = \mathsf{sort}([c0, A, V, l])\\ \\ \begin{array}{l} t_0 := \frac{\frac{1}{V}}{\ell}\\ \mathbf{if}\;A \leq -4.2 \cdot 10^{-132}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{\frac{A}{V}}}{\sqrt{\ell}}\\ \mathbf{elif}\;A \leq 1.3 \cdot 10^{-305}:\\ \;\;\;\;c0 \cdot \sqrt{A \cdot t_0}\\ \mathbf{elif}\;A \leq 8.2 \cdot 10^{-169}:\\ \;\;\;\;\sqrt{A} \cdot \left(c0 \cdot {\left(\ell \cdot V\right)}^{-0.5}\right)\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \left(\sqrt{A} \cdot \sqrt{t_0}\right)\\ \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 (/ (/ 1.0 V) l)))
   (if (<= A -4.2e-132)
     (* c0 (/ (sqrt (/ A V)) (sqrt l)))
     (if (<= A 1.3e-305)
       (* c0 (sqrt (* A t_0)))
       (if (<= A 8.2e-169)
         (* (sqrt A) (* c0 (pow (* l V) -0.5)))
         (* c0 (* (sqrt A) (sqrt t_0))))))))
assert(c0 < A && A < V && V < l);
double code(double c0, double A, double V, double l) {
	double t_0 = (1.0 / V) / l;
	double tmp;
	if (A <= -4.2e-132) {
		tmp = c0 * (sqrt((A / V)) / sqrt(l));
	} else if (A <= 1.3e-305) {
		tmp = c0 * sqrt((A * t_0));
	} else if (A <= 8.2e-169) {
		tmp = sqrt(A) * (c0 * pow((l * V), -0.5));
	} else {
		tmp = c0 * (sqrt(A) * sqrt(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 = (1.0d0 / v) / l
    if (a <= (-4.2d-132)) then
        tmp = c0 * (sqrt((a / v)) / sqrt(l))
    else if (a <= 1.3d-305) then
        tmp = c0 * sqrt((a * t_0))
    else if (a <= 8.2d-169) then
        tmp = sqrt(a) * (c0 * ((l * v) ** (-0.5d0)))
    else
        tmp = c0 * (sqrt(a) * sqrt(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 = (1.0 / V) / l;
	double tmp;
	if (A <= -4.2e-132) {
		tmp = c0 * (Math.sqrt((A / V)) / Math.sqrt(l));
	} else if (A <= 1.3e-305) {
		tmp = c0 * Math.sqrt((A * t_0));
	} else if (A <= 8.2e-169) {
		tmp = Math.sqrt(A) * (c0 * Math.pow((l * V), -0.5));
	} else {
		tmp = c0 * (Math.sqrt(A) * Math.sqrt(t_0));
	}
	return tmp;
}
[c0, A, V, l] = sort([c0, A, V, l])
def code(c0, A, V, l):
	t_0 = (1.0 / V) / l
	tmp = 0
	if A <= -4.2e-132:
		tmp = c0 * (math.sqrt((A / V)) / math.sqrt(l))
	elif A <= 1.3e-305:
		tmp = c0 * math.sqrt((A * t_0))
	elif A <= 8.2e-169:
		tmp = math.sqrt(A) * (c0 * math.pow((l * V), -0.5))
	else:
		tmp = c0 * (math.sqrt(A) * math.sqrt(t_0))
	return tmp
c0, A, V, l = sort([c0, A, V, l])
function code(c0, A, V, l)
	t_0 = Float64(Float64(1.0 / V) / l)
	tmp = 0.0
	if (A <= -4.2e-132)
		tmp = Float64(c0 * Float64(sqrt(Float64(A / V)) / sqrt(l)));
	elseif (A <= 1.3e-305)
		tmp = Float64(c0 * sqrt(Float64(A * t_0)));
	elseif (A <= 8.2e-169)
		tmp = Float64(sqrt(A) * Float64(c0 * (Float64(l * V) ^ -0.5)));
	else
		tmp = Float64(c0 * Float64(sqrt(A) * sqrt(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 = (1.0 / V) / l;
	tmp = 0.0;
	if (A <= -4.2e-132)
		tmp = c0 * (sqrt((A / V)) / sqrt(l));
	elseif (A <= 1.3e-305)
		tmp = c0 * sqrt((A * t_0));
	elseif (A <= 8.2e-169)
		tmp = sqrt(A) * (c0 * ((l * V) ^ -0.5));
	else
		tmp = c0 * (sqrt(A) * sqrt(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[(N[(1.0 / V), $MachinePrecision] / l), $MachinePrecision]}, If[LessEqual[A, -4.2e-132], N[(c0 * N[(N[Sqrt[N[(A / V), $MachinePrecision]], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[A, 1.3e-305], N[(c0 * N[Sqrt[N[(A * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[A, 8.2e-169], N[(N[Sqrt[A], $MachinePrecision] * N[(c0 * N[Power[N[(l * V), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 * N[(N[Sqrt[A], $MachinePrecision] * N[Sqrt[t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
[c0, A, V, l] = \mathsf{sort}([c0, A, V, l])\\
\\
\begin{array}{l}
t_0 := \frac{\frac{1}{V}}{\ell}\\
\mathbf{if}\;A \leq -4.2 \cdot 10^{-132}:\\
\;\;\;\;c0 \cdot \frac{\sqrt{\frac{A}{V}}}{\sqrt{\ell}}\\

\mathbf{elif}\;A \leq 1.3 \cdot 10^{-305}:\\
\;\;\;\;c0 \cdot \sqrt{A \cdot t_0}\\

\mathbf{elif}\;A \leq 8.2 \cdot 10^{-169}:\\
\;\;\;\;\sqrt{A} \cdot \left(c0 \cdot {\left(\ell \cdot V\right)}^{-0.5}\right)\\

\mathbf{else}:\\
\;\;\;\;c0 \cdot \left(\sqrt{A} \cdot \sqrt{t_0}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if A < -4.2000000000000002e-132

    1. Initial program 73.5%

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

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

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

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

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

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

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

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

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

    if -4.2000000000000002e-132 < A < 1.3000000000000001e-305

    1. Initial program 82.2%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. clear-num82.2%

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{1}{\frac{V \cdot \ell}{A}}}} \]
      2. associate-/r/82.2%

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

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

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

    if 1.3000000000000001e-305 < A < 8.1999999999999996e-169

    1. Initial program 72.5%

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

        \[\leadsto \color{blue}{\sqrt{\frac{A}{V \cdot \ell}} \cdot c0} \]
      2. sqrt-div92.0%

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

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

      \[\leadsto \color{blue}{\frac{\sqrt{A} \cdot c0}{\sqrt{V \cdot \ell}}} \]
    5. Step-by-step derivation
      1. div-inv85.4%

        \[\leadsto \color{blue}{\left(\sqrt{A} \cdot c0\right) \cdot \frac{1}{\sqrt{V \cdot \ell}}} \]
      2. *-commutative85.4%

        \[\leadsto \color{blue}{\left(c0 \cdot \sqrt{A}\right)} \cdot \frac{1}{\sqrt{V \cdot \ell}} \]
      3. metadata-eval85.4%

        \[\leadsto \left(c0 \cdot \sqrt{A}\right) \cdot \frac{\color{blue}{\sqrt{1}}}{\sqrt{V \cdot \ell}} \]
      4. sqrt-div82.8%

        \[\leadsto \left(c0 \cdot \sqrt{A}\right) \cdot \color{blue}{\sqrt{\frac{1}{V \cdot \ell}}} \]
      5. associate-/r*82.7%

        \[\leadsto \left(c0 \cdot \sqrt{A}\right) \cdot \sqrt{\color{blue}{\frac{\frac{1}{V}}{\ell}}} \]
      6. associate-*r*89.2%

        \[\leadsto \color{blue}{c0 \cdot \left(\sqrt{A} \cdot \sqrt{\frac{\frac{1}{V}}{\ell}}\right)} \]
      7. *-commutative89.2%

        \[\leadsto c0 \cdot \color{blue}{\left(\sqrt{\frac{\frac{1}{V}}{\ell}} \cdot \sqrt{A}\right)} \]
      8. associate-*r*89.3%

        \[\leadsto \color{blue}{\left(c0 \cdot \sqrt{\frac{\frac{1}{V}}{\ell}}\right) \cdot \sqrt{A}} \]
      9. associate-/r*89.5%

        \[\leadsto \left(c0 \cdot \sqrt{\color{blue}{\frac{1}{V \cdot \ell}}}\right) \cdot \sqrt{A} \]
      10. sqrt-div92.0%

        \[\leadsto \left(c0 \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{V \cdot \ell}}}\right) \cdot \sqrt{A} \]
      11. metadata-eval92.0%

        \[\leadsto \left(c0 \cdot \frac{\color{blue}{1}}{\sqrt{V \cdot \ell}}\right) \cdot \sqrt{A} \]
      12. pow1/292.0%

        \[\leadsto \left(c0 \cdot \frac{1}{\color{blue}{{\left(V \cdot \ell\right)}^{0.5}}}\right) \cdot \sqrt{A} \]
      13. pow-flip92.1%

        \[\leadsto \left(c0 \cdot \color{blue}{{\left(V \cdot \ell\right)}^{\left(-0.5\right)}}\right) \cdot \sqrt{A} \]
      14. metadata-eval92.1%

        \[\leadsto \left(c0 \cdot {\left(V \cdot \ell\right)}^{\color{blue}{-0.5}}\right) \cdot \sqrt{A} \]
    6. Applied egg-rr92.1%

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

    if 8.1999999999999996e-169 < A

    1. Initial program 72.6%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. div-inv72.6%

        \[\leadsto c0 \cdot \sqrt{\color{blue}{A \cdot \frac{1}{V \cdot \ell}}} \]
      2. sqrt-prod83.5%

        \[\leadsto c0 \cdot \color{blue}{\left(\sqrt{A} \cdot \sqrt{\frac{1}{V \cdot \ell}}\right)} \]
      3. associate-/r*84.3%

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

      \[\leadsto c0 \cdot \color{blue}{\left(\sqrt{A} \cdot \sqrt{\frac{\frac{1}{V}}{\ell}}\right)} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification70.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;A \leq -4.2 \cdot 10^{-132}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{\frac{A}{V}}}{\sqrt{\ell}}\\ \mathbf{elif}\;A \leq 1.3 \cdot 10^{-305}:\\ \;\;\;\;c0 \cdot \sqrt{A \cdot \frac{\frac{1}{V}}{\ell}}\\ \mathbf{elif}\;A \leq 8.2 \cdot 10^{-169}:\\ \;\;\;\;\sqrt{A} \cdot \left(c0 \cdot {\left(\ell \cdot V\right)}^{-0.5}\right)\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \left(\sqrt{A} \cdot \sqrt{\frac{\frac{1}{V}}{\ell}}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 79.3% accurate, 0.5× speedup?

\[\begin{array}{l} [c0, A, V, l] = \mathsf{sort}([c0, A, V, l])\\ \\ \begin{array}{l} \mathbf{if}\;\ell \cdot V \leq -1 \cdot 10^{+234}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{V}}{\ell}}\\ \mathbf{elif}\;\ell \cdot V \leq 4 \cdot 10^{-314}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{1}{\frac{\ell \cdot V}{A}}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{A} \cdot \frac{c0}{\sqrt{\ell \cdot V}}\\ \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 (<= (* l V) -1e+234)
   (* c0 (sqrt (/ (/ A V) l)))
   (if (<= (* l V) 4e-314)
     (* c0 (sqrt (/ 1.0 (/ (* l V) A))))
     (* (sqrt A) (/ c0 (sqrt (* l V)))))))
assert(c0 < A && A < V && V < l);
double code(double c0, double A, double V, double l) {
	double tmp;
	if ((l * V) <= -1e+234) {
		tmp = c0 * sqrt(((A / V) / l));
	} else if ((l * V) <= 4e-314) {
		tmp = c0 * sqrt((1.0 / ((l * V) / A)));
	} else {
		tmp = sqrt(A) * (c0 / sqrt((l * V)));
	}
	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 ((l * v) <= (-1d+234)) then
        tmp = c0 * sqrt(((a / v) / l))
    else if ((l * v) <= 4d-314) then
        tmp = c0 * sqrt((1.0d0 / ((l * v) / a)))
    else
        tmp = sqrt(a) * (c0 / sqrt((l * v)))
    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 ((l * V) <= -1e+234) {
		tmp = c0 * Math.sqrt(((A / V) / l));
	} else if ((l * V) <= 4e-314) {
		tmp = c0 * Math.sqrt((1.0 / ((l * V) / A)));
	} else {
		tmp = Math.sqrt(A) * (c0 / Math.sqrt((l * V)));
	}
	return tmp;
}
[c0, A, V, l] = sort([c0, A, V, l])
def code(c0, A, V, l):
	tmp = 0
	if (l * V) <= -1e+234:
		tmp = c0 * math.sqrt(((A / V) / l))
	elif (l * V) <= 4e-314:
		tmp = c0 * math.sqrt((1.0 / ((l * V) / A)))
	else:
		tmp = math.sqrt(A) * (c0 / math.sqrt((l * V)))
	return tmp
c0, A, V, l = sort([c0, A, V, l])
function code(c0, A, V, l)
	tmp = 0.0
	if (Float64(l * V) <= -1e+234)
		tmp = Float64(c0 * sqrt(Float64(Float64(A / V) / l)));
	elseif (Float64(l * V) <= 4e-314)
		tmp = Float64(c0 * sqrt(Float64(1.0 / Float64(Float64(l * V) / A))));
	else
		tmp = Float64(sqrt(A) * Float64(c0 / sqrt(Float64(l * V))));
	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 ((l * V) <= -1e+234)
		tmp = c0 * sqrt(((A / V) / l));
	elseif ((l * V) <= 4e-314)
		tmp = c0 * sqrt((1.0 / ((l * V) / A)));
	else
		tmp = sqrt(A) * (c0 / sqrt((l * V)));
	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[(l * V), $MachinePrecision], -1e+234], N[(c0 * N[Sqrt[N[(N[(A / V), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(l * V), $MachinePrecision], 4e-314], N[(c0 * N[Sqrt[N[(1.0 / N[(N[(l * V), $MachinePrecision] / A), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[A], $MachinePrecision] * N[(c0 / N[Sqrt[N[(l * V), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[c0, A, V, l] = \mathsf{sort}([c0, A, V, l])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \cdot V \leq -1 \cdot 10^{+234}:\\
\;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{V}}{\ell}}\\

\mathbf{elif}\;\ell \cdot V \leq 4 \cdot 10^{-314}:\\
\;\;\;\;c0 \cdot \sqrt{\frac{1}{\frac{\ell \cdot V}{A}}}\\

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


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

    1. Initial program 46.2%

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

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

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

      \[\leadsto \color{blue}{c0 \cdot \sqrt{\frac{\frac{A}{V}}{\ell}}} \]
    4. Add Preprocessing

    if -1.00000000000000002e234 < (*.f64 V l) < 3.9999999999e-314

    1. Initial program 80.2%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. clear-num80.2%

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{1}{\frac{V \cdot \ell}{A}}}} \]
      2. associate-/r/79.5%

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

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

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

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{1}{V} \cdot A}{\ell}}} \]
      2. associate-*r/72.9%

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{1}{V} \cdot \frac{A}{\ell}}} \]
      3. frac-times80.2%

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

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{1}{\frac{V \cdot \ell}{A}}}} \]
    6. Applied egg-rr80.2%

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

    if 3.9999999999e-314 < (*.f64 V l)

    1. Initial program 75.4%

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

        \[\leadsto \color{blue}{\sqrt{\frac{A}{V \cdot \ell}} \cdot c0} \]
      2. sqrt-div89.8%

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

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

      \[\leadsto \color{blue}{\frac{\sqrt{A} \cdot c0}{\sqrt{V \cdot \ell}}} \]
    5. Applied egg-rr75.2%

      \[\leadsto \color{blue}{{\left(\frac{A}{V \cdot \ell}\right)}^{0.25} \cdot \left({\left(\frac{A}{V \cdot \ell}\right)}^{0.25} \cdot c0\right)} \]
    6. Step-by-step derivation
      1. associate-*r*75.2%

        \[\leadsto \color{blue}{\left({\left(\frac{A}{V \cdot \ell}\right)}^{0.25} \cdot {\left(\frac{A}{V \cdot \ell}\right)}^{0.25}\right) \cdot c0} \]
      2. associate-/l/71.6%

        \[\leadsto \left({\color{blue}{\left(\frac{\frac{A}{\ell}}{V}\right)}}^{0.25} \cdot {\left(\frac{A}{V \cdot \ell}\right)}^{0.25}\right) \cdot c0 \]
      3. associate-/l/75.0%

        \[\leadsto \left({\left(\frac{\frac{A}{\ell}}{V}\right)}^{0.25} \cdot {\color{blue}{\left(\frac{\frac{A}{\ell}}{V}\right)}}^{0.25}\right) \cdot c0 \]
      4. pow-prod-up75.2%

        \[\leadsto \color{blue}{{\left(\frac{\frac{A}{\ell}}{V}\right)}^{\left(0.25 + 0.25\right)}} \cdot c0 \]
      5. metadata-eval75.2%

        \[\leadsto {\left(\frac{\frac{A}{\ell}}{V}\right)}^{\color{blue}{0.5}} \cdot c0 \]
      6. pow1/275.2%

        \[\leadsto \color{blue}{\sqrt{\frac{\frac{A}{\ell}}{V}}} \cdot c0 \]
      7. *-commutative75.2%

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

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

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{A}{V}}{\ell}}} \]
      10. sqrt-div42.2%

        \[\leadsto c0 \cdot \color{blue}{\frac{\sqrt{\frac{A}{V}}}{\sqrt{\ell}}} \]
      11. clear-num42.2%

        \[\leadsto c0 \cdot \color{blue}{\frac{1}{\frac{\sqrt{\ell}}{\sqrt{\frac{A}{V}}}}} \]
      12. div-inv42.3%

        \[\leadsto \color{blue}{\frac{c0}{\frac{\sqrt{\ell}}{\sqrt{\frac{A}{V}}}}} \]
      13. associate-/r/42.0%

        \[\leadsto \color{blue}{\frac{c0}{\sqrt{\ell}} \cdot \sqrt{\frac{A}{V}}} \]
      14. sqrt-div49.9%

        \[\leadsto \frac{c0}{\sqrt{\ell}} \cdot \color{blue}{\frac{\sqrt{A}}{\sqrt{V}}} \]
      15. frac-times47.6%

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

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

        \[\leadsto \frac{c0 \cdot \sqrt{A}}{\sqrt{\color{blue}{V \cdot \ell}}} \]
    7. Applied egg-rr84.9%

      \[\leadsto \color{blue}{\frac{c0 \cdot \sqrt{A}}{\sqrt{V \cdot \ell}}} \]
    8. Step-by-step derivation
      1. associate-/l*89.8%

        \[\leadsto \color{blue}{\frac{c0}{\frac{\sqrt{V \cdot \ell}}{\sqrt{A}}}} \]
      2. associate-/r/88.1%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \cdot V \leq -1 \cdot 10^{+234}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{V}}{\ell}}\\ \mathbf{elif}\;\ell \cdot V \leq 4 \cdot 10^{-314}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{1}{\frac{\ell \cdot V}{A}}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{A} \cdot \frac{c0}{\sqrt{\ell \cdot V}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 75.6% accurate, 0.5× speedup?

\[\begin{array}{l} [c0, A, V, l] = \mathsf{sort}([c0, A, V, l])\\ \\ \begin{array}{l} t_0 := c0 \cdot \sqrt{\frac{A}{\ell \cdot V}}\\ \mathbf{if}\;t_0 \leq 10^{-190}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{1}{V} \cdot \frac{A}{\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 (* l V))))))
   (if (<= t_0 1e-190) (* c0 (sqrt (* (/ 1.0 V) (/ A 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 / (l * V)));
	double tmp;
	if (t_0 <= 1e-190) {
		tmp = c0 * sqrt(((1.0 / V) * (A / 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 / (l * v)))
    if (t_0 <= 1d-190) then
        tmp = c0 * sqrt(((1.0d0 / v) * (a / 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 / (l * V)));
	double tmp;
	if (t_0 <= 1e-190) {
		tmp = c0 * Math.sqrt(((1.0 / V) * (A / 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 / (l * V)))
	tmp = 0
	if t_0 <= 1e-190:
		tmp = c0 * math.sqrt(((1.0 / V) * (A / 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(l * V))))
	tmp = 0.0
	if (t_0 <= 1e-190)
		tmp = Float64(c0 * sqrt(Float64(Float64(1.0 / V) * Float64(A / 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 / (l * V)));
	tmp = 0.0;
	if (t_0 <= 1e-190)
		tmp = c0 * sqrt(((1.0 / V) * (A / 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[(l * V), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 1e-190], N[(c0 * N[Sqrt[N[(N[(1.0 / V), $MachinePrecision] * N[(A / 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{A}{\ell \cdot V}}\\
\mathbf{if}\;t_0 \leq 10^{-190}:\\
\;\;\;\;c0 \cdot \sqrt{\frac{1}{V} \cdot \frac{A}{\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)))) < 1e-190

    1. Initial program 69.1%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. *-un-lft-identity69.1%

        \[\leadsto c0 \cdot \sqrt{\frac{\color{blue}{1 \cdot A}}{V \cdot \ell}} \]
      2. times-frac70.4%

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{1}{V} \cdot \frac{A}{\ell}}} \]
    4. Applied egg-rr70.4%

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

    if 1e-190 < (*.f64 c0 (sqrt.f64 (/.f64 A (*.f64 V l))))

    1. Initial program 84.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c0 \cdot \sqrt{\frac{A}{\ell \cdot V}} \leq 10^{-190}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{1}{V} \cdot \frac{A}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{A}{\ell \cdot V}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 75.7% accurate, 0.5× speedup?

\[\begin{array}{l} [c0, A, V, l] = \mathsf{sort}([c0, A, V, l])\\ \\ \begin{array}{l} t_0 := c0 \cdot \sqrt{\frac{A}{\ell \cdot V}}\\ \mathbf{if}\;t_0 \leq 4 \cdot 10^{-252}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{1}{V}}{\frac{\ell}{A}}}\\ \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 (* l V))))))
   (if (<= t_0 4e-252) (* c0 (sqrt (/ (/ 1.0 V) (/ l A)))) 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 / (l * V)));
	double tmp;
	if (t_0 <= 4e-252) {
		tmp = c0 * sqrt(((1.0 / V) / (l / A)));
	} 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 / (l * v)))
    if (t_0 <= 4d-252) then
        tmp = c0 * sqrt(((1.0d0 / v) / (l / a)))
    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 / (l * V)));
	double tmp;
	if (t_0 <= 4e-252) {
		tmp = c0 * Math.sqrt(((1.0 / V) / (l / A)));
	} 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 / (l * V)))
	tmp = 0
	if t_0 <= 4e-252:
		tmp = c0 * math.sqrt(((1.0 / V) / (l / A)))
	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(l * V))))
	tmp = 0.0
	if (t_0 <= 4e-252)
		tmp = Float64(c0 * sqrt(Float64(Float64(1.0 / V) / Float64(l / A))));
	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 / (l * V)));
	tmp = 0.0;
	if (t_0 <= 4e-252)
		tmp = c0 * sqrt(((1.0 / V) / (l / A)));
	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[(l * V), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 4e-252], N[(c0 * N[Sqrt[N[(N[(1.0 / V), $MachinePrecision] / N[(l / A), $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{A}{\ell \cdot V}}\\
\mathbf{if}\;t_0 \leq 4 \cdot 10^{-252}:\\
\;\;\;\;c0 \cdot \sqrt{\frac{\frac{1}{V}}{\frac{\ell}{A}}}\\

\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)))) < 3.99999999999999977e-252

    1. Initial program 68.4%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. clear-num67.9%

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{1}{\frac{V \cdot \ell}{A}}}} \]
      2. associate-/r/68.4%

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

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

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

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{1}{V} \cdot A}{\ell}}} \]
      2. associate-/l*69.3%

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

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

    if 3.99999999999999977e-252 < (*.f64 c0 (sqrt.f64 (/.f64 A (*.f64 V l))))

    1. Initial program 85.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c0 \cdot \sqrt{\frac{A}{\ell \cdot V}} \leq 4 \cdot 10^{-252}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{1}{V}}{\frac{\ell}{A}}}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{A}{\ell \cdot V}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 81.4% accurate, 0.5× speedup?

\[\begin{array}{l} [c0, A, V, l] = \mathsf{sort}([c0, A, V, l])\\ \\ \begin{array}{l} \mathbf{if}\;A \leq -1.85 \cdot 10^{-133}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{\frac{A}{V}}}{\sqrt{\ell}}\\ \mathbf{elif}\;A \leq 1.3 \cdot 10^{-305}:\\ \;\;\;\;c0 \cdot \sqrt{A \cdot \frac{\frac{1}{V}}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{A} \cdot \left(c0 \cdot {\left(\ell \cdot V\right)}^{-0.5}\right)\\ \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 -1.85e-133)
   (* c0 (/ (sqrt (/ A V)) (sqrt l)))
   (if (<= A 1.3e-305)
     (* c0 (sqrt (* A (/ (/ 1.0 V) l))))
     (* (sqrt A) (* c0 (pow (* l V) -0.5))))))
assert(c0 < A && A < V && V < l);
double code(double c0, double A, double V, double l) {
	double tmp;
	if (A <= -1.85e-133) {
		tmp = c0 * (sqrt((A / V)) / sqrt(l));
	} else if (A <= 1.3e-305) {
		tmp = c0 * sqrt((A * ((1.0 / V) / l)));
	} else {
		tmp = sqrt(A) * (c0 * pow((l * V), -0.5));
	}
	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 <= (-1.85d-133)) then
        tmp = c0 * (sqrt((a / v)) / sqrt(l))
    else if (a <= 1.3d-305) then
        tmp = c0 * sqrt((a * ((1.0d0 / v) / l)))
    else
        tmp = sqrt(a) * (c0 * ((l * v) ** (-0.5d0)))
    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 <= -1.85e-133) {
		tmp = c0 * (Math.sqrt((A / V)) / Math.sqrt(l));
	} else if (A <= 1.3e-305) {
		tmp = c0 * Math.sqrt((A * ((1.0 / V) / l)));
	} else {
		tmp = Math.sqrt(A) * (c0 * Math.pow((l * V), -0.5));
	}
	return tmp;
}
[c0, A, V, l] = sort([c0, A, V, l])
def code(c0, A, V, l):
	tmp = 0
	if A <= -1.85e-133:
		tmp = c0 * (math.sqrt((A / V)) / math.sqrt(l))
	elif A <= 1.3e-305:
		tmp = c0 * math.sqrt((A * ((1.0 / V) / l)))
	else:
		tmp = math.sqrt(A) * (c0 * math.pow((l * V), -0.5))
	return tmp
c0, A, V, l = sort([c0, A, V, l])
function code(c0, A, V, l)
	tmp = 0.0
	if (A <= -1.85e-133)
		tmp = Float64(c0 * Float64(sqrt(Float64(A / V)) / sqrt(l)));
	elseif (A <= 1.3e-305)
		tmp = Float64(c0 * sqrt(Float64(A * Float64(Float64(1.0 / V) / l))));
	else
		tmp = Float64(sqrt(A) * Float64(c0 * (Float64(l * V) ^ -0.5)));
	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 <= -1.85e-133)
		tmp = c0 * (sqrt((A / V)) / sqrt(l));
	elseif (A <= 1.3e-305)
		tmp = c0 * sqrt((A * ((1.0 / V) / l)));
	else
		tmp = sqrt(A) * (c0 * ((l * V) ^ -0.5));
	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, -1.85e-133], N[(c0 * N[(N[Sqrt[N[(A / V), $MachinePrecision]], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[A, 1.3e-305], N[(c0 * N[Sqrt[N[(A * N[(N[(1.0 / V), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[A], $MachinePrecision] * N[(c0 * N[Power[N[(l * V), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[c0, A, V, l] = \mathsf{sort}([c0, A, V, l])\\
\\
\begin{array}{l}
\mathbf{if}\;A \leq -1.85 \cdot 10^{-133}:\\
\;\;\;\;c0 \cdot \frac{\sqrt{\frac{A}{V}}}{\sqrt{\ell}}\\

\mathbf{elif}\;A \leq 1.3 \cdot 10^{-305}:\\
\;\;\;\;c0 \cdot \sqrt{A \cdot \frac{\frac{1}{V}}{\ell}}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{A} \cdot \left(c0 \cdot {\left(\ell \cdot V\right)}^{-0.5}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if A < -1.85000000000000018e-133

    1. Initial program 73.5%

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

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

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

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

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

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

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

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

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

    if -1.85000000000000018e-133 < A < 1.3000000000000001e-305

    1. Initial program 82.2%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. clear-num82.2%

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{1}{\frac{V \cdot \ell}{A}}}} \]
      2. associate-/r/82.2%

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

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

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

    if 1.3000000000000001e-305 < A

    1. Initial program 72.6%

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

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

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

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

      \[\leadsto \color{blue}{\frac{\sqrt{A} \cdot c0}{\sqrt{V \cdot \ell}}} \]
    5. Step-by-step derivation
      1. div-inv80.9%

        \[\leadsto \color{blue}{\left(\sqrt{A} \cdot c0\right) \cdot \frac{1}{\sqrt{V \cdot \ell}}} \]
      2. *-commutative80.9%

        \[\leadsto \color{blue}{\left(c0 \cdot \sqrt{A}\right)} \cdot \frac{1}{\sqrt{V \cdot \ell}} \]
      3. metadata-eval80.9%

        \[\leadsto \left(c0 \cdot \sqrt{A}\right) \cdot \frac{\color{blue}{\sqrt{1}}}{\sqrt{V \cdot \ell}} \]
      4. sqrt-div80.3%

        \[\leadsto \left(c0 \cdot \sqrt{A}\right) \cdot \color{blue}{\sqrt{\frac{1}{V \cdot \ell}}} \]
      5. associate-/r*81.0%

        \[\leadsto \left(c0 \cdot \sqrt{A}\right) \cdot \sqrt{\color{blue}{\frac{\frac{1}{V}}{\ell}}} \]
      6. associate-*r*85.4%

        \[\leadsto \color{blue}{c0 \cdot \left(\sqrt{A} \cdot \sqrt{\frac{\frac{1}{V}}{\ell}}\right)} \]
      7. *-commutative85.4%

        \[\leadsto c0 \cdot \color{blue}{\left(\sqrt{\frac{\frac{1}{V}}{\ell}} \cdot \sqrt{A}\right)} \]
      8. associate-*r*84.1%

        \[\leadsto \color{blue}{\left(c0 \cdot \sqrt{\frac{\frac{1}{V}}{\ell}}\right) \cdot \sqrt{A}} \]
      9. associate-/r*84.1%

        \[\leadsto \left(c0 \cdot \sqrt{\color{blue}{\frac{1}{V \cdot \ell}}}\right) \cdot \sqrt{A} \]
      10. sqrt-div84.6%

        \[\leadsto \left(c0 \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{V \cdot \ell}}}\right) \cdot \sqrt{A} \]
      11. metadata-eval84.6%

        \[\leadsto \left(c0 \cdot \frac{\color{blue}{1}}{\sqrt{V \cdot \ell}}\right) \cdot \sqrt{A} \]
      12. pow1/284.6%

        \[\leadsto \left(c0 \cdot \frac{1}{\color{blue}{{\left(V \cdot \ell\right)}^{0.5}}}\right) \cdot \sqrt{A} \]
      13. pow-flip84.7%

        \[\leadsto \left(c0 \cdot \color{blue}{{\left(V \cdot \ell\right)}^{\left(-0.5\right)}}\right) \cdot \sqrt{A} \]
      14. metadata-eval84.7%

        \[\leadsto \left(c0 \cdot {\left(V \cdot \ell\right)}^{\color{blue}{-0.5}}\right) \cdot \sqrt{A} \]
    6. Applied egg-rr84.7%

      \[\leadsto \color{blue}{\left(c0 \cdot {\left(V \cdot \ell\right)}^{-0.5}\right) \cdot \sqrt{A}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification69.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;A \leq -1.85 \cdot 10^{-133}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{\frac{A}{V}}}{\sqrt{\ell}}\\ \mathbf{elif}\;A \leq 1.3 \cdot 10^{-305}:\\ \;\;\;\;c0 \cdot \sqrt{A \cdot \frac{\frac{1}{V}}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{A} \cdot \left(c0 \cdot {\left(\ell \cdot V\right)}^{-0.5}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 76.0% accurate, 0.5× speedup?

\[\begin{array}{l} [c0, A, V, l] = \mathsf{sort}([c0, A, V, l])\\ \\ \begin{array}{l} t_0 := c0 \cdot \sqrt{\frac{A}{\ell \cdot V}}\\ \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 (* l V))))))
   (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 / (l * V)));
	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 / (l * v)))
    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 / (l * V)));
	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 / (l * V)))
	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(l * V))))
	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 / (l * V)));
	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[(l * V), $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}{\ell \cdot V}}\\
\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 67.8%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Step-by-step derivation
      1. *-commutative67.8%

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

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

      \[\leadsto \color{blue}{c0 \cdot \sqrt{\frac{\frac{A}{V}}{\ell}}} \]
    4. Add Preprocessing

    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. Final simplification76.6%

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

Alternative 10: 75.6% accurate, 0.5× speedup?

\[\begin{array}{l} [c0, A, V, l] = \mathsf{sort}([c0, A, V, l])\\ \\ \begin{array}{l} t_0 := c0 \cdot \sqrt{\frac{A}{\ell \cdot V}}\\ \mathbf{if}\;t_0 \leq 5 \cdot 10^{-180}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{\ell}}{V}}\\ \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 (* l V))))))
   (if (<= t_0 5e-180) (* c0 (sqrt (/ (/ A l) V))) 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 / (l * V)));
	double tmp;
	if (t_0 <= 5e-180) {
		tmp = c0 * sqrt(((A / l) / V));
	} 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 / (l * v)))
    if (t_0 <= 5d-180) then
        tmp = c0 * sqrt(((a / l) / v))
    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 / (l * V)));
	double tmp;
	if (t_0 <= 5e-180) {
		tmp = c0 * Math.sqrt(((A / l) / V));
	} 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 / (l * V)))
	tmp = 0
	if t_0 <= 5e-180:
		tmp = c0 * math.sqrt(((A / l) / V))
	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(l * V))))
	tmp = 0.0
	if (t_0 <= 5e-180)
		tmp = Float64(c0 * sqrt(Float64(Float64(A / l) / V)));
	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 / (l * V)));
	tmp = 0.0;
	if (t_0 <= 5e-180)
		tmp = c0 * sqrt(((A / l) / V));
	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[(l * V), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 5e-180], N[(c0 * N[Sqrt[N[(N[(A / l), $MachinePrecision] / V), $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}{\ell \cdot V}}\\
\mathbf{if}\;t_0 \leq 5 \cdot 10^{-180}:\\
\;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{\ell}}{V}}\\

\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)))) < 5.0000000000000001e-180

    1. Initial program 68.9%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. clear-num68.2%

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{1}{\frac{V \cdot \ell}{A}}}} \]
      2. associate-/r/68.9%

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

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{1}{V}}{\ell}} \cdot A} \]
    4. Applied egg-rr69.4%

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

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{1}{V} \cdot A}{\ell}}} \]
      2. associate-*r/70.2%

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

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{1 \cdot \frac{A}{\ell}}{V}}} \]
      4. *-un-lft-identity70.2%

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

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

    if 5.0000000000000001e-180 < (*.f64 c0 (sqrt.f64 (/.f64 A (*.f64 V l))))

    1. Initial program 85.5%

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

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

Alternative 11: 81.4% accurate, 0.5× speedup?

\[\begin{array}{l} [c0, A, V, l] = \mathsf{sort}([c0, A, V, l])\\ \\ \begin{array}{l} \mathbf{if}\;A \leq -8.8 \cdot 10^{-131}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{\frac{A}{V}}}{\sqrt{\ell}}\\ \mathbf{elif}\;A \leq 1.3 \cdot 10^{-305}:\\ \;\;\;\;c0 \cdot \sqrt{A \cdot \frac{\frac{1}{V}}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{A} \cdot \frac{c0}{\sqrt{\ell \cdot V}}\\ \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 -8.8e-131)
   (* c0 (/ (sqrt (/ A V)) (sqrt l)))
   (if (<= A 1.3e-305)
     (* c0 (sqrt (* A (/ (/ 1.0 V) l))))
     (* (sqrt A) (/ c0 (sqrt (* l V)))))))
assert(c0 < A && A < V && V < l);
double code(double c0, double A, double V, double l) {
	double tmp;
	if (A <= -8.8e-131) {
		tmp = c0 * (sqrt((A / V)) / sqrt(l));
	} else if (A <= 1.3e-305) {
		tmp = c0 * sqrt((A * ((1.0 / V) / l)));
	} else {
		tmp = sqrt(A) * (c0 / sqrt((l * V)));
	}
	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 <= (-8.8d-131)) then
        tmp = c0 * (sqrt((a / v)) / sqrt(l))
    else if (a <= 1.3d-305) then
        tmp = c0 * sqrt((a * ((1.0d0 / v) / l)))
    else
        tmp = sqrt(a) * (c0 / sqrt((l * v)))
    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 <= -8.8e-131) {
		tmp = c0 * (Math.sqrt((A / V)) / Math.sqrt(l));
	} else if (A <= 1.3e-305) {
		tmp = c0 * Math.sqrt((A * ((1.0 / V) / l)));
	} else {
		tmp = Math.sqrt(A) * (c0 / Math.sqrt((l * V)));
	}
	return tmp;
}
[c0, A, V, l] = sort([c0, A, V, l])
def code(c0, A, V, l):
	tmp = 0
	if A <= -8.8e-131:
		tmp = c0 * (math.sqrt((A / V)) / math.sqrt(l))
	elif A <= 1.3e-305:
		tmp = c0 * math.sqrt((A * ((1.0 / V) / l)))
	else:
		tmp = math.sqrt(A) * (c0 / math.sqrt((l * V)))
	return tmp
c0, A, V, l = sort([c0, A, V, l])
function code(c0, A, V, l)
	tmp = 0.0
	if (A <= -8.8e-131)
		tmp = Float64(c0 * Float64(sqrt(Float64(A / V)) / sqrt(l)));
	elseif (A <= 1.3e-305)
		tmp = Float64(c0 * sqrt(Float64(A * Float64(Float64(1.0 / V) / l))));
	else
		tmp = Float64(sqrt(A) * Float64(c0 / sqrt(Float64(l * V))));
	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 <= -8.8e-131)
		tmp = c0 * (sqrt((A / V)) / sqrt(l));
	elseif (A <= 1.3e-305)
		tmp = c0 * sqrt((A * ((1.0 / V) / l)));
	else
		tmp = sqrt(A) * (c0 / sqrt((l * V)));
	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, -8.8e-131], N[(c0 * N[(N[Sqrt[N[(A / V), $MachinePrecision]], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[A, 1.3e-305], N[(c0 * N[Sqrt[N[(A * N[(N[(1.0 / V), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[A], $MachinePrecision] * N[(c0 / N[Sqrt[N[(l * V), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[c0, A, V, l] = \mathsf{sort}([c0, A, V, l])\\
\\
\begin{array}{l}
\mathbf{if}\;A \leq -8.8 \cdot 10^{-131}:\\
\;\;\;\;c0 \cdot \frac{\sqrt{\frac{A}{V}}}{\sqrt{\ell}}\\

\mathbf{elif}\;A \leq 1.3 \cdot 10^{-305}:\\
\;\;\;\;c0 \cdot \sqrt{A \cdot \frac{\frac{1}{V}}{\ell}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if A < -8.7999999999999999e-131

    1. Initial program 73.5%

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

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

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

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

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

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

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

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

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

    if -8.7999999999999999e-131 < A < 1.3000000000000001e-305

    1. Initial program 82.2%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. clear-num82.2%

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{1}{\frac{V \cdot \ell}{A}}}} \]
      2. associate-/r/82.2%

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

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

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

    if 1.3000000000000001e-305 < A

    1. Initial program 72.6%

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

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

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

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

      \[\leadsto \color{blue}{\frac{\sqrt{A} \cdot c0}{\sqrt{V \cdot \ell}}} \]
    5. Applied egg-rr72.5%

      \[\leadsto \color{blue}{{\left(\frac{A}{V \cdot \ell}\right)}^{0.25} \cdot \left({\left(\frac{A}{V \cdot \ell}\right)}^{0.25} \cdot c0\right)} \]
    6. Step-by-step derivation
      1. associate-*r*72.4%

        \[\leadsto \color{blue}{\left({\left(\frac{A}{V \cdot \ell}\right)}^{0.25} \cdot {\left(\frac{A}{V \cdot \ell}\right)}^{0.25}\right) \cdot c0} \]
      2. associate-/l/69.3%

        \[\leadsto \left({\color{blue}{\left(\frac{\frac{A}{\ell}}{V}\right)}}^{0.25} \cdot {\left(\frac{A}{V \cdot \ell}\right)}^{0.25}\right) \cdot c0 \]
      3. associate-/l/72.5%

        \[\leadsto \left({\left(\frac{\frac{A}{\ell}}{V}\right)}^{0.25} \cdot {\color{blue}{\left(\frac{\frac{A}{\ell}}{V}\right)}}^{0.25}\right) \cdot c0 \]
      4. pow-prod-up72.6%

        \[\leadsto \color{blue}{{\left(\frac{\frac{A}{\ell}}{V}\right)}^{\left(0.25 + 0.25\right)}} \cdot c0 \]
      5. metadata-eval72.6%

        \[\leadsto {\left(\frac{\frac{A}{\ell}}{V}\right)}^{\color{blue}{0.5}} \cdot c0 \]
      6. pow1/272.6%

        \[\leadsto \color{blue}{\sqrt{\frac{\frac{A}{\ell}}{V}}} \cdot c0 \]
      7. *-commutative72.6%

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

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

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{A}{V}}{\ell}}} \]
      10. sqrt-div43.2%

        \[\leadsto c0 \cdot \color{blue}{\frac{\sqrt{\frac{A}{V}}}{\sqrt{\ell}}} \]
      11. clear-num43.2%

        \[\leadsto c0 \cdot \color{blue}{\frac{1}{\frac{\sqrt{\ell}}{\sqrt{\frac{A}{V}}}}} \]
      12. div-inv43.2%

        \[\leadsto \color{blue}{\frac{c0}{\frac{\sqrt{\ell}}{\sqrt{\frac{A}{V}}}}} \]
      13. associate-/r/43.0%

        \[\leadsto \color{blue}{\frac{c0}{\sqrt{\ell}} \cdot \sqrt{\frac{A}{V}}} \]
      14. sqrt-div51.5%

        \[\leadsto \frac{c0}{\sqrt{\ell}} \cdot \color{blue}{\frac{\sqrt{A}}{\sqrt{V}}} \]
      15. frac-times49.5%

        \[\leadsto \color{blue}{\frac{c0 \cdot \sqrt{A}}{\sqrt{\ell} \cdot \sqrt{V}}} \]
      16. sqrt-prod81.0%

        \[\leadsto \frac{c0 \cdot \sqrt{A}}{\color{blue}{\sqrt{\ell \cdot V}}} \]
      17. *-commutative81.0%

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

      \[\leadsto \color{blue}{\frac{c0 \cdot \sqrt{A}}{\sqrt{V \cdot \ell}}} \]
    8. Step-by-step derivation
      1. associate-/l*85.3%

        \[\leadsto \color{blue}{\frac{c0}{\frac{\sqrt{V \cdot \ell}}{\sqrt{A}}}} \]
      2. associate-/r/84.6%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;A \leq -8.8 \cdot 10^{-131}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{\frac{A}{V}}}{\sqrt{\ell}}\\ \mathbf{elif}\;A \leq 1.3 \cdot 10^{-305}:\\ \;\;\;\;c0 \cdot \sqrt{A \cdot \frac{\frac{1}{V}}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{A} \cdot \frac{c0}{\sqrt{\ell \cdot V}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 75.6% accurate, 0.5× speedup?

\[\begin{array}{l} [c0, A, V, l] = \mathsf{sort}([c0, A, V, l])\\ \\ \begin{array}{l} \mathbf{if}\;V \leq 7 \cdot 10^{-309}:\\ \;\;\;\;c0 \cdot \sqrt{A \cdot \frac{\frac{1}{V}}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c0}{\sqrt{V}} \cdot \sqrt{\frac{A}{\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 7e-309)
   (* c0 (sqrt (* A (/ (/ 1.0 V) l))))
   (* (/ c0 (sqrt V)) (sqrt (/ A l)))))
assert(c0 < A && A < V && V < l);
double code(double c0, double A, double V, double l) {
	double tmp;
	if (V <= 7e-309) {
		tmp = c0 * sqrt((A * ((1.0 / V) / l)));
	} else {
		tmp = (c0 / sqrt(V)) * sqrt((A / 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 <= 7d-309) then
        tmp = c0 * sqrt((a * ((1.0d0 / v) / l)))
    else
        tmp = (c0 / sqrt(v)) * sqrt((a / 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 <= 7e-309) {
		tmp = c0 * Math.sqrt((A * ((1.0 / V) / l)));
	} else {
		tmp = (c0 / Math.sqrt(V)) * Math.sqrt((A / l));
	}
	return tmp;
}
[c0, A, V, l] = sort([c0, A, V, l])
def code(c0, A, V, l):
	tmp = 0
	if V <= 7e-309:
		tmp = c0 * math.sqrt((A * ((1.0 / V) / l)))
	else:
		tmp = (c0 / math.sqrt(V)) * math.sqrt((A / l))
	return tmp
c0, A, V, l = sort([c0, A, V, l])
function code(c0, A, V, l)
	tmp = 0.0
	if (V <= 7e-309)
		tmp = Float64(c0 * sqrt(Float64(A * Float64(Float64(1.0 / V) / l))));
	else
		tmp = Float64(Float64(c0 / sqrt(V)) * sqrt(Float64(A / 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 <= 7e-309)
		tmp = c0 * sqrt((A * ((1.0 / V) / l)));
	else
		tmp = (c0 / sqrt(V)) * sqrt((A / 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[V, 7e-309], N[(c0 * N[Sqrt[N[(A * N[(N[(1.0 / V), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(c0 / N[Sqrt[V], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(A / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[c0, A, V, l] = \mathsf{sort}([c0, A, V, l])\\
\\
\begin{array}{l}
\mathbf{if}\;V \leq 7 \cdot 10^{-309}:\\
\;\;\;\;c0 \cdot \sqrt{A \cdot \frac{\frac{1}{V}}{\ell}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if V < 6.9999999999999984e-309

    1. Initial program 72.6%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. clear-num71.9%

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{1}{\frac{V \cdot \ell}{A}}}} \]
      2. associate-/r/72.5%

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

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

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

    if 6.9999999999999984e-309 < V

    1. Initial program 76.0%

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

        \[\leadsto \color{blue}{\sqrt{\frac{A}{V \cdot \ell}} \cdot c0} \]
      2. sqrt-div44.0%

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

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

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

        \[\leadsto \frac{\color{blue}{c0 \cdot \sqrt{A}}}{\sqrt{V \cdot \ell}} \]
      2. sqrt-prod47.9%

        \[\leadsto \frac{c0 \cdot \sqrt{A}}{\color{blue}{\sqrt{V} \cdot \sqrt{\ell}}} \]
      3. times-frac49.3%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;V \leq 7 \cdot 10^{-309}:\\ \;\;\;\;c0 \cdot \sqrt{A \cdot \frac{\frac{1}{V}}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c0}{\sqrt{V}} \cdot \sqrt{\frac{A}{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 13: 73.6% accurate, 1.0× speedup?

\[\begin{array}{l} [c0, A, V, l] = \mathsf{sort}([c0, A, V, l])\\ \\ c0 \cdot \sqrt{\frac{A}{\ell \cdot V}} \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 (* l V)))))
assert(c0 < A && A < V && V < l);
double code(double c0, double A, double V, double l) {
	return c0 * sqrt((A / (l * V)));
}
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 / (l * v)))
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 / (l * V)));
}
[c0, A, V, l] = sort([c0, A, V, l])
def code(c0, A, V, l):
	return c0 * math.sqrt((A / (l * V)))
c0, A, V, l = sort([c0, A, V, l])
function code(c0, A, V, l)
	return Float64(c0 * sqrt(Float64(A / Float64(l * V))))
end
c0, A, V, l = num2cell(sort([c0, A, V, l])){:}
function tmp = code(c0, A, V, l)
	tmp = c0 * sqrt((A / (l * V)));
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[(l * V), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[c0, A, V, l] = \mathsf{sort}([c0, A, V, l])\\
\\
c0 \cdot \sqrt{\frac{A}{\ell \cdot V}}
\end{array}
Derivation
  1. Initial program 74.3%

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

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

Reproduce

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