Average Error: 19.0 → 6.3
Time: 14.1s
Precision: binary64
Cost: 20556
\[ \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:\\ \;\;\;\;\frac{c0}{\sqrt{\ell} \cdot \sqrt{\frac{V}{A}}}\\ \mathbf{elif}\;V \cdot \ell \leq -2 \cdot 10^{-300}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{-A}}{\sqrt{V \cdot \left(-\ell\right)}}\\ \mathbf{elif}\;V \cdot \ell \leq 2 \cdot 10^{-313}:\\ \;\;\;\;{\left(\frac{V}{A}\right)}^{-0.5} \cdot \frac{c0}{\sqrt{\ell}}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \left(\sqrt{A} \cdot {\left(\frac{{V}^{-1}}{\ell}\right)}^{0.5}\right)\\ \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 l) (sqrt (/ V A))))
   (if (<= (* V l) -2e-300)
     (* c0 (/ (sqrt (- A)) (sqrt (* V (- l)))))
     (if (<= (* V l) 2e-313)
       (* (pow (/ V A) -0.5) (/ c0 (sqrt l)))
       (* c0 (* (sqrt A) (pow (/ (pow V -1.0) l) 0.5)))))))
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(l) * sqrt((V / A)));
	} else if ((V * l) <= -2e-300) {
		tmp = c0 * (sqrt(-A) / sqrt((V * -l)));
	} else if ((V * l) <= 2e-313) {
		tmp = pow((V / A), -0.5) * (c0 / sqrt(l));
	} else {
		tmp = c0 * (sqrt(A) * pow((pow(V, -1.0) / l), 0.5));
	}
	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 = c0 / (Math.sqrt(l) * Math.sqrt((V / A)));
	} else if ((V * l) <= -2e-300) {
		tmp = c0 * (Math.sqrt(-A) / Math.sqrt((V * -l)));
	} else if ((V * l) <= 2e-313) {
		tmp = Math.pow((V / A), -0.5) * (c0 / Math.sqrt(l));
	} else {
		tmp = c0 * (Math.sqrt(A) * Math.pow((Math.pow(V, -1.0) / l), 0.5));
	}
	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 = c0 / (math.sqrt(l) * math.sqrt((V / A)))
	elif (V * l) <= -2e-300:
		tmp = c0 * (math.sqrt(-A) / math.sqrt((V * -l)))
	elif (V * l) <= 2e-313:
		tmp = math.pow((V / A), -0.5) * (c0 / math.sqrt(l))
	else:
		tmp = c0 * (math.sqrt(A) * math.pow((math.pow(V, -1.0) / l), 0.5))
	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(c0 / Float64(sqrt(l) * sqrt(Float64(V / A))));
	elseif (Float64(V * l) <= -2e-300)
		tmp = Float64(c0 * Float64(sqrt(Float64(-A)) / sqrt(Float64(V * Float64(-l)))));
	elseif (Float64(V * l) <= 2e-313)
		tmp = Float64((Float64(V / A) ^ -0.5) * Float64(c0 / sqrt(l)));
	else
		tmp = Float64(c0 * Float64(sqrt(A) * (Float64((V ^ -1.0) / l) ^ 0.5)));
	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 = c0 / (sqrt(l) * sqrt((V / A)));
	elseif ((V * l) <= -2e-300)
		tmp = c0 * (sqrt(-A) / sqrt((V * -l)));
	elseif ((V * l) <= 2e-313)
		tmp = ((V / A) ^ -0.5) * (c0 / sqrt(l));
	else
		tmp = c0 * (sqrt(A) * (((V ^ -1.0) / l) ^ 0.5));
	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[(c0 / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[N[(V / A), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(V * l), $MachinePrecision], -2e-300], N[(c0 * N[(N[Sqrt[(-A)], $MachinePrecision] / N[Sqrt[N[(V * (-l)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(V * l), $MachinePrecision], 2e-313], N[(N[Power[N[(V / A), $MachinePrecision], -0.5], $MachinePrecision] * N[(c0 / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 * N[(N[Sqrt[A], $MachinePrecision] * N[Power[N[(N[Power[V, -1.0], $MachinePrecision] / l), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}
\begin{array}{l}
\mathbf{if}\;V \cdot \ell \leq -\infty:\\
\;\;\;\;\frac{c0}{\sqrt{\ell} \cdot \sqrt{\frac{V}{A}}}\\

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

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

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


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

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

    1. Initial program 40.1

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

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

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

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

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

    if -inf.0 < (*.f64 V l) < -2.00000000000000005e-300

    1. Initial program 10.1

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

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

    if -2.00000000000000005e-300 < (*.f64 V l) < 1.99999999998e-313

    1. Initial program 60.3

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

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

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

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

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

    if 1.99999999998e-313 < (*.f64 V l)

    1. Initial program 14.5

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

      \[\leadsto c0 \cdot \color{blue}{\left(\sqrt{A} \cdot \sqrt{\frac{1}{V \cdot \ell}}\right)} \]
    3. Applied egg-rr5.8

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

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

Alternatives

Alternative 1
Error11.9
Cost40912
\[\begin{array}{l} t_0 := \frac{c0}{\sqrt{\ell} \cdot \sqrt{\frac{V}{A}}}\\ t_1 := c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}\\ \mathbf{if}\;t_1 \leq -\infty:\\ \;\;\;\;t_0\\ \mathbf{elif}\;t_1 \leq -1 \cdot 10^{-298}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_1 \leq 0:\\ \;\;\;\;t_0\\ \mathbf{elif}\;t_1 \leq 5 \cdot 10^{+293}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error14.5
Cost34576
\[\begin{array}{l} t_0 := c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}\\ \mathbf{if}\;t_0 \leq -\infty:\\ \;\;\;\;\frac{c0}{\sqrt{V} \cdot \sqrt{\frac{\ell}{A}}}\\ \mathbf{elif}\;t_0 \leq -5 \cdot 10^{-277}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;t_0 \leq 0:\\ \;\;\;\;\frac{c0}{{\left(\frac{\frac{A}{\ell}}{V}\right)}^{-0.5}}\\ \mathbf{elif}\;t_0 \leq 5 \cdot 10^{+293}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot {\left(\ell \cdot \frac{V}{A}\right)}^{-0.5}\\ \end{array} \]
Alternative 3
Error5.8
Cost20296
\[\begin{array}{l} \mathbf{if}\;V \cdot \ell \leq -2 \cdot 10^{-300}:\\ \;\;\;\;c0 \cdot \left({\ell}^{-0.5} \cdot \frac{\sqrt{-A}}{\sqrt{-V}}\right)\\ \mathbf{elif}\;V \cdot \ell \leq 2 \cdot 10^{-313}:\\ \;\;\;\;{\left(\frac{V}{A}\right)}^{-0.5} \cdot \frac{c0}{\sqrt{\ell}}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \left(\sqrt{A} \cdot {\left(\frac{{V}^{-1}}{\ell}\right)}^{0.5}\right)\\ \end{array} \]
Alternative 4
Error9.3
Cost14092
\[\begin{array}{l} \mathbf{if}\;V \cdot \ell \leq -5 \cdot 10^{+194}:\\ \;\;\;\;\frac{c0}{\sqrt{\ell} \cdot \sqrt{\frac{V}{A}}}\\ \mathbf{elif}\;V \cdot \ell \leq -2 \cdot 10^{-207}:\\ \;\;\;\;\frac{c0}{\sqrt{\frac{V \cdot \ell}{A}}}\\ \mathbf{elif}\;V \cdot \ell \leq 0:\\ \;\;\;\;{\left(\frac{V}{A}\right)}^{-0.5} \cdot \frac{c0}{\sqrt{\ell}}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{A}}{\sqrt{V \cdot \ell}}\\ \end{array} \]
Alternative 5
Error6.3
Cost14092
\[\begin{array}{l} \mathbf{if}\;V \cdot \ell \leq -\infty:\\ \;\;\;\;\frac{c0}{\sqrt{\ell} \cdot \sqrt{\frac{V}{A}}}\\ \mathbf{elif}\;V \cdot \ell \leq -2 \cdot 10^{-300}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{-A}}{\sqrt{V \cdot \left(-\ell\right)}}\\ \mathbf{elif}\;V \cdot \ell \leq 0:\\ \;\;\;\;{\left(\frac{V}{A}\right)}^{-0.5} \cdot \frac{c0}{\sqrt{\ell}}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{A}}{\sqrt{V \cdot \ell}}\\ \end{array} \]
Alternative 6
Error8.8
Cost14028
\[\begin{array}{l} t_0 := \frac{c0}{\sqrt{\ell} \cdot \sqrt{\frac{V}{A}}}\\ \mathbf{if}\;V \cdot \ell \leq -5 \cdot 10^{+194}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;V \cdot \ell \leq -2 \cdot 10^{-122}:\\ \;\;\;\;\frac{c0}{\sqrt{\left(V \cdot \ell\right) \cdot \frac{1}{A}}}\\ \mathbf{elif}\;V \cdot \ell \leq 0:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{c0}{\frac{\sqrt{V \cdot \ell}}{\sqrt{A}}}\\ \end{array} \]
Alternative 7
Error8.8
Cost14028
\[\begin{array}{l} t_0 := \frac{c0}{\sqrt{\ell} \cdot \sqrt{\frac{V}{A}}}\\ \mathbf{if}\;V \cdot \ell \leq -5 \cdot 10^{+194}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;V \cdot \ell \leq -2 \cdot 10^{-122}:\\ \;\;\;\;\frac{c0}{\sqrt{\left(V \cdot \ell\right) \cdot \frac{1}{A}}}\\ \mathbf{elif}\;V \cdot \ell \leq 0:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{A}}{\sqrt{V \cdot \ell}}\\ \end{array} \]
Alternative 8
Error14.6
Cost7752
\[\begin{array}{l} t_0 := \frac{A}{V \cdot \ell}\\ \mathbf{if}\;t_0 \leq 5 \cdot 10^{-321}:\\ \;\;\;\;\frac{c0}{{\left(\frac{\frac{A}{\ell}}{V}\right)}^{-0.5}}\\ \mathbf{elif}\;t_0 \leq 10^{+293}:\\ \;\;\;\;\frac{c0}{\sqrt{\frac{V \cdot \ell}{A}}}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \frac{1}{\sqrt{\ell \cdot \frac{V}{A}}}\\ \end{array} \]
Alternative 9
Error14.6
Cost7688
\[\begin{array}{l} t_0 := \frac{A}{V \cdot \ell}\\ \mathbf{if}\;t_0 \leq 5 \cdot 10^{-321}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{V}}{\ell}}\\ \mathbf{elif}\;t_0 \leq 10^{+293}:\\ \;\;\;\;\frac{c0}{\sqrt{\frac{V \cdot \ell}{A}}}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot {\left(\ell \cdot \frac{V}{A}\right)}^{-0.5}\\ \end{array} \]
Alternative 10
Error14.6
Cost7688
\[\begin{array}{l} t_0 := \frac{A}{V \cdot \ell}\\ \mathbf{if}\;t_0 \leq 5 \cdot 10^{-321}:\\ \;\;\;\;\frac{c0}{{\left(\frac{\frac{A}{\ell}}{V}\right)}^{-0.5}}\\ \mathbf{elif}\;t_0 \leq 10^{+293}:\\ \;\;\;\;\frac{c0}{\sqrt{\frac{V \cdot \ell}{A}}}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot {\left(\ell \cdot \frac{V}{A}\right)}^{-0.5}\\ \end{array} \]
Alternative 11
Error14.6
Cost7624
\[\begin{array}{l} t_0 := \frac{A}{V \cdot \ell}\\ \mathbf{if}\;t_0 \leq 5 \cdot 10^{-321}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{V}}{\ell}}\\ \mathbf{elif}\;t_0 \leq 10^{+293}:\\ \;\;\;\;\frac{c0}{\sqrt{\frac{V \cdot \ell}{A}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c0}{\sqrt{\ell \cdot \frac{V}{A}}}\\ \end{array} \]
Alternative 12
Error18.9
Cost7376
\[\begin{array}{l} t_0 := \frac{c0}{\sqrt{\ell \cdot \frac{V}{A}}}\\ t_1 := \frac{c0}{\sqrt{\frac{V}{\frac{A}{\ell}}}}\\ \mathbf{if}\;A \leq -1 \cdot 10^{+145}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;A \leq -1 \cdot 10^{-50}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;A \leq 10^{-126}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;A \leq 10^{+276}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 13
Error18.8
Cost6848
\[\frac{c0}{\sqrt{\frac{V}{\frac{A}{\ell}}}} \]

Error

Reproduce

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