Average Error: 19.5 → 6.7
Time: 4.6s
Precision: binary64
\[ \begin{array}{c}[V, l] = \mathsf{sort}([V, l])\\ \end{array} \]
\[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
\[\begin{array}{l} \mathbf{if}\;V \cdot \ell \leq -\infty:\\ \;\;\;\;\left(\sqrt{\frac{A}{V}} \cdot \sqrt{\frac{1}{\ell}}\right) \cdot c0\\ \mathbf{elif}\;V \cdot \ell \leq -2 \cdot 10^{-320}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{-A}}{\sqrt{V \cdot \left(-\ell\right)}}\\ \mathbf{elif}\;V \cdot \ell \leq 4 \cdot 10^{-296}:\\ \;\;\;\;\frac{c0}{\sqrt{\frac{V}{\frac{A}{\ell}}}}\\ \mathbf{elif}\;V \cdot \ell \leq 10^{+268}:\\ \;\;\;\;c0 \cdot \left(\sqrt{A} \cdot \sqrt{\frac{1}{V \cdot \ell}}\right)\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{V}}{\ell}}\\ \end{array} \]
(FPCore (c0 A V l) :precision binary64 (* c0 (sqrt (/ A (* V l)))))
(FPCore (c0 A V l)
 :precision binary64
 (if (<= (* V l) (- INFINITY))
   (* (* (sqrt (/ A V)) (sqrt (/ 1.0 l))) c0)
   (if (<= (* V l) -2e-320)
     (* c0 (/ (sqrt (- A)) (sqrt (* V (- l)))))
     (if (<= (* V l) 4e-296)
       (/ c0 (sqrt (/ V (/ A l))))
       (if (<= (* V l) 1e+268)
         (* c0 (* (sqrt A) (sqrt (/ 1.0 (* V l)))))
         (* c0 (sqrt (/ (/ A V) l))))))))
double code(double c0, double A, double V, double l) {
	return c0 * sqrt((A / (V * l)));
}
double code(double c0, double A, double V, double l) {
	double tmp;
	if ((V * l) <= -((double) INFINITY)) {
		tmp = (sqrt((A / V)) * sqrt((1.0 / l))) * c0;
	} else if ((V * l) <= -2e-320) {
		tmp = c0 * (sqrt(-A) / sqrt((V * -l)));
	} else if ((V * l) <= 4e-296) {
		tmp = c0 / sqrt((V / (A / l)));
	} else if ((V * l) <= 1e+268) {
		tmp = c0 * (sqrt(A) * sqrt((1.0 / (V * l))));
	} else {
		tmp = c0 * sqrt(((A / V) / l));
	}
	return tmp;
}
public static double code(double c0, double A, double V, double l) {
	return c0 * Math.sqrt((A / (V * l)));
}
public static double code(double c0, double A, double V, double l) {
	double tmp;
	if ((V * l) <= -Double.POSITIVE_INFINITY) {
		tmp = (Math.sqrt((A / V)) * Math.sqrt((1.0 / l))) * c0;
	} else if ((V * l) <= -2e-320) {
		tmp = c0 * (Math.sqrt(-A) / Math.sqrt((V * -l)));
	} else if ((V * l) <= 4e-296) {
		tmp = c0 / Math.sqrt((V / (A / l)));
	} else if ((V * l) <= 1e+268) {
		tmp = c0 * (Math.sqrt(A) * Math.sqrt((1.0 / (V * l))));
	} else {
		tmp = c0 * Math.sqrt(((A / V) / l));
	}
	return tmp;
}
def code(c0, A, V, l):
	return c0 * math.sqrt((A / (V * l)))
def code(c0, A, V, l):
	tmp = 0
	if (V * l) <= -math.inf:
		tmp = (math.sqrt((A / V)) * math.sqrt((1.0 / l))) * c0
	elif (V * l) <= -2e-320:
		tmp = c0 * (math.sqrt(-A) / math.sqrt((V * -l)))
	elif (V * l) <= 4e-296:
		tmp = c0 / math.sqrt((V / (A / l)))
	elif (V * l) <= 1e+268:
		tmp = c0 * (math.sqrt(A) * math.sqrt((1.0 / (V * l))))
	else:
		tmp = c0 * math.sqrt(((A / V) / l))
	return tmp
function code(c0, A, V, l)
	return Float64(c0 * sqrt(Float64(A / Float64(V * l))))
end
function code(c0, A, V, l)
	tmp = 0.0
	if (Float64(V * l) <= Float64(-Inf))
		tmp = Float64(Float64(sqrt(Float64(A / V)) * sqrt(Float64(1.0 / l))) * c0);
	elseif (Float64(V * l) <= -2e-320)
		tmp = Float64(c0 * Float64(sqrt(Float64(-A)) / sqrt(Float64(V * Float64(-l)))));
	elseif (Float64(V * l) <= 4e-296)
		tmp = Float64(c0 / sqrt(Float64(V / Float64(A / l))));
	elseif (Float64(V * l) <= 1e+268)
		tmp = Float64(c0 * Float64(sqrt(A) * sqrt(Float64(1.0 / Float64(V * l)))));
	else
		tmp = Float64(c0 * sqrt(Float64(Float64(A / V) / l)));
	end
	return tmp
end
function tmp = code(c0, A, V, l)
	tmp = c0 * sqrt((A / (V * l)));
end
function tmp_2 = code(c0, A, V, l)
	tmp = 0.0;
	if ((V * l) <= -Inf)
		tmp = (sqrt((A / V)) * sqrt((1.0 / l))) * c0;
	elseif ((V * l) <= -2e-320)
		tmp = c0 * (sqrt(-A) / sqrt((V * -l)));
	elseif ((V * l) <= 4e-296)
		tmp = c0 / sqrt((V / (A / l)));
	elseif ((V * l) <= 1e+268)
		tmp = c0 * (sqrt(A) * sqrt((1.0 / (V * l))));
	else
		tmp = c0 * sqrt(((A / V) / l));
	end
	tmp_2 = tmp;
end
code[c0_, A_, V_, l_] := N[(c0 * N[Sqrt[N[(A / N[(V * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
code[c0_, A_, V_, l_] := If[LessEqual[N[(V * l), $MachinePrecision], (-Infinity)], N[(N[(N[Sqrt[N[(A / V), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(1.0 / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * c0), $MachinePrecision], If[LessEqual[N[(V * l), $MachinePrecision], -2e-320], N[(c0 * N[(N[Sqrt[(-A)], $MachinePrecision] / N[Sqrt[N[(V * (-l)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(V * l), $MachinePrecision], 4e-296], N[(c0 / N[Sqrt[N[(V / N[(A / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(V * l), $MachinePrecision], 1e+268], N[(c0 * N[(N[Sqrt[A], $MachinePrecision] * N[Sqrt[N[(1.0 / N[(V * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 * N[Sqrt[N[(N[(A / V), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}
\begin{array}{l}
\mathbf{if}\;V \cdot \ell \leq -\infty:\\
\;\;\;\;\left(\sqrt{\frac{A}{V}} \cdot \sqrt{\frac{1}{\ell}}\right) \cdot c0\\

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

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

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

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


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 5 regimes
  2. if (*.f64 V l) < -inf.0

    1. Initial program 40.5

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Applied egg-rr24.3

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

      \[\leadsto \color{blue}{\frac{c0}{\sqrt{V \cdot \frac{\ell}{A}}}} \]
    4. Taylor expanded in c0 around 0 40.5

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

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

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

    if -inf.0 < (*.f64 V l) < -1.99998e-320

    1. Initial program 10.3

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Applied egg-rr0.6

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

    if -1.99998e-320 < (*.f64 V l) < 4e-296

    1. Initial program 60.9

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Applied egg-rr36.7

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

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

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

    if 4e-296 < (*.f64 V l) < 9.9999999999999997e267

    1. Initial program 9.7

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Applied egg-rr0.4

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

    if 9.9999999999999997e267 < (*.f64 V l)

    1. Initial program 36.6

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Applied egg-rr23.7

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

      \[\leadsto \color{blue}{\frac{c0}{\sqrt{V \cdot \frac{\ell}{A}}}} \]
    4. Taylor expanded in c0 around 0 36.6

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;V \cdot \ell \leq -\infty:\\ \;\;\;\;\left(\sqrt{\frac{A}{V}} \cdot \sqrt{\frac{1}{\ell}}\right) \cdot c0\\ \mathbf{elif}\;V \cdot \ell \leq -2 \cdot 10^{-320}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{-A}}{\sqrt{V \cdot \left(-\ell\right)}}\\ \mathbf{elif}\;V \cdot \ell \leq 4 \cdot 10^{-296}:\\ \;\;\;\;\frac{c0}{\sqrt{\frac{V}{\frac{A}{\ell}}}}\\ \mathbf{elif}\;V \cdot \ell \leq 10^{+268}:\\ \;\;\;\;c0 \cdot \left(\sqrt{A} \cdot \sqrt{\frac{1}{V \cdot \ell}}\right)\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{V}}{\ell}}\\ \end{array} \]

Reproduce

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