Average Error: 34.7 → 24.9
Time: 17.1s
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 := 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 := n \cdot \left(U \cdot \ell\right)\\ \mathbf{if}\;t_2 \leq 0:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(2, n \cdot \left(U \cdot t\right), \left(\frac{n}{Om} \cdot \left(\ell \cdot \left(U \cdot \ell\right)\right)\right) \cdot -4\right)}\\ \mathbf{elif}\;t_2 \leq \infty:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(t_1, t, \left(t_1 \cdot \frac{\ell}{Om}\right) \cdot \mathsf{fma}\left(\ell, -2, \left(n \cdot \frac{\ell}{Om}\right) \cdot \left(U* - U\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(t_1, t, -2 \cdot \frac{t_3 \cdot \left(2 \cdot \ell + \frac{t_3}{Om}\right)}{Om}\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
         (*
          t_1
          (-
           (- t (* 2.0 (/ (* l l) Om)))
           (* (* n (pow (/ l Om) 2.0)) (- U U*)))))
        (t_3 (* n (* U l))))
   (if (<= t_2 0.0)
     (sqrt (fma 2.0 (* n (* U t)) (* (* (/ n Om) (* l (* U l))) -4.0)))
     (if (<= t_2 INFINITY)
       (sqrt
        (fma
         t_1
         t
         (* (* t_1 (/ l Om)) (fma l -2.0 (* (* n (/ l Om)) (- U* U))))))
       (sqrt (fma t_1 t (* -2.0 (/ (* t_3 (+ (* 2.0 l) (/ t_3 Om))) 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 = (2.0 * n) * U;
	double t_2 = t_1 * ((t - (2.0 * ((l * l) / Om))) - ((n * pow((l / Om), 2.0)) * (U - U_42_)));
	double t_3 = n * (U * l);
	double tmp;
	if (t_2 <= 0.0) {
		tmp = sqrt(fma(2.0, (n * (U * t)), (((n / Om) * (l * (U * l))) * -4.0)));
	} else if (t_2 <= ((double) INFINITY)) {
		tmp = sqrt(fma(t_1, t, ((t_1 * (l / Om)) * fma(l, -2.0, ((n * (l / Om)) * (U_42_ - U))))));
	} else {
		tmp = sqrt(fma(t_1, t, (-2.0 * ((t_3 * ((2.0 * l) + (t_3 / Om))) / 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 = Float64(Float64(2.0 * n) * U)
	t_2 = 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(n * Float64(U * l))
	tmp = 0.0
	if (t_2 <= 0.0)
		tmp = sqrt(fma(2.0, Float64(n * Float64(U * t)), Float64(Float64(Float64(n / Om) * Float64(l * Float64(U * l))) * -4.0)));
	elseif (t_2 <= Inf)
		tmp = sqrt(fma(t_1, t, Float64(Float64(t_1 * Float64(l / Om)) * fma(l, -2.0, Float64(Float64(n * Float64(l / Om)) * Float64(U_42_ - U))))));
	else
		tmp = sqrt(fma(t_1, t, Float64(-2.0 * Float64(Float64(t_3 * Float64(Float64(2.0 * l) + Float64(t_3 / Om))) / 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[(N[(2.0 * n), $MachinePrecision] * U), $MachinePrecision]}, Block[{t$95$2 = 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]}, Block[{t$95$3 = N[(n * N[(U * l), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, 0.0], N[Sqrt[N[(2.0 * N[(n * N[(U * t), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(n / Om), $MachinePrecision] * N[(l * N[(U * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[t$95$2, Infinity], N[Sqrt[N[(t$95$1 * t + N[(N[(t$95$1 * N[(l / Om), $MachinePrecision]), $MachinePrecision] * N[(l * -2.0 + N[(N[(n * N[(l / Om), $MachinePrecision]), $MachinePrecision] * N[(U$42$ - U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[N[(t$95$1 * t + N[(-2.0 * N[(N[(t$95$3 * N[(N[(2.0 * l), $MachinePrecision] + N[(t$95$3 / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / Om), $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 := 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 := n \cdot \left(U \cdot \ell\right)\\
\mathbf{if}\;t_2 \leq 0:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(2, n \cdot \left(U \cdot t\right), \left(\frac{n}{Om} \cdot \left(\ell \cdot \left(U \cdot \ell\right)\right)\right) \cdot -4\right)}\\

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

\mathbf{else}:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(t_1, t, -2 \cdot \frac{t_3 \cdot \left(2 \cdot \ell + \frac{t_3}{Om}\right)}{Om}\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.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. Simplified51.8

      \[\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.8

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

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

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

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

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

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

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

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

    if +inf.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*))))

    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. Simplified63.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. Applied egg-rr63.5

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

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

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

Reproduce

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