Average Error: 43.0 → 11.9
Time: 8.5s
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 t + \frac{t \cdot t}{x}\\ t_2 := \mathsf{fma}\left(2, t \cdot t, \ell \cdot \ell\right)\\ t_3 := t \cdot \sqrt{2}\\ t_4 := \frac{\ell \cdot \ell}{x}\\ t_5 := \sqrt{\frac{x + 1}{x + -1}}\\ t_6 := \frac{t_3}{t_5 \cdot \left(t \cdot \left(-\sqrt{2}\right)\right)}\\ t_7 := \frac{t_2}{x}\\ \mathbf{if}\;t \leq -7.2 \cdot 10^{+98}:\\ \;\;\;\;t_6\\ \mathbf{elif}\;t \leq -5.2 \cdot 10^{-125}:\\ \;\;\;\;\frac{t_3}{\sqrt{t_4 + \left(\mathsf{fma}\left(2, t_1, \frac{2 \cdot t_2}{x \cdot x}\right) + t_7\right)}}\\ \mathbf{elif}\;t \leq -7 \cdot 10^{-224}:\\ \;\;\;\;t_6\\ \mathbf{elif}\;t \leq 5.5 \cdot 10^{-56}:\\ \;\;\;\;\frac{t_3}{\sqrt{t_4 + \mathsf{fma}\left(2, t_1, t_7\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{t_3}{\sqrt{2} \cdot \left(t \cdot t_5\right)}\\ \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 t) (/ (* t t) x)))
        (t_2 (fma 2.0 (* t t) (* l l)))
        (t_3 (* t (sqrt 2.0)))
        (t_4 (/ (* l l) x))
        (t_5 (sqrt (/ (+ x 1.0) (+ x -1.0))))
        (t_6 (/ t_3 (* t_5 (* t (- (sqrt 2.0))))))
        (t_7 (/ t_2 x)))
   (if (<= t -7.2e+98)
     t_6
     (if (<= t -5.2e-125)
       (/ t_3 (sqrt (+ t_4 (+ (fma 2.0 t_1 (/ (* 2.0 t_2) (* x x))) t_7))))
       (if (<= t -7e-224)
         t_6
         (if (<= t 5.5e-56)
           (/ t_3 (sqrt (+ t_4 (fma 2.0 t_1 t_7))))
           (/ t_3 (* (sqrt 2.0) (* t t_5)))))))))
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 * t) + ((t * t) / x);
	double t_2 = fma(2.0, (t * t), (l * l));
	double t_3 = t * sqrt(2.0);
	double t_4 = (l * l) / x;
	double t_5 = sqrt(((x + 1.0) / (x + -1.0)));
	double t_6 = t_3 / (t_5 * (t * -sqrt(2.0)));
	double t_7 = t_2 / x;
	double tmp;
	if (t <= -7.2e+98) {
		tmp = t_6;
	} else if (t <= -5.2e-125) {
		tmp = t_3 / sqrt((t_4 + (fma(2.0, t_1, ((2.0 * t_2) / (x * x))) + t_7)));
	} else if (t <= -7e-224) {
		tmp = t_6;
	} else if (t <= 5.5e-56) {
		tmp = t_3 / sqrt((t_4 + fma(2.0, t_1, t_7)));
	} else {
		tmp = t_3 / (sqrt(2.0) * (t * t_5));
	}
	return tmp;
}
function code(x, l, t)
	return Float64(Float64(sqrt(2.0) * t) / sqrt(Float64(Float64(Float64(Float64(x + 1.0) / Float64(x - 1.0)) * Float64(Float64(l * l) + Float64(2.0 * Float64(t * t)))) - Float64(l * l))))
end
function code(x, l, t)
	t_1 = Float64(Float64(t * t) + Float64(Float64(t * t) / x))
	t_2 = fma(2.0, Float64(t * t), Float64(l * l))
	t_3 = Float64(t * sqrt(2.0))
	t_4 = Float64(Float64(l * l) / x)
	t_5 = sqrt(Float64(Float64(x + 1.0) / Float64(x + -1.0)))
	t_6 = Float64(t_3 / Float64(t_5 * Float64(t * Float64(-sqrt(2.0)))))
	t_7 = Float64(t_2 / x)
	tmp = 0.0
	if (t <= -7.2e+98)
		tmp = t_6;
	elseif (t <= -5.2e-125)
		tmp = Float64(t_3 / sqrt(Float64(t_4 + Float64(fma(2.0, t_1, Float64(Float64(2.0 * t_2) / Float64(x * x))) + t_7))));
	elseif (t <= -7e-224)
		tmp = t_6;
	elseif (t <= 5.5e-56)
		tmp = Float64(t_3 / sqrt(Float64(t_4 + fma(2.0, t_1, t_7))));
	else
		tmp = Float64(t_3 / Float64(sqrt(2.0) * Float64(t * t_5)));
	end
	return tmp
end
code[x_, l_, t_] := N[(N[(N[Sqrt[2.0], $MachinePrecision] * t), $MachinePrecision] / N[Sqrt[N[(N[(N[(N[(x + 1.0), $MachinePrecision] / N[(x - 1.0), $MachinePrecision]), $MachinePrecision] * N[(N[(l * l), $MachinePrecision] + N[(2.0 * N[(t * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(l * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
code[x_, l_, t_] := Block[{t$95$1 = N[(N[(t * t), $MachinePrecision] + N[(N[(t * t), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(2.0 * N[(t * t), $MachinePrecision] + N[(l * l), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(t * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(N[(l * l), $MachinePrecision] / x), $MachinePrecision]}, Block[{t$95$5 = N[Sqrt[N[(N[(x + 1.0), $MachinePrecision] / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$6 = N[(t$95$3 / N[(t$95$5 * N[(t * (-N[Sqrt[2.0], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$7 = N[(t$95$2 / x), $MachinePrecision]}, If[LessEqual[t, -7.2e+98], t$95$6, If[LessEqual[t, -5.2e-125], N[(t$95$3 / N[Sqrt[N[(t$95$4 + N[(N[(2.0 * t$95$1 + N[(N[(2.0 * t$95$2), $MachinePrecision] / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$7), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t, -7e-224], t$95$6, If[LessEqual[t, 5.5e-56], N[(t$95$3 / N[Sqrt[N[(t$95$4 + N[(2.0 * t$95$1 + t$95$7), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(t$95$3 / N[(N[Sqrt[2.0], $MachinePrecision] * N[(t * t$95$5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]]]
\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 t + \frac{t \cdot t}{x}\\
t_2 := \mathsf{fma}\left(2, t \cdot t, \ell \cdot \ell\right)\\
t_3 := t \cdot \sqrt{2}\\
t_4 := \frac{\ell \cdot \ell}{x}\\
t_5 := \sqrt{\frac{x + 1}{x + -1}}\\
t_6 := \frac{t_3}{t_5 \cdot \left(t \cdot \left(-\sqrt{2}\right)\right)}\\
t_7 := \frac{t_2}{x}\\
\mathbf{if}\;t \leq -7.2 \cdot 10^{+98}:\\
\;\;\;\;t_6\\

\mathbf{elif}\;t \leq -5.2 \cdot 10^{-125}:\\
\;\;\;\;\frac{t_3}{\sqrt{t_4 + \left(\mathsf{fma}\left(2, t_1, \frac{2 \cdot t_2}{x \cdot x}\right) + t_7\right)}}\\

\mathbf{elif}\;t \leq -7 \cdot 10^{-224}:\\
\;\;\;\;t_6\\

\mathbf{elif}\;t \leq 5.5 \cdot 10^{-56}:\\
\;\;\;\;\frac{t_3}{\sqrt{t_4 + \mathsf{fma}\left(2, t_1, t_7\right)}}\\

\mathbf{else}:\\
\;\;\;\;\frac{t_3}{\sqrt{2} \cdot \left(t \cdot t_5\right)}\\


\end{array}

Error

Derivation

  1. Split input into 4 regimes
  2. if t < -7.19999999999999962e98 or -5.20000000000000011e-125 < t < -7.00000000000000037e-224

    1. Initial program 52.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. Taylor expanded in t around -inf 10.3

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

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

    if -7.19999999999999962e98 < t < -5.20000000000000011e-125

    1. Initial program 25.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. Taylor expanded in x around -inf 11.0

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

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

    if -7.00000000000000037e-224 < t < 5.4999999999999999e-56

    1. Initial program 53.9

      \[\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. Taylor expanded in x around inf 23.4

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

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

    if 5.4999999999999999e-56 < t

    1. Initial program 38.5

      \[\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. Taylor expanded in l around 0 6.3

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

      \[\leadsto \frac{\sqrt{2} \cdot t}{\color{blue}{\sqrt{2} \cdot \left(t \cdot \sqrt{\frac{x + 1}{x + -1}}\right)}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification11.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -7.2 \cdot 10^{+98}:\\ \;\;\;\;\frac{t \cdot \sqrt{2}}{\sqrt{\frac{x + 1}{x + -1}} \cdot \left(t \cdot \left(-\sqrt{2}\right)\right)}\\ \mathbf{elif}\;t \leq -5.2 \cdot 10^{-125}:\\ \;\;\;\;\frac{t \cdot \sqrt{2}}{\sqrt{\frac{\ell \cdot \ell}{x} + \left(\mathsf{fma}\left(2, t \cdot t + \frac{t \cdot t}{x}, \frac{2 \cdot \mathsf{fma}\left(2, t \cdot t, \ell \cdot \ell\right)}{x \cdot x}\right) + \frac{\mathsf{fma}\left(2, t \cdot t, \ell \cdot \ell\right)}{x}\right)}}\\ \mathbf{elif}\;t \leq -7 \cdot 10^{-224}:\\ \;\;\;\;\frac{t \cdot \sqrt{2}}{\sqrt{\frac{x + 1}{x + -1}} \cdot \left(t \cdot \left(-\sqrt{2}\right)\right)}\\ \mathbf{elif}\;t \leq 5.5 \cdot 10^{-56}:\\ \;\;\;\;\frac{t \cdot \sqrt{2}}{\sqrt{\frac{\ell \cdot \ell}{x} + \mathsf{fma}\left(2, t \cdot t + \frac{t \cdot t}{x}, \frac{\mathsf{fma}\left(2, t \cdot t, \ell \cdot \ell\right)}{x}\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{t \cdot \sqrt{2}}{\sqrt{2} \cdot \left(t \cdot \sqrt{\frac{x + 1}{x + -1}}\right)}\\ \end{array} \]

Reproduce

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