Toniolo and Linder, Equation (13)

Percentage Accurate: 50.5% → 59.4%
Time: 8.3s
Alternatives: 11
Speedup: 0.4×

Specification

?
\[\begin{array}{l} \\ \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \frac{\ell \cdot \ell}{Om}\right) - \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)} \end{array} \]
(FPCore (n U t l Om U*)
 :precision binary64
 (sqrt
  (*
   (* (* 2.0 n) U)
   (- (- t (* 2.0 (/ (* l l) Om))) (* (* n (pow (/ l Om) 2.0)) (- U U*))))))
double code(double n, double U, double t, double l, double Om, double U_42_) {
	return sqrt((((2.0 * n) * U) * ((t - (2.0 * ((l * l) / Om))) - ((n * pow((l / Om), 2.0)) * (U - U_42_)))));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(n, u, t, l, om, u_42)
use fmin_fmax_functions
    real(8), intent (in) :: n
    real(8), intent (in) :: u
    real(8), intent (in) :: t
    real(8), intent (in) :: l
    real(8), intent (in) :: om
    real(8), intent (in) :: u_42
    code = sqrt((((2.0d0 * n) * u) * ((t - (2.0d0 * ((l * l) / om))) - ((n * ((l / om) ** 2.0d0)) * (u - u_42)))))
end function
public static double code(double n, double U, double t, double l, double Om, double U_42_) {
	return Math.sqrt((((2.0 * n) * U) * ((t - (2.0 * ((l * l) / Om))) - ((n * Math.pow((l / Om), 2.0)) * (U - U_42_)))));
}
def code(n, U, t, l, Om, U_42_):
	return math.sqrt((((2.0 * n) * U) * ((t - (2.0 * ((l * l) / Om))) - ((n * math.pow((l / Om), 2.0)) * (U - U_42_)))))
function code(n, U, t, l, Om, U_42_)
	return sqrt(Float64(Float64(Float64(2.0 * n) * U) * Float64(Float64(t - Float64(2.0 * Float64(Float64(l * l) / Om))) - Float64(Float64(n * (Float64(l / Om) ^ 2.0)) * Float64(U - U_42_)))))
end
function tmp = code(n, U, t, l, Om, U_42_)
	tmp = sqrt((((2.0 * n) * U) * ((t - (2.0 * ((l * l) / Om))) - ((n * ((l / Om) ^ 2.0)) * (U - U_42_)))));
end
code[n_, U_, t_, l_, Om_, U$42$_] := N[Sqrt[N[(N[(N[(2.0 * n), $MachinePrecision] * U), $MachinePrecision] * N[(N[(t - N[(2.0 * N[(N[(l * l), $MachinePrecision] / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(n * N[Power[N[(l / Om), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(U - U$42$), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

\\
\sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \frac{\ell \cdot \ell}{Om}\right) - \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)}
\end{array}

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 11 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: 50.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \frac{\ell \cdot \ell}{Om}\right) - \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)} \end{array} \]
(FPCore (n U t l Om U*)
 :precision binary64
 (sqrt
  (*
   (* (* 2.0 n) U)
   (- (- t (* 2.0 (/ (* l l) Om))) (* (* n (pow (/ l Om) 2.0)) (- U U*))))))
double code(double n, double U, double t, double l, double Om, double U_42_) {
	return sqrt((((2.0 * n) * U) * ((t - (2.0 * ((l * l) / Om))) - ((n * pow((l / Om), 2.0)) * (U - U_42_)))));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(n, u, t, l, om, u_42)
use fmin_fmax_functions
    real(8), intent (in) :: n
    real(8), intent (in) :: u
    real(8), intent (in) :: t
    real(8), intent (in) :: l
    real(8), intent (in) :: om
    real(8), intent (in) :: u_42
    code = sqrt((((2.0d0 * n) * u) * ((t - (2.0d0 * ((l * l) / om))) - ((n * ((l / om) ** 2.0d0)) * (u - u_42)))))
end function
public static double code(double n, double U, double t, double l, double Om, double U_42_) {
	return Math.sqrt((((2.0 * n) * U) * ((t - (2.0 * ((l * l) / Om))) - ((n * Math.pow((l / Om), 2.0)) * (U - U_42_)))));
}
def code(n, U, t, l, Om, U_42_):
	return math.sqrt((((2.0 * n) * U) * ((t - (2.0 * ((l * l) / Om))) - ((n * math.pow((l / Om), 2.0)) * (U - U_42_)))))
function code(n, U, t, l, Om, U_42_)
	return sqrt(Float64(Float64(Float64(2.0 * n) * U) * Float64(Float64(t - Float64(2.0 * Float64(Float64(l * l) / Om))) - Float64(Float64(n * (Float64(l / Om) ^ 2.0)) * Float64(U - U_42_)))))
end
function tmp = code(n, U, t, l, Om, U_42_)
	tmp = sqrt((((2.0 * n) * U) * ((t - (2.0 * ((l * l) / Om))) - ((n * ((l / Om) ^ 2.0)) * (U - U_42_)))));
end
code[n_, U_, t_, l_, Om_, U$42$_] := N[Sqrt[N[(N[(N[(2.0 * n), $MachinePrecision] * U), $MachinePrecision] * N[(N[(t - N[(2.0 * N[(N[(l * l), $MachinePrecision] / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(n * N[Power[N[(l / Om), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(U - U$42$), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

\\
\sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \frac{\ell \cdot \ell}{Om}\right) - \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)}
\end{array}

Alternative 1: 59.4% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \frac{\ell \cdot \ell}{Om}\right) - \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)}\\ \mathbf{if}\;t\_1 \leq 0:\\ \;\;\;\;-1 \cdot \left(\left(\sqrt{U} \cdot \sqrt{n \cdot t}\right) \cdot \left(-1 \cdot \sqrt{2}\right)\right)\\ \mathbf{elif}\;t\_1 \leq \infty:\\ \;\;\;\;\sqrt{\left(\mathsf{fma}\left(-2, \ell \cdot \frac{\ell}{Om}, t\right) - n \cdot \left(\left(\frac{\ell}{Om} \cdot \frac{\ell}{Om}\right) \cdot \left(U - U*\right)\right)\right) \cdot \left(\left(n + n\right) \cdot U\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\left(\left(\left(\left(\ell \cdot \ell\right) \cdot n\right) \cdot \mathsf{fma}\left(n, \frac{U - U*}{Om \cdot Om}, \frac{2}{Om}\right)\right) \cdot U\right) \cdot -2}\\ \end{array} \end{array} \]
(FPCore (n U t l Om U*)
 :precision binary64
 (let* ((t_1
         (sqrt
          (*
           (* (* 2.0 n) U)
           (-
            (- t (* 2.0 (/ (* l l) Om)))
            (* (* n (pow (/ l Om) 2.0)) (- U U*)))))))
   (if (<= t_1 0.0)
     (* -1.0 (* (* (sqrt U) (sqrt (* n t))) (* -1.0 (sqrt 2.0))))
     (if (<= t_1 INFINITY)
       (sqrt
        (*
         (-
          (fma -2.0 (* l (/ l Om)) t)
          (* n (* (* (/ l Om) (/ l Om)) (- U U*))))
         (* (+ n n) U)))
       (sqrt
        (*
         (* (* (* (* l l) n) (fma n (/ (- U U*) (* Om Om)) (/ 2.0 Om))) U)
         -2.0))))))
double code(double n, double U, double t, double l, double Om, double U_42_) {
	double t_1 = sqrt((((2.0 * n) * U) * ((t - (2.0 * ((l * l) / Om))) - ((n * pow((l / Om), 2.0)) * (U - U_42_)))));
	double tmp;
	if (t_1 <= 0.0) {
		tmp = -1.0 * ((sqrt(U) * sqrt((n * t))) * (-1.0 * sqrt(2.0)));
	} else if (t_1 <= ((double) INFINITY)) {
		tmp = sqrt(((fma(-2.0, (l * (l / Om)), t) - (n * (((l / Om) * (l / Om)) * (U - U_42_)))) * ((n + n) * U)));
	} else {
		tmp = sqrt((((((l * l) * n) * fma(n, ((U - U_42_) / (Om * Om)), (2.0 / Om))) * U) * -2.0));
	}
	return tmp;
}
function code(n, U, t, l, Om, U_42_)
	t_1 = sqrt(Float64(Float64(Float64(2.0 * n) * U) * Float64(Float64(t - Float64(2.0 * Float64(Float64(l * l) / Om))) - Float64(Float64(n * (Float64(l / Om) ^ 2.0)) * Float64(U - U_42_)))))
	tmp = 0.0
	if (t_1 <= 0.0)
		tmp = Float64(-1.0 * Float64(Float64(sqrt(U) * sqrt(Float64(n * t))) * Float64(-1.0 * sqrt(2.0))));
	elseif (t_1 <= Inf)
		tmp = sqrt(Float64(Float64(fma(-2.0, Float64(l * Float64(l / Om)), t) - Float64(n * Float64(Float64(Float64(l / Om) * Float64(l / Om)) * Float64(U - U_42_)))) * Float64(Float64(n + n) * U)));
	else
		tmp = sqrt(Float64(Float64(Float64(Float64(Float64(l * l) * n) * fma(n, Float64(Float64(U - U_42_) / Float64(Om * Om)), Float64(2.0 / Om))) * U) * -2.0));
	end
	return tmp
end
code[n_, U_, t_, l_, Om_, U$42$_] := Block[{t$95$1 = N[Sqrt[N[(N[(N[(2.0 * n), $MachinePrecision] * U), $MachinePrecision] * N[(N[(t - N[(2.0 * N[(N[(l * l), $MachinePrecision] / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(n * N[Power[N[(l / Om), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(U - U$42$), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$1, 0.0], N[(-1.0 * N[(N[(N[Sqrt[U], $MachinePrecision] * N[Sqrt[N[(n * t), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(-1.0 * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[Sqrt[N[(N[(N[(-2.0 * N[(l * N[(l / Om), $MachinePrecision]), $MachinePrecision] + t), $MachinePrecision] - N[(n * N[(N[(N[(l / Om), $MachinePrecision] * N[(l / Om), $MachinePrecision]), $MachinePrecision] * N[(U - U$42$), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(n + n), $MachinePrecision] * U), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[N[(N[(N[(N[(N[(l * l), $MachinePrecision] * n), $MachinePrecision] * N[(n * N[(N[(U - U$42$), $MachinePrecision] / N[(Om * Om), $MachinePrecision]), $MachinePrecision] + N[(2.0 / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * U), $MachinePrecision] * -2.0), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \frac{\ell \cdot \ell}{Om}\right) - \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)}\\
\mathbf{if}\;t\_1 \leq 0:\\
\;\;\;\;-1 \cdot \left(\left(\sqrt{U} \cdot \sqrt{n \cdot t}\right) \cdot \left(-1 \cdot \sqrt{2}\right)\right)\\

\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;\sqrt{\left(\mathsf{fma}\left(-2, \ell \cdot \frac{\ell}{Om}, t\right) - n \cdot \left(\left(\frac{\ell}{Om} \cdot \frac{\ell}{Om}\right) \cdot \left(U - U*\right)\right)\right) \cdot \left(\left(n + n\right) \cdot U\right)}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{\left(\left(\left(\left(\ell \cdot \ell\right) \cdot n\right) \cdot \mathsf{fma}\left(n, \frac{U - U*}{Om \cdot Om}, \frac{2}{Om}\right)\right) \cdot U\right) \cdot -2}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (sqrt.f64 (*.f64 (*.f64 (*.f64 #s(literal 2 binary64) n) U) (-.f64 (-.f64 t (*.f64 #s(literal 2 binary64) (/.f64 (*.f64 l l) Om))) (*.f64 (*.f64 n (pow.f64 (/.f64 l Om) #s(literal 2 binary64))) (-.f64 U U*))))) < 0.0

    1. Initial program 50.5%

      \[\sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \frac{\ell \cdot \ell}{Om}\right) - \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)} \]
    2. Applied rewrites53.0%

      \[\leadsto \sqrt{\color{blue}{\left(\mathsf{fma}\left(-2, \ell \cdot \frac{\ell}{Om}, t\right) - n \cdot \left(\left(\frac{\ell}{Om} \cdot \frac{\ell}{Om}\right) \cdot \left(U - U*\right)\right)\right) \cdot \left(\left(n + n\right) \cdot U\right)}} \]
    3. Taylor expanded in t around -inf

      \[\leadsto \color{blue}{-1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left({\left(\sqrt{-1}\right)}^{2} \cdot \sqrt{2}\right)\right)} \]
    4. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto -1 \cdot \color{blue}{\left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left({\left(\sqrt{-1}\right)}^{2} \cdot \sqrt{2}\right)\right)} \]
      2. lower-*.f64N/A

        \[\leadsto -1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \color{blue}{\left({\left(\sqrt{-1}\right)}^{2} \cdot \sqrt{2}\right)}\right) \]
      3. lower-sqrt.f64N/A

        \[\leadsto -1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left(\color{blue}{{\left(\sqrt{-1}\right)}^{2}} \cdot \sqrt{2}\right)\right) \]
      4. lower-*.f64N/A

        \[\leadsto -1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left({\color{blue}{\left(\sqrt{-1}\right)}}^{2} \cdot \sqrt{2}\right)\right) \]
      5. lower-*.f64N/A

        \[\leadsto -1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left({\left(\sqrt{-1}\right)}^{2} \cdot \sqrt{2}\right)\right) \]
      6. sqrt-pow2N/A

        \[\leadsto -1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left({-1}^{\left(\frac{2}{2}\right)} \cdot \sqrt{\color{blue}{2}}\right)\right) \]
      7. metadata-evalN/A

        \[\leadsto -1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left({-1}^{1} \cdot \sqrt{2}\right)\right) \]
      8. metadata-evalN/A

        \[\leadsto -1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left(-1 \cdot \sqrt{\color{blue}{2}}\right)\right) \]
      9. lower-*.f64N/A

        \[\leadsto -1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left(-1 \cdot \color{blue}{\sqrt{2}}\right)\right) \]
      10. lower-sqrt.f6436.0

        \[\leadsto -1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left(-1 \cdot \sqrt{2}\right)\right) \]
    5. Applied rewrites36.0%

      \[\leadsto \color{blue}{-1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left(-1 \cdot \sqrt{2}\right)\right)} \]
    6. Step-by-step derivation
      1. lift-sqrt.f64N/A

        \[\leadsto -1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left(\color{blue}{-1} \cdot \sqrt{2}\right)\right) \]
      2. lift-*.f64N/A

        \[\leadsto -1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left(-1 \cdot \sqrt{2}\right)\right) \]
      3. lift-*.f64N/A

        \[\leadsto -1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left(-1 \cdot \sqrt{2}\right)\right) \]
      4. sqrt-prodN/A

        \[\leadsto -1 \cdot \left(\left(\sqrt{U} \cdot \sqrt{n \cdot t}\right) \cdot \left(\color{blue}{-1} \cdot \sqrt{2}\right)\right) \]
      5. lower-*.f64N/A

        \[\leadsto -1 \cdot \left(\left(\sqrt{U} \cdot \sqrt{n \cdot t}\right) \cdot \left(\color{blue}{-1} \cdot \sqrt{2}\right)\right) \]
      6. lower-sqrt.f64N/A

        \[\leadsto -1 \cdot \left(\left(\sqrt{U} \cdot \sqrt{n \cdot t}\right) \cdot \left(-1 \cdot \sqrt{2}\right)\right) \]
      7. lower-sqrt.f64N/A

        \[\leadsto -1 \cdot \left(\left(\sqrt{U} \cdot \sqrt{n \cdot t}\right) \cdot \left(-1 \cdot \sqrt{2}\right)\right) \]
      8. lift-*.f6421.1

        \[\leadsto -1 \cdot \left(\left(\sqrt{U} \cdot \sqrt{n \cdot t}\right) \cdot \left(-1 \cdot \sqrt{2}\right)\right) \]
    7. Applied rewrites21.1%

      \[\leadsto -1 \cdot \left(\left(\sqrt{U} \cdot \sqrt{n \cdot t}\right) \cdot \left(\color{blue}{-1} \cdot \sqrt{2}\right)\right) \]

    if 0.0 < (sqrt.f64 (*.f64 (*.f64 (*.f64 #s(literal 2 binary64) n) U) (-.f64 (-.f64 t (*.f64 #s(literal 2 binary64) (/.f64 (*.f64 l l) Om))) (*.f64 (*.f64 n (pow.f64 (/.f64 l Om) #s(literal 2 binary64))) (-.f64 U U*))))) < +inf.0

    1. Initial program 50.5%

      \[\sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \frac{\ell \cdot \ell}{Om}\right) - \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)} \]
    2. Applied rewrites53.0%

      \[\leadsto \sqrt{\color{blue}{\left(\mathsf{fma}\left(-2, \ell \cdot \frac{\ell}{Om}, t\right) - n \cdot \left(\left(\frac{\ell}{Om} \cdot \frac{\ell}{Om}\right) \cdot \left(U - U*\right)\right)\right) \cdot \left(\left(n + n\right) \cdot U\right)}} \]

    if +inf.0 < (sqrt.f64 (*.f64 (*.f64 (*.f64 #s(literal 2 binary64) n) U) (-.f64 (-.f64 t (*.f64 #s(literal 2 binary64) (/.f64 (*.f64 l l) Om))) (*.f64 (*.f64 n (pow.f64 (/.f64 l Om) #s(literal 2 binary64))) (-.f64 U U*)))))

    1. Initial program 50.5%

      \[\sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \frac{\ell \cdot \ell}{Om}\right) - \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)} \]
    2. Taylor expanded in l around inf

      \[\leadsto \sqrt{\color{blue}{-2 \cdot \left(U \cdot \left({\ell}^{2} \cdot \left(n \cdot \left(2 \cdot \frac{1}{Om} + \frac{n \cdot \left(U - U*\right)}{{Om}^{2}}\right)\right)\right)\right)}} \]
    3. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \sqrt{\left(U \cdot \left({\ell}^{2} \cdot \left(n \cdot \left(2 \cdot \frac{1}{Om} + \frac{n \cdot \left(U - U*\right)}{{Om}^{2}}\right)\right)\right)\right) \cdot \color{blue}{-2}} \]
      2. lower-*.f64N/A

        \[\leadsto \sqrt{\left(U \cdot \left({\ell}^{2} \cdot \left(n \cdot \left(2 \cdot \frac{1}{Om} + \frac{n \cdot \left(U - U*\right)}{{Om}^{2}}\right)\right)\right)\right) \cdot \color{blue}{-2}} \]
    4. Applied rewrites20.6%

      \[\leadsto \sqrt{\color{blue}{\left(\left(\left(\left(\ell \cdot \ell\right) \cdot n\right) \cdot \mathsf{fma}\left(n, \frac{U - U*}{Om \cdot Om}, \frac{2}{Om}\right)\right) \cdot U\right) \cdot -2}} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 2: 53.3% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \left(2 \cdot n\right) \cdot U\\ t_2 := \sqrt{t\_1 \cdot \left(\left(t - 2 \cdot \frac{\ell \cdot \ell}{Om}\right) - \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)}\\ \mathbf{if}\;t\_2 \leq 0:\\ \;\;\;\;-1 \cdot \left(\left(\sqrt{U} \cdot \sqrt{n \cdot t}\right) \cdot \left(-1 \cdot \sqrt{2}\right)\right)\\ \mathbf{elif}\;t\_2 \leq \infty:\\ \;\;\;\;\sqrt{t\_1 \cdot \mathsf{fma}\left(-2, \ell \cdot \frac{\ell}{Om}, t\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\left(\left(\left(\left(\ell \cdot \ell\right) \cdot n\right) \cdot \mathsf{fma}\left(n, \frac{U - U*}{Om \cdot Om}, \frac{2}{Om}\right)\right) \cdot U\right) \cdot -2}\\ \end{array} \end{array} \]
(FPCore (n U t l Om U*)
 :precision binary64
 (let* ((t_1 (* (* 2.0 n) U))
        (t_2
         (sqrt
          (*
           t_1
           (-
            (- t (* 2.0 (/ (* l l) Om)))
            (* (* n (pow (/ l Om) 2.0)) (- U U*)))))))
   (if (<= t_2 0.0)
     (* -1.0 (* (* (sqrt U) (sqrt (* n t))) (* -1.0 (sqrt 2.0))))
     (if (<= t_2 INFINITY)
       (sqrt (* t_1 (fma -2.0 (* l (/ l Om)) t)))
       (sqrt
        (*
         (* (* (* (* l l) n) (fma n (/ (- U U*) (* Om Om)) (/ 2.0 Om))) U)
         -2.0))))))
double code(double n, double U, double t, double l, double Om, double U_42_) {
	double t_1 = (2.0 * n) * U;
	double t_2 = sqrt((t_1 * ((t - (2.0 * ((l * l) / Om))) - ((n * pow((l / Om), 2.0)) * (U - U_42_)))));
	double tmp;
	if (t_2 <= 0.0) {
		tmp = -1.0 * ((sqrt(U) * sqrt((n * t))) * (-1.0 * sqrt(2.0)));
	} else if (t_2 <= ((double) INFINITY)) {
		tmp = sqrt((t_1 * fma(-2.0, (l * (l / Om)), t)));
	} else {
		tmp = sqrt((((((l * l) * n) * fma(n, ((U - U_42_) / (Om * Om)), (2.0 / Om))) * U) * -2.0));
	}
	return tmp;
}
function code(n, U, t, l, Om, U_42_)
	t_1 = Float64(Float64(2.0 * n) * U)
	t_2 = sqrt(Float64(t_1 * Float64(Float64(t - Float64(2.0 * Float64(Float64(l * l) / Om))) - Float64(Float64(n * (Float64(l / Om) ^ 2.0)) * Float64(U - U_42_)))))
	tmp = 0.0
	if (t_2 <= 0.0)
		tmp = Float64(-1.0 * Float64(Float64(sqrt(U) * sqrt(Float64(n * t))) * Float64(-1.0 * sqrt(2.0))));
	elseif (t_2 <= Inf)
		tmp = sqrt(Float64(t_1 * fma(-2.0, Float64(l * Float64(l / Om)), t)));
	else
		tmp = sqrt(Float64(Float64(Float64(Float64(Float64(l * l) * n) * fma(n, Float64(Float64(U - U_42_) / Float64(Om * Om)), Float64(2.0 / Om))) * U) * -2.0));
	end
	return tmp
end
code[n_, U_, t_, l_, Om_, U$42$_] := Block[{t$95$1 = N[(N[(2.0 * n), $MachinePrecision] * U), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(t$95$1 * N[(N[(t - N[(2.0 * N[(N[(l * l), $MachinePrecision] / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(n * N[Power[N[(l / Om), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(U - U$42$), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$2, 0.0], N[(-1.0 * N[(N[(N[Sqrt[U], $MachinePrecision] * N[Sqrt[N[(n * t), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(-1.0 * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, Infinity], N[Sqrt[N[(t$95$1 * N[(-2.0 * N[(l * N[(l / Om), $MachinePrecision]), $MachinePrecision] + t), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[N[(N[(N[(N[(N[(l * l), $MachinePrecision] * n), $MachinePrecision] * N[(n * N[(N[(U - U$42$), $MachinePrecision] / N[(Om * Om), $MachinePrecision]), $MachinePrecision] + N[(2.0 / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * U), $MachinePrecision] * -2.0), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \left(2 \cdot n\right) \cdot U\\
t_2 := \sqrt{t\_1 \cdot \left(\left(t - 2 \cdot \frac{\ell \cdot \ell}{Om}\right) - \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)}\\
\mathbf{if}\;t\_2 \leq 0:\\
\;\;\;\;-1 \cdot \left(\left(\sqrt{U} \cdot \sqrt{n \cdot t}\right) \cdot \left(-1 \cdot \sqrt{2}\right)\right)\\

\mathbf{elif}\;t\_2 \leq \infty:\\
\;\;\;\;\sqrt{t\_1 \cdot \mathsf{fma}\left(-2, \ell \cdot \frac{\ell}{Om}, t\right)}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{\left(\left(\left(\left(\ell \cdot \ell\right) \cdot n\right) \cdot \mathsf{fma}\left(n, \frac{U - U*}{Om \cdot Om}, \frac{2}{Om}\right)\right) \cdot U\right) \cdot -2}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (sqrt.f64 (*.f64 (*.f64 (*.f64 #s(literal 2 binary64) n) U) (-.f64 (-.f64 t (*.f64 #s(literal 2 binary64) (/.f64 (*.f64 l l) Om))) (*.f64 (*.f64 n (pow.f64 (/.f64 l Om) #s(literal 2 binary64))) (-.f64 U U*))))) < 0.0

    1. Initial program 50.5%

      \[\sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \frac{\ell \cdot \ell}{Om}\right) - \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)} \]
    2. Applied rewrites53.0%

      \[\leadsto \sqrt{\color{blue}{\left(\mathsf{fma}\left(-2, \ell \cdot \frac{\ell}{Om}, t\right) - n \cdot \left(\left(\frac{\ell}{Om} \cdot \frac{\ell}{Om}\right) \cdot \left(U - U*\right)\right)\right) \cdot \left(\left(n + n\right) \cdot U\right)}} \]
    3. Taylor expanded in t around -inf

      \[\leadsto \color{blue}{-1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left({\left(\sqrt{-1}\right)}^{2} \cdot \sqrt{2}\right)\right)} \]
    4. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto -1 \cdot \color{blue}{\left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left({\left(\sqrt{-1}\right)}^{2} \cdot \sqrt{2}\right)\right)} \]
      2. lower-*.f64N/A

        \[\leadsto -1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \color{blue}{\left({\left(\sqrt{-1}\right)}^{2} \cdot \sqrt{2}\right)}\right) \]
      3. lower-sqrt.f64N/A

        \[\leadsto -1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left(\color{blue}{{\left(\sqrt{-1}\right)}^{2}} \cdot \sqrt{2}\right)\right) \]
      4. lower-*.f64N/A

        \[\leadsto -1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left({\color{blue}{\left(\sqrt{-1}\right)}}^{2} \cdot \sqrt{2}\right)\right) \]
      5. lower-*.f64N/A

        \[\leadsto -1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left({\left(\sqrt{-1}\right)}^{2} \cdot \sqrt{2}\right)\right) \]
      6. sqrt-pow2N/A

        \[\leadsto -1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left({-1}^{\left(\frac{2}{2}\right)} \cdot \sqrt{\color{blue}{2}}\right)\right) \]
      7. metadata-evalN/A

        \[\leadsto -1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left({-1}^{1} \cdot \sqrt{2}\right)\right) \]
      8. metadata-evalN/A

        \[\leadsto -1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left(-1 \cdot \sqrt{\color{blue}{2}}\right)\right) \]
      9. lower-*.f64N/A

        \[\leadsto -1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left(-1 \cdot \color{blue}{\sqrt{2}}\right)\right) \]
      10. lower-sqrt.f6436.0

        \[\leadsto -1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left(-1 \cdot \sqrt{2}\right)\right) \]
    5. Applied rewrites36.0%

      \[\leadsto \color{blue}{-1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left(-1 \cdot \sqrt{2}\right)\right)} \]
    6. Step-by-step derivation
      1. lift-sqrt.f64N/A

        \[\leadsto -1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left(\color{blue}{-1} \cdot \sqrt{2}\right)\right) \]
      2. lift-*.f64N/A

        \[\leadsto -1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left(-1 \cdot \sqrt{2}\right)\right) \]
      3. lift-*.f64N/A

        \[\leadsto -1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left(-1 \cdot \sqrt{2}\right)\right) \]
      4. sqrt-prodN/A

        \[\leadsto -1 \cdot \left(\left(\sqrt{U} \cdot \sqrt{n \cdot t}\right) \cdot \left(\color{blue}{-1} \cdot \sqrt{2}\right)\right) \]
      5. lower-*.f64N/A

        \[\leadsto -1 \cdot \left(\left(\sqrt{U} \cdot \sqrt{n \cdot t}\right) \cdot \left(\color{blue}{-1} \cdot \sqrt{2}\right)\right) \]
      6. lower-sqrt.f64N/A

        \[\leadsto -1 \cdot \left(\left(\sqrt{U} \cdot \sqrt{n \cdot t}\right) \cdot \left(-1 \cdot \sqrt{2}\right)\right) \]
      7. lower-sqrt.f64N/A

        \[\leadsto -1 \cdot \left(\left(\sqrt{U} \cdot \sqrt{n \cdot t}\right) \cdot \left(-1 \cdot \sqrt{2}\right)\right) \]
      8. lift-*.f6421.1

        \[\leadsto -1 \cdot \left(\left(\sqrt{U} \cdot \sqrt{n \cdot t}\right) \cdot \left(-1 \cdot \sqrt{2}\right)\right) \]
    7. Applied rewrites21.1%

      \[\leadsto -1 \cdot \left(\left(\sqrt{U} \cdot \sqrt{n \cdot t}\right) \cdot \left(\color{blue}{-1} \cdot \sqrt{2}\right)\right) \]

    if 0.0 < (sqrt.f64 (*.f64 (*.f64 (*.f64 #s(literal 2 binary64) n) U) (-.f64 (-.f64 t (*.f64 #s(literal 2 binary64) (/.f64 (*.f64 l l) Om))) (*.f64 (*.f64 n (pow.f64 (/.f64 l Om) #s(literal 2 binary64))) (-.f64 U U*))))) < +inf.0

    1. Initial program 50.5%

      \[\sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \frac{\ell \cdot \ell}{Om}\right) - \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)} \]
    2. Taylor expanded in n around 0

      \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \color{blue}{\left(t - 2 \cdot \frac{{\ell}^{2}}{Om}\right)}} \]
    3. Step-by-step derivation
      1. fp-cancel-sub-sign-invN/A

        \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(t + \color{blue}{\left(\mathsf{neg}\left(2\right)\right) \cdot \frac{{\ell}^{2}}{Om}}\right)} \]
      2. metadata-evalN/A

        \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(t + -2 \cdot \frac{\color{blue}{{\ell}^{2}}}{Om}\right)} \]
      3. +-commutativeN/A

        \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(-2 \cdot \frac{{\ell}^{2}}{Om} + \color{blue}{t}\right)} \]
      4. lower-fma.f64N/A

        \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \mathsf{fma}\left(-2, \color{blue}{\frac{{\ell}^{2}}{Om}}, t\right)} \]
      5. pow2N/A

        \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \mathsf{fma}\left(-2, \frac{\ell \cdot \ell}{Om}, t\right)} \]
      6. associate-/l*N/A

        \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \mathsf{fma}\left(-2, \ell \cdot \color{blue}{\frac{\ell}{Om}}, t\right)} \]
      7. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \mathsf{fma}\left(-2, \ell \cdot \color{blue}{\frac{\ell}{Om}}, t\right)} \]
      8. lift-/.f6447.0

        \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \mathsf{fma}\left(-2, \ell \cdot \frac{\ell}{\color{blue}{Om}}, t\right)} \]
    4. Applied rewrites47.0%

      \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \color{blue}{\mathsf{fma}\left(-2, \ell \cdot \frac{\ell}{Om}, t\right)}} \]

    if +inf.0 < (sqrt.f64 (*.f64 (*.f64 (*.f64 #s(literal 2 binary64) n) U) (-.f64 (-.f64 t (*.f64 #s(literal 2 binary64) (/.f64 (*.f64 l l) Om))) (*.f64 (*.f64 n (pow.f64 (/.f64 l Om) #s(literal 2 binary64))) (-.f64 U U*)))))

    1. Initial program 50.5%

      \[\sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \frac{\ell \cdot \ell}{Om}\right) - \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)} \]
    2. Taylor expanded in l around inf

      \[\leadsto \sqrt{\color{blue}{-2 \cdot \left(U \cdot \left({\ell}^{2} \cdot \left(n \cdot \left(2 \cdot \frac{1}{Om} + \frac{n \cdot \left(U - U*\right)}{{Om}^{2}}\right)\right)\right)\right)}} \]
    3. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \sqrt{\left(U \cdot \left({\ell}^{2} \cdot \left(n \cdot \left(2 \cdot \frac{1}{Om} + \frac{n \cdot \left(U - U*\right)}{{Om}^{2}}\right)\right)\right)\right) \cdot \color{blue}{-2}} \]
      2. lower-*.f64N/A

        \[\leadsto \sqrt{\left(U \cdot \left({\ell}^{2} \cdot \left(n \cdot \left(2 \cdot \frac{1}{Om} + \frac{n \cdot \left(U - U*\right)}{{Om}^{2}}\right)\right)\right)\right) \cdot \color{blue}{-2}} \]
    4. Applied rewrites20.6%

      \[\leadsto \sqrt{\color{blue}{\left(\left(\left(\left(\ell \cdot \ell\right) \cdot n\right) \cdot \mathsf{fma}\left(n, \frac{U - U*}{Om \cdot Om}, \frac{2}{Om}\right)\right) \cdot U\right) \cdot -2}} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 3: 53.2% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \left(2 \cdot n\right) \cdot U\\ t_2 := \sqrt{t\_1 \cdot \left(\left(t - 2 \cdot \frac{\ell \cdot \ell}{Om}\right) - \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)}\\ \mathbf{if}\;t\_2 \leq 0:\\ \;\;\;\;-1 \cdot \left(\left(\sqrt{U} \cdot \sqrt{n \cdot t}\right) \cdot \left(-1 \cdot \sqrt{2}\right)\right)\\ \mathbf{elif}\;t\_2 \leq \infty:\\ \;\;\;\;\sqrt{t\_1 \cdot \mathsf{fma}\left(-2, \ell \cdot \frac{\ell}{Om}, t\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{t\_1 \cdot \left(-\left(\ell \cdot \ell\right) \cdot \frac{2 + \frac{n \cdot \left(U - U*\right)}{Om}}{Om}\right)}\\ \end{array} \end{array} \]
(FPCore (n U t l Om U*)
 :precision binary64
 (let* ((t_1 (* (* 2.0 n) U))
        (t_2
         (sqrt
          (*
           t_1
           (-
            (- t (* 2.0 (/ (* l l) Om)))
            (* (* n (pow (/ l Om) 2.0)) (- U U*)))))))
   (if (<= t_2 0.0)
     (* -1.0 (* (* (sqrt U) (sqrt (* n t))) (* -1.0 (sqrt 2.0))))
     (if (<= t_2 INFINITY)
       (sqrt (* t_1 (fma -2.0 (* l (/ l Om)) t)))
       (sqrt (* t_1 (- (* (* l l) (/ (+ 2.0 (/ (* n (- U U*)) Om)) Om)))))))))
double code(double n, double U, double t, double l, double Om, double U_42_) {
	double t_1 = (2.0 * n) * U;
	double t_2 = sqrt((t_1 * ((t - (2.0 * ((l * l) / Om))) - ((n * pow((l / Om), 2.0)) * (U - U_42_)))));
	double tmp;
	if (t_2 <= 0.0) {
		tmp = -1.0 * ((sqrt(U) * sqrt((n * t))) * (-1.0 * sqrt(2.0)));
	} else if (t_2 <= ((double) INFINITY)) {
		tmp = sqrt((t_1 * fma(-2.0, (l * (l / Om)), t)));
	} else {
		tmp = sqrt((t_1 * -((l * l) * ((2.0 + ((n * (U - U_42_)) / Om)) / Om))));
	}
	return tmp;
}
function code(n, U, t, l, Om, U_42_)
	t_1 = Float64(Float64(2.0 * n) * U)
	t_2 = sqrt(Float64(t_1 * Float64(Float64(t - Float64(2.0 * Float64(Float64(l * l) / Om))) - Float64(Float64(n * (Float64(l / Om) ^ 2.0)) * Float64(U - U_42_)))))
	tmp = 0.0
	if (t_2 <= 0.0)
		tmp = Float64(-1.0 * Float64(Float64(sqrt(U) * sqrt(Float64(n * t))) * Float64(-1.0 * sqrt(2.0))));
	elseif (t_2 <= Inf)
		tmp = sqrt(Float64(t_1 * fma(-2.0, Float64(l * Float64(l / Om)), t)));
	else
		tmp = sqrt(Float64(t_1 * Float64(-Float64(Float64(l * l) * Float64(Float64(2.0 + Float64(Float64(n * Float64(U - U_42_)) / Om)) / Om)))));
	end
	return tmp
end
code[n_, U_, t_, l_, Om_, U$42$_] := Block[{t$95$1 = N[(N[(2.0 * n), $MachinePrecision] * U), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(t$95$1 * N[(N[(t - N[(2.0 * N[(N[(l * l), $MachinePrecision] / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(n * N[Power[N[(l / Om), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(U - U$42$), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$2, 0.0], N[(-1.0 * N[(N[(N[Sqrt[U], $MachinePrecision] * N[Sqrt[N[(n * t), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(-1.0 * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, Infinity], N[Sqrt[N[(t$95$1 * N[(-2.0 * N[(l * N[(l / Om), $MachinePrecision]), $MachinePrecision] + t), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[N[(t$95$1 * (-N[(N[(l * l), $MachinePrecision] * N[(N[(2.0 + N[(N[(n * N[(U - U$42$), $MachinePrecision]), $MachinePrecision] / Om), $MachinePrecision]), $MachinePrecision] / Om), $MachinePrecision]), $MachinePrecision])), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \left(2 \cdot n\right) \cdot U\\
t_2 := \sqrt{t\_1 \cdot \left(\left(t - 2 \cdot \frac{\ell \cdot \ell}{Om}\right) - \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)}\\
\mathbf{if}\;t\_2 \leq 0:\\
\;\;\;\;-1 \cdot \left(\left(\sqrt{U} \cdot \sqrt{n \cdot t}\right) \cdot \left(-1 \cdot \sqrt{2}\right)\right)\\

\mathbf{elif}\;t\_2 \leq \infty:\\
\;\;\;\;\sqrt{t\_1 \cdot \mathsf{fma}\left(-2, \ell \cdot \frac{\ell}{Om}, t\right)}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{t\_1 \cdot \left(-\left(\ell \cdot \ell\right) \cdot \frac{2 + \frac{n \cdot \left(U - U*\right)}{Om}}{Om}\right)}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (sqrt.f64 (*.f64 (*.f64 (*.f64 #s(literal 2 binary64) n) U) (-.f64 (-.f64 t (*.f64 #s(literal 2 binary64) (/.f64 (*.f64 l l) Om))) (*.f64 (*.f64 n (pow.f64 (/.f64 l Om) #s(literal 2 binary64))) (-.f64 U U*))))) < 0.0

    1. Initial program 50.5%

      \[\sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \frac{\ell \cdot \ell}{Om}\right) - \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)} \]
    2. Applied rewrites53.0%

      \[\leadsto \sqrt{\color{blue}{\left(\mathsf{fma}\left(-2, \ell \cdot \frac{\ell}{Om}, t\right) - n \cdot \left(\left(\frac{\ell}{Om} \cdot \frac{\ell}{Om}\right) \cdot \left(U - U*\right)\right)\right) \cdot \left(\left(n + n\right) \cdot U\right)}} \]
    3. Taylor expanded in t around -inf

      \[\leadsto \color{blue}{-1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left({\left(\sqrt{-1}\right)}^{2} \cdot \sqrt{2}\right)\right)} \]
    4. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto -1 \cdot \color{blue}{\left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left({\left(\sqrt{-1}\right)}^{2} \cdot \sqrt{2}\right)\right)} \]
      2. lower-*.f64N/A

        \[\leadsto -1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \color{blue}{\left({\left(\sqrt{-1}\right)}^{2} \cdot \sqrt{2}\right)}\right) \]
      3. lower-sqrt.f64N/A

        \[\leadsto -1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left(\color{blue}{{\left(\sqrt{-1}\right)}^{2}} \cdot \sqrt{2}\right)\right) \]
      4. lower-*.f64N/A

        \[\leadsto -1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left({\color{blue}{\left(\sqrt{-1}\right)}}^{2} \cdot \sqrt{2}\right)\right) \]
      5. lower-*.f64N/A

        \[\leadsto -1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left({\left(\sqrt{-1}\right)}^{2} \cdot \sqrt{2}\right)\right) \]
      6. sqrt-pow2N/A

        \[\leadsto -1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left({-1}^{\left(\frac{2}{2}\right)} \cdot \sqrt{\color{blue}{2}}\right)\right) \]
      7. metadata-evalN/A

        \[\leadsto -1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left({-1}^{1} \cdot \sqrt{2}\right)\right) \]
      8. metadata-evalN/A

        \[\leadsto -1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left(-1 \cdot \sqrt{\color{blue}{2}}\right)\right) \]
      9. lower-*.f64N/A

        \[\leadsto -1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left(-1 \cdot \color{blue}{\sqrt{2}}\right)\right) \]
      10. lower-sqrt.f6436.0

        \[\leadsto -1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left(-1 \cdot \sqrt{2}\right)\right) \]
    5. Applied rewrites36.0%

      \[\leadsto \color{blue}{-1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left(-1 \cdot \sqrt{2}\right)\right)} \]
    6. Step-by-step derivation
      1. lift-sqrt.f64N/A

        \[\leadsto -1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left(\color{blue}{-1} \cdot \sqrt{2}\right)\right) \]
      2. lift-*.f64N/A

        \[\leadsto -1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left(-1 \cdot \sqrt{2}\right)\right) \]
      3. lift-*.f64N/A

        \[\leadsto -1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left(-1 \cdot \sqrt{2}\right)\right) \]
      4. sqrt-prodN/A

        \[\leadsto -1 \cdot \left(\left(\sqrt{U} \cdot \sqrt{n \cdot t}\right) \cdot \left(\color{blue}{-1} \cdot \sqrt{2}\right)\right) \]
      5. lower-*.f64N/A

        \[\leadsto -1 \cdot \left(\left(\sqrt{U} \cdot \sqrt{n \cdot t}\right) \cdot \left(\color{blue}{-1} \cdot \sqrt{2}\right)\right) \]
      6. lower-sqrt.f64N/A

        \[\leadsto -1 \cdot \left(\left(\sqrt{U} \cdot \sqrt{n \cdot t}\right) \cdot \left(-1 \cdot \sqrt{2}\right)\right) \]
      7. lower-sqrt.f64N/A

        \[\leadsto -1 \cdot \left(\left(\sqrt{U} \cdot \sqrt{n \cdot t}\right) \cdot \left(-1 \cdot \sqrt{2}\right)\right) \]
      8. lift-*.f6421.1

        \[\leadsto -1 \cdot \left(\left(\sqrt{U} \cdot \sqrt{n \cdot t}\right) \cdot \left(-1 \cdot \sqrt{2}\right)\right) \]
    7. Applied rewrites21.1%

      \[\leadsto -1 \cdot \left(\left(\sqrt{U} \cdot \sqrt{n \cdot t}\right) \cdot \left(\color{blue}{-1} \cdot \sqrt{2}\right)\right) \]

    if 0.0 < (sqrt.f64 (*.f64 (*.f64 (*.f64 #s(literal 2 binary64) n) U) (-.f64 (-.f64 t (*.f64 #s(literal 2 binary64) (/.f64 (*.f64 l l) Om))) (*.f64 (*.f64 n (pow.f64 (/.f64 l Om) #s(literal 2 binary64))) (-.f64 U U*))))) < +inf.0

    1. Initial program 50.5%

      \[\sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \frac{\ell \cdot \ell}{Om}\right) - \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)} \]
    2. Taylor expanded in n around 0

      \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \color{blue}{\left(t - 2 \cdot \frac{{\ell}^{2}}{Om}\right)}} \]
    3. Step-by-step derivation
      1. fp-cancel-sub-sign-invN/A

        \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(t + \color{blue}{\left(\mathsf{neg}\left(2\right)\right) \cdot \frac{{\ell}^{2}}{Om}}\right)} \]
      2. metadata-evalN/A

        \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(t + -2 \cdot \frac{\color{blue}{{\ell}^{2}}}{Om}\right)} \]
      3. +-commutativeN/A

        \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(-2 \cdot \frac{{\ell}^{2}}{Om} + \color{blue}{t}\right)} \]
      4. lower-fma.f64N/A

        \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \mathsf{fma}\left(-2, \color{blue}{\frac{{\ell}^{2}}{Om}}, t\right)} \]
      5. pow2N/A

        \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \mathsf{fma}\left(-2, \frac{\ell \cdot \ell}{Om}, t\right)} \]
      6. associate-/l*N/A

        \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \mathsf{fma}\left(-2, \ell \cdot \color{blue}{\frac{\ell}{Om}}, t\right)} \]
      7. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \mathsf{fma}\left(-2, \ell \cdot \color{blue}{\frac{\ell}{Om}}, t\right)} \]
      8. lift-/.f6447.0

        \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \mathsf{fma}\left(-2, \ell \cdot \frac{\ell}{\color{blue}{Om}}, t\right)} \]
    4. Applied rewrites47.0%

      \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \color{blue}{\mathsf{fma}\left(-2, \ell \cdot \frac{\ell}{Om}, t\right)}} \]

    if +inf.0 < (sqrt.f64 (*.f64 (*.f64 (*.f64 #s(literal 2 binary64) n) U) (-.f64 (-.f64 t (*.f64 #s(literal 2 binary64) (/.f64 (*.f64 l l) Om))) (*.f64 (*.f64 n (pow.f64 (/.f64 l Om) #s(literal 2 binary64))) (-.f64 U U*)))))

    1. Initial program 50.5%

      \[\sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \frac{\ell \cdot \ell}{Om}\right) - \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)} \]
    2. Taylor expanded in l around inf

      \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \color{blue}{\left(-1 \cdot \left({\ell}^{2} \cdot \left(2 \cdot \frac{1}{Om} + \frac{n \cdot \left(U - U*\right)}{{Om}^{2}}\right)\right)\right)}} \]
    3. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\mathsf{neg}\left({\ell}^{2} \cdot \left(2 \cdot \frac{1}{Om} + \frac{n \cdot \left(U - U*\right)}{{Om}^{2}}\right)\right)\right)} \]
      2. lower-neg.f64N/A

        \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(-{\ell}^{2} \cdot \left(2 \cdot \frac{1}{Om} + \frac{n \cdot \left(U - U*\right)}{{Om}^{2}}\right)\right)} \]
      3. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(-{\ell}^{2} \cdot \left(2 \cdot \frac{1}{Om} + \frac{n \cdot \left(U - U*\right)}{{Om}^{2}}\right)\right)} \]
      4. pow2N/A

        \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(-\left(\ell \cdot \ell\right) \cdot \left(2 \cdot \frac{1}{Om} + \frac{n \cdot \left(U - U*\right)}{{Om}^{2}}\right)\right)} \]
      5. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(-\left(\ell \cdot \ell\right) \cdot \left(2 \cdot \frac{1}{Om} + \frac{n \cdot \left(U - U*\right)}{{Om}^{2}}\right)\right)} \]
      6. +-commutativeN/A

        \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(-\left(\ell \cdot \ell\right) \cdot \left(\frac{n \cdot \left(U - U*\right)}{{Om}^{2}} + 2 \cdot \frac{1}{Om}\right)\right)} \]
      7. associate-/l*N/A

        \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(-\left(\ell \cdot \ell\right) \cdot \left(n \cdot \frac{U - U*}{{Om}^{2}} + 2 \cdot \frac{1}{Om}\right)\right)} \]
      8. lower-fma.f64N/A

        \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(-\left(\ell \cdot \ell\right) \cdot \mathsf{fma}\left(n, \frac{U - U*}{{Om}^{2}}, 2 \cdot \frac{1}{Om}\right)\right)} \]
      9. lower-/.f64N/A

        \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(-\left(\ell \cdot \ell\right) \cdot \mathsf{fma}\left(n, \frac{U - U*}{{Om}^{2}}, 2 \cdot \frac{1}{Om}\right)\right)} \]
      10. lift--.f64N/A

        \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(-\left(\ell \cdot \ell\right) \cdot \mathsf{fma}\left(n, \frac{U - U*}{{Om}^{2}}, 2 \cdot \frac{1}{Om}\right)\right)} \]
      11. unpow2N/A

        \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(-\left(\ell \cdot \ell\right) \cdot \mathsf{fma}\left(n, \frac{U - U*}{Om \cdot Om}, 2 \cdot \frac{1}{Om}\right)\right)} \]
      12. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(-\left(\ell \cdot \ell\right) \cdot \mathsf{fma}\left(n, \frac{U - U*}{Om \cdot Om}, 2 \cdot \frac{1}{Om}\right)\right)} \]
      13. associate-*r/N/A

        \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(-\left(\ell \cdot \ell\right) \cdot \mathsf{fma}\left(n, \frac{U - U*}{Om \cdot Om}, \frac{2 \cdot 1}{Om}\right)\right)} \]
      14. metadata-evalN/A

        \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(-\left(\ell \cdot \ell\right) \cdot \mathsf{fma}\left(n, \frac{U - U*}{Om \cdot Om}, \frac{2}{Om}\right)\right)} \]
      15. lower-/.f6420.6

        \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(-\left(\ell \cdot \ell\right) \cdot \mathsf{fma}\left(n, \frac{U - U*}{Om \cdot Om}, \frac{2}{Om}\right)\right)} \]
    4. Applied rewrites20.6%

      \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \color{blue}{\left(-\left(\ell \cdot \ell\right) \cdot \mathsf{fma}\left(n, \frac{U - U*}{Om \cdot Om}, \frac{2}{Om}\right)\right)}} \]
    5. Taylor expanded in Om around inf

      \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(-\left(\ell \cdot \ell\right) \cdot \frac{2 + \frac{n \cdot \left(U - U*\right)}{Om}}{Om}\right)} \]
    6. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(-\left(\ell \cdot \ell\right) \cdot \frac{2 + \frac{n \cdot \left(U - U*\right)}{Om}}{Om}\right)} \]
      2. lower-+.f64N/A

        \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(-\left(\ell \cdot \ell\right) \cdot \frac{2 + \frac{n \cdot \left(U - U*\right)}{Om}}{Om}\right)} \]
      3. lower-/.f64N/A

        \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(-\left(\ell \cdot \ell\right) \cdot \frac{2 + \frac{n \cdot \left(U - U*\right)}{Om}}{Om}\right)} \]
      4. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(-\left(\ell \cdot \ell\right) \cdot \frac{2 + \frac{n \cdot \left(U - U*\right)}{Om}}{Om}\right)} \]
      5. lift--.f6421.8

        \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(-\left(\ell \cdot \ell\right) \cdot \frac{2 + \frac{n \cdot \left(U - U*\right)}{Om}}{Om}\right)} \]
    7. Applied rewrites21.8%

      \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(-\left(\ell \cdot \ell\right) \cdot \frac{2 + \frac{n \cdot \left(U - U*\right)}{Om}}{Om}\right)} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 4: 52.7% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \left(2 \cdot n\right) \cdot U\\ t_2 := \sqrt{t\_1 \cdot \left(\left(t - 2 \cdot \frac{\ell \cdot \ell}{Om}\right) - \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)}\\ \mathbf{if}\;t\_2 \leq 0:\\ \;\;\;\;-1 \cdot \left(\left(\sqrt{U} \cdot \sqrt{n \cdot t}\right) \cdot \left(-1 \cdot \sqrt{2}\right)\right)\\ \mathbf{elif}\;t\_2 \leq \infty:\\ \;\;\;\;\sqrt{t\_1 \cdot \mathsf{fma}\left(-2, \ell \cdot \frac{\ell}{Om}, t\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\left(n + n\right) \cdot \left(U \cdot \frac{U* \cdot \left(\left(\ell \cdot \ell\right) \cdot n\right)}{Om \cdot Om}\right)}\\ \end{array} \end{array} \]
(FPCore (n U t l Om U*)
 :precision binary64
 (let* ((t_1 (* (* 2.0 n) U))
        (t_2
         (sqrt
          (*
           t_1
           (-
            (- t (* 2.0 (/ (* l l) Om)))
            (* (* n (pow (/ l Om) 2.0)) (- U U*)))))))
   (if (<= t_2 0.0)
     (* -1.0 (* (* (sqrt U) (sqrt (* n t))) (* -1.0 (sqrt 2.0))))
     (if (<= t_2 INFINITY)
       (sqrt (* t_1 (fma -2.0 (* l (/ l Om)) t)))
       (sqrt (* (+ n n) (* U (/ (* U* (* (* l l) n)) (* Om Om)))))))))
double code(double n, double U, double t, double l, double Om, double U_42_) {
	double t_1 = (2.0 * n) * U;
	double t_2 = sqrt((t_1 * ((t - (2.0 * ((l * l) / Om))) - ((n * pow((l / Om), 2.0)) * (U - U_42_)))));
	double tmp;
	if (t_2 <= 0.0) {
		tmp = -1.0 * ((sqrt(U) * sqrt((n * t))) * (-1.0 * sqrt(2.0)));
	} else if (t_2 <= ((double) INFINITY)) {
		tmp = sqrt((t_1 * fma(-2.0, (l * (l / Om)), t)));
	} else {
		tmp = sqrt(((n + n) * (U * ((U_42_ * ((l * l) * n)) / (Om * Om)))));
	}
	return tmp;
}
function code(n, U, t, l, Om, U_42_)
	t_1 = Float64(Float64(2.0 * n) * U)
	t_2 = sqrt(Float64(t_1 * Float64(Float64(t - Float64(2.0 * Float64(Float64(l * l) / Om))) - Float64(Float64(n * (Float64(l / Om) ^ 2.0)) * Float64(U - U_42_)))))
	tmp = 0.0
	if (t_2 <= 0.0)
		tmp = Float64(-1.0 * Float64(Float64(sqrt(U) * sqrt(Float64(n * t))) * Float64(-1.0 * sqrt(2.0))));
	elseif (t_2 <= Inf)
		tmp = sqrt(Float64(t_1 * fma(-2.0, Float64(l * Float64(l / Om)), t)));
	else
		tmp = sqrt(Float64(Float64(n + n) * Float64(U * Float64(Float64(U_42_ * Float64(Float64(l * l) * n)) / Float64(Om * Om)))));
	end
	return tmp
end
code[n_, U_, t_, l_, Om_, U$42$_] := Block[{t$95$1 = N[(N[(2.0 * n), $MachinePrecision] * U), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(t$95$1 * N[(N[(t - N[(2.0 * N[(N[(l * l), $MachinePrecision] / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(n * N[Power[N[(l / Om), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(U - U$42$), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$2, 0.0], N[(-1.0 * N[(N[(N[Sqrt[U], $MachinePrecision] * N[Sqrt[N[(n * t), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(-1.0 * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, Infinity], N[Sqrt[N[(t$95$1 * N[(-2.0 * N[(l * N[(l / Om), $MachinePrecision]), $MachinePrecision] + t), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[N[(N[(n + n), $MachinePrecision] * N[(U * N[(N[(U$42$ * N[(N[(l * l), $MachinePrecision] * n), $MachinePrecision]), $MachinePrecision] / N[(Om * Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \left(2 \cdot n\right) \cdot U\\
t_2 := \sqrt{t\_1 \cdot \left(\left(t - 2 \cdot \frac{\ell \cdot \ell}{Om}\right) - \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)}\\
\mathbf{if}\;t\_2 \leq 0:\\
\;\;\;\;-1 \cdot \left(\left(\sqrt{U} \cdot \sqrt{n \cdot t}\right) \cdot \left(-1 \cdot \sqrt{2}\right)\right)\\

\mathbf{elif}\;t\_2 \leq \infty:\\
\;\;\;\;\sqrt{t\_1 \cdot \mathsf{fma}\left(-2, \ell \cdot \frac{\ell}{Om}, t\right)}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{\left(n + n\right) \cdot \left(U \cdot \frac{U* \cdot \left(\left(\ell \cdot \ell\right) \cdot n\right)}{Om \cdot Om}\right)}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (sqrt.f64 (*.f64 (*.f64 (*.f64 #s(literal 2 binary64) n) U) (-.f64 (-.f64 t (*.f64 #s(literal 2 binary64) (/.f64 (*.f64 l l) Om))) (*.f64 (*.f64 n (pow.f64 (/.f64 l Om) #s(literal 2 binary64))) (-.f64 U U*))))) < 0.0

    1. Initial program 50.5%

      \[\sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \frac{\ell \cdot \ell}{Om}\right) - \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)} \]
    2. Applied rewrites53.0%

      \[\leadsto \sqrt{\color{blue}{\left(\mathsf{fma}\left(-2, \ell \cdot \frac{\ell}{Om}, t\right) - n \cdot \left(\left(\frac{\ell}{Om} \cdot \frac{\ell}{Om}\right) \cdot \left(U - U*\right)\right)\right) \cdot \left(\left(n + n\right) \cdot U\right)}} \]
    3. Taylor expanded in t around -inf

      \[\leadsto \color{blue}{-1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left({\left(\sqrt{-1}\right)}^{2} \cdot \sqrt{2}\right)\right)} \]
    4. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto -1 \cdot \color{blue}{\left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left({\left(\sqrt{-1}\right)}^{2} \cdot \sqrt{2}\right)\right)} \]
      2. lower-*.f64N/A

        \[\leadsto -1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \color{blue}{\left({\left(\sqrt{-1}\right)}^{2} \cdot \sqrt{2}\right)}\right) \]
      3. lower-sqrt.f64N/A

        \[\leadsto -1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left(\color{blue}{{\left(\sqrt{-1}\right)}^{2}} \cdot \sqrt{2}\right)\right) \]
      4. lower-*.f64N/A

        \[\leadsto -1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left({\color{blue}{\left(\sqrt{-1}\right)}}^{2} \cdot \sqrt{2}\right)\right) \]
      5. lower-*.f64N/A

        \[\leadsto -1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left({\left(\sqrt{-1}\right)}^{2} \cdot \sqrt{2}\right)\right) \]
      6. sqrt-pow2N/A

        \[\leadsto -1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left({-1}^{\left(\frac{2}{2}\right)} \cdot \sqrt{\color{blue}{2}}\right)\right) \]
      7. metadata-evalN/A

        \[\leadsto -1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left({-1}^{1} \cdot \sqrt{2}\right)\right) \]
      8. metadata-evalN/A

        \[\leadsto -1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left(-1 \cdot \sqrt{\color{blue}{2}}\right)\right) \]
      9. lower-*.f64N/A

        \[\leadsto -1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left(-1 \cdot \color{blue}{\sqrt{2}}\right)\right) \]
      10. lower-sqrt.f6436.0

        \[\leadsto -1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left(-1 \cdot \sqrt{2}\right)\right) \]
    5. Applied rewrites36.0%

      \[\leadsto \color{blue}{-1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left(-1 \cdot \sqrt{2}\right)\right)} \]
    6. Step-by-step derivation
      1. lift-sqrt.f64N/A

        \[\leadsto -1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left(\color{blue}{-1} \cdot \sqrt{2}\right)\right) \]
      2. lift-*.f64N/A

        \[\leadsto -1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left(-1 \cdot \sqrt{2}\right)\right) \]
      3. lift-*.f64N/A

        \[\leadsto -1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left(-1 \cdot \sqrt{2}\right)\right) \]
      4. sqrt-prodN/A

        \[\leadsto -1 \cdot \left(\left(\sqrt{U} \cdot \sqrt{n \cdot t}\right) \cdot \left(\color{blue}{-1} \cdot \sqrt{2}\right)\right) \]
      5. lower-*.f64N/A

        \[\leadsto -1 \cdot \left(\left(\sqrt{U} \cdot \sqrt{n \cdot t}\right) \cdot \left(\color{blue}{-1} \cdot \sqrt{2}\right)\right) \]
      6. lower-sqrt.f64N/A

        \[\leadsto -1 \cdot \left(\left(\sqrt{U} \cdot \sqrt{n \cdot t}\right) \cdot \left(-1 \cdot \sqrt{2}\right)\right) \]
      7. lower-sqrt.f64N/A

        \[\leadsto -1 \cdot \left(\left(\sqrt{U} \cdot \sqrt{n \cdot t}\right) \cdot \left(-1 \cdot \sqrt{2}\right)\right) \]
      8. lift-*.f6421.1

        \[\leadsto -1 \cdot \left(\left(\sqrt{U} \cdot \sqrt{n \cdot t}\right) \cdot \left(-1 \cdot \sqrt{2}\right)\right) \]
    7. Applied rewrites21.1%

      \[\leadsto -1 \cdot \left(\left(\sqrt{U} \cdot \sqrt{n \cdot t}\right) \cdot \left(\color{blue}{-1} \cdot \sqrt{2}\right)\right) \]

    if 0.0 < (sqrt.f64 (*.f64 (*.f64 (*.f64 #s(literal 2 binary64) n) U) (-.f64 (-.f64 t (*.f64 #s(literal 2 binary64) (/.f64 (*.f64 l l) Om))) (*.f64 (*.f64 n (pow.f64 (/.f64 l Om) #s(literal 2 binary64))) (-.f64 U U*))))) < +inf.0

    1. Initial program 50.5%

      \[\sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \frac{\ell \cdot \ell}{Om}\right) - \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)} \]
    2. Taylor expanded in n around 0

      \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \color{blue}{\left(t - 2 \cdot \frac{{\ell}^{2}}{Om}\right)}} \]
    3. Step-by-step derivation
      1. fp-cancel-sub-sign-invN/A

        \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(t + \color{blue}{\left(\mathsf{neg}\left(2\right)\right) \cdot \frac{{\ell}^{2}}{Om}}\right)} \]
      2. metadata-evalN/A

        \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(t + -2 \cdot \frac{\color{blue}{{\ell}^{2}}}{Om}\right)} \]
      3. +-commutativeN/A

        \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(-2 \cdot \frac{{\ell}^{2}}{Om} + \color{blue}{t}\right)} \]
      4. lower-fma.f64N/A

        \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \mathsf{fma}\left(-2, \color{blue}{\frac{{\ell}^{2}}{Om}}, t\right)} \]
      5. pow2N/A

        \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \mathsf{fma}\left(-2, \frac{\ell \cdot \ell}{Om}, t\right)} \]
      6. associate-/l*N/A

        \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \mathsf{fma}\left(-2, \ell \cdot \color{blue}{\frac{\ell}{Om}}, t\right)} \]
      7. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \mathsf{fma}\left(-2, \ell \cdot \color{blue}{\frac{\ell}{Om}}, t\right)} \]
      8. lift-/.f6447.0

        \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \mathsf{fma}\left(-2, \ell \cdot \frac{\ell}{\color{blue}{Om}}, t\right)} \]
    4. Applied rewrites47.0%

      \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \color{blue}{\mathsf{fma}\left(-2, \ell \cdot \frac{\ell}{Om}, t\right)}} \]

    if +inf.0 < (sqrt.f64 (*.f64 (*.f64 (*.f64 #s(literal 2 binary64) n) U) (-.f64 (-.f64 t (*.f64 #s(literal 2 binary64) (/.f64 (*.f64 l l) Om))) (*.f64 (*.f64 n (pow.f64 (/.f64 l Om) #s(literal 2 binary64))) (-.f64 U U*)))))

    1. Initial program 50.5%

      \[\sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \frac{\ell \cdot \ell}{Om}\right) - \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)} \]
    2. Applied rewrites52.8%

      \[\leadsto \sqrt{\color{blue}{\left(n + n\right) \cdot \left(U \cdot \left(\mathsf{fma}\left(-2, \ell \cdot \frac{\ell}{Om}, t\right) - n \cdot \left(\left(\frac{\ell}{Om} \cdot \frac{\ell}{Om}\right) \cdot \left(U - U*\right)\right)\right)\right)}} \]
    3. Taylor expanded in U* around inf

      \[\leadsto \sqrt{\left(n + n\right) \cdot \left(U \cdot \color{blue}{\frac{U* \cdot \left({\ell}^{2} \cdot n\right)}{{Om}^{2}}}\right)} \]
    4. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \sqrt{\left(n + n\right) \cdot \left(U \cdot \frac{U* \cdot \left({\ell}^{2} \cdot n\right)}{\color{blue}{{Om}^{2}}}\right)} \]
      2. lower-*.f64N/A

        \[\leadsto \sqrt{\left(n + n\right) \cdot \left(U \cdot \frac{U* \cdot \left({\ell}^{2} \cdot n\right)}{{\color{blue}{Om}}^{2}}\right)} \]
      3. lower-*.f64N/A

        \[\leadsto \sqrt{\left(n + n\right) \cdot \left(U \cdot \frac{U* \cdot \left({\ell}^{2} \cdot n\right)}{{Om}^{2}}\right)} \]
      4. pow2N/A

        \[\leadsto \sqrt{\left(n + n\right) \cdot \left(U \cdot \frac{U* \cdot \left(\left(\ell \cdot \ell\right) \cdot n\right)}{{Om}^{2}}\right)} \]
      5. lift-*.f64N/A

        \[\leadsto \sqrt{\left(n + n\right) \cdot \left(U \cdot \frac{U* \cdot \left(\left(\ell \cdot \ell\right) \cdot n\right)}{{Om}^{2}}\right)} \]
      6. pow2N/A

        \[\leadsto \sqrt{\left(n + n\right) \cdot \left(U \cdot \frac{U* \cdot \left(\left(\ell \cdot \ell\right) \cdot n\right)}{Om \cdot \color{blue}{Om}}\right)} \]
      7. lift-*.f6416.4

        \[\leadsto \sqrt{\left(n + n\right) \cdot \left(U \cdot \frac{U* \cdot \left(\left(\ell \cdot \ell\right) \cdot n\right)}{Om \cdot \color{blue}{Om}}\right)} \]
    5. Applied rewrites16.4%

      \[\leadsto \sqrt{\left(n + n\right) \cdot \left(U \cdot \color{blue}{\frac{U* \cdot \left(\left(\ell \cdot \ell\right) \cdot n\right)}{Om \cdot Om}}\right)} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 5: 50.3% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \left(2 \cdot n\right) \cdot U\\ t_2 := \sqrt{t\_1 \cdot \left(\left(t - 2 \cdot \frac{\ell \cdot \ell}{Om}\right) - \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)}\\ t_3 := \mathsf{fma}\left(-2, \ell \cdot \frac{\ell}{Om}, t\right)\\ \mathbf{if}\;t\_2 \leq 0:\\ \;\;\;\;-1 \cdot \left(\left(\sqrt{U} \cdot \sqrt{n \cdot t}\right) \cdot \left(-1 \cdot \sqrt{2}\right)\right)\\ \mathbf{elif}\;t\_2 \leq 10^{+133}:\\ \;\;\;\;\sqrt{t\_1 \cdot t\_3}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\left(\left(t\_3 \cdot n\right) \cdot U\right) \cdot 2}\\ \end{array} \end{array} \]
(FPCore (n U t l Om U*)
 :precision binary64
 (let* ((t_1 (* (* 2.0 n) U))
        (t_2
         (sqrt
          (*
           t_1
           (-
            (- t (* 2.0 (/ (* l l) Om)))
            (* (* n (pow (/ l Om) 2.0)) (- U U*))))))
        (t_3 (fma -2.0 (* l (/ l Om)) t)))
   (if (<= t_2 0.0)
     (* -1.0 (* (* (sqrt U) (sqrt (* n t))) (* -1.0 (sqrt 2.0))))
     (if (<= t_2 1e+133) (sqrt (* t_1 t_3)) (sqrt (* (* (* t_3 n) U) 2.0))))))
double code(double n, double U, double t, double l, double Om, double U_42_) {
	double t_1 = (2.0 * n) * U;
	double t_2 = sqrt((t_1 * ((t - (2.0 * ((l * l) / Om))) - ((n * pow((l / Om), 2.0)) * (U - U_42_)))));
	double t_3 = fma(-2.0, (l * (l / Om)), t);
	double tmp;
	if (t_2 <= 0.0) {
		tmp = -1.0 * ((sqrt(U) * sqrt((n * t))) * (-1.0 * sqrt(2.0)));
	} else if (t_2 <= 1e+133) {
		tmp = sqrt((t_1 * t_3));
	} else {
		tmp = sqrt((((t_3 * n) * U) * 2.0));
	}
	return tmp;
}
function code(n, U, t, l, Om, U_42_)
	t_1 = Float64(Float64(2.0 * n) * U)
	t_2 = sqrt(Float64(t_1 * Float64(Float64(t - Float64(2.0 * Float64(Float64(l * l) / Om))) - Float64(Float64(n * (Float64(l / Om) ^ 2.0)) * Float64(U - U_42_)))))
	t_3 = fma(-2.0, Float64(l * Float64(l / Om)), t)
	tmp = 0.0
	if (t_2 <= 0.0)
		tmp = Float64(-1.0 * Float64(Float64(sqrt(U) * sqrt(Float64(n * t))) * Float64(-1.0 * sqrt(2.0))));
	elseif (t_2 <= 1e+133)
		tmp = sqrt(Float64(t_1 * t_3));
	else
		tmp = sqrt(Float64(Float64(Float64(t_3 * n) * U) * 2.0));
	end
	return tmp
end
code[n_, U_, t_, l_, Om_, U$42$_] := Block[{t$95$1 = N[(N[(2.0 * n), $MachinePrecision] * U), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(t$95$1 * N[(N[(t - N[(2.0 * N[(N[(l * l), $MachinePrecision] / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(n * N[Power[N[(l / Om), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(U - U$42$), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(-2.0 * N[(l * N[(l / Om), $MachinePrecision]), $MachinePrecision] + t), $MachinePrecision]}, If[LessEqual[t$95$2, 0.0], N[(-1.0 * N[(N[(N[Sqrt[U], $MachinePrecision] * N[Sqrt[N[(n * t), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(-1.0 * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 1e+133], N[Sqrt[N[(t$95$1 * t$95$3), $MachinePrecision]], $MachinePrecision], N[Sqrt[N[(N[(N[(t$95$3 * n), $MachinePrecision] * U), $MachinePrecision] * 2.0), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \left(2 \cdot n\right) \cdot U\\
t_2 := \sqrt{t\_1 \cdot \left(\left(t - 2 \cdot \frac{\ell \cdot \ell}{Om}\right) - \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)}\\
t_3 := \mathsf{fma}\left(-2, \ell \cdot \frac{\ell}{Om}, t\right)\\
\mathbf{if}\;t\_2 \leq 0:\\
\;\;\;\;-1 \cdot \left(\left(\sqrt{U} \cdot \sqrt{n \cdot t}\right) \cdot \left(-1 \cdot \sqrt{2}\right)\right)\\

\mathbf{elif}\;t\_2 \leq 10^{+133}:\\
\;\;\;\;\sqrt{t\_1 \cdot t\_3}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{\left(\left(t\_3 \cdot n\right) \cdot U\right) \cdot 2}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (sqrt.f64 (*.f64 (*.f64 (*.f64 #s(literal 2 binary64) n) U) (-.f64 (-.f64 t (*.f64 #s(literal 2 binary64) (/.f64 (*.f64 l l) Om))) (*.f64 (*.f64 n (pow.f64 (/.f64 l Om) #s(literal 2 binary64))) (-.f64 U U*))))) < 0.0

    1. Initial program 50.5%

      \[\sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \frac{\ell \cdot \ell}{Om}\right) - \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)} \]
    2. Applied rewrites53.0%

      \[\leadsto \sqrt{\color{blue}{\left(\mathsf{fma}\left(-2, \ell \cdot \frac{\ell}{Om}, t\right) - n \cdot \left(\left(\frac{\ell}{Om} \cdot \frac{\ell}{Om}\right) \cdot \left(U - U*\right)\right)\right) \cdot \left(\left(n + n\right) \cdot U\right)}} \]
    3. Taylor expanded in t around -inf

      \[\leadsto \color{blue}{-1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left({\left(\sqrt{-1}\right)}^{2} \cdot \sqrt{2}\right)\right)} \]
    4. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto -1 \cdot \color{blue}{\left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left({\left(\sqrt{-1}\right)}^{2} \cdot \sqrt{2}\right)\right)} \]
      2. lower-*.f64N/A

        \[\leadsto -1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \color{blue}{\left({\left(\sqrt{-1}\right)}^{2} \cdot \sqrt{2}\right)}\right) \]
      3. lower-sqrt.f64N/A

        \[\leadsto -1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left(\color{blue}{{\left(\sqrt{-1}\right)}^{2}} \cdot \sqrt{2}\right)\right) \]
      4. lower-*.f64N/A

        \[\leadsto -1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left({\color{blue}{\left(\sqrt{-1}\right)}}^{2} \cdot \sqrt{2}\right)\right) \]
      5. lower-*.f64N/A

        \[\leadsto -1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left({\left(\sqrt{-1}\right)}^{2} \cdot \sqrt{2}\right)\right) \]
      6. sqrt-pow2N/A

        \[\leadsto -1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left({-1}^{\left(\frac{2}{2}\right)} \cdot \sqrt{\color{blue}{2}}\right)\right) \]
      7. metadata-evalN/A

        \[\leadsto -1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left({-1}^{1} \cdot \sqrt{2}\right)\right) \]
      8. metadata-evalN/A

        \[\leadsto -1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left(-1 \cdot \sqrt{\color{blue}{2}}\right)\right) \]
      9. lower-*.f64N/A

        \[\leadsto -1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left(-1 \cdot \color{blue}{\sqrt{2}}\right)\right) \]
      10. lower-sqrt.f6436.0

        \[\leadsto -1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left(-1 \cdot \sqrt{2}\right)\right) \]
    5. Applied rewrites36.0%

      \[\leadsto \color{blue}{-1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left(-1 \cdot \sqrt{2}\right)\right)} \]
    6. Step-by-step derivation
      1. lift-sqrt.f64N/A

        \[\leadsto -1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left(\color{blue}{-1} \cdot \sqrt{2}\right)\right) \]
      2. lift-*.f64N/A

        \[\leadsto -1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left(-1 \cdot \sqrt{2}\right)\right) \]
      3. lift-*.f64N/A

        \[\leadsto -1 \cdot \left(\sqrt{U \cdot \left(n \cdot t\right)} \cdot \left(-1 \cdot \sqrt{2}\right)\right) \]
      4. sqrt-prodN/A

        \[\leadsto -1 \cdot \left(\left(\sqrt{U} \cdot \sqrt{n \cdot t}\right) \cdot \left(\color{blue}{-1} \cdot \sqrt{2}\right)\right) \]
      5. lower-*.f64N/A

        \[\leadsto -1 \cdot \left(\left(\sqrt{U} \cdot \sqrt{n \cdot t}\right) \cdot \left(\color{blue}{-1} \cdot \sqrt{2}\right)\right) \]
      6. lower-sqrt.f64N/A

        \[\leadsto -1 \cdot \left(\left(\sqrt{U} \cdot \sqrt{n \cdot t}\right) \cdot \left(-1 \cdot \sqrt{2}\right)\right) \]
      7. lower-sqrt.f64N/A

        \[\leadsto -1 \cdot \left(\left(\sqrt{U} \cdot \sqrt{n \cdot t}\right) \cdot \left(-1 \cdot \sqrt{2}\right)\right) \]
      8. lift-*.f6421.1

        \[\leadsto -1 \cdot \left(\left(\sqrt{U} \cdot \sqrt{n \cdot t}\right) \cdot \left(-1 \cdot \sqrt{2}\right)\right) \]
    7. Applied rewrites21.1%

      \[\leadsto -1 \cdot \left(\left(\sqrt{U} \cdot \sqrt{n \cdot t}\right) \cdot \left(\color{blue}{-1} \cdot \sqrt{2}\right)\right) \]

    if 0.0 < (sqrt.f64 (*.f64 (*.f64 (*.f64 #s(literal 2 binary64) n) U) (-.f64 (-.f64 t (*.f64 #s(literal 2 binary64) (/.f64 (*.f64 l l) Om))) (*.f64 (*.f64 n (pow.f64 (/.f64 l Om) #s(literal 2 binary64))) (-.f64 U U*))))) < 1e133

    1. Initial program 50.5%

      \[\sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \frac{\ell \cdot \ell}{Om}\right) - \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)} \]
    2. Taylor expanded in n around 0

      \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \color{blue}{\left(t - 2 \cdot \frac{{\ell}^{2}}{Om}\right)}} \]
    3. Step-by-step derivation
      1. fp-cancel-sub-sign-invN/A

        \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(t + \color{blue}{\left(\mathsf{neg}\left(2\right)\right) \cdot \frac{{\ell}^{2}}{Om}}\right)} \]
      2. metadata-evalN/A

        \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(t + -2 \cdot \frac{\color{blue}{{\ell}^{2}}}{Om}\right)} \]
      3. +-commutativeN/A

        \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(-2 \cdot \frac{{\ell}^{2}}{Om} + \color{blue}{t}\right)} \]
      4. lower-fma.f64N/A

        \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \mathsf{fma}\left(-2, \color{blue}{\frac{{\ell}^{2}}{Om}}, t\right)} \]
      5. pow2N/A

        \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \mathsf{fma}\left(-2, \frac{\ell \cdot \ell}{Om}, t\right)} \]
      6. associate-/l*N/A

        \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \mathsf{fma}\left(-2, \ell \cdot \color{blue}{\frac{\ell}{Om}}, t\right)} \]
      7. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \mathsf{fma}\left(-2, \ell \cdot \color{blue}{\frac{\ell}{Om}}, t\right)} \]
      8. lift-/.f6447.0

        \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \mathsf{fma}\left(-2, \ell \cdot \frac{\ell}{\color{blue}{Om}}, t\right)} \]
    4. Applied rewrites47.0%

      \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \color{blue}{\mathsf{fma}\left(-2, \ell \cdot \frac{\ell}{Om}, t\right)}} \]

    if 1e133 < (sqrt.f64 (*.f64 (*.f64 (*.f64 #s(literal 2 binary64) n) U) (-.f64 (-.f64 t (*.f64 #s(literal 2 binary64) (/.f64 (*.f64 l l) Om))) (*.f64 (*.f64 n (pow.f64 (/.f64 l Om) #s(literal 2 binary64))) (-.f64 U U*)))))

    1. Initial program 50.5%

      \[\sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \frac{\ell \cdot \ell}{Om}\right) - \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)} \]
    2. Taylor expanded in n around 0

      \[\leadsto \sqrt{\color{blue}{2 \cdot \left(U \cdot \left(n \cdot \left(t - 2 \cdot \frac{{\ell}^{2}}{Om}\right)\right)\right)}} \]
    3. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \sqrt{\left(U \cdot \left(n \cdot \left(t - 2 \cdot \frac{{\ell}^{2}}{Om}\right)\right)\right) \cdot \color{blue}{2}} \]
      2. lower-*.f64N/A

        \[\leadsto \sqrt{\left(U \cdot \left(n \cdot \left(t - 2 \cdot \frac{{\ell}^{2}}{Om}\right)\right)\right) \cdot \color{blue}{2}} \]
      3. *-commutativeN/A

        \[\leadsto \sqrt{\left(\left(n \cdot \left(t - 2 \cdot \frac{{\ell}^{2}}{Om}\right)\right) \cdot U\right) \cdot 2} \]
      4. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\left(n \cdot \left(t - 2 \cdot \frac{{\ell}^{2}}{Om}\right)\right) \cdot U\right) \cdot 2} \]
      5. *-commutativeN/A

        \[\leadsto \sqrt{\left(\left(\left(t - 2 \cdot \frac{{\ell}^{2}}{Om}\right) \cdot n\right) \cdot U\right) \cdot 2} \]
      6. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\left(\left(t - 2 \cdot \frac{{\ell}^{2}}{Om}\right) \cdot n\right) \cdot U\right) \cdot 2} \]
      7. fp-cancel-sub-sign-invN/A

        \[\leadsto \sqrt{\left(\left(\left(t + \left(\mathsf{neg}\left(2\right)\right) \cdot \frac{{\ell}^{2}}{Om}\right) \cdot n\right) \cdot U\right) \cdot 2} \]
      8. metadata-evalN/A

        \[\leadsto \sqrt{\left(\left(\left(t + -2 \cdot \frac{{\ell}^{2}}{Om}\right) \cdot n\right) \cdot U\right) \cdot 2} \]
      9. +-commutativeN/A

        \[\leadsto \sqrt{\left(\left(\left(-2 \cdot \frac{{\ell}^{2}}{Om} + t\right) \cdot n\right) \cdot U\right) \cdot 2} \]
      10. lower-fma.f64N/A

        \[\leadsto \sqrt{\left(\left(\mathsf{fma}\left(-2, \frac{{\ell}^{2}}{Om}, t\right) \cdot n\right) \cdot U\right) \cdot 2} \]
      11. pow2N/A

        \[\leadsto \sqrt{\left(\left(\mathsf{fma}\left(-2, \frac{\ell \cdot \ell}{Om}, t\right) \cdot n\right) \cdot U\right) \cdot 2} \]
      12. associate-/l*N/A

        \[\leadsto \sqrt{\left(\left(\mathsf{fma}\left(-2, \ell \cdot \frac{\ell}{Om}, t\right) \cdot n\right) \cdot U\right) \cdot 2} \]
      13. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\left(\mathsf{fma}\left(-2, \ell \cdot \frac{\ell}{Om}, t\right) \cdot n\right) \cdot U\right) \cdot 2} \]
      14. lift-/.f6447.6

        \[\leadsto \sqrt{\left(\left(\mathsf{fma}\left(-2, \ell \cdot \frac{\ell}{Om}, t\right) \cdot n\right) \cdot U\right) \cdot 2} \]
    4. Applied rewrites47.6%

      \[\leadsto \sqrt{\color{blue}{\left(\left(\mathsf{fma}\left(-2, \ell \cdot \frac{\ell}{Om}, t\right) \cdot n\right) \cdot U\right) \cdot 2}} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 6: 48.2% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;t \leq 1.95 \cdot 10^{+105}:\\ \;\;\;\;\sqrt{\left(\left(\mathsf{fma}\left(-2, \ell \cdot \frac{\ell}{Om}, t\right) \cdot n\right) \cdot U\right) \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{t} \cdot \sqrt{\left(n + n\right) \cdot U}\\ \end{array} \end{array} \]
(FPCore (n U t l Om U*)
 :precision binary64
 (if (<= t 1.95e+105)
   (sqrt (* (* (* (fma -2.0 (* l (/ l Om)) t) n) U) 2.0))
   (* (sqrt t) (sqrt (* (+ n n) U)))))
double code(double n, double U, double t, double l, double Om, double U_42_) {
	double tmp;
	if (t <= 1.95e+105) {
		tmp = sqrt((((fma(-2.0, (l * (l / Om)), t) * n) * U) * 2.0));
	} else {
		tmp = sqrt(t) * sqrt(((n + n) * U));
	}
	return tmp;
}
function code(n, U, t, l, Om, U_42_)
	tmp = 0.0
	if (t <= 1.95e+105)
		tmp = sqrt(Float64(Float64(Float64(fma(-2.0, Float64(l * Float64(l / Om)), t) * n) * U) * 2.0));
	else
		tmp = Float64(sqrt(t) * sqrt(Float64(Float64(n + n) * U)));
	end
	return tmp
end
code[n_, U_, t_, l_, Om_, U$42$_] := If[LessEqual[t, 1.95e+105], N[Sqrt[N[(N[(N[(N[(-2.0 * N[(l * N[(l / Om), $MachinePrecision]), $MachinePrecision] + t), $MachinePrecision] * n), $MachinePrecision] * U), $MachinePrecision] * 2.0), $MachinePrecision]], $MachinePrecision], N[(N[Sqrt[t], $MachinePrecision] * N[Sqrt[N[(N[(n + n), $MachinePrecision] * U), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;t \leq 1.95 \cdot 10^{+105}:\\
\;\;\;\;\sqrt{\left(\left(\mathsf{fma}\left(-2, \ell \cdot \frac{\ell}{Om}, t\right) \cdot n\right) \cdot U\right) \cdot 2}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{t} \cdot \sqrt{\left(n + n\right) \cdot U}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < 1.94999999999999989e105

    1. Initial program 50.5%

      \[\sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \frac{\ell \cdot \ell}{Om}\right) - \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)} \]
    2. Taylor expanded in n around 0

      \[\leadsto \sqrt{\color{blue}{2 \cdot \left(U \cdot \left(n \cdot \left(t - 2 \cdot \frac{{\ell}^{2}}{Om}\right)\right)\right)}} \]
    3. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \sqrt{\left(U \cdot \left(n \cdot \left(t - 2 \cdot \frac{{\ell}^{2}}{Om}\right)\right)\right) \cdot \color{blue}{2}} \]
      2. lower-*.f64N/A

        \[\leadsto \sqrt{\left(U \cdot \left(n \cdot \left(t - 2 \cdot \frac{{\ell}^{2}}{Om}\right)\right)\right) \cdot \color{blue}{2}} \]
      3. *-commutativeN/A

        \[\leadsto \sqrt{\left(\left(n \cdot \left(t - 2 \cdot \frac{{\ell}^{2}}{Om}\right)\right) \cdot U\right) \cdot 2} \]
      4. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\left(n \cdot \left(t - 2 \cdot \frac{{\ell}^{2}}{Om}\right)\right) \cdot U\right) \cdot 2} \]
      5. *-commutativeN/A

        \[\leadsto \sqrt{\left(\left(\left(t - 2 \cdot \frac{{\ell}^{2}}{Om}\right) \cdot n\right) \cdot U\right) \cdot 2} \]
      6. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\left(\left(t - 2 \cdot \frac{{\ell}^{2}}{Om}\right) \cdot n\right) \cdot U\right) \cdot 2} \]
      7. fp-cancel-sub-sign-invN/A

        \[\leadsto \sqrt{\left(\left(\left(t + \left(\mathsf{neg}\left(2\right)\right) \cdot \frac{{\ell}^{2}}{Om}\right) \cdot n\right) \cdot U\right) \cdot 2} \]
      8. metadata-evalN/A

        \[\leadsto \sqrt{\left(\left(\left(t + -2 \cdot \frac{{\ell}^{2}}{Om}\right) \cdot n\right) \cdot U\right) \cdot 2} \]
      9. +-commutativeN/A

        \[\leadsto \sqrt{\left(\left(\left(-2 \cdot \frac{{\ell}^{2}}{Om} + t\right) \cdot n\right) \cdot U\right) \cdot 2} \]
      10. lower-fma.f64N/A

        \[\leadsto \sqrt{\left(\left(\mathsf{fma}\left(-2, \frac{{\ell}^{2}}{Om}, t\right) \cdot n\right) \cdot U\right) \cdot 2} \]
      11. pow2N/A

        \[\leadsto \sqrt{\left(\left(\mathsf{fma}\left(-2, \frac{\ell \cdot \ell}{Om}, t\right) \cdot n\right) \cdot U\right) \cdot 2} \]
      12. associate-/l*N/A

        \[\leadsto \sqrt{\left(\left(\mathsf{fma}\left(-2, \ell \cdot \frac{\ell}{Om}, t\right) \cdot n\right) \cdot U\right) \cdot 2} \]
      13. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\left(\mathsf{fma}\left(-2, \ell \cdot \frac{\ell}{Om}, t\right) \cdot n\right) \cdot U\right) \cdot 2} \]
      14. lift-/.f6447.6

        \[\leadsto \sqrt{\left(\left(\mathsf{fma}\left(-2, \ell \cdot \frac{\ell}{Om}, t\right) \cdot n\right) \cdot U\right) \cdot 2} \]
    4. Applied rewrites47.6%

      \[\leadsto \sqrt{\color{blue}{\left(\left(\mathsf{fma}\left(-2, \ell \cdot \frac{\ell}{Om}, t\right) \cdot n\right) \cdot U\right) \cdot 2}} \]

    if 1.94999999999999989e105 < t

    1. Initial program 50.5%

      \[\sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \frac{\ell \cdot \ell}{Om}\right) - \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)} \]
    2. Applied rewrites53.0%

      \[\leadsto \sqrt{\color{blue}{\left(\mathsf{fma}\left(-2, \ell \cdot \frac{\ell}{Om}, t\right) - n \cdot \left(\left(\frac{\ell}{Om} \cdot \frac{\ell}{Om}\right) \cdot \left(U - U*\right)\right)\right) \cdot \left(\left(n + n\right) \cdot U\right)}} \]
    3. Applied rewrites25.7%

      \[\leadsto \color{blue}{\sqrt{\mathsf{fma}\left(-2, \ell \cdot \frac{\ell}{Om}, t\right) - n \cdot \left(\frac{\ell \cdot \ell}{Om \cdot Om} \cdot \left(U - U*\right)\right)} \cdot \sqrt{\left(n + n\right) \cdot U}} \]
    4. Taylor expanded in t around inf

      \[\leadsto \color{blue}{\sqrt{t}} \cdot \sqrt{\left(n + n\right) \cdot U} \]
    5. Step-by-step derivation
      1. lower-sqrt.f6421.7

        \[\leadsto \sqrt{t} \cdot \sqrt{\left(n + n\right) \cdot U} \]
    6. Applied rewrites21.7%

      \[\leadsto \color{blue}{\sqrt{t}} \cdot \sqrt{\left(n + n\right) \cdot U} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 7: 41.4% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \frac{\ell \cdot \ell}{Om}\right) - \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)\\ \mathbf{if}\;t\_1 \leq 5 \cdot 10^{+203}:\\ \;\;\;\;\sqrt{\left(n + n\right) \cdot \left(U \cdot t\right)}\\ \mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+302}:\\ \;\;\;\;\sqrt{\left(\left(t \cdot n\right) \cdot U\right) \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{U* \cdot U} \cdot \frac{\left(\sqrt{2} \cdot n\right) \cdot \ell}{Om}\\ \end{array} \end{array} \]
(FPCore (n U t l Om U*)
 :precision binary64
 (let* ((t_1
         (*
          (* (* 2.0 n) U)
          (-
           (- t (* 2.0 (/ (* l l) Om)))
           (* (* n (pow (/ l Om) 2.0)) (- U U*))))))
   (if (<= t_1 5e+203)
     (sqrt (* (+ n n) (* U t)))
     (if (<= t_1 2e+302)
       (sqrt (* (* (* t n) U) 2.0))
       (* (sqrt (* U* U)) (/ (* (* (sqrt 2.0) n) l) Om))))))
double code(double n, double U, double t, double l, double Om, double U_42_) {
	double t_1 = ((2.0 * n) * U) * ((t - (2.0 * ((l * l) / Om))) - ((n * pow((l / Om), 2.0)) * (U - U_42_)));
	double tmp;
	if (t_1 <= 5e+203) {
		tmp = sqrt(((n + n) * (U * t)));
	} else if (t_1 <= 2e+302) {
		tmp = sqrt((((t * n) * U) * 2.0));
	} else {
		tmp = sqrt((U_42_ * U)) * (((sqrt(2.0) * n) * l) / Om);
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(n, u, t, l, om, u_42)
use fmin_fmax_functions
    real(8), intent (in) :: n
    real(8), intent (in) :: u
    real(8), intent (in) :: t
    real(8), intent (in) :: l
    real(8), intent (in) :: om
    real(8), intent (in) :: u_42
    real(8) :: t_1
    real(8) :: tmp
    t_1 = ((2.0d0 * n) * u) * ((t - (2.0d0 * ((l * l) / om))) - ((n * ((l / om) ** 2.0d0)) * (u - u_42)))
    if (t_1 <= 5d+203) then
        tmp = sqrt(((n + n) * (u * t)))
    else if (t_1 <= 2d+302) then
        tmp = sqrt((((t * n) * u) * 2.0d0))
    else
        tmp = sqrt((u_42 * u)) * (((sqrt(2.0d0) * n) * l) / om)
    end if
    code = tmp
end function
public static double code(double n, double U, double t, double l, double Om, double U_42_) {
	double t_1 = ((2.0 * n) * U) * ((t - (2.0 * ((l * l) / Om))) - ((n * Math.pow((l / Om), 2.0)) * (U - U_42_)));
	double tmp;
	if (t_1 <= 5e+203) {
		tmp = Math.sqrt(((n + n) * (U * t)));
	} else if (t_1 <= 2e+302) {
		tmp = Math.sqrt((((t * n) * U) * 2.0));
	} else {
		tmp = Math.sqrt((U_42_ * U)) * (((Math.sqrt(2.0) * n) * l) / Om);
	}
	return tmp;
}
def code(n, U, t, l, Om, U_42_):
	t_1 = ((2.0 * n) * U) * ((t - (2.0 * ((l * l) / Om))) - ((n * math.pow((l / Om), 2.0)) * (U - U_42_)))
	tmp = 0
	if t_1 <= 5e+203:
		tmp = math.sqrt(((n + n) * (U * t)))
	elif t_1 <= 2e+302:
		tmp = math.sqrt((((t * n) * U) * 2.0))
	else:
		tmp = math.sqrt((U_42_ * U)) * (((math.sqrt(2.0) * n) * l) / Om)
	return tmp
function code(n, U, t, l, Om, U_42_)
	t_1 = Float64(Float64(Float64(2.0 * n) * U) * Float64(Float64(t - Float64(2.0 * Float64(Float64(l * l) / Om))) - Float64(Float64(n * (Float64(l / Om) ^ 2.0)) * Float64(U - U_42_))))
	tmp = 0.0
	if (t_1 <= 5e+203)
		tmp = sqrt(Float64(Float64(n + n) * Float64(U * t)));
	elseif (t_1 <= 2e+302)
		tmp = sqrt(Float64(Float64(Float64(t * n) * U) * 2.0));
	else
		tmp = Float64(sqrt(Float64(U_42_ * U)) * Float64(Float64(Float64(sqrt(2.0) * n) * l) / Om));
	end
	return tmp
end
function tmp_2 = code(n, U, t, l, Om, U_42_)
	t_1 = ((2.0 * n) * U) * ((t - (2.0 * ((l * l) / Om))) - ((n * ((l / Om) ^ 2.0)) * (U - U_42_)));
	tmp = 0.0;
	if (t_1 <= 5e+203)
		tmp = sqrt(((n + n) * (U * t)));
	elseif (t_1 <= 2e+302)
		tmp = sqrt((((t * n) * U) * 2.0));
	else
		tmp = sqrt((U_42_ * U)) * (((sqrt(2.0) * n) * l) / Om);
	end
	tmp_2 = tmp;
end
code[n_, U_, t_, l_, Om_, U$42$_] := Block[{t$95$1 = N[(N[(N[(2.0 * n), $MachinePrecision] * U), $MachinePrecision] * N[(N[(t - N[(2.0 * N[(N[(l * l), $MachinePrecision] / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(n * N[Power[N[(l / Om), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(U - U$42$), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 5e+203], N[Sqrt[N[(N[(n + n), $MachinePrecision] * N[(U * t), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[t$95$1, 2e+302], N[Sqrt[N[(N[(N[(t * n), $MachinePrecision] * U), $MachinePrecision] * 2.0), $MachinePrecision]], $MachinePrecision], N[(N[Sqrt[N[(U$42$ * U), $MachinePrecision]], $MachinePrecision] * N[(N[(N[(N[Sqrt[2.0], $MachinePrecision] * n), $MachinePrecision] * l), $MachinePrecision] / Om), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \frac{\ell \cdot \ell}{Om}\right) - \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)\\
\mathbf{if}\;t\_1 \leq 5 \cdot 10^{+203}:\\
\;\;\;\;\sqrt{\left(n + n\right) \cdot \left(U \cdot t\right)}\\

\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+302}:\\
\;\;\;\;\sqrt{\left(\left(t \cdot n\right) \cdot U\right) \cdot 2}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{U* \cdot U} \cdot \frac{\left(\sqrt{2} \cdot n\right) \cdot \ell}{Om}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 (*.f64 (*.f64 #s(literal 2 binary64) n) U) (-.f64 (-.f64 t (*.f64 #s(literal 2 binary64) (/.f64 (*.f64 l l) Om))) (*.f64 (*.f64 n (pow.f64 (/.f64 l Om) #s(literal 2 binary64))) (-.f64 U U*)))) < 4.99999999999999994e203

    1. Initial program 50.5%

      \[\sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \frac{\ell \cdot \ell}{Om}\right) - \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)} \]
    2. Applied rewrites52.8%

      \[\leadsto \sqrt{\color{blue}{\left(n + n\right) \cdot \left(U \cdot \left(\mathsf{fma}\left(-2, \ell \cdot \frac{\ell}{Om}, t\right) - n \cdot \left(\left(\frac{\ell}{Om} \cdot \frac{\ell}{Om}\right) \cdot \left(U - U*\right)\right)\right)\right)}} \]
    3. Taylor expanded in t around inf

      \[\leadsto \sqrt{\left(n + n\right) \cdot \color{blue}{\left(U \cdot t\right)}} \]
    4. Step-by-step derivation
      1. lower-*.f6435.7

        \[\leadsto \sqrt{\left(n + n\right) \cdot \left(U \cdot \color{blue}{t}\right)} \]
    5. Applied rewrites35.7%

      \[\leadsto \sqrt{\left(n + n\right) \cdot \color{blue}{\left(U \cdot t\right)}} \]

    if 4.99999999999999994e203 < (*.f64 (*.f64 (*.f64 #s(literal 2 binary64) n) U) (-.f64 (-.f64 t (*.f64 #s(literal 2 binary64) (/.f64 (*.f64 l l) Om))) (*.f64 (*.f64 n (pow.f64 (/.f64 l Om) #s(literal 2 binary64))) (-.f64 U U*)))) < 2.0000000000000002e302

    1. Initial program 50.5%

      \[\sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \frac{\ell \cdot \ell}{Om}\right) - \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)} \]
    2. Taylor expanded in t around inf

      \[\leadsto \sqrt{\color{blue}{2 \cdot \left(U \cdot \left(n \cdot t\right)\right)}} \]
    3. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \sqrt{\left(U \cdot \left(n \cdot t\right)\right) \cdot \color{blue}{2}} \]
      2. lower-*.f64N/A

        \[\leadsto \sqrt{\left(U \cdot \left(n \cdot t\right)\right) \cdot \color{blue}{2}} \]
      3. *-commutativeN/A

        \[\leadsto \sqrt{\left(\left(n \cdot t\right) \cdot U\right) \cdot 2} \]
      4. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\left(n \cdot t\right) \cdot U\right) \cdot 2} \]
      5. *-commutativeN/A

        \[\leadsto \sqrt{\left(\left(t \cdot n\right) \cdot U\right) \cdot 2} \]
      6. lower-*.f6436.1

        \[\leadsto \sqrt{\left(\left(t \cdot n\right) \cdot U\right) \cdot 2} \]
    4. Applied rewrites36.1%

      \[\leadsto \sqrt{\color{blue}{\left(\left(t \cdot n\right) \cdot U\right) \cdot 2}} \]

    if 2.0000000000000002e302 < (*.f64 (*.f64 (*.f64 #s(literal 2 binary64) n) U) (-.f64 (-.f64 t (*.f64 #s(literal 2 binary64) (/.f64 (*.f64 l l) Om))) (*.f64 (*.f64 n (pow.f64 (/.f64 l Om) #s(literal 2 binary64))) (-.f64 U U*))))

    1. Initial program 50.5%

      \[\sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \frac{\ell \cdot \ell}{Om}\right) - \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)} \]
    2. Taylor expanded in U* around inf

      \[\leadsto \color{blue}{\frac{\ell \cdot \left(n \cdot \sqrt{2}\right)}{Om} \cdot \sqrt{U \cdot U*}} \]
    3. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \sqrt{U \cdot U*} \cdot \color{blue}{\frac{\ell \cdot \left(n \cdot \sqrt{2}\right)}{Om}} \]
      2. lower-*.f64N/A

        \[\leadsto \sqrt{U \cdot U*} \cdot \color{blue}{\frac{\ell \cdot \left(n \cdot \sqrt{2}\right)}{Om}} \]
      3. lower-sqrt.f64N/A

        \[\leadsto \sqrt{U \cdot U*} \cdot \frac{\color{blue}{\ell \cdot \left(n \cdot \sqrt{2}\right)}}{Om} \]
      4. *-commutativeN/A

        \[\leadsto \sqrt{U* \cdot U} \cdot \frac{\color{blue}{\ell} \cdot \left(n \cdot \sqrt{2}\right)}{Om} \]
      5. lower-*.f64N/A

        \[\leadsto \sqrt{U* \cdot U} \cdot \frac{\color{blue}{\ell} \cdot \left(n \cdot \sqrt{2}\right)}{Om} \]
      6. lower-/.f64N/A

        \[\leadsto \sqrt{U* \cdot U} \cdot \frac{\ell \cdot \left(n \cdot \sqrt{2}\right)}{\color{blue}{Om}} \]
      7. *-commutativeN/A

        \[\leadsto \sqrt{U* \cdot U} \cdot \frac{\left(n \cdot \sqrt{2}\right) \cdot \ell}{Om} \]
      8. lower-*.f64N/A

        \[\leadsto \sqrt{U* \cdot U} \cdot \frac{\left(n \cdot \sqrt{2}\right) \cdot \ell}{Om} \]
      9. *-commutativeN/A

        \[\leadsto \sqrt{U* \cdot U} \cdot \frac{\left(\sqrt{2} \cdot n\right) \cdot \ell}{Om} \]
      10. lower-*.f64N/A

        \[\leadsto \sqrt{U* \cdot U} \cdot \frac{\left(\sqrt{2} \cdot n\right) \cdot \ell}{Om} \]
      11. lower-sqrt.f6414.3

        \[\leadsto \sqrt{U* \cdot U} \cdot \frac{\left(\sqrt{2} \cdot n\right) \cdot \ell}{Om} \]
    4. Applied rewrites14.3%

      \[\leadsto \color{blue}{\sqrt{U* \cdot U} \cdot \frac{\left(\sqrt{2} \cdot n\right) \cdot \ell}{Om}} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 8: 38.6% accurate, 3.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;n \leq 3 \cdot 10^{-287}:\\ \;\;\;\;\sqrt{\left(\left(t \cdot n\right) \cdot U\right) \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{n + n} \cdot \sqrt{U \cdot t}\\ \end{array} \end{array} \]
(FPCore (n U t l Om U*)
 :precision binary64
 (if (<= n 3e-287)
   (sqrt (* (* (* t n) U) 2.0))
   (* (sqrt (+ n n)) (sqrt (* U t)))))
double code(double n, double U, double t, double l, double Om, double U_42_) {
	double tmp;
	if (n <= 3e-287) {
		tmp = sqrt((((t * n) * U) * 2.0));
	} else {
		tmp = sqrt((n + n)) * sqrt((U * t));
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(n, u, t, l, om, u_42)
use fmin_fmax_functions
    real(8), intent (in) :: n
    real(8), intent (in) :: u
    real(8), intent (in) :: t
    real(8), intent (in) :: l
    real(8), intent (in) :: om
    real(8), intent (in) :: u_42
    real(8) :: tmp
    if (n <= 3d-287) then
        tmp = sqrt((((t * n) * u) * 2.0d0))
    else
        tmp = sqrt((n + n)) * sqrt((u * t))
    end if
    code = tmp
end function
public static double code(double n, double U, double t, double l, double Om, double U_42_) {
	double tmp;
	if (n <= 3e-287) {
		tmp = Math.sqrt((((t * n) * U) * 2.0));
	} else {
		tmp = Math.sqrt((n + n)) * Math.sqrt((U * t));
	}
	return tmp;
}
def code(n, U, t, l, Om, U_42_):
	tmp = 0
	if n <= 3e-287:
		tmp = math.sqrt((((t * n) * U) * 2.0))
	else:
		tmp = math.sqrt((n + n)) * math.sqrt((U * t))
	return tmp
function code(n, U, t, l, Om, U_42_)
	tmp = 0.0
	if (n <= 3e-287)
		tmp = sqrt(Float64(Float64(Float64(t * n) * U) * 2.0));
	else
		tmp = Float64(sqrt(Float64(n + n)) * sqrt(Float64(U * t)));
	end
	return tmp
end
function tmp_2 = code(n, U, t, l, Om, U_42_)
	tmp = 0.0;
	if (n <= 3e-287)
		tmp = sqrt((((t * n) * U) * 2.0));
	else
		tmp = sqrt((n + n)) * sqrt((U * t));
	end
	tmp_2 = tmp;
end
code[n_, U_, t_, l_, Om_, U$42$_] := If[LessEqual[n, 3e-287], N[Sqrt[N[(N[(N[(t * n), $MachinePrecision] * U), $MachinePrecision] * 2.0), $MachinePrecision]], $MachinePrecision], N[(N[Sqrt[N[(n + n), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(U * t), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;n \leq 3 \cdot 10^{-287}:\\
\;\;\;\;\sqrt{\left(\left(t \cdot n\right) \cdot U\right) \cdot 2}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{n + n} \cdot \sqrt{U \cdot t}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if n < 2.99999999999999992e-287

    1. Initial program 50.5%

      \[\sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \frac{\ell \cdot \ell}{Om}\right) - \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)} \]
    2. Taylor expanded in t around inf

      \[\leadsto \sqrt{\color{blue}{2 \cdot \left(U \cdot \left(n \cdot t\right)\right)}} \]
    3. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \sqrt{\left(U \cdot \left(n \cdot t\right)\right) \cdot \color{blue}{2}} \]
      2. lower-*.f64N/A

        \[\leadsto \sqrt{\left(U \cdot \left(n \cdot t\right)\right) \cdot \color{blue}{2}} \]
      3. *-commutativeN/A

        \[\leadsto \sqrt{\left(\left(n \cdot t\right) \cdot U\right) \cdot 2} \]
      4. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\left(n \cdot t\right) \cdot U\right) \cdot 2} \]
      5. *-commutativeN/A

        \[\leadsto \sqrt{\left(\left(t \cdot n\right) \cdot U\right) \cdot 2} \]
      6. lower-*.f6436.1

        \[\leadsto \sqrt{\left(\left(t \cdot n\right) \cdot U\right) \cdot 2} \]
    4. Applied rewrites36.1%

      \[\leadsto \sqrt{\color{blue}{\left(\left(t \cdot n\right) \cdot U\right) \cdot 2}} \]

    if 2.99999999999999992e-287 < n

    1. Initial program 50.5%

      \[\sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \frac{\ell \cdot \ell}{Om}\right) - \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)} \]
    2. Applied rewrites52.8%

      \[\leadsto \sqrt{\color{blue}{\left(n + n\right) \cdot \left(U \cdot \left(\mathsf{fma}\left(-2, \ell \cdot \frac{\ell}{Om}, t\right) - n \cdot \left(\left(\frac{\ell}{Om} \cdot \frac{\ell}{Om}\right) \cdot \left(U - U*\right)\right)\right)\right)}} \]
    3. Taylor expanded in t around inf

      \[\leadsto \sqrt{\left(n + n\right) \cdot \color{blue}{\left(U \cdot t\right)}} \]
    4. Step-by-step derivation
      1. lower-*.f6435.7

        \[\leadsto \sqrt{\left(n + n\right) \cdot \left(U \cdot \color{blue}{t}\right)} \]
    5. Applied rewrites35.7%

      \[\leadsto \sqrt{\left(n + n\right) \cdot \color{blue}{\left(U \cdot t\right)}} \]
    6. Step-by-step derivation
      1. lift-sqrt.f64N/A

        \[\leadsto \color{blue}{\sqrt{\left(n + n\right) \cdot \left(U \cdot t\right)}} \]
      2. lift-*.f64N/A

        \[\leadsto \sqrt{\color{blue}{\left(n + n\right) \cdot \left(U \cdot t\right)}} \]
      3. sqrt-prodN/A

        \[\leadsto \color{blue}{\sqrt{n + n} \cdot \sqrt{U \cdot t}} \]
      4. lift-+.f64N/A

        \[\leadsto \sqrt{\color{blue}{n + n}} \cdot \sqrt{U \cdot t} \]
      5. lower-*.f64N/A

        \[\leadsto \color{blue}{\sqrt{n + n} \cdot \sqrt{U \cdot t}} \]
      6. lift-+.f64N/A

        \[\leadsto \sqrt{\color{blue}{n + n}} \cdot \sqrt{U \cdot t} \]
      7. lift-sqrt.f64N/A

        \[\leadsto \color{blue}{\sqrt{n + n}} \cdot \sqrt{U \cdot t} \]
      8. lower-sqrt.f6420.8

        \[\leadsto \sqrt{n + n} \cdot \color{blue}{\sqrt{U \cdot t}} \]
    7. Applied rewrites20.8%

      \[\leadsto \color{blue}{\sqrt{n + n} \cdot \sqrt{U \cdot t}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 9: 37.3% accurate, 3.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;t \leq 2 \cdot 10^{+134}:\\ \;\;\;\;\sqrt{\left(\left(t \cdot n\right) \cdot U\right) \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{t} \cdot \sqrt{\left(n + n\right) \cdot U}\\ \end{array} \end{array} \]
(FPCore (n U t l Om U*)
 :precision binary64
 (if (<= t 2e+134)
   (sqrt (* (* (* t n) U) 2.0))
   (* (sqrt t) (sqrt (* (+ n n) U)))))
double code(double n, double U, double t, double l, double Om, double U_42_) {
	double tmp;
	if (t <= 2e+134) {
		tmp = sqrt((((t * n) * U) * 2.0));
	} else {
		tmp = sqrt(t) * sqrt(((n + n) * U));
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(n, u, t, l, om, u_42)
use fmin_fmax_functions
    real(8), intent (in) :: n
    real(8), intent (in) :: u
    real(8), intent (in) :: t
    real(8), intent (in) :: l
    real(8), intent (in) :: om
    real(8), intent (in) :: u_42
    real(8) :: tmp
    if (t <= 2d+134) then
        tmp = sqrt((((t * n) * u) * 2.0d0))
    else
        tmp = sqrt(t) * sqrt(((n + n) * u))
    end if
    code = tmp
end function
public static double code(double n, double U, double t, double l, double Om, double U_42_) {
	double tmp;
	if (t <= 2e+134) {
		tmp = Math.sqrt((((t * n) * U) * 2.0));
	} else {
		tmp = Math.sqrt(t) * Math.sqrt(((n + n) * U));
	}
	return tmp;
}
def code(n, U, t, l, Om, U_42_):
	tmp = 0
	if t <= 2e+134:
		tmp = math.sqrt((((t * n) * U) * 2.0))
	else:
		tmp = math.sqrt(t) * math.sqrt(((n + n) * U))
	return tmp
function code(n, U, t, l, Om, U_42_)
	tmp = 0.0
	if (t <= 2e+134)
		tmp = sqrt(Float64(Float64(Float64(t * n) * U) * 2.0));
	else
		tmp = Float64(sqrt(t) * sqrt(Float64(Float64(n + n) * U)));
	end
	return tmp
end
function tmp_2 = code(n, U, t, l, Om, U_42_)
	tmp = 0.0;
	if (t <= 2e+134)
		tmp = sqrt((((t * n) * U) * 2.0));
	else
		tmp = sqrt(t) * sqrt(((n + n) * U));
	end
	tmp_2 = tmp;
end
code[n_, U_, t_, l_, Om_, U$42$_] := If[LessEqual[t, 2e+134], N[Sqrt[N[(N[(N[(t * n), $MachinePrecision] * U), $MachinePrecision] * 2.0), $MachinePrecision]], $MachinePrecision], N[(N[Sqrt[t], $MachinePrecision] * N[Sqrt[N[(N[(n + n), $MachinePrecision] * U), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;t \leq 2 \cdot 10^{+134}:\\
\;\;\;\;\sqrt{\left(\left(t \cdot n\right) \cdot U\right) \cdot 2}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{t} \cdot \sqrt{\left(n + n\right) \cdot U}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < 1.99999999999999984e134

    1. Initial program 50.5%

      \[\sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \frac{\ell \cdot \ell}{Om}\right) - \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)} \]
    2. Taylor expanded in t around inf

      \[\leadsto \sqrt{\color{blue}{2 \cdot \left(U \cdot \left(n \cdot t\right)\right)}} \]
    3. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \sqrt{\left(U \cdot \left(n \cdot t\right)\right) \cdot \color{blue}{2}} \]
      2. lower-*.f64N/A

        \[\leadsto \sqrt{\left(U \cdot \left(n \cdot t\right)\right) \cdot \color{blue}{2}} \]
      3. *-commutativeN/A

        \[\leadsto \sqrt{\left(\left(n \cdot t\right) \cdot U\right) \cdot 2} \]
      4. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\left(n \cdot t\right) \cdot U\right) \cdot 2} \]
      5. *-commutativeN/A

        \[\leadsto \sqrt{\left(\left(t \cdot n\right) \cdot U\right) \cdot 2} \]
      6. lower-*.f6436.1

        \[\leadsto \sqrt{\left(\left(t \cdot n\right) \cdot U\right) \cdot 2} \]
    4. Applied rewrites36.1%

      \[\leadsto \sqrt{\color{blue}{\left(\left(t \cdot n\right) \cdot U\right) \cdot 2}} \]

    if 1.99999999999999984e134 < t

    1. Initial program 50.5%

      \[\sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \frac{\ell \cdot \ell}{Om}\right) - \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)} \]
    2. Applied rewrites53.0%

      \[\leadsto \sqrt{\color{blue}{\left(\mathsf{fma}\left(-2, \ell \cdot \frac{\ell}{Om}, t\right) - n \cdot \left(\left(\frac{\ell}{Om} \cdot \frac{\ell}{Om}\right) \cdot \left(U - U*\right)\right)\right) \cdot \left(\left(n + n\right) \cdot U\right)}} \]
    3. Applied rewrites25.7%

      \[\leadsto \color{blue}{\sqrt{\mathsf{fma}\left(-2, \ell \cdot \frac{\ell}{Om}, t\right) - n \cdot \left(\frac{\ell \cdot \ell}{Om \cdot Om} \cdot \left(U - U*\right)\right)} \cdot \sqrt{\left(n + n\right) \cdot U}} \]
    4. Taylor expanded in t around inf

      \[\leadsto \color{blue}{\sqrt{t}} \cdot \sqrt{\left(n + n\right) \cdot U} \]
    5. Step-by-step derivation
      1. lower-sqrt.f6421.7

        \[\leadsto \sqrt{t} \cdot \sqrt{\left(n + n\right) \cdot U} \]
    6. Applied rewrites21.7%

      \[\leadsto \color{blue}{\sqrt{t}} \cdot \sqrt{\left(n + n\right) \cdot U} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 10: 36.2% accurate, 3.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;Om \leq 10^{+25}:\\ \;\;\;\;\sqrt{\left(\left(t \cdot n\right) \cdot U\right) \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\left(n + n\right) \cdot \left(U \cdot t\right)}\\ \end{array} \end{array} \]
(FPCore (n U t l Om U*)
 :precision binary64
 (if (<= Om 1e+25) (sqrt (* (* (* t n) U) 2.0)) (sqrt (* (+ n n) (* U t)))))
double code(double n, double U, double t, double l, double Om, double U_42_) {
	double tmp;
	if (Om <= 1e+25) {
		tmp = sqrt((((t * n) * U) * 2.0));
	} else {
		tmp = sqrt(((n + n) * (U * t)));
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(n, u, t, l, om, u_42)
use fmin_fmax_functions
    real(8), intent (in) :: n
    real(8), intent (in) :: u
    real(8), intent (in) :: t
    real(8), intent (in) :: l
    real(8), intent (in) :: om
    real(8), intent (in) :: u_42
    real(8) :: tmp
    if (om <= 1d+25) then
        tmp = sqrt((((t * n) * u) * 2.0d0))
    else
        tmp = sqrt(((n + n) * (u * t)))
    end if
    code = tmp
end function
public static double code(double n, double U, double t, double l, double Om, double U_42_) {
	double tmp;
	if (Om <= 1e+25) {
		tmp = Math.sqrt((((t * n) * U) * 2.0));
	} else {
		tmp = Math.sqrt(((n + n) * (U * t)));
	}
	return tmp;
}
def code(n, U, t, l, Om, U_42_):
	tmp = 0
	if Om <= 1e+25:
		tmp = math.sqrt((((t * n) * U) * 2.0))
	else:
		tmp = math.sqrt(((n + n) * (U * t)))
	return tmp
function code(n, U, t, l, Om, U_42_)
	tmp = 0.0
	if (Om <= 1e+25)
		tmp = sqrt(Float64(Float64(Float64(t * n) * U) * 2.0));
	else
		tmp = sqrt(Float64(Float64(n + n) * Float64(U * t)));
	end
	return tmp
end
function tmp_2 = code(n, U, t, l, Om, U_42_)
	tmp = 0.0;
	if (Om <= 1e+25)
		tmp = sqrt((((t * n) * U) * 2.0));
	else
		tmp = sqrt(((n + n) * (U * t)));
	end
	tmp_2 = tmp;
end
code[n_, U_, t_, l_, Om_, U$42$_] := If[LessEqual[Om, 1e+25], N[Sqrt[N[(N[(N[(t * n), $MachinePrecision] * U), $MachinePrecision] * 2.0), $MachinePrecision]], $MachinePrecision], N[Sqrt[N[(N[(n + n), $MachinePrecision] * N[(U * t), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;Om \leq 10^{+25}:\\
\;\;\;\;\sqrt{\left(\left(t \cdot n\right) \cdot U\right) \cdot 2}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{\left(n + n\right) \cdot \left(U \cdot t\right)}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if Om < 1.00000000000000009e25

    1. Initial program 50.5%

      \[\sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \frac{\ell \cdot \ell}{Om}\right) - \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)} \]
    2. Taylor expanded in t around inf

      \[\leadsto \sqrt{\color{blue}{2 \cdot \left(U \cdot \left(n \cdot t\right)\right)}} \]
    3. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \sqrt{\left(U \cdot \left(n \cdot t\right)\right) \cdot \color{blue}{2}} \]
      2. lower-*.f64N/A

        \[\leadsto \sqrt{\left(U \cdot \left(n \cdot t\right)\right) \cdot \color{blue}{2}} \]
      3. *-commutativeN/A

        \[\leadsto \sqrt{\left(\left(n \cdot t\right) \cdot U\right) \cdot 2} \]
      4. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\left(n \cdot t\right) \cdot U\right) \cdot 2} \]
      5. *-commutativeN/A

        \[\leadsto \sqrt{\left(\left(t \cdot n\right) \cdot U\right) \cdot 2} \]
      6. lower-*.f6436.1

        \[\leadsto \sqrt{\left(\left(t \cdot n\right) \cdot U\right) \cdot 2} \]
    4. Applied rewrites36.1%

      \[\leadsto \sqrt{\color{blue}{\left(\left(t \cdot n\right) \cdot U\right) \cdot 2}} \]

    if 1.00000000000000009e25 < Om

    1. Initial program 50.5%

      \[\sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \frac{\ell \cdot \ell}{Om}\right) - \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)} \]
    2. Applied rewrites52.8%

      \[\leadsto \sqrt{\color{blue}{\left(n + n\right) \cdot \left(U \cdot \left(\mathsf{fma}\left(-2, \ell \cdot \frac{\ell}{Om}, t\right) - n \cdot \left(\left(\frac{\ell}{Om} \cdot \frac{\ell}{Om}\right) \cdot \left(U - U*\right)\right)\right)\right)}} \]
    3. Taylor expanded in t around inf

      \[\leadsto \sqrt{\left(n + n\right) \cdot \color{blue}{\left(U \cdot t\right)}} \]
    4. Step-by-step derivation
      1. lower-*.f6435.7

        \[\leadsto \sqrt{\left(n + n\right) \cdot \left(U \cdot \color{blue}{t}\right)} \]
    5. Applied rewrites35.7%

      \[\leadsto \sqrt{\left(n + n\right) \cdot \color{blue}{\left(U \cdot t\right)}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 11: 35.7% accurate, 4.7× speedup?

\[\begin{array}{l} \\ \sqrt{\left(n + n\right) \cdot \left(U \cdot t\right)} \end{array} \]
(FPCore (n U t l Om U*) :precision binary64 (sqrt (* (+ n n) (* U t))))
double code(double n, double U, double t, double l, double Om, double U_42_) {
	return sqrt(((n + n) * (U * t)));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(n, u, t, l, om, u_42)
use fmin_fmax_functions
    real(8), intent (in) :: n
    real(8), intent (in) :: u
    real(8), intent (in) :: t
    real(8), intent (in) :: l
    real(8), intent (in) :: om
    real(8), intent (in) :: u_42
    code = sqrt(((n + n) * (u * t)))
end function
public static double code(double n, double U, double t, double l, double Om, double U_42_) {
	return Math.sqrt(((n + n) * (U * t)));
}
def code(n, U, t, l, Om, U_42_):
	return math.sqrt(((n + n) * (U * t)))
function code(n, U, t, l, Om, U_42_)
	return sqrt(Float64(Float64(n + n) * Float64(U * t)))
end
function tmp = code(n, U, t, l, Om, U_42_)
	tmp = sqrt(((n + n) * (U * t)));
end
code[n_, U_, t_, l_, Om_, U$42$_] := N[Sqrt[N[(N[(n + n), $MachinePrecision] * N[(U * t), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

\\
\sqrt{\left(n + n\right) \cdot \left(U \cdot t\right)}
\end{array}
Derivation
  1. Initial program 50.5%

    \[\sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \frac{\ell \cdot \ell}{Om}\right) - \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)} \]
  2. Applied rewrites52.8%

    \[\leadsto \sqrt{\color{blue}{\left(n + n\right) \cdot \left(U \cdot \left(\mathsf{fma}\left(-2, \ell \cdot \frac{\ell}{Om}, t\right) - n \cdot \left(\left(\frac{\ell}{Om} \cdot \frac{\ell}{Om}\right) \cdot \left(U - U*\right)\right)\right)\right)}} \]
  3. Taylor expanded in t around inf

    \[\leadsto \sqrt{\left(n + n\right) \cdot \color{blue}{\left(U \cdot t\right)}} \]
  4. Step-by-step derivation
    1. lower-*.f6435.7

      \[\leadsto \sqrt{\left(n + n\right) \cdot \left(U \cdot \color{blue}{t}\right)} \]
  5. Applied rewrites35.7%

    \[\leadsto \sqrt{\left(n + n\right) \cdot \color{blue}{\left(U \cdot t\right)}} \]
  6. Add Preprocessing

Reproduce

?
herbie shell --seed 2025134 
(FPCore (n U t l Om U*)
  :name "Toniolo and Linder, Equation (13)"
  :precision binary64
  (sqrt (* (* (* 2.0 n) U) (- (- t (* 2.0 (/ (* l l) Om))) (* (* n (pow (/ l Om) 2.0)) (- U U*))))))