Average Error: 34.3 → 25.0
Time: 28.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 := \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(\ell, -2, \left(U* - U\right) \cdot \left(n \cdot \frac{\ell}{Om}\right)\right)\\ t_4 := \mathsf{fma}\left(\frac{\ell}{Om}, t_3, t\right)\\ \mathbf{if}\;t_2 \leq 8.836062299 \cdot 10^{-314}:\\ \;\;\;\;\sqrt{2 \cdot n} \cdot \sqrt{U \cdot t_4}\\ \mathbf{else}:\\ \;\;\;\;\begin{array}{l} t_5 := t_1 \cdot t\\ \mathbf{if}\;t_2 \leq 5.7633557427454346 \cdot 10^{+299}:\\ \;\;\;\;\sqrt{t_5 + t_1 \cdot \left(\frac{\ell}{Om} \cdot t_3\right)}\\ \mathbf{elif}\;t_2 \leq \infty:\\ \;\;\;\;\sqrt{2 \cdot \left(n \cdot U\right)} \cdot \sqrt{t_4}\\ \mathbf{else}:\\ \;\;\;\;\begin{array}{l} t_6 := n \cdot \left(U \cdot \ell\right)\\ \sqrt{t_5 + -2 \cdot \frac{t_6 \cdot \mathsf{fma}\left(2, \ell, \frac{t_6}{Om}\right)}{Om}} \end{array}\\ \end{array}\\ \end{array} \]
\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(\ell, -2, \left(U* - U\right) \cdot \left(n \cdot \frac{\ell}{Om}\right)\right)\\
t_4 := \mathsf{fma}\left(\frac{\ell}{Om}, t_3, t\right)\\
\mathbf{if}\;t_2 \leq 8.836062299 \cdot 10^{-314}:\\
\;\;\;\;\sqrt{2 \cdot n} \cdot \sqrt{U \cdot t_4}\\

\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_5 := t_1 \cdot t\\
\mathbf{if}\;t_2 \leq 5.7633557427454346 \cdot 10^{+299}:\\
\;\;\;\;\sqrt{t_5 + t_1 \cdot \left(\frac{\ell}{Om} \cdot t_3\right)}\\

\mathbf{elif}\;t_2 \leq \infty:\\
\;\;\;\;\sqrt{2 \cdot \left(n \cdot U\right)} \cdot \sqrt{t_4}\\

\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_6 := n \cdot \left(U \cdot \ell\right)\\
\sqrt{t_5 + -2 \cdot \frac{t_6 \cdot \mathsf{fma}\left(2, \ell, \frac{t_6}{Om}\right)}{Om}}
\end{array}\\


\end{array}\\


\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 -2.0 (* (- U* U) (* n (/ l Om)))))
        (t_4 (fma (/ l Om) t_3 t)))
   (if (<= t_2 8.836062299e-314)
     (* (sqrt (* 2.0 n)) (sqrt (* U t_4)))
     (let* ((t_5 (* t_1 t)))
       (if (<= t_2 5.7633557427454346e+299)
         (sqrt (+ t_5 (* t_1 (* (/ l Om) t_3))))
         (if (<= t_2 INFINITY)
           (* (sqrt (* 2.0 (* n U))) (sqrt t_4))
           (let* ((t_6 (* n (* U l))))
             (sqrt
              (+ t_5 (* -2.0 (/ (* t_6 (fma 2.0 l (/ t_6 Om))) 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;
	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, -2.0, ((U_42_ - U) * (n * (l / Om))));
	double t_4 = fma((l / Om), t_3, t);
	double tmp;
	if (t_2 <= 8.836062299e-314) {
		tmp = sqrt(2.0 * n) * sqrt(U * t_4);
	} else {
		double t_5 = t_1 * t;
		double tmp_1;
		if (t_2 <= 5.7633557427454346e+299) {
			tmp_1 = sqrt(t_5 + (t_1 * ((l / Om) * t_3)));
		} else if (t_2 <= ((double) INFINITY)) {
			tmp_1 = sqrt(2.0 * (n * U)) * sqrt(t_4);
		} else {
			double t_6 = n * (U * l);
			tmp_1 = sqrt(t_5 + (-2.0 * ((t_6 * fma(2.0, l, (t_6 / Om))) / Om)));
		}
		tmp = tmp_1;
	}
	return tmp;
}

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*)))) < 8.83606229909e-314

    1. Initial program 55.9

      \[\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.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 associate-*l*_binary6436.8

      \[\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)}} \]
    4. Applied sqrt-prod_binary6439.4

      \[\leadsto \color{blue}{\sqrt{2 \cdot n} \cdot \sqrt{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)}} \]
    5. Simplified39.4

      \[\leadsto \color{blue}{\sqrt{n \cdot 2}} \cdot \sqrt{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)} \]
    6. Simplified39.4

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

    if 8.83606229909e-314 < (*.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*)))) < 5.7633557427454346e299

    1. Initial program 1.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. Simplified0.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 distribute-rgt-in_binary640.9

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

    if 5.7633557427454346e299 < (*.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 63.2

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

      \[\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_binary6452.3

      \[\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 distribute-rgt-out_binary6452.3

      \[\leadsto \sqrt{\color{blue}{\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)}} \]
    5. Applied sqrt-prod_binary6449.7

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

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

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

    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.5

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

      \[\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. Taylor expanded in U* around 0 41.0

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

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

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

Reproduce

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