Henrywood and Agarwal, Equation (3)

Percentage Accurate: 73.5% → 89.9%
Time: 26.0s
Alternatives: 12
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 12 alternatives:

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

Initial Program: 73.5% accurate, 1.0× speedup?

\[\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: 89.9% 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}{\sqrt{\ell}} \cdot \frac{\sqrt{-A}}{\sqrt{-V}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c0}{\sqrt{\ell \cdot V} \cdot \sqrt{\frac{1}{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 -5e-310)
   (* (/ c0 (sqrt l)) (/ (sqrt (- A)) (sqrt (- V))))
   (/ c0 (* (sqrt (* l V)) (sqrt (/ 1.0 A))))))
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((l * V)) * sqrt((1.0 / 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 <= (-5d-310)) then
        tmp = (c0 / sqrt(l)) * (sqrt(-a) / sqrt(-v))
    else
        tmp = c0 / (sqrt((l * v)) * sqrt((1.0d0 / 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 <= -5e-310) {
		tmp = (c0 / Math.sqrt(l)) * (Math.sqrt(-A) / Math.sqrt(-V));
	} else {
		tmp = c0 / (Math.sqrt((l * V)) * Math.sqrt((1.0 / A)));
	}
	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((l * V)) * math.sqrt((1.0 / A)))
	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(Float64(c0 / sqrt(l)) * Float64(sqrt(Float64(-A)) / sqrt(Float64(-V))));
	else
		tmp = Float64(c0 / Float64(sqrt(Float64(l * V)) * sqrt(Float64(1.0 / 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 <= -5e-310)
		tmp = (c0 / sqrt(l)) * (sqrt(-A) / sqrt(-V));
	else
		tmp = c0 / (sqrt((l * V)) * sqrt((1.0 / 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[A, -5e-310], N[(N[(c0 / N[Sqrt[l], $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[(-A)], $MachinePrecision] / N[Sqrt[(-V)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 / N[(N[Sqrt[N[(l * V), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(1.0 / A), $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}{\sqrt{\ell}} \cdot \frac{\sqrt{-A}}{\sqrt{-V}}\\

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


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

    1. Initial program 69.5%

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.999999999999985e-310 < A

    1. Initial program 77.0%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto c0 \cdot \color{blue}{\frac{1}{\frac{\sqrt{-\ell}}{\sqrt{\frac{A}{-V}}}}} \]
      10. un-div-inv41.6%

        \[\leadsto \color{blue}{\frac{c0}{\frac{\sqrt{-\ell}}{\sqrt{\frac{A}{-V}}}}} \]
      11. sqrt-undiv76.1%

        \[\leadsto \frac{c0}{\color{blue}{\sqrt{\frac{-\ell}{\frac{A}{-V}}}}} \]
      12. add-sqr-sqrt38.8%

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

        \[\leadsto \frac{c0}{\sqrt{\frac{\color{blue}{\sqrt{\left(-\ell\right) \cdot \left(-\ell\right)}}}{\frac{A}{-V}}}} \]
      14. sqr-neg24.0%

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

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

        \[\leadsto \frac{c0}{\sqrt{\frac{\color{blue}{\ell}}{\frac{A}{-V}}}} \]
      17. add-sqr-sqrt0.0%

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

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

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

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

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

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

        \[\leadsto \frac{c0}{\color{blue}{{\left(V \cdot \frac{\ell}{A}\right)}^{0.5}}} \]
      2. associate-*r/76.7%

        \[\leadsto \frac{c0}{{\color{blue}{\left(\frac{V \cdot \ell}{A}\right)}}^{0.5}} \]
      3. div-inv76.6%

        \[\leadsto \frac{c0}{{\color{blue}{\left(\left(V \cdot \ell\right) \cdot \frac{1}{A}\right)}}^{0.5}} \]
      4. unpow-prod-down85.4%

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

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

      \[\leadsto \frac{c0}{\color{blue}{\sqrt{V \cdot \ell} \cdot {\left(\frac{1}{A}\right)}^{0.5}}} \]
    11. Step-by-step derivation
      1. unpow1/285.4%

        \[\leadsto \frac{c0}{\sqrt{V \cdot \ell} \cdot \color{blue}{\sqrt{\frac{1}{A}}}} \]
    12. Simplified85.4%

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

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

Alternative 2: 76.8% 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}{\ell \cdot V}}\\ \mathbf{if}\;t\_0 \leq 0 \lor \neg \left(t\_0 \leq 5 \cdot 10^{+193}\right):\\ \;\;\;\;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 (or (<= t_0 0.0) (not (<= t_0 5e+193)))
     (* 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) || !(t_0 <= 5e+193)) {
		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) .or. (.not. (t_0 <= 5d+193))) 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) || !(t_0 <= 5e+193)) {
		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) or not (t_0 <= 5e+193):
		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) || !(t_0 <= 5e+193))
		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) || ~((t_0 <= 5e+193)))
		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[Or[LessEqual[t$95$0, 0.0], N[Not[LessEqual[t$95$0, 5e+193]], $MachinePrecision]], 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 \lor \neg \left(t\_0 \leq 5 \cdot 10^{+193}\right):\\
\;\;\;\;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 or 4.99999999999999972e193 < (*.f64 c0 (sqrt.f64 (/.f64 A (*.f64 V l))))

    1. Initial program 66.1%

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

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{A}{V}}{\ell}}} \]
    3. Simplified72.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)))) < 4.99999999999999972e193

    1. Initial program 99.6%

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

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

Alternative 3: 45.3% 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}{\ell \cdot V}}\\ \mathbf{if}\;t\_0 \leq 0:\\ \;\;\;\;\sqrt{\frac{A}{\ell} \cdot \left(c0 \cdot \frac{c0}{V}\right)}\\ \mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+232}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{c0}{\sqrt{V \cdot \frac{\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
 (let* ((t_0 (* c0 (sqrt (/ A (* l V))))))
   (if (<= t_0 0.0)
     (sqrt (* (/ A l) (* c0 (/ c0 V))))
     (if (<= t_0 4e+232) t_0 (/ c0 (sqrt (* V (/ l A))))))))
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 = sqrt(((A / l) * (c0 * (c0 / V))));
	} else if (t_0 <= 4e+232) {
		tmp = t_0;
	} 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) :: t_0
    real(8) :: tmp
    t_0 = c0 * sqrt((a / (l * v)))
    if (t_0 <= 0.0d0) then
        tmp = sqrt(((a / l) * (c0 * (c0 / v))))
    else if (t_0 <= 4d+232) then
        tmp = t_0
    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 t_0 = c0 * Math.sqrt((A / (l * V)));
	double tmp;
	if (t_0 <= 0.0) {
		tmp = Math.sqrt(((A / l) * (c0 * (c0 / V))));
	} else if (t_0 <= 4e+232) {
		tmp = t_0;
	} 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):
	t_0 = c0 * math.sqrt((A / (l * V)))
	tmp = 0
	if t_0 <= 0.0:
		tmp = math.sqrt(((A / l) * (c0 * (c0 / V))))
	elif t_0 <= 4e+232:
		tmp = t_0
	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)
	t_0 = Float64(c0 * sqrt(Float64(A / Float64(l * V))))
	tmp = 0.0
	if (t_0 <= 0.0)
		tmp = sqrt(Float64(Float64(A / l) * Float64(c0 * Float64(c0 / V))));
	elseif (t_0 <= 4e+232)
		tmp = t_0;
	else
		tmp = Float64(c0 / sqrt(Float64(V * Float64(l / 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 / (l * V)));
	tmp = 0.0;
	if (t_0 <= 0.0)
		tmp = sqrt(((A / l) * (c0 * (c0 / V))));
	elseif (t_0 <= 4e+232)
		tmp = t_0;
	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_] := 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[Sqrt[N[(N[(A / l), $MachinePrecision] * N[(c0 * N[(c0 / V), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[t$95$0, 4e+232], t$95$0, N[(c0 / N[Sqrt[N[(V * N[(l / 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}{\ell \cdot V}}\\
\mathbf{if}\;t\_0 \leq 0:\\
\;\;\;\;\sqrt{\frac{A}{\ell} \cdot \left(c0 \cdot \frac{c0}{V}\right)}\\

\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+232}:\\
\;\;\;\;t\_0\\

\mathbf{else}:\\
\;\;\;\;\frac{c0}{\sqrt{V \cdot \frac{\ell}{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 67.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 99.6%

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

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

    1. Initial program 56.4%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto c0 \cdot \color{blue}{\frac{1}{\frac{\sqrt{-\ell}}{\sqrt{\frac{A}{-V}}}}} \]
      10. un-div-inv36.6%

        \[\leadsto \color{blue}{\frac{c0}{\frac{\sqrt{-\ell}}{\sqrt{\frac{A}{-V}}}}} \]
      11. sqrt-undiv70.9%

        \[\leadsto \frac{c0}{\color{blue}{\sqrt{\frac{-\ell}{\frac{A}{-V}}}}} \]
      12. add-sqr-sqrt27.8%

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

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

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

        \[\leadsto \frac{c0}{\sqrt{\frac{\color{blue}{\sqrt{\ell} \cdot \sqrt{\ell}}}{\frac{A}{-V}}}} \]
      16. add-sqr-sqrt0.1%

        \[\leadsto \frac{c0}{\sqrt{\frac{\color{blue}{\ell}}{\frac{A}{-V}}}} \]
      17. add-sqr-sqrt0.1%

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

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

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

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

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

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

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

Alternative 4: 76.9% 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}{\ell \cdot V}}\\ \mathbf{if}\;t\_0 \leq 0:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{V}}{\ell}}\\ \mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+232}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{c0}{\sqrt{V \cdot \frac{\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
 (let* ((t_0 (* c0 (sqrt (/ A (* l V))))))
   (if (<= t_0 0.0)
     (* c0 (sqrt (/ (/ A V) l)))
     (if (<= t_0 4e+232) t_0 (/ c0 (sqrt (* V (/ l A))))))))
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 if (t_0 <= 4e+232) {
		tmp = t_0;
	} 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) :: 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 if (t_0 <= 4d+232) then
        tmp = t_0
    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 t_0 = c0 * Math.sqrt((A / (l * V)));
	double tmp;
	if (t_0 <= 0.0) {
		tmp = c0 * Math.sqrt(((A / V) / l));
	} else if (t_0 <= 4e+232) {
		tmp = t_0;
	} 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):
	t_0 = c0 * math.sqrt((A / (l * V)))
	tmp = 0
	if t_0 <= 0.0:
		tmp = c0 * math.sqrt(((A / V) / l))
	elif t_0 <= 4e+232:
		tmp = t_0
	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)
	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)));
	elseif (t_0 <= 4e+232)
		tmp = t_0;
	else
		tmp = Float64(c0 / sqrt(Float64(V * Float64(l / 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 / (l * V)));
	tmp = 0.0;
	if (t_0 <= 0.0)
		tmp = c0 * sqrt(((A / V) / l));
	elseif (t_0 <= 4e+232)
		tmp = t_0;
	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_] := 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], If[LessEqual[t$95$0, 4e+232], t$95$0, N[(c0 / N[Sqrt[N[(V * N[(l / 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}{\ell \cdot V}}\\
\mathbf{if}\;t\_0 \leq 0:\\
\;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{V}}{\ell}}\\

\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+232}:\\
\;\;\;\;t\_0\\

\mathbf{else}:\\
\;\;\;\;\frac{c0}{\sqrt{V \cdot \frac{\ell}{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 67.4%

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

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

      \[\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)))) < 4.00000000000000023e232

    1. Initial program 99.6%

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

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

    1. Initial program 56.4%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto c0 \cdot \color{blue}{\frac{1}{\frac{\sqrt{-\ell}}{\sqrt{\frac{A}{-V}}}}} \]
      10. un-div-inv36.6%

        \[\leadsto \color{blue}{\frac{c0}{\frac{\sqrt{-\ell}}{\sqrt{\frac{A}{-V}}}}} \]
      11. sqrt-undiv70.9%

        \[\leadsto \frac{c0}{\color{blue}{\sqrt{\frac{-\ell}{\frac{A}{-V}}}}} \]
      12. add-sqr-sqrt27.8%

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

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

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

        \[\leadsto \frac{c0}{\sqrt{\frac{\color{blue}{\sqrt{\ell} \cdot \sqrt{\ell}}}{\frac{A}{-V}}}} \]
      16. add-sqr-sqrt0.1%

        \[\leadsto \frac{c0}{\sqrt{\frac{\color{blue}{\ell}}{\frac{A}{-V}}}} \]
      17. add-sqr-sqrt0.1%

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

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

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

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

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

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

    \[\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{elif}\;c0 \cdot \sqrt{\frac{A}{\ell \cdot V}} \leq 4 \cdot 10^{+232}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{A}{\ell \cdot V}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c0}{\sqrt{V \cdot \frac{\ell}{A}}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 89.2% 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 -2 \cdot 10^{+282}:\\ \;\;\;\;\frac{c0 \cdot \sqrt{\frac{A}{V}}}{\sqrt{\ell}}\\ \mathbf{elif}\;\ell \cdot V \leq -1 \cdot 10^{-266}:\\ \;\;\;\;\frac{c0}{\frac{\sqrt{\ell \cdot \left(-V\right)}}{\sqrt{-A}}}\\ \mathbf{elif}\;\ell \cdot V \leq 2 \cdot 10^{-312}:\\ \;\;\;\;\frac{c0}{\sqrt{\ell \cdot \frac{V}{A}}}\\ \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) -2e+282)
   (/ (* c0 (sqrt (/ A V))) (sqrt l))
   (if (<= (* l V) -1e-266)
     (/ c0 (/ (sqrt (* l (- V))) (sqrt (- A))))
     (if (<= (* l V) 2e-312)
       (/ c0 (sqrt (* l (/ V A))))
       (* 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) <= -2e+282) {
		tmp = (c0 * sqrt((A / V))) / sqrt(l);
	} else if ((l * V) <= -1e-266) {
		tmp = c0 / (sqrt((l * -V)) / sqrt(-A));
	} else if ((l * V) <= 2e-312) {
		tmp = c0 / sqrt((l * (V / A)));
	} 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 ((l * v) <= (-2d+282)) then
        tmp = (c0 * sqrt((a / v))) / sqrt(l)
    else if ((l * v) <= (-1d-266)) then
        tmp = c0 / (sqrt((l * -v)) / sqrt(-a))
    else if ((l * v) <= 2d-312) then
        tmp = c0 / sqrt((l * (v / a)))
    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 ((l * V) <= -2e+282) {
		tmp = (c0 * Math.sqrt((A / V))) / Math.sqrt(l);
	} else if ((l * V) <= -1e-266) {
		tmp = c0 / (Math.sqrt((l * -V)) / Math.sqrt(-A));
	} else if ((l * V) <= 2e-312) {
		tmp = c0 / Math.sqrt((l * (V / A)));
	} 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) <= -2e+282:
		tmp = (c0 * math.sqrt((A / V))) / math.sqrt(l)
	elif (l * V) <= -1e-266:
		tmp = c0 / (math.sqrt((l * -V)) / math.sqrt(-A))
	elif (l * V) <= 2e-312:
		tmp = c0 / math.sqrt((l * (V / A)))
	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) <= -2e+282)
		tmp = Float64(Float64(c0 * sqrt(Float64(A / V))) / sqrt(l));
	elseif (Float64(l * V) <= -1e-266)
		tmp = Float64(c0 / Float64(sqrt(Float64(l * Float64(-V))) / sqrt(Float64(-A))));
	elseif (Float64(l * V) <= 2e-312)
		tmp = Float64(c0 / sqrt(Float64(l * Float64(V / A))));
	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) <= -2e+282)
		tmp = (c0 * sqrt((A / V))) / sqrt(l);
	elseif ((l * V) <= -1e-266)
		tmp = c0 / (sqrt((l * -V)) / sqrt(-A));
	elseif ((l * V) <= 2e-312)
		tmp = c0 / sqrt((l * (V / A)));
	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], -2e+282], N[(N[(c0 * N[Sqrt[N[(A / V), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(l * V), $MachinePrecision], -1e-266], N[(c0 / N[(N[Sqrt[N[(l * (-V)), $MachinePrecision]], $MachinePrecision] / N[Sqrt[(-A)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(l * V), $MachinePrecision], 2e-312], N[(c0 / N[Sqrt[N[(l * N[(V / A), $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}\;\ell \cdot V \leq -2 \cdot 10^{+282}:\\
\;\;\;\;\frac{c0 \cdot \sqrt{\frac{A}{V}}}{\sqrt{\ell}}\\

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

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

\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) < -2.00000000000000007e282

    1. Initial program 47.1%

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

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

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

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

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

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

    if -2.00000000000000007e282 < (*.f64 V l) < -9.9999999999999998e-267

    1. Initial program 79.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{c0}{\frac{\sqrt{-\ell}}{\sqrt{\frac{A}{-V}}}}} \]
      11. sqrt-undiv75.0%

        \[\leadsto \frac{c0}{\color{blue}{\sqrt{\frac{-\ell}{\frac{A}{-V}}}}} \]
      12. add-sqr-sqrt32.8%

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

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

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

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

        \[\leadsto \frac{c0}{\sqrt{\frac{\color{blue}{\ell}}{\frac{A}{-V}}}} \]
      17. add-sqr-sqrt0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -9.9999999999999998e-267 < (*.f64 V l) < 2.0000000000019e-312

    1. Initial program 50.4%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto c0 \cdot \color{blue}{\frac{1}{\frac{\sqrt{-\ell}}{\sqrt{\frac{A}{-V}}}}} \]
      10. un-div-inv33.4%

        \[\leadsto \color{blue}{\frac{c0}{\frac{\sqrt{-\ell}}{\sqrt{\frac{A}{-V}}}}} \]
      11. sqrt-undiv75.1%

        \[\leadsto \frac{c0}{\color{blue}{\sqrt{\frac{-\ell}{\frac{A}{-V}}}}} \]
      12. add-sqr-sqrt26.5%

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

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

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

        \[\leadsto \frac{c0}{\sqrt{\frac{\color{blue}{\sqrt{\ell} \cdot \sqrt{\ell}}}{\frac{A}{-V}}}} \]
      16. add-sqr-sqrt0.1%

        \[\leadsto \frac{c0}{\sqrt{\frac{\color{blue}{\ell}}{\frac{A}{-V}}}} \]
      17. add-sqr-sqrt0.0%

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

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

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

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

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

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

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

    if 2.0000000000019e-312 < (*.f64 V l)

    1. Initial program 82.2%

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

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

        \[\leadsto c0 \cdot {\color{blue}{\left(A \cdot \frac{1}{V \cdot \ell}\right)}}^{0.5} \]
      3. unpow-prod-down92.2%

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

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

      \[\leadsto c0 \cdot \color{blue}{\left(\sqrt{A} \cdot {\left(\frac{1}{V \cdot \ell}\right)}^{0.5}\right)} \]
    5. Step-by-step derivation
      1. unpow1/292.2%

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

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

      \[\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 simplification87.1%

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

Alternative 6: 89.4% 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:\\ \;\;\;\;\frac{c0 \cdot \sqrt{\frac{A}{V}}}{\sqrt{\ell}}\\ \mathbf{elif}\;\ell \cdot V \leq -1 \cdot 10^{-266}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{-A}}{\sqrt{\ell \cdot \left(-V\right)}}\\ \mathbf{elif}\;\ell \cdot V \leq 2 \cdot 10^{-312}:\\ \;\;\;\;\frac{c0}{\sqrt{\ell \cdot \frac{V}{A}}}\\ \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) -1e-266)
     (* c0 (/ (sqrt (- A)) (sqrt (* l (- V)))))
     (if (<= (* l V) 2e-312)
       (/ c0 (sqrt (* l (/ V A))))
       (* 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) <= -1e-266) {
		tmp = c0 * (sqrt(-A) / sqrt((l * -V)));
	} else if ((l * V) <= 2e-312) {
		tmp = c0 / sqrt((l * (V / A)));
	} 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) <= -1e-266) {
		tmp = c0 * (Math.sqrt(-A) / Math.sqrt((l * -V)));
	} else if ((l * V) <= 2e-312) {
		tmp = c0 / Math.sqrt((l * (V / A)));
	} 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) <= -1e-266:
		tmp = c0 * (math.sqrt(-A) / math.sqrt((l * -V)))
	elif (l * V) <= 2e-312:
		tmp = c0 / math.sqrt((l * (V / A)))
	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(Float64(c0 * sqrt(Float64(A / V))) / sqrt(l));
	elseif (Float64(l * V) <= -1e-266)
		tmp = Float64(c0 * Float64(sqrt(Float64(-A)) / sqrt(Float64(l * Float64(-V)))));
	elseif (Float64(l * V) <= 2e-312)
		tmp = Float64(c0 / sqrt(Float64(l * Float64(V / A))));
	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) <= -1e-266)
		tmp = c0 * (sqrt(-A) / sqrt((l * -V)));
	elseif ((l * V) <= 2e-312)
		tmp = c0 / sqrt((l * (V / A)));
	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[(N[(c0 * N[Sqrt[N[(A / V), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(l * V), $MachinePrecision], -1e-266], N[(c0 * N[(N[Sqrt[(-A)], $MachinePrecision] / N[Sqrt[N[(l * (-V)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(l * V), $MachinePrecision], 2e-312], N[(c0 / N[Sqrt[N[(l * N[(V / A), $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}\;\ell \cdot V \leq -\infty:\\
\;\;\;\;\frac{c0 \cdot \sqrt{\frac{A}{V}}}{\sqrt{\ell}}\\

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

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

\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 37.7%

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

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

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

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

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

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

    if -inf.0 < (*.f64 V l) < -9.9999999999999998e-267

    1. Initial program 80.6%

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

        \[\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. *-commutative99.4%

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

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

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

    if -9.9999999999999998e-267 < (*.f64 V l) < 2.0000000000019e-312

    1. Initial program 50.4%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto c0 \cdot \color{blue}{\frac{1}{\frac{\sqrt{-\ell}}{\sqrt{\frac{A}{-V}}}}} \]
      10. un-div-inv33.4%

        \[\leadsto \color{blue}{\frac{c0}{\frac{\sqrt{-\ell}}{\sqrt{\frac{A}{-V}}}}} \]
      11. sqrt-undiv75.1%

        \[\leadsto \frac{c0}{\color{blue}{\sqrt{\frac{-\ell}{\frac{A}{-V}}}}} \]
      12. add-sqr-sqrt26.5%

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

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

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

        \[\leadsto \frac{c0}{\sqrt{\frac{\color{blue}{\sqrt{\ell} \cdot \sqrt{\ell}}}{\frac{A}{-V}}}} \]
      16. add-sqr-sqrt0.1%

        \[\leadsto \frac{c0}{\sqrt{\frac{\color{blue}{\ell}}{\frac{A}{-V}}}} \]
      17. add-sqr-sqrt0.0%

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

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

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

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

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

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

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

    if 2.0000000000019e-312 < (*.f64 V l)

    1. Initial program 82.2%

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

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

        \[\leadsto c0 \cdot {\color{blue}{\left(A \cdot \frac{1}{V \cdot \ell}\right)}}^{0.5} \]
      3. unpow-prod-down92.2%

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

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

      \[\leadsto c0 \cdot \color{blue}{\left(\sqrt{A} \cdot {\left(\frac{1}{V \cdot \ell}\right)}^{0.5}\right)} \]
    5. Step-by-step derivation
      1. unpow1/292.2%

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

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

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

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

Alternative 7: 82.4% 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^{+185}:\\ \;\;\;\;\frac{c0}{\sqrt{\ell}} \cdot \sqrt{\frac{A}{V}}\\ \mathbf{elif}\;\ell \cdot V \leq -1 \cdot 10^{-14}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{A}{\ell \cdot V}}\\ \mathbf{elif}\;\ell \cdot V \leq 2 \cdot 10^{-312}:\\ \;\;\;\;c0 \cdot {\left(\ell \cdot \frac{V}{A}\right)}^{-0.5}\\ \mathbf{else}:\\ \;\;\;\;\frac{c0 \cdot \sqrt{A}}{\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+185)
   (* (/ c0 (sqrt l)) (sqrt (/ A V)))
   (if (<= (* l V) -1e-14)
     (* c0 (sqrt (/ A (* l V))))
     (if (<= (* l V) 2e-312)
       (* c0 (pow (* l (/ V A)) -0.5))
       (/ (* c0 (sqrt A)) (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+185) {
		tmp = (c0 / sqrt(l)) * sqrt((A / V));
	} else if ((l * V) <= -1e-14) {
		tmp = c0 * sqrt((A / (l * V)));
	} else if ((l * V) <= 2e-312) {
		tmp = c0 * pow((l * (V / A)), -0.5);
	} else {
		tmp = (c0 * sqrt(A)) / 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+185)) then
        tmp = (c0 / sqrt(l)) * sqrt((a / v))
    else if ((l * v) <= (-1d-14)) then
        tmp = c0 * sqrt((a / (l * v)))
    else if ((l * v) <= 2d-312) then
        tmp = c0 * ((l * (v / a)) ** (-0.5d0))
    else
        tmp = (c0 * sqrt(a)) / 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+185) {
		tmp = (c0 / Math.sqrt(l)) * Math.sqrt((A / V));
	} else if ((l * V) <= -1e-14) {
		tmp = c0 * Math.sqrt((A / (l * V)));
	} else if ((l * V) <= 2e-312) {
		tmp = c0 * Math.pow((l * (V / A)), -0.5);
	} else {
		tmp = (c0 * Math.sqrt(A)) / 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+185:
		tmp = (c0 / math.sqrt(l)) * math.sqrt((A / V))
	elif (l * V) <= -1e-14:
		tmp = c0 * math.sqrt((A / (l * V)))
	elif (l * V) <= 2e-312:
		tmp = c0 * math.pow((l * (V / A)), -0.5)
	else:
		tmp = (c0 * math.sqrt(A)) / 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+185)
		tmp = Float64(Float64(c0 / sqrt(l)) * sqrt(Float64(A / V)));
	elseif (Float64(l * V) <= -1e-14)
		tmp = Float64(c0 * sqrt(Float64(A / Float64(l * V))));
	elseif (Float64(l * V) <= 2e-312)
		tmp = Float64(c0 * (Float64(l * Float64(V / A)) ^ -0.5));
	else
		tmp = Float64(Float64(c0 * sqrt(A)) / 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+185)
		tmp = (c0 / sqrt(l)) * sqrt((A / V));
	elseif ((l * V) <= -1e-14)
		tmp = c0 * sqrt((A / (l * V)));
	elseif ((l * V) <= 2e-312)
		tmp = c0 * ((l * (V / A)) ^ -0.5);
	else
		tmp = (c0 * sqrt(A)) / 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+185], N[(N[(c0 / N[Sqrt[l], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(A / V), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(l * V), $MachinePrecision], -1e-14], N[(c0 * N[Sqrt[N[(A / N[(l * V), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(l * V), $MachinePrecision], 2e-312], N[(c0 * N[Power[N[(l * N[(V / A), $MachinePrecision]), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision], N[(N[(c0 * N[Sqrt[A], $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(l * V), $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^{+185}:\\
\;\;\;\;\frac{c0}{\sqrt{\ell}} \cdot \sqrt{\frac{A}{V}}\\

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

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

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


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

    1. Initial program 43.5%

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

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

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

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

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

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

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

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

    if -9.9999999999999998e184 < (*.f64 V l) < -9.99999999999999999e-15

    1. Initial program 92.8%

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

    if -9.99999999999999999e-15 < (*.f64 V l) < 2.0000000000019e-312

    1. Initial program 66.2%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto c0 \cdot {\color{blue}{\left(V \cdot \frac{\ell}{A}\right)}}^{-0.5} \]
    8. Applied egg-rr79.3%

      \[\leadsto c0 \cdot \color{blue}{{\left(V \cdot \frac{\ell}{A}\right)}^{-0.5}} \]
    9. Step-by-step derivation
      1. *-commutative79.3%

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

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

        \[\leadsto c0 \cdot {\color{blue}{\left(\ell \cdot \frac{V}{A}\right)}}^{-0.5} \]
    10. Simplified78.6%

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

    if 2.0000000000019e-312 < (*.f64 V l)

    1. Initial program 82.2%

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

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

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

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

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

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

Alternative 8: 82.5% 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^{+185}:\\ \;\;\;\;\frac{c0}{\sqrt{\ell}} \cdot \sqrt{\frac{A}{V}}\\ \mathbf{elif}\;\ell \cdot V \leq -1 \cdot 10^{-14}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{A}{\ell \cdot V}}\\ \mathbf{elif}\;\ell \cdot V \leq 2 \cdot 10^{-312}:\\ \;\;\;\;c0 \cdot {\left(\ell \cdot \frac{V}{A}\right)}^{-0.5}\\ \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+185)
   (* (/ c0 (sqrt l)) (sqrt (/ A V)))
   (if (<= (* l V) -1e-14)
     (* c0 (sqrt (/ A (* l V))))
     (if (<= (* l V) 2e-312)
       (* c0 (pow (* l (/ V A)) -0.5))
       (* (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+185) {
		tmp = (c0 / sqrt(l)) * sqrt((A / V));
	} else if ((l * V) <= -1e-14) {
		tmp = c0 * sqrt((A / (l * V)));
	} else if ((l * V) <= 2e-312) {
		tmp = c0 * pow((l * (V / A)), -0.5);
	} 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+185)) then
        tmp = (c0 / sqrt(l)) * sqrt((a / v))
    else if ((l * v) <= (-1d-14)) then
        tmp = c0 * sqrt((a / (l * v)))
    else if ((l * v) <= 2d-312) then
        tmp = c0 * ((l * (v / a)) ** (-0.5d0))
    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+185) {
		tmp = (c0 / Math.sqrt(l)) * Math.sqrt((A / V));
	} else if ((l * V) <= -1e-14) {
		tmp = c0 * Math.sqrt((A / (l * V)));
	} else if ((l * V) <= 2e-312) {
		tmp = c0 * Math.pow((l * (V / A)), -0.5);
	} 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+185:
		tmp = (c0 / math.sqrt(l)) * math.sqrt((A / V))
	elif (l * V) <= -1e-14:
		tmp = c0 * math.sqrt((A / (l * V)))
	elif (l * V) <= 2e-312:
		tmp = c0 * math.pow((l * (V / A)), -0.5)
	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+185)
		tmp = Float64(Float64(c0 / sqrt(l)) * sqrt(Float64(A / V)));
	elseif (Float64(l * V) <= -1e-14)
		tmp = Float64(c0 * sqrt(Float64(A / Float64(l * V))));
	elseif (Float64(l * V) <= 2e-312)
		tmp = Float64(c0 * (Float64(l * Float64(V / A)) ^ -0.5));
	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+185)
		tmp = (c0 / sqrt(l)) * sqrt((A / V));
	elseif ((l * V) <= -1e-14)
		tmp = c0 * sqrt((A / (l * V)));
	elseif ((l * V) <= 2e-312)
		tmp = c0 * ((l * (V / A)) ^ -0.5);
	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+185], N[(N[(c0 / N[Sqrt[l], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(A / V), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(l * V), $MachinePrecision], -1e-14], N[(c0 * N[Sqrt[N[(A / N[(l * V), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(l * V), $MachinePrecision], 2e-312], N[(c0 * N[Power[N[(l * N[(V / A), $MachinePrecision]), $MachinePrecision], -0.5], $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^{+185}:\\
\;\;\;\;\frac{c0}{\sqrt{\ell}} \cdot \sqrt{\frac{A}{V}}\\

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

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

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


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

    1. Initial program 43.5%

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

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

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

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

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

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

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

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

    if -9.9999999999999998e184 < (*.f64 V l) < -9.99999999999999999e-15

    1. Initial program 92.8%

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

    if -9.99999999999999999e-15 < (*.f64 V l) < 2.0000000000019e-312

    1. Initial program 66.2%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto c0 \cdot {\color{blue}{\left(V \cdot \frac{\ell}{A}\right)}}^{-0.5} \]
    8. Applied egg-rr79.3%

      \[\leadsto c0 \cdot \color{blue}{{\left(V \cdot \frac{\ell}{A}\right)}^{-0.5}} \]
    9. Step-by-step derivation
      1. *-commutative79.3%

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

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

        \[\leadsto c0 \cdot {\color{blue}{\left(\ell \cdot \frac{V}{A}\right)}}^{-0.5} \]
    10. Simplified78.6%

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

    if 2.0000000000019e-312 < (*.f64 V l)

    1. Initial program 82.2%

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

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

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

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

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

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

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

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

Alternative 9: 82.7% 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 -2 \cdot 10^{+79}:\\ \;\;\;\;c0 \cdot \left(\sqrt{\frac{A}{V}} \cdot \sqrt{\frac{1}{\ell}}\right)\\ \mathbf{elif}\;\ell \cdot V \leq 2 \cdot 10^{-312}:\\ \;\;\;\;\frac{c0}{\sqrt{V \cdot \frac{\ell}{A}}}\\ \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) -2e+79)
   (* c0 (* (sqrt (/ A V)) (sqrt (/ 1.0 l))))
   (if (<= (* l V) 2e-312)
     (/ c0 (sqrt (* V (/ l A))))
     (* 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) <= -2e+79) {
		tmp = c0 * (sqrt((A / V)) * sqrt((1.0 / l)));
	} else if ((l * V) <= 2e-312) {
		tmp = c0 / sqrt((V * (l / A)));
	} 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 ((l * v) <= (-2d+79)) then
        tmp = c0 * (sqrt((a / v)) * sqrt((1.0d0 / l)))
    else if ((l * v) <= 2d-312) then
        tmp = c0 / sqrt((v * (l / a)))
    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 ((l * V) <= -2e+79) {
		tmp = c0 * (Math.sqrt((A / V)) * Math.sqrt((1.0 / l)));
	} else if ((l * V) <= 2e-312) {
		tmp = c0 / Math.sqrt((V * (l / A)));
	} 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) <= -2e+79:
		tmp = c0 * (math.sqrt((A / V)) * math.sqrt((1.0 / l)))
	elif (l * V) <= 2e-312:
		tmp = c0 / math.sqrt((V * (l / A)))
	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) <= -2e+79)
		tmp = Float64(c0 * Float64(sqrt(Float64(A / V)) * sqrt(Float64(1.0 / l))));
	elseif (Float64(l * V) <= 2e-312)
		tmp = Float64(c0 / sqrt(Float64(V * Float64(l / A))));
	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) <= -2e+79)
		tmp = c0 * (sqrt((A / V)) * sqrt((1.0 / l)));
	elseif ((l * V) <= 2e-312)
		tmp = c0 / sqrt((V * (l / A)));
	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], -2e+79], N[(c0 * N[(N[Sqrt[N[(A / V), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(1.0 / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(l * V), $MachinePrecision], 2e-312], N[(c0 / N[Sqrt[N[(V * N[(l / A), $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}\;\ell \cdot V \leq -2 \cdot 10^{+79}:\\
\;\;\;\;c0 \cdot \left(\sqrt{\frac{A}{V}} \cdot \sqrt{\frac{1}{\ell}}\right)\\

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

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


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

    1. Initial program 56.6%

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

        \[\leadsto c0 \cdot \color{blue}{{\left(\frac{A}{V \cdot \ell}\right)}^{0.5}} \]
      2. associate-/r*67.2%

        \[\leadsto c0 \cdot {\color{blue}{\left(\frac{\frac{A}{V}}{\ell}\right)}}^{0.5} \]
      3. div-inv67.2%

        \[\leadsto c0 \cdot {\color{blue}{\left(\frac{A}{V} \cdot \frac{1}{\ell}\right)}}^{0.5} \]
      4. unpow-prod-down39.2%

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

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

      \[\leadsto c0 \cdot \color{blue}{\left(\sqrt{\frac{A}{V}} \cdot {\left(\frac{1}{\ell}\right)}^{0.5}\right)} \]
    5. Step-by-step derivation
      1. unpow1/239.2%

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

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

    if -1.99999999999999993e79 < (*.f64 V l) < 2.0000000000019e-312

    1. Initial program 71.6%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto c0 \cdot \color{blue}{\frac{1}{\frac{\sqrt{-\ell}}{\sqrt{\frac{A}{-V}}}}} \]
      10. un-div-inv37.6%

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

        \[\leadsto \frac{c0}{\color{blue}{\sqrt{\frac{-\ell}{\frac{A}{-V}}}}} \]
      12. add-sqr-sqrt32.4%

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

        \[\leadsto \frac{c0}{\sqrt{\frac{\color{blue}{\sqrt{\left(-\ell\right) \cdot \left(-\ell\right)}}}{\frac{A}{-V}}}} \]
      14. sqr-neg22.8%

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

        \[\leadsto \frac{c0}{\sqrt{\frac{\color{blue}{\sqrt{\ell} \cdot \sqrt{\ell}}}{\frac{A}{-V}}}} \]
      16. add-sqr-sqrt0.1%

        \[\leadsto \frac{c0}{\sqrt{\frac{\color{blue}{\ell}}{\frac{A}{-V}}}} \]
      17. add-sqr-sqrt0.0%

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

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

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

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

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

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

    if 2.0000000000019e-312 < (*.f64 V l)

    1. Initial program 82.2%

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

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

        \[\leadsto c0 \cdot {\color{blue}{\left(A \cdot \frac{1}{V \cdot \ell}\right)}}^{0.5} \]
      3. unpow-prod-down92.2%

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

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

      \[\leadsto c0 \cdot \color{blue}{\left(\sqrt{A} \cdot {\left(\frac{1}{V \cdot \ell}\right)}^{0.5}\right)} \]
    5. Step-by-step derivation
      1. unpow1/292.2%

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

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

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

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

Alternative 10: 81.9% 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 -5 \cdot 10^{+108}:\\ \;\;\;\;\frac{c0 \cdot \sqrt{\frac{A}{V}}}{\sqrt{\ell}}\\ \mathbf{elif}\;\ell \cdot V \leq 2 \cdot 10^{-312}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{1}{V} \cdot \frac{A}{\ell}}\\ \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) -5e+108)
   (/ (* c0 (sqrt (/ A V))) (sqrt l))
   (if (<= (* l V) 2e-312)
     (* c0 (sqrt (* (/ 1.0 V) (/ A l))))
     (* 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) <= -5e+108) {
		tmp = (c0 * sqrt((A / V))) / sqrt(l);
	} else if ((l * V) <= 2e-312) {
		tmp = c0 * sqrt(((1.0 / V) * (A / l)));
	} 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 ((l * v) <= (-5d+108)) then
        tmp = (c0 * sqrt((a / v))) / sqrt(l)
    else if ((l * v) <= 2d-312) then
        tmp = c0 * sqrt(((1.0d0 / v) * (a / l)))
    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 ((l * V) <= -5e+108) {
		tmp = (c0 * Math.sqrt((A / V))) / Math.sqrt(l);
	} else if ((l * V) <= 2e-312) {
		tmp = c0 * Math.sqrt(((1.0 / V) * (A / l)));
	} 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) <= -5e+108:
		tmp = (c0 * math.sqrt((A / V))) / math.sqrt(l)
	elif (l * V) <= 2e-312:
		tmp = c0 * math.sqrt(((1.0 / V) * (A / l)))
	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) <= -5e+108)
		tmp = Float64(Float64(c0 * sqrt(Float64(A / V))) / sqrt(l));
	elseif (Float64(l * V) <= 2e-312)
		tmp = Float64(c0 * sqrt(Float64(Float64(1.0 / V) * Float64(A / l))));
	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) <= -5e+108)
		tmp = (c0 * sqrt((A / V))) / sqrt(l);
	elseif ((l * V) <= 2e-312)
		tmp = c0 * sqrt(((1.0 / V) * (A / l)));
	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], -5e+108], N[(N[(c0 * N[Sqrt[N[(A / V), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(l * V), $MachinePrecision], 2e-312], N[(c0 * N[Sqrt[N[(N[(1.0 / V), $MachinePrecision] * N[(A / l), $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}\;\ell \cdot V \leq -5 \cdot 10^{+108}:\\
\;\;\;\;\frac{c0 \cdot \sqrt{\frac{A}{V}}}{\sqrt{\ell}}\\

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

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


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

    1. Initial program 55.2%

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

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

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

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

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

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

    if -4.99999999999999991e108 < (*.f64 V l) < 2.0000000000019e-312

    1. Initial program 71.7%

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

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

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

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

    if 2.0000000000019e-312 < (*.f64 V l)

    1. Initial program 82.2%

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

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

        \[\leadsto c0 \cdot {\color{blue}{\left(A \cdot \frac{1}{V \cdot \ell}\right)}}^{0.5} \]
      3. unpow-prod-down92.2%

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

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

      \[\leadsto c0 \cdot \color{blue}{\left(\sqrt{A} \cdot {\left(\frac{1}{V \cdot \ell}\right)}^{0.5}\right)} \]
    5. Step-by-step derivation
      1. unpow1/292.2%

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

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

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

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

Alternative 11: 80.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 -5 \cdot 10^{+108}:\\ \;\;\;\;\frac{c0 \cdot \sqrt{\frac{A}{V}}}{\sqrt{\ell}}\\ \mathbf{elif}\;\ell \cdot V \leq 2 \cdot 10^{-312}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{1}{V} \cdot \frac{A}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c0 \cdot \sqrt{A}}{\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) -5e+108)
   (/ (* c0 (sqrt (/ A V))) (sqrt l))
   (if (<= (* l V) 2e-312)
     (* c0 (sqrt (* (/ 1.0 V) (/ A l))))
     (/ (* c0 (sqrt A)) (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) <= -5e+108) {
		tmp = (c0 * sqrt((A / V))) / sqrt(l);
	} else if ((l * V) <= 2e-312) {
		tmp = c0 * sqrt(((1.0 / V) * (A / l)));
	} else {
		tmp = (c0 * sqrt(A)) / 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) <= (-5d+108)) then
        tmp = (c0 * sqrt((a / v))) / sqrt(l)
    else if ((l * v) <= 2d-312) then
        tmp = c0 * sqrt(((1.0d0 / v) * (a / l)))
    else
        tmp = (c0 * sqrt(a)) / 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) <= -5e+108) {
		tmp = (c0 * Math.sqrt((A / V))) / Math.sqrt(l);
	} else if ((l * V) <= 2e-312) {
		tmp = c0 * Math.sqrt(((1.0 / V) * (A / l)));
	} else {
		tmp = (c0 * Math.sqrt(A)) / 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) <= -5e+108:
		tmp = (c0 * math.sqrt((A / V))) / math.sqrt(l)
	elif (l * V) <= 2e-312:
		tmp = c0 * math.sqrt(((1.0 / V) * (A / l)))
	else:
		tmp = (c0 * math.sqrt(A)) / 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) <= -5e+108)
		tmp = Float64(Float64(c0 * sqrt(Float64(A / V))) / sqrt(l));
	elseif (Float64(l * V) <= 2e-312)
		tmp = Float64(c0 * sqrt(Float64(Float64(1.0 / V) * Float64(A / l))));
	else
		tmp = Float64(Float64(c0 * sqrt(A)) / 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) <= -5e+108)
		tmp = (c0 * sqrt((A / V))) / sqrt(l);
	elseif ((l * V) <= 2e-312)
		tmp = c0 * sqrt(((1.0 / V) * (A / l)));
	else
		tmp = (c0 * sqrt(A)) / 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], -5e+108], N[(N[(c0 * N[Sqrt[N[(A / V), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(l * V), $MachinePrecision], 2e-312], N[(c0 * N[Sqrt[N[(N[(1.0 / V), $MachinePrecision] * N[(A / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(c0 * N[Sqrt[A], $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(l * V), $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 -5 \cdot 10^{+108}:\\
\;\;\;\;\frac{c0 \cdot \sqrt{\frac{A}{V}}}{\sqrt{\ell}}\\

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

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


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

    1. Initial program 55.2%

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

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

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

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

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

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

    if -4.99999999999999991e108 < (*.f64 V l) < 2.0000000000019e-312

    1. Initial program 71.7%

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

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

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

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

    if 2.0000000000019e-312 < (*.f64 V l)

    1. Initial program 82.2%

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

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

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

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

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

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

Alternative 12: 73.5% 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 73.5%

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

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

Reproduce

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