Average Error: 19.3 → 6.2
Time: 6.9s
Precision: binary64
\[[V, l] = \mathsf{sort}([V, l]) \\]
\[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
\[\begin{array}{l} \mathbf{if}\;V \cdot \ell \leq -\infty:\\ \;\;\;\;c0 \cdot \frac{\sqrt{\frac{A}{V}}}{\sqrt{\ell}}\\ \mathbf{elif}\;V \cdot \ell \leq -1.75142386 \cdot 10^{-315}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{-A}}{\sqrt{-V \cdot \ell}}\\ \mathbf{elif}\;V \cdot \ell \leq 0:\\ \;\;\;\;c0 \cdot {\left(e^{0.25 \cdot \left(\log \left(\frac{-A}{\ell}\right) + \log \left(\frac{-1}{V}\right)\right)}\right)}^{2}\\ \mathbf{elif}\;V \cdot \ell \leq 5.970120430153575 \cdot 10^{+246}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{A}}{\sqrt{V \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{\ell}}{V}}\\ \end{array} \]
c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}
\begin{array}{l}
\mathbf{if}\;V \cdot \ell \leq -\infty:\\
\;\;\;\;c0 \cdot \frac{\sqrt{\frac{A}{V}}}{\sqrt{\ell}}\\

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

\mathbf{elif}\;V \cdot \ell \leq 0:\\
\;\;\;\;c0 \cdot {\left(e^{0.25 \cdot \left(\log \left(\frac{-A}{\ell}\right) + \log \left(\frac{-1}{V}\right)\right)}\right)}^{2}\\

\mathbf{elif}\;V \cdot \ell \leq 5.970120430153575 \cdot 10^{+246}:\\
\;\;\;\;c0 \cdot \frac{\sqrt{A}}{\sqrt{V \cdot \ell}}\\

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


\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))
   (* c0 (/ (sqrt (/ A V)) (sqrt l)))
   (if (<= (* V l) -1.75142386e-315)
     (* c0 (/ (sqrt (- A)) (sqrt (- (* V l)))))
     (if (<= (* V l) 0.0)
       (* c0 (pow (exp (* 0.25 (+ (log (/ (- A) l)) (log (/ -1.0 V))))) 2.0))
       (if (<= (* V l) 5.970120430153575e+246)
         (* c0 (/ (sqrt A) (sqrt (* V l))))
         (* c0 (sqrt (/ (/ A l) V))))))))
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 = c0 * (sqrt((A / V)) / sqrt(l));
	} else if ((V * l) <= -1.75142386e-315) {
		tmp = c0 * (sqrt(-A) / sqrt(-(V * l)));
	} else if ((V * l) <= 0.0) {
		tmp = c0 * pow(exp((0.25 * (log((-A / l)) + log((-1.0 / V))))), 2.0);
	} else if ((V * l) <= 5.970120430153575e+246) {
		tmp = c0 * (sqrt(A) / sqrt((V * l)));
	} else {
		tmp = c0 * sqrt(((A / l) / V));
	}
	return tmp;
}

Error

Bits error versus c0

Bits error versus A

Bits error versus V

Bits error versus l

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 41.4

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

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

    if -inf.0 < (*.f64 V l) < -1.751423861e-315

    1. Initial program 10.3

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

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

    if -1.751423861e-315 < (*.f64 V l) < 0.0

    1. Initial program 63.2

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

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

      \[\leadsto c0 \cdot \color{blue}{{\left({\left(\frac{\frac{A}{V}}{\ell}\right)}^{0.25}\right)}^{2}} \]
    4. Taylor expanded in V around -inf 34.8

      \[\leadsto c0 \cdot {\color{blue}{\left(e^{0.25 \cdot \left(\log \left(-1 \cdot \frac{A}{\ell}\right) + \log \left(\frac{-1}{V}\right)\right)}\right)}}^{2} \]

    if 0.0 < (*.f64 V l) < 5.9701204301535753e246

    1. Initial program 9.8

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

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

    if 5.9701204301535753e246 < (*.f64 V l)

    1. Initial program 33.8

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;V \cdot \ell \leq -\infty:\\ \;\;\;\;c0 \cdot \frac{\sqrt{\frac{A}{V}}}{\sqrt{\ell}}\\ \mathbf{elif}\;V \cdot \ell \leq -1.75142386 \cdot 10^{-315}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{-A}}{\sqrt{-V \cdot \ell}}\\ \mathbf{elif}\;V \cdot \ell \leq 0:\\ \;\;\;\;c0 \cdot {\left(e^{0.25 \cdot \left(\log \left(\frac{-A}{\ell}\right) + \log \left(\frac{-1}{V}\right)\right)}\right)}^{2}\\ \mathbf{elif}\;V \cdot \ell \leq 5.970120430153575 \cdot 10^{+246}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{A}}{\sqrt{V \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{\ell}}{V}}\\ \end{array} \]

Reproduce

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