Henrywood and Agarwal, Equation (3)

Percentage Accurate: 73.3% → 91.1%
Time: 17.2s
Alternatives: 11
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 11 alternatives:

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

Initial Program: 73.3% accurate, 1.0× speedup?

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

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

Alternative 1: 91.1% accurate, 0.3× speedup?

\[\begin{array}{l} [c0, A, V, l] = \mathsf{sort}([c0, A, V, l])\\ \\ \begin{array}{l} \mathbf{if}\;A \leq -2 \cdot 10^{-310}:\\ \;\;\;\;\frac{c0}{\frac{\sqrt{-V}}{\sqrt{-A}} \cdot \sqrt{\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 (<= A -2e-310)
   (/ c0 (* (/ (sqrt (- V)) (sqrt (- A))) (sqrt 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 (A <= -2e-310) {
		tmp = c0 / ((sqrt(-V) / sqrt(-A)) * sqrt(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 (a <= (-2d-310)) then
        tmp = c0 / ((sqrt(-v) / sqrt(-a)) * sqrt(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 (A <= -2e-310) {
		tmp = c0 / ((Math.sqrt(-V) / Math.sqrt(-A)) * Math.sqrt(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 A <= -2e-310:
		tmp = c0 / ((math.sqrt(-V) / math.sqrt(-A)) * math.sqrt(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 (A <= -2e-310)
		tmp = Float64(c0 / Float64(Float64(sqrt(Float64(-V)) / sqrt(Float64(-A))) * sqrt(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 (A <= -2e-310)
		tmp = c0 / ((sqrt(-V) / sqrt(-A)) * sqrt(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[A, -2e-310], N[(c0 / N[(N[(N[Sqrt[(-V)], $MachinePrecision] / N[Sqrt[(-A)], $MachinePrecision]), $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 * N[(N[Sqrt[A], $MachinePrecision] * N[Sqrt[N[(N[(1.0 / V), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[c0, A, V, l] = \mathsf{sort}([c0, A, V, l])\\
\\
\begin{array}{l}
\mathbf{if}\;A \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\frac{c0}{\frac{\sqrt{-V}}{\sqrt{-A}} \cdot \sqrt{\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 2 regimes
  2. if A < -1.999999999999994e-310

    1. Initial program 71.9%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(c0 \cdot \left(\sqrt{\frac{A}{V}} \cdot \sqrt{\frac{1}{\ell}}\right)\right)} - 1} \]
    6. Applied egg-rr28.0%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{c0}{\sqrt{\ell \cdot \frac{V}{A}}}\right)} - 1} \]
    7. Step-by-step derivation
      1. expm1-def59.4%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{c0}{\sqrt{\ell \cdot \frac{V}{A}}}\right)\right)} \]
      2. expm1-log1p72.8%

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

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

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

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

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

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

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

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

    if -1.999999999999994e-310 < A

    1. Initial program 80.0%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;A \leq -2 \cdot 10^{-310}:\\ \;\;\;\;\frac{c0}{\frac{\sqrt{-V}}{\sqrt{-A}} \cdot \sqrt{\ell}}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \left(\sqrt{A} \cdot \sqrt{\frac{\frac{1}{V}}{\ell}}\right)\\ \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}{V \cdot \ell}}\\ \mathbf{if}\;t_0 \leq 0 \lor \neg \left(t_0 \leq 10^{+251}\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 (* V l))))))
   (if (or (<= t_0 0.0) (not (<= t_0 1e+251)))
     (* c0 (sqrt (/ (/ A V) l)))
     t_0)))
assert(c0 < A && A < V && V < l);
double code(double c0, double A, double V, double l) {
	double t_0 = c0 * sqrt((A / (V * l)));
	double tmp;
	if ((t_0 <= 0.0) || !(t_0 <= 1e+251)) {
		tmp = c0 * sqrt(((A / V) / l));
	} else {
		tmp = t_0;
	}
	return tmp;
}
NOTE: c0, A, V, and l should be sorted in increasing order before calling this function.
real(8) function code(c0, a, v, l)
    real(8), intent (in) :: c0
    real(8), intent (in) :: a
    real(8), intent (in) :: v
    real(8), intent (in) :: l
    real(8) :: t_0
    real(8) :: tmp
    t_0 = c0 * sqrt((a / (v * l)))
    if ((t_0 <= 0.0d0) .or. (.not. (t_0 <= 1d+251))) then
        tmp = c0 * sqrt(((a / v) / l))
    else
        tmp = t_0
    end if
    code = tmp
end function
assert c0 < A && A < V && V < l;
public static double code(double c0, double A, double V, double l) {
	double t_0 = c0 * Math.sqrt((A / (V * l)));
	double tmp;
	if ((t_0 <= 0.0) || !(t_0 <= 1e+251)) {
		tmp = c0 * Math.sqrt(((A / V) / l));
	} else {
		tmp = t_0;
	}
	return tmp;
}
[c0, A, V, l] = sort([c0, A, V, l])
def code(c0, A, V, l):
	t_0 = c0 * math.sqrt((A / (V * l)))
	tmp = 0
	if (t_0 <= 0.0) or not (t_0 <= 1e+251):
		tmp = c0 * math.sqrt(((A / V) / l))
	else:
		tmp = t_0
	return tmp
c0, A, V, l = sort([c0, A, V, l])
function code(c0, A, V, l)
	t_0 = Float64(c0 * sqrt(Float64(A / Float64(V * l))))
	tmp = 0.0
	if ((t_0 <= 0.0) || !(t_0 <= 1e+251))
		tmp = Float64(c0 * sqrt(Float64(Float64(A / V) / l)));
	else
		tmp = t_0;
	end
	return tmp
end
c0, A, V, l = num2cell(sort([c0, A, V, l])){:}
function tmp_2 = code(c0, A, V, l)
	t_0 = c0 * sqrt((A / (V * l)));
	tmp = 0.0;
	if ((t_0 <= 0.0) || ~((t_0 <= 1e+251)))
		tmp = c0 * sqrt(((A / V) / l));
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
NOTE: c0, A, V, and l should be sorted in increasing order before calling this function.
code[c0_, A_, V_, l_] := Block[{t$95$0 = N[(c0 * N[Sqrt[N[(A / N[(V * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, 0.0], N[Not[LessEqual[t$95$0, 1e+251]], $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}{V \cdot \ell}}\\
\mathbf{if}\;t_0 \leq 0 \lor \neg \left(t_0 \leq 10^{+251}\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 1e251 < (*.f64 c0 (sqrt.f64 (/.f64 A (*.f64 V l))))

    1. Initial program 66.5%

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

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

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

      \[\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)))) < 1e251

    1. Initial program 98.5%

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

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

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

\mathbf{elif}\;t_0 \leq 2 \cdot 10^{+211}:\\
\;\;\;\;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 68.5%

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

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

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

    1. Initial program 98.4%

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

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

    1. Initial program 61.9%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(c0 \cdot \left(\sqrt{\frac{A}{V}} \cdot \sqrt{\frac{1}{\ell}}\right)\right)\right)} \]
      9. expm1-udef30.6%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(c0 \cdot \left(\sqrt{\frac{A}{V}} \cdot \sqrt{\frac{1}{\ell}}\right)\right)} - 1} \]
    6. Applied egg-rr63.8%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{c0}{\sqrt{\ell \cdot \frac{V}{A}}}\right)} - 1} \]
    7. Step-by-step derivation
      1. expm1-def63.8%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{c0}{\sqrt{\ell \cdot \frac{V}{A}}}\right)\right)} \]
      2. expm1-log1p66.6%

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

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

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

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

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

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

Alternative 4: 76.4% accurate, 0.3× speedup?

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

\mathbf{elif}\;t_0 \leq 2 \cdot 10^{+211}:\\
\;\;\;\;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)))) < 1.00000000000000003e-306

    1. Initial program 68.7%

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

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

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

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

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

        \[\leadsto c0 \cdot \sqrt{\frac{\color{blue}{A}}{V \cdot \ell}} \]
      3. *-un-lft-identity68.7%

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

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

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

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

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

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

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(c0 \cdot \left(\sqrt{\frac{A}{V}} \cdot \sqrt{\frac{1}{\ell}}\right)\right)} - 1} \]
    6. Applied egg-rr15.4%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{c0}{\sqrt{\ell \cdot \frac{V}{A}}}\right)} - 1} \]
    7. Step-by-step derivation
      1. expm1-def44.0%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{c0}{\sqrt{\ell \cdot \frac{V}{A}}}\right)\right)} \]
      2. expm1-log1p74.8%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{\sqrt{\color{blue}{\frac{\ell}{\frac{A}{V}}}}} \]
      7. clear-num74.5%

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

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

        \[\leadsto \frac{c0}{\frac{\color{blue}{1}}{\sqrt{\frac{\frac{A}{V}}{\ell}}}} \]
      10. associate-/l/68.6%

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

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

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

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

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

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

    if 1.00000000000000003e-306 < (*.f64 c0 (sqrt.f64 (/.f64 A (*.f64 V l)))) < 1.9999999999999999e211

    1. Initial program 98.4%

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

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

    1. Initial program 61.9%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(c0 \cdot \left(\sqrt{\frac{A}{V}} \cdot \sqrt{\frac{1}{\ell}}\right)\right)\right)} \]
      9. expm1-udef30.6%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(c0 \cdot \left(\sqrt{\frac{A}{V}} \cdot \sqrt{\frac{1}{\ell}}\right)\right)} - 1} \]
    6. Applied egg-rr63.8%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{c0}{\sqrt{\ell \cdot \frac{V}{A}}}\right)} - 1} \]
    7. Step-by-step derivation
      1. expm1-def63.8%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{c0}{\sqrt{\ell \cdot \frac{V}{A}}}\right)\right)} \]
      2. expm1-log1p66.6%

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

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

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

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

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

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

Alternative 5: 86.0% accurate, 0.5× speedup?

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

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

\mathbf{elif}\;V \cdot \ell \leq 0:\\
\;\;\;\;\frac{\frac{c0}{\sqrt{\frac{V}{A}}}}{\sqrt{\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 4 regimes
  2. if (*.f64 V l) < -1.99999999999999981e187

    1. Initial program 36.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.99999999999999981e187 < (*.f64 V l) < -1.00000000000000004e-166

    1. Initial program 95.9%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(c0 \cdot \left(\sqrt{\frac{A}{V}} \cdot \sqrt{\frac{1}{\ell}}\right)\right)\right)} \]
      9. expm1-udef13.8%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(c0 \cdot \left(\sqrt{\frac{A}{V}} \cdot \sqrt{\frac{1}{\ell}}\right)\right)} - 1} \]
    6. Applied egg-rr26.3%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{c0}{\sqrt{\ell \cdot \frac{V}{A}}}\right)} - 1} \]
    7. Step-by-step derivation
      1. expm1-def71.5%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{c0}{\sqrt{\ell \cdot \frac{V}{A}}}\right)\right)} \]
      2. expm1-log1p84.4%

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

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

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

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

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

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

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

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

    if -1.00000000000000004e-166 < (*.f64 V l) < -0.0

    1. Initial program 54.0%

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

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

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

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

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

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

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

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

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

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

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

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

    if -0.0 < (*.f64 V l)

    1. Initial program 83.0%

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

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

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

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

      \[\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 simplification78.3%

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

Alternative 6: 90.0% accurate, 0.5× speedup?

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

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

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

\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) < -1e270

    1. Initial program 33.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1e270 < (*.f64 V l) < -4.99006e-322

    1. Initial program 88.6%

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

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

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

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

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

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

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

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

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

    if -4.99006e-322 < (*.f64 V l) < -0.0

    1. Initial program 49.0%

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

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

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

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

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

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

      \[\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/245.9%

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

      \[\leadsto c0 \cdot \color{blue}{\left(\sqrt{\frac{A}{V}} \cdot \sqrt{\frac{1}{\ell}}\right)} \]
    7. Step-by-step derivation
      1. clear-num45.9%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0 \cdot {\ell}^{\color{blue}{-0.5}}}{\sqrt{\frac{V}{A}}} \]
    10. Applied egg-rr48.3%

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

        \[\leadsto \color{blue}{\frac{c0}{\frac{\sqrt{\frac{V}{A}}}{{\ell}^{-0.5}}}} \]
    12. Simplified48.4%

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

    if -0.0 < (*.f64 V l)

    1. Initial program 83.0%

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

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

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

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

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

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

Alternative 7: 81.8% accurate, 0.5× speedup?

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

\mathbf{elif}\;t_0 \leq 10^{+306}:\\
\;\;\;\;c0 \cdot \sqrt{t_0}\\

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


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

    1. Initial program 30.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.00000017e-317 < (/.f64 A (*.f64 V l)) < 1.00000000000000002e306

    1. Initial program 99.2%

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

    if 1.00000000000000002e306 < (/.f64 A (*.f64 V l))

    1. Initial program 43.3%

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

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

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

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

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

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

      \[\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/240.3%

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

      \[\leadsto c0 \cdot \color{blue}{\left(\sqrt{\frac{A}{V}} \cdot \sqrt{\frac{1}{\ell}}\right)} \]
    7. Step-by-step derivation
      1. clear-num40.3%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0 \cdot {\ell}^{\color{blue}{-0.5}}}{\sqrt{\frac{V}{A}}} \]
    10. Applied egg-rr42.1%

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

        \[\leadsto \color{blue}{\frac{c0}{\frac{\sqrt{\frac{V}{A}}}{{\ell}^{-0.5}}}} \]
    12. Simplified42.1%

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

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

Alternative 8: 81.6% accurate, 0.5× speedup?

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

\mathbf{else}:\\
\;\;\;\;c0 \cdot \sqrt{t_0}\\


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

    1. Initial program 37.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.00000017e-317 < (/.f64 A (*.f64 V l)) < 1.9999999999999999e304

    1. Initial program 99.2%

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

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

Alternative 9: 81.6% accurate, 0.5× speedup?

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

\mathbf{elif}\;t_0 \leq 2 \cdot 10^{+304}:\\
\;\;\;\;c0 \cdot \sqrt{t_0}\\

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


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

    1. Initial program 30.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.00000017e-317 < (/.f64 A (*.f64 V l)) < 1.9999999999999999e304

    1. Initial program 99.2%

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

    if 1.9999999999999999e304 < (/.f64 A (*.f64 V l))

    1. Initial program 44.4%

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

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

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

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

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

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

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

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

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

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

Alternative 10: 81.8% accurate, 0.5× speedup?

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

\mathbf{elif}\;t_0 \leq 2 \cdot 10^{+304}:\\
\;\;\;\;c0 \cdot \sqrt{t_0}\\

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


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

    1. Initial program 30.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.00000017e-317 < (/.f64 A (*.f64 V l)) < 1.9999999999999999e304

    1. Initial program 99.2%

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

    if 1.9999999999999999e304 < (/.f64 A (*.f64 V l))

    1. Initial program 44.4%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(c0 \cdot \left(\sqrt{\frac{A}{V}} \cdot \sqrt{\frac{1}{\ell}}\right)\right)\right)} \]
      9. expm1-udef9.6%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(c0 \cdot \left(\sqrt{\frac{A}{V}} \cdot \sqrt{\frac{1}{\ell}}\right)\right)} - 1} \]
    6. Applied egg-rr20.8%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{c0}{\sqrt{\ell \cdot \frac{V}{A}}}\right)} - 1} \]
    7. Step-by-step derivation
      1. expm1-def22.6%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{c0}{\sqrt{\ell \cdot \frac{V}{A}}}\right)\right)} \]
      2. expm1-log1p54.4%

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

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

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

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

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

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

Alternative 11: 73.3% accurate, 1.0× speedup?

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

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

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

Reproduce

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