Average Error: 34.3 → 26.6
Time: 13.7s
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}{Om} \cdot \left(U* - U\right)\\ \mathbf{if}\;\ell \leq -3.9 \cdot 10^{+116}:\\ \;\;\;\;\left(\ell \cdot \sqrt{2}\right) \cdot \left(-\sqrt{\frac{-n}{\frac{Om}{U \cdot \left(2 - t_1\right)}}}\right)\\ \mathbf{elif}\;\ell \leq 4 \cdot 10^{+120}:\\ \;\;\;\;\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)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{2} \cdot \left(\ell \cdot \sqrt{\frac{n}{Om} \cdot \left(U \cdot \left(t_1 + -2\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 (* (/ n Om) (- U* U))))
   (if (<= l -3.9e+116)
     (* (* l (sqrt 2.0)) (- (sqrt (/ (- n) (/ Om (* U (- 2.0 t_1)))))))
     (if (<= l 4e+120)
       (sqrt
        (*
         2.0
         (*
          (* n U)
          (fma (/ l Om) (fma l -2.0 (* (- U* U) (* n (/ l Om)))) t))))
       (* (sqrt 2.0) (* l (sqrt (* (/ n Om) (* U (+ t_1 -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 = (n / Om) * (U_42_ - U);
	double tmp;
	if (l <= -3.9e+116) {
		tmp = (l * sqrt(2.0)) * -sqrt((-n / (Om / (U * (2.0 - t_1)))));
	} else if (l <= 4e+120) {
		tmp = sqrt((2.0 * ((n * U) * fma((l / Om), fma(l, -2.0, ((U_42_ - U) * (n * (l / Om)))), t))));
	} else {
		tmp = sqrt(2.0) * (l * sqrt(((n / Om) * (U * (t_1 + -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(n / Om) * Float64(U_42_ - U))
	tmp = 0.0
	if (l <= -3.9e+116)
		tmp = Float64(Float64(l * sqrt(2.0)) * Float64(-sqrt(Float64(Float64(-n) / Float64(Om / Float64(U * Float64(2.0 - t_1)))))));
	elseif (l <= 4e+120)
		tmp = sqrt(Float64(2.0 * Float64(Float64(n * U) * fma(Float64(l / Om), fma(l, -2.0, Float64(Float64(U_42_ - U) * Float64(n * Float64(l / Om)))), t))));
	else
		tmp = Float64(sqrt(2.0) * Float64(l * sqrt(Float64(Float64(n / Om) * Float64(U * Float64(t_1 + -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 / Om), $MachinePrecision] * N[(U$42$ - U), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -3.9e+116], N[(N[(l * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision] * (-N[Sqrt[N[((-n) / N[(Om / N[(U * N[(2.0 - t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], If[LessEqual[l, 4e+120], N[Sqrt[N[(2.0 * N[(N[(n * U), $MachinePrecision] * N[(N[(l / Om), $MachinePrecision] * N[(l * -2.0 + N[(N[(U$42$ - U), $MachinePrecision] * N[(n * N[(l / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[Sqrt[2.0], $MachinePrecision] * N[(l * N[Sqrt[N[(N[(n / Om), $MachinePrecision] * N[(U * N[(t$95$1 + -2.0), $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}{Om} \cdot \left(U* - U\right)\\
\mathbf{if}\;\ell \leq -3.9 \cdot 10^{+116}:\\
\;\;\;\;\left(\ell \cdot \sqrt{2}\right) \cdot \left(-\sqrt{\frac{-n}{\frac{Om}{U \cdot \left(2 - t_1\right)}}}\right)\\

\mathbf{elif}\;\ell \leq 4 \cdot 10^{+120}:\\
\;\;\;\;\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)}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{2} \cdot \left(\ell \cdot \sqrt{\frac{n}{Om} \cdot \left(U \cdot \left(t_1 + -2\right)\right)}\right)\\


\end{array}

Error

Derivation

  1. Split input into 3 regimes
  2. if l < -3.90000000000000032e116

    1. Initial program 57.1

      \[\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. Simplified45.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 t around 0 48.8

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

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

      \[\leadsto \color{blue}{-1 \cdot \left(\sqrt{2} \cdot \left(\ell \cdot \sqrt{-1 \cdot \frac{n \cdot \left(\left(2 + -1 \cdot \frac{n \cdot \left(U* - U\right)}{Om}\right) \cdot U\right)}{Om}}\right)\right)} \]
    6. Simplified28.7

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

    if -3.90000000000000032e116 < l < 3.9999999999999999e120

    1. Initial program 27.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. Simplified26.1

      \[\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-rr26.1

      \[\leadsto \sqrt{\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)}^{1}}} \]

    if 3.9999999999999999e120 < l

    1. Initial program 58.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. Simplified45.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. Taylor expanded in t around 0 49.9

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

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

      \[\leadsto \color{blue}{\left(\sqrt{2} \cdot \ell\right) \cdot \sqrt{\frac{n \cdot \left(\left(\frac{n \cdot \left(U* - U\right)}{Om} - 2\right) \cdot U\right)}{Om}}} \]
    6. Simplified28.3

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

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

Reproduce

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