Toniolo and Linder, Equation (7)

Percentage Accurate: 33.9% → 85.3%
Time: 19.1s
Alternatives: 9
Speedup: 85.0×

Specification

?
\[\begin{array}{l} \\ \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}} \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)))))
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)));
}
real(8) function code(x, l, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: l
    real(8), intent (in) :: t
    code = (sqrt(2.0d0) * t) / sqrt(((((x + 1.0d0) / (x - 1.0d0)) * ((l * l) + (2.0d0 * (t * t)))) - (l * l)))
end function
public static double code(double x, double l, double t) {
	return (Math.sqrt(2.0) * t) / Math.sqrt(((((x + 1.0) / (x - 1.0)) * ((l * l) + (2.0 * (t * t)))) - (l * l)));
}
def code(x, l, t):
	return (math.sqrt(2.0) * t) / math.sqrt(((((x + 1.0) / (x - 1.0)) * ((l * l) + (2.0 * (t * t)))) - (l * l)))
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 tmp = code(x, l, t)
	tmp = (sqrt(2.0) * t) / sqrt(((((x + 1.0) / (x - 1.0)) * ((l * l) + (2.0 * (t * t)))) - (l * l)));
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]
\begin{array}{l}

\\
\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}}
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 9 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 33.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \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}} \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)))))
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)));
}
real(8) function code(x, l, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: l
    real(8), intent (in) :: t
    code = (sqrt(2.0d0) * t) / sqrt(((((x + 1.0d0) / (x - 1.0d0)) * ((l * l) + (2.0d0 * (t * t)))) - (l * l)))
end function
public static double code(double x, double l, double t) {
	return (Math.sqrt(2.0) * t) / Math.sqrt(((((x + 1.0) / (x - 1.0)) * ((l * l) + (2.0 * (t * t)))) - (l * l)));
}
def code(x, l, t):
	return (math.sqrt(2.0) * t) / math.sqrt(((((x + 1.0) / (x - 1.0)) * ((l * l) + (2.0 * (t * t)))) - (l * l)))
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 tmp = code(x, l, t)
	tmp = (sqrt(2.0) * t) / sqrt(((((x + 1.0) / (x - 1.0)) * ((l * l) + (2.0 * (t * t)))) - (l * l)));
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]
\begin{array}{l}

\\
\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}}
\end{array}

Alternative 1: 85.3% accurate, 0.6× speedup?

\[\begin{array}{l} t\_m = \left|t\right| \\ t\_s = \mathsf{copysign}\left(1, t\right) \\ \begin{array}{l} t_2 := \mathsf{fma}\left(t\_m, t\_m, t\_m \cdot t\_m\right)\\ t_3 := \mathsf{fma}\left(\ell, \ell, \ell \cdot \ell\right)\\ t_4 := t\_m \cdot \sqrt{2}\\ t\_s \cdot \begin{array}{l} \mathbf{if}\;t\_m \leq 9.5 \cdot 10^{-160}:\\ \;\;\;\;\frac{t\_4}{\mathsf{fma}\left(0.5, \frac{2 \cdot \mathsf{fma}\left(2, t\_m \cdot t\_m, \ell \cdot \ell\right)}{t\_4 \cdot x}, t\_4\right)}\\ \mathbf{elif}\;t\_m \leq 2.85 \cdot 10^{+57}:\\ \;\;\;\;\frac{t\_4}{\sqrt{2 \cdot \left(t\_m \cdot t\_m\right) - \frac{\left(-2 \cdot t\_2 - t\_3\right) - \frac{\mathsf{fma}\left(-2, -t\_2, t\_3\right)}{x}}{x}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{t\_4}{t\_m \cdot \left(\sqrt{2} + \frac{2}{\sqrt{2} \cdot x}\right)}\\ \end{array} \end{array} \end{array} \]
t\_m = (fabs.f64 t)
t\_s = (copysign.f64 #s(literal 1 binary64) t)
(FPCore (t_s x l t_m)
 :precision binary64
 (let* ((t_2 (fma t_m t_m (* t_m t_m)))
        (t_3 (fma l l (* l l)))
        (t_4 (* t_m (sqrt 2.0))))
   (*
    t_s
    (if (<= t_m 9.5e-160)
      (/ t_4 (fma 0.5 (/ (* 2.0 (fma 2.0 (* t_m t_m) (* l l))) (* t_4 x)) t_4))
      (if (<= t_m 2.85e+57)
        (/
         t_4
         (sqrt
          (-
           (* 2.0 (* t_m t_m))
           (/ (- (- (* -2.0 t_2) t_3) (/ (fma -2.0 (- t_2) t_3) x)) x))))
        (/ t_4 (* t_m (+ (sqrt 2.0) (/ 2.0 (* (sqrt 2.0) x))))))))))
t\_m = fabs(t);
t\_s = copysign(1.0, t);
double code(double t_s, double x, double l, double t_m) {
	double t_2 = fma(t_m, t_m, (t_m * t_m));
	double t_3 = fma(l, l, (l * l));
	double t_4 = t_m * sqrt(2.0);
	double tmp;
	if (t_m <= 9.5e-160) {
		tmp = t_4 / fma(0.5, ((2.0 * fma(2.0, (t_m * t_m), (l * l))) / (t_4 * x)), t_4);
	} else if (t_m <= 2.85e+57) {
		tmp = t_4 / sqrt(((2.0 * (t_m * t_m)) - ((((-2.0 * t_2) - t_3) - (fma(-2.0, -t_2, t_3) / x)) / x)));
	} else {
		tmp = t_4 / (t_m * (sqrt(2.0) + (2.0 / (sqrt(2.0) * x))));
	}
	return t_s * tmp;
}
t\_m = abs(t)
t\_s = copysign(1.0, t)
function code(t_s, x, l, t_m)
	t_2 = fma(t_m, t_m, Float64(t_m * t_m))
	t_3 = fma(l, l, Float64(l * l))
	t_4 = Float64(t_m * sqrt(2.0))
	tmp = 0.0
	if (t_m <= 9.5e-160)
		tmp = Float64(t_4 / fma(0.5, Float64(Float64(2.0 * fma(2.0, Float64(t_m * t_m), Float64(l * l))) / Float64(t_4 * x)), t_4));
	elseif (t_m <= 2.85e+57)
		tmp = Float64(t_4 / sqrt(Float64(Float64(2.0 * Float64(t_m * t_m)) - Float64(Float64(Float64(Float64(-2.0 * t_2) - t_3) - Float64(fma(-2.0, Float64(-t_2), t_3) / x)) / x))));
	else
		tmp = Float64(t_4 / Float64(t_m * Float64(sqrt(2.0) + Float64(2.0 / Float64(sqrt(2.0) * x)))));
	end
	return Float64(t_s * tmp)
end
t\_m = N[Abs[t], $MachinePrecision]
t\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[t]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[t$95$s_, x_, l_, t$95$m_] := Block[{t$95$2 = N[(t$95$m * t$95$m + N[(t$95$m * t$95$m), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(l * l + N[(l * l), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(t$95$m * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]}, N[(t$95$s * If[LessEqual[t$95$m, 9.5e-160], N[(t$95$4 / N[(0.5 * N[(N[(2.0 * N[(2.0 * N[(t$95$m * t$95$m), $MachinePrecision] + N[(l * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$4 * x), $MachinePrecision]), $MachinePrecision] + t$95$4), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$m, 2.85e+57], N[(t$95$4 / N[Sqrt[N[(N[(2.0 * N[(t$95$m * t$95$m), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(N[(-2.0 * t$95$2), $MachinePrecision] - t$95$3), $MachinePrecision] - N[(N[(-2.0 * (-t$95$2) + t$95$3), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(t$95$4 / N[(t$95$m * N[(N[Sqrt[2.0], $MachinePrecision] + N[(2.0 / N[(N[Sqrt[2.0], $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]]]]
\begin{array}{l}
t\_m = \left|t\right|
\\
t\_s = \mathsf{copysign}\left(1, t\right)

\\
\begin{array}{l}
t_2 := \mathsf{fma}\left(t\_m, t\_m, t\_m \cdot t\_m\right)\\
t_3 := \mathsf{fma}\left(\ell, \ell, \ell \cdot \ell\right)\\
t_4 := t\_m \cdot \sqrt{2}\\
t\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_m \leq 9.5 \cdot 10^{-160}:\\
\;\;\;\;\frac{t\_4}{\mathsf{fma}\left(0.5, \frac{2 \cdot \mathsf{fma}\left(2, t\_m \cdot t\_m, \ell \cdot \ell\right)}{t\_4 \cdot x}, t\_4\right)}\\

\mathbf{elif}\;t\_m \leq 2.85 \cdot 10^{+57}:\\
\;\;\;\;\frac{t\_4}{\sqrt{2 \cdot \left(t\_m \cdot t\_m\right) - \frac{\left(-2 \cdot t\_2 - t\_3\right) - \frac{\mathsf{fma}\left(-2, -t\_2, t\_3\right)}{x}}{x}}}\\

\mathbf{else}:\\
\;\;\;\;\frac{t\_4}{t\_m \cdot \left(\sqrt{2} + \frac{2}{\sqrt{2} \cdot x}\right)}\\


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if t < 9.5000000000000002e-160

    1. Initial program 3.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. Add Preprocessing
    3. Taylor expanded in x around inf

      \[\leadsto \frac{\sqrt{2} \cdot t}{\color{blue}{\frac{1}{2} \cdot \frac{\left(2 \cdot {t}^{2} + {\ell}^{2}\right) - -1 \cdot \left(2 \cdot {t}^{2} + {\ell}^{2}\right)}{t \cdot \left(x \cdot \sqrt{2}\right)} + t \cdot \sqrt{2}}} \]
    4. Step-by-step derivation
      1. lower-fma.f64N/A

        \[\leadsto \frac{\sqrt{2} \cdot t}{\color{blue}{\mathsf{fma}\left(\frac{1}{2}, \frac{\left(2 \cdot {t}^{2} + {\ell}^{2}\right) - -1 \cdot \left(2 \cdot {t}^{2} + {\ell}^{2}\right)}{t \cdot \left(x \cdot \sqrt{2}\right)}, t \cdot \sqrt{2}\right)}} \]
    5. Applied rewrites66.9%

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

    if 9.5000000000000002e-160 < t < 2.8499999999999999e57

    1. Initial program 54.1%

      \[\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. Add Preprocessing
    3. Step-by-step derivation
      1. lift--.f64N/A

        \[\leadsto \frac{\sqrt{2} \cdot t}{\sqrt{\color{blue}{\frac{x + 1}{x - 1} \cdot \left(\ell \cdot \ell + 2 \cdot \left(t \cdot t\right)\right) - \ell \cdot \ell}}} \]
      2. sub-negN/A

        \[\leadsto \frac{\sqrt{2} \cdot t}{\sqrt{\color{blue}{\frac{x + 1}{x - 1} \cdot \left(\ell \cdot \ell + 2 \cdot \left(t \cdot t\right)\right) + \left(\mathsf{neg}\left(\ell \cdot \ell\right)\right)}}} \]
      3. lift-*.f64N/A

        \[\leadsto \frac{\sqrt{2} \cdot t}{\sqrt{\color{blue}{\frac{x + 1}{x - 1} \cdot \left(\ell \cdot \ell + 2 \cdot \left(t \cdot t\right)\right)} + \left(\mathsf{neg}\left(\ell \cdot \ell\right)\right)}} \]
      4. lift-+.f64N/A

        \[\leadsto \frac{\sqrt{2} \cdot t}{\sqrt{\frac{x + 1}{x - 1} \cdot \color{blue}{\left(\ell \cdot \ell + 2 \cdot \left(t \cdot t\right)\right)} + \left(\mathsf{neg}\left(\ell \cdot \ell\right)\right)}} \]
      5. distribute-rgt-inN/A

        \[\leadsto \frac{\sqrt{2} \cdot t}{\sqrt{\color{blue}{\left(\left(\ell \cdot \ell\right) \cdot \frac{x + 1}{x - 1} + \left(2 \cdot \left(t \cdot t\right)\right) \cdot \frac{x + 1}{x - 1}\right)} + \left(\mathsf{neg}\left(\ell \cdot \ell\right)\right)}} \]
      6. distribute-rgt-inN/A

        \[\leadsto \frac{\sqrt{2} \cdot t}{\sqrt{\color{blue}{\frac{x + 1}{x - 1} \cdot \left(\ell \cdot \ell + 2 \cdot \left(t \cdot t\right)\right)} + \left(\mathsf{neg}\left(\ell \cdot \ell\right)\right)}} \]
      7. lift-/.f64N/A

        \[\leadsto \frac{\sqrt{2} \cdot t}{\sqrt{\color{blue}{\frac{x + 1}{x - 1}} \cdot \left(\ell \cdot \ell + 2 \cdot \left(t \cdot t\right)\right) + \left(\mathsf{neg}\left(\ell \cdot \ell\right)\right)}} \]
      8. clear-numN/A

        \[\leadsto \frac{\sqrt{2} \cdot t}{\sqrt{\color{blue}{\frac{1}{\frac{x - 1}{x + 1}}} \cdot \left(\ell \cdot \ell + 2 \cdot \left(t \cdot t\right)\right) + \left(\mathsf{neg}\left(\ell \cdot \ell\right)\right)}} \]
      9. lift-+.f64N/A

        \[\leadsto \frac{\sqrt{2} \cdot t}{\sqrt{\frac{1}{\frac{x - 1}{x + 1}} \cdot \color{blue}{\left(\ell \cdot \ell + 2 \cdot \left(t \cdot t\right)\right)} + \left(\mathsf{neg}\left(\ell \cdot \ell\right)\right)}} \]
      10. associate-/r/N/A

        \[\leadsto \frac{\sqrt{2} \cdot t}{\sqrt{\color{blue}{\left(\frac{1}{x - 1} \cdot \left(x + 1\right)\right)} \cdot \left(\ell \cdot \ell + 2 \cdot \left(t \cdot t\right)\right) + \left(\mathsf{neg}\left(\ell \cdot \ell\right)\right)}} \]
      11. associate-*l*N/A

        \[\leadsto \frac{\sqrt{2} \cdot t}{\sqrt{\color{blue}{\frac{1}{x - 1} \cdot \left(\left(x + 1\right) \cdot \left(\ell \cdot \ell + 2 \cdot \left(t \cdot t\right)\right)\right)} + \left(\mathsf{neg}\left(\ell \cdot \ell\right)\right)}} \]
      12. lower-fma.f64N/A

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

      \[\leadsto \frac{\sqrt{2} \cdot t}{\sqrt{\color{blue}{\mathsf{fma}\left(\frac{1}{x + -1}, \mathsf{fma}\left(2, t \cdot t, \ell \cdot \ell\right) \cdot \left(x + 1\right), -\ell \cdot \ell\right)}}} \]
    5. Step-by-step derivation
      1. lift-fma.f64N/A

        \[\leadsto \frac{\sqrt{2} \cdot t}{\sqrt{\color{blue}{\frac{1}{x + -1} \cdot \left(\mathsf{fma}\left(2, t \cdot t, \ell \cdot \ell\right) \cdot \left(x + 1\right)\right) + \left(\mathsf{neg}\left(\ell \cdot \ell\right)\right)}}} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{\sqrt{2} \cdot t}{\sqrt{\frac{1}{x + -1} \cdot \color{blue}{\left(\mathsf{fma}\left(2, t \cdot t, \ell \cdot \ell\right) \cdot \left(x + 1\right)\right)} + \left(\mathsf{neg}\left(\ell \cdot \ell\right)\right)}} \]
      3. *-commutativeN/A

        \[\leadsto \frac{\sqrt{2} \cdot t}{\sqrt{\frac{1}{x + -1} \cdot \color{blue}{\left(\left(x + 1\right) \cdot \mathsf{fma}\left(2, t \cdot t, \ell \cdot \ell\right)\right)} + \left(\mathsf{neg}\left(\ell \cdot \ell\right)\right)}} \]
      4. associate-*r*N/A

        \[\leadsto \frac{\sqrt{2} \cdot t}{\sqrt{\color{blue}{\left(\frac{1}{x + -1} \cdot \left(x + 1\right)\right) \cdot \mathsf{fma}\left(2, t \cdot t, \ell \cdot \ell\right)} + \left(\mathsf{neg}\left(\ell \cdot \ell\right)\right)}} \]
      5. lift-/.f64N/A

        \[\leadsto \frac{\sqrt{2} \cdot t}{\sqrt{\left(\color{blue}{\frac{1}{x + -1}} \cdot \left(x + 1\right)\right) \cdot \mathsf{fma}\left(2, t \cdot t, \ell \cdot \ell\right) + \left(\mathsf{neg}\left(\ell \cdot \ell\right)\right)}} \]
      6. lift-+.f64N/A

        \[\leadsto \frac{\sqrt{2} \cdot t}{\sqrt{\left(\frac{1}{\color{blue}{x + -1}} \cdot \left(x + 1\right)\right) \cdot \mathsf{fma}\left(2, t \cdot t, \ell \cdot \ell\right) + \left(\mathsf{neg}\left(\ell \cdot \ell\right)\right)}} \]
      7. metadata-evalN/A

        \[\leadsto \frac{\sqrt{2} \cdot t}{\sqrt{\left(\frac{1}{x + \color{blue}{\left(\mathsf{neg}\left(1\right)\right)}} \cdot \left(x + 1\right)\right) \cdot \mathsf{fma}\left(2, t \cdot t, \ell \cdot \ell\right) + \left(\mathsf{neg}\left(\ell \cdot \ell\right)\right)}} \]
      8. sub-negN/A

        \[\leadsto \frac{\sqrt{2} \cdot t}{\sqrt{\left(\frac{1}{\color{blue}{x - 1}} \cdot \left(x + 1\right)\right) \cdot \mathsf{fma}\left(2, t \cdot t, \ell \cdot \ell\right) + \left(\mathsf{neg}\left(\ell \cdot \ell\right)\right)}} \]
      9. lift--.f64N/A

        \[\leadsto \frac{\sqrt{2} \cdot t}{\sqrt{\left(\frac{1}{\color{blue}{x - 1}} \cdot \left(x + 1\right)\right) \cdot \mathsf{fma}\left(2, t \cdot t, \ell \cdot \ell\right) + \left(\mathsf{neg}\left(\ell \cdot \ell\right)\right)}} \]
      10. associate-/r/N/A

        \[\leadsto \frac{\sqrt{2} \cdot t}{\sqrt{\color{blue}{\frac{1}{\frac{x - 1}{x + 1}}} \cdot \mathsf{fma}\left(2, t \cdot t, \ell \cdot \ell\right) + \left(\mathsf{neg}\left(\ell \cdot \ell\right)\right)}} \]
      11. clear-numN/A

        \[\leadsto \frac{\sqrt{2} \cdot t}{\sqrt{\color{blue}{\frac{x + 1}{x - 1}} \cdot \mathsf{fma}\left(2, t \cdot t, \ell \cdot \ell\right) + \left(\mathsf{neg}\left(\ell \cdot \ell\right)\right)}} \]
      12. lift-/.f64N/A

        \[\leadsto \frac{\sqrt{2} \cdot t}{\sqrt{\color{blue}{\frac{x + 1}{x - 1}} \cdot \mathsf{fma}\left(2, t \cdot t, \ell \cdot \ell\right) + \left(\mathsf{neg}\left(\ell \cdot \ell\right)\right)}} \]
      13. lift-fma.f64N/A

        \[\leadsto \frac{\sqrt{2} \cdot t}{\sqrt{\frac{x + 1}{x - 1} \cdot \color{blue}{\left(2 \cdot \left(t \cdot t\right) + \ell \cdot \ell\right)} + \left(\mathsf{neg}\left(\ell \cdot \ell\right)\right)}} \]
      14. +-commutativeN/A

        \[\leadsto \frac{\sqrt{2} \cdot t}{\sqrt{\frac{x + 1}{x - 1} \cdot \color{blue}{\left(\ell \cdot \ell + 2 \cdot \left(t \cdot t\right)\right)} + \left(\mathsf{neg}\left(\ell \cdot \ell\right)\right)}} \]
      15. distribute-lft-inN/A

        \[\leadsto \frac{\sqrt{2} \cdot t}{\sqrt{\color{blue}{\left(\frac{x + 1}{x - 1} \cdot \left(\ell \cdot \ell\right) + \frac{x + 1}{x - 1} \cdot \left(2 \cdot \left(t \cdot t\right)\right)\right)} + \left(\mathsf{neg}\left(\ell \cdot \ell\right)\right)}} \]
    6. Applied rewrites54.2%

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

      \[\leadsto \frac{\sqrt{2} \cdot t}{\sqrt{\color{blue}{-1 \cdot \frac{-2 \cdot \left({t}^{2} - -1 \cdot {t}^{2}\right) + \left(-1 \cdot \left({\ell}^{2} - -1 \cdot {\ell}^{2}\right) + -1 \cdot \frac{-2 \cdot \left(-1 \cdot {t}^{2} - {t}^{2}\right) + -1 \cdot \left(-1 \cdot {\ell}^{2} - {\ell}^{2}\right)}{x}\right)}{x} + 2 \cdot {t}^{2}}}} \]
    8. Applied rewrites88.1%

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

    if 2.8499999999999999e57 < t

    1. Initial program 24.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. Add Preprocessing
    3. Taylor expanded in x around inf

      \[\leadsto \frac{\sqrt{2} \cdot t}{\color{blue}{\frac{1}{2} \cdot \frac{\left(2 \cdot {t}^{2} + {\ell}^{2}\right) - -1 \cdot \left(2 \cdot {t}^{2} + {\ell}^{2}\right)}{t \cdot \left(x \cdot \sqrt{2}\right)} + t \cdot \sqrt{2}}} \]
    4. Step-by-step derivation
      1. lower-fma.f64N/A

        \[\leadsto \frac{\sqrt{2} \cdot t}{\color{blue}{\mathsf{fma}\left(\frac{1}{2}, \frac{\left(2 \cdot {t}^{2} + {\ell}^{2}\right) - -1 \cdot \left(2 \cdot {t}^{2} + {\ell}^{2}\right)}{t \cdot \left(x \cdot \sqrt{2}\right)}, t \cdot \sqrt{2}\right)}} \]
    5. Applied rewrites26.0%

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

      \[\leadsto \frac{\sqrt{2} \cdot t}{t \cdot \color{blue}{\left(\sqrt{2} + 2 \cdot \frac{1}{x \cdot \sqrt{2}}\right)}} \]
    7. Step-by-step derivation
      1. Applied rewrites92.7%

        \[\leadsto \frac{\sqrt{2} \cdot t}{t \cdot \color{blue}{\left(\sqrt{2} + \frac{2}{\sqrt{2} \cdot x}\right)}} \]
    8. Recombined 3 regimes into one program.
    9. Final simplification85.7%

      \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq 9.5 \cdot 10^{-160}:\\ \;\;\;\;\frac{t \cdot \sqrt{2}}{\mathsf{fma}\left(0.5, \frac{2 \cdot \mathsf{fma}\left(2, t \cdot t, \ell \cdot \ell\right)}{\left(t \cdot \sqrt{2}\right) \cdot x}, t \cdot \sqrt{2}\right)}\\ \mathbf{elif}\;t \leq 2.85 \cdot 10^{+57}:\\ \;\;\;\;\frac{t \cdot \sqrt{2}}{\sqrt{2 \cdot \left(t \cdot t\right) - \frac{\left(-2 \cdot \mathsf{fma}\left(t, t, t \cdot t\right) - \mathsf{fma}\left(\ell, \ell, \ell \cdot \ell\right)\right) - \frac{\mathsf{fma}\left(-2, -\mathsf{fma}\left(t, t, t \cdot t\right), \mathsf{fma}\left(\ell, \ell, \ell \cdot \ell\right)\right)}{x}}{x}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{t \cdot \sqrt{2}}{t \cdot \left(\sqrt{2} + \frac{2}{\sqrt{2} \cdot x}\right)}\\ \end{array} \]
    10. Add Preprocessing

    Alternative 2: 85.1% accurate, 0.8× speedup?

    \[\begin{array}{l} t\_m = \left|t\right| \\ t\_s = \mathsf{copysign}\left(1, t\right) \\ \begin{array}{l} t_2 := 2 \cdot \mathsf{fma}\left(2, t\_m \cdot t\_m, \ell \cdot \ell\right)\\ t_3 := t\_m \cdot \sqrt{2}\\ t\_s \cdot \begin{array}{l} \mathbf{if}\;t\_m \leq 9.5 \cdot 10^{-160}:\\ \;\;\;\;\frac{t\_3}{\mathsf{fma}\left(0.5, \frac{t\_2}{t\_3 \cdot x}, t\_3\right)}\\ \mathbf{elif}\;t\_m \leq 2.85 \cdot 10^{+57}:\\ \;\;\;\;\frac{t\_3}{\sqrt{\mathsf{fma}\left(2, t\_m \cdot t\_m, \frac{t\_2}{x}\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{t\_3}{t\_m \cdot \left(\sqrt{2} + \frac{2}{\sqrt{2} \cdot x}\right)}\\ \end{array} \end{array} \end{array} \]
    t\_m = (fabs.f64 t)
    t\_s = (copysign.f64 #s(literal 1 binary64) t)
    (FPCore (t_s x l t_m)
     :precision binary64
     (let* ((t_2 (* 2.0 (fma 2.0 (* t_m t_m) (* l l)))) (t_3 (* t_m (sqrt 2.0))))
       (*
        t_s
        (if (<= t_m 9.5e-160)
          (/ t_3 (fma 0.5 (/ t_2 (* t_3 x)) t_3))
          (if (<= t_m 2.85e+57)
            (/ t_3 (sqrt (fma 2.0 (* t_m t_m) (/ t_2 x))))
            (/ t_3 (* t_m (+ (sqrt 2.0) (/ 2.0 (* (sqrt 2.0) x))))))))))
    t\_m = fabs(t);
    t\_s = copysign(1.0, t);
    double code(double t_s, double x, double l, double t_m) {
    	double t_2 = 2.0 * fma(2.0, (t_m * t_m), (l * l));
    	double t_3 = t_m * sqrt(2.0);
    	double tmp;
    	if (t_m <= 9.5e-160) {
    		tmp = t_3 / fma(0.5, (t_2 / (t_3 * x)), t_3);
    	} else if (t_m <= 2.85e+57) {
    		tmp = t_3 / sqrt(fma(2.0, (t_m * t_m), (t_2 / x)));
    	} else {
    		tmp = t_3 / (t_m * (sqrt(2.0) + (2.0 / (sqrt(2.0) * x))));
    	}
    	return t_s * tmp;
    }
    
    t\_m = abs(t)
    t\_s = copysign(1.0, t)
    function code(t_s, x, l, t_m)
    	t_2 = Float64(2.0 * fma(2.0, Float64(t_m * t_m), Float64(l * l)))
    	t_3 = Float64(t_m * sqrt(2.0))
    	tmp = 0.0
    	if (t_m <= 9.5e-160)
    		tmp = Float64(t_3 / fma(0.5, Float64(t_2 / Float64(t_3 * x)), t_3));
    	elseif (t_m <= 2.85e+57)
    		tmp = Float64(t_3 / sqrt(fma(2.0, Float64(t_m * t_m), Float64(t_2 / x))));
    	else
    		tmp = Float64(t_3 / Float64(t_m * Float64(sqrt(2.0) + Float64(2.0 / Float64(sqrt(2.0) * x)))));
    	end
    	return Float64(t_s * tmp)
    end
    
    t\_m = N[Abs[t], $MachinePrecision]
    t\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[t]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
    code[t$95$s_, x_, l_, t$95$m_] := Block[{t$95$2 = N[(2.0 * N[(2.0 * N[(t$95$m * t$95$m), $MachinePrecision] + N[(l * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$m * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]}, N[(t$95$s * If[LessEqual[t$95$m, 9.5e-160], N[(t$95$3 / N[(0.5 * N[(t$95$2 / N[(t$95$3 * x), $MachinePrecision]), $MachinePrecision] + t$95$3), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$m, 2.85e+57], N[(t$95$3 / N[Sqrt[N[(2.0 * N[(t$95$m * t$95$m), $MachinePrecision] + N[(t$95$2 / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(t$95$3 / N[(t$95$m * N[(N[Sqrt[2.0], $MachinePrecision] + N[(2.0 / N[(N[Sqrt[2.0], $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]]]
    
    \begin{array}{l}
    t\_m = \left|t\right|
    \\
    t\_s = \mathsf{copysign}\left(1, t\right)
    
    \\
    \begin{array}{l}
    t_2 := 2 \cdot \mathsf{fma}\left(2, t\_m \cdot t\_m, \ell \cdot \ell\right)\\
    t_3 := t\_m \cdot \sqrt{2}\\
    t\_s \cdot \begin{array}{l}
    \mathbf{if}\;t\_m \leq 9.5 \cdot 10^{-160}:\\
    \;\;\;\;\frac{t\_3}{\mathsf{fma}\left(0.5, \frac{t\_2}{t\_3 \cdot x}, t\_3\right)}\\
    
    \mathbf{elif}\;t\_m \leq 2.85 \cdot 10^{+57}:\\
    \;\;\;\;\frac{t\_3}{\sqrt{\mathsf{fma}\left(2, t\_m \cdot t\_m, \frac{t\_2}{x}\right)}}\\
    
    \mathbf{else}:\\
    \;\;\;\;\frac{t\_3}{t\_m \cdot \left(\sqrt{2} + \frac{2}{\sqrt{2} \cdot x}\right)}\\
    
    
    \end{array}
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 3 regimes
    2. if t < 9.5000000000000002e-160

      1. Initial program 3.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. Add Preprocessing
      3. Taylor expanded in x around inf

        \[\leadsto \frac{\sqrt{2} \cdot t}{\color{blue}{\frac{1}{2} \cdot \frac{\left(2 \cdot {t}^{2} + {\ell}^{2}\right) - -1 \cdot \left(2 \cdot {t}^{2} + {\ell}^{2}\right)}{t \cdot \left(x \cdot \sqrt{2}\right)} + t \cdot \sqrt{2}}} \]
      4. Step-by-step derivation
        1. lower-fma.f64N/A

          \[\leadsto \frac{\sqrt{2} \cdot t}{\color{blue}{\mathsf{fma}\left(\frac{1}{2}, \frac{\left(2 \cdot {t}^{2} + {\ell}^{2}\right) - -1 \cdot \left(2 \cdot {t}^{2} + {\ell}^{2}\right)}{t \cdot \left(x \cdot \sqrt{2}\right)}, t \cdot \sqrt{2}\right)}} \]
      5. Applied rewrites61.7%

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

      if 9.5000000000000002e-160 < t < 2.8499999999999999e57

      1. Initial program 56.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. Add Preprocessing
      3. Taylor expanded in x around inf

        \[\leadsto \frac{\sqrt{2} \cdot t}{\sqrt{\color{blue}{\left(2 \cdot \frac{{t}^{2}}{x} + \left(2 \cdot {t}^{2} + \frac{{\ell}^{2}}{x}\right)\right) - -1 \cdot \frac{2 \cdot {t}^{2} + {\ell}^{2}}{x}}}} \]
      4. Step-by-step derivation
        1. cancel-sign-sub-invN/A

          \[\leadsto \frac{\sqrt{2} \cdot t}{\sqrt{\color{blue}{\left(2 \cdot \frac{{t}^{2}}{x} + \left(2 \cdot {t}^{2} + \frac{{\ell}^{2}}{x}\right)\right) + \left(\mathsf{neg}\left(-1\right)\right) \cdot \frac{2 \cdot {t}^{2} + {\ell}^{2}}{x}}}} \]
        2. metadata-evalN/A

          \[\leadsto \frac{\sqrt{2} \cdot t}{\sqrt{\left(2 \cdot \frac{{t}^{2}}{x} + \left(2 \cdot {t}^{2} + \frac{{\ell}^{2}}{x}\right)\right) + \color{blue}{1} \cdot \frac{2 \cdot {t}^{2} + {\ell}^{2}}{x}}} \]
        3. *-lft-identityN/A

          \[\leadsto \frac{\sqrt{2} \cdot t}{\sqrt{\left(2 \cdot \frac{{t}^{2}}{x} + \left(2 \cdot {t}^{2} + \frac{{\ell}^{2}}{x}\right)\right) + \color{blue}{\frac{2 \cdot {t}^{2} + {\ell}^{2}}{x}}}} \]
        4. lower-+.f64N/A

          \[\leadsto \frac{\sqrt{2} \cdot t}{\sqrt{\color{blue}{\left(2 \cdot \frac{{t}^{2}}{x} + \left(2 \cdot {t}^{2} + \frac{{\ell}^{2}}{x}\right)\right) + \frac{2 \cdot {t}^{2} + {\ell}^{2}}{x}}}} \]
      5. Applied rewrites84.9%

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

        \[\leadsto \frac{\sqrt{2} \cdot t}{\sqrt{-1 \cdot \frac{-2 \cdot {t}^{2} + \left(-1 \cdot \left(2 \cdot {t}^{2} + {\ell}^{2}\right) + -1 \cdot {\ell}^{2}\right)}{x} + \color{blue}{2 \cdot {t}^{2}}}} \]
      7. Step-by-step derivation
        1. Applied rewrites84.9%

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

        if 2.8499999999999999e57 < t

        1. Initial program 29.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. Add Preprocessing
        3. Taylor expanded in x around inf

          \[\leadsto \frac{\sqrt{2} \cdot t}{\color{blue}{\frac{1}{2} \cdot \frac{\left(2 \cdot {t}^{2} + {\ell}^{2}\right) - -1 \cdot \left(2 \cdot {t}^{2} + {\ell}^{2}\right)}{t \cdot \left(x \cdot \sqrt{2}\right)} + t \cdot \sqrt{2}}} \]
        4. Step-by-step derivation
          1. lower-fma.f64N/A

            \[\leadsto \frac{\sqrt{2} \cdot t}{\color{blue}{\mathsf{fma}\left(\frac{1}{2}, \frac{\left(2 \cdot {t}^{2} + {\ell}^{2}\right) - -1 \cdot \left(2 \cdot {t}^{2} + {\ell}^{2}\right)}{t \cdot \left(x \cdot \sqrt{2}\right)}, t \cdot \sqrt{2}\right)}} \]
        5. Applied rewrites30.2%

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

          \[\leadsto \frac{\sqrt{2} \cdot t}{t \cdot \color{blue}{\left(\sqrt{2} + 2 \cdot \frac{1}{x \cdot \sqrt{2}}\right)}} \]
        7. Step-by-step derivation
          1. Applied rewrites94.3%

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

          \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq 9.5 \cdot 10^{-160}:\\ \;\;\;\;\frac{t \cdot \sqrt{2}}{\mathsf{fma}\left(0.5, \frac{2 \cdot \mathsf{fma}\left(2, t \cdot t, \ell \cdot \ell\right)}{\left(t \cdot \sqrt{2}\right) \cdot x}, t \cdot \sqrt{2}\right)}\\ \mathbf{elif}\;t \leq 2.85 \cdot 10^{+57}:\\ \;\;\;\;\frac{t \cdot \sqrt{2}}{\sqrt{\mathsf{fma}\left(2, t \cdot t, \frac{2 \cdot \mathsf{fma}\left(2, t \cdot t, \ell \cdot \ell\right)}{x}\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{t \cdot \sqrt{2}}{t \cdot \left(\sqrt{2} + \frac{2}{\sqrt{2} \cdot x}\right)}\\ \end{array} \]
        10. Add Preprocessing

        Reproduce

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