Average Error: 34.8 → 26.8
Time: 15.5s
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{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t + \frac{\ell \cdot \ell}{Om} \cdot -2\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(2, U \cdot t, \frac{\ell \cdot \ell}{\frac{Om}{U}} \cdot -4\right)}\\ \mathbf{elif}\;t_1 \leq 3.9311733367951677 \cdot 10^{+145}:\\ \;\;\;\;\sqrt{\left(2 \cdot \left(n \cdot U\right)\right) \cdot \left(t + \frac{\ell}{Om} \cdot \mathsf{fma}\left(\ell, -2, {\left(\frac{\frac{Om}{\ell}}{n}\right)}^{-1} \cdot \left(U* - U\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{2} \cdot \sqrt{n \cdot \mathsf{fma}\left(U, t, -2 \cdot \frac{\frac{U \cdot \ell}{Om}}{\frac{1}{\ell}}\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
          (*
           (* (* 2.0 n) U)
           (+
            (+ t (* (/ (* l l) Om) -2.0))
            (* (* n (pow (/ l Om) 2.0)) (- U* U)))))))
   (if (<= t_1 0.0)
     (sqrt (* n (fma 2.0 (* U t) (* (/ (* l l) (/ Om U)) -4.0))))
     (if (<= t_1 3.9311733367951677e+145)
       (sqrt
        (*
         (* 2.0 (* n U))
         (+
          t
          (* (/ l Om) (fma l -2.0 (* (pow (/ (/ Om l) n) -1.0) (- U* U)))))))
       (*
        (sqrt 2.0)
        (sqrt (* n (fma U t (* -2.0 (/ (/ (* U l) Om) (/ 1.0 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 = sqrt((((2.0 * n) * U) * ((t + (((l * l) / Om) * -2.0)) + ((n * pow((l / Om), 2.0)) * (U_42_ - U)))));
	double tmp;
	if (t_1 <= 0.0) {
		tmp = sqrt((n * fma(2.0, (U * t), (((l * l) / (Om / U)) * -4.0))));
	} else if (t_1 <= 3.9311733367951677e+145) {
		tmp = sqrt(((2.0 * (n * U)) * (t + ((l / Om) * fma(l, -2.0, (pow(((Om / l) / n), -1.0) * (U_42_ - U)))))));
	} else {
		tmp = sqrt(2.0) * sqrt((n * fma(U, t, (-2.0 * (((U * l) / Om) / (1.0 / 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 = sqrt(Float64(Float64(Float64(2.0 * n) * U) * Float64(Float64(t + Float64(Float64(Float64(l * l) / Om) * -2.0)) + Float64(Float64(n * (Float64(l / Om) ^ 2.0)) * Float64(U_42_ - U)))))
	tmp = 0.0
	if (t_1 <= 0.0)
		tmp = sqrt(Float64(n * fma(2.0, Float64(U * t), Float64(Float64(Float64(l * l) / Float64(Om / U)) * -4.0))));
	elseif (t_1 <= 3.9311733367951677e+145)
		tmp = sqrt(Float64(Float64(2.0 * Float64(n * U)) * Float64(t + Float64(Float64(l / Om) * fma(l, -2.0, Float64((Float64(Float64(Om / l) / n) ^ -1.0) * Float64(U_42_ - U)))))));
	else
		tmp = Float64(sqrt(2.0) * sqrt(Float64(n * fma(U, t, Float64(-2.0 * Float64(Float64(Float64(U * l) / Om) / Float64(1.0 / 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[Sqrt[N[(N[(N[(2.0 * n), $MachinePrecision] * U), $MachinePrecision] * N[(N[(t + N[(N[(N[(l * l), $MachinePrecision] / Om), $MachinePrecision] * -2.0), $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$1, 0.0], N[Sqrt[N[(n * N[(2.0 * N[(U * t), $MachinePrecision] + N[(N[(N[(l * l), $MachinePrecision] / N[(Om / U), $MachinePrecision]), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[t$95$1, 3.9311733367951677e+145], N[Sqrt[N[(N[(2.0 * N[(n * U), $MachinePrecision]), $MachinePrecision] * N[(t + N[(N[(l / Om), $MachinePrecision] * N[(l * -2.0 + N[(N[Power[N[(N[(Om / l), $MachinePrecision] / n), $MachinePrecision], -1.0], $MachinePrecision] * N[(U$42$ - U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[Sqrt[2.0], $MachinePrecision] * N[Sqrt[N[(n * N[(U * t + N[(-2.0 * N[(N[(N[(U * l), $MachinePrecision] / Om), $MachinePrecision] / N[(1.0 / 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 := \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t + \frac{\ell \cdot \ell}{Om} \cdot -2\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(2, U \cdot t, \frac{\ell \cdot \ell}{\frac{Om}{U}} \cdot -4\right)}\\

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

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


\end{array}

Error

Bits error versus n

Bits error versus U

Bits error versus t

Bits error versus l

Bits error versus Om

Bits error versus U*

Derivation

  1. Split input into 3 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 56.8

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

      \[\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 n around 0 40.7

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

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

    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*))))) < 3.93117333679516767e145

    1. Initial program 1.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. Simplified1.2

      \[\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 n around 0 2.5

      \[\leadsto \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 \color{blue}{\frac{n \cdot \ell}{Om}}\right)\right)} \]
    4. Simplified1.2

      \[\leadsto \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 \color{blue}{\frac{n}{\frac{Om}{\ell}}}\right)\right)} \]
    5. Applied egg-rr1.2

      \[\leadsto \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 \color{blue}{{\left(\frac{\frac{Om}{\ell}}{n}\right)}^{-1}}\right)\right)} \]

    if 3.93117333679516767e145 < (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 62.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. Simplified53.9

      \[\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-rr53.9

      \[\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 n around 0 59.4

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

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

      \[\leadsto \sqrt{2} \cdot \sqrt{n \cdot \mathsf{fma}\left(U, t, \color{blue}{\frac{\frac{U \cdot \ell}{Om}}{\frac{1}{\ell}}} \cdot -2\right)} \]
  3. Recombined 3 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 + \frac{\ell \cdot \ell}{Om} \cdot -2\right) + \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U* - U\right)\right)} \leq 0:\\ \;\;\;\;\sqrt{n \cdot \mathsf{fma}\left(2, U \cdot t, \frac{\ell \cdot \ell}{\frac{Om}{U}} \cdot -4\right)}\\ \mathbf{elif}\;\sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t + \frac{\ell \cdot \ell}{Om} \cdot -2\right) + \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U* - U\right)\right)} \leq 3.9311733367951677 \cdot 10^{+145}:\\ \;\;\;\;\sqrt{\left(2 \cdot \left(n \cdot U\right)\right) \cdot \left(t + \frac{\ell}{Om} \cdot \mathsf{fma}\left(\ell, -2, {\left(\frac{\frac{Om}{\ell}}{n}\right)}^{-1} \cdot \left(U* - U\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{2} \cdot \sqrt{n \cdot \mathsf{fma}\left(U, t, -2 \cdot \frac{\frac{U \cdot \ell}{Om}}{\frac{1}{\ell}}\right)}\\ \end{array} \]

Reproduce

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