Henrywood and Agarwal, Equation (3)

Percentage Accurate: 73.5% → 90.1%
Time: 10.6s
Alternatives: 9
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 9 alternatives:

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

Initial Program: 73.5% accurate, 1.0× speedup?

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

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

Alternative 1: 90.1% accurate, 0.5× speedup?

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

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

\mathbf{elif}\;\ell \cdot V \leq 0 \lor \neg \left(\ell \cdot V \leq 5 \cdot 10^{+299}\right):\\
\;\;\;\;\frac{c0}{\sqrt{V \cdot \frac{\ell}{A}}}\\

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


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

    1. Initial program 47.9%

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

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

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

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

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

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

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

    if -1.0000000000000001e272 < (*.f64 V l) < -2.0000000000000001e-210

    1. Initial program 88.8%

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

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

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

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

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

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

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

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

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

    if -2.0000000000000001e-210 < (*.f64 V l) < -0.0 or 5.0000000000000003e299 < (*.f64 V l)

    1. Initial program 49.2%

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

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

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

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

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

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

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

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

    if -0.0 < (*.f64 V l) < 5.0000000000000003e299

    1. Initial program 87.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 77.0% accurate, 0.3× speedup?

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

    1. Initial program 67.4%

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

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

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

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

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

    1. Initial program 99.5%

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

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

Alternative 3: 87.8% accurate, 0.3× speedup?

\[\begin{array}{l} [c0, A, V, l] = \mathsf{sort}([c0, A, V, l])\\ \\ \begin{array}{l} \mathbf{if}\;\ell \leq -5 \cdot 10^{-310}:\\ \;\;\;\;c0 \cdot \frac{\frac{\sqrt{A}}{\sqrt{-V}}}{\sqrt{-\ell}}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \left(\frac{1}{\sqrt{\frac{V}{A}}} \cdot {\ell}^{-0.5}\right)\\ \end{array} \end{array} \]
NOTE: c0, A, V, and l should be sorted in increasing order before calling this function.
(FPCore (c0 A V l)
 :precision binary64
 (if (<= l -5e-310)
   (* c0 (/ (/ (sqrt A) (sqrt (- V))) (sqrt (- l))))
   (* c0 (* (/ 1.0 (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 tmp;
	if (l <= -5e-310) {
		tmp = c0 * ((sqrt(A) / sqrt(-V)) / sqrt(-l));
	} else {
		tmp = c0 * ((1.0 / 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) :: tmp
    if (l <= (-5d-310)) then
        tmp = c0 * ((sqrt(a) / sqrt(-v)) / sqrt(-l))
    else
        tmp = c0 * ((1.0d0 / 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 tmp;
	if (l <= -5e-310) {
		tmp = c0 * ((Math.sqrt(A) / Math.sqrt(-V)) / Math.sqrt(-l));
	} else {
		tmp = c0 * ((1.0 / 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):
	tmp = 0
	if l <= -5e-310:
		tmp = c0 * ((math.sqrt(A) / math.sqrt(-V)) / math.sqrt(-l))
	else:
		tmp = c0 * ((1.0 / 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)
	tmp = 0.0
	if (l <= -5e-310)
		tmp = Float64(c0 * Float64(Float64(sqrt(A) / sqrt(Float64(-V))) / sqrt(Float64(-l))));
	else
		tmp = Float64(c0 * Float64(Float64(1.0 / 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)
	tmp = 0.0;
	if (l <= -5e-310)
		tmp = c0 * ((sqrt(A) / sqrt(-V)) / sqrt(-l));
	else
		tmp = c0 * ((1.0 / 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_] := If[LessEqual[l, -5e-310], N[(c0 * N[(N[(N[Sqrt[A], $MachinePrecision] / N[Sqrt[(-V)], $MachinePrecision]), $MachinePrecision] / N[Sqrt[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 * N[(N[(1.0 / N[Sqrt[N[(V / A), $MachinePrecision]], $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}
\mathbf{if}\;\ell \leq -5 \cdot 10^{-310}:\\
\;\;\;\;c0 \cdot \frac{\frac{\sqrt{A}}{\sqrt{-V}}}{\sqrt{-\ell}}\\

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


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

    1. Initial program 75.2%

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

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

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

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

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

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

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

        \[\leadsto c0 \cdot \frac{\color{blue}{\frac{\sqrt{-\left(-A\right)}}{\sqrt{-V}}}}{\sqrt{-\ell}} \]
      3. remove-double-neg54.5%

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

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

    if -4.999999999999985e-310 < l

    1. Initial program 75.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 87.3% accurate, 0.5× speedup?

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

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

\mathbf{elif}\;\ell \cdot V \leq 0 \lor \neg \left(\ell \cdot V \leq 5 \cdot 10^{+299}\right):\\
\;\;\;\;\frac{c0}{\sqrt{V \cdot \frac{\ell}{A}}}\\

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


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

    1. Initial program 55.2%

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

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

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

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

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

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

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

    if -5.00000000000000012e143 < (*.f64 V l) < -2.00000000000000014e-189

    1. Initial program 96.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto c0 \cdot \frac{\color{blue}{1}}{\sqrt{V \cdot \frac{\ell}{A}}} \]
      10. pow1/283.3%

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

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

        \[\leadsto c0 \cdot {\color{blue}{\left(\frac{V \cdot \ell}{A}\right)}}^{\left(-0.5\right)} \]
      13. *-commutative97.0%

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

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

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

    if -2.00000000000000014e-189 < (*.f64 V l) < -0.0 or 5.0000000000000003e299 < (*.f64 V l)

    1. Initial program 47.3%

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

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

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

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

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

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

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

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

    if -0.0 < (*.f64 V l) < 5.0000000000000003e299

    1. Initial program 87.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 81.7% accurate, 0.5× speedup?

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

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


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

    1. Initial program 75.2%

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

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

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

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

    if -4.999999999999985e-310 < l

    1. Initial program 75.2%

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

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

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

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

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

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

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

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

Alternative 6: 79.2% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 38.4%

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

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

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

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

    if 5.00000000000023e-311 < (/.f64 A (*.f64 V l)) < 1e270

    1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto c0 \cdot \frac{\color{blue}{1}}{\sqrt{V \cdot \frac{\ell}{A}}} \]
      10. pow1/286.8%

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

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

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

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

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

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

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

    1. Initial program 49.3%

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

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

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

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

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

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

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

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

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

Alternative 7: 79.8% accurate, 0.8× speedup?

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

\mathbf{elif}\;t_0 \leq 5 \cdot 10^{+293}:\\
\;\;\;\;c0 \cdot {\left(\frac{\ell \cdot V}{A}\right)}^{-0.5}\\

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


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

    1. Initial program 38.4%

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

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

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

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

    if 5.00000000000023e-311 < (/.f64 A (*.f64 V l)) < 5.00000000000000033e293

    1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto c0 \cdot \frac{\color{blue}{1}}{\sqrt{V \cdot \frac{\ell}{A}}} \]
      10. pow1/287.0%

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

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

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

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

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

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

    if 5.00000000000000033e293 < (/.f64 A (*.f64 V l))

    1. Initial program 46.1%

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

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

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

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

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

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

Alternative 8: 80.2% accurate, 0.9× speedup?

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

\mathbf{elif}\;t_0 \leq 5 \cdot 10^{+302}:\\
\;\;\;\;c0 \cdot \sqrt{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 A (*.f64 V l)) < 0.0

    1. Initial program 36.9%

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

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

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

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

    if 0.0 < (/.f64 A (*.f64 V l)) < 5e302

    1. Initial program 98.9%

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

    if 5e302 < (/.f64 A (*.f64 V l))

    1. Initial program 39.9%

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

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

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

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

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

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

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

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

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

Alternative 9: 73.5% accurate, 1.0× speedup?

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

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

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

Reproduce

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