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

\mathbf{elif}\;t_3 \leq \infty:\\
\;\;\;\;\sqrt{t_4 + \frac{\ell}{Om} \cdot \left(t_2 \cdot t_1\right)}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{t_4 + \frac{\ell}{Om} \cdot \left(-2 \cdot \left(n \cdot \left(\left(\left(2 + \frac{n \cdot U}{Om}\right) - \frac{n \cdot U*}{Om}\right) \cdot \left(U \cdot \ell\right)\right)\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.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. Simplified51.9

      \[\leadsto \color{blue}{\sqrt{\left(\left(2 \cdot n\right) \cdot U\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 associate-*l*_binary6437.1

      \[\leadsto \sqrt{\color{blue}{\left(2 \cdot n\right) \cdot \left(U \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)\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.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. Simplified21.1

      \[\leadsto \color{blue}{\sqrt{\left(\left(2 \cdot n\right) \cdot U\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 distribute-rgt-in_binary6421.1

      \[\leadsto \sqrt{\color{blue}{t \cdot \left(\left(2 \cdot n\right) \cdot U\right) + \left(\frac{\ell}{Om} \cdot \mathsf{fma}\left(\ell, -2, \left(U* - U\right) \cdot \left(n \cdot \frac{\ell}{Om}\right)\right)\right) \cdot \left(\left(2 \cdot n\right) \cdot U\right)}} \]
    4. Applied associate-*l*_binary6419.5

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

      \[\leadsto \color{blue}{\sqrt{\left(\left(2 \cdot n\right) \cdot U\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 distribute-rgt-in_binary6463.6

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

      \[\leadsto \sqrt{t \cdot \left(\left(2 \cdot n\right) \cdot U\right) + \color{blue}{\frac{\ell}{Om} \cdot \left(\mathsf{fma}\left(\ell, -2, \left(U* - U\right) \cdot \left(n \cdot \frac{\ell}{Om}\right)\right) \cdot \left(\left(2 \cdot n\right) \cdot U\right)\right)}} \]
    5. Applied associate-*r*_binary6455.8

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

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

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

Reproduce

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