?

Average Error: 19.1 → 4.6
Time: 13.1s
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 -2 \cdot 10^{-321}:\\ \;\;\;\;\frac{\frac{\sqrt{-A}}{\sqrt{-V}}}{\sqrt{\ell}} \cdot c0\\ \mathbf{elif}\;V \cdot \ell \leq 10^{-315}:\\ \;\;\;\;c0 \cdot \left({\ell}^{-0.5} \cdot \sqrt{\frac{A}{V}}\right)\\ \mathbf{elif}\;V \cdot \ell \leq 2 \cdot 10^{+304}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{A}}{\sqrt{V \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c0}{\sqrt{\ell \cdot \frac{V}{A}}}\\ \end{array} \]
(FPCore (c0 A V l) :precision binary64 (* c0 (sqrt (/ A (* V l)))))
(FPCore (c0 A V l)
 :precision binary64
 (if (<= (* V l) -2e-321)
   (* (/ (/ (sqrt (- A)) (sqrt (- V))) (sqrt l)) c0)
   (if (<= (* V l) 1e-315)
     (* c0 (* (pow l -0.5) (sqrt (/ A V))))
     (if (<= (* V l) 2e+304)
       (* c0 (/ (sqrt A) (sqrt (* V l))))
       (/ c0 (sqrt (* l (/ V 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 tmp;
	if ((V * l) <= -2e-321) {
		tmp = ((sqrt(-A) / sqrt(-V)) / sqrt(l)) * c0;
	} else if ((V * l) <= 1e-315) {
		tmp = c0 * (pow(l, -0.5) * sqrt((A / V)));
	} else if ((V * l) <= 2e+304) {
		tmp = c0 * (sqrt(A) / sqrt((V * l)));
	} else {
		tmp = c0 / sqrt((l * (V / 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) :: tmp
    if ((v * l) <= (-2d-321)) then
        tmp = ((sqrt(-a) / sqrt(-v)) / sqrt(l)) * c0
    else if ((v * l) <= 1d-315) then
        tmp = c0 * ((l ** (-0.5d0)) * sqrt((a / v)))
    else if ((v * l) <= 2d+304) then
        tmp = c0 * (sqrt(a) / sqrt((v * l)))
    else
        tmp = c0 / sqrt((l * (v / 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 tmp;
	if ((V * l) <= -2e-321) {
		tmp = ((Math.sqrt(-A) / Math.sqrt(-V)) / Math.sqrt(l)) * c0;
	} else if ((V * l) <= 1e-315) {
		tmp = c0 * (Math.pow(l, -0.5) * Math.sqrt((A / V)));
	} else if ((V * l) <= 2e+304) {
		tmp = c0 * (Math.sqrt(A) / Math.sqrt((V * l)));
	} else {
		tmp = c0 / Math.sqrt((l * (V / A)));
	}
	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) <= -2e-321:
		tmp = ((math.sqrt(-A) / math.sqrt(-V)) / math.sqrt(l)) * c0
	elif (V * l) <= 1e-315:
		tmp = c0 * (math.pow(l, -0.5) * math.sqrt((A / V)))
	elif (V * l) <= 2e+304:
		tmp = c0 * (math.sqrt(A) / math.sqrt((V * l)))
	else:
		tmp = c0 / math.sqrt((l * (V / 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)
	tmp = 0.0
	if (Float64(V * l) <= -2e-321)
		tmp = Float64(Float64(Float64(sqrt(Float64(-A)) / sqrt(Float64(-V))) / sqrt(l)) * c0);
	elseif (Float64(V * l) <= 1e-315)
		tmp = Float64(c0 * Float64((l ^ -0.5) * sqrt(Float64(A / V))));
	elseif (Float64(V * l) <= 2e+304)
		tmp = Float64(c0 * Float64(sqrt(A) / sqrt(Float64(V * l))));
	else
		tmp = Float64(c0 / sqrt(Float64(l * Float64(V / 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)
	tmp = 0.0;
	if ((V * l) <= -2e-321)
		tmp = ((sqrt(-A) / sqrt(-V)) / sqrt(l)) * c0;
	elseif ((V * l) <= 1e-315)
		tmp = c0 * ((l ^ -0.5) * sqrt((A / V)));
	elseif ((V * l) <= 2e+304)
		tmp = c0 * (sqrt(A) / sqrt((V * l)));
	else
		tmp = c0 / sqrt((l * (V / 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_] := If[LessEqual[N[(V * l), $MachinePrecision], -2e-321], N[(N[(N[(N[Sqrt[(-A)], $MachinePrecision] / N[Sqrt[(-V)], $MachinePrecision]), $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision] * c0), $MachinePrecision], If[LessEqual[N[(V * l), $MachinePrecision], 1e-315], N[(c0 * N[(N[Power[l, -0.5], $MachinePrecision] * N[Sqrt[N[(A / V), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(V * l), $MachinePrecision], 2e+304], N[(c0 * N[(N[Sqrt[A], $MachinePrecision] / N[Sqrt[N[(V * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 / N[Sqrt[N[(l * N[(V / A), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}
\begin{array}{l}
\mathbf{if}\;V \cdot \ell \leq -2 \cdot 10^{-321}:\\
\;\;\;\;\frac{\frac{\sqrt{-A}}{\sqrt{-V}}}{\sqrt{\ell}} \cdot c0\\

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

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

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


\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) < -2.00097e-321

    1. Initial program 15.2

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

      \[\leadsto \color{blue}{\frac{c0 \cdot \sqrt{\frac{A}{V}}}{\sqrt{\ell}}} \]
    3. Simplified10.9

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

      [Start]12.9

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

      *-commutative [=>]12.9

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

      associate-/l* [=>]13.0

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

      associate-/r/ [=>]10.9

      \[ \color{blue}{\frac{\sqrt{\frac{A}{V}}}{\sqrt{\ell}} \cdot c0} \]
    4. Applied egg-rr0.9

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

    if -2.00097e-321 < (*.f64 V l) < 9.999999985e-316

    1. Initial program 63.3

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

      \[\leadsto \color{blue}{\frac{c0 \cdot \sqrt{\frac{A}{V}}}{\sqrt{\ell}}} \]
    3. Simplified27.6

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

      [Start]28.1

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

      *-commutative [=>]28.1

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

      associate-/l* [=>]28.0

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

      associate-/r/ [=>]27.6

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

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

    if 9.999999985e-316 < (*.f64 V l) < 1.9999999999999999e304

    1. Initial program 10.1

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

      \[\leadsto c0 \cdot \color{blue}{\left(\sqrt{A} \cdot \frac{1}{\sqrt{V \cdot \ell}}\right)} \]
    3. Simplified0.5

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

      [Start]0.5

      \[ c0 \cdot \left(\sqrt{A} \cdot \frac{1}{\sqrt{V \cdot \ell}}\right) \]

      *-commutative [<=]0.5

      \[ c0 \cdot \color{blue}{\left(\frac{1}{\sqrt{V \cdot \ell}} \cdot \sqrt{A}\right)} \]

      associate-*l/ [=>]0.5

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

      *-lft-identity [=>]0.5

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

    if 1.9999999999999999e304 < (*.f64 V l)

    1. Initial program 42.4

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

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

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

      [Start]24.3

      \[ \frac{c0}{\sqrt{\frac{V}{\frac{A}{\ell}}}} \]

      associate-/r/ [=>]24.3

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

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

Alternatives

Alternative 1
Error14.0
Cost34512
\[\begin{array}{l} t_0 := c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}\\ t_1 := \frac{c0}{\sqrt{\ell \cdot \frac{V}{A}}}\\ \mathbf{if}\;t_0 \leq -5 \cdot 10^{+304}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_0 \leq -2 \cdot 10^{-242}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;t_0 \leq 0:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{\ell}}{V}}\\ \mathbf{elif}\;t_0 \leq 5 \cdot 10^{+293}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error14.0
Cost34512
\[\begin{array}{l} t_0 := c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}\\ \mathbf{if}\;t_0 \leq -5 \cdot 10^{+304}:\\ \;\;\;\;\frac{c0}{\sqrt{\ell \cdot \frac{V}{A}}}\\ \mathbf{elif}\;t_0 \leq -2 \cdot 10^{-242}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;t_0 \leq 0:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{\ell}}{V}}\\ \mathbf{elif}\;t_0 \leq 2 \cdot 10^{+302}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{c0}{\sqrt{V \cdot \frac{\ell}{A}}}\\ \end{array} \]
Alternative 3
Error14.6
Cost27724
\[\begin{array}{l} t_0 := c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}\\ \mathbf{if}\;t_0 \leq -2 \cdot 10^{-242}:\\ \;\;\;\;\frac{c0}{\sqrt{\frac{V \cdot \ell}{A}}}\\ \mathbf{elif}\;t_0 \leq 0:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{\ell}}{V}}\\ \mathbf{elif}\;t_0 \leq 2 \cdot 10^{+302}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\sqrt{A \cdot \left(\frac{c0}{\ell} \cdot \frac{c0}{V}\right)}\\ \end{array} \]
Alternative 4
Error4.6
Cost20036
\[\begin{array}{l} \mathbf{if}\;V \cdot \ell \leq -2 \cdot 10^{-321}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{-A}}{\sqrt{-V} \cdot \sqrt{\ell}}\\ \mathbf{elif}\;V \cdot \ell \leq 10^{-315}:\\ \;\;\;\;c0 \cdot \left({\ell}^{-0.5} \cdot \sqrt{\frac{A}{V}}\right)\\ \mathbf{elif}\;V \cdot \ell \leq 2 \cdot 10^{+304}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{A}}{\sqrt{V \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c0}{\sqrt{\ell \cdot \frac{V}{A}}}\\ \end{array} \]
Alternative 5
Error11.2
Cost14288
\[\begin{array}{l} \mathbf{if}\;V \cdot \ell \leq -\infty:\\ \;\;\;\;\sqrt{A \cdot \left(\frac{c0}{\ell} \cdot \frac{c0}{V}\right)}\\ \mathbf{elif}\;V \cdot \ell \leq -4 \cdot 10^{-119}:\\ \;\;\;\;\frac{c0}{\sqrt{\frac{V \cdot \ell}{A}}}\\ \mathbf{elif}\;V \cdot \ell \leq 10^{-315}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{A}{\ell} \cdot \frac{1}{V}}\\ \mathbf{elif}\;V \cdot \ell \leq 2 \cdot 10^{+304}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{A}}{\sqrt{V \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c0}{\sqrt{\ell \cdot \frac{V}{A}}}\\ \end{array} \]
Alternative 6
Error8.1
Cost14288
\[\begin{array}{l} t_0 := c0 \cdot \frac{\sqrt{\frac{A}{V}}}{\sqrt{\ell}}\\ \mathbf{if}\;V \cdot \ell \leq -2 \cdot 10^{+288}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;V \cdot \ell \leq -4 \cdot 10^{-119}:\\ \;\;\;\;\frac{c0}{\sqrt{\frac{V \cdot \ell}{A}}}\\ \mathbf{elif}\;V \cdot \ell \leq 10^{-315}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;V \cdot \ell \leq 2 \cdot 10^{+304}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{A}}{\sqrt{V \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c0}{\sqrt{\ell \cdot \frac{V}{A}}}\\ \end{array} \]
Alternative 7
Error8.2
Cost14288
\[\begin{array}{l} \mathbf{if}\;V \cdot \ell \leq -2 \cdot 10^{+288}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{\frac{A}{V}}}{\sqrt{\ell}}\\ \mathbf{elif}\;V \cdot \ell \leq -1 \cdot 10^{-157}:\\ \;\;\;\;\frac{c0}{\sqrt{\frac{V \cdot \ell}{A}}}\\ \mathbf{elif}\;V \cdot \ell \leq 10^{-315}:\\ \;\;\;\;\frac{\frac{c0}{\sqrt{\ell}}}{\sqrt{\frac{V}{A}}}\\ \mathbf{elif}\;V \cdot \ell \leq 2 \cdot 10^{+304}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{A}}{\sqrt{V \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c0}{\sqrt{\ell \cdot \frac{V}{A}}}\\ \end{array} \]
Alternative 8
Error6.1
Cost14288
\[\begin{array}{l} t_0 := \sqrt{\frac{A}{V}}\\ \mathbf{if}\;V \cdot \ell \leq -\infty:\\ \;\;\;\;c0 \cdot \frac{t_0}{\sqrt{\ell}}\\ \mathbf{elif}\;V \cdot \ell \leq -5 \cdot 10^{-243}:\\ \;\;\;\;\sqrt{-A} \cdot \frac{c0}{\sqrt{V \cdot \left(-\ell\right)}}\\ \mathbf{elif}\;V \cdot \ell \leq 10^{-315}:\\ \;\;\;\;c0 \cdot \left({\ell}^{-0.5} \cdot t_0\right)\\ \mathbf{elif}\;V \cdot \ell \leq 2 \cdot 10^{+304}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{A}}{\sqrt{V \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c0}{\sqrt{\ell \cdot \frac{V}{A}}}\\ \end{array} \]
Alternative 9
Error5.3
Cost14288
\[\begin{array}{l} t_0 := \sqrt{\frac{A}{V}}\\ \mathbf{if}\;V \cdot \ell \leq -\infty:\\ \;\;\;\;c0 \cdot \frac{t_0}{\sqrt{\ell}}\\ \mathbf{elif}\;V \cdot \ell \leq -5 \cdot 10^{-243}:\\ \;\;\;\;\frac{c0}{\frac{\sqrt{V \cdot \left(-\ell\right)}}{\sqrt{-A}}}\\ \mathbf{elif}\;V \cdot \ell \leq 10^{-315}:\\ \;\;\;\;c0 \cdot \left({\ell}^{-0.5} \cdot t_0\right)\\ \mathbf{elif}\;V \cdot \ell \leq 2 \cdot 10^{+304}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{A}}{\sqrt{V \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c0}{\sqrt{\ell \cdot \frac{V}{A}}}\\ \end{array} \]
Alternative 10
Error14.5
Cost7890
\[\begin{array}{l} \mathbf{if}\;V \cdot \ell \leq -\infty \lor \neg \left(V \cdot \ell \leq -4 \cdot 10^{-115} \lor \neg \left(V \cdot \ell \leq 10^{-315}\right) \land V \cdot \ell \leq 10^{+184}\right):\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{\ell}}{V}}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}\\ \end{array} \]
Alternative 11
Error14.3
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 -1 \cdot 10^{+294}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;V \cdot \ell \leq -4 \cdot 10^{-119}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;V \cdot \ell \leq 10^{-219}:\\ \;\;\;\;\frac{c0}{\sqrt{\ell \cdot \frac{V}{A}}}\\ \mathbf{elif}\;V \cdot \ell \leq 10^{+120}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 12
Error19.1
Cost6848
\[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]

Error

Reproduce?

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