Average Error: 19.6 → 7.1
Time: 11.5s
Precision: binary64
Cost: 14156
\[ \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{\frac{c0}{\sqrt{\frac{V}{A}}}}{\sqrt{\ell}}\\ \mathbf{elif}\;V \cdot \ell \leq -2 \cdot 10^{-294}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{-A}}{\sqrt{V \cdot \left(-\ell\right)}}\\ \mathbf{elif}\;V \cdot \ell \leq 2 \cdot 10^{-306}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{\frac{-A}{\ell}}}{\sqrt{-V}}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{A}}{\sqrt{V \cdot \ell}}\\ \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 (/ V A))) (sqrt l))
   (if (<= (* V l) -2e-294)
     (* c0 (/ (sqrt (- A)) (sqrt (* V (- l)))))
     (if (<= (* V l) 2e-306)
       (* c0 (/ (sqrt (/ (- A) l)) (sqrt (- V))))
       (* c0 (/ (sqrt A) (sqrt (* V l))))))))
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((V / A))) / sqrt(l);
	} else if ((V * l) <= -2e-294) {
		tmp = c0 * (sqrt(-A) / sqrt((V * -l)));
	} else if ((V * l) <= 2e-306) {
		tmp = c0 * (sqrt((-A / l)) / sqrt(-V));
	} else {
		tmp = c0 * (sqrt(A) / sqrt((V * l)));
	}
	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((V / A))) / Math.sqrt(l);
	} else if ((V * l) <= -2e-294) {
		tmp = c0 * (Math.sqrt(-A) / Math.sqrt((V * -l)));
	} else if ((V * l) <= 2e-306) {
		tmp = c0 * (Math.sqrt((-A / l)) / Math.sqrt(-V));
	} else {
		tmp = c0 * (Math.sqrt(A) / Math.sqrt((V * l)));
	}
	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((V / A))) / math.sqrt(l)
	elif (V * l) <= -2e-294:
		tmp = c0 * (math.sqrt(-A) / math.sqrt((V * -l)))
	elif (V * l) <= 2e-306:
		tmp = c0 * (math.sqrt((-A / l)) / math.sqrt(-V))
	else:
		tmp = c0 * (math.sqrt(A) / math.sqrt((V * l)))
	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(Float64(c0 / sqrt(Float64(V / A))) / sqrt(l));
	elseif (Float64(V * l) <= -2e-294)
		tmp = Float64(c0 * Float64(sqrt(Float64(-A)) / sqrt(Float64(V * Float64(-l)))));
	elseif (Float64(V * l) <= 2e-306)
		tmp = Float64(c0 * Float64(sqrt(Float64(Float64(-A) / l)) / sqrt(Float64(-V))));
	else
		tmp = Float64(c0 * Float64(sqrt(A) / sqrt(Float64(V * l))));
	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((V / A))) / sqrt(l);
	elseif ((V * l) <= -2e-294)
		tmp = c0 * (sqrt(-A) / sqrt((V * -l)));
	elseif ((V * l) <= 2e-306)
		tmp = c0 * (sqrt((-A / l)) / sqrt(-V));
	else
		tmp = c0 * (sqrt(A) / sqrt((V * l)));
	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[(N[(c0 / N[Sqrt[N[(V / A), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(V * l), $MachinePrecision], -2e-294], N[(c0 * N[(N[Sqrt[(-A)], $MachinePrecision] / N[Sqrt[N[(V * (-l)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(V * l), $MachinePrecision], 2e-306], N[(c0 * N[(N[Sqrt[N[((-A) / l), $MachinePrecision]], $MachinePrecision] / N[Sqrt[(-V)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 * N[(N[Sqrt[A], $MachinePrecision] / N[Sqrt[N[(V * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}
\begin{array}{l}
\mathbf{if}\;V \cdot \ell \leq -\infty:\\
\;\;\;\;\frac{\frac{c0}{\sqrt{\frac{V}{A}}}}{\sqrt{\ell}}\\

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

\mathbf{elif}\;V \cdot \ell \leq 2 \cdot 10^{-306}:\\
\;\;\;\;c0 \cdot \frac{\sqrt{\frac{-A}{\ell}}}{\sqrt{-V}}\\

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


\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 42.5

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

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

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

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

    if -inf.0 < (*.f64 V l) < -2.00000000000000003e-294

    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.00000000000000003e-294 < (*.f64 V l) < 2.00000000000000006e-306

    1. Initial program 59.0

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

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

      \[\leadsto \color{blue}{\sqrt{\left(c0 \cdot c0\right) \cdot \frac{A}{\ell \cdot V}}} \]
    4. Taylor expanded in c0 around 0 59.0

      \[\leadsto \color{blue}{\sqrt{\frac{A}{V \cdot \ell}} \cdot c0} \]
    5. Simplified37.7

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

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

    if 2.00000000000000006e-306 < (*.f64 V l)

    1. Initial program 15.2

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

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

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

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

Alternatives

Alternative 1
Error15.5
Cost34512
\[\begin{array}{l} t_0 := c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}\\ \mathbf{if}\;t_0 \leq -\infty:\\ \;\;\;\;c0 \cdot \frac{\sqrt{\frac{A}{\ell}}}{\sqrt{V}}\\ \mathbf{elif}\;t_0 \leq -2 \cdot 10^{-143}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;t_0 \leq 0:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{V}}{\ell}}\\ \mathbf{elif}\;t_0 \leq 10^{+276}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{c0}{\sqrt{V \cdot \frac{\ell}{A}}}\\ \end{array} \]
Alternative 2
Error6.5
Cost20036
\[\begin{array}{l} t_0 := \sqrt{-V}\\ \mathbf{if}\;V \cdot \ell \leq -2 \cdot 10^{-288}:\\ \;\;\;\;c0 \cdot \frac{\frac{\sqrt{-A}}{t_0}}{\sqrt{\ell}}\\ \mathbf{elif}\;V \cdot \ell \leq 2 \cdot 10^{-306}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{\frac{-A}{\ell}}}{t_0}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{A}}{\sqrt{V \cdot \ell}}\\ \end{array} \]
Alternative 3
Error9.8
Cost14156
\[\begin{array}{l} t_0 := c0 \cdot \frac{\sqrt{\frac{-A}{\ell}}}{\sqrt{-V}}\\ \mathbf{if}\;V \cdot \ell \leq -1.1 \cdot 10^{+171}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;V \cdot \ell \leq -4 \cdot 10^{-177}:\\ \;\;\;\;\frac{c0}{\sqrt{\frac{V \cdot \ell}{A}}}\\ \mathbf{elif}\;V \cdot \ell \leq 2 \cdot 10^{-306}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{A}}{\sqrt{V \cdot \ell}}\\ \end{array} \]
Alternative 4
Error7.1
Cost14156
\[\begin{array}{l} \mathbf{if}\;V \cdot \ell \leq -\infty:\\ \;\;\;\;\frac{\frac{c0}{\sqrt{\frac{V}{A}}}}{\sqrt{\ell}}\\ \mathbf{elif}\;V \cdot \ell \leq -2 \cdot 10^{-294}:\\ \;\;\;\;\frac{c0}{\frac{\sqrt{V \cdot \left(-\ell\right)}}{\sqrt{-A}}}\\ \mathbf{elif}\;V \cdot \ell \leq 2 \cdot 10^{-306}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{\frac{-A}{\ell}}}{\sqrt{-V}}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{A}}{\sqrt{V \cdot \ell}}\\ \end{array} \]
Alternative 5
Error12.1
Cost14028
\[\begin{array}{l} \mathbf{if}\;V \cdot \ell \leq -1 \cdot 10^{+214}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{1}{V} \cdot \frac{A}{\ell}}\\ \mathbf{elif}\;V \cdot \ell \leq -1 \cdot 10^{-222}:\\ \;\;\;\;\frac{c0}{\sqrt{\frac{V \cdot \ell}{A}}}\\ \mathbf{elif}\;V \cdot \ell \leq 10^{-319}:\\ \;\;\;\;c0 \cdot {\left(\ell \cdot \frac{V}{A}\right)}^{-0.5}\\ \mathbf{else}:\\ \;\;\;\;\frac{c0}{\frac{\sqrt{V \cdot \ell}}{\sqrt{A}}}\\ \end{array} \]
Alternative 6
Error10.0
Cost14028
\[\begin{array}{l} t_0 := \frac{\frac{c0}{\sqrt{\frac{V}{A}}}}{\sqrt{\ell}}\\ \mathbf{if}\;V \cdot \ell \leq -1 \cdot 10^{+294}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;V \cdot \ell \leq -1 \cdot 10^{-162}:\\ \;\;\;\;\frac{c0}{\sqrt{\frac{V \cdot \ell}{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
Error10.0
Cost14028
\[\begin{array}{l} t_0 := \sqrt{\frac{V}{A}}\\ \mathbf{if}\;V \cdot \ell \leq -1 \cdot 10^{+294}:\\ \;\;\;\;\frac{\frac{c0}{t_0}}{\sqrt{\ell}}\\ \mathbf{elif}\;V \cdot \ell \leq -1 \cdot 10^{-162}:\\ \;\;\;\;\frac{c0}{\sqrt{\frac{V \cdot \ell}{A}}}\\ \mathbf{elif}\;V \cdot \ell \leq 0:\\ \;\;\;\;\frac{\frac{c0}{\sqrt{\ell}}}{t_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{c0}{\frac{\sqrt{V \cdot \ell}}{\sqrt{A}}}\\ \end{array} \]
Alternative 8
Error10.0
Cost14028
\[\begin{array}{l} t_0 := \sqrt{\frac{V}{A}}\\ \mathbf{if}\;V \cdot \ell \leq -1 \cdot 10^{+294}:\\ \;\;\;\;\frac{\frac{c0}{t_0}}{\sqrt{\ell}}\\ \mathbf{elif}\;V \cdot \ell \leq -1 \cdot 10^{-162}:\\ \;\;\;\;\frac{c0}{\sqrt{\frac{V \cdot \ell}{A}}}\\ \mathbf{elif}\;V \cdot \ell \leq 0:\\ \;\;\;\;\frac{\frac{c0}{\sqrt{\ell}}}{t_0}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{A}}{\sqrt{V \cdot \ell}}\\ \end{array} \]
Alternative 9
Error14.7
Cost7688
\[\begin{array}{l} t_0 := \frac{A}{V \cdot \ell}\\ \mathbf{if}\;t_0 \leq 0:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{V}}{\ell}}\\ \mathbf{elif}\;t_0 \leq 5 \cdot 10^{+300}:\\ \;\;\;\;c0 \cdot \sqrt{t_0}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot {\left(\ell \cdot \frac{V}{A}\right)}^{-0.5}\\ \end{array} \]
Alternative 10
Error16.2
Cost7628
\[\begin{array}{l} t_0 := \frac{c0}{\sqrt{\frac{V \cdot \ell}{A}}}\\ \mathbf{if}\;V \cdot \ell \leq -1 \cdot 10^{+307}:\\ \;\;\;\;\frac{c0}{\sqrt{\frac{\ell}{\frac{A}{V}}}}\\ \mathbf{elif}\;V \cdot \ell \leq -1 \cdot 10^{-222}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;V \cdot \ell \leq 10^{-205}:\\ \;\;\;\;\frac{c0}{\sqrt{\ell \cdot \frac{V}{A}}}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 11
Error16.4
Cost7628
\[\begin{array}{l} t_0 := \frac{c0}{\sqrt{\frac{V \cdot \ell}{A}}}\\ t_1 := c0 \cdot \sqrt{\frac{\frac{A}{\ell}}{V}}\\ \mathbf{if}\;V \cdot \ell \leq -1 \cdot 10^{+214}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;V \cdot \ell \leq -4 \cdot 10^{-177}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;V \cdot \ell \leq 5 \cdot 10^{-250}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 12
Error14.7
Cost7624
\[\begin{array}{l} t_0 := \frac{A}{V \cdot \ell}\\ \mathbf{if}\;t_0 \leq 0:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{V}}{\ell}}\\ \mathbf{elif}\;t_0 \leq 5 \cdot 10^{+300}:\\ \;\;\;\;c0 \cdot \sqrt{t_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{c0}{\sqrt{\ell \cdot \frac{V}{A}}}\\ \end{array} \]
Alternative 13
Error19.7
Cost6848
\[\frac{c0}{\sqrt{\frac{\ell}{\frac{A}{V}}}} \]
Alternative 14
Error19.8
Cost6848
\[\frac{c0}{\sqrt{\ell \cdot \frac{V}{A}}} \]

Error

Reproduce

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