Toniolo and Linder, Equation (13)

Percentage Accurate: 49.1% → 63.1%
Time: 8.3s
Alternatives: 13
Speedup: 0.7×

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 13 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: 49.1% 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: 63.1% accurate, 0.3× speedup?

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

\\
\begin{array}{l}
t_1 := {\left(\frac{\ell}{Om}\right)}^{2}\\
t_2 := \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 t\_1\right) \cdot \left(U - U*\right)\right)}\\
\mathbf{if}\;t\_2 \leq 0:\\
\;\;\;\;\sqrt{\left(n + n\right) \cdot \left(U \cdot \left(\mathsf{fma}\left(-2, \frac{{\ell}^{2}}{Om}, t\right) - \left(U - U*\right) \cdot \left(t\_1 \cdot n\right)\right)\right)}\\

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

\mathbf{else}:\\
\;\;\;\;\sqrt{\left(-2 \cdot U\right) \cdot \left(\left({\ell}^{2} \cdot n\right) \cdot \frac{\mathsf{fma}\left(n, \frac{U - U*}{Om}, 2\right)}{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 11.3%

      \[\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 rewrites37.3%

      \[\leadsto \sqrt{\color{blue}{\left(n + n\right) \cdot \left(U \cdot \left(\mathsf{fma}\left(-2, \frac{{\ell}^{2}}{Om}, t\right) - \left(U - U*\right) \cdot \left({\left(\frac{\ell}{Om}\right)}^{2} \cdot n\right)\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 68.3%

      \[\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 rewrites73.1%

      \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \color{blue}{\left(\ell \cdot \frac{\ell}{Om}\right)}\right) - \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)} \]
    3. Applied rewrites73.1%

      \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \left(\ell \cdot \frac{\ell}{Om}\right)\right) - \left(n \cdot \color{blue}{\left(\frac{\ell}{Om} \cdot \frac{\ell}{Om}\right)}\right) \cdot \left(U - U*\right)\right)} \]
    4. Applied rewrites73.7%

      \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \left(\ell \cdot \frac{\ell}{Om}\right)\right) - \color{blue}{\left(\left(n \cdot \frac{\ell}{Om}\right) \cdot \frac{\ell}{Om}\right)} \cdot \left(U - U*\right)\right)} \]
    5. Applied rewrites73.7%

      \[\leadsto \sqrt{\color{blue}{\left(\left(n + n\right) \cdot U\right)} \cdot \left(\left(t - 2 \cdot \left(\ell \cdot \frac{\ell}{Om}\right)\right) - \left(\left(n \cdot \frac{\ell}{Om}\right) \cdot \frac{\ell}{Om}\right) \cdot \left(U - U*\right)\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 0.0%

      \[\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. Applied rewrites31.9%

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

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

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

Alternative 2: 61.9% 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 0:\\ \;\;\;\;\sqrt{n \cdot \mathsf{fma}\left(-4, \frac{U \cdot {\ell}^{2}}{Om}, 2 \cdot \left(U \cdot t\right)\right)}\\ \mathbf{elif}\;t\_1 \leq \infty:\\ \;\;\;\;\sqrt{\left(\left(n + n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \left(\ell \cdot \frac{\ell}{Om}\right)\right) - \left(\left(n \cdot \frac{\ell}{Om}\right) \cdot \frac{\ell}{Om}\right) \cdot \left(U - U*\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\frac{2 \cdot \frac{U \cdot \left(U* \cdot {\left(\ell \cdot n\right)}^{2}\right)}{Om}}{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 0.0)
     (sqrt (* n (fma -4.0 (/ (* U (pow l 2.0)) Om) (* 2.0 (* U t)))))
     (if (<= t_1 INFINITY)
       (sqrt
        (*
         (* (+ n n) U)
         (-
          (- t (* 2.0 (* l (/ l Om))))
          (* (* (* n (/ l Om)) (/ l Om)) (- U U*)))))
       (sqrt (/ (* 2.0 (/ (* U (* U* (pow (* l n) 2.0))) Om)) 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 <= 0.0) {
		tmp = sqrt((n * fma(-4.0, ((U * pow(l, 2.0)) / Om), (2.0 * (U * t)))));
	} else if (t_1 <= ((double) INFINITY)) {
		tmp = sqrt((((n + n) * U) * ((t - (2.0 * (l * (l / Om)))) - (((n * (l / Om)) * (l / Om)) * (U - U_42_)))));
	} else {
		tmp = sqrt(((2.0 * ((U * (U_42_ * pow((l * n), 2.0))) / Om)) / 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 <= 0.0)
		tmp = sqrt(Float64(n * fma(-4.0, Float64(Float64(U * (l ^ 2.0)) / Om), Float64(2.0 * Float64(U * t)))));
	elseif (t_1 <= Inf)
		tmp = sqrt(Float64(Float64(Float64(n + n) * U) * Float64(Float64(t - Float64(2.0 * Float64(l * Float64(l / Om)))) - Float64(Float64(Float64(n * Float64(l / Om)) * Float64(l / Om)) * Float64(U - U_42_)))));
	else
		tmp = sqrt(Float64(Float64(2.0 * Float64(Float64(U * Float64(U_42_ * (Float64(l * n) ^ 2.0))) / Om)) / Om));
	end
	return 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, 0.0], N[Sqrt[N[(n * N[(-4.0 * N[(N[(U * N[Power[l, 2.0], $MachinePrecision]), $MachinePrecision] / Om), $MachinePrecision] + N[(2.0 * N[(U * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[Sqrt[N[(N[(N[(n + n), $MachinePrecision] * U), $MachinePrecision] * N[(N[(t - N[(2.0 * N[(l * N[(l / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(n * N[(l / Om), $MachinePrecision]), $MachinePrecision] * N[(l / Om), $MachinePrecision]), $MachinePrecision] * N[(U - U$42$), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[N[(N[(2.0 * N[(N[(U * N[(U$42$ * N[Power[N[(l * n), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / Om), $MachinePrecision]), $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 0:\\
\;\;\;\;\sqrt{n \cdot \mathsf{fma}\left(-4, \frac{U \cdot {\ell}^{2}}{Om}, 2 \cdot \left(U \cdot t\right)\right)}\\

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

\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{2 \cdot \frac{U \cdot \left(U* \cdot {\left(\ell \cdot n\right)}^{2}\right)}{Om}}{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*)))) < 0.0

    1. Initial program 9.9%

      \[\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 Om around inf

      \[\leadsto \sqrt{\color{blue}{-4 \cdot \frac{U \cdot \left({\ell}^{2} \cdot n\right)}{Om} + 2 \cdot \left(U \cdot \left(n \cdot t\right)\right)}} \]
    3. Applied rewrites32.7%

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

      \[\leadsto \sqrt{n \cdot \color{blue}{\left(-4 \cdot \frac{U \cdot {\ell}^{2}}{Om} + 2 \cdot \left(U \cdot t\right)\right)}} \]
    5. Applied rewrites33.4%

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

    if 0.0 < (*.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 68.3%

      \[\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 rewrites73.1%

      \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \color{blue}{\left(\ell \cdot \frac{\ell}{Om}\right)}\right) - \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)} \]
    3. Applied rewrites73.1%

      \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \left(\ell \cdot \frac{\ell}{Om}\right)\right) - \left(n \cdot \color{blue}{\left(\frac{\ell}{Om} \cdot \frac{\ell}{Om}\right)}\right) \cdot \left(U - U*\right)\right)} \]
    4. Applied rewrites73.7%

      \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \left(\ell \cdot \frac{\ell}{Om}\right)\right) - \color{blue}{\left(\left(n \cdot \frac{\ell}{Om}\right) \cdot \frac{\ell}{Om}\right)} \cdot \left(U - U*\right)\right)} \]
    5. Applied rewrites73.7%

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

    if +inf.0 < (*.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 0.0%

      \[\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. Applied rewrites33.9%

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

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

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

      \[\leadsto \sqrt{\frac{2 \cdot \frac{U \cdot \left(U* \cdot \left({\ell}^{2} \cdot {n}^{2}\right)\right)}{Om}}{Om}} \]
    7. Applied rewrites36.7%

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

Alternative 3: 61.5% accurate, 0.4× speedup?

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

\\
\begin{array}{l}
t_1 := \left(\left(n \cdot \frac{\ell}{Om}\right) \cdot \frac{\ell}{Om}\right) \cdot \left(U - U*\right)\\
t_2 := \left(2 \cdot n\right) \cdot U\\
t_3 := \sqrt{t\_2 \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\_3 \leq 0:\\
\;\;\;\;\sqrt{n \cdot \mathsf{fma}\left(-4, \frac{U \cdot {\ell}^{2}}{Om}, 2 \cdot \left(U \cdot t\right)\right)}\\

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

\mathbf{else}:\\
\;\;\;\;\sqrt{t\_2 \cdot \left(t - t\_1\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 11.3%

      \[\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 Om around inf

      \[\leadsto \sqrt{\color{blue}{-4 \cdot \frac{U \cdot \left({\ell}^{2} \cdot n\right)}{Om} + 2 \cdot \left(U \cdot \left(n \cdot t\right)\right)}} \]
    3. Applied rewrites34.3%

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

      \[\leadsto \sqrt{n \cdot \color{blue}{\left(-4 \cdot \frac{U \cdot {\ell}^{2}}{Om} + 2 \cdot \left(U \cdot t\right)\right)}} \]
    5. Applied rewrites35.0%

      \[\leadsto \sqrt{n \cdot \color{blue}{\mathsf{fma}\left(-4, \frac{U \cdot {\ell}^{2}}{Om}, 2 \cdot \left(U \cdot t\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 68.3%

      \[\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 rewrites73.1%

      \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \color{blue}{\left(\ell \cdot \frac{\ell}{Om}\right)}\right) - \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)} \]
    3. Applied rewrites73.1%

      \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \left(\ell \cdot \frac{\ell}{Om}\right)\right) - \left(n \cdot \color{blue}{\left(\frac{\ell}{Om} \cdot \frac{\ell}{Om}\right)}\right) \cdot \left(U - U*\right)\right)} \]
    4. Applied rewrites73.7%

      \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \left(\ell \cdot \frac{\ell}{Om}\right)\right) - \color{blue}{\left(\left(n \cdot \frac{\ell}{Om}\right) \cdot \frac{\ell}{Om}\right)} \cdot \left(U - U*\right)\right)} \]
    5. Applied rewrites73.7%

      \[\leadsto \sqrt{\color{blue}{\left(\left(n + n\right) \cdot U\right)} \cdot \left(\left(t - 2 \cdot \left(\ell \cdot \frac{\ell}{Om}\right)\right) - \left(\left(n \cdot \frac{\ell}{Om}\right) \cdot \frac{\ell}{Om}\right) \cdot \left(U - U*\right)\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 0.0%

      \[\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 rewrites5.2%

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

      \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \left(\ell \cdot \frac{\ell}{Om}\right)\right) - \left(n \cdot \color{blue}{\left(\frac{\ell}{Om} \cdot \frac{\ell}{Om}\right)}\right) \cdot \left(U - U*\right)\right)} \]
    4. Applied rewrites9.2%

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

      \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\color{blue}{t} - \left(\left(n \cdot \frac{\ell}{Om}\right) \cdot \frac{\ell}{Om}\right) \cdot \left(U - U*\right)\right)} \]
    6. Applied rewrites32.6%

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

Alternative 4: 61.5% accurate, 0.4× speedup?

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

\\
\begin{array}{l}
t_1 := \left(\left(n \cdot \frac{\ell}{Om}\right) \cdot \frac{\ell}{Om}\right) \cdot \left(U - U*\right)\\
t_2 := \left(2 \cdot n\right) \cdot U\\
t_3 := \sqrt{t\_2 \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\_3 \leq 0:\\
\;\;\;\;\sqrt{\left(2 \cdot U\right) \cdot \left(\mathsf{fma}\left(-2, \frac{{\ell}^{2}}{Om}, t\right) \cdot n\right)}\\

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

\mathbf{else}:\\
\;\;\;\;\sqrt{t\_2 \cdot \left(t - t\_1\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 11.3%

      \[\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. Applied rewrites35.1%

      \[\leadsto \sqrt{\color{blue}{\left(2 \cdot U\right) \cdot \left(\mathsf{fma}\left(-2, \frac{{\ell}^{2}}{Om}, t\right) \cdot n\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 68.3%

      \[\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 rewrites73.1%

      \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \color{blue}{\left(\ell \cdot \frac{\ell}{Om}\right)}\right) - \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)} \]
    3. Applied rewrites73.1%

      \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \left(\ell \cdot \frac{\ell}{Om}\right)\right) - \left(n \cdot \color{blue}{\left(\frac{\ell}{Om} \cdot \frac{\ell}{Om}\right)}\right) \cdot \left(U - U*\right)\right)} \]
    4. Applied rewrites73.7%

      \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \left(\ell \cdot \frac{\ell}{Om}\right)\right) - \color{blue}{\left(\left(n \cdot \frac{\ell}{Om}\right) \cdot \frac{\ell}{Om}\right)} \cdot \left(U - U*\right)\right)} \]
    5. Applied rewrites73.7%

      \[\leadsto \sqrt{\color{blue}{\left(\left(n + n\right) \cdot U\right)} \cdot \left(\left(t - 2 \cdot \left(\ell \cdot \frac{\ell}{Om}\right)\right) - \left(\left(n \cdot \frac{\ell}{Om}\right) \cdot \frac{\ell}{Om}\right) \cdot \left(U - U*\right)\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 0.0%

      \[\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 rewrites5.2%

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

      \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \left(\ell \cdot \frac{\ell}{Om}\right)\right) - \left(n \cdot \color{blue}{\left(\frac{\ell}{Om} \cdot \frac{\ell}{Om}\right)}\right) \cdot \left(U - U*\right)\right)} \]
    4. Applied rewrites9.2%

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

      \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\color{blue}{t} - \left(\left(n \cdot \frac{\ell}{Om}\right) \cdot \frac{\ell}{Om}\right) \cdot \left(U - U*\right)\right)} \]
    6. Applied rewrites32.6%

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

Alternative 5: 61.1% 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 := \left(\left(n \cdot \frac{\ell}{Om}\right) \cdot \frac{\ell}{Om}\right) \cdot \left(U - U*\right)\\ \mathbf{if}\;t\_2 \leq 0:\\ \;\;\;\;\sqrt{\left(t \cdot n\right) \cdot \left(U + U\right)}\\ \mathbf{elif}\;t\_2 \leq \infty:\\ \;\;\;\;\sqrt{\left(\left(n + n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \left(\ell \cdot \frac{\ell}{Om}\right)\right) - t\_3\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{t\_1 \cdot \left(t - t\_3\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*))))))
        (t_3 (* (* (* n (/ l Om)) (/ l Om)) (- U U*))))
   (if (<= t_2 0.0)
     (sqrt (* (* t n) (+ U U)))
     (if (<= t_2 INFINITY)
       (sqrt (* (* (+ n n) U) (- (- t (* 2.0 (* l (/ l Om)))) t_3)))
       (sqrt (* t_1 (- t t_3)))))))
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 = ((n * (l / Om)) * (l / Om)) * (U - U_42_);
	double tmp;
	if (t_2 <= 0.0) {
		tmp = sqrt(((t * n) * (U + U)));
	} else if (t_2 <= ((double) INFINITY)) {
		tmp = sqrt((((n + n) * U) * ((t - (2.0 * (l * (l / Om)))) - t_3)));
	} else {
		tmp = sqrt((t_1 * (t - t_3)));
	}
	return tmp;
}
public static 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 = Math.sqrt((t_1 * ((t - (2.0 * ((l * l) / Om))) - ((n * Math.pow((l / Om), 2.0)) * (U - U_42_)))));
	double t_3 = ((n * (l / Om)) * (l / Om)) * (U - U_42_);
	double tmp;
	if (t_2 <= 0.0) {
		tmp = Math.sqrt(((t * n) * (U + U)));
	} else if (t_2 <= Double.POSITIVE_INFINITY) {
		tmp = Math.sqrt((((n + n) * U) * ((t - (2.0 * (l * (l / Om)))) - t_3)));
	} else {
		tmp = Math.sqrt((t_1 * (t - t_3)));
	}
	return tmp;
}
def code(n, U, t, l, Om, U_42_):
	t_1 = (2.0 * n) * U
	t_2 = math.sqrt((t_1 * ((t - (2.0 * ((l * l) / Om))) - ((n * math.pow((l / Om), 2.0)) * (U - U_42_)))))
	t_3 = ((n * (l / Om)) * (l / Om)) * (U - U_42_)
	tmp = 0
	if t_2 <= 0.0:
		tmp = math.sqrt(((t * n) * (U + U)))
	elif t_2 <= math.inf:
		tmp = math.sqrt((((n + n) * U) * ((t - (2.0 * (l * (l / Om)))) - t_3)))
	else:
		tmp = math.sqrt((t_1 * (t - t_3)))
	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 = Float64(Float64(Float64(n * Float64(l / Om)) * Float64(l / Om)) * Float64(U - U_42_))
	tmp = 0.0
	if (t_2 <= 0.0)
		tmp = sqrt(Float64(Float64(t * n) * Float64(U + U)));
	elseif (t_2 <= Inf)
		tmp = sqrt(Float64(Float64(Float64(n + n) * U) * Float64(Float64(t - Float64(2.0 * Float64(l * Float64(l / Om)))) - t_3)));
	else
		tmp = sqrt(Float64(t_1 * Float64(t - t_3)));
	end
	return tmp
end
function tmp_2 = code(n, U, t, l, Om, U_42_)
	t_1 = (2.0 * n) * U;
	t_2 = sqrt((t_1 * ((t - (2.0 * ((l * l) / Om))) - ((n * ((l / Om) ^ 2.0)) * (U - U_42_)))));
	t_3 = ((n * (l / Om)) * (l / Om)) * (U - U_42_);
	tmp = 0.0;
	if (t_2 <= 0.0)
		tmp = sqrt(((t * n) * (U + U)));
	elseif (t_2 <= Inf)
		tmp = sqrt((((n + n) * U) * ((t - (2.0 * (l * (l / Om)))) - t_3)));
	else
		tmp = sqrt((t_1 * (t - t_3)));
	end
	tmp_2 = 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[(N[(N[(n * N[(l / Om), $MachinePrecision]), $MachinePrecision] * N[(l / Om), $MachinePrecision]), $MachinePrecision] * N[(U - U$42$), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, 0.0], N[Sqrt[N[(N[(t * n), $MachinePrecision] * N[(U + U), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[t$95$2, Infinity], N[Sqrt[N[(N[(N[(n + n), $MachinePrecision] * U), $MachinePrecision] * N[(N[(t - N[(2.0 * N[(l * N[(l / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[N[(t$95$1 * N[(t - t$95$3), $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)}\\
t_3 := \left(\left(n \cdot \frac{\ell}{Om}\right) \cdot \frac{\ell}{Om}\right) \cdot \left(U - U*\right)\\
\mathbf{if}\;t\_2 \leq 0:\\
\;\;\;\;\sqrt{\left(t \cdot n\right) \cdot \left(U + U\right)}\\

\mathbf{elif}\;t\_2 \leq \infty:\\
\;\;\;\;\sqrt{\left(\left(n + n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \left(\ell \cdot \frac{\ell}{Om}\right)\right) - t\_3\right)}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{t\_1 \cdot \left(t - t\_3\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 11.3%

      \[\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. Applied rewrites31.6%

      \[\leadsto \sqrt{\color{blue}{\left(\left(t \cdot n\right) \cdot U\right) \cdot 2}} \]
    4. Applied rewrites31.6%

      \[\leadsto \sqrt{\left(t \cdot n\right) \cdot \color{blue}{\left(U \cdot 2\right)}} \]
    5. Taylor expanded in U around 0

      \[\leadsto \sqrt{\left(t \cdot n\right) \cdot \left(2 \cdot \color{blue}{U}\right)} \]
    6. Applied rewrites31.6%

      \[\leadsto \sqrt{\left(t \cdot n\right) \cdot \left(U + \color{blue}{U}\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 68.3%

      \[\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 rewrites73.1%

      \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \color{blue}{\left(\ell \cdot \frac{\ell}{Om}\right)}\right) - \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)} \]
    3. Applied rewrites73.1%

      \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \left(\ell \cdot \frac{\ell}{Om}\right)\right) - \left(n \cdot \color{blue}{\left(\frac{\ell}{Om} \cdot \frac{\ell}{Om}\right)}\right) \cdot \left(U - U*\right)\right)} \]
    4. Applied rewrites73.7%

      \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \left(\ell \cdot \frac{\ell}{Om}\right)\right) - \color{blue}{\left(\left(n \cdot \frac{\ell}{Om}\right) \cdot \frac{\ell}{Om}\right)} \cdot \left(U - U*\right)\right)} \]
    5. Applied rewrites73.7%

      \[\leadsto \sqrt{\color{blue}{\left(\left(n + n\right) \cdot U\right)} \cdot \left(\left(t - 2 \cdot \left(\ell \cdot \frac{\ell}{Om}\right)\right) - \left(\left(n \cdot \frac{\ell}{Om}\right) \cdot \frac{\ell}{Om}\right) \cdot \left(U - U*\right)\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 0.0%

      \[\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 rewrites5.2%

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

      \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \left(\ell \cdot \frac{\ell}{Om}\right)\right) - \left(n \cdot \color{blue}{\left(\frac{\ell}{Om} \cdot \frac{\ell}{Om}\right)}\right) \cdot \left(U - U*\right)\right)} \]
    4. Applied rewrites9.2%

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

      \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\color{blue}{t} - \left(\left(n \cdot \frac{\ell}{Om}\right) \cdot \frac{\ell}{Om}\right) \cdot \left(U - U*\right)\right)} \]
    6. Applied rewrites32.6%

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

Alternative 6: 60.6% 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:\\ \;\;\;\;\sqrt{\left(t \cdot n\right) \cdot \left(U + U\right)}\\ \mathbf{elif}\;t\_2 \leq \infty:\\ \;\;\;\;\sqrt{\left(\left(n + n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \left(\ell \cdot \frac{\ell}{Om}\right)\right) - \left(n \cdot \left(\frac{\ell}{Om} \cdot \frac{\ell}{Om}\right)\right) \cdot \left(U - U*\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{t\_1 \cdot \left(t - \left(\left(n \cdot \frac{\ell}{Om}\right) \cdot \frac{\ell}{Om}\right) \cdot \left(U - U*\right)\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)
     (sqrt (* (* t n) (+ U U)))
     (if (<= t_2 INFINITY)
       (sqrt
        (*
         (* (+ n n) U)
         (-
          (- t (* 2.0 (* l (/ l Om))))
          (* (* n (* (/ l Om) (/ l Om))) (- U U*)))))
       (sqrt (* t_1 (- t (* (* (* n (/ l Om)) (/ l Om)) (- U U*)))))))))
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 = sqrt(((t * n) * (U + U)));
	} else if (t_2 <= ((double) INFINITY)) {
		tmp = sqrt((((n + n) * U) * ((t - (2.0 * (l * (l / Om)))) - ((n * ((l / Om) * (l / Om))) * (U - U_42_)))));
	} else {
		tmp = sqrt((t_1 * (t - (((n * (l / Om)) * (l / Om)) * (U - U_42_)))));
	}
	return tmp;
}
public static 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 = Math.sqrt((t_1 * ((t - (2.0 * ((l * l) / Om))) - ((n * Math.pow((l / Om), 2.0)) * (U - U_42_)))));
	double tmp;
	if (t_2 <= 0.0) {
		tmp = Math.sqrt(((t * n) * (U + U)));
	} else if (t_2 <= Double.POSITIVE_INFINITY) {
		tmp = Math.sqrt((((n + n) * U) * ((t - (2.0 * (l * (l / Om)))) - ((n * ((l / Om) * (l / Om))) * (U - U_42_)))));
	} else {
		tmp = Math.sqrt((t_1 * (t - (((n * (l / Om)) * (l / Om)) * (U - U_42_)))));
	}
	return tmp;
}
def code(n, U, t, l, Om, U_42_):
	t_1 = (2.0 * n) * U
	t_2 = math.sqrt((t_1 * ((t - (2.0 * ((l * l) / Om))) - ((n * math.pow((l / Om), 2.0)) * (U - U_42_)))))
	tmp = 0
	if t_2 <= 0.0:
		tmp = math.sqrt(((t * n) * (U + U)))
	elif t_2 <= math.inf:
		tmp = math.sqrt((((n + n) * U) * ((t - (2.0 * (l * (l / Om)))) - ((n * ((l / Om) * (l / Om))) * (U - U_42_)))))
	else:
		tmp = math.sqrt((t_1 * (t - (((n * (l / Om)) * (l / Om)) * (U - U_42_)))))
	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 = sqrt(Float64(Float64(t * n) * Float64(U + U)));
	elseif (t_2 <= Inf)
		tmp = sqrt(Float64(Float64(Float64(n + n) * U) * Float64(Float64(t - Float64(2.0 * Float64(l * Float64(l / Om)))) - Float64(Float64(n * Float64(Float64(l / Om) * Float64(l / Om))) * Float64(U - U_42_)))));
	else
		tmp = sqrt(Float64(t_1 * Float64(t - Float64(Float64(Float64(n * Float64(l / Om)) * Float64(l / Om)) * Float64(U - U_42_)))));
	end
	return tmp
end
function tmp_2 = code(n, U, t, l, Om, U_42_)
	t_1 = (2.0 * n) * U;
	t_2 = sqrt((t_1 * ((t - (2.0 * ((l * l) / Om))) - ((n * ((l / Om) ^ 2.0)) * (U - U_42_)))));
	tmp = 0.0;
	if (t_2 <= 0.0)
		tmp = sqrt(((t * n) * (U + U)));
	elseif (t_2 <= Inf)
		tmp = sqrt((((n + n) * U) * ((t - (2.0 * (l * (l / Om)))) - ((n * ((l / Om) * (l / Om))) * (U - U_42_)))));
	else
		tmp = sqrt((t_1 * (t - (((n * (l / Om)) * (l / Om)) * (U - U_42_)))));
	end
	tmp_2 = 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[Sqrt[N[(N[(t * n), $MachinePrecision] * N[(U + U), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[t$95$2, Infinity], N[Sqrt[N[(N[(N[(n + n), $MachinePrecision] * U), $MachinePrecision] * N[(N[(t - N[(2.0 * N[(l * N[(l / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(n * N[(N[(l / Om), $MachinePrecision] * N[(l / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(U - U$42$), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[N[(t$95$1 * N[(t - N[(N[(N[(n * N[(l / Om), $MachinePrecision]), $MachinePrecision] * N[(l / Om), $MachinePrecision]), $MachinePrecision] * N[(U - U$42$), $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:\\
\;\;\;\;\sqrt{\left(t \cdot n\right) \cdot \left(U + U\right)}\\

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

\mathbf{else}:\\
\;\;\;\;\sqrt{t\_1 \cdot \left(t - \left(\left(n \cdot \frac{\ell}{Om}\right) \cdot \frac{\ell}{Om}\right) \cdot \left(U - U*\right)\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 11.3%

      \[\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. Applied rewrites31.6%

      \[\leadsto \sqrt{\color{blue}{\left(\left(t \cdot n\right) \cdot U\right) \cdot 2}} \]
    4. Applied rewrites31.6%

      \[\leadsto \sqrt{\left(t \cdot n\right) \cdot \color{blue}{\left(U \cdot 2\right)}} \]
    5. Taylor expanded in U around 0

      \[\leadsto \sqrt{\left(t \cdot n\right) \cdot \left(2 \cdot \color{blue}{U}\right)} \]
    6. Applied rewrites31.6%

      \[\leadsto \sqrt{\left(t \cdot n\right) \cdot \left(U + \color{blue}{U}\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 68.3%

      \[\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 rewrites73.1%

      \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \color{blue}{\left(\ell \cdot \frac{\ell}{Om}\right)}\right) - \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)} \]
    3. Applied rewrites73.1%

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

      \[\leadsto \sqrt{\color{blue}{\left(\left(n + n\right) \cdot U\right)} \cdot \left(\left(t - 2 \cdot \left(\ell \cdot \frac{\ell}{Om}\right)\right) - \left(n \cdot \left(\frac{\ell}{Om} \cdot \frac{\ell}{Om}\right)\right) \cdot \left(U - U*\right)\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 0.0%

      \[\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 rewrites5.2%

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

      \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \left(\ell \cdot \frac{\ell}{Om}\right)\right) - \left(n \cdot \color{blue}{\left(\frac{\ell}{Om} \cdot \frac{\ell}{Om}\right)}\right) \cdot \left(U - U*\right)\right)} \]
    4. Applied rewrites9.2%

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

      \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\color{blue}{t} - \left(\left(n \cdot \frac{\ell}{Om}\right) \cdot \frac{\ell}{Om}\right) \cdot \left(U - U*\right)\right)} \]
    6. Applied rewrites32.6%

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

Alternative 7: 45.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^{+82}:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(\frac{\left(\left(\ell \cdot \ell\right) \cdot n\right) \cdot U}{Om}, -4, \left(\left(t \cdot n\right) \cdot U\right) \cdot 2\right)}\\ \mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+294}:\\ \;\;\;\;\sqrt{t \cdot \left(n \cdot \left(U + U\right)\right)}\\ \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+82)
     (sqrt (fma (/ (* (* (* l l) n) U) Om) -4.0 (* (* (* t n) U) 2.0)))
     (if (<= t_1 5e+294)
       (sqrt (* t (* n (+ U U))))
       (* (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+82) {
		tmp = sqrt(fma(((((l * l) * n) * U) / Om), -4.0, (((t * n) * U) * 2.0)));
	} else if (t_1 <= 5e+294) {
		tmp = sqrt((t * (n * (U + U))));
	} else {
		tmp = sqrt((U_42_ * U)) * (((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+82)
		tmp = sqrt(fma(Float64(Float64(Float64(Float64(l * l) * n) * U) / Om), -4.0, Float64(Float64(Float64(t * n) * U) * 2.0)));
	elseif (t_1 <= 5e+294)
		tmp = sqrt(Float64(t * Float64(n * Float64(U + U))));
	else
		tmp = Float64(sqrt(Float64(U_42_ * U)) * Float64(Float64(Float64(sqrt(2.0) * n) * l) / Om));
	end
	return 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+82], N[Sqrt[N[(N[(N[(N[(N[(l * l), $MachinePrecision] * n), $MachinePrecision] * U), $MachinePrecision] / Om), $MachinePrecision] * -4.0 + N[(N[(N[(t * n), $MachinePrecision] * U), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[t$95$1, 5e+294], N[Sqrt[N[(t * N[(n * N[(U + U), $MachinePrecision]), $MachinePrecision]), $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^{+82}:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(\frac{\left(\left(\ell \cdot \ell\right) \cdot n\right) \cdot U}{Om}, -4, \left(\left(t \cdot n\right) \cdot U\right) \cdot 2\right)}\\

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

\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*)))) < 5.00000000000000015e82

    1. Initial program 63.4%

      \[\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 Om around inf

      \[\leadsto \sqrt{\color{blue}{-4 \cdot \frac{U \cdot \left({\ell}^{2} \cdot n\right)}{Om} + 2 \cdot \left(U \cdot \left(n \cdot t\right)\right)}} \]
    3. Applied rewrites60.7%

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

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

    if 5.00000000000000015e82 < (*.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.9999999999999999e294

    1. Initial program 98.9%

      \[\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. Applied rewrites65.1%

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

      \[\leadsto \sqrt{\left(t \cdot n\right) \cdot \color{blue}{\left(U \cdot 2\right)}} \]
    5. Taylor expanded in U around 0

      \[\leadsto \sqrt{\left(t \cdot n\right) \cdot \left(2 \cdot \color{blue}{U}\right)} \]
    6. Applied rewrites65.1%

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

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

    if 4.9999999999999999e294 < (*.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 22.3%

      \[\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. Applied rewrites22.7%

      \[\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: 43.9% 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 0:\\ \;\;\;\;\sqrt{\left(t \cdot n\right) \cdot \left(U + U\right)}\\ \mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+294}:\\ \;\;\;\;\sqrt{t \cdot \left(n \cdot \left(U + U\right)\right)}\\ \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 0.0)
     (sqrt (* (* t n) (+ U U)))
     (if (<= t_1 5e+294)
       (sqrt (* t (* n (+ U U))))
       (* (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 <= 0.0) {
		tmp = sqrt(((t * n) * (U + U)));
	} else if (t_1 <= 5e+294) {
		tmp = sqrt((t * (n * (U + U))));
	} 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 <= 0.0d0) then
        tmp = sqrt(((t * n) * (u + u)))
    else if (t_1 <= 5d+294) then
        tmp = sqrt((t * (n * (u + u))))
    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 <= 0.0) {
		tmp = Math.sqrt(((t * n) * (U + U)));
	} else if (t_1 <= 5e+294) {
		tmp = Math.sqrt((t * (n * (U + U))));
	} 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 <= 0.0:
		tmp = math.sqrt(((t * n) * (U + U)))
	elif t_1 <= 5e+294:
		tmp = math.sqrt((t * (n * (U + U))))
	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 <= 0.0)
		tmp = sqrt(Float64(Float64(t * n) * Float64(U + U)));
	elseif (t_1 <= 5e+294)
		tmp = sqrt(Float64(t * Float64(n * Float64(U + U))));
	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 <= 0.0)
		tmp = sqrt(((t * n) * (U + U)));
	elseif (t_1 <= 5e+294)
		tmp = sqrt((t * (n * (U + U))));
	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, 0.0], N[Sqrt[N[(N[(t * n), $MachinePrecision] * N[(U + U), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[t$95$1, 5e+294], N[Sqrt[N[(t * N[(n * N[(U + U), $MachinePrecision]), $MachinePrecision]), $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 0:\\
\;\;\;\;\sqrt{\left(t \cdot n\right) \cdot \left(U + U\right)}\\

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

\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*)))) < 0.0

    1. Initial program 9.9%

      \[\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. Applied rewrites31.1%

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

      \[\leadsto \sqrt{\left(t \cdot n\right) \cdot \color{blue}{\left(U \cdot 2\right)}} \]
    5. Taylor expanded in U around 0

      \[\leadsto \sqrt{\left(t \cdot n\right) \cdot \left(2 \cdot \color{blue}{U}\right)} \]
    6. Applied rewrites31.2%

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

    if 0.0 < (*.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.9999999999999999e294

    1. Initial program 97.6%

      \[\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. Applied rewrites66.1%

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

      \[\leadsto \sqrt{\left(t \cdot n\right) \cdot \color{blue}{\left(U \cdot 2\right)}} \]
    5. Taylor expanded in U around 0

      \[\leadsto \sqrt{\left(t \cdot n\right) \cdot \left(2 \cdot \color{blue}{U}\right)} \]
    6. Applied rewrites66.1%

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

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

    if 4.9999999999999999e294 < (*.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 22.3%

      \[\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. Applied rewrites22.7%

      \[\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 9: 53.4% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \left(2 \cdot n\right) \cdot U\\ \mathbf{if}\;\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)} \leq 5 \cdot 10^{-91}:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(\frac{\left(\left(\ell \cdot \ell\right) \cdot n\right) \cdot U}{Om}, -4, \left(\left(t \cdot n\right) \cdot U\right) \cdot 2\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{t\_1 \cdot \left(t - \left(\left(n \cdot \frac{\ell}{Om}\right) \cdot \frac{\ell}{Om}\right) \cdot \left(U - U*\right)\right)}\\ \end{array} \end{array} \]
(FPCore (n U t l Om U*)
 :precision binary64
 (let* ((t_1 (* (* 2.0 n) U)))
   (if (<=
        (sqrt
         (*
          t_1
          (-
           (- t (* 2.0 (/ (* l l) Om)))
           (* (* n (pow (/ l Om) 2.0)) (- U U*)))))
        5e-91)
     (sqrt (fma (/ (* (* (* l l) n) U) Om) -4.0 (* (* (* t n) U) 2.0)))
     (sqrt (* t_1 (- t (* (* (* n (/ l Om)) (/ l Om)) (- U U*))))))))
double code(double n, double U, double t, double l, double Om, double U_42_) {
	double t_1 = (2.0 * n) * U;
	double tmp;
	if (sqrt((t_1 * ((t - (2.0 * ((l * l) / Om))) - ((n * pow((l / Om), 2.0)) * (U - U_42_))))) <= 5e-91) {
		tmp = sqrt(fma(((((l * l) * n) * U) / Om), -4.0, (((t * n) * U) * 2.0)));
	} else {
		tmp = sqrt((t_1 * (t - (((n * (l / Om)) * (l / Om)) * (U - U_42_)))));
	}
	return tmp;
}
function code(n, U, t, l, Om, U_42_)
	t_1 = Float64(Float64(2.0 * n) * U)
	tmp = 0.0
	if (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_))))) <= 5e-91)
		tmp = sqrt(fma(Float64(Float64(Float64(Float64(l * l) * n) * U) / Om), -4.0, Float64(Float64(Float64(t * n) * U) * 2.0)));
	else
		tmp = sqrt(Float64(t_1 * Float64(t - Float64(Float64(Float64(n * Float64(l / Om)) * Float64(l / Om)) * Float64(U - U_42_)))));
	end
	return tmp
end
code[n_, U_, t_, l_, Om_, U$42$_] := Block[{t$95$1 = N[(N[(2.0 * n), $MachinePrecision] * U), $MachinePrecision]}, If[LessEqual[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], 5e-91], N[Sqrt[N[(N[(N[(N[(N[(l * l), $MachinePrecision] * n), $MachinePrecision] * U), $MachinePrecision] / Om), $MachinePrecision] * -4.0 + N[(N[(N[(t * n), $MachinePrecision] * U), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[N[(t$95$1 * N[(t - N[(N[(N[(n * N[(l / Om), $MachinePrecision]), $MachinePrecision] * N[(l / Om), $MachinePrecision]), $MachinePrecision] * N[(U - U$42$), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \left(2 \cdot n\right) \cdot U\\
\mathbf{if}\;\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)} \leq 5 \cdot 10^{-91}:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(\frac{\left(\left(\ell \cdot \ell\right) \cdot n\right) \cdot U}{Om}, -4, \left(\left(t \cdot n\right) \cdot U\right) \cdot 2\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 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*))))) < 4.99999999999999997e-91

    1. Initial program 36.3%

      \[\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 Om around inf

      \[\leadsto \sqrt{\color{blue}{-4 \cdot \frac{U \cdot \left({\ell}^{2} \cdot n\right)}{Om} + 2 \cdot \left(U \cdot \left(n \cdot t\right)\right)}} \]
    3. Applied rewrites44.7%

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

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

    if 4.99999999999999997e-91 < (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 52.2%

      \[\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 rewrites57.4%

      \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \color{blue}{\left(\ell \cdot \frac{\ell}{Om}\right)}\right) - \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)} \]
    3. Applied rewrites57.4%

      \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \left(\ell \cdot \frac{\ell}{Om}\right)\right) - \left(n \cdot \color{blue}{\left(\frac{\ell}{Om} \cdot \frac{\ell}{Om}\right)}\right) \cdot \left(U - U*\right)\right)} \]
    4. Applied rewrites58.7%

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

      \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\color{blue}{t} - \left(\left(n \cdot \frac{\ell}{Om}\right) \cdot \frac{\ell}{Om}\right) \cdot \left(U - U*\right)\right)} \]
    6. Applied rewrites55.6%

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

Alternative 10: 52.7% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \left(2 \cdot n\right) \cdot U\\ \mathbf{if}\;\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)} \leq 5 \cdot 10^{-91}:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(\frac{\left(\left(\ell \cdot \ell\right) \cdot n\right) \cdot U}{Om}, -4, \left(\left(t \cdot n\right) \cdot U\right) \cdot 2\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{t\_1 \cdot \left(t - \left(n \cdot \left(\frac{\ell}{Om} \cdot \frac{\ell}{Om}\right)\right) \cdot \left(U - U*\right)\right)}\\ \end{array} \end{array} \]
(FPCore (n U t l Om U*)
 :precision binary64
 (let* ((t_1 (* (* 2.0 n) U)))
   (if (<=
        (sqrt
         (*
          t_1
          (-
           (- t (* 2.0 (/ (* l l) Om)))
           (* (* n (pow (/ l Om) 2.0)) (- U U*)))))
        5e-91)
     (sqrt (fma (/ (* (* (* l l) n) U) Om) -4.0 (* (* (* t n) U) 2.0)))
     (sqrt (* t_1 (- t (* (* n (* (/ l Om) (/ l Om))) (- U U*))))))))
double code(double n, double U, double t, double l, double Om, double U_42_) {
	double t_1 = (2.0 * n) * U;
	double tmp;
	if (sqrt((t_1 * ((t - (2.0 * ((l * l) / Om))) - ((n * pow((l / Om), 2.0)) * (U - U_42_))))) <= 5e-91) {
		tmp = sqrt(fma(((((l * l) * n) * U) / Om), -4.0, (((t * n) * U) * 2.0)));
	} else {
		tmp = sqrt((t_1 * (t - ((n * ((l / Om) * (l / Om))) * (U - U_42_)))));
	}
	return tmp;
}
function code(n, U, t, l, Om, U_42_)
	t_1 = Float64(Float64(2.0 * n) * U)
	tmp = 0.0
	if (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_))))) <= 5e-91)
		tmp = sqrt(fma(Float64(Float64(Float64(Float64(l * l) * n) * U) / Om), -4.0, Float64(Float64(Float64(t * n) * U) * 2.0)));
	else
		tmp = sqrt(Float64(t_1 * Float64(t - Float64(Float64(n * Float64(Float64(l / Om) * Float64(l / Om))) * Float64(U - U_42_)))));
	end
	return tmp
end
code[n_, U_, t_, l_, Om_, U$42$_] := Block[{t$95$1 = N[(N[(2.0 * n), $MachinePrecision] * U), $MachinePrecision]}, If[LessEqual[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], 5e-91], N[Sqrt[N[(N[(N[(N[(N[(l * l), $MachinePrecision] * n), $MachinePrecision] * U), $MachinePrecision] / Om), $MachinePrecision] * -4.0 + N[(N[(N[(t * n), $MachinePrecision] * U), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[N[(t$95$1 * N[(t - N[(N[(n * N[(N[(l / Om), $MachinePrecision] * N[(l / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(U - U$42$), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \left(2 \cdot n\right) \cdot U\\
\mathbf{if}\;\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)} \leq 5 \cdot 10^{-91}:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(\frac{\left(\left(\ell \cdot \ell\right) \cdot n\right) \cdot U}{Om}, -4, \left(\left(t \cdot n\right) \cdot U\right) \cdot 2\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 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*))))) < 4.99999999999999997e-91

    1. Initial program 36.3%

      \[\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 Om around inf

      \[\leadsto \sqrt{\color{blue}{-4 \cdot \frac{U \cdot \left({\ell}^{2} \cdot n\right)}{Om} + 2 \cdot \left(U \cdot \left(n \cdot t\right)\right)}} \]
    3. Applied rewrites44.7%

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

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

    if 4.99999999999999997e-91 < (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 52.2%

      \[\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 rewrites57.4%

      \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \color{blue}{\left(\ell \cdot \frac{\ell}{Om}\right)}\right) - \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)} \]
    3. Applied rewrites57.4%

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

      \[\leadsto \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\color{blue}{t} - \left(n \cdot \left(\frac{\ell}{Om} \cdot \frac{\ell}{Om}\right)\right) \cdot \left(U - U*\right)\right)} \]
    5. Applied rewrites54.6%

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

Alternative 11: 37.2% accurate, 3.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq 1.65 \cdot 10^{-167}:\\ \;\;\;\;\sqrt{t \cdot \left(n \cdot \left(U + U\right)\right)}\\ \mathbf{elif}\;\ell \leq 1.3 \cdot 10^{+40}:\\ \;\;\;\;\sqrt{\left(t \cdot n\right) \cdot \left(U + U\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\left(-2 \cdot U\right) \cdot \left(\left(\left(\ell \cdot \ell\right) \cdot n\right) \cdot \frac{2}{Om}\right)}\\ \end{array} \end{array} \]
(FPCore (n U t l Om U*)
 :precision binary64
 (if (<= l 1.65e-167)
   (sqrt (* t (* n (+ U U))))
   (if (<= l 1.3e+40)
     (sqrt (* (* t n) (+ U U)))
     (sqrt (* (* -2.0 U) (* (* (* l l) n) (/ 2.0 Om)))))))
double code(double n, double U, double t, double l, double Om, double U_42_) {
	double tmp;
	if (l <= 1.65e-167) {
		tmp = sqrt((t * (n * (U + U))));
	} else if (l <= 1.3e+40) {
		tmp = sqrt(((t * n) * (U + U)));
	} else {
		tmp = sqrt(((-2.0 * U) * (((l * l) * n) * (2.0 / 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) :: tmp
    if (l <= 1.65d-167) then
        tmp = sqrt((t * (n * (u + u))))
    else if (l <= 1.3d+40) then
        tmp = sqrt(((t * n) * (u + u)))
    else
        tmp = sqrt((((-2.0d0) * u) * (((l * l) * n) * (2.0d0 / 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 tmp;
	if (l <= 1.65e-167) {
		tmp = Math.sqrt((t * (n * (U + U))));
	} else if (l <= 1.3e+40) {
		tmp = Math.sqrt(((t * n) * (U + U)));
	} else {
		tmp = Math.sqrt(((-2.0 * U) * (((l * l) * n) * (2.0 / Om))));
	}
	return tmp;
}
def code(n, U, t, l, Om, U_42_):
	tmp = 0
	if l <= 1.65e-167:
		tmp = math.sqrt((t * (n * (U + U))))
	elif l <= 1.3e+40:
		tmp = math.sqrt(((t * n) * (U + U)))
	else:
		tmp = math.sqrt(((-2.0 * U) * (((l * l) * n) * (2.0 / Om))))
	return tmp
function code(n, U, t, l, Om, U_42_)
	tmp = 0.0
	if (l <= 1.65e-167)
		tmp = sqrt(Float64(t * Float64(n * Float64(U + U))));
	elseif (l <= 1.3e+40)
		tmp = sqrt(Float64(Float64(t * n) * Float64(U + U)));
	else
		tmp = sqrt(Float64(Float64(-2.0 * U) * Float64(Float64(Float64(l * l) * n) * Float64(2.0 / Om))));
	end
	return tmp
end
function tmp_2 = code(n, U, t, l, Om, U_42_)
	tmp = 0.0;
	if (l <= 1.65e-167)
		tmp = sqrt((t * (n * (U + U))));
	elseif (l <= 1.3e+40)
		tmp = sqrt(((t * n) * (U + U)));
	else
		tmp = sqrt(((-2.0 * U) * (((l * l) * n) * (2.0 / Om))));
	end
	tmp_2 = tmp;
end
code[n_, U_, t_, l_, Om_, U$42$_] := If[LessEqual[l, 1.65e-167], N[Sqrt[N[(t * N[(n * N[(U + U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[l, 1.3e+40], N[Sqrt[N[(N[(t * n), $MachinePrecision] * N[(U + U), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[N[(N[(-2.0 * U), $MachinePrecision] * N[(N[(N[(l * l), $MachinePrecision] * n), $MachinePrecision] * N[(2.0 / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 1.65 \cdot 10^{-167}:\\
\;\;\;\;\sqrt{t \cdot \left(n \cdot \left(U + U\right)\right)}\\

\mathbf{elif}\;\ell \leq 1.3 \cdot 10^{+40}:\\
\;\;\;\;\sqrt{\left(t \cdot n\right) \cdot \left(U + U\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < 1.64999999999999998e-167

    1. Initial program 52.2%

      \[\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. Applied rewrites39.6%

      \[\leadsto \sqrt{\color{blue}{\left(\left(t \cdot n\right) \cdot U\right) \cdot 2}} \]
    4. Applied rewrites39.6%

      \[\leadsto \sqrt{\left(t \cdot n\right) \cdot \color{blue}{\left(U \cdot 2\right)}} \]
    5. Taylor expanded in U around 0

      \[\leadsto \sqrt{\left(t \cdot n\right) \cdot \left(2 \cdot \color{blue}{U}\right)} \]
    6. Applied rewrites39.6%

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

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

    if 1.64999999999999998e-167 < l < 1.3e40

    1. Initial program 58.3%

      \[\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. Applied rewrites43.3%

      \[\leadsto \sqrt{\color{blue}{\left(\left(t \cdot n\right) \cdot U\right) \cdot 2}} \]
    4. Applied rewrites43.3%

      \[\leadsto \sqrt{\left(t \cdot n\right) \cdot \color{blue}{\left(U \cdot 2\right)}} \]
    5. Taylor expanded in U around 0

      \[\leadsto \sqrt{\left(t \cdot n\right) \cdot \left(2 \cdot \color{blue}{U}\right)} \]
    6. Applied rewrites43.3%

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

    if 1.3e40 < l

    1. Initial program 30.7%

      \[\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. Applied rewrites35.3%

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

      \[\leadsto \sqrt{\left(-2 \cdot U\right) \cdot \left(\left({\ell}^{2} \cdot n\right) \cdot \frac{2}{\color{blue}{Om}}\right)} \]
    5. Applied rewrites23.6%

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

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

Alternative 12: 35.6% accurate, 5.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq 1.65 \cdot 10^{-167}:\\ \;\;\;\;\sqrt{t \cdot \left(n \cdot \left(U + U\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\left(t \cdot n\right) \cdot \left(U + U\right)}\\ \end{array} \end{array} \]
(FPCore (n U t l Om U*)
 :precision binary64
 (if (<= l 1.65e-167) (sqrt (* t (* n (+ U U)))) (sqrt (* (* t n) (+ U U)))))
double code(double n, double U, double t, double l, double Om, double U_42_) {
	double tmp;
	if (l <= 1.65e-167) {
		tmp = sqrt((t * (n * (U + U))));
	} else {
		tmp = sqrt(((t * n) * (U + 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 (l <= 1.65d-167) then
        tmp = sqrt((t * (n * (u + u))))
    else
        tmp = sqrt(((t * n) * (u + 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 (l <= 1.65e-167) {
		tmp = Math.sqrt((t * (n * (U + U))));
	} else {
		tmp = Math.sqrt(((t * n) * (U + U)));
	}
	return tmp;
}
def code(n, U, t, l, Om, U_42_):
	tmp = 0
	if l <= 1.65e-167:
		tmp = math.sqrt((t * (n * (U + U))))
	else:
		tmp = math.sqrt(((t * n) * (U + U)))
	return tmp
function code(n, U, t, l, Om, U_42_)
	tmp = 0.0
	if (l <= 1.65e-167)
		tmp = sqrt(Float64(t * Float64(n * Float64(U + U))));
	else
		tmp = sqrt(Float64(Float64(t * n) * Float64(U + U)));
	end
	return tmp
end
function tmp_2 = code(n, U, t, l, Om, U_42_)
	tmp = 0.0;
	if (l <= 1.65e-167)
		tmp = sqrt((t * (n * (U + U))));
	else
		tmp = sqrt(((t * n) * (U + U)));
	end
	tmp_2 = tmp;
end
code[n_, U_, t_, l_, Om_, U$42$_] := If[LessEqual[l, 1.65e-167], N[Sqrt[N[(t * N[(n * N[(U + U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[N[(N[(t * n), $MachinePrecision] * N[(U + U), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 1.65 \cdot 10^{-167}:\\
\;\;\;\;\sqrt{t \cdot \left(n \cdot \left(U + U\right)\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < 1.64999999999999998e-167

    1. Initial program 52.2%

      \[\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. Applied rewrites39.6%

      \[\leadsto \sqrt{\color{blue}{\left(\left(t \cdot n\right) \cdot U\right) \cdot 2}} \]
    4. Applied rewrites39.6%

      \[\leadsto \sqrt{\left(t \cdot n\right) \cdot \color{blue}{\left(U \cdot 2\right)}} \]
    5. Taylor expanded in U around 0

      \[\leadsto \sqrt{\left(t \cdot n\right) \cdot \left(2 \cdot \color{blue}{U}\right)} \]
    6. Applied rewrites39.6%

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

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

    if 1.64999999999999998e-167 < l

    1. Initial program 43.6%

      \[\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. Applied rewrites28.4%

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

      \[\leadsto \sqrt{\left(t \cdot n\right) \cdot \color{blue}{\left(U \cdot 2\right)}} \]
    5. Taylor expanded in U around 0

      \[\leadsto \sqrt{\left(t \cdot n\right) \cdot \left(2 \cdot \color{blue}{U}\right)} \]
    6. Applied rewrites28.4%

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

Alternative 13: 35.4% accurate, 7.4× speedup?

\[\begin{array}{l} \\ \sqrt{t \cdot \left(n \cdot \left(U + U\right)\right)} \end{array} \]
(FPCore (n U t l Om U*) :precision binary64 (sqrt (* t (* n (+ U U)))))
double code(double n, double U, double t, double l, double Om, double U_42_) {
	return sqrt((t * (n * (U + U))));
}
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((t * (n * (u + u))))
end function
public static double code(double n, double U, double t, double l, double Om, double U_42_) {
	return Math.sqrt((t * (n * (U + U))));
}
def code(n, U, t, l, Om, U_42_):
	return math.sqrt((t * (n * (U + U))))
function code(n, U, t, l, Om, U_42_)
	return sqrt(Float64(t * Float64(n * Float64(U + U))))
end
function tmp = code(n, U, t, l, Om, U_42_)
	tmp = sqrt((t * (n * (U + U))));
end
code[n_, U_, t_, l_, Om_, U$42$_] := N[Sqrt[N[(t * N[(n * N[(U + U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

\\
\sqrt{t \cdot \left(n \cdot \left(U + U\right)\right)}
\end{array}
Derivation
  1. Initial program 49.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)} \]
  2. Taylor expanded in t around inf

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

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

    \[\leadsto \sqrt{\left(t \cdot n\right) \cdot \color{blue}{\left(U \cdot 2\right)}} \]
  5. Taylor expanded in U around 0

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

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

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

Reproduce

?
herbie shell --seed 2025101 
(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*))))))