?

Average Error: 18.9 → 17.0
Time: 15.2s
Precision: binary64
Cost: 27852

?

\[ \begin{array}{c}[V, l] = \mathsf{sort}([V, l])\\ \end{array} \]
\[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
\[\begin{array}{l} t_0 := c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}\\ \mathbf{if}\;t_0 \leq -1 \cdot 10^{-228}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;t_0 \leq 5 \cdot 10^{-192}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{\ell}}{V}}\\ \mathbf{elif}\;t_0 \leq 2 \cdot 10^{+215}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{A - \left(A - \frac{A}{V}\right)}{\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 (* c0 (sqrt (/ A (* V l))))))
   (if (<= t_0 -1e-228)
     t_0
     (if (<= t_0 5e-192)
       (* c0 (sqrt (/ (/ A l) V)))
       (if (<= t_0 2e+215) t_0 (* c0 (sqrt (/ (- A (- A (/ 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 = c0 * sqrt((A / (V * l)));
	double tmp;
	if (t_0 <= -1e-228) {
		tmp = t_0;
	} else if (t_0 <= 5e-192) {
		tmp = c0 * sqrt(((A / l) / V));
	} else if (t_0 <= 2e+215) {
		tmp = t_0;
	} else {
		tmp = c0 * sqrt(((A - (A - (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 = c0 * sqrt((a / (v * l)))
    if (t_0 <= (-1d-228)) then
        tmp = t_0
    else if (t_0 <= 5d-192) then
        tmp = c0 * sqrt(((a / l) / v))
    else if (t_0 <= 2d+215) then
        tmp = t_0
    else
        tmp = c0 * sqrt(((a - (a - (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 = c0 * Math.sqrt((A / (V * l)));
	double tmp;
	if (t_0 <= -1e-228) {
		tmp = t_0;
	} else if (t_0 <= 5e-192) {
		tmp = c0 * Math.sqrt(((A / l) / V));
	} else if (t_0 <= 2e+215) {
		tmp = t_0;
	} else {
		tmp = c0 * Math.sqrt(((A - (A - (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 = c0 * math.sqrt((A / (V * l)))
	tmp = 0
	if t_0 <= -1e-228:
		tmp = t_0
	elif t_0 <= 5e-192:
		tmp = c0 * math.sqrt(((A / l) / V))
	elif t_0 <= 2e+215:
		tmp = t_0
	else:
		tmp = c0 * math.sqrt(((A - (A - (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 = Float64(c0 * sqrt(Float64(A / Float64(V * l))))
	tmp = 0.0
	if (t_0 <= -1e-228)
		tmp = t_0;
	elseif (t_0 <= 5e-192)
		tmp = Float64(c0 * sqrt(Float64(Float64(A / l) / V)));
	elseif (t_0 <= 2e+215)
		tmp = t_0;
	else
		tmp = Float64(c0 * sqrt(Float64(Float64(A - Float64(A - 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 = c0 * sqrt((A / (V * l)));
	tmp = 0.0;
	if (t_0 <= -1e-228)
		tmp = t_0;
	elseif (t_0 <= 5e-192)
		tmp = c0 * sqrt(((A / l) / V));
	elseif (t_0 <= 2e+215)
		tmp = t_0;
	else
		tmp = c0 * sqrt(((A - (A - (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[(c0 * N[Sqrt[N[(A / N[(V * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -1e-228], t$95$0, If[LessEqual[t$95$0, 5e-192], N[(c0 * N[Sqrt[N[(N[(A / l), $MachinePrecision] / V), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 2e+215], t$95$0, N[(c0 * N[Sqrt[N[(N[(A - N[(A - N[(A / V), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}
\begin{array}{l}
t_0 := c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}\\
\mathbf{if}\;t_0 \leq -1 \cdot 10^{-228}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;t_0 \leq 2 \cdot 10^{+215}:\\
\;\;\;\;t_0\\

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


\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 c0 (sqrt.f64 (/.f64 A (*.f64 V l)))) < -1.00000000000000003e-228 or 5.0000000000000001e-192 < (*.f64 c0 (sqrt.f64 (/.f64 A (*.f64 V l)))) < 1.99999999999999981e215

    1. Initial program 8.9

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

    if -1.00000000000000003e-228 < (*.f64 c0 (sqrt.f64 (/.f64 A (*.f64 V l)))) < 5.0000000000000001e-192

    1. Initial program 27.5

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

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

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

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

      [Start]27.5

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

      rational.json-simplify-14 [<=]21.2

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

      rational.json-simplify-15 [=>]21.1

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

    if 1.99999999999999981e215 < (*.f64 c0 (sqrt.f64 (/.f64 A (*.f64 V l))))

    1. Initial program 43.7

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Simplified37.3

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

      [Start]43.7

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

      rational.json-simplify-28 [=>]37.3

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

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

      \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\left(A - A\right) - \frac{A}{V}}{-\ell}}} \]
    5. Simplified45.9

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

      [Start]37.3

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

      rational.json-simplify-40 [=>]37.3

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

      rational.json-simplify-6 [=>]45.9

      \[ c0 \cdot \sqrt{\frac{\color{blue}{A - \left(A - \frac{A}{V}\right)}}{\ell}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification17.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \leq -1 \cdot 10^{-228}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}\\ \mathbf{elif}\;c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \leq 5 \cdot 10^{-192}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{\ell}}{V}}\\ \mathbf{elif}\;c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \leq 2 \cdot 10^{+215}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{A - \left(A - \frac{A}{V}\right)}{\ell}}\\ \end{array} \]

Alternatives

Alternative 1
Error16.5
Cost27724
\[\begin{array}{l} t_0 := c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}\\ \mathbf{if}\;t_0 \leq -1 \cdot 10^{-228}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;t_0 \leq 5 \cdot 10^{-192}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{\ell}}{V}}\\ \mathbf{elif}\;t_0 \leq 5 \cdot 10^{+107}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{A}{\ell} \cdot \frac{1}{V}}\\ \end{array} \]
Alternative 2
Error17.0
Cost7368
\[\begin{array}{l} t_0 := c0 \cdot \sqrt{\frac{\frac{A}{V}}{\ell}}\\ \mathbf{if}\;V \cdot \ell \leq -4 \cdot 10^{+119}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;V \cdot \ell \leq 5 \cdot 10^{+113}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error18.9
Cost6848
\[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]

Error

Reproduce?

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