Average Error: 34.4 → 24.8
Time: 17.9s
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(\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)\\ t_2 := \frac{n}{Om \cdot Om}\\ \mathbf{if}\;t_1 \leq 0:\\ \;\;\;\;\left|\sqrt{2 \cdot \left(n \cdot \left(U \cdot \mathsf{fma}\left(\frac{\ell}{Om}, \mathsf{fma}\left(\ell, -2, \frac{n \cdot \left(\ell \cdot \left(U* - U\right)\right)}{Om}\right), t\right)\right)\right)}\right|\\ \mathbf{elif}\;t_1 \leq 10^{+305}:\\ \;\;\;\;\left|\sqrt{2 \cdot \left(\left(n \cdot U\right) \cdot \mathsf{fma}\left(\frac{\ell}{Om}, \mathsf{fma}\left(\ell, -2, n \cdot \left(\frac{\ell}{Om} \cdot \left(U* - U\right)\right)\right), t\right)\right)}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\sqrt{n \cdot \left(U \cdot \left(U* \cdot t_2 + \left(\frac{-2}{Om} - U \cdot t_2\right)\right)\right)} \cdot \left(\ell \cdot \sqrt{2}\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 (* (/ (* l l) Om) -2.0))
           (* (* n (pow (/ l Om) 2.0)) (- U* U)))))
        (t_2 (/ n (* Om Om))))
   (if (<= t_1 0.0)
     (fabs
      (sqrt
       (*
        2.0
        (*
         n
         (* U (fma (/ l Om) (fma l -2.0 (/ (* n (* l (- U* U))) Om)) t))))))
     (if (<= t_1 1e+305)
       (fabs
        (sqrt
         (*
          2.0
          (*
           (* n U)
           (fma (/ l Om) (fma l -2.0 (* n (* (/ l Om) (- U* U)))) t)))))
       (fabs
        (*
         (sqrt (* n (* U (+ (* U* t_2) (- (/ -2.0 Om) (* U t_2))))))
         (* l (sqrt 2.0))))))))
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) * ((t + (((l * l) / Om) * -2.0)) + ((n * pow((l / Om), 2.0)) * (U_42_ - U)));
	double t_2 = n / (Om * Om);
	double tmp;
	if (t_1 <= 0.0) {
		tmp = fabs(sqrt((2.0 * (n * (U * fma((l / Om), fma(l, -2.0, ((n * (l * (U_42_ - U))) / Om)), t))))));
	} else if (t_1 <= 1e+305) {
		tmp = fabs(sqrt((2.0 * ((n * U) * fma((l / Om), fma(l, -2.0, (n * ((l / Om) * (U_42_ - U)))), t)))));
	} else {
		tmp = fabs((sqrt((n * (U * ((U_42_ * t_2) + ((-2.0 / Om) - (U * t_2)))))) * (l * sqrt(2.0))));
	}
	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(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))))
	t_2 = Float64(n / Float64(Om * Om))
	tmp = 0.0
	if (t_1 <= 0.0)
		tmp = abs(sqrt(Float64(2.0 * Float64(n * Float64(U * fma(Float64(l / Om), fma(l, -2.0, Float64(Float64(n * Float64(l * Float64(U_42_ - U))) / Om)), t))))));
	elseif (t_1 <= 1e+305)
		tmp = abs(sqrt(Float64(2.0 * Float64(Float64(n * U) * fma(Float64(l / Om), fma(l, -2.0, Float64(n * Float64(Float64(l / Om) * Float64(U_42_ - U)))), t)))));
	else
		tmp = abs(Float64(sqrt(Float64(n * Float64(U * Float64(Float64(U_42_ * t_2) + Float64(Float64(-2.0 / Om) - Float64(U * t_2)))))) * Float64(l * sqrt(2.0))));
	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[(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]}, Block[{t$95$2 = N[(n / N[(Om * Om), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 0.0], N[Abs[N[Sqrt[N[(2.0 * N[(n * N[(U * N[(N[(l / Om), $MachinePrecision] * N[(l * -2.0 + N[(N[(n * N[(l * N[(U$42$ - U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / Om), $MachinePrecision]), $MachinePrecision] + t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision], If[LessEqual[t$95$1, 1e+305], N[Abs[N[Sqrt[N[(2.0 * N[(N[(n * U), $MachinePrecision] * N[(N[(l / Om), $MachinePrecision] * N[(l * -2.0 + N[(n * N[(N[(l / Om), $MachinePrecision] * N[(U$42$ - U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[Sqrt[N[(n * N[(U * N[(N[(U$42$ * t$95$2), $MachinePrecision] + N[(N[(-2.0 / Om), $MachinePrecision] - N[(U * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(l * N[Sqrt[2.0], $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(\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)\\
t_2 := \frac{n}{Om \cdot Om}\\
\mathbf{if}\;t_1 \leq 0:\\
\;\;\;\;\left|\sqrt{2 \cdot \left(n \cdot \left(U \cdot \mathsf{fma}\left(\frac{\ell}{Om}, \mathsf{fma}\left(\ell, -2, \frac{n \cdot \left(\ell \cdot \left(U* - U\right)\right)}{Om}\right), t\right)\right)\right)}\right|\\

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

\mathbf{else}:\\
\;\;\;\;\left|\sqrt{n \cdot \left(U \cdot \left(U* \cdot t_2 + \left(\frac{-2}{Om} - U \cdot t_2\right)\right)\right)} \cdot \left(\ell \cdot \sqrt{2}\right)\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 (*.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.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. Simplified51.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)}} \]
    3. Applied egg-rr51.7

      \[\leadsto \color{blue}{\left|\sqrt{2 \cdot \left(\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)\right)}\right|} \]
    4. Applied egg-rr37.4

      \[\leadsto \left|\sqrt{2 \cdot \color{blue}{{\left(n \cdot \left(U \cdot \mathsf{fma}\left(\frac{\ell}{Om}, \mathsf{fma}\left(\ell, -2, n \cdot \left(\frac{\ell}{Om} \cdot \left(U* - U\right)\right)\right), t\right)\right)\right)}^{1}}}\right| \]
    5. Applied egg-rr38.6

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

    if 0.0 < (*.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*)))) < 9.9999999999999994e304

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

      \[\leadsto \color{blue}{\left|\sqrt{2 \cdot \left(\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)\right)}\right|} \]
    4. Applied egg-rr9.4

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

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

    if 9.9999999999999994e304 < (*.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 63.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.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)}} \]
    3. Applied egg-rr56.7

      \[\leadsto \color{blue}{\left|\sqrt{2 \cdot \left(\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)\right)}\right|} \]
    4. Taylor expanded in l around inf 46.3

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

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

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

Reproduce

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