Average Error: 34.8 → 26.1
Time: 12.3s
Precision: binary64
\[\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)} \]
\[\begin{array}{l} t_1 := \sqrt{\mathsf{fma}\left(-2, \frac{n}{Om} \cdot \left(\left(2 + \frac{n}{Om} \cdot \left(U - U*\right)\right) \cdot \left(\ell \cdot \left(\ell \cdot U\right)\right)\right), 2 \cdot \left(n \cdot \left(U \cdot t\right)\right)\right)}\\ \mathbf{if}\;\ell \leq -5.4 \cdot 10^{+93}:\\ \;\;\;\;\sqrt{2} \cdot \left(\sqrt{\frac{n \cdot \left(U \cdot \left(\frac{n \cdot \left(U* - U\right)}{Om} + -2\right)\right)}{Om}} \cdot \left(-\ell\right)\right)\\ \mathbf{elif}\;\ell \leq -1.25 \cdot 10^{-72}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\ell \leq 2.1 \cdot 10^{-32}:\\ \;\;\;\;\sqrt{\left(2 \cdot \left(n \cdot U\right)\right) \cdot \left(t + \frac{\ell}{Om} \cdot \mathsf{fma}\left(\ell, -2, \left(U* - U\right) \cdot \left(n \cdot \frac{\ell}{Om}\right)\right)\right)}\\ \mathbf{elif}\;\ell \leq 1.55 \cdot 10^{+134}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\sqrt{2} \cdot \left(\ell \cdot \sqrt{\left(n \cdot U\right) \cdot \mathsf{fma}\left(\frac{n}{Om}, \frac{U* - U}{Om}, \frac{-2}{Om}\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*))))))
(FPCore (n U t l Om U*)
 :precision binary64
 (let* ((t_1
         (sqrt
          (fma
           -2.0
           (* (/ n Om) (* (+ 2.0 (* (/ n Om) (- U U*))) (* l (* l U))))
           (* 2.0 (* n (* U t)))))))
   (if (<= l -5.4e+93)
     (*
      (sqrt 2.0)
      (* (sqrt (/ (* n (* U (+ (/ (* n (- U* U)) Om) -2.0))) Om)) (- l)))
     (if (<= l -1.25e-72)
       t_1
       (if (<= l 2.1e-32)
         (sqrt
          (*
           (* 2.0 (* n U))
           (+ t (* (/ l Om) (fma l -2.0 (* (- U* U) (* n (/ l Om))))))))
         (if (<= l 1.55e+134)
           t_1
           (*
            (sqrt 2.0)
            (*
             l
             (sqrt
              (* (* n U) (fma (/ n Om) (/ (- U* U) Om) (/ -2.0 Om))))))))))))
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_)))));
}
double code(double n, double U, double t, double l, double Om, double U_42_) {
	double t_1 = sqrt(fma(-2.0, ((n / Om) * ((2.0 + ((n / Om) * (U - U_42_))) * (l * (l * U)))), (2.0 * (n * (U * t)))));
	double tmp;
	if (l <= -5.4e+93) {
		tmp = sqrt(2.0) * (sqrt(((n * (U * (((n * (U_42_ - U)) / Om) + -2.0))) / Om)) * -l);
	} else if (l <= -1.25e-72) {
		tmp = t_1;
	} else if (l <= 2.1e-32) {
		tmp = sqrt(((2.0 * (n * U)) * (t + ((l / Om) * fma(l, -2.0, ((U_42_ - U) * (n * (l / Om))))))));
	} else if (l <= 1.55e+134) {
		tmp = t_1;
	} else {
		tmp = sqrt(2.0) * (l * sqrt(((n * U) * fma((n / Om), ((U_42_ - U) / Om), (-2.0 / Om)))));
	}
	return tmp;
}
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 code(n, U, t, l, Om, U_42_)
	t_1 = sqrt(fma(-2.0, Float64(Float64(n / Om) * Float64(Float64(2.0 + Float64(Float64(n / Om) * Float64(U - U_42_))) * Float64(l * Float64(l * U)))), Float64(2.0 * Float64(n * Float64(U * t)))))
	tmp = 0.0
	if (l <= -5.4e+93)
		tmp = Float64(sqrt(2.0) * Float64(sqrt(Float64(Float64(n * Float64(U * Float64(Float64(Float64(n * Float64(U_42_ - U)) / Om) + -2.0))) / Om)) * Float64(-l)));
	elseif (l <= -1.25e-72)
		tmp = t_1;
	elseif (l <= 2.1e-32)
		tmp = sqrt(Float64(Float64(2.0 * Float64(n * U)) * Float64(t + Float64(Float64(l / Om) * fma(l, -2.0, Float64(Float64(U_42_ - U) * Float64(n * Float64(l / Om))))))));
	elseif (l <= 1.55e+134)
		tmp = t_1;
	else
		tmp = Float64(sqrt(2.0) * Float64(l * sqrt(Float64(Float64(n * U) * fma(Float64(n / Om), Float64(Float64(U_42_ - U) / Om), Float64(-2.0 / Om))))));
	end
	return tmp
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]
code[n_, U_, t_, l_, Om_, U$42$_] := Block[{t$95$1 = N[Sqrt[N[(-2.0 * N[(N[(n / Om), $MachinePrecision] * N[(N[(2.0 + N[(N[(n / Om), $MachinePrecision] * N[(U - U$42$), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(l * N[(l * U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(2.0 * N[(n * N[(U * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[l, -5.4e+93], N[(N[Sqrt[2.0], $MachinePrecision] * N[(N[Sqrt[N[(N[(n * N[(U * N[(N[(N[(n * N[(U$42$ - U), $MachinePrecision]), $MachinePrecision] / Om), $MachinePrecision] + -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / Om), $MachinePrecision]], $MachinePrecision] * (-l)), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -1.25e-72], t$95$1, If[LessEqual[l, 2.1e-32], N[Sqrt[N[(N[(2.0 * N[(n * U), $MachinePrecision]), $MachinePrecision] * N[(t + N[(N[(l / Om), $MachinePrecision] * N[(l * -2.0 + N[(N[(U$42$ - U), $MachinePrecision] * N[(n * N[(l / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[l, 1.55e+134], t$95$1, N[(N[Sqrt[2.0], $MachinePrecision] * N[(l * N[Sqrt[N[(N[(n * U), $MachinePrecision] * N[(N[(n / Om), $MachinePrecision] * N[(N[(U$42$ - U), $MachinePrecision] / Om), $MachinePrecision] + N[(-2.0 / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\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)}
\begin{array}{l}
t_1 := \sqrt{\mathsf{fma}\left(-2, \frac{n}{Om} \cdot \left(\left(2 + \frac{n}{Om} \cdot \left(U - U*\right)\right) \cdot \left(\ell \cdot \left(\ell \cdot U\right)\right)\right), 2 \cdot \left(n \cdot \left(U \cdot t\right)\right)\right)}\\
\mathbf{if}\;\ell \leq -5.4 \cdot 10^{+93}:\\
\;\;\;\;\sqrt{2} \cdot \left(\sqrt{\frac{n \cdot \left(U \cdot \left(\frac{n \cdot \left(U* - U\right)}{Om} + -2\right)\right)}{Om}} \cdot \left(-\ell\right)\right)\\

\mathbf{elif}\;\ell \leq -1.25 \cdot 10^{-72}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;\ell \leq 1.55 \cdot 10^{+134}:\\
\;\;\;\;t_1\\

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


\end{array}

Error

Derivation

  1. Split input into 4 regimes
  2. if l < -5.3999999999999999e93

    1. Initial program 54.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. Simplified43.6

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

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

    if -5.3999999999999999e93 < l < -1.2499999999999999e-72 or 2.0999999999999999e-32 < l < 1.54999999999999991e134

    1. Initial program 31.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. Simplified29.5

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

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

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

    if -1.2499999999999999e-72 < l < 2.0999999999999999e-32

    1. Initial program 25.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. Simplified24.7

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

    if 1.54999999999999991e134 < l

    1. Initial program 60.5

      \[\sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \frac{\ell \cdot \ell}{Om}\right) - \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)} \]
    2. Simplified47.6

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -5.4 \cdot 10^{+93}:\\ \;\;\;\;\sqrt{2} \cdot \left(\sqrt{\frac{n \cdot \left(U \cdot \left(\frac{n \cdot \left(U* - U\right)}{Om} + -2\right)\right)}{Om}} \cdot \left(-\ell\right)\right)\\ \mathbf{elif}\;\ell \leq -1.25 \cdot 10^{-72}:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(-2, \frac{n}{Om} \cdot \left(\left(2 + \frac{n}{Om} \cdot \left(U - U*\right)\right) \cdot \left(\ell \cdot \left(\ell \cdot U\right)\right)\right), 2 \cdot \left(n \cdot \left(U \cdot t\right)\right)\right)}\\ \mathbf{elif}\;\ell \leq 2.1 \cdot 10^{-32}:\\ \;\;\;\;\sqrt{\left(2 \cdot \left(n \cdot U\right)\right) \cdot \left(t + \frac{\ell}{Om} \cdot \mathsf{fma}\left(\ell, -2, \left(U* - U\right) \cdot \left(n \cdot \frac{\ell}{Om}\right)\right)\right)}\\ \mathbf{elif}\;\ell \leq 1.55 \cdot 10^{+134}:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(-2, \frac{n}{Om} \cdot \left(\left(2 + \frac{n}{Om} \cdot \left(U - U*\right)\right) \cdot \left(\ell \cdot \left(\ell \cdot U\right)\right)\right), 2 \cdot \left(n \cdot \left(U \cdot t\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{2} \cdot \left(\ell \cdot \sqrt{\left(n \cdot U\right) \cdot \mathsf{fma}\left(\frac{n}{Om}, \frac{U* - U}{Om}, \frac{-2}{Om}\right)}\right)\\ \end{array} \]

Reproduce

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