Average Error: 42.5 → 7.7
Time: 12.9s
Precision: binary64
\[\frac{\sqrt{2} \cdot t}{\sqrt{\frac{x + 1}{x - 1} \cdot \left(\ell \cdot \ell + 2 \cdot \left(t \cdot t\right)\right) - \ell \cdot \ell}} \]
\[\begin{array}{l} t_1 := t \cdot \sqrt{\frac{2}{x - 1} + 2 \cdot \frac{x}{x - 1}}\\ t_2 := t \cdot \sqrt{2}\\ \mathbf{if}\;t \leq -1.1296845245651568 \cdot 10^{+129}:\\ \;\;\;\;\frac{t_2}{-t_1}\\ \mathbf{else}:\\ \;\;\;\;\begin{array}{l} t_3 := \frac{t \cdot t}{x}\\ \mathbf{if}\;t \leq -3.244214081833893 \cdot 10^{-124}:\\ \;\;\;\;\frac{t_2}{\sqrt{\mathsf{fma}\left(4, t_3, 2 \cdot \left(t \cdot t + \frac{\ell}{\frac{x}{\ell}}\right)\right)}}\\ \mathbf{elif}\;t \leq 4.33667404189508 \cdot 10^{-308}:\\ \;\;\;\;\begin{array}{l} t_4 := 2 + \frac{4}{x}\\ \frac{t_2}{-\mathsf{fma}\left(t, \sqrt{t_4}, \frac{\ell \cdot \ell}{t \cdot x} \cdot \sqrt{\frac{1}{t_4}}\right)} \end{array}\\ \mathbf{elif}\;t \leq 7.245697021475806 \cdot 10^{-165}:\\ \;\;\;\;\begin{array}{l} t_5 := \sqrt{2} \cdot x\\ \frac{t_2}{\mathsf{fma}\left(t, \sqrt{2}, \mathsf{fma}\left(2, \frac{t}{t_5}, \frac{\ell \cdot \ell}{t \cdot t_5}\right)\right)} \end{array}\\ \mathbf{elif}\;t \leq 9.321129763170555 \cdot 10^{+68}:\\ \;\;\;\;\begin{array}{l} t_6 := \sqrt{t \cdot t + \ell \cdot \frac{\ell}{x}}\\ \frac{t_2}{\sqrt{\mathsf{fma}\left(4, t_3, 2 \cdot \left(t_6 \cdot t_6\right)\right)}} \end{array}\\ \mathbf{else}:\\ \;\;\;\;\frac{t_2}{t_1}\\ \end{array}\\ \end{array} \]
\frac{\sqrt{2} \cdot t}{\sqrt{\frac{x + 1}{x - 1} \cdot \left(\ell \cdot \ell + 2 \cdot \left(t \cdot t\right)\right) - \ell \cdot \ell}}
\begin{array}{l}
t_1 := t \cdot \sqrt{\frac{2}{x - 1} + 2 \cdot \frac{x}{x - 1}}\\
t_2 := t \cdot \sqrt{2}\\
\mathbf{if}\;t \leq -1.1296845245651568 \cdot 10^{+129}:\\
\;\;\;\;\frac{t_2}{-t_1}\\

\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_3 := \frac{t \cdot t}{x}\\
\mathbf{if}\;t \leq -3.244214081833893 \cdot 10^{-124}:\\
\;\;\;\;\frac{t_2}{\sqrt{\mathsf{fma}\left(4, t_3, 2 \cdot \left(t \cdot t + \frac{\ell}{\frac{x}{\ell}}\right)\right)}}\\

\mathbf{elif}\;t \leq 4.33667404189508 \cdot 10^{-308}:\\
\;\;\;\;\begin{array}{l}
t_4 := 2 + \frac{4}{x}\\
\frac{t_2}{-\mathsf{fma}\left(t, \sqrt{t_4}, \frac{\ell \cdot \ell}{t \cdot x} \cdot \sqrt{\frac{1}{t_4}}\right)}
\end{array}\\

\mathbf{elif}\;t \leq 7.245697021475806 \cdot 10^{-165}:\\
\;\;\;\;\begin{array}{l}
t_5 := \sqrt{2} \cdot x\\
\frac{t_2}{\mathsf{fma}\left(t, \sqrt{2}, \mathsf{fma}\left(2, \frac{t}{t_5}, \frac{\ell \cdot \ell}{t \cdot t_5}\right)\right)}
\end{array}\\

\mathbf{elif}\;t \leq 9.321129763170555 \cdot 10^{+68}:\\
\;\;\;\;\begin{array}{l}
t_6 := \sqrt{t \cdot t + \ell \cdot \frac{\ell}{x}}\\
\frac{t_2}{\sqrt{\mathsf{fma}\left(4, t_3, 2 \cdot \left(t_6 \cdot t_6\right)\right)}}
\end{array}\\

\mathbf{else}:\\
\;\;\;\;\frac{t_2}{t_1}\\


\end{array}\\


\end{array}
(FPCore (x l t)
 :precision binary64
 (/
  (* (sqrt 2.0) t)
  (sqrt (- (* (/ (+ x 1.0) (- x 1.0)) (+ (* l l) (* 2.0 (* t t)))) (* l l)))))
(FPCore (x l t)
 :precision binary64
 (let* ((t_1 (* t (sqrt (+ (/ 2.0 (- x 1.0)) (* 2.0 (/ x (- x 1.0)))))))
        (t_2 (* t (sqrt 2.0))))
   (if (<= t -1.1296845245651568e+129)
     (/ t_2 (- t_1))
     (let* ((t_3 (/ (* t t) x)))
       (if (<= t -3.244214081833893e-124)
         (/ t_2 (sqrt (fma 4.0 t_3 (* 2.0 (+ (* t t) (/ l (/ x l)))))))
         (if (<= t 4.33667404189508e-308)
           (let* ((t_4 (+ 2.0 (/ 4.0 x))))
             (/
              t_2
              (-
               (fma t (sqrt t_4) (* (/ (* l l) (* t x)) (sqrt (/ 1.0 t_4)))))))
           (if (<= t 7.245697021475806e-165)
             (let* ((t_5 (* (sqrt 2.0) x)))
               (/
                t_2
                (fma t (sqrt 2.0) (fma 2.0 (/ t t_5) (/ (* l l) (* t t_5))))))
             (if (<= t 9.321129763170555e+68)
               (let* ((t_6 (sqrt (+ (* t t) (* l (/ l x))))))
                 (/ t_2 (sqrt (fma 4.0 t_3 (* 2.0 (* t_6 t_6))))))
               (/ t_2 t_1)))))))))
double code(double x, double l, double t) {
	return (sqrt(2.0) * t) / sqrt((((x + 1.0) / (x - 1.0)) * ((l * l) + (2.0 * (t * t)))) - (l * l));
}
double code(double x, double l, double t) {
	double t_1 = t * sqrt((2.0 / (x - 1.0)) + (2.0 * (x / (x - 1.0))));
	double t_2 = t * sqrt(2.0);
	double tmp;
	if (t <= -1.1296845245651568e+129) {
		tmp = t_2 / -t_1;
	} else {
		double t_3 = (t * t) / x;
		double tmp_1;
		if (t <= -3.244214081833893e-124) {
			tmp_1 = t_2 / sqrt(fma(4.0, t_3, (2.0 * ((t * t) + (l / (x / l))))));
		} else if (t <= 4.33667404189508e-308) {
			double t_4 = 2.0 + (4.0 / x);
			tmp_1 = t_2 / -fma(t, sqrt(t_4), (((l * l) / (t * x)) * sqrt(1.0 / t_4)));
		} else if (t <= 7.245697021475806e-165) {
			double t_5 = sqrt(2.0) * x;
			tmp_1 = t_2 / fma(t, sqrt(2.0), fma(2.0, (t / t_5), ((l * l) / (t * t_5))));
		} else if (t <= 9.321129763170555e+68) {
			double t_6 = sqrt((t * t) + (l * (l / x)));
			tmp_1 = t_2 / sqrt(fma(4.0, t_3, (2.0 * (t_6 * t_6))));
		} else {
			tmp_1 = t_2 / t_1;
		}
		tmp = tmp_1;
	}
	return tmp;
}

Error

Bits error versus x

Bits error versus l

Bits error versus t

Derivation

  1. Split input into 6 regimes
  2. if t < -1.12968452456515676e129

    1. Initial program 55.7

      \[\frac{\sqrt{2} \cdot t}{\sqrt{\frac{x + 1}{x - 1} \cdot \left(\ell \cdot \ell + 2 \cdot \left(t \cdot t\right)\right) - \ell \cdot \ell}} \]
    2. Simplified55.7

      \[\leadsto \color{blue}{\frac{\sqrt{2} \cdot t}{\sqrt{\frac{x + 1}{x - 1} \cdot \mathsf{fma}\left(2, t \cdot t, \ell \cdot \ell\right) - \ell \cdot \ell}}} \]
    3. Taylor expanded in t around -inf 1.9

      \[\leadsto \frac{\sqrt{2} \cdot t}{\color{blue}{-1 \cdot \left(\sqrt{2 \cdot \frac{1}{x - 1} + 2 \cdot \frac{x}{x - 1}} \cdot t\right)}} \]
    4. Simplified1.9

      \[\leadsto \frac{\sqrt{2} \cdot t}{\color{blue}{-\sqrt{\frac{2}{x - 1} + 2 \cdot \frac{x}{x - 1}} \cdot t}} \]

    if -1.12968452456515676e129 < t < -3.2442140818338929e-124

    1. Initial program 22.2

      \[\frac{\sqrt{2} \cdot t}{\sqrt{\frac{x + 1}{x - 1} \cdot \left(\ell \cdot \ell + 2 \cdot \left(t \cdot t\right)\right) - \ell \cdot \ell}} \]
    2. Simplified22.2

      \[\leadsto \color{blue}{\frac{\sqrt{2} \cdot t}{\sqrt{\frac{x + 1}{x - 1} \cdot \mathsf{fma}\left(2, t \cdot t, \ell \cdot \ell\right) - \ell \cdot \ell}}} \]
    3. Taylor expanded in x around inf 9.4

      \[\leadsto \frac{\sqrt{2} \cdot t}{\sqrt{\color{blue}{4 \cdot \frac{{t}^{2}}{x} + \left(2 \cdot \frac{{\ell}^{2}}{x} + 2 \cdot {t}^{2}\right)}}} \]
    4. Simplified9.4

      \[\leadsto \frac{\sqrt{2} \cdot t}{\sqrt{\color{blue}{\mathsf{fma}\left(4, \frac{t \cdot t}{x}, 2 \cdot \left(\frac{\ell \cdot \ell}{x} + t \cdot t\right)\right)}}} \]
    5. Applied associate-/l*_binary644.8

      \[\leadsto \frac{\sqrt{2} \cdot t}{\sqrt{\mathsf{fma}\left(4, \frac{t \cdot t}{x}, 2 \cdot \left(\color{blue}{\frac{\ell}{\frac{x}{\ell}}} + t \cdot t\right)\right)}} \]

    if -3.2442140818338929e-124 < t < 4.3366740418950802e-308

    1. Initial program 57.4

      \[\frac{\sqrt{2} \cdot t}{\sqrt{\frac{x + 1}{x - 1} \cdot \left(\ell \cdot \ell + 2 \cdot \left(t \cdot t\right)\right) - \ell \cdot \ell}} \]
    2. Simplified57.4

      \[\leadsto \color{blue}{\frac{\sqrt{2} \cdot t}{\sqrt{\frac{x + 1}{x - 1} \cdot \mathsf{fma}\left(2, t \cdot t, \ell \cdot \ell\right) - \ell \cdot \ell}}} \]
    3. Taylor expanded in x around inf 30.6

      \[\leadsto \frac{\sqrt{2} \cdot t}{\sqrt{\color{blue}{4 \cdot \frac{{t}^{2}}{x} + \left(2 \cdot \frac{{\ell}^{2}}{x} + 2 \cdot {t}^{2}\right)}}} \]
    4. Simplified30.6

      \[\leadsto \frac{\sqrt{2} \cdot t}{\sqrt{\color{blue}{\mathsf{fma}\left(4, \frac{t \cdot t}{x}, 2 \cdot \left(\frac{\ell \cdot \ell}{x} + t \cdot t\right)\right)}}} \]
    5. Taylor expanded in t around -inf 22.1

      \[\leadsto \frac{\sqrt{2} \cdot t}{\color{blue}{-\left(t \cdot \sqrt{2 + 4 \cdot \frac{1}{x}} + \frac{{\ell}^{2}}{t \cdot x} \cdot \sqrt{\frac{1}{2 + 4 \cdot \frac{1}{x}}}\right)}} \]
    6. Simplified22.1

      \[\leadsto \frac{\sqrt{2} \cdot t}{\color{blue}{-\mathsf{fma}\left(t, \sqrt{2 + \frac{4}{x}}, \frac{\ell \cdot \ell}{x \cdot t} \cdot \sqrt{\frac{1}{2 + \frac{4}{x}}}\right)}} \]

    if 4.3366740418950802e-308 < t < 7.2456970214758061e-165

    1. Initial program 63.3

      \[\frac{\sqrt{2} \cdot t}{\sqrt{\frac{x + 1}{x - 1} \cdot \left(\ell \cdot \ell + 2 \cdot \left(t \cdot t\right)\right) - \ell \cdot \ell}} \]
    2. Simplified63.3

      \[\leadsto \color{blue}{\frac{\sqrt{2} \cdot t}{\sqrt{\frac{x + 1}{x - 1} \cdot \mathsf{fma}\left(2, t \cdot t, \ell \cdot \ell\right) - \ell \cdot \ell}}} \]
    3. Taylor expanded in x around inf 23.0

      \[\leadsto \frac{\sqrt{2} \cdot t}{\color{blue}{t \cdot \sqrt{2} + \left(2 \cdot \frac{t}{\sqrt{2} \cdot x} + \frac{{\ell}^{2}}{t \cdot \left(\sqrt{2} \cdot x\right)}\right)}} \]
    4. Simplified23.0

      \[\leadsto \frac{\sqrt{2} \cdot t}{\color{blue}{\mathsf{fma}\left(t, \sqrt{2}, \mathsf{fma}\left(2, \frac{t}{\sqrt{2} \cdot x}, \frac{\ell \cdot \ell}{t \cdot \left(\sqrt{2} \cdot x\right)}\right)\right)}} \]

    if 7.2456970214758061e-165 < t < 9.3211297631705548e68

    1. Initial program 28.3

      \[\frac{\sqrt{2} \cdot t}{\sqrt{\frac{x + 1}{x - 1} \cdot \left(\ell \cdot \ell + 2 \cdot \left(t \cdot t\right)\right) - \ell \cdot \ell}} \]
    2. Simplified28.3

      \[\leadsto \color{blue}{\frac{\sqrt{2} \cdot t}{\sqrt{\frac{x + 1}{x - 1} \cdot \mathsf{fma}\left(2, t \cdot t, \ell \cdot \ell\right) - \ell \cdot \ell}}} \]
    3. Taylor expanded in x around inf 11.1

      \[\leadsto \frac{\sqrt{2} \cdot t}{\sqrt{\color{blue}{4 \cdot \frac{{t}^{2}}{x} + \left(2 \cdot \frac{{\ell}^{2}}{x} + 2 \cdot {t}^{2}\right)}}} \]
    4. Simplified11.1

      \[\leadsto \frac{\sqrt{2} \cdot t}{\sqrt{\color{blue}{\mathsf{fma}\left(4, \frac{t \cdot t}{x}, 2 \cdot \left(\frac{\ell \cdot \ell}{x} + t \cdot t\right)\right)}}} \]
    5. Applied *-un-lft-identity_binary6411.1

      \[\leadsto \frac{\sqrt{2} \cdot t}{\sqrt{\mathsf{fma}\left(4, \frac{t \cdot t}{x}, 2 \cdot \left(\frac{\ell \cdot \ell}{\color{blue}{1 \cdot x}} + t \cdot t\right)\right)}} \]
    6. Applied times-frac_binary645.3

      \[\leadsto \frac{\sqrt{2} \cdot t}{\sqrt{\mathsf{fma}\left(4, \frac{t \cdot t}{x}, 2 \cdot \left(\color{blue}{\frac{\ell}{1} \cdot \frac{\ell}{x}} + t \cdot t\right)\right)}} \]
    7. Simplified5.3

      \[\leadsto \frac{\sqrt{2} \cdot t}{\sqrt{\mathsf{fma}\left(4, \frac{t \cdot t}{x}, 2 \cdot \left(\color{blue}{\ell} \cdot \frac{\ell}{x} + t \cdot t\right)\right)}} \]
    8. Applied add-sqr-sqrt_binary645.3

      \[\leadsto \frac{\sqrt{2} \cdot t}{\sqrt{\mathsf{fma}\left(4, \frac{t \cdot t}{x}, 2 \cdot \color{blue}{\left(\sqrt{\ell \cdot \frac{\ell}{x} + t \cdot t} \cdot \sqrt{\ell \cdot \frac{\ell}{x} + t \cdot t}\right)}\right)}} \]

    if 9.3211297631705548e68 < t

    1. Initial program 46.6

      \[\frac{\sqrt{2} \cdot t}{\sqrt{\frac{x + 1}{x - 1} \cdot \left(\ell \cdot \ell + 2 \cdot \left(t \cdot t\right)\right) - \ell \cdot \ell}} \]
    2. Simplified46.6

      \[\leadsto \color{blue}{\frac{\sqrt{2} \cdot t}{\sqrt{\frac{x + 1}{x - 1} \cdot \mathsf{fma}\left(2, t \cdot t, \ell \cdot \ell\right) - \ell \cdot \ell}}} \]
    3. Taylor expanded in t around inf 3.5

      \[\leadsto \frac{\sqrt{2} \cdot t}{\color{blue}{\sqrt{2 \cdot \frac{1}{x - 1} + 2 \cdot \frac{x}{x - 1}} \cdot t}} \]
    4. Simplified3.5

      \[\leadsto \frac{\sqrt{2} \cdot t}{\color{blue}{\sqrt{\frac{2}{x - 1} + 2 \cdot \frac{x}{x - 1}} \cdot t}} \]
  3. Recombined 6 regimes into one program.
  4. Final simplification7.7

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -1.1296845245651568 \cdot 10^{+129}:\\ \;\;\;\;\frac{t \cdot \sqrt{2}}{-t \cdot \sqrt{\frac{2}{x - 1} + 2 \cdot \frac{x}{x - 1}}}\\ \mathbf{elif}\;t \leq -3.244214081833893 \cdot 10^{-124}:\\ \;\;\;\;\frac{t \cdot \sqrt{2}}{\sqrt{\mathsf{fma}\left(4, \frac{t \cdot t}{x}, 2 \cdot \left(t \cdot t + \frac{\ell}{\frac{x}{\ell}}\right)\right)}}\\ \mathbf{elif}\;t \leq 4.33667404189508 \cdot 10^{-308}:\\ \;\;\;\;\frac{t \cdot \sqrt{2}}{-\mathsf{fma}\left(t, \sqrt{2 + \frac{4}{x}}, \frac{\ell \cdot \ell}{t \cdot x} \cdot \sqrt{\frac{1}{2 + \frac{4}{x}}}\right)}\\ \mathbf{elif}\;t \leq 7.245697021475806 \cdot 10^{-165}:\\ \;\;\;\;\frac{t \cdot \sqrt{2}}{\mathsf{fma}\left(t, \sqrt{2}, \mathsf{fma}\left(2, \frac{t}{\sqrt{2} \cdot x}, \frac{\ell \cdot \ell}{t \cdot \left(\sqrt{2} \cdot x\right)}\right)\right)}\\ \mathbf{elif}\;t \leq 9.321129763170555 \cdot 10^{+68}:\\ \;\;\;\;\frac{t \cdot \sqrt{2}}{\sqrt{\mathsf{fma}\left(4, \frac{t \cdot t}{x}, 2 \cdot \left(\sqrt{t \cdot t + \ell \cdot \frac{\ell}{x}} \cdot \sqrt{t \cdot t + \ell \cdot \frac{\ell}{x}}\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{t \cdot \sqrt{2}}{t \cdot \sqrt{\frac{2}{x - 1} + 2 \cdot \frac{x}{x - 1}}}\\ \end{array} \]

Reproduce

herbie shell --seed 2022103 
(FPCore (x l t)
  :name "Toniolo and Linder, Equation (7)"
  :precision binary64
  (/ (* (sqrt 2.0) t) (sqrt (- (* (/ (+ x 1.0) (- x 1.0)) (+ (* l l) (* 2.0 (* t t)))) (* l l)))))