Henrywood and Agarwal, Equation (3)

Percentage Accurate: 73.6% → 90.7%
Time: 8.0s
Alternatives: 15
Speedup: 1.0×

Specification

?
\[\begin{array}{l} \\ c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \end{array} \]
(FPCore (c0 A V l) :precision binary64 (* c0 (sqrt (/ A (* V l)))))
double code(double c0, double A, double V, double l) {
	return c0 * sqrt((A / (V * l)));
}
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
public static double code(double c0, double A, double V, double l) {
	return c0 * Math.sqrt((A / (V * l)));
}
def code(c0, A, V, l):
	return c0 * math.sqrt((A / (V * l)))
function code(c0, A, V, l)
	return Float64(c0 * sqrt(Float64(A / Float64(V * l))))
end
function tmp = code(c0, A, V, l)
	tmp = c0 * sqrt((A / (V * l)));
end
code[c0_, A_, V_, l_] := N[(c0 * N[Sqrt[N[(A / N[(V * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 15 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 73.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \end{array} \]
(FPCore (c0 A V l) :precision binary64 (* c0 (sqrt (/ A (* V l)))))
double code(double c0, double A, double V, double l) {
	return c0 * sqrt((A / (V * l)));
}
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
public static double code(double c0, double A, double V, double l) {
	return c0 * Math.sqrt((A / (V * l)));
}
def code(c0, A, V, l):
	return c0 * math.sqrt((A / (V * l)))
function code(c0, A, V, l)
	return Float64(c0 * sqrt(Float64(A / Float64(V * l))))
end
function tmp = code(c0, A, V, l)
	tmp = c0 * sqrt((A / (V * l)));
end
code[c0_, A_, V_, l_] := N[(c0 * N[Sqrt[N[(A / N[(V * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}
\end{array}

Alternative 1: 90.7% accurate, 0.4× speedup?

\[\begin{array}{l} [c0, A, V, l] = \mathsf{sort}([c0, A, V, l])\\ \\ \begin{array}{l} t_0 := \sqrt{-A}\\ \mathbf{if}\;\ell \cdot V \leq -1 \cdot 10^{+307}:\\ \;\;\;\;\frac{t\_0 \cdot \frac{c0}{\sqrt{\ell}}}{\sqrt{-V}}\\ \mathbf{elif}\;\ell \cdot V \leq -4 \cdot 10^{-202}:\\ \;\;\;\;c0 \cdot \frac{t\_0}{\sqrt{V \cdot \left(-\ell\right)}}\\ \mathbf{elif}\;\ell \cdot V \leq 0:\\ \;\;\;\;\frac{c0}{\sqrt{V \cdot \frac{\ell}{A}}}\\ \mathbf{elif}\;\ell \cdot V \leq 4 \cdot 10^{+259}:\\ \;\;\;\;c0 \cdot \left(\sqrt{A} \cdot \sqrt{\frac{1}{\ell \cdot V}}\right)\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{V}}{\ell}}\\ \end{array} \end{array} \]
NOTE: c0, A, V, and l should be sorted in increasing order before calling this function.
(FPCore (c0 A V l)
 :precision binary64
 (let* ((t_0 (sqrt (- A))))
   (if (<= (* l V) -1e+307)
     (/ (* t_0 (/ c0 (sqrt l))) (sqrt (- V)))
     (if (<= (* l V) -4e-202)
       (* c0 (/ t_0 (sqrt (* V (- l)))))
       (if (<= (* l V) 0.0)
         (/ c0 (sqrt (* V (/ l A))))
         (if (<= (* l V) 4e+259)
           (* c0 (* (sqrt A) (sqrt (/ 1.0 (* l V)))))
           (* c0 (sqrt (/ (/ A V) l)))))))))
assert(c0 < A && A < V && V < l);
double code(double c0, double A, double V, double l) {
	double t_0 = sqrt(-A);
	double tmp;
	if ((l * V) <= -1e+307) {
		tmp = (t_0 * (c0 / sqrt(l))) / sqrt(-V);
	} else if ((l * V) <= -4e-202) {
		tmp = c0 * (t_0 / sqrt((V * -l)));
	} else if ((l * V) <= 0.0) {
		tmp = c0 / sqrt((V * (l / A)));
	} else if ((l * V) <= 4e+259) {
		tmp = c0 * (sqrt(A) * sqrt((1.0 / (l * V))));
	} else {
		tmp = c0 * sqrt(((A / V) / l));
	}
	return tmp;
}
NOTE: c0, A, V, and l should be sorted in increasing order before calling this 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(-a)
    if ((l * v) <= (-1d+307)) then
        tmp = (t_0 * (c0 / sqrt(l))) / sqrt(-v)
    else if ((l * v) <= (-4d-202)) then
        tmp = c0 * (t_0 / sqrt((v * -l)))
    else if ((l * v) <= 0.0d0) then
        tmp = c0 / sqrt((v * (l / a)))
    else if ((l * v) <= 4d+259) then
        tmp = c0 * (sqrt(a) * sqrt((1.0d0 / (l * v))))
    else
        tmp = c0 * sqrt(((a / v) / l))
    end if
    code = tmp
end function
assert c0 < A && A < V && V < l;
public static double code(double c0, double A, double V, double l) {
	double t_0 = Math.sqrt(-A);
	double tmp;
	if ((l * V) <= -1e+307) {
		tmp = (t_0 * (c0 / Math.sqrt(l))) / Math.sqrt(-V);
	} else if ((l * V) <= -4e-202) {
		tmp = c0 * (t_0 / Math.sqrt((V * -l)));
	} else if ((l * V) <= 0.0) {
		tmp = c0 / Math.sqrt((V * (l / A)));
	} else if ((l * V) <= 4e+259) {
		tmp = c0 * (Math.sqrt(A) * Math.sqrt((1.0 / (l * V))));
	} else {
		tmp = c0 * Math.sqrt(((A / V) / l));
	}
	return tmp;
}
[c0, A, V, l] = sort([c0, A, V, l])
def code(c0, A, V, l):
	t_0 = math.sqrt(-A)
	tmp = 0
	if (l * V) <= -1e+307:
		tmp = (t_0 * (c0 / math.sqrt(l))) / math.sqrt(-V)
	elif (l * V) <= -4e-202:
		tmp = c0 * (t_0 / math.sqrt((V * -l)))
	elif (l * V) <= 0.0:
		tmp = c0 / math.sqrt((V * (l / A)))
	elif (l * V) <= 4e+259:
		tmp = c0 * (math.sqrt(A) * math.sqrt((1.0 / (l * V))))
	else:
		tmp = c0 * math.sqrt(((A / V) / l))
	return tmp
c0, A, V, l = sort([c0, A, V, l])
function code(c0, A, V, l)
	t_0 = sqrt(Float64(-A))
	tmp = 0.0
	if (Float64(l * V) <= -1e+307)
		tmp = Float64(Float64(t_0 * Float64(c0 / sqrt(l))) / sqrt(Float64(-V)));
	elseif (Float64(l * V) <= -4e-202)
		tmp = Float64(c0 * Float64(t_0 / sqrt(Float64(V * Float64(-l)))));
	elseif (Float64(l * V) <= 0.0)
		tmp = Float64(c0 / sqrt(Float64(V * Float64(l / A))));
	elseif (Float64(l * V) <= 4e+259)
		tmp = Float64(c0 * Float64(sqrt(A) * sqrt(Float64(1.0 / Float64(l * V)))));
	else
		tmp = Float64(c0 * sqrt(Float64(Float64(A / V) / l)));
	end
	return tmp
end
c0, A, V, l = num2cell(sort([c0, A, V, l])){:}
function tmp_2 = code(c0, A, V, l)
	t_0 = sqrt(-A);
	tmp = 0.0;
	if ((l * V) <= -1e+307)
		tmp = (t_0 * (c0 / sqrt(l))) / sqrt(-V);
	elseif ((l * V) <= -4e-202)
		tmp = c0 * (t_0 / sqrt((V * -l)));
	elseif ((l * V) <= 0.0)
		tmp = c0 / sqrt((V * (l / A)));
	elseif ((l * V) <= 4e+259)
		tmp = c0 * (sqrt(A) * sqrt((1.0 / (l * V))));
	else
		tmp = c0 * sqrt(((A / V) / l));
	end
	tmp_2 = tmp;
end
NOTE: c0, A, V, and l should be sorted in increasing order before calling this function.
code[c0_, A_, V_, l_] := Block[{t$95$0 = N[Sqrt[(-A)], $MachinePrecision]}, If[LessEqual[N[(l * V), $MachinePrecision], -1e+307], N[(N[(t$95$0 * N[(c0 / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[(-V)], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(l * V), $MachinePrecision], -4e-202], N[(c0 * N[(t$95$0 / N[Sqrt[N[(V * (-l)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(l * V), $MachinePrecision], 0.0], N[(c0 / N[Sqrt[N[(V * N[(l / A), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(l * V), $MachinePrecision], 4e+259], N[(c0 * N[(N[Sqrt[A], $MachinePrecision] * N[Sqrt[N[(1.0 / N[(l * V), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 * N[Sqrt[N[(N[(A / V), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
[c0, A, V, l] = \mathsf{sort}([c0, A, V, l])\\
\\
\begin{array}{l}
t_0 := \sqrt{-A}\\
\mathbf{if}\;\ell \cdot V \leq -1 \cdot 10^{+307}:\\
\;\;\;\;\frac{t\_0 \cdot \frac{c0}{\sqrt{\ell}}}{\sqrt{-V}}\\

\mathbf{elif}\;\ell \cdot V \leq -4 \cdot 10^{-202}:\\
\;\;\;\;c0 \cdot \frac{t\_0}{\sqrt{V \cdot \left(-\ell\right)}}\\

\mathbf{elif}\;\ell \cdot V \leq 0:\\
\;\;\;\;\frac{c0}{\sqrt{V \cdot \frac{\ell}{A}}}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if (*.f64 V l) < -9.99999999999999986e306

    1. Initial program 42.8%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{A}{V \cdot \ell}}} \]
      2. clear-numN/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{1}{\frac{V \cdot \ell}{A}}}} \]
      3. lift-*.f64N/A

        \[\leadsto c0 \cdot \sqrt{\frac{1}{\frac{\color{blue}{V \cdot \ell}}{A}}} \]
      4. associate-/l*N/A

        \[\leadsto c0 \cdot \sqrt{\frac{1}{\color{blue}{V \cdot \frac{\ell}{A}}}} \]
      5. associate-/r*N/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{1}{V}}{\frac{\ell}{A}}}} \]
      6. lower-/.f64N/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{1}{V}}{\frac{\ell}{A}}}} \]
      7. lower-/.f64N/A

        \[\leadsto c0 \cdot \sqrt{\frac{\color{blue}{\frac{1}{V}}}{\frac{\ell}{A}}} \]
      8. lower-/.f6461.9

        \[\leadsto c0 \cdot \sqrt{\frac{\frac{1}{V}}{\color{blue}{\frac{\ell}{A}}}} \]
    4. Applied rewrites61.9%

      \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{1}{V}}{\frac{\ell}{A}}}} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{c0 \cdot \sqrt{\frac{\frac{1}{V}}{\frac{\ell}{A}}}} \]
      2. lift-sqrt.f64N/A

        \[\leadsto c0 \cdot \color{blue}{\sqrt{\frac{\frac{1}{V}}{\frac{\ell}{A}}}} \]
      3. lift-/.f64N/A

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

        \[\leadsto c0 \cdot \color{blue}{\frac{\sqrt{\frac{1}{V}}}{\sqrt{\frac{\ell}{A}}}} \]
      5. pow1/2N/A

        \[\leadsto c0 \cdot \frac{\color{blue}{{\left(\frac{1}{V}\right)}^{\frac{1}{2}}}}{\sqrt{\frac{\ell}{A}}} \]
      6. associate-*r/N/A

        \[\leadsto \color{blue}{\frac{c0 \cdot {\left(\frac{1}{V}\right)}^{\frac{1}{2}}}{\sqrt{\frac{\ell}{A}}}} \]
      7. pow1/2N/A

        \[\leadsto \frac{c0 \cdot \color{blue}{\sqrt{\frac{1}{V}}}}{\sqrt{\frac{\ell}{A}}} \]
      8. lift-/.f64N/A

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

        \[\leadsto \frac{c0 \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{V}}}}{\sqrt{\frac{\ell}{A}}} \]
      10. metadata-evalN/A

        \[\leadsto \frac{c0 \cdot \frac{\color{blue}{1}}{\sqrt{V}}}{\sqrt{\frac{\ell}{A}}} \]
      11. div-invN/A

        \[\leadsto \frac{\color{blue}{\frac{c0}{\sqrt{V}}}}{\sqrt{\frac{\ell}{A}}} \]
      12. associate-/r*N/A

        \[\leadsto \color{blue}{\frac{c0}{\sqrt{V} \cdot \sqrt{\frac{\ell}{A}}}} \]
      13. lift-/.f64N/A

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

        \[\leadsto \frac{c0}{\sqrt{V} \cdot \color{blue}{\frac{\sqrt{\ell}}{\sqrt{A}}}} \]
      15. lift-sqrt.f64N/A

        \[\leadsto \frac{c0}{\sqrt{V} \cdot \frac{\sqrt{\ell}}{\color{blue}{\sqrt{A}}}} \]
      16. associate-/l*N/A

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

        \[\leadsto \frac{c0}{\frac{\color{blue}{\sqrt{V \cdot \ell}}}{\sqrt{A}}} \]
      18. lift-*.f64N/A

        \[\leadsto \frac{c0}{\frac{\sqrt{\color{blue}{V \cdot \ell}}}{\sqrt{A}}} \]
      19. lift-sqrt.f64N/A

        \[\leadsto \frac{c0}{\frac{\color{blue}{\sqrt{V \cdot \ell}}}{\sqrt{A}}} \]
    6. Applied rewrites99.6%

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

    if -9.99999999999999986e306 < (*.f64 V l) < -4.0000000000000001e-202

    1. Initial program 83.2%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{A}{V \cdot \ell}}} \]
      2. clear-numN/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{1}{\frac{V \cdot \ell}{A}}}} \]
      3. lift-*.f64N/A

        \[\leadsto c0 \cdot \sqrt{\frac{1}{\frac{\color{blue}{V \cdot \ell}}{A}}} \]
      4. associate-/l*N/A

        \[\leadsto c0 \cdot \sqrt{\frac{1}{\color{blue}{V \cdot \frac{\ell}{A}}}} \]
      5. associate-/r*N/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{1}{V}}{\frac{\ell}{A}}}} \]
      6. lower-/.f64N/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{1}{V}}{\frac{\ell}{A}}}} \]
      7. lower-/.f64N/A

        \[\leadsto c0 \cdot \sqrt{\frac{\color{blue}{\frac{1}{V}}}{\frac{\ell}{A}}} \]
      8. lower-/.f6477.2

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

      \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{1}{V}}{\frac{\ell}{A}}}} \]
    5. Step-by-step derivation
      1. lift-sqrt.f64N/A

        \[\leadsto c0 \cdot \color{blue}{\sqrt{\frac{\frac{1}{V}}{\frac{\ell}{A}}}} \]
      2. lift-/.f64N/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{1}{V}}{\frac{\ell}{A}}}} \]
      3. lift-/.f64N/A

        \[\leadsto c0 \cdot \sqrt{\frac{\frac{1}{V}}{\color{blue}{\frac{\ell}{A}}}} \]
      4. associate-/r/N/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{1}{V}}{\ell} \cdot A}} \]
      5. lift-/.f64N/A

        \[\leadsto c0 \cdot \sqrt{\frac{\color{blue}{\frac{1}{V}}}{\ell} \cdot A} \]
      6. associate-/r*N/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{1}{V \cdot \ell}} \cdot A} \]
      7. lift-*.f64N/A

        \[\leadsto c0 \cdot \sqrt{\frac{1}{\color{blue}{V \cdot \ell}} \cdot A} \]
      8. associate-*l/N/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{1 \cdot A}{V \cdot \ell}}} \]
      9. frac-2negN/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\mathsf{neg}\left(1 \cdot A\right)}{\mathsf{neg}\left(V \cdot \ell\right)}}} \]
      10. *-lft-identityN/A

        \[\leadsto c0 \cdot \sqrt{\frac{\mathsf{neg}\left(\color{blue}{A}\right)}{\mathsf{neg}\left(V \cdot \ell\right)}} \]
      11. sqrt-divN/A

        \[\leadsto c0 \cdot \color{blue}{\frac{\sqrt{\mathsf{neg}\left(A\right)}}{\sqrt{\mathsf{neg}\left(V \cdot \ell\right)}}} \]
      12. pow1/2N/A

        \[\leadsto c0 \cdot \frac{\color{blue}{{\left(\mathsf{neg}\left(A\right)\right)}^{\frac{1}{2}}}}{\sqrt{\mathsf{neg}\left(V \cdot \ell\right)}} \]
      13. lower-/.f64N/A

        \[\leadsto c0 \cdot \color{blue}{\frac{{\left(\mathsf{neg}\left(A\right)\right)}^{\frac{1}{2}}}{\sqrt{\mathsf{neg}\left(V \cdot \ell\right)}}} \]
      14. pow1/2N/A

        \[\leadsto c0 \cdot \frac{\color{blue}{\sqrt{\mathsf{neg}\left(A\right)}}}{\sqrt{\mathsf{neg}\left(V \cdot \ell\right)}} \]
      15. lower-sqrt.f64N/A

        \[\leadsto c0 \cdot \frac{\color{blue}{\sqrt{\mathsf{neg}\left(A\right)}}}{\sqrt{\mathsf{neg}\left(V \cdot \ell\right)}} \]
      16. lower-neg.f64N/A

        \[\leadsto c0 \cdot \frac{\sqrt{\color{blue}{\mathsf{neg}\left(A\right)}}}{\sqrt{\mathsf{neg}\left(V \cdot \ell\right)}} \]
      17. lower-sqrt.f64N/A

        \[\leadsto c0 \cdot \frac{\sqrt{\mathsf{neg}\left(A\right)}}{\color{blue}{\sqrt{\mathsf{neg}\left(V \cdot \ell\right)}}} \]
      18. lift-*.f64N/A

        \[\leadsto c0 \cdot \frac{\sqrt{\mathsf{neg}\left(A\right)}}{\sqrt{\mathsf{neg}\left(\color{blue}{V \cdot \ell}\right)}} \]
      19. *-commutativeN/A

        \[\leadsto c0 \cdot \frac{\sqrt{\mathsf{neg}\left(A\right)}}{\sqrt{\mathsf{neg}\left(\color{blue}{\ell \cdot V}\right)}} \]
      20. distribute-rgt-neg-inN/A

        \[\leadsto c0 \cdot \frac{\sqrt{\mathsf{neg}\left(A\right)}}{\sqrt{\color{blue}{\ell \cdot \left(\mathsf{neg}\left(V\right)\right)}}} \]
      21. lower-*.f64N/A

        \[\leadsto c0 \cdot \frac{\sqrt{\mathsf{neg}\left(A\right)}}{\sqrt{\color{blue}{\ell \cdot \left(\mathsf{neg}\left(V\right)\right)}}} \]
      22. lower-neg.f6499.5

        \[\leadsto c0 \cdot \frac{\sqrt{-A}}{\sqrt{\ell \cdot \color{blue}{\left(-V\right)}}} \]
    6. Applied rewrites99.5%

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

    if -4.0000000000000001e-202 < (*.f64 V l) < -0.0

    1. Initial program 45.5%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{A}{V \cdot \ell}}} \]
      2. lift-*.f64N/A

        \[\leadsto c0 \cdot \sqrt{\frac{A}{\color{blue}{V \cdot \ell}}} \]
      3. associate-/l/N/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{A}{\ell}}{V}}} \]
      4. lower-/.f64N/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{A}{\ell}}{V}}} \]
      5. lower-/.f6461.0

        \[\leadsto c0 \cdot \sqrt{\frac{\color{blue}{\frac{A}{\ell}}}{V}} \]
    4. Applied rewrites61.0%

      \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{A}{\ell}}{V}}} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{c0 \cdot \sqrt{\frac{\frac{A}{\ell}}{V}}} \]
      2. lift-sqrt.f64N/A

        \[\leadsto c0 \cdot \color{blue}{\sqrt{\frac{\frac{A}{\ell}}{V}}} \]
      3. lift-/.f64N/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{A}{\ell}}{V}}} \]
      4. lift-/.f64N/A

        \[\leadsto c0 \cdot \sqrt{\frac{\color{blue}{\frac{A}{\ell}}}{V}} \]
      5. associate-/l/N/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{A}{V \cdot \ell}}} \]
      6. lift-*.f64N/A

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

        \[\leadsto c0 \cdot \color{blue}{\frac{\sqrt{A}}{\sqrt{V \cdot \ell}}} \]
      8. associate-*r/N/A

        \[\leadsto \color{blue}{\frac{c0 \cdot \sqrt{A}}{\sqrt{V \cdot \ell}}} \]
      9. associate-*l/N/A

        \[\leadsto \color{blue}{\frac{c0}{\sqrt{V \cdot \ell}} \cdot \sqrt{A}} \]
      10. associate-/r/N/A

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

        \[\leadsto \frac{c0}{\color{blue}{\sqrt{\frac{V \cdot \ell}{A}}}} \]
      12. lift-/.f64N/A

        \[\leadsto \frac{c0}{\sqrt{\color{blue}{\frac{V \cdot \ell}{A}}}} \]
      13. lift-sqrt.f64N/A

        \[\leadsto \frac{c0}{\color{blue}{\sqrt{\frac{V \cdot \ell}{A}}}} \]
      14. lower-/.f6445.5

        \[\leadsto \color{blue}{\frac{c0}{\sqrt{\frac{V \cdot \ell}{A}}}} \]
      15. lift-*.f64N/A

        \[\leadsto \frac{c0}{\sqrt{\frac{\color{blue}{V \cdot \ell}}{A}}} \]
      16. *-commutativeN/A

        \[\leadsto \frac{c0}{\sqrt{\frac{\color{blue}{\ell \cdot V}}{A}}} \]
      17. lower-*.f6445.5

        \[\leadsto \frac{c0}{\sqrt{\frac{\color{blue}{\ell \cdot V}}{A}}} \]
    6. Applied rewrites45.5%

      \[\leadsto \color{blue}{\frac{c0}{\sqrt{\frac{\ell \cdot V}{A}}}} \]
    7. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \frac{c0}{\sqrt{\color{blue}{\frac{\ell \cdot V}{A}}}} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{c0}{\sqrt{\frac{\color{blue}{\ell \cdot V}}{A}}} \]
      3. associate-*l/N/A

        \[\leadsto \frac{c0}{\sqrt{\color{blue}{\frac{\ell}{A} \cdot V}}} \]
      4. lift-/.f64N/A

        \[\leadsto \frac{c0}{\sqrt{\color{blue}{\frac{\ell}{A}} \cdot V}} \]
      5. lift-*.f6461.1

        \[\leadsto \frac{c0}{\sqrt{\color{blue}{\frac{\ell}{A} \cdot V}}} \]
    8. Applied rewrites61.1%

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

    if -0.0 < (*.f64 V l) < 4e259

    1. Initial program 91.8%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-sqrt.f64N/A

        \[\leadsto c0 \cdot \color{blue}{\sqrt{\frac{A}{V \cdot \ell}}} \]
      2. lift-/.f64N/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{A}{V \cdot \ell}}} \]
      3. clear-numN/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{1}{\frac{V \cdot \ell}{A}}}} \]
      4. associate-/r/N/A

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

        \[\leadsto c0 \cdot \color{blue}{\left(\sqrt{\frac{1}{V \cdot \ell}} \cdot \sqrt{A}\right)} \]
      6. pow1/2N/A

        \[\leadsto c0 \cdot \left(\color{blue}{{\left(\frac{1}{V \cdot \ell}\right)}^{\frac{1}{2}}} \cdot \sqrt{A}\right) \]
      7. lower-*.f64N/A

        \[\leadsto c0 \cdot \color{blue}{\left({\left(\frac{1}{V \cdot \ell}\right)}^{\frac{1}{2}} \cdot \sqrt{A}\right)} \]
      8. pow1/2N/A

        \[\leadsto c0 \cdot \left(\color{blue}{\sqrt{\frac{1}{V \cdot \ell}}} \cdot \sqrt{A}\right) \]
      9. lower-sqrt.f64N/A

        \[\leadsto c0 \cdot \left(\color{blue}{\sqrt{\frac{1}{V \cdot \ell}}} \cdot \sqrt{A}\right) \]
      10. lower-/.f64N/A

        \[\leadsto c0 \cdot \left(\sqrt{\color{blue}{\frac{1}{V \cdot \ell}}} \cdot \sqrt{A}\right) \]
      11. lower-sqrt.f6499.4

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

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

    if 4e259 < (*.f64 V l)

    1. Initial program 55.8%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{A}{V \cdot \ell}}} \]
      2. lift-*.f64N/A

        \[\leadsto c0 \cdot \sqrt{\frac{A}{\color{blue}{V \cdot \ell}}} \]
      3. associate-/r*N/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{A}{V}}{\ell}}} \]
      4. lower-/.f64N/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{A}{V}}{\ell}}} \]
      5. lower-/.f6477.1

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \cdot V \leq -1 \cdot 10^{+307}:\\ \;\;\;\;\frac{\sqrt{-A} \cdot \frac{c0}{\sqrt{\ell}}}{\sqrt{-V}}\\ \mathbf{elif}\;\ell \cdot V \leq -4 \cdot 10^{-202}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{-A}}{\sqrt{V \cdot \left(-\ell\right)}}\\ \mathbf{elif}\;\ell \cdot V \leq 0:\\ \;\;\;\;\frac{c0}{\sqrt{V \cdot \frac{\ell}{A}}}\\ \mathbf{elif}\;\ell \cdot V \leq 4 \cdot 10^{+259}:\\ \;\;\;\;c0 \cdot \left(\sqrt{A} \cdot \sqrt{\frac{1}{\ell \cdot V}}\right)\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{V}}{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 89.7% accurate, 0.4× speedup?

\[\begin{array}{l} [c0, A, V, l] = \mathsf{sort}([c0, A, V, l])\\ \\ \begin{array}{l} \mathbf{if}\;\ell \cdot V \leq -\infty:\\ \;\;\;\;\frac{c0}{\sqrt{\ell} \cdot \sqrt{\frac{V}{A}}}\\ \mathbf{elif}\;\ell \cdot V \leq -4 \cdot 10^{-202}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{-A}}{\sqrt{V \cdot \left(-\ell\right)}}\\ \mathbf{elif}\;\ell \cdot V \leq 0:\\ \;\;\;\;\frac{c0}{\sqrt{V \cdot \frac{\ell}{A}}}\\ \mathbf{elif}\;\ell \cdot V \leq 4 \cdot 10^{+259}:\\ \;\;\;\;c0 \cdot \left(\sqrt{A} \cdot \sqrt{\frac{1}{\ell \cdot V}}\right)\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{V}}{\ell}}\\ \end{array} \end{array} \]
NOTE: c0, A, V, and l should be sorted in increasing order before calling this function.
(FPCore (c0 A V l)
 :precision binary64
 (if (<= (* l V) (- INFINITY))
   (/ c0 (* (sqrt l) (sqrt (/ V A))))
   (if (<= (* l V) -4e-202)
     (* c0 (/ (sqrt (- A)) (sqrt (* V (- l)))))
     (if (<= (* l V) 0.0)
       (/ c0 (sqrt (* V (/ l A))))
       (if (<= (* l V) 4e+259)
         (* c0 (* (sqrt A) (sqrt (/ 1.0 (* l V)))))
         (* c0 (sqrt (/ (/ A V) l))))))))
assert(c0 < A && A < V && V < l);
double code(double c0, double A, double V, double l) {
	double tmp;
	if ((l * V) <= -((double) INFINITY)) {
		tmp = c0 / (sqrt(l) * sqrt((V / A)));
	} else if ((l * V) <= -4e-202) {
		tmp = c0 * (sqrt(-A) / sqrt((V * -l)));
	} else if ((l * V) <= 0.0) {
		tmp = c0 / sqrt((V * (l / A)));
	} else if ((l * V) <= 4e+259) {
		tmp = c0 * (sqrt(A) * sqrt((1.0 / (l * V))));
	} else {
		tmp = c0 * sqrt(((A / V) / l));
	}
	return tmp;
}
assert c0 < A && A < V && V < l;
public static double code(double c0, double A, double V, double l) {
	double tmp;
	if ((l * V) <= -Double.POSITIVE_INFINITY) {
		tmp = c0 / (Math.sqrt(l) * Math.sqrt((V / A)));
	} else if ((l * V) <= -4e-202) {
		tmp = c0 * (Math.sqrt(-A) / Math.sqrt((V * -l)));
	} else if ((l * V) <= 0.0) {
		tmp = c0 / Math.sqrt((V * (l / A)));
	} else if ((l * V) <= 4e+259) {
		tmp = c0 * (Math.sqrt(A) * Math.sqrt((1.0 / (l * V))));
	} else {
		tmp = c0 * Math.sqrt(((A / V) / l));
	}
	return tmp;
}
[c0, A, V, l] = sort([c0, A, V, l])
def code(c0, A, V, l):
	tmp = 0
	if (l * V) <= -math.inf:
		tmp = c0 / (math.sqrt(l) * math.sqrt((V / A)))
	elif (l * V) <= -4e-202:
		tmp = c0 * (math.sqrt(-A) / math.sqrt((V * -l)))
	elif (l * V) <= 0.0:
		tmp = c0 / math.sqrt((V * (l / A)))
	elif (l * V) <= 4e+259:
		tmp = c0 * (math.sqrt(A) * math.sqrt((1.0 / (l * V))))
	else:
		tmp = c0 * math.sqrt(((A / V) / l))
	return tmp
c0, A, V, l = sort([c0, A, V, l])
function code(c0, A, V, l)
	tmp = 0.0
	if (Float64(l * V) <= Float64(-Inf))
		tmp = Float64(c0 / Float64(sqrt(l) * sqrt(Float64(V / A))));
	elseif (Float64(l * V) <= -4e-202)
		tmp = Float64(c0 * Float64(sqrt(Float64(-A)) / sqrt(Float64(V * Float64(-l)))));
	elseif (Float64(l * V) <= 0.0)
		tmp = Float64(c0 / sqrt(Float64(V * Float64(l / A))));
	elseif (Float64(l * V) <= 4e+259)
		tmp = Float64(c0 * Float64(sqrt(A) * sqrt(Float64(1.0 / Float64(l * V)))));
	else
		tmp = Float64(c0 * sqrt(Float64(Float64(A / V) / l)));
	end
	return tmp
end
c0, A, V, l = num2cell(sort([c0, A, V, l])){:}
function tmp_2 = code(c0, A, V, l)
	tmp = 0.0;
	if ((l * V) <= -Inf)
		tmp = c0 / (sqrt(l) * sqrt((V / A)));
	elseif ((l * V) <= -4e-202)
		tmp = c0 * (sqrt(-A) / sqrt((V * -l)));
	elseif ((l * V) <= 0.0)
		tmp = c0 / sqrt((V * (l / A)));
	elseif ((l * V) <= 4e+259)
		tmp = c0 * (sqrt(A) * sqrt((1.0 / (l * V))));
	else
		tmp = c0 * sqrt(((A / V) / l));
	end
	tmp_2 = tmp;
end
NOTE: c0, A, V, and l should be sorted in increasing order before calling this function.
code[c0_, A_, V_, l_] := If[LessEqual[N[(l * V), $MachinePrecision], (-Infinity)], N[(c0 / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[N[(V / A), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(l * V), $MachinePrecision], -4e-202], N[(c0 * N[(N[Sqrt[(-A)], $MachinePrecision] / N[Sqrt[N[(V * (-l)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(l * V), $MachinePrecision], 0.0], N[(c0 / N[Sqrt[N[(V * N[(l / A), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(l * V), $MachinePrecision], 4e+259], N[(c0 * N[(N[Sqrt[A], $MachinePrecision] * N[Sqrt[N[(1.0 / N[(l * V), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 * N[Sqrt[N[(N[(A / V), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
[c0, A, V, l] = \mathsf{sort}([c0, A, V, l])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \cdot V \leq -\infty:\\
\;\;\;\;\frac{c0}{\sqrt{\ell} \cdot \sqrt{\frac{V}{A}}}\\

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

\mathbf{elif}\;\ell \cdot V \leq 0:\\
\;\;\;\;\frac{c0}{\sqrt{V \cdot \frac{\ell}{A}}}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if (*.f64 V l) < -inf.0

    1. Initial program 36.3%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{A}{V \cdot \ell}}} \]
      2. lift-*.f64N/A

        \[\leadsto c0 \cdot \sqrt{\frac{A}{\color{blue}{V \cdot \ell}}} \]
      3. associate-/l/N/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{A}{\ell}}{V}}} \]
      4. lower-/.f64N/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{A}{\ell}}{V}}} \]
      5. lower-/.f6461.7

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

      \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{A}{\ell}}{V}}} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{c0 \cdot \sqrt{\frac{\frac{A}{\ell}}{V}}} \]
      2. lift-sqrt.f64N/A

        \[\leadsto c0 \cdot \color{blue}{\sqrt{\frac{\frac{A}{\ell}}{V}}} \]
      3. lift-/.f64N/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{A}{\ell}}{V}}} \]
      4. lift-/.f64N/A

        \[\leadsto c0 \cdot \sqrt{\frac{\color{blue}{\frac{A}{\ell}}}{V}} \]
      5. associate-/l/N/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{A}{V \cdot \ell}}} \]
      6. lift-*.f64N/A

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

        \[\leadsto c0 \cdot \color{blue}{\frac{\sqrt{A}}{\sqrt{V \cdot \ell}}} \]
      8. associate-*r/N/A

        \[\leadsto \color{blue}{\frac{c0 \cdot \sqrt{A}}{\sqrt{V \cdot \ell}}} \]
      9. associate-*l/N/A

        \[\leadsto \color{blue}{\frac{c0}{\sqrt{V \cdot \ell}} \cdot \sqrt{A}} \]
      10. associate-/r/N/A

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

        \[\leadsto \frac{c0}{\color{blue}{\sqrt{\frac{V \cdot \ell}{A}}}} \]
      12. lift-/.f64N/A

        \[\leadsto \frac{c0}{\sqrt{\color{blue}{\frac{V \cdot \ell}{A}}}} \]
      13. lift-sqrt.f64N/A

        \[\leadsto \frac{c0}{\color{blue}{\sqrt{\frac{V \cdot \ell}{A}}}} \]
      14. lower-/.f6436.3

        \[\leadsto \color{blue}{\frac{c0}{\sqrt{\frac{V \cdot \ell}{A}}}} \]
      15. lift-*.f64N/A

        \[\leadsto \frac{c0}{\sqrt{\frac{\color{blue}{V \cdot \ell}}{A}}} \]
      16. *-commutativeN/A

        \[\leadsto \frac{c0}{\sqrt{\frac{\color{blue}{\ell \cdot V}}{A}}} \]
      17. lower-*.f6436.3

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

      \[\leadsto \color{blue}{\frac{c0}{\sqrt{\frac{\ell \cdot V}{A}}}} \]
    7. Step-by-step derivation
      1. lift-sqrt.f64N/A

        \[\leadsto \frac{c0}{\color{blue}{\sqrt{\frac{\ell \cdot V}{A}}}} \]
      2. pow1/2N/A

        \[\leadsto \frac{c0}{\color{blue}{{\left(\frac{\ell \cdot V}{A}\right)}^{\frac{1}{2}}}} \]
      3. lift-/.f64N/A

        \[\leadsto \frac{c0}{{\color{blue}{\left(\frac{\ell \cdot V}{A}\right)}}^{\frac{1}{2}}} \]
      4. lift-*.f64N/A

        \[\leadsto \frac{c0}{{\left(\frac{\color{blue}{\ell \cdot V}}{A}\right)}^{\frac{1}{2}}} \]
      5. associate-/l*N/A

        \[\leadsto \frac{c0}{{\color{blue}{\left(\ell \cdot \frac{V}{A}\right)}}^{\frac{1}{2}}} \]
      6. unpow-prod-downN/A

        \[\leadsto \frac{c0}{\color{blue}{{\ell}^{\frac{1}{2}} \cdot {\left(\frac{V}{A}\right)}^{\frac{1}{2}}}} \]
      7. *-commutativeN/A

        \[\leadsto \frac{c0}{\color{blue}{{\left(\frac{V}{A}\right)}^{\frac{1}{2}} \cdot {\ell}^{\frac{1}{2}}}} \]
      8. lower-*.f64N/A

        \[\leadsto \frac{c0}{\color{blue}{{\left(\frac{V}{A}\right)}^{\frac{1}{2}} \cdot {\ell}^{\frac{1}{2}}}} \]
      9. pow1/2N/A

        \[\leadsto \frac{c0}{\color{blue}{\sqrt{\frac{V}{A}}} \cdot {\ell}^{\frac{1}{2}}} \]
      10. lower-sqrt.f64N/A

        \[\leadsto \frac{c0}{\color{blue}{\sqrt{\frac{V}{A}}} \cdot {\ell}^{\frac{1}{2}}} \]
      11. lower-/.f64N/A

        \[\leadsto \frac{c0}{\sqrt{\color{blue}{\frac{V}{A}}} \cdot {\ell}^{\frac{1}{2}}} \]
      12. pow1/2N/A

        \[\leadsto \frac{c0}{\sqrt{\frac{V}{A}} \cdot \color{blue}{\sqrt{\ell}}} \]
      13. lower-sqrt.f6482.2

        \[\leadsto \frac{c0}{\sqrt{\frac{V}{A}} \cdot \color{blue}{\sqrt{\ell}}} \]
    8. Applied rewrites82.2%

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

    if -inf.0 < (*.f64 V l) < -4.0000000000000001e-202

    1. Initial program 87.3%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{A}{V \cdot \ell}}} \]
      2. clear-numN/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{1}{\frac{V \cdot \ell}{A}}}} \]
      3. lift-*.f64N/A

        \[\leadsto c0 \cdot \sqrt{\frac{1}{\frac{\color{blue}{V \cdot \ell}}{A}}} \]
      4. associate-/l*N/A

        \[\leadsto c0 \cdot \sqrt{\frac{1}{\color{blue}{V \cdot \frac{\ell}{A}}}} \]
      5. associate-/r*N/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{1}{V}}{\frac{\ell}{A}}}} \]
      6. lower-/.f64N/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{1}{V}}{\frac{\ell}{A}}}} \]
      7. lower-/.f64N/A

        \[\leadsto c0 \cdot \sqrt{\frac{\color{blue}{\frac{1}{V}}}{\frac{\ell}{A}}} \]
      8. lower-/.f6479.1

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

      \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{1}{V}}{\frac{\ell}{A}}}} \]
    5. Step-by-step derivation
      1. lift-sqrt.f64N/A

        \[\leadsto c0 \cdot \color{blue}{\sqrt{\frac{\frac{1}{V}}{\frac{\ell}{A}}}} \]
      2. lift-/.f64N/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{1}{V}}{\frac{\ell}{A}}}} \]
      3. lift-/.f64N/A

        \[\leadsto c0 \cdot \sqrt{\frac{\frac{1}{V}}{\color{blue}{\frac{\ell}{A}}}} \]
      4. associate-/r/N/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{1}{V}}{\ell} \cdot A}} \]
      5. lift-/.f64N/A

        \[\leadsto c0 \cdot \sqrt{\frac{\color{blue}{\frac{1}{V}}}{\ell} \cdot A} \]
      6. associate-/r*N/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{1}{V \cdot \ell}} \cdot A} \]
      7. lift-*.f64N/A

        \[\leadsto c0 \cdot \sqrt{\frac{1}{\color{blue}{V \cdot \ell}} \cdot A} \]
      8. associate-*l/N/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{1 \cdot A}{V \cdot \ell}}} \]
      9. frac-2negN/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\mathsf{neg}\left(1 \cdot A\right)}{\mathsf{neg}\left(V \cdot \ell\right)}}} \]
      10. *-lft-identityN/A

        \[\leadsto c0 \cdot \sqrt{\frac{\mathsf{neg}\left(\color{blue}{A}\right)}{\mathsf{neg}\left(V \cdot \ell\right)}} \]
      11. sqrt-divN/A

        \[\leadsto c0 \cdot \color{blue}{\frac{\sqrt{\mathsf{neg}\left(A\right)}}{\sqrt{\mathsf{neg}\left(V \cdot \ell\right)}}} \]
      12. pow1/2N/A

        \[\leadsto c0 \cdot \frac{\color{blue}{{\left(\mathsf{neg}\left(A\right)\right)}^{\frac{1}{2}}}}{\sqrt{\mathsf{neg}\left(V \cdot \ell\right)}} \]
      13. lower-/.f64N/A

        \[\leadsto c0 \cdot \color{blue}{\frac{{\left(\mathsf{neg}\left(A\right)\right)}^{\frac{1}{2}}}{\sqrt{\mathsf{neg}\left(V \cdot \ell\right)}}} \]
      14. pow1/2N/A

        \[\leadsto c0 \cdot \frac{\color{blue}{\sqrt{\mathsf{neg}\left(A\right)}}}{\sqrt{\mathsf{neg}\left(V \cdot \ell\right)}} \]
      15. lower-sqrt.f64N/A

        \[\leadsto c0 \cdot \frac{\color{blue}{\sqrt{\mathsf{neg}\left(A\right)}}}{\sqrt{\mathsf{neg}\left(V \cdot \ell\right)}} \]
      16. lower-neg.f64N/A

        \[\leadsto c0 \cdot \frac{\sqrt{\color{blue}{\mathsf{neg}\left(A\right)}}}{\sqrt{\mathsf{neg}\left(V \cdot \ell\right)}} \]
      17. lower-sqrt.f64N/A

        \[\leadsto c0 \cdot \frac{\sqrt{\mathsf{neg}\left(A\right)}}{\color{blue}{\sqrt{\mathsf{neg}\left(V \cdot \ell\right)}}} \]
      18. lift-*.f64N/A

        \[\leadsto c0 \cdot \frac{\sqrt{\mathsf{neg}\left(A\right)}}{\sqrt{\mathsf{neg}\left(\color{blue}{V \cdot \ell}\right)}} \]
      19. *-commutativeN/A

        \[\leadsto c0 \cdot \frac{\sqrt{\mathsf{neg}\left(A\right)}}{\sqrt{\mathsf{neg}\left(\color{blue}{\ell \cdot V}\right)}} \]
      20. distribute-rgt-neg-inN/A

        \[\leadsto c0 \cdot \frac{\sqrt{\mathsf{neg}\left(A\right)}}{\sqrt{\color{blue}{\ell \cdot \left(\mathsf{neg}\left(V\right)\right)}}} \]
      21. lower-*.f64N/A

        \[\leadsto c0 \cdot \frac{\sqrt{\mathsf{neg}\left(A\right)}}{\sqrt{\color{blue}{\ell \cdot \left(\mathsf{neg}\left(V\right)\right)}}} \]
      22. lower-neg.f6499.4

        \[\leadsto c0 \cdot \frac{\sqrt{-A}}{\sqrt{\ell \cdot \color{blue}{\left(-V\right)}}} \]
    6. Applied rewrites99.4%

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

    if -4.0000000000000001e-202 < (*.f64 V l) < -0.0

    1. Initial program 48.9%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{A}{V \cdot \ell}}} \]
      2. lift-*.f64N/A

        \[\leadsto c0 \cdot \sqrt{\frac{A}{\color{blue}{V \cdot \ell}}} \]
      3. associate-/l/N/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{A}{\ell}}{V}}} \]
      4. lower-/.f64N/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{A}{\ell}}{V}}} \]
      5. lower-/.f6466.9

        \[\leadsto c0 \cdot \sqrt{\frac{\color{blue}{\frac{A}{\ell}}}{V}} \]
    4. Applied rewrites66.9%

      \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{A}{\ell}}{V}}} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{c0 \cdot \sqrt{\frac{\frac{A}{\ell}}{V}}} \]
      2. lift-sqrt.f64N/A

        \[\leadsto c0 \cdot \color{blue}{\sqrt{\frac{\frac{A}{\ell}}{V}}} \]
      3. lift-/.f64N/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{A}{\ell}}{V}}} \]
      4. lift-/.f64N/A

        \[\leadsto c0 \cdot \sqrt{\frac{\color{blue}{\frac{A}{\ell}}}{V}} \]
      5. associate-/l/N/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{A}{V \cdot \ell}}} \]
      6. lift-*.f64N/A

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

        \[\leadsto c0 \cdot \color{blue}{\frac{\sqrt{A}}{\sqrt{V \cdot \ell}}} \]
      8. associate-*r/N/A

        \[\leadsto \color{blue}{\frac{c0 \cdot \sqrt{A}}{\sqrt{V \cdot \ell}}} \]
      9. associate-*l/N/A

        \[\leadsto \color{blue}{\frac{c0}{\sqrt{V \cdot \ell}} \cdot \sqrt{A}} \]
      10. associate-/r/N/A

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

        \[\leadsto \frac{c0}{\color{blue}{\sqrt{\frac{V \cdot \ell}{A}}}} \]
      12. lift-/.f64N/A

        \[\leadsto \frac{c0}{\sqrt{\color{blue}{\frac{V \cdot \ell}{A}}}} \]
      13. lift-sqrt.f64N/A

        \[\leadsto \frac{c0}{\color{blue}{\sqrt{\frac{V \cdot \ell}{A}}}} \]
      14. lower-/.f6449.4

        \[\leadsto \color{blue}{\frac{c0}{\sqrt{\frac{V \cdot \ell}{A}}}} \]
      15. lift-*.f64N/A

        \[\leadsto \frac{c0}{\sqrt{\frac{\color{blue}{V \cdot \ell}}{A}}} \]
      16. *-commutativeN/A

        \[\leadsto \frac{c0}{\sqrt{\frac{\color{blue}{\ell \cdot V}}{A}}} \]
      17. lower-*.f6449.4

        \[\leadsto \frac{c0}{\sqrt{\frac{\color{blue}{\ell \cdot V}}{A}}} \]
    6. Applied rewrites49.4%

      \[\leadsto \color{blue}{\frac{c0}{\sqrt{\frac{\ell \cdot V}{A}}}} \]
    7. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \frac{c0}{\sqrt{\color{blue}{\frac{\ell \cdot V}{A}}}} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{c0}{\sqrt{\frac{\color{blue}{\ell \cdot V}}{A}}} \]
      3. associate-*l/N/A

        \[\leadsto \frac{c0}{\sqrt{\color{blue}{\frac{\ell}{A} \cdot V}}} \]
      4. lift-/.f64N/A

        \[\leadsto \frac{c0}{\sqrt{\color{blue}{\frac{\ell}{A}} \cdot V}} \]
      5. lift-*.f6467.8

        \[\leadsto \frac{c0}{\sqrt{\color{blue}{\frac{\ell}{A} \cdot V}}} \]
    8. Applied rewrites67.8%

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

    if -0.0 < (*.f64 V l) < 4e259

    1. Initial program 86.4%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-sqrt.f64N/A

        \[\leadsto c0 \cdot \color{blue}{\sqrt{\frac{A}{V \cdot \ell}}} \]
      2. lift-/.f64N/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{A}{V \cdot \ell}}} \]
      3. clear-numN/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{1}{\frac{V \cdot \ell}{A}}}} \]
      4. associate-/r/N/A

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

        \[\leadsto c0 \cdot \color{blue}{\left(\sqrt{\frac{1}{V \cdot \ell}} \cdot \sqrt{A}\right)} \]
      6. pow1/2N/A

        \[\leadsto c0 \cdot \left(\color{blue}{{\left(\frac{1}{V \cdot \ell}\right)}^{\frac{1}{2}}} \cdot \sqrt{A}\right) \]
      7. lower-*.f64N/A

        \[\leadsto c0 \cdot \color{blue}{\left({\left(\frac{1}{V \cdot \ell}\right)}^{\frac{1}{2}} \cdot \sqrt{A}\right)} \]
      8. pow1/2N/A

        \[\leadsto c0 \cdot \left(\color{blue}{\sqrt{\frac{1}{V \cdot \ell}}} \cdot \sqrt{A}\right) \]
      9. lower-sqrt.f64N/A

        \[\leadsto c0 \cdot \left(\color{blue}{\sqrt{\frac{1}{V \cdot \ell}}} \cdot \sqrt{A}\right) \]
      10. lower-/.f64N/A

        \[\leadsto c0 \cdot \left(\sqrt{\color{blue}{\frac{1}{V \cdot \ell}}} \cdot \sqrt{A}\right) \]
      11. lower-sqrt.f6498.5

        \[\leadsto c0 \cdot \left(\sqrt{\frac{1}{V \cdot \ell}} \cdot \color{blue}{\sqrt{A}}\right) \]
    4. Applied rewrites98.5%

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

    if 4e259 < (*.f64 V l)

    1. Initial program 43.9%

      \[c0 \cdot \sqrt{\frac{A}{V \cdot \ell}} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{A}{V \cdot \ell}}} \]
      2. lift-*.f64N/A

        \[\leadsto c0 \cdot \sqrt{\frac{A}{\color{blue}{V \cdot \ell}}} \]
      3. associate-/r*N/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{A}{V}}{\ell}}} \]
      4. lower-/.f64N/A

        \[\leadsto c0 \cdot \sqrt{\color{blue}{\frac{\frac{A}{V}}{\ell}}} \]
      5. lower-/.f6464.4

        \[\leadsto c0 \cdot \sqrt{\frac{\color{blue}{\frac{A}{V}}}{\ell}} \]
    4. Applied rewrites64.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \cdot V \leq -\infty:\\ \;\;\;\;\frac{c0}{\sqrt{\ell} \cdot \sqrt{\frac{V}{A}}}\\ \mathbf{elif}\;\ell \cdot V \leq -4 \cdot 10^{-202}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{-A}}{\sqrt{V \cdot \left(-\ell\right)}}\\ \mathbf{elif}\;\ell \cdot V \leq 0:\\ \;\;\;\;\frac{c0}{\sqrt{V \cdot \frac{\ell}{A}}}\\ \mathbf{elif}\;\ell \cdot V \leq 4 \cdot 10^{+259}:\\ \;\;\;\;c0 \cdot \left(\sqrt{A} \cdot \sqrt{\frac{1}{\ell \cdot V}}\right)\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{V}}{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Reproduce

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