Average Error: 19.3 → 5.7
Time: 9.0s
Precision: binary64
Cost: 20100
\[ \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 0:\\ \;\;\;\;c0 \cdot \left({\ell}^{-0.5} \cdot \frac{\sqrt{-A}}{\sqrt{-V}}\right)\\ \mathbf{elif}\;V \cdot \ell \leq 5 \cdot 10^{+277}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{A}}{\sqrt{V \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot {\left(V \cdot \frac{\ell}{A}\right)}^{-0.5}\\ \end{array} \]
(FPCore (c0 A V l) :precision binary64 (* c0 (sqrt (/ A (* V l)))))
(FPCore (c0 A V l)
 :precision binary64
 (if (<= (* V l) 0.0)
   (* c0 (* (pow l -0.5) (/ (sqrt (- A)) (sqrt (- V)))))
   (if (<= (* V l) 5e+277)
     (* c0 (/ (sqrt A) (sqrt (* V l))))
     (* c0 (pow (* V (/ l A)) -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) <= 0.0) {
		tmp = c0 * (pow(l, -0.5) * (sqrt(-A) / sqrt(-V)));
	} else if ((V * l) <= 5e+277) {
		tmp = c0 * (sqrt(A) / sqrt((V * l)));
	} else {
		tmp = c0 * pow((V * (l / A)), -0.5);
	}
	return tmp;
}
real(8) function code(c0, a, v, l)
    real(8), intent (in) :: c0
    real(8), intent (in) :: a
    real(8), intent (in) :: v
    real(8), intent (in) :: l
    code = c0 * sqrt((a / (v * l)))
end function
real(8) function code(c0, a, v, l)
    real(8), intent (in) :: c0
    real(8), intent (in) :: a
    real(8), intent (in) :: v
    real(8), intent (in) :: l
    real(8) :: tmp
    if ((v * l) <= 0.0d0) then
        tmp = c0 * ((l ** (-0.5d0)) * (sqrt(-a) / sqrt(-v)))
    else if ((v * l) <= 5d+277) then
        tmp = c0 * (sqrt(a) / sqrt((v * l)))
    else
        tmp = c0 * ((v * (l / a)) ** (-0.5d0))
    end if
    code = tmp
end function
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) <= 0.0) {
		tmp = c0 * (Math.pow(l, -0.5) * (Math.sqrt(-A) / Math.sqrt(-V)));
	} else if ((V * l) <= 5e+277) {
		tmp = c0 * (Math.sqrt(A) / Math.sqrt((V * l)));
	} else {
		tmp = c0 * Math.pow((V * (l / A)), -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) <= 0.0:
		tmp = c0 * (math.pow(l, -0.5) * (math.sqrt(-A) / math.sqrt(-V)))
	elif (V * l) <= 5e+277:
		tmp = c0 * (math.sqrt(A) / math.sqrt((V * l)))
	else:
		tmp = c0 * math.pow((V * (l / A)), -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) <= 0.0)
		tmp = Float64(c0 * Float64((l ^ -0.5) * Float64(sqrt(Float64(-A)) / sqrt(Float64(-V)))));
	elseif (Float64(V * l) <= 5e+277)
		tmp = Float64(c0 * Float64(sqrt(A) / sqrt(Float64(V * l))));
	else
		tmp = Float64(c0 * (Float64(V * Float64(l / A)) ^ -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) <= 0.0)
		tmp = c0 * ((l ^ -0.5) * (sqrt(-A) / sqrt(-V)));
	elseif ((V * l) <= 5e+277)
		tmp = c0 * (sqrt(A) / sqrt((V * l)));
	else
		tmp = c0 * ((V * (l / A)) ^ -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], 0.0], N[(c0 * N[(N[Power[l, -0.5], $MachinePrecision] * N[(N[Sqrt[(-A)], $MachinePrecision] / N[Sqrt[(-V)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(V * l), $MachinePrecision], 5e+277], N[(c0 * N[(N[Sqrt[A], $MachinePrecision] / N[Sqrt[N[(V * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 * N[Power[N[(V * N[(l / A), $MachinePrecision]), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]]]
c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}
\begin{array}{l}
\mathbf{if}\;V \cdot \ell \leq 0:\\
\;\;\;\;c0 \cdot \left({\ell}^{-0.5} \cdot \frac{\sqrt{-A}}{\sqrt{-V}}\right)\\

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

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


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 3 regimes
  2. if (*.f64 V l) < -0.0

    1. Initial program 22.5

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

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

      \[\leadsto c0 \cdot \color{blue}{\left({\ell}^{-0.5} \cdot \sqrt{\frac{A}{V}}\right)} \]
    4. Applied egg-rr6.5

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

    if -0.0 < (*.f64 V l) < 4.99999999999999982e277

    1. Initial program 10.6

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

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

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

    if 4.99999999999999982e277 < (*.f64 V l)

    1. Initial program 38.5

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;V \cdot \ell \leq 0:\\ \;\;\;\;c0 \cdot \left({\ell}^{-0.5} \cdot \frac{\sqrt{-A}}{\sqrt{-V}}\right)\\ \mathbf{elif}\;V \cdot \ell \leq 5 \cdot 10^{+277}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{A}}{\sqrt{V \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot {\left(V \cdot \frac{\ell}{A}\right)}^{-0.5}\\ \end{array} \]

Alternatives

Alternative 1
Error14.6
Cost7624
\[\begin{array}{l} t_0 := \frac{A}{V \cdot \ell}\\ \mathbf{if}\;t_0 \leq 10^{-323}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{V}}{\ell}}\\ \mathbf{elif}\;t_0 \leq 5 \cdot 10^{+287}:\\ \;\;\;\;c0 \cdot \sqrt{t_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{c0}{\sqrt{\frac{V}{\frac{A}{\ell}}}}\\ \end{array} \]

Error

Reproduce

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