
(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:
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(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}
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}
if t < 2.5500000000000002e-158Initial program 33.0%
Applied rewrites40.1%
if 2.5500000000000002e-158 < t Initial program 40.5%
Applied rewrites44.0%
Applied rewrites40.5%
Applied rewrites46.7%
Applied rewrites51.1%
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}
if t < 1.62000000000000009e-15Initial program 36.3%
Applied rewrites43.9%
Applied rewrites35.9%
Applied rewrites42.9%
Applied rewrites45.4%
if 1.62000000000000009e-15 < t Initial program 36.3%
Applied rewrites36.8%
Applied rewrites36.3%
Applied rewrites40.2%
Applied rewrites45.0%
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}
if t < 1.09999999999999997e-35Initial program 35.9%
Applied rewrites43.6%
if 1.09999999999999997e-35 < t Initial program 37.3%
Applied rewrites38.0%
Applied rewrites37.3%
Applied rewrites42.1%
Applied rewrites46.7%
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}
Initial program 36.3%
Applied rewrites41.8%
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}
if l < 1.6499999999999999e109Initial program 41.7%
Applied rewrites44.2%
Applied rewrites41.3%
Applied rewrites41.4%
if 1.6499999999999999e109 < l Initial program 0.9%
Applied rewrites26.5%
Applied rewrites0.9%
Applied rewrites0.9%
Taylor expanded in x around 0
Simplified26.6%
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}
Initial program 36.3%
Applied rewrites41.8%
Applied rewrites36.0%
Applied rewrites41.5%
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}
Initial program 36.3%
Applied rewrites41.8%
Applied rewrites36.0%
Applied rewrites11.4%
Taylor expanded in x around 0
Simplified7.3%
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)))))