Average Error: 19.3 → 5.8
Time: 15.4s
Precision: binary64
Cost: 20164
\[ \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}\\ \mathbf{if}\;V \cdot \ell \leq -5 \cdot 10^{-324}:\\ \;\;\;\;c0 \cdot \frac{1}{\sqrt{\ell} \cdot \frac{t_0}{\sqrt{-A}}}\\ \mathbf{elif}\;V \cdot \ell \leq 5 \cdot 10^{-320}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{\frac{-A}{\ell}}}{t_0}\\ \mathbf{elif}\;V \cdot \ell \leq 2 \cdot 10^{+252}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{A}}{\sqrt{V \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{V}}{\ell}}\\ \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))))
   (if (<= (* V l) -5e-324)
     (* c0 (/ 1.0 (* (sqrt l) (/ t_0 (sqrt (- A))))))
     (if (<= (* V l) 5e-320)
       (* c0 (/ (sqrt (/ (- A) l)) t_0))
       (if (<= (* V l) 2e+252)
         (* c0 (/ (sqrt A) (sqrt (* V l))))
         (* c0 (sqrt (/ (/ A 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 t_0 = sqrt(-V);
	double tmp;
	if ((V * l) <= -5e-324) {
		tmp = c0 * (1.0 / (sqrt(l) * (t_0 / sqrt(-A))));
	} else if ((V * l) <= 5e-320) {
		tmp = c0 * (sqrt((-A / l)) / t_0);
	} else if ((V * l) <= 2e+252) {
		tmp = c0 * (sqrt(A) / sqrt((V * l)));
	} else {
		tmp = c0 * sqrt(((A / V) / l));
	}
	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) :: tmp
    t_0 = sqrt(-v)
    if ((v * l) <= (-5d-324)) then
        tmp = c0 * (1.0d0 / (sqrt(l) * (t_0 / sqrt(-a))))
    else if ((v * l) <= 5d-320) then
        tmp = c0 * (sqrt((-a / l)) / t_0)
    else if ((v * l) <= 2d+252) then
        tmp = c0 * (sqrt(a) / sqrt((v * l)))
    else
        tmp = c0 * sqrt(((a / v) / l))
    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 tmp;
	if ((V * l) <= -5e-324) {
		tmp = c0 * (1.0 / (Math.sqrt(l) * (t_0 / Math.sqrt(-A))));
	} else if ((V * l) <= 5e-320) {
		tmp = c0 * (Math.sqrt((-A / l)) / t_0);
	} else if ((V * l) <= 2e+252) {
		tmp = c0 * (Math.sqrt(A) / Math.sqrt((V * l)));
	} else {
		tmp = c0 * Math.sqrt(((A / V) / l));
	}
	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)
	tmp = 0
	if (V * l) <= -5e-324:
		tmp = c0 * (1.0 / (math.sqrt(l) * (t_0 / math.sqrt(-A))))
	elif (V * l) <= 5e-320:
		tmp = c0 * (math.sqrt((-A / l)) / t_0)
	elif (V * l) <= 2e+252:
		tmp = c0 * (math.sqrt(A) / math.sqrt((V * l)))
	else:
		tmp = c0 * math.sqrt(((A / 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)
	t_0 = sqrt(Float64(-V))
	tmp = 0.0
	if (Float64(V * l) <= -5e-324)
		tmp = Float64(c0 * Float64(1.0 / Float64(sqrt(l) * Float64(t_0 / sqrt(Float64(-A))))));
	elseif (Float64(V * l) <= 5e-320)
		tmp = Float64(c0 * Float64(sqrt(Float64(Float64(-A) / l)) / t_0));
	elseif (Float64(V * l) <= 2e+252)
		tmp = Float64(c0 * Float64(sqrt(A) / sqrt(Float64(V * l))));
	else
		tmp = Float64(c0 * sqrt(Float64(Float64(A / 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)
	t_0 = sqrt(-V);
	tmp = 0.0;
	if ((V * l) <= -5e-324)
		tmp = c0 * (1.0 / (sqrt(l) * (t_0 / sqrt(-A))));
	elseif ((V * l) <= 5e-320)
		tmp = c0 * (sqrt((-A / l)) / t_0);
	elseif ((V * l) <= 2e+252)
		tmp = c0 * (sqrt(A) / sqrt((V * l)));
	else
		tmp = c0 * sqrt(((A / 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_] := Block[{t$95$0 = N[Sqrt[(-V)], $MachinePrecision]}, If[LessEqual[N[(V * l), $MachinePrecision], -5e-324], N[(c0 * N[(1.0 / N[(N[Sqrt[l], $MachinePrecision] * N[(t$95$0 / N[Sqrt[(-A)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(V * l), $MachinePrecision], 5e-320], N[(c0 * N[(N[Sqrt[N[((-A) / l), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(V * l), $MachinePrecision], 2e+252], N[(c0 * N[(N[Sqrt[A], $MachinePrecision] / N[Sqrt[N[(V * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 * N[Sqrt[N[(N[(A / V), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}
\begin{array}{l}
t_0 := \sqrt{-V}\\
\mathbf{if}\;V \cdot \ell \leq -5 \cdot 10^{-324}:\\
\;\;\;\;c0 \cdot \frac{1}{\sqrt{\ell} \cdot \frac{t_0}{\sqrt{-A}}}\\

\mathbf{elif}\;V \cdot \ell \leq 5 \cdot 10^{-320}:\\
\;\;\;\;c0 \cdot \frac{\sqrt{\frac{-A}{\ell}}}{t_0}\\

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

\mathbf{else}:\\
\;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{V}}{\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) < -4.94066e-324

    1. Initial program 14.6

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

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

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

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

    if -4.94066e-324 < (*.f64 V l) < 4.99994e-320

    1. Initial program 63.8

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

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

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

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

    if 4.99994e-320 < (*.f64 V l) < 2.0000000000000002e252

    1. Initial program 9.9

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

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

    if 2.0000000000000002e252 < (*.f64 V l)

    1. Initial program 34.7

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

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

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

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

      \[\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): 28 points increase in error, 26 points decrease in error
  3. Recombined 4 regimes into one program.
  4. Final simplification5.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;V \cdot \ell \leq -5 \cdot 10^{-324}:\\ \;\;\;\;c0 \cdot \frac{1}{\sqrt{\ell} \cdot \frac{\sqrt{-V}}{\sqrt{-A}}}\\ \mathbf{elif}\;V \cdot \ell \leq 5 \cdot 10^{-320}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{\frac{-A}{\ell}}}{\sqrt{-V}}\\ \mathbf{elif}\;V \cdot \ell \leq 2 \cdot 10^{+252}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{A}}{\sqrt{V \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{V}}{\ell}}\\ \end{array} \]

Alternatives

Alternative 1
Error12.6
Cost34640
\[\begin{array}{l} t_0 := c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}\\ t_1 := \frac{c0}{\sqrt{\frac{V \cdot \ell}{A}}}\\ \mathbf{if}\;t_0 \leq -\infty:\\ \;\;\;\;\frac{\frac{c0}{\sqrt{\frac{V}{A}}}}{\sqrt{\ell}}\\ \mathbf{elif}\;t_0 \leq -2 \cdot 10^{-282}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_0 \leq 0:\\ \;\;\;\;c0 \cdot \frac{\sqrt{\frac{A}{V}}}{\sqrt{\ell}}\\ \mathbf{elif}\;t_0 \leq 5 \cdot 10^{+301}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\frac{c0 \cdot A}{V} \cdot \frac{c0}{\ell}}\\ \end{array} \]
Alternative 2
Error16.3
Cost27724
\[\begin{array}{l} t_0 := V \cdot \frac{\ell}{A}\\ t_1 := c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}\\ \mathbf{if}\;t_1 \leq -5 \cdot 10^{+300}:\\ \;\;\;\;\frac{c0}{\sqrt{t_0}}\\ \mathbf{elif}\;t_1 \leq -1 \cdot 10^{-317}:\\ \;\;\;\;\frac{c0}{\sqrt{\frac{V \cdot \ell}{A}}}\\ \mathbf{elif}\;t_1 \leq 5 \cdot 10^{+301}:\\ \;\;\;\;c0 \cdot {t_0}^{-0.5}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\frac{c0 \cdot A}{V} \cdot \frac{c0}{\ell}}\\ \end{array} \]
Alternative 3
Error8.9
Cost14288
\[\begin{array}{l} \mathbf{if}\;V \cdot \ell \leq -1 \cdot 10^{+112}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{\frac{A}{V}}}{\sqrt{\ell}}\\ \mathbf{elif}\;V \cdot \ell \leq -2 \cdot 10^{-99}:\\ \;\;\;\;\frac{c0}{\sqrt{\frac{V \cdot \ell}{A}}}\\ \mathbf{elif}\;V \cdot \ell \leq 0:\\ \;\;\;\;\frac{\frac{c0}{\sqrt{\frac{V}{A}}}}{\sqrt{\ell}}\\ \mathbf{elif}\;V \cdot \ell \leq 2 \cdot 10^{+252}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{A}}{\sqrt{V \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{V}}{\ell}}\\ \end{array} \]
Alternative 4
Error9.0
Cost14288
\[\begin{array}{l} \mathbf{if}\;V \cdot \ell \leq -1 \cdot 10^{+112}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{\frac{A}{V}}}{\sqrt{\ell}}\\ \mathbf{elif}\;V \cdot \ell \leq -2 \cdot 10^{-99}:\\ \;\;\;\;\frac{c0}{\sqrt{\frac{V \cdot \ell}{A}}}\\ \mathbf{elif}\;V \cdot \ell \leq 0:\\ \;\;\;\;\frac{c0 \cdot {\ell}^{-0.5}}{\sqrt{\frac{V}{A}}}\\ \mathbf{elif}\;V \cdot \ell \leq 2 \cdot 10^{+252}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{A}}{\sqrt{V \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{V}}{\ell}}\\ \end{array} \]
Alternative 5
Error9.1
Cost14288
\[\begin{array}{l} t_0 := c0 \cdot \frac{\sqrt{\frac{-A}{\ell}}}{\sqrt{-V}}\\ \mathbf{if}\;V \cdot \ell \leq -1 \cdot 10^{+36}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;V \cdot \ell \leq -2 \cdot 10^{-99}:\\ \;\;\;\;\frac{c0}{\sqrt{\frac{V \cdot \ell}{A}}}\\ \mathbf{elif}\;V \cdot \ell \leq 5 \cdot 10^{-320}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;V \cdot \ell \leq 2 \cdot 10^{+252}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{A}}{\sqrt{V \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{V}}{\ell}}\\ \end{array} \]
Alternative 6
Error6.3
Cost14288
\[\begin{array}{l} \mathbf{if}\;V \cdot \ell \leq -1 \cdot 10^{+262}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{\frac{A}{V}}}{\sqrt{\ell}}\\ \mathbf{elif}\;V \cdot \ell \leq -5 \cdot 10^{-324}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{-A}}{\sqrt{\ell \cdot \left(-V\right)}}\\ \mathbf{elif}\;V \cdot \ell \leq 5 \cdot 10^{-320}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{\frac{-A}{\ell}}}{\sqrt{-V}}\\ \mathbf{elif}\;V \cdot \ell \leq 2 \cdot 10^{+252}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{A}}{\sqrt{V \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{V}}{\ell}}\\ \end{array} \]
Alternative 7
Error12.5
Cost14028
\[\begin{array}{l} t_0 := \frac{c0}{\sqrt{\frac{V \cdot \ell}{A}}}\\ t_1 := c0 \cdot \frac{\sqrt{\frac{A}{V}}}{\sqrt{\ell}}\\ \mathbf{if}\;V \cdot \ell \leq -1 \cdot 10^{+112}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;V \cdot \ell \leq -2 \cdot 10^{-99}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;V \cdot \ell \leq 10^{-314}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;V \cdot \ell \leq 5 \cdot 10^{+79}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{c0}{\sqrt{\ell \cdot \frac{V}{A}}}\\ \end{array} \]
Alternative 8
Error14.8
Cost7888
\[\begin{array}{l} t_0 := \frac{c0}{\sqrt{\frac{V \cdot \ell}{A}}}\\ t_1 := c0 \cdot \sqrt{\frac{\frac{A}{V}}{\ell}}\\ \mathbf{if}\;V \cdot \ell \leq -2 \cdot 10^{+162}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;V \cdot \ell \leq -1 \cdot 10^{-236}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;V \cdot \ell \leq 2 \cdot 10^{-292}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;V \cdot \ell \leq 5 \cdot 10^{+144}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Error15.3
Cost7888
\[\begin{array}{l} t_0 := \frac{c0}{\sqrt{\frac{V \cdot \ell}{A}}}\\ t_1 := \frac{c0}{\sqrt{\ell \cdot \frac{V}{A}}}\\ \mathbf{if}\;V \cdot \ell \leq -2 \cdot 10^{+169}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;V \cdot \ell \leq -1 \cdot 10^{-236}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;V \cdot \ell \leq 2 \cdot 10^{-292}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{V}}{\ell}}\\ \mathbf{elif}\;V \cdot \ell \leq 5 \cdot 10^{+79}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Error16.0
Cost7888
\[\begin{array}{l} t_0 := \frac{c0}{\sqrt{\frac{V \cdot \ell}{A}}}\\ t_1 := \frac{c0}{\sqrt{\ell \cdot \frac{V}{A}}}\\ \mathbf{if}\;V \cdot \ell \leq -2 \cdot 10^{+169}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;V \cdot \ell \leq -5 \cdot 10^{-48}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;V \cdot \ell \leq 2 \cdot 10^{-292}:\\ \;\;\;\;\frac{c0}{\sqrt{V \cdot \frac{\ell}{A}}}\\ \mathbf{elif}\;V \cdot \ell \leq 5 \cdot 10^{+79}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 11
Error19.3
Cost6848
\[\frac{c0}{\sqrt{\frac{V \cdot \ell}{A}}} \]

Error

Reproduce

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