Average Error: 19.3 → 5.7
Time: 20.0s
Precision: binary64
Cost: 20036
\[ \begin{array}{c}[V, l] = \mathsf{sort}([V, l])\\ \end{array} \]
\[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
\[\begin{array}{l} t_0 := \sqrt{-V}\\ t_1 := \sqrt{-A}\\ \mathbf{if}\;V \cdot \ell \leq -1 \cdot 10^{+294}:\\ \;\;\;\;\frac{c0 \cdot \frac{t_1}{t_0}}{\sqrt{\ell}}\\ \mathbf{elif}\;V \cdot \ell \leq -1 \cdot 10^{-303}:\\ \;\;\;\;c0 \cdot \frac{t_1}{\sqrt{V \cdot \left(-\ell\right)}}\\ \mathbf{elif}\;V \cdot \ell \leq 0:\\ \;\;\;\;c0 \cdot \frac{\sqrt{\frac{-A}{\ell}}}{t_0}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \left({\left(V \cdot \ell\right)}^{-0.5} \cdot \sqrt{A}\right)\\ \end{array} \]
(FPCore (c0 A V l) :precision binary64 (* c0 (sqrt (/ A (* V l)))))
(FPCore (c0 A V l)
 :precision binary64
 (let* ((t_0 (sqrt (- V))) (t_1 (sqrt (- A))))
   (if (<= (* V l) -1e+294)
     (/ (* c0 (/ t_1 t_0)) (sqrt l))
     (if (<= (* V l) -1e-303)
       (* c0 (/ t_1 (sqrt (* V (- l)))))
       (if (<= (* V l) 0.0)
         (* c0 (/ (sqrt (/ (- A) l)) t_0))
         (* c0 (* (pow (* V l) -0.5) (sqrt A))))))))
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 t_0 = sqrt(-V);
	double t_1 = sqrt(-A);
	double tmp;
	if ((V * l) <= -1e+294) {
		tmp = (c0 * (t_1 / t_0)) / sqrt(l);
	} else if ((V * l) <= -1e-303) {
		tmp = c0 * (t_1 / sqrt((V * -l)));
	} else if ((V * l) <= 0.0) {
		tmp = c0 * (sqrt((-A / l)) / t_0);
	} else {
		tmp = c0 * (pow((V * l), -0.5) * sqrt(A));
	}
	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) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = sqrt(-v)
    t_1 = sqrt(-a)
    if ((v * l) <= (-1d+294)) then
        tmp = (c0 * (t_1 / t_0)) / sqrt(l)
    else if ((v * l) <= (-1d-303)) then
        tmp = c0 * (t_1 / sqrt((v * -l)))
    else if ((v * l) <= 0.0d0) then
        tmp = c0 * (sqrt((-a / l)) / t_0)
    else
        tmp = c0 * (((v * l) ** (-0.5d0)) * sqrt(a))
    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 t_0 = Math.sqrt(-V);
	double t_1 = Math.sqrt(-A);
	double tmp;
	if ((V * l) <= -1e+294) {
		tmp = (c0 * (t_1 / t_0)) / Math.sqrt(l);
	} else if ((V * l) <= -1e-303) {
		tmp = c0 * (t_1 / Math.sqrt((V * -l)));
	} else if ((V * l) <= 0.0) {
		tmp = c0 * (Math.sqrt((-A / l)) / t_0);
	} else {
		tmp = c0 * (Math.pow((V * l), -0.5) * Math.sqrt(A));
	}
	return tmp;
}
def code(c0, A, V, l):
	return c0 * math.sqrt((A / (V * l)))
def code(c0, A, V, l):
	t_0 = math.sqrt(-V)
	t_1 = math.sqrt(-A)
	tmp = 0
	if (V * l) <= -1e+294:
		tmp = (c0 * (t_1 / t_0)) / math.sqrt(l)
	elif (V * l) <= -1e-303:
		tmp = c0 * (t_1 / math.sqrt((V * -l)))
	elif (V * l) <= 0.0:
		tmp = c0 * (math.sqrt((-A / l)) / t_0)
	else:
		tmp = c0 * (math.pow((V * l), -0.5) * math.sqrt(A))
	return tmp
function code(c0, A, V, l)
	return Float64(c0 * sqrt(Float64(A / Float64(V * l))))
end
function code(c0, A, V, l)
	t_0 = sqrt(Float64(-V))
	t_1 = sqrt(Float64(-A))
	tmp = 0.0
	if (Float64(V * l) <= -1e+294)
		tmp = Float64(Float64(c0 * Float64(t_1 / t_0)) / sqrt(l));
	elseif (Float64(V * l) <= -1e-303)
		tmp = Float64(c0 * Float64(t_1 / sqrt(Float64(V * Float64(-l)))));
	elseif (Float64(V * l) <= 0.0)
		tmp = Float64(c0 * Float64(sqrt(Float64(Float64(-A) / l)) / t_0));
	else
		tmp = Float64(c0 * Float64((Float64(V * l) ^ -0.5) * sqrt(A)));
	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)
	t_0 = sqrt(-V);
	t_1 = sqrt(-A);
	tmp = 0.0;
	if ((V * l) <= -1e+294)
		tmp = (c0 * (t_1 / t_0)) / sqrt(l);
	elseif ((V * l) <= -1e-303)
		tmp = c0 * (t_1 / sqrt((V * -l)));
	elseif ((V * l) <= 0.0)
		tmp = c0 * (sqrt((-A / l)) / t_0);
	else
		tmp = c0 * (((V * l) ^ -0.5) * sqrt(A));
	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_] := Block[{t$95$0 = N[Sqrt[(-V)], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[(-A)], $MachinePrecision]}, If[LessEqual[N[(V * l), $MachinePrecision], -1e+294], N[(N[(c0 * N[(t$95$1 / t$95$0), $MachinePrecision]), $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(V * l), $MachinePrecision], -1e-303], N[(c0 * N[(t$95$1 / N[Sqrt[N[(V * (-l)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(V * l), $MachinePrecision], 0.0], N[(c0 * N[(N[Sqrt[N[((-A) / l), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision], N[(c0 * N[(N[Power[N[(V * l), $MachinePrecision], -0.5], $MachinePrecision] * N[Sqrt[A], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}
\begin{array}{l}
t_0 := \sqrt{-V}\\
t_1 := \sqrt{-A}\\
\mathbf{if}\;V \cdot \ell \leq -1 \cdot 10^{+294}:\\
\;\;\;\;\frac{c0 \cdot \frac{t_1}{t_0}}{\sqrt{\ell}}\\

\mathbf{elif}\;V \cdot \ell \leq -1 \cdot 10^{-303}:\\
\;\;\;\;c0 \cdot \frac{t_1}{\sqrt{V \cdot \left(-\ell\right)}}\\

\mathbf{elif}\;V \cdot \ell \leq 0:\\
\;\;\;\;c0 \cdot \frac{\sqrt{\frac{-A}{\ell}}}{t_0}\\

\mathbf{else}:\\
\;\;\;\;c0 \cdot \left({\left(V \cdot \ell\right)}^{-0.5} \cdot \sqrt{A}\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) < -1.00000000000000007e294

    1. Initial program 38.4

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

      \[\leadsto c0 \cdot \color{blue}{{\left(\frac{\frac{A}{V}}{\ell}\right)}^{0.5}} \]
    3. Applied egg-rr9.2

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

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

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

    if -1.00000000000000007e294 < (*.f64 V l) < -9.99999999999999931e-304

    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 -9.99999999999999931e-304 < (*.f64 V l) < 0.0

    1. Initial program 61.8

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

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

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

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

    if 0.0 < (*.f64 V l)

    1. Initial program 15.5

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

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

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

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

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

Alternatives

Alternative 1
Error14.4
Cost34640
\[\begin{array}{l} t_0 := c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}\\ t_1 := \frac{c0}{\sqrt{\frac{\ell}{\frac{A}{V}}}}\\ \mathbf{if}\;t_0 \leq -1 \cdot 10^{+174}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_0 \leq -2 \cdot 10^{-296}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;t_0 \leq 10^{-291}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_0 \leq 5 \cdot 10^{+303}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\frac{c0 \cdot \left(A \cdot \frac{c0}{V}\right)}{\ell}}\\ \end{array} \]
Alternative 2
Error6.5
Cost20036
\[\begin{array}{l} \mathbf{if}\;V \cdot \ell \leq 0:\\ \;\;\;\;c0 \cdot \frac{\frac{\sqrt{-A}}{\sqrt{-V}}}{\sqrt{\ell}}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \left({\left(V \cdot \ell\right)}^{-0.5} \cdot \sqrt{A}\right)\\ \end{array} \]
Alternative 3
Error9.0
Cost14156
\[\begin{array}{l} t_0 := c0 \cdot \frac{\sqrt{\frac{-A}{\ell}}}{\sqrt{-V}}\\ \mathbf{if}\;V \cdot \ell \leq -5 \cdot 10^{+154}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;V \cdot \ell \leq -5 \cdot 10^{-127}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}\\ \mathbf{elif}\;V \cdot \ell \leq 0:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \left({\left(V \cdot \ell\right)}^{-0.5} \cdot \sqrt{A}\right)\\ \end{array} \]
Alternative 4
Error6.3
Cost14156
\[\begin{array}{l} t_0 := c0 \cdot \frac{\sqrt{\frac{-A}{\ell}}}{\sqrt{-V}}\\ \mathbf{if}\;V \cdot \ell \leq -\infty:\\ \;\;\;\;t_0\\ \mathbf{elif}\;V \cdot \ell \leq -1 \cdot 10^{-303}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{-A}}{\sqrt{V \cdot \left(-\ell\right)}}\\ \mathbf{elif}\;V \cdot \ell \leq 0:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \left({\left(V \cdot \ell\right)}^{-0.5} \cdot \sqrt{A}\right)\\ \end{array} \]
Alternative 5
Error9.8
Cost14092
\[\begin{array}{l} t_0 := \sqrt{\frac{A}{V}} \cdot \left(c0 \cdot {\ell}^{-0.5}\right)\\ \mathbf{if}\;V \cdot \ell \leq -5 \cdot 10^{+151}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;V \cdot \ell \leq -1 \cdot 10^{-158}:\\ \;\;\;\;c0 \cdot {\left(\frac{V \cdot \ell}{A}\right)}^{-0.5}\\ \mathbf{elif}\;V \cdot \ell \leq 0:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{A}}{\sqrt{V \cdot \ell}}\\ \end{array} \]
Alternative 6
Error9.8
Cost14092
\[\begin{array}{l} t_0 := \sqrt{\frac{A}{V}} \cdot \left(c0 \cdot {\ell}^{-0.5}\right)\\ \mathbf{if}\;V \cdot \ell \leq -5 \cdot 10^{+151}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;V \cdot \ell \leq -1 \cdot 10^{-158}:\\ \;\;\;\;c0 \cdot {\left(\frac{V \cdot \ell}{A}\right)}^{-0.5}\\ \mathbf{elif}\;V \cdot \ell \leq 0:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \left({\left(V \cdot \ell\right)}^{-0.5} \cdot \sqrt{A}\right)\\ \end{array} \]
Alternative 7
Error12.1
Cost14028
\[\begin{array}{l} \mathbf{if}\;V \cdot \ell \leq -\infty:\\ \;\;\;\;\frac{c0}{\sqrt{\frac{V}{\frac{A}{\ell}}}}\\ \mathbf{elif}\;V \cdot \ell \leq -1 \cdot 10^{-118}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}\\ \mathbf{elif}\;V \cdot \ell \leq 0:\\ \;\;\;\;c0 \cdot {\left(V \cdot \frac{\ell}{A}\right)}^{-0.5}\\ \mathbf{else}:\\ \;\;\;\;\frac{c0}{\frac{\sqrt{V \cdot \ell}}{\sqrt{A}}}\\ \end{array} \]
Alternative 8
Error12.1
Cost14028
\[\begin{array}{l} \mathbf{if}\;V \cdot \ell \leq -\infty:\\ \;\;\;\;\frac{c0}{\sqrt{\frac{V}{\frac{A}{\ell}}}}\\ \mathbf{elif}\;V \cdot \ell \leq -1 \cdot 10^{-118}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}\\ \mathbf{elif}\;V \cdot \ell \leq 0:\\ \;\;\;\;c0 \cdot {\left(V \cdot \frac{\ell}{A}\right)}^{-0.5}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{A}}{\sqrt{V \cdot \ell}}\\ \end{array} \]
Alternative 9
Error9.9
Cost14028
\[\begin{array}{l} t_0 := \frac{c0 \cdot \sqrt{\frac{A}{V}}}{\sqrt{\ell}}\\ \mathbf{if}\;V \cdot \ell \leq -5 \cdot 10^{+223}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;V \cdot \ell \leq -2 \cdot 10^{-176}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}\\ \mathbf{elif}\;V \cdot \ell \leq 0:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{A}}{\sqrt{V \cdot \ell}}\\ \end{array} \]
Alternative 10
Error9.4
Cost14028
\[\begin{array}{l} t_0 := c0 \cdot \frac{\sqrt{\frac{A}{V}}}{\sqrt{\ell}}\\ \mathbf{if}\;V \cdot \ell \leq -5 \cdot 10^{+151}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;V \cdot \ell \leq -1 \cdot 10^{-158}:\\ \;\;\;\;c0 \cdot {\left(\frac{V \cdot \ell}{A}\right)}^{-0.5}\\ \mathbf{elif}\;V \cdot \ell \leq 0:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{A}}{\sqrt{V \cdot \ell}}\\ \end{array} \]
Alternative 11
Error14.6
Cost7624
\[\begin{array}{l} t_0 := \frac{A}{V \cdot \ell}\\ t_1 := \frac{c0}{\sqrt{\frac{V}{\frac{A}{\ell}}}}\\ \mathbf{if}\;t_0 \leq 0:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_0 \leq 5 \cdot 10^{+299}:\\ \;\;\;\;c0 \cdot \sqrt{t_0}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 12
Error19.3
Cost6848
\[\frac{c0}{\sqrt{\frac{V}{\frac{A}{\ell}}}} \]
Alternative 13
Error19.3
Cost6848
\[\frac{c0}{\sqrt{\frac{V \cdot \ell}{A}}} \]

Error

Reproduce

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