Average Error: 19.0 → 6.4
Time: 18.6s
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} \mathbf{if}\;V \cdot \ell \leq 0:\\ \;\;\;\;\frac{\frac{\sqrt{-A}}{\sqrt{-V}} \cdot c0}{\sqrt{\ell}}\\ \mathbf{elif}\;V \cdot \ell \leq 10^{+297}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{A}}{\sqrt{V \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{\ell}}{V}}\\ \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)
   (/ (* (/ (sqrt (- A)) (sqrt (- V))) c0) (sqrt l))
   (if (<= (* V l) 1e+297)
     (* c0 (/ (sqrt A) (sqrt (* V l))))
     (* c0 (sqrt (/ (/ A l) V))))))
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 = ((sqrt(-A) / sqrt(-V)) * c0) / sqrt(l);
	} else if ((V * l) <= 1e+297) {
		tmp = c0 * (sqrt(A) / sqrt((V * l)));
	} else {
		tmp = c0 * sqrt(((A / l) / V));
	}
	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 = ((sqrt(-a) / sqrt(-v)) * c0) / sqrt(l)
    else if ((v * l) <= 1d+297) then
        tmp = c0 * (sqrt(a) / sqrt((v * l)))
    else
        tmp = c0 * sqrt(((a / l) / v))
    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 = ((Math.sqrt(-A) / Math.sqrt(-V)) * c0) / Math.sqrt(l);
	} else if ((V * l) <= 1e+297) {
		tmp = c0 * (Math.sqrt(A) / Math.sqrt((V * l)));
	} else {
		tmp = c0 * Math.sqrt(((A / l) / V));
	}
	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 = ((math.sqrt(-A) / math.sqrt(-V)) * c0) / math.sqrt(l)
	elif (V * l) <= 1e+297:
		tmp = c0 * (math.sqrt(A) / math.sqrt((V * l)))
	else:
		tmp = c0 * math.sqrt(((A / l) / V))
	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(Float64(Float64(sqrt(Float64(-A)) / sqrt(Float64(-V))) * c0) / sqrt(l));
	elseif (Float64(V * l) <= 1e+297)
		tmp = Float64(c0 * Float64(sqrt(A) / sqrt(Float64(V * l))));
	else
		tmp = Float64(c0 * sqrt(Float64(Float64(A / l) / V)));
	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 = ((sqrt(-A) / sqrt(-V)) * c0) / sqrt(l);
	elseif ((V * l) <= 1e+297)
		tmp = c0 * (sqrt(A) / sqrt((V * l)));
	else
		tmp = c0 * sqrt(((A / l) / V));
	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[(N[(N[(N[Sqrt[(-A)], $MachinePrecision] / N[Sqrt[(-V)], $MachinePrecision]), $MachinePrecision] * c0), $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(V * l), $MachinePrecision], 1e+297], N[(c0 * N[(N[Sqrt[A], $MachinePrecision] / N[Sqrt[N[(V * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 * N[Sqrt[N[(N[(A / l), $MachinePrecision] / V), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}
\begin{array}{l}
\mathbf{if}\;V \cdot \ell \leq 0:\\
\;\;\;\;\frac{\frac{\sqrt{-A}}{\sqrt{-V}} \cdot c0}{\sqrt{\ell}}\\

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

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


\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-rr20.6

      \[\leadsto c0 \cdot \color{blue}{\frac{1}{\sqrt{\frac{\ell}{\frac{A}{V}}}}} \]
    3. Taylor expanded in c0 around 0 22.5

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

      \[\leadsto \color{blue}{\sqrt{\frac{\frac{A}{V}}{\ell}} \cdot c0} \]
      Proof
      (*.f64 (sqrt.f64 (/.f64 (/.f64 A V) l)) c0): 0 points increase in error, 0 points decrease in error
      (*.f64 (sqrt.f64 (Rewrite<= associate-/r*_binary64 (/.f64 A (*.f64 V l)))) c0): 24 points increase in error, 26 points decrease in error
    5. Applied egg-rr15.9

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

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

    if -0.0 < (*.f64 V l) < 1e297

    1. Initial program 10.2

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

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

    if 1e297 < (*.f64 V l)

    1. Initial program 40.7

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;V \cdot \ell \leq 0:\\ \;\;\;\;\frac{\frac{\sqrt{-A}}{\sqrt{-V}} \cdot c0}{\sqrt{\ell}}\\ \mathbf{elif}\;V \cdot \ell \leq 10^{+297}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{A}}{\sqrt{V \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{\ell}}{V}}\\ \end{array} \]

Alternatives

Alternative 1
Error9.3
Cost14288
\[\begin{array}{l} t_0 := \sqrt{\frac{A}{V}}\\ \mathbf{if}\;V \cdot \ell \leq -5 \cdot 10^{+194}:\\ \;\;\;\;c0 \cdot \frac{t_0}{\sqrt{\ell}}\\ \mathbf{elif}\;V \cdot \ell \leq -1 \cdot 10^{-127}:\\ \;\;\;\;c0 \cdot {\left(\frac{V \cdot \ell}{A}\right)}^{-0.5}\\ \mathbf{elif}\;V \cdot \ell \leq 2 \cdot 10^{-322}:\\ \;\;\;\;\frac{c0 \cdot t_0}{\sqrt{\ell}}\\ \mathbf{elif}\;V \cdot \ell \leq 10^{+297}:\\ \;\;\;\;\frac{c0 \cdot \sqrt{A}}{\sqrt{V \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{\ell}}{V}}\\ \end{array} \]
Alternative 2
Error8.4
Cost14288
\[\begin{array}{l} t_0 := \sqrt{\frac{A}{V}}\\ \mathbf{if}\;V \cdot \ell \leq -5 \cdot 10^{+194}:\\ \;\;\;\;c0 \cdot \frac{t_0}{\sqrt{\ell}}\\ \mathbf{elif}\;V \cdot \ell \leq -1 \cdot 10^{-127}:\\ \;\;\;\;c0 \cdot {\left(\frac{V \cdot \ell}{A}\right)}^{-0.5}\\ \mathbf{elif}\;V \cdot \ell \leq 2 \cdot 10^{-322}:\\ \;\;\;\;\frac{c0 \cdot t_0}{\sqrt{\ell}}\\ \mathbf{elif}\;V \cdot \ell \leq 10^{+297}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{A}}{\sqrt{V \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{\ell}}{V}}\\ \end{array} \]
Alternative 3
Error8.5
Cost14288
\[\begin{array}{l} t_0 := \sqrt{\frac{A}{V}}\\ \mathbf{if}\;V \cdot \ell \leq -5 \cdot 10^{+194}:\\ \;\;\;\;c0 \cdot \frac{t_0}{\sqrt{\ell}}\\ \mathbf{elif}\;V \cdot \ell \leq -1 \cdot 10^{-127}:\\ \;\;\;\;c0 \cdot {\left(\frac{V \cdot \ell}{A}\right)}^{-0.5}\\ \mathbf{elif}\;V \cdot \ell \leq 2 \cdot 10^{-322}:\\ \;\;\;\;t_0 \cdot \left(c0 \cdot {\ell}^{-0.5}\right)\\ \mathbf{elif}\;V \cdot \ell \leq 10^{+297}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{A}}{\sqrt{V \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{\ell}}{V}}\\ \end{array} \]
Alternative 4
Error8.2
Cost14288
\[\begin{array}{l} t_0 := \sqrt{\frac{A}{V}}\\ \mathbf{if}\;V \cdot \ell \leq -5 \cdot 10^{+194}:\\ \;\;\;\;c0 \cdot \frac{t_0}{\sqrt{\ell}}\\ \mathbf{elif}\;V \cdot \ell \leq -4 \cdot 10^{-112}:\\ \;\;\;\;c0 \cdot {\left(\frac{V \cdot \ell}{A}\right)}^{-0.5}\\ \mathbf{elif}\;V \cdot \ell \leq 2 \cdot 10^{-322}:\\ \;\;\;\;c0 \cdot \left({\ell}^{-0.5} \cdot t_0\right)\\ \mathbf{elif}\;V \cdot \ell \leq 10^{+297}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{A}}{\sqrt{V \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{\ell}}{V}}\\ \end{array} \]
Alternative 5
Error8.3
Cost14288
\[\begin{array}{l} \mathbf{if}\;V \cdot \ell \leq -2 \cdot 10^{+217}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{\frac{-A}{\ell}}}{\sqrt{-V}}\\ \mathbf{elif}\;V \cdot \ell \leq -4 \cdot 10^{-112}:\\ \;\;\;\;c0 \cdot {\left(\frac{V \cdot \ell}{A}\right)}^{-0.5}\\ \mathbf{elif}\;V \cdot \ell \leq 2 \cdot 10^{-322}:\\ \;\;\;\;c0 \cdot \left({\ell}^{-0.5} \cdot \sqrt{\frac{A}{V}}\right)\\ \mathbf{elif}\;V \cdot \ell \leq 10^{+297}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{A}}{\sqrt{V \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{\ell}}{V}}\\ \end{array} \]
Alternative 6
Error6.1
Cost14288
\[\begin{array}{l} \mathbf{if}\;V \cdot \ell \leq -2 \cdot 10^{+217}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{\frac{-A}{\ell}}}{\sqrt{-V}}\\ \mathbf{elif}\;V \cdot \ell \leq -4 \cdot 10^{-312}:\\ \;\;\;\;\frac{c0}{\frac{\sqrt{\ell \cdot \left(-V\right)}}{\sqrt{-A}}}\\ \mathbf{elif}\;V \cdot \ell \leq 0:\\ \;\;\;\;\frac{1}{\frac{\sqrt{V \cdot \frac{\ell}{A}}}{c0}}\\ \mathbf{elif}\;V \cdot \ell \leq 10^{+297}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{A}}{\sqrt{V \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{\ell}}{V}}\\ \end{array} \]
Alternative 7
Error6.1
Cost14288
\[\begin{array}{l} \mathbf{if}\;V \cdot \ell \leq -1 \cdot 10^{+225}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{\frac{-A}{\ell}}}{\sqrt{-V}}\\ \mathbf{elif}\;V \cdot \ell \leq -4 \cdot 10^{-312}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{-A}}{\sqrt{\ell \cdot \left(-V\right)}}\\ \mathbf{elif}\;V \cdot \ell \leq 0:\\ \;\;\;\;\frac{1}{\frac{\sqrt{V \cdot \frac{\ell}{A}}}{c0}}\\ \mathbf{elif}\;V \cdot \ell \leq 10^{+297}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{A}}{\sqrt{V \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{\ell}}{V}}\\ \end{array} \]
Alternative 8
Error11.6
Cost14024
\[\begin{array}{l} t_0 := \frac{A}{V \cdot \ell}\\ t_1 := \frac{\frac{c0}{\sqrt{\frac{V}{A}}}}{\sqrt{\ell}}\\ \mathbf{if}\;t_0 \leq 10^{-311}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_0 \leq 10^{+297}:\\ \;\;\;\;c0 \cdot \sqrt{t_0}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Error11.5
Cost14024
\[\begin{array}{l} t_0 := \frac{A}{V \cdot \ell}\\ \mathbf{if}\;t_0 \leq 10^{-311}:\\ \;\;\;\;\frac{c0 \cdot \sqrt{\frac{A}{V}}}{\sqrt{\ell}}\\ \mathbf{elif}\;t_0 \leq 10^{+297}:\\ \;\;\;\;c0 \cdot \sqrt{t_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{c0}{\sqrt{\frac{V}{A}}}}{\sqrt{\ell}}\\ \end{array} \]
Alternative 10
Error11.4
Cost14024
\[\begin{array}{l} t_0 := \frac{A}{V \cdot \ell}\\ \mathbf{if}\;t_0 \leq 10^{-311}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{\frac{A}{V}}}{\sqrt{\ell}}\\ \mathbf{elif}\;t_0 \leq 10^{+297}:\\ \;\;\;\;c0 \cdot \sqrt{t_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{c0}{\sqrt{\frac{V}{A}}}}{\sqrt{\ell}}\\ \end{array} \]
Alternative 11
Error14.7
Cost7952
\[\begin{array}{l} t_0 := c0 \cdot {\left(\frac{V \cdot \ell}{A}\right)}^{-0.5}\\ t_1 := \frac{\frac{A}{\ell}}{V}\\ \mathbf{if}\;V \cdot \ell \leq -1.65 \cdot 10^{+300}:\\ \;\;\;\;\frac{c0}{{t_1}^{-0.5}}\\ \mathbf{elif}\;V \cdot \ell \leq -5 \cdot 10^{-132}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;V \cdot \ell \leq 0:\\ \;\;\;\;\frac{c0}{\sqrt{\ell \cdot \frac{V}{A}}}\\ \mathbf{elif}\;V \cdot \ell \leq 5 \cdot 10^{+139}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \sqrt{t_1}\\ \end{array} \]
Alternative 12
Error15.1
Cost7888
\[\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 -2 \cdot 10^{+225}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;V \cdot \ell \leq -5 \cdot 10^{-132}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;V \cdot \ell \leq 10^{-191}:\\ \;\;\;\;\frac{c0}{\sqrt{\ell \cdot \frac{V}{A}}}\\ \mathbf{elif}\;V \cdot \ell \leq 2 \cdot 10^{+55}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 13
Error18.9
Cost6980
\[\begin{array}{l} \mathbf{if}\;c0 \leq 2.0968615991431445 \cdot 10^{-140}:\\ \;\;\;\;\frac{c0}{\sqrt{\ell \cdot \frac{V}{A}}}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{\ell}}{V}}\\ \end{array} \]
Alternative 14
Error19.1
Cost6848
\[\frac{c0}{\sqrt{\ell \cdot \frac{V}{A}}} \]

Error

Reproduce

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