Average Error: 19.1 → 6.3
Time: 5.1s
Precision: binary64
\[[V, l] = \mathsf{sort}([V, l]) \\]
\[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
\[\begin{array}{l} \mathbf{if}\;V \cdot \ell \leq -1.7086687575887787 \cdot 10^{+296}:\\ \;\;\;\;\frac{c0}{\sqrt{\ell}} \cdot \sqrt{\frac{A}{V}}\\ \mathbf{elif}\;V \cdot \ell \leq -1.1809769999832396 \cdot 10^{-286}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{-A}}{\sqrt{-V \cdot \ell}}\\ \mathbf{elif}\;V \cdot \ell \leq 6.629893507142484 \cdot 10^{-298}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{1}{\frac{V}{\frac{A}{\ell}}}}\\ \mathbf{elif}\;V \cdot \ell \leq 6.589927006716444 \cdot 10^{+296}:\\ \;\;\;\;c0 \cdot \left(\sqrt{A} \cdot \sqrt{\frac{1}{V \cdot \ell}}\right)\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot {\left(\frac{\ell}{\frac{A}{V}}\right)}^{-0.5}\\ \end{array} \]
(FPCore (c0 A V l) :precision binary64 (* c0 (sqrt (/ A (* V l)))))
(FPCore (c0 A V l)
 :precision binary64
 (if (<= (* V l) -1.7086687575887787e+296)
   (* (/ c0 (sqrt l)) (sqrt (/ A V)))
   (if (<= (* V l) -1.1809769999832396e-286)
     (* c0 (/ (sqrt (- A)) (sqrt (- (* V l)))))
     (if (<= (* V l) 6.629893507142484e-298)
       (* c0 (sqrt (/ 1.0 (/ V (/ A l)))))
       (if (<= (* V l) 6.589927006716444e+296)
         (* c0 (* (sqrt A) (sqrt (/ 1.0 (* V l)))))
         (* c0 (pow (/ l (/ A V)) -0.5)))))))
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) <= -1.7086687575887787e+296) {
		tmp = (c0 / sqrt(l)) * sqrt((A / V));
	} else if ((V * l) <= -1.1809769999832396e-286) {
		tmp = c0 * (sqrt(-A) / sqrt(-(V * l)));
	} else if ((V * l) <= 6.629893507142484e-298) {
		tmp = c0 * sqrt((1.0 / (V / (A / l))));
	} else if ((V * l) <= 6.589927006716444e+296) {
		tmp = c0 * (sqrt(A) * sqrt((1.0 / (V * l))));
	} else {
		tmp = c0 * pow((l / (A / V)), -0.5);
	}
	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) <= (-1.7086687575887787d+296)) then
        tmp = (c0 / sqrt(l)) * sqrt((a / v))
    else if ((v * l) <= (-1.1809769999832396d-286)) then
        tmp = c0 * (sqrt(-a) / sqrt(-(v * l)))
    else if ((v * l) <= 6.629893507142484d-298) then
        tmp = c0 * sqrt((1.0d0 / (v / (a / l))))
    else if ((v * l) <= 6.589927006716444d+296) then
        tmp = c0 * (sqrt(a) * sqrt((1.0d0 / (v * l))))
    else
        tmp = c0 * ((l / (a / v)) ** (-0.5d0))
    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) <= -1.7086687575887787e+296) {
		tmp = (c0 / Math.sqrt(l)) * Math.sqrt((A / V));
	} else if ((V * l) <= -1.1809769999832396e-286) {
		tmp = c0 * (Math.sqrt(-A) / Math.sqrt(-(V * l)));
	} else if ((V * l) <= 6.629893507142484e-298) {
		tmp = c0 * Math.sqrt((1.0 / (V / (A / l))));
	} else if ((V * l) <= 6.589927006716444e+296) {
		tmp = c0 * (Math.sqrt(A) * Math.sqrt((1.0 / (V * l))));
	} else {
		tmp = c0 * Math.pow((l / (A / V)), -0.5);
	}
	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) <= -1.7086687575887787e+296:
		tmp = (c0 / math.sqrt(l)) * math.sqrt((A / V))
	elif (V * l) <= -1.1809769999832396e-286:
		tmp = c0 * (math.sqrt(-A) / math.sqrt(-(V * l)))
	elif (V * l) <= 6.629893507142484e-298:
		tmp = c0 * math.sqrt((1.0 / (V / (A / l))))
	elif (V * l) <= 6.589927006716444e+296:
		tmp = c0 * (math.sqrt(A) * math.sqrt((1.0 / (V * l))))
	else:
		tmp = c0 * math.pow((l / (A / V)), -0.5)
	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) <= -1.7086687575887787e+296)
		tmp = Float64(Float64(c0 / sqrt(l)) * sqrt(Float64(A / V)));
	elseif (Float64(V * l) <= -1.1809769999832396e-286)
		tmp = Float64(c0 * Float64(sqrt(Float64(-A)) / sqrt(Float64(-Float64(V * l)))));
	elseif (Float64(V * l) <= 6.629893507142484e-298)
		tmp = Float64(c0 * sqrt(Float64(1.0 / Float64(V / Float64(A / l)))));
	elseif (Float64(V * l) <= 6.589927006716444e+296)
		tmp = Float64(c0 * Float64(sqrt(A) * sqrt(Float64(1.0 / Float64(V * l)))));
	else
		tmp = Float64(c0 * (Float64(l / Float64(A / V)) ^ -0.5));
	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) <= -1.7086687575887787e+296)
		tmp = (c0 / sqrt(l)) * sqrt((A / V));
	elseif ((V * l) <= -1.1809769999832396e-286)
		tmp = c0 * (sqrt(-A) / sqrt(-(V * l)));
	elseif ((V * l) <= 6.629893507142484e-298)
		tmp = c0 * sqrt((1.0 / (V / (A / l))));
	elseif ((V * l) <= 6.589927006716444e+296)
		tmp = c0 * (sqrt(A) * sqrt((1.0 / (V * l))));
	else
		tmp = c0 * ((l / (A / V)) ^ -0.5);
	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], -1.7086687575887787e+296], N[(N[(c0 / N[Sqrt[l], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(A / V), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(V * l), $MachinePrecision], -1.1809769999832396e-286], N[(c0 * N[(N[Sqrt[(-A)], $MachinePrecision] / N[Sqrt[(-N[(V * l), $MachinePrecision])], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(V * l), $MachinePrecision], 6.629893507142484e-298], N[(c0 * N[Sqrt[N[(1.0 / N[(V / N[(A / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(V * l), $MachinePrecision], 6.589927006716444e+296], N[(c0 * N[(N[Sqrt[A], $MachinePrecision] * N[Sqrt[N[(1.0 / N[(V * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 * N[Power[N[(l / N[(A / V), $MachinePrecision]), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]]]]]
c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}
\begin{array}{l}
\mathbf{if}\;V \cdot \ell \leq -1.7086687575887787 \cdot 10^{+296}:\\
\;\;\;\;\frac{c0}{\sqrt{\ell}} \cdot \sqrt{\frac{A}{V}}\\

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

\mathbf{elif}\;V \cdot \ell \leq 6.629893507142484 \cdot 10^{-298}:\\
\;\;\;\;c0 \cdot \sqrt{\frac{1}{\frac{V}{\frac{A}{\ell}}}}\\

\mathbf{elif}\;V \cdot \ell \leq 6.589927006716444 \cdot 10^{+296}:\\
\;\;\;\;c0 \cdot \left(\sqrt{A} \cdot \sqrt{\frac{1}{V \cdot \ell}}\right)\\

\mathbf{else}:\\
\;\;\;\;c0 \cdot {\left(\frac{\ell}{\frac{A}{V}}\right)}^{-0.5}\\


\end{array}

Error

Bits error versus c0

Bits error versus A

Bits error versus V

Bits error versus l

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 5 regimes
  2. if (*.f64 V l) < -1.7086687575887787e296

    1. Initial program 41.6

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

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

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

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

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

    if -1.7086687575887787e296 < (*.f64 V l) < -1.1809769999832396e-286

    1. Initial program 10.0

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

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

    if -1.1809769999832396e-286 < (*.f64 V l) < 6.6298935071424837e-298

    1. Initial program 56.5

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

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

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

    if 6.6298935071424837e-298 < (*.f64 V l) < 6.5899270067164442e296

    1. Initial program 10.0

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

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

    if 6.5899270067164442e296 < (*.f64 V l)

    1. Initial program 39.5

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;V \cdot \ell \leq -1.7086687575887787 \cdot 10^{+296}:\\ \;\;\;\;\frac{c0}{\sqrt{\ell}} \cdot \sqrt{\frac{A}{V}}\\ \mathbf{elif}\;V \cdot \ell \leq -1.1809769999832396 \cdot 10^{-286}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{-A}}{\sqrt{-V \cdot \ell}}\\ \mathbf{elif}\;V \cdot \ell \leq 6.629893507142484 \cdot 10^{-298}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{1}{\frac{V}{\frac{A}{\ell}}}}\\ \mathbf{elif}\;V \cdot \ell \leq 6.589927006716444 \cdot 10^{+296}:\\ \;\;\;\;c0 \cdot \left(\sqrt{A} \cdot \sqrt{\frac{1}{V \cdot \ell}}\right)\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot {\left(\frac{\ell}{\frac{A}{V}}\right)}^{-0.5}\\ \end{array} \]

Reproduce

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