Toniolo and Linder, Equation (7)

Percentage Accurate: 33.6% → 44.4%
Time: 10.0s
Alternatives: 7
Speedup: 1.2×

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)));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, l, t)
use fmin_fmax_functions
    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 7 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.6% 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)));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, l, t)
use fmin_fmax_functions
    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: 44.4% accurate, 0.9× speedup?

\[\begin{array}{l} t\_m = \left|t\right| \\ t\_s = \mathsf{copysign}\left(1, t\right) \\ \begin{array}{l} t_2 := \frac{1 + x}{x - 1}\\ t\_s \cdot \begin{array}{l} \mathbf{if}\;t\_m \leq 2.55 \cdot 10^{-158}:\\ \;\;\;\;t\_m \cdot \frac{\sqrt{2}}{\sqrt{\mathsf{fma}\left(-\ell, \ell, \mathsf{fma}\left(t\_m \cdot t\_m, 2, \ell \cdot \ell\right) \cdot t\_2\right)}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\frac{2}{\mathsf{fma}\left(\frac{x + 1}{x - 1}, 2 \cdot \left(t\_m \cdot t\_m\right), \ell \cdot \mathsf{fma}\left(\ell, t\_2, -\ell\right)\right)}} \cdot t\_m\\ \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 (/ (+ 1.0 x) (- x 1.0))))
   (*
    t_s
    (if (<= t_m 2.55e-158)
      (*
       t_m
       (/
        (sqrt 2.0)
        (sqrt (fma (- l) l (* (fma (* t_m t_m) 2.0 (* l l)) t_2)))))
      (*
       (sqrt
        (/
         2.0
         (fma
          (/ (+ x 1.0) (- x 1.0))
          (* 2.0 (* t_m t_m))
          (* l (fma l t_2 (- l))))))
       t_m)))))
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 = (1.0 + x) / (x - 1.0);
	double tmp;
	if (t_m <= 2.55e-158) {
		tmp = t_m * (sqrt(2.0) / sqrt(fma(-l, l, (fma((t_m * t_m), 2.0, (l * l)) * t_2))));
	} else {
		tmp = sqrt((2.0 / fma(((x + 1.0) / (x - 1.0)), (2.0 * (t_m * t_m)), (l * fma(l, t_2, -l))))) * t_m;
	}
	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(Float64(1.0 + x) / Float64(x - 1.0))
	tmp = 0.0
	if (t_m <= 2.55e-158)
		tmp = Float64(t_m * Float64(sqrt(2.0) / sqrt(fma(Float64(-l), l, Float64(fma(Float64(t_m * t_m), 2.0, Float64(l * l)) * t_2)))));
	else
		tmp = Float64(sqrt(Float64(2.0 / fma(Float64(Float64(x + 1.0) / Float64(x - 1.0)), Float64(2.0 * Float64(t_m * t_m)), Float64(l * fma(l, t_2, Float64(-l)))))) * t_m);
	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[(N[(1.0 + x), $MachinePrecision] / N[(x - 1.0), $MachinePrecision]), $MachinePrecision]}, N[(t$95$s * If[LessEqual[t$95$m, 2.55e-158], N[(t$95$m * N[(N[Sqrt[2.0], $MachinePrecision] / N[Sqrt[N[((-l) * l + N[(N[(N[(t$95$m * t$95$m), $MachinePrecision] * 2.0 + N[(l * l), $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(2.0 / N[(N[(N[(x + 1.0), $MachinePrecision] / N[(x - 1.0), $MachinePrecision]), $MachinePrecision] * N[(2.0 * N[(t$95$m * t$95$m), $MachinePrecision]), $MachinePrecision] + N[(l * N[(l * t$95$2 + (-l)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$m), $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
t\_m = \left|t\right|
\\
t\_s = \mathsf{copysign}\left(1, t\right)

\\
\begin{array}{l}
t_2 := \frac{1 + x}{x - 1}\\
t\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_m \leq 2.55 \cdot 10^{-158}:\\
\;\;\;\;t\_m \cdot \frac{\sqrt{2}}{\sqrt{\mathsf{fma}\left(-\ell, \ell, \mathsf{fma}\left(t\_m \cdot t\_m, 2, \ell \cdot \ell\right) \cdot t\_2\right)}}\\

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


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

    1. Initial program 33.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. Applied rewrites40.1%

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

    if 2.5500000000000002e-158 < t

    1. Initial program 40.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. Add Preprocessing
    3. Applied rewrites44.0%

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

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

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

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

Alternative 2: 43.4% accurate, 0.9× speedup?

\[\begin{array}{l} 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.62 \cdot 10^{-15}:\\ \;\;\;\;\sqrt{\frac{2}{\mathsf{fma}\left(\frac{x + 1}{x - 1}, 2 \cdot \left(t\_m \cdot t\_m\right), \ell \cdot \left(\frac{\left(1 + x\right) \cdot \ell}{x - 1} - \ell\right)\right)}} \cdot t\_m\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\frac{2}{\mathsf{fma}\left(1 + x, \left(t\_m \cdot 2\right) \cdot \frac{t\_m}{x - 1}, \ell \cdot \mathsf{fma}\left(\ell, \frac{1 + x}{x - 1}, -\ell\right)\right)}} \cdot t\_m\\ \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
 (*
  t_s
  (if (<= t_m 1.62e-15)
    (*
     (sqrt
      (/
       2.0
       (fma
        (/ (+ x 1.0) (- x 1.0))
        (* 2.0 (* t_m t_m))
        (* l (- (/ (* (+ 1.0 x) l) (- x 1.0)) l)))))
     t_m)
    (*
     (sqrt
      (/
       2.0
       (fma
        (+ 1.0 x)
        (* (* t_m 2.0) (/ t_m (- x 1.0)))
        (* l (fma l (/ (+ 1.0 x) (- x 1.0)) (- l))))))
     t_m))))
t\_m = fabs(t);
t\_s = copysign(1.0, t);
double code(double t_s, double x, double l, double t_m) {
	double tmp;
	if (t_m <= 1.62e-15) {
		tmp = sqrt((2.0 / fma(((x + 1.0) / (x - 1.0)), (2.0 * (t_m * t_m)), (l * ((((1.0 + x) * l) / (x - 1.0)) - l))))) * t_m;
	} else {
		tmp = sqrt((2.0 / fma((1.0 + x), ((t_m * 2.0) * (t_m / (x - 1.0))), (l * fma(l, ((1.0 + x) / (x - 1.0)), -l))))) * t_m;
	}
	return t_s * tmp;
}
t\_m = abs(t)
t\_s = copysign(1.0, t)
function code(t_s, x, l, t_m)
	tmp = 0.0
	if (t_m <= 1.62e-15)
		tmp = Float64(sqrt(Float64(2.0 / fma(Float64(Float64(x + 1.0) / Float64(x - 1.0)), Float64(2.0 * Float64(t_m * t_m)), Float64(l * Float64(Float64(Float64(Float64(1.0 + x) * l) / Float64(x - 1.0)) - l))))) * t_m);
	else
		tmp = Float64(sqrt(Float64(2.0 / fma(Float64(1.0 + x), Float64(Float64(t_m * 2.0) * Float64(t_m / Float64(x - 1.0))), Float64(l * fma(l, Float64(Float64(1.0 + x) / Float64(x - 1.0)), Float64(-l)))))) * t_m);
	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_] := N[(t$95$s * If[LessEqual[t$95$m, 1.62e-15], N[(N[Sqrt[N[(2.0 / N[(N[(N[(x + 1.0), $MachinePrecision] / N[(x - 1.0), $MachinePrecision]), $MachinePrecision] * N[(2.0 * N[(t$95$m * t$95$m), $MachinePrecision]), $MachinePrecision] + N[(l * N[(N[(N[(N[(1.0 + x), $MachinePrecision] * l), $MachinePrecision] / N[(x - 1.0), $MachinePrecision]), $MachinePrecision] - l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$m), $MachinePrecision], N[(N[Sqrt[N[(2.0 / N[(N[(1.0 + x), $MachinePrecision] * N[(N[(t$95$m * 2.0), $MachinePrecision] * N[(t$95$m / N[(x - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(l * N[(l * N[(N[(1.0 + x), $MachinePrecision] / N[(x - 1.0), $MachinePrecision]), $MachinePrecision] + (-l)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$m), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
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.62 \cdot 10^{-15}:\\
\;\;\;\;\sqrt{\frac{2}{\mathsf{fma}\left(\frac{x + 1}{x - 1}, 2 \cdot \left(t\_m \cdot t\_m\right), \ell \cdot \left(\frac{\left(1 + x\right) \cdot \ell}{x - 1} - \ell\right)\right)}} \cdot t\_m\\

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


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

    1. Initial program 36.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. Applied rewrites43.9%

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

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

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

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

    if 1.62000000000000009e-15 < t

    1. Initial program 36.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. Applied rewrites36.8%

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

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

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

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

Alternative 3: 41.9% accurate, 0.9× speedup?

\[\begin{array}{l} t\_m = \left|t\right| \\ t\_s = \mathsf{copysign}\left(1, t\right) \\ \begin{array}{l} t_2 := \frac{1 + x}{x - 1}\\ t\_s \cdot \begin{array}{l} \mathbf{if}\;t\_m \leq 1.1 \cdot 10^{-35}:\\ \;\;\;\;t\_m \cdot \frac{\sqrt{2}}{\sqrt{\mathsf{fma}\left(-\ell, \ell, \mathsf{fma}\left(t\_m \cdot t\_m, 2, \ell \cdot \ell\right) \cdot t\_2\right)}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\frac{2}{\mathsf{fma}\left(1 + x, \left(t\_m \cdot 2\right) \cdot \frac{t\_m}{x - 1}, \ell \cdot \mathsf{fma}\left(\ell, t\_2, -\ell\right)\right)}} \cdot t\_m\\ \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 (/ (+ 1.0 x) (- x 1.0))))
   (*
    t_s
    (if (<= t_m 1.1e-35)
      (*
       t_m
       (/
        (sqrt 2.0)
        (sqrt (fma (- l) l (* (fma (* t_m t_m) 2.0 (* l l)) t_2)))))
      (*
       (sqrt
        (/
         2.0
         (fma
          (+ 1.0 x)
          (* (* t_m 2.0) (/ t_m (- x 1.0)))
          (* l (fma l t_2 (- l))))))
       t_m)))))
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 = (1.0 + x) / (x - 1.0);
	double tmp;
	if (t_m <= 1.1e-35) {
		tmp = t_m * (sqrt(2.0) / sqrt(fma(-l, l, (fma((t_m * t_m), 2.0, (l * l)) * t_2))));
	} else {
		tmp = sqrt((2.0 / fma((1.0 + x), ((t_m * 2.0) * (t_m / (x - 1.0))), (l * fma(l, t_2, -l))))) * t_m;
	}
	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(Float64(1.0 + x) / Float64(x - 1.0))
	tmp = 0.0
	if (t_m <= 1.1e-35)
		tmp = Float64(t_m * Float64(sqrt(2.0) / sqrt(fma(Float64(-l), l, Float64(fma(Float64(t_m * t_m), 2.0, Float64(l * l)) * t_2)))));
	else
		tmp = Float64(sqrt(Float64(2.0 / fma(Float64(1.0 + x), Float64(Float64(t_m * 2.0) * Float64(t_m / Float64(x - 1.0))), Float64(l * fma(l, t_2, Float64(-l)))))) * t_m);
	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[(N[(1.0 + x), $MachinePrecision] / N[(x - 1.0), $MachinePrecision]), $MachinePrecision]}, N[(t$95$s * If[LessEqual[t$95$m, 1.1e-35], N[(t$95$m * N[(N[Sqrt[2.0], $MachinePrecision] / N[Sqrt[N[((-l) * l + N[(N[(N[(t$95$m * t$95$m), $MachinePrecision] * 2.0 + N[(l * l), $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(2.0 / N[(N[(1.0 + x), $MachinePrecision] * N[(N[(t$95$m * 2.0), $MachinePrecision] * N[(t$95$m / N[(x - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(l * N[(l * t$95$2 + (-l)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$m), $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
t\_m = \left|t\right|
\\
t\_s = \mathsf{copysign}\left(1, t\right)

\\
\begin{array}{l}
t_2 := \frac{1 + x}{x - 1}\\
t\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_m \leq 1.1 \cdot 10^{-35}:\\
\;\;\;\;t\_m \cdot \frac{\sqrt{2}}{\sqrt{\mathsf{fma}\left(-\ell, \ell, \mathsf{fma}\left(t\_m \cdot t\_m, 2, \ell \cdot \ell\right) \cdot t\_2\right)}}\\

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


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

    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. Applied rewrites43.6%

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

    if 1.09999999999999997e-35 < t

    1. Initial program 37.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. Applied rewrites38.0%

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

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

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

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

Alternative 4: 38.4% accurate, 1.0× speedup?

\[\begin{array}{l} t\_m = \left|t\right| \\ t\_s = \mathsf{copysign}\left(1, t\right) \\ t\_s \cdot \left(t\_m \cdot \frac{\sqrt{2}}{\sqrt{\mathsf{fma}\left(-\ell, \ell, \mathsf{fma}\left(t\_m \cdot t\_m, 2, \ell \cdot \ell\right) \cdot \frac{1 + x}{x - 1}\right)}}\right) \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
 (*
  t_s
  (*
   t_m
   (/
    (sqrt 2.0)
    (sqrt
     (fma
      (- l)
      l
      (* (fma (* t_m t_m) 2.0 (* l l)) (/ (+ 1.0 x) (- x 1.0)))))))))
t\_m = fabs(t);
t\_s = copysign(1.0, t);
double code(double t_s, double x, double l, double t_m) {
	return t_s * (t_m * (sqrt(2.0) / sqrt(fma(-l, l, (fma((t_m * t_m), 2.0, (l * l)) * ((1.0 + x) / (x - 1.0)))))));
}
t\_m = abs(t)
t\_s = copysign(1.0, t)
function code(t_s, x, l, t_m)
	return Float64(t_s * Float64(t_m * Float64(sqrt(2.0) / sqrt(fma(Float64(-l), l, Float64(fma(Float64(t_m * t_m), 2.0, Float64(l * l)) * Float64(Float64(1.0 + x) / Float64(x - 1.0))))))))
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_] := N[(t$95$s * N[(t$95$m * N[(N[Sqrt[2.0], $MachinePrecision] / N[Sqrt[N[((-l) * l + N[(N[(N[(t$95$m * t$95$m), $MachinePrecision] * 2.0 + N[(l * l), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 + x), $MachinePrecision] / N[(x - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
t\_m = \left|t\right|
\\
t\_s = \mathsf{copysign}\left(1, t\right)

\\
t\_s \cdot \left(t\_m \cdot \frac{\sqrt{2}}{\sqrt{\mathsf{fma}\left(-\ell, \ell, \mathsf{fma}\left(t\_m \cdot t\_m, 2, \ell \cdot \ell\right) \cdot \frac{1 + x}{x - 1}\right)}}\right)
\end{array}
Derivation
  1. Initial program 36.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. Applied rewrites41.8%

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

Alternative 5: 35.7% accurate, 1.1× 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(2, t\_m \cdot t\_m, \ell \cdot \ell\right)\\ t\_s \cdot \begin{array}{l} \mathbf{if}\;\ell \leq 1.65 \cdot 10^{+109}:\\ \;\;\;\;\sqrt{\frac{2}{\frac{x + 1}{x - 1} \cdot t\_2 - \ell \cdot \ell}} \cdot t\_m\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\frac{2}{\mathsf{fma}\left(\mathsf{fma}\left(x + 1, x, 1\right), -1 \cdot t\_2, \left(-\ell\right) \cdot \ell\right)}} \cdot t\_m\\ \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 2.0 (* t_m t_m) (* l l))))
   (*
    t_s
    (if (<= l 1.65e+109)
      (* (sqrt (/ 2.0 (- (* (/ (+ x 1.0) (- x 1.0)) t_2) (* l l)))) t_m)
      (*
       (sqrt (/ 2.0 (fma (fma (+ x 1.0) x 1.0) (* -1.0 t_2) (* (- l) l))))
       t_m)))))
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(2.0, (t_m * t_m), (l * l));
	double tmp;
	if (l <= 1.65e+109) {
		tmp = sqrt((2.0 / ((((x + 1.0) / (x - 1.0)) * t_2) - (l * l)))) * t_m;
	} else {
		tmp = sqrt((2.0 / fma(fma((x + 1.0), x, 1.0), (-1.0 * t_2), (-l * l)))) * t_m;
	}
	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(2.0, Float64(t_m * t_m), Float64(l * l))
	tmp = 0.0
	if (l <= 1.65e+109)
		tmp = Float64(sqrt(Float64(2.0 / Float64(Float64(Float64(Float64(x + 1.0) / Float64(x - 1.0)) * t_2) - Float64(l * l)))) * t_m);
	else
		tmp = Float64(sqrt(Float64(2.0 / fma(fma(Float64(x + 1.0), x, 1.0), Float64(-1.0 * t_2), Float64(Float64(-l) * l)))) * t_m);
	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[(t$95$m * t$95$m), $MachinePrecision] + N[(l * l), $MachinePrecision]), $MachinePrecision]}, N[(t$95$s * If[LessEqual[l, 1.65e+109], N[(N[Sqrt[N[(2.0 / N[(N[(N[(N[(x + 1.0), $MachinePrecision] / N[(x - 1.0), $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision] - N[(l * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$m), $MachinePrecision], N[(N[Sqrt[N[(2.0 / N[(N[(N[(x + 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision] * N[(-1.0 * t$95$2), $MachinePrecision] + N[((-l) * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$m), $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(2, t\_m \cdot t\_m, \ell \cdot \ell\right)\\
t\_s \cdot \begin{array}{l}
\mathbf{if}\;\ell \leq 1.65 \cdot 10^{+109}:\\
\;\;\;\;\sqrt{\frac{2}{\frac{x + 1}{x - 1} \cdot t\_2 - \ell \cdot \ell}} \cdot t\_m\\

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


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < 1.6499999999999999e109

    1. Initial program 41.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. Applied rewrites44.2%

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

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

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

    if 1.6499999999999999e109 < l

    1. Initial program 0.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. Applied rewrites26.5%

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

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

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

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

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

Alternative 6: 38.1% accurate, 1.2× speedup?

\[\begin{array}{l} t\_m = \left|t\right| \\ t\_s = \mathsf{copysign}\left(1, t\right) \\ t\_s \cdot \left(\sqrt{\frac{2}{\mathsf{fma}\left(-\ell, \ell, \frac{x + 1}{x - 1} \cdot \mathsf{fma}\left(2, t\_m \cdot t\_m, \ell \cdot \ell\right)\right)}} \cdot t\_m\right) \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
 (*
  t_s
  (*
   (sqrt
    (/
     2.0
     (fma (- l) l (* (/ (+ x 1.0) (- x 1.0)) (fma 2.0 (* t_m t_m) (* l l))))))
   t_m)))
t\_m = fabs(t);
t\_s = copysign(1.0, t);
double code(double t_s, double x, double l, double t_m) {
	return t_s * (sqrt((2.0 / fma(-l, l, (((x + 1.0) / (x - 1.0)) * fma(2.0, (t_m * t_m), (l * l)))))) * t_m);
}
t\_m = abs(t)
t\_s = copysign(1.0, t)
function code(t_s, x, l, t_m)
	return Float64(t_s * Float64(sqrt(Float64(2.0 / fma(Float64(-l), l, Float64(Float64(Float64(x + 1.0) / Float64(x - 1.0)) * fma(2.0, Float64(t_m * t_m), Float64(l * l)))))) * t_m))
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_] := N[(t$95$s * N[(N[Sqrt[N[(2.0 / N[((-l) * l + N[(N[(N[(x + 1.0), $MachinePrecision] / N[(x - 1.0), $MachinePrecision]), $MachinePrecision] * N[(2.0 * N[(t$95$m * t$95$m), $MachinePrecision] + N[(l * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$m), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
t\_m = \left|t\right|
\\
t\_s = \mathsf{copysign}\left(1, t\right)

\\
t\_s \cdot \left(\sqrt{\frac{2}{\mathsf{fma}\left(-\ell, \ell, \frac{x + 1}{x - 1} \cdot \mathsf{fma}\left(2, t\_m \cdot t\_m, \ell \cdot \ell\right)\right)}} \cdot t\_m\right)
\end{array}
Derivation
  1. Initial program 36.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. Applied rewrites41.8%

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

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

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

Alternative 7: 6.7% accurate, 1.2× speedup?

\[\begin{array}{l} t\_m = \left|t\right| \\ t\_s = \mathsf{copysign}\left(1, t\right) \\ t\_s \cdot \left(\sqrt{\frac{2}{\mathsf{fma}\left(\mathsf{fma}\left(x + 1, x, 1\right), -1 \cdot \mathsf{fma}\left(2, t\_m \cdot t\_m, \ell \cdot \ell\right), \left(-\ell\right) \cdot \ell\right)}} \cdot t\_m\right) \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
 (*
  t_s
  (*
   (sqrt
    (/
     2.0
     (fma
      (fma (+ x 1.0) x 1.0)
      (* -1.0 (fma 2.0 (* t_m t_m) (* l l)))
      (* (- l) l))))
   t_m)))
t\_m = fabs(t);
t\_s = copysign(1.0, t);
double code(double t_s, double x, double l, double t_m) {
	return t_s * (sqrt((2.0 / fma(fma((x + 1.0), x, 1.0), (-1.0 * fma(2.0, (t_m * t_m), (l * l))), (-l * l)))) * t_m);
}
t\_m = abs(t)
t\_s = copysign(1.0, t)
function code(t_s, x, l, t_m)
	return Float64(t_s * Float64(sqrt(Float64(2.0 / fma(fma(Float64(x + 1.0), x, 1.0), Float64(-1.0 * fma(2.0, Float64(t_m * t_m), Float64(l * l))), Float64(Float64(-l) * l)))) * t_m))
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_] := N[(t$95$s * N[(N[Sqrt[N[(2.0 / N[(N[(N[(x + 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision] * N[(-1.0 * N[(2.0 * N[(t$95$m * t$95$m), $MachinePrecision] + N[(l * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[((-l) * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$m), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
t\_m = \left|t\right|
\\
t\_s = \mathsf{copysign}\left(1, t\right)

\\
t\_s \cdot \left(\sqrt{\frac{2}{\mathsf{fma}\left(\mathsf{fma}\left(x + 1, x, 1\right), -1 \cdot \mathsf{fma}\left(2, t\_m \cdot t\_m, \ell \cdot \ell\right), \left(-\ell\right) \cdot \ell\right)}} \cdot t\_m\right)
\end{array}
Derivation
  1. Initial program 36.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. Applied rewrites41.8%

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

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

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

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

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

Reproduce

?
herbie shell --seed 2025017 -o generate:proofs
(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)))))