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

\mathbf{elif}\;t_1 \leq 5 \cdot 10^{+277}:\\
\;\;\;\;\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)}\\

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

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


\end{array}

Error

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.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. Simplified52.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. Taylor expanded in n around 0 41.8

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

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

    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.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)}} \]

    if 4.99999999999999982e277 < (*.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 60.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. Simplified50.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. Taylor expanded in t around inf 52.8

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

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

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

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

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

      \[\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. Simplified41.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 4 regimes into one program.
  4. Final simplification25.2

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

Reproduce

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