Average Error: 18.9 → 12.9
Time: 3.8s
Precision: 64
\[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}\]
\[\begin{array}{l} \mathbf{if}\;V \cdot \ell \le -7.60320495836003008 \cdot 10^{-291}:\\ \;\;\;\;c0 \cdot \sqrt{A \cdot \frac{\frac{1}{V}}{\ell}}\\ \mathbf{elif}\;V \cdot \ell \le 2.47033 \cdot 10^{-323}:\\ \;\;\;\;\left(c0 \cdot \sqrt{\frac{1}{V}}\right) \cdot \sqrt{\frac{A}{\ell}}\\ \mathbf{elif}\;V \cdot \ell \le 4.25252124024244761 \cdot 10^{295}:\\ \;\;\;\;\frac{c0 \cdot \sqrt{A}}{\sqrt{V \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{1}{V} \cdot \frac{A}{\ell}}\\ \end{array}\]
c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}
\begin{array}{l}
\mathbf{if}\;V \cdot \ell \le -7.60320495836003008 \cdot 10^{-291}:\\
\;\;\;\;c0 \cdot \sqrt{A \cdot \frac{\frac{1}{V}}{\ell}}\\

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

\mathbf{elif}\;V \cdot \ell \le 4.25252124024244761 \cdot 10^{295}:\\
\;\;\;\;\frac{c0 \cdot \sqrt{A}}{\sqrt{V \cdot \ell}}\\

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

\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) <= -7.60320495836003e-291)) {
		VAR = (c0 * sqrt((A * ((1.0 / V) / l))));
	} else {
		double VAR_1;
		if (((V * l) <= 2.4703282292062e-323)) {
			VAR_1 = ((c0 * sqrt((1.0 / V))) * sqrt((A / l)));
		} else {
			double VAR_2;
			if (((V * l) <= 4.252521240242448e+295)) {
				VAR_2 = ((c0 * sqrt(A)) / sqrt((V * l)));
			} else {
				VAR_2 = (c0 * sqrt(((1.0 / V) * (A / l))));
			}
			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) < -7.60320495836003e-291

    1. Initial program 14.2

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

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

      \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{1}{V} \cdot \frac{A}{\ell}}}\]
    5. Using strategy rm
    6. Applied div-inv16.9

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

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

      \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{A}{V}} \cdot \frac{1}{\ell}}\]
    9. Using strategy rm
    10. Applied div-inv17.1

      \[\leadsto c0 \cdot \sqrt{\color{blue}{\left(A \cdot \frac{1}{V}\right)} \cdot \frac{1}{\ell}}\]
    11. Applied associate-*l*14.0

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

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

    if -7.60320495836003e-291 < (* V l) < 2.4703282292062e-323

    1. Initial program 59.6

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

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

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

      \[\leadsto c0 \cdot \color{blue}{\left(\sqrt{\frac{1}{V}} \cdot \sqrt{\frac{A}{\ell}}\right)}\]
    6. Applied associate-*r*39.7

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

    if 2.4703282292062e-323 < (* V l) < 4.252521240242448e+295

    1. Initial program 10.3

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

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

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

    if 4.252521240242448e+295 < (* V l)

    1. Initial program 41.5

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity41.5

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;V \cdot \ell \le -7.60320495836003008 \cdot 10^{-291}:\\ \;\;\;\;c0 \cdot \sqrt{A \cdot \frac{\frac{1}{V}}{\ell}}\\ \mathbf{elif}\;V \cdot \ell \le 2.47033 \cdot 10^{-323}:\\ \;\;\;\;\left(c0 \cdot \sqrt{\frac{1}{V}}\right) \cdot \sqrt{\frac{A}{\ell}}\\ \mathbf{elif}\;V \cdot \ell \le 4.25252124024244761 \cdot 10^{295}:\\ \;\;\;\;\frac{c0 \cdot \sqrt{A}}{\sqrt{V \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{1}{V} \cdot \frac{A}{\ell}}\\ \end{array}\]

Reproduce

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