Toniolo and Linder, Equation (7)

Percentage Accurate: 32.2% → 79.3%
Time: 14.1s
Alternatives: 6
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 6 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: 32.2% 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: 79.3% accurate, 1.2× speedup?

\[\begin{array}{l} l_m = \left|\ell\right| \\ t\_m = \left|t\right| \\ t\_s = \mathsf{copysign}\left(1, t\right) \\ t\_s \cdot \begin{array}{l} \mathbf{if}\;t\_m \leq 1.95 \cdot 10^{-137}:\\ \;\;\;\;\frac{\left(\left(t\_m \cdot \sqrt{0.5}\right) \cdot \sqrt{2}\right) \cdot \sqrt{x}}{l\_m}\\ \mathbf{else}:\\ \;\;\;\;\frac{t\_m \cdot \sqrt{2}}{t\_m \cdot \sqrt{\frac{\mathsf{fma}\left(2, x, 2\right)}{x + -1}}}\\ \end{array} \end{array} \]
l_m = (fabs.f64 l)
t\_m = (fabs.f64 t)
t\_s = (copysign.f64 #s(literal 1 binary64) t)
(FPCore (t_s x l_m t_m)
 :precision binary64
 (*
  t_s
  (if (<= t_m 1.95e-137)
    (/ (* (* (* t_m (sqrt 0.5)) (sqrt 2.0)) (sqrt x)) l_m)
    (/ (* t_m (sqrt 2.0)) (* t_m (sqrt (/ (fma 2.0 x 2.0) (+ x -1.0))))))))
l_m = fabs(l);
t\_m = fabs(t);
t\_s = copysign(1.0, t);
double code(double t_s, double x, double l_m, double t_m) {
	double tmp;
	if (t_m <= 1.95e-137) {
		tmp = (((t_m * sqrt(0.5)) * sqrt(2.0)) * sqrt(x)) / l_m;
	} else {
		tmp = (t_m * sqrt(2.0)) / (t_m * sqrt((fma(2.0, x, 2.0) / (x + -1.0))));
	}
	return t_s * tmp;
}
l_m = abs(l)
t\_m = abs(t)
t\_s = copysign(1.0, t)
function code(t_s, x, l_m, t_m)
	tmp = 0.0
	if (t_m <= 1.95e-137)
		tmp = Float64(Float64(Float64(Float64(t_m * sqrt(0.5)) * sqrt(2.0)) * sqrt(x)) / l_m);
	else
		tmp = Float64(Float64(t_m * sqrt(2.0)) / Float64(t_m * sqrt(Float64(fma(2.0, x, 2.0) / Float64(x + -1.0)))));
	end
	return Float64(t_s * tmp)
end
l_m = N[Abs[l], $MachinePrecision]
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$95$m_, t$95$m_] := N[(t$95$s * If[LessEqual[t$95$m, 1.95e-137], N[(N[(N[(N[(t$95$m * N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision] * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision] * N[Sqrt[x], $MachinePrecision]), $MachinePrecision] / l$95$m), $MachinePrecision], N[(N[(t$95$m * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision] / N[(t$95$m * N[Sqrt[N[(N[(2.0 * x + 2.0), $MachinePrecision] / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
l_m = \left|\ell\right|
\\
t\_m = \left|t\right|
\\
t\_s = \mathsf{copysign}\left(1, t\right)

\\
t\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_m \leq 1.95 \cdot 10^{-137}:\\
\;\;\;\;\frac{\left(\left(t\_m \cdot \sqrt{0.5}\right) \cdot \sqrt{2}\right) \cdot \sqrt{x}}{l\_m}\\

\mathbf{else}:\\
\;\;\;\;\frac{t\_m \cdot \sqrt{2}}{t\_m \cdot \sqrt{\frac{\mathsf{fma}\left(2, x, 2\right)}{x + -1}}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < 1.95e-137

    1. Initial program 4.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. Add Preprocessing
    3. Taylor expanded in l around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{t \cdot \left(\sqrt{\frac{1}{2}} \cdot \sqrt{2}\right)}{\ell} \cdot \color{blue}{\sqrt{x}} \]
    10. Step-by-step derivation
      1. Applied rewrites63.4%

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

      if 1.95e-137 < t

      1. Initial program 35.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 l around 0

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

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

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

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

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

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

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

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

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

          \[\leadsto \frac{\sqrt{2} \cdot t}{\left(t \cdot \sqrt{2}\right) \cdot \sqrt{\frac{1 + x}{\color{blue}{x + -1}}}} \]
      5. Applied rewrites90.4%

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

          \[\leadsto \color{blue}{\frac{\sqrt{2} \cdot t}{t \cdot \sqrt{2 \cdot \frac{x + 1}{x + -1}}}} \]
        2. Step-by-step derivation
          1. Applied rewrites90.4%

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

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

        Alternative 2: 79.2% accurate, 1.2× speedup?

        \[\begin{array}{l} l_m = \left|\ell\right| \\ t\_m = \left|t\right| \\ t\_s = \mathsf{copysign}\left(1, t\right) \\ t\_s \cdot \begin{array}{l} \mathbf{if}\;t\_m \leq 1.95 \cdot 10^{-137}:\\ \;\;\;\;\frac{\left(\left(t\_m \cdot \sqrt{0.5}\right) \cdot \sqrt{2}\right) \cdot \sqrt{x}}{l\_m}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{2} \cdot \frac{t\_m}{t\_m \cdot \sqrt{\frac{\mathsf{fma}\left(2, x, 2\right)}{x + -1}}}\\ \end{array} \end{array} \]
        l_m = (fabs.f64 l)
        t\_m = (fabs.f64 t)
        t\_s = (copysign.f64 #s(literal 1 binary64) t)
        (FPCore (t_s x l_m t_m)
         :precision binary64
         (*
          t_s
          (if (<= t_m 1.95e-137)
            (/ (* (* (* t_m (sqrt 0.5)) (sqrt 2.0)) (sqrt x)) l_m)
            (* (sqrt 2.0) (/ t_m (* t_m (sqrt (/ (fma 2.0 x 2.0) (+ x -1.0)))))))))
        l_m = fabs(l);
        t\_m = fabs(t);
        t\_s = copysign(1.0, t);
        double code(double t_s, double x, double l_m, double t_m) {
        	double tmp;
        	if (t_m <= 1.95e-137) {
        		tmp = (((t_m * sqrt(0.5)) * sqrt(2.0)) * sqrt(x)) / l_m;
        	} else {
        		tmp = sqrt(2.0) * (t_m / (t_m * sqrt((fma(2.0, x, 2.0) / (x + -1.0)))));
        	}
        	return t_s * tmp;
        }
        
        l_m = abs(l)
        t\_m = abs(t)
        t\_s = copysign(1.0, t)
        function code(t_s, x, l_m, t_m)
        	tmp = 0.0
        	if (t_m <= 1.95e-137)
        		tmp = Float64(Float64(Float64(Float64(t_m * sqrt(0.5)) * sqrt(2.0)) * sqrt(x)) / l_m);
        	else
        		tmp = Float64(sqrt(2.0) * Float64(t_m / Float64(t_m * sqrt(Float64(fma(2.0, x, 2.0) / Float64(x + -1.0))))));
        	end
        	return Float64(t_s * tmp)
        end
        
        l_m = N[Abs[l], $MachinePrecision]
        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$95$m_, t$95$m_] := N[(t$95$s * If[LessEqual[t$95$m, 1.95e-137], N[(N[(N[(N[(t$95$m * N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision] * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision] * N[Sqrt[x], $MachinePrecision]), $MachinePrecision] / l$95$m), $MachinePrecision], N[(N[Sqrt[2.0], $MachinePrecision] * N[(t$95$m / N[(t$95$m * N[Sqrt[N[(N[(2.0 * x + 2.0), $MachinePrecision] / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
        
        \begin{array}{l}
        l_m = \left|\ell\right|
        \\
        t\_m = \left|t\right|
        \\
        t\_s = \mathsf{copysign}\left(1, t\right)
        
        \\
        t\_s \cdot \begin{array}{l}
        \mathbf{if}\;t\_m \leq 1.95 \cdot 10^{-137}:\\
        \;\;\;\;\frac{\left(\left(t\_m \cdot \sqrt{0.5}\right) \cdot \sqrt{2}\right) \cdot \sqrt{x}}{l\_m}\\
        
        \mathbf{else}:\\
        \;\;\;\;\sqrt{2} \cdot \frac{t\_m}{t\_m \cdot \sqrt{\frac{\mathsf{fma}\left(2, x, 2\right)}{x + -1}}}\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if t < 1.95e-137

          1. Initial program 8.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. Add Preprocessing
          3. Taylor expanded in l around 0

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

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

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

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

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

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

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

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

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

              \[\leadsto \frac{\sqrt{2} \cdot t}{\left(t \cdot \sqrt{2}\right) \cdot \sqrt{\frac{1 + x}{\color{blue}{x + -1}}}} \]
          5. Applied rewrites43.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \frac{t \cdot \left(\sqrt{\frac{1}{2}} \cdot \sqrt{2}\right)}{\ell} \cdot \color{blue}{\sqrt{x}} \]
          10. Step-by-step derivation
            1. Applied rewrites58.6%

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

            if 1.95e-137 < t

            1. Initial program 39.0%

              \[\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 l around 0

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

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

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

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

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

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

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

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

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

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

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

                \[\leadsto \color{blue}{\frac{\sqrt{2} \cdot t}{t \cdot \sqrt{2 \cdot \frac{x + 1}{x + -1}}}} \]
              2. Step-by-step derivation
                1. lift-/.f64N/A

                  \[\leadsto \color{blue}{\frac{\sqrt{2} \cdot t}{t \cdot \sqrt{2 \cdot \frac{x + 1}{x + -1}}}} \]
                2. lift-*.f64N/A

                  \[\leadsto \frac{\color{blue}{\sqrt{2} \cdot t}}{t \cdot \sqrt{2 \cdot \frac{x + 1}{x + -1}}} \]
                3. associate-/l*N/A

                  \[\leadsto \color{blue}{\sqrt{2} \cdot \frac{t}{t \cdot \sqrt{2 \cdot \frac{x + 1}{x + -1}}}} \]
                4. *-commutativeN/A

                  \[\leadsto \color{blue}{\frac{t}{t \cdot \sqrt{2 \cdot \frac{x + 1}{x + -1}}} \cdot \sqrt{2}} \]
                5. lower-*.f64N/A

                  \[\leadsto \color{blue}{\frac{t}{t \cdot \sqrt{2 \cdot \frac{x + 1}{x + -1}}} \cdot \sqrt{2}} \]
              3. Applied rewrites85.0%

                \[\leadsto \color{blue}{\frac{t}{t \cdot \sqrt{\frac{\mathsf{fma}\left(2, x, 2\right)}{x + -1}}} \cdot \sqrt{2}} \]
            7. Recombined 2 regimes into one program.
            8. Final simplification79.2%

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

            Reproduce

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