Average Error: 35.0 → 26.8
Time: 11.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 := \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:\\ \;\;\;\;{\left(e^{0.25 \cdot \left(\log \left(2 \cdot \left(U \cdot t\right) + -4 \cdot \frac{U \cdot {\ell}^{2}}{Om}\right) + \log n\right)}\right)}^{2}\\ \mathbf{elif}\;t_2 \leq 5 \cdot 10^{+149}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_2 \leq \infty:\\ \;\;\;\;\sqrt{t_1} \cdot \sqrt{\mathsf{fma}\left(\frac{\ell}{Om}, \mathsf{fma}\left(n, \frac{\ell}{Om} \cdot \left(U* - U\right), \ell \cdot -2\right), t\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{2 \cdot \left(n \cdot \left(U \cdot t + \mathsf{fma}\left(\frac{n}{Om}, \frac{U* - U}{Om}, \frac{-2}{Om}\right) \cdot \left(\ell \cdot \left(U \cdot \ell\right)\right)\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 (* (* 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)
     (pow
      (exp
       (*
        0.25
        (+
         (log (+ (* 2.0 (* U t)) (* -4.0 (/ (* U (pow l 2.0)) Om))))
         (log n))))
      2.0)
     (if (<= t_2 5e+149)
       t_2
       (if (<= t_2 INFINITY)
         (*
          (sqrt t_1)
          (sqrt (fma (/ l Om) (fma n (* (/ l Om) (- U* U)) (* l -2.0)) t)))
         (sqrt
          (*
           2.0
           (*
            n
            (+
             (* U t)
             (*
              (fma (/ n Om) (/ (- U* U) Om) (/ -2.0 Om))
              (* l (* U l))))))))))))
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 = (2.0 * n) * U;
	double t_2 = sqrt((t_1 * ((t - (2.0 * ((l * l) / Om))) + ((n * pow((l / Om), 2.0)) * (U_42_ - U)))));
	double tmp;
	if (t_2 <= 0.0) {
		tmp = pow(exp((0.25 * (log(((2.0 * (U * t)) + (-4.0 * ((U * pow(l, 2.0)) / Om)))) + log(n)))), 2.0);
	} else if (t_2 <= 5e+149) {
		tmp = t_2;
	} else if (t_2 <= ((double) INFINITY)) {
		tmp = sqrt(t_1) * sqrt(fma((l / Om), fma(n, ((l / Om) * (U_42_ - U)), (l * -2.0)), t));
	} else {
		tmp = sqrt((2.0 * (n * ((U * t) + (fma((n / Om), ((U_42_ - U) / Om), (-2.0 / Om)) * (l * (U * l)))))));
	}
	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 = 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_42_ - U)))))
	tmp = 0.0
	if (t_2 <= 0.0)
		tmp = exp(Float64(0.25 * Float64(log(Float64(Float64(2.0 * Float64(U * t)) + Float64(-4.0 * Float64(Float64(U * (l ^ 2.0)) / Om)))) + log(n)))) ^ 2.0;
	elseif (t_2 <= 5e+149)
		tmp = t_2;
	elseif (t_2 <= Inf)
		tmp = Float64(sqrt(t_1) * sqrt(fma(Float64(l / Om), fma(n, Float64(Float64(l / Om) * Float64(U_42_ - U)), Float64(l * -2.0)), t)));
	else
		tmp = sqrt(Float64(2.0 * Float64(n * Float64(Float64(U * t) + Float64(fma(Float64(n / Om), Float64(Float64(U_42_ - U) / Om), Float64(-2.0 / Om)) * Float64(l * Float64(U * l)))))));
	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[(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$42$ - U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$2, 0.0], N[Power[N[Exp[N[(0.25 * N[(N[Log[N[(N[(2.0 * N[(U * t), $MachinePrecision]), $MachinePrecision] + N[(-4.0 * N[(N[(U * N[Power[l, 2.0], $MachinePrecision]), $MachinePrecision] / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[Log[n], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision], If[LessEqual[t$95$2, 5e+149], t$95$2, If[LessEqual[t$95$2, Infinity], N[(N[Sqrt[t$95$1], $MachinePrecision] * N[Sqrt[N[(N[(l / Om), $MachinePrecision] * N[(n * N[(N[(l / Om), $MachinePrecision] * N[(U$42$ - U), $MachinePrecision]), $MachinePrecision] + N[(l * -2.0), $MachinePrecision]), $MachinePrecision] + t), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(2.0 * N[(n * N[(N[(U * t), $MachinePrecision] + N[(N[(N[(n / Om), $MachinePrecision] * N[(N[(U$42$ - U), $MachinePrecision] / Om), $MachinePrecision] + N[(-2.0 / Om), $MachinePrecision]), $MachinePrecision] * N[(l * N[(U * l), $MachinePrecision]), $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 := \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:\\
\;\;\;\;{\left(e^{0.25 \cdot \left(\log \left(2 \cdot \left(U \cdot t\right) + -4 \cdot \frac{U \cdot {\ell}^{2}}{Om}\right) + \log n\right)}\right)}^{2}\\

\mathbf{elif}\;t_2 \leq 5 \cdot 10^{+149}:\\
\;\;\;\;t_2\\

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

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


\end{array}

Error

Derivation

  1. Split input into 4 regimes
  2. if (sqrt.f64 (*.f64 (*.f64 (*.f64 2 n) U) (-.f64 (-.f64 t (*.f64 2 (/.f64 (*.f64 l l) Om))) (*.f64 (*.f64 n (pow.f64 (/.f64 l Om) 2)) (-.f64 U U*))))) < 0.0

    1. Initial program 57.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. Simplified57.0

      \[\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, \frac{\ell}{Om} \cdot \left(n \cdot \left(U* - U\right)\right)\right)\right)}} \]
    3. Applied egg-rr57.0

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

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

      \[\leadsto {\color{blue}{\left(e^{0.25 \cdot \left(\log \left(2 \cdot \left(t \cdot U\right) + -4 \cdot \frac{{\ell}^{2} \cdot U}{Om}\right) + \log n\right)}\right)}}^{2} \]

    if 0.0 < (sqrt.f64 (*.f64 (*.f64 (*.f64 2 n) U) (-.f64 (-.f64 t (*.f64 2 (/.f64 (*.f64 l l) Om))) (*.f64 (*.f64 n (pow.f64 (/.f64 l Om) 2)) (-.f64 U U*))))) < 4.9999999999999999e149

    1. Initial program 1.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)} \]

    if 4.9999999999999999e149 < (sqrt.f64 (*.f64 (*.f64 (*.f64 2 n) U) (-.f64 (-.f64 t (*.f64 2 (/.f64 (*.f64 l l) Om))) (*.f64 (*.f64 n (pow.f64 (/.f64 l Om) 2)) (-.f64 U U*))))) < +inf.0

    1. Initial program 63.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. Simplified52.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, \frac{\ell}{Om} \cdot \left(n \cdot \left(U* - U\right)\right)\right)\right)}} \]
    3. Applied egg-rr50.7

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

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

    1. Initial program 64.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. Simplified58.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, \frac{\ell}{Om} \cdot \left(n \cdot \left(U* - U\right)\right)\right)\right)}} \]
    3. Taylor expanded in l around 0 59.1

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\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)} \leq 0:\\ \;\;\;\;{\left(e^{0.25 \cdot \left(\log \left(2 \cdot \left(U \cdot t\right) + -4 \cdot \frac{U \cdot {\ell}^{2}}{Om}\right) + \log n\right)}\right)}^{2}\\ \mathbf{elif}\;\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)} \leq 5 \cdot 10^{+149}:\\ \;\;\;\;\sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \frac{\ell \cdot \ell}{Om}\right) + \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U* - U\right)\right)}\\ \mathbf{elif}\;\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)} \leq \infty:\\ \;\;\;\;\sqrt{\left(2 \cdot n\right) \cdot U} \cdot \sqrt{\mathsf{fma}\left(\frac{\ell}{Om}, \mathsf{fma}\left(n, \frac{\ell}{Om} \cdot \left(U* - U\right), \ell \cdot -2\right), t\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{2 \cdot \left(n \cdot \left(U \cdot t + \mathsf{fma}\left(\frac{n}{Om}, \frac{U* - U}{Om}, \frac{-2}{Om}\right) \cdot \left(\ell \cdot \left(U \cdot \ell\right)\right)\right)\right)}\\ \end{array} \]

Reproduce

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