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

\mathbf{elif}\;t_3 \leq 0:\\
\;\;\;\;\sqrt{2} \cdot \left(\sqrt{n} \cdot \sqrt{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)\\

\mathbf{elif}\;t_3 \leq \infty:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(t, t_2, t_2 \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)}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{2} \cdot \left(\left(\sqrt{\frac{n \cdot U}{t_1}} \cdot \frac{t}{\ell}\right) \cdot -0.5 - \ell \cdot \sqrt{n \cdot \left(U \cdot t_1\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 4 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*)))) < -1.99999999999999996e-12

    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. Simplified18.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 U* around inf 31.8

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

    if -1.99999999999999996e-12 < (*.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.4

      \[\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. Simplified55.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. Applied egg-rr55.2

      \[\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. Applied egg-rr39.4

      \[\leadsto \sqrt{2} \cdot \color{blue}{\left(\sqrt{n} \cdot \sqrt{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)} \]

    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.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. Simplified20.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-rr20.7

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

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

      \[\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 l around -inf 52.1

      \[\leadsto \sqrt{2} \cdot \color{blue}{\left(-\left(0.5 \cdot \left(\sqrt{\frac{n \cdot U}{\frac{n \cdot U*}{{Om}^{2}} - \left(2 \cdot \frac{1}{Om} + \frac{n \cdot U}{{Om}^{2}}\right)}} \cdot \frac{t}{\ell}\right) + \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 \ell\right)\right)} \]
    5. Simplified51.1

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

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

Reproduce

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