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

\mathbf{elif}\;t_2 \leq 10^{+285}:\\
\;\;\;\;{\left(2 \cdot \left(\left(n \cdot U\right) \cdot t_3\right)\right)}^{0.5}\\

\mathbf{elif}\;t_2 \leq \infty:\\
\;\;\;\;\sqrt{t_3} \cdot \sqrt{t_1}\\

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


\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*)))) < 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.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-rr51.4

      \[\leadsto \color{blue}{{\left(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)}^{0.5}} \]
    4. Taylor expanded in n around 0 40.4

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

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

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

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

    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.9999999999999998e284

    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.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-rr1.4

      \[\leadsto \color{blue}{{\left(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)}^{0.5}} \]

    if 9.9999999999999998e284 < (*.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 62.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. Simplified50.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-rr47.6

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

    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}{{\left(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)}^{0.5}} \]
    4. Taylor expanded in n around 0 58.0

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

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

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

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

Reproduce

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