Average Error: 18.8 → 8.3
Time: 2.9s
Precision: 64
\[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}\]
\[\begin{array}{l} \mathbf{if}\;V \cdot \ell = -\infty:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{\ell}}{V}}\\ \mathbf{elif}\;V \cdot \ell \le -1.7163677675578823 \cdot 10^{-306}:\\ \;\;\;\;\frac{c0 \cdot \sqrt{1}}{\frac{\sqrt{-V \cdot \ell}}{\sqrt{-A}}}\\ \mathbf{elif}\;V \cdot \ell \le 0.0:\\ \;\;\;\;\frac{c0 \cdot \sqrt{1}}{\frac{\sqrt{-V}}{\sqrt{-\frac{A}{\ell}}}}\\ \mathbf{elif}\;V \cdot \ell \le 1.6501826448876958 \cdot 10^{214}:\\ \;\;\;\;c0 \cdot \left(\sqrt{A} \cdot \sqrt{\frac{1}{V \cdot \ell}}\right)\\ \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 = -\infty:\\
\;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{\ell}}{V}}\\

\mathbf{elif}\;V \cdot \ell \le -1.7163677675578823 \cdot 10^{-306}:\\
\;\;\;\;\frac{c0 \cdot \sqrt{1}}{\frac{\sqrt{-V \cdot \ell}}{\sqrt{-A}}}\\

\mathbf{elif}\;V \cdot \ell \le 0.0:\\
\;\;\;\;\frac{c0 \cdot \sqrt{1}}{\frac{\sqrt{-V}}{\sqrt{-\frac{A}{\ell}}}}\\

\mathbf{elif}\;V \cdot \ell \le 1.6501826448876958 \cdot 10^{214}:\\
\;\;\;\;c0 \cdot \left(\sqrt{A} \cdot \sqrt{\frac{1}{V \cdot \ell}}\right)\\

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

\end{array}
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 VAR;
	if (((V * l) <= -inf.0)) {
		VAR = (c0 * sqrt(((A / l) / V)));
	} else {
		double VAR_1;
		if (((V * l) <= -1.7163677675578823e-306)) {
			VAR_1 = ((c0 * sqrt(1.0)) / (sqrt(-(V * l)) / sqrt(-A)));
		} else {
			double VAR_2;
			if (((V * l) <= 0.0)) {
				VAR_2 = ((c0 * sqrt(1.0)) / (sqrt(-V) / sqrt(-(A / l))));
			} else {
				double VAR_3;
				if (((V * l) <= 1.6501826448876958e+214)) {
					VAR_3 = (c0 * (sqrt(A) * sqrt((1.0 / (V * l)))));
				} else {
					VAR_3 = (c0 * sqrt(((A / l) / V)));
				}
				VAR_2 = VAR_3;
			}
			VAR_1 = VAR_2;
		}
		VAR = VAR_1;
	}
	return VAR;
}

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 4 regimes
  2. if (* V l) < -inf.0 or 1.6501826448876958e+214 < (* V l)

    1. Initial program 34.6

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}\]
    2. Using strategy rm
    3. Applied *-commutative34.6

      \[\leadsto c0 \cdot \sqrt{\frac{A}{\color{blue}{\ell \cdot V}}}\]
    4. Applied associate-/r*22.3

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

    if -inf.0 < (* V l) < -1.7163677675578823e-306

    1. Initial program 9.2

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}\]
    2. Using strategy rm
    3. Applied clear-num9.6

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

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

      \[\leadsto \color{blue}{\frac{c0 \cdot \sqrt{1}}{\sqrt{\frac{V \cdot \ell}{A}}}}\]
    6. Using strategy rm
    7. Applied frac-2neg9.2

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

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

    if -1.7163677675578823e-306 < (* V l) < 0.0

    1. Initial program 61.8

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}\]
    2. Using strategy rm
    3. Applied clear-num61.8

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

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

      \[\leadsto \color{blue}{\frac{c0 \cdot \sqrt{1}}{\sqrt{\frac{V \cdot \ell}{A}}}}\]
    6. Using strategy rm
    7. Applied associate-/l*35.9

      \[\leadsto \frac{c0 \cdot \sqrt{1}}{\sqrt{\color{blue}{\frac{V}{\frac{A}{\ell}}}}}\]
    8. Using strategy rm
    9. Applied frac-2neg35.9

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

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

    if 0.0 < (* V l) < 1.6501826448876958e+214

    1. Initial program 9.8

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}\]
    2. Using strategy rm
    3. Applied div-inv10.1

      \[\leadsto c0 \cdot \sqrt{\color{blue}{A \cdot \frac{1}{V \cdot \ell}}}\]
    4. Using strategy rm
    5. Applied sqrt-prod1.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;V \cdot \ell = -\infty:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{\ell}}{V}}\\ \mathbf{elif}\;V \cdot \ell \le -1.7163677675578823 \cdot 10^{-306}:\\ \;\;\;\;\frac{c0 \cdot \sqrt{1}}{\frac{\sqrt{-V \cdot \ell}}{\sqrt{-A}}}\\ \mathbf{elif}\;V \cdot \ell \le 0.0:\\ \;\;\;\;\frac{c0 \cdot \sqrt{1}}{\frac{\sqrt{-V}}{\sqrt{-\frac{A}{\ell}}}}\\ \mathbf{elif}\;V \cdot \ell \le 1.6501826448876958 \cdot 10^{214}:\\ \;\;\;\;c0 \cdot \left(\sqrt{A} \cdot \sqrt{\frac{1}{V \cdot \ell}}\right)\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{\ell}}{V}}\\ \end{array}\]

Reproduce

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