Henrywood and Agarwal, Equation (3)

Percentage Accurate: 74.0% → 92.8%
Time: 8.1s
Alternatives: 12
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 12 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: 74.0% 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: 92.8% accurate, 0.4× speedup?

\[\begin{array}{l} [c0, A, V, l] = \mathsf{sort}([c0, A, V, l])\\ \\ \begin{array}{l} \mathbf{if}\;V \cdot \ell \leq -5 \cdot 10^{-324}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{-A}}{\sqrt{-V} \cdot \sqrt{\ell}}\\ \mathbf{elif}\;V \cdot \ell \leq 10^{-318}:\\ \;\;\;\;\frac{c0}{\sqrt{\ell} \cdot \sqrt{\frac{V}{A}}}\\ \mathbf{elif}\;V \cdot \ell \leq 4 \cdot 10^{+296}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{A}}{\sqrt{V \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{\ell}}{V}}\\ \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 (<= (* V l) -5e-324)
   (* c0 (/ (sqrt (- A)) (* (sqrt (- V)) (sqrt l))))
   (if (<= (* V l) 1e-318)
     (/ c0 (* (sqrt l) (sqrt (/ V A))))
     (if (<= (* V l) 4e+296)
       (* c0 (/ (sqrt A) (sqrt (* V l))))
       (* c0 (sqrt (/ (/ A l) V)))))))
assert(c0 < A && A < V && V < l);
double code(double c0, double A, double V, double l) {
	double tmp;
	if ((V * l) <= -5e-324) {
		tmp = c0 * (sqrt(-A) / (sqrt(-V) * sqrt(l)));
	} else if ((V * l) <= 1e-318) {
		tmp = c0 / (sqrt(l) * sqrt((V / A)));
	} else if ((V * l) <= 4e+296) {
		tmp = c0 * (sqrt(A) / sqrt((V * l)));
	} else {
		tmp = c0 * sqrt(((A / l) / V));
	}
	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) :: tmp
    if ((v * l) <= (-5d-324)) then
        tmp = c0 * (sqrt(-a) / (sqrt(-v) * sqrt(l)))
    else if ((v * l) <= 1d-318) then
        tmp = c0 / (sqrt(l) * sqrt((v / a)))
    else if ((v * l) <= 4d+296) then
        tmp = c0 * (sqrt(a) / sqrt((v * l)))
    else
        tmp = c0 * sqrt(((a / l) / v))
    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 tmp;
	if ((V * l) <= -5e-324) {
		tmp = c0 * (Math.sqrt(-A) / (Math.sqrt(-V) * Math.sqrt(l)));
	} else if ((V * l) <= 1e-318) {
		tmp = c0 / (Math.sqrt(l) * Math.sqrt((V / A)));
	} else if ((V * l) <= 4e+296) {
		tmp = c0 * (Math.sqrt(A) / Math.sqrt((V * l)));
	} else {
		tmp = c0 * Math.sqrt(((A / l) / V));
	}
	return tmp;
}
[c0, A, V, l] = sort([c0, A, V, l])
def code(c0, A, V, l):
	tmp = 0
	if (V * l) <= -5e-324:
		tmp = c0 * (math.sqrt(-A) / (math.sqrt(-V) * math.sqrt(l)))
	elif (V * l) <= 1e-318:
		tmp = c0 / (math.sqrt(l) * math.sqrt((V / A)))
	elif (V * l) <= 4e+296:
		tmp = c0 * (math.sqrt(A) / math.sqrt((V * l)))
	else:
		tmp = c0 * math.sqrt(((A / l) / V))
	return tmp
c0, A, V, l = sort([c0, A, V, l])
function code(c0, A, V, l)
	tmp = 0.0
	if (Float64(V * l) <= -5e-324)
		tmp = Float64(c0 * Float64(sqrt(Float64(-A)) / Float64(sqrt(Float64(-V)) * sqrt(l))));
	elseif (Float64(V * l) <= 1e-318)
		tmp = Float64(c0 / Float64(sqrt(l) * sqrt(Float64(V / A))));
	elseif (Float64(V * l) <= 4e+296)
		tmp = Float64(c0 * Float64(sqrt(A) / sqrt(Float64(V * l))));
	else
		tmp = Float64(c0 * sqrt(Float64(Float64(A / l) / V)));
	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 ((V * l) <= -5e-324)
		tmp = c0 * (sqrt(-A) / (sqrt(-V) * sqrt(l)));
	elseif ((V * l) <= 1e-318)
		tmp = c0 / (sqrt(l) * sqrt((V / A)));
	elseif ((V * l) <= 4e+296)
		tmp = c0 * (sqrt(A) / sqrt((V * l)));
	else
		tmp = c0 * sqrt(((A / l) / V));
	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[(V * l), $MachinePrecision], -5e-324], N[(c0 * N[(N[Sqrt[(-A)], $MachinePrecision] / N[(N[Sqrt[(-V)], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(V * l), $MachinePrecision], 1e-318], N[(c0 / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[N[(V / A), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(V * l), $MachinePrecision], 4e+296], N[(c0 * N[(N[Sqrt[A], $MachinePrecision] / N[Sqrt[N[(V * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 * N[Sqrt[N[(N[(A / l), $MachinePrecision] / V), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[c0, A, V, l] = \mathsf{sort}([c0, A, V, l])\\
\\
\begin{array}{l}
\mathbf{if}\;V \cdot \ell \leq -5 \cdot 10^{-324}:\\
\;\;\;\;c0 \cdot \frac{\sqrt{-A}}{\sqrt{-V} \cdot \sqrt{\ell}}\\

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (*.f64 V l) < -4.94066e-324

    1. Initial program 78.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. div-invN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto c0 \cdot \color{blue}{\left(\sqrt{\frac{A}{V}} \cdot \frac{1}{\sqrt{\ell}}\right)} \]
      12. frac-2negN/A

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

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

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

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

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

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

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

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

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

        \[\leadsto c0 \cdot \color{blue}{\frac{\sqrt{\mathsf{neg}\left(A\right)} \cdot -1}{\sqrt{\mathsf{neg}\left(V\right)} \cdot \left(\mathsf{neg}\left(\sqrt{\ell}\right)\right)}} \]
    6. Applied rewrites97.8%

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

    if -4.94066e-324 < (*.f64 V l) < 9.9999875e-319

    1. Initial program 36.6%

      \[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. div-invN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 9.9999875e-319 < (*.f64 V l) < 3.99999999999999993e296

    1. Initial program 84.2%

      \[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. sqrt-divN/A

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

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

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

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

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

    if 3.99999999999999993e296 < (*.f64 V l)

    1. Initial program 37.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-/.f6468.1

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;V \cdot \ell \leq -5 \cdot 10^{-324}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{-A}}{\sqrt{-V} \cdot \sqrt{\ell}}\\ \mathbf{elif}\;V \cdot \ell \leq 10^{-318}:\\ \;\;\;\;\frac{c0}{\sqrt{\ell} \cdot \sqrt{\frac{V}{A}}}\\ \mathbf{elif}\;V \cdot \ell \leq 4 \cdot 10^{+296}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{A}}{\sqrt{V \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{\ell}}{V}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 92.1% accurate, 0.4× speedup?

\[\begin{array}{l} [c0, A, V, l] = \mathsf{sort}([c0, A, V, l])\\ \\ \begin{array}{l} \mathbf{if}\;V \cdot \ell \leq -\infty:\\ \;\;\;\;c0 \cdot \left(\sqrt{\frac{A}{-\ell}} \cdot \sqrt{\frac{-1}{V}}\right)\\ \mathbf{elif}\;V \cdot \ell \leq -5 \cdot 10^{-324}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{-A}}{\sqrt{V \cdot \left(-\ell\right)}}\\ \mathbf{elif}\;V \cdot \ell \leq 10^{-318}:\\ \;\;\;\;\frac{c0}{\sqrt{\ell} \cdot \sqrt{\frac{V}{A}}}\\ \mathbf{elif}\;V \cdot \ell \leq 4 \cdot 10^{+296}:\\ \;\;\;\;c0 \cdot \frac{\sqrt{A}}{\sqrt{V \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \sqrt{\frac{\frac{A}{\ell}}{V}}\\ \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 (<= (* V l) (- INFINITY))
   (* c0 (* (sqrt (/ A (- l))) (sqrt (/ -1.0 V))))
   (if (<= (* V l) -5e-324)
     (* c0 (/ (sqrt (- A)) (sqrt (* V (- l)))))
     (if (<= (* V l) 1e-318)
       (/ c0 (* (sqrt l) (sqrt (/ V A))))
       (if (<= (* V l) 4e+296)
         (* c0 (/ (sqrt A) (sqrt (* V l))))
         (* c0 (sqrt (/ (/ A l) V))))))))
assert(c0 < A && A < V && V < l);
double code(double c0, double A, double V, double l) {
	double tmp;
	if ((V * l) <= -((double) INFINITY)) {
		tmp = c0 * (sqrt((A / -l)) * sqrt((-1.0 / V)));
	} else if ((V * l) <= -5e-324) {
		tmp = c0 * (sqrt(-A) / sqrt((V * -l)));
	} else if ((V * l) <= 1e-318) {
		tmp = c0 / (sqrt(l) * sqrt((V / A)));
	} else if ((V * l) <= 4e+296) {
		tmp = c0 * (sqrt(A) / sqrt((V * l)));
	} else {
		tmp = c0 * sqrt(((A / l) / V));
	}
	return tmp;
}
assert c0 < A && A < V && V < l;
public static double code(double c0, double A, double V, double l) {
	double tmp;
	if ((V * l) <= -Double.POSITIVE_INFINITY) {
		tmp = c0 * (Math.sqrt((A / -l)) * Math.sqrt((-1.0 / V)));
	} else if ((V * l) <= -5e-324) {
		tmp = c0 * (Math.sqrt(-A) / Math.sqrt((V * -l)));
	} else if ((V * l) <= 1e-318) {
		tmp = c0 / (Math.sqrt(l) * Math.sqrt((V / A)));
	} else if ((V * l) <= 4e+296) {
		tmp = c0 * (Math.sqrt(A) / Math.sqrt((V * l)));
	} else {
		tmp = c0 * Math.sqrt(((A / l) / V));
	}
	return tmp;
}
[c0, A, V, l] = sort([c0, A, V, l])
def code(c0, A, V, l):
	tmp = 0
	if (V * l) <= -math.inf:
		tmp = c0 * (math.sqrt((A / -l)) * math.sqrt((-1.0 / V)))
	elif (V * l) <= -5e-324:
		tmp = c0 * (math.sqrt(-A) / math.sqrt((V * -l)))
	elif (V * l) <= 1e-318:
		tmp = c0 / (math.sqrt(l) * math.sqrt((V / A)))
	elif (V * l) <= 4e+296:
		tmp = c0 * (math.sqrt(A) / math.sqrt((V * l)))
	else:
		tmp = c0 * math.sqrt(((A / l) / V))
	return tmp
c0, A, V, l = sort([c0, A, V, l])
function code(c0, A, V, l)
	tmp = 0.0
	if (Float64(V * l) <= Float64(-Inf))
		tmp = Float64(c0 * Float64(sqrt(Float64(A / Float64(-l))) * sqrt(Float64(-1.0 / V))));
	elseif (Float64(V * l) <= -5e-324)
		tmp = Float64(c0 * Float64(sqrt(Float64(-A)) / sqrt(Float64(V * Float64(-l)))));
	elseif (Float64(V * l) <= 1e-318)
		tmp = Float64(c0 / Float64(sqrt(l) * sqrt(Float64(V / A))));
	elseif (Float64(V * l) <= 4e+296)
		tmp = Float64(c0 * Float64(sqrt(A) / sqrt(Float64(V * l))));
	else
		tmp = Float64(c0 * sqrt(Float64(Float64(A / l) / V)));
	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 ((V * l) <= -Inf)
		tmp = c0 * (sqrt((A / -l)) * sqrt((-1.0 / V)));
	elseif ((V * l) <= -5e-324)
		tmp = c0 * (sqrt(-A) / sqrt((V * -l)));
	elseif ((V * l) <= 1e-318)
		tmp = c0 / (sqrt(l) * sqrt((V / A)));
	elseif ((V * l) <= 4e+296)
		tmp = c0 * (sqrt(A) / sqrt((V * l)));
	else
		tmp = c0 * sqrt(((A / l) / V));
	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[(V * l), $MachinePrecision], (-Infinity)], N[(c0 * N[(N[Sqrt[N[(A / (-l)), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(-1.0 / V), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(V * l), $MachinePrecision], -5e-324], N[(c0 * N[(N[Sqrt[(-A)], $MachinePrecision] / N[Sqrt[N[(V * (-l)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(V * l), $MachinePrecision], 1e-318], N[(c0 / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[N[(V / A), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(V * l), $MachinePrecision], 4e+296], N[(c0 * N[(N[Sqrt[A], $MachinePrecision] / N[Sqrt[N[(V * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 * N[Sqrt[N[(N[(A / l), $MachinePrecision] / V), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
[c0, A, V, l] = \mathsf{sort}([c0, A, V, l])\\
\\
\begin{array}{l}
\mathbf{if}\;V \cdot \ell \leq -\infty:\\
\;\;\;\;c0 \cdot \left(\sqrt{\frac{A}{-\ell}} \cdot \sqrt{\frac{-1}{V}}\right)\\

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

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

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

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


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

    1. Initial program 36.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. 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.9

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -inf.0 < (*.f64 V l) < -4.94066e-324

    1. Initial program 85.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-/.f6478.0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.94066e-324 < (*.f64 V l) < 9.9999875e-319

    1. Initial program 39.0%

      \[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. div-invN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 9.9999875e-319 < (*.f64 V l) < 3.99999999999999993e296

    1. Initial program 86.0%

      \[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. sqrt-divN/A

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

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

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

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

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

    if 3.99999999999999993e296 < (*.f64 V l)

    1. Initial program 37.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-/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-/.f6464.9

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

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

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

Reproduce

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