
(FPCore (x) :precision binary64 (log (/ (sinh x) x)))
double code(double x) {
return log((sinh(x) / x));
}
real(8) function code(x)
real(8), intent (in) :: x
code = log((sinh(x) / x))
end function
public static double code(double x) {
return Math.log((Math.sinh(x) / x));
}
def code(x): return math.log((math.sinh(x) / x))
function code(x) return log(Float64(sinh(x) / x)) end
function tmp = code(x) tmp = log((sinh(x) / x)); end
code[x_] := N[Log[N[(N[Sinh[x], $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\log \left(\frac{\sinh x}{x}\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (log (/ (sinh x) x)))
double code(double x) {
return log((sinh(x) / x));
}
real(8) function code(x)
real(8), intent (in) :: x
code = log((sinh(x) / x))
end function
public static double code(double x) {
return Math.log((Math.sinh(x) / x));
}
def code(x): return math.log((math.sinh(x) / x))
function code(x) return log(Float64(sinh(x) / x)) end
function tmp = code(x) tmp = log((sinh(x) / x)); end
code[x_] := N[Log[N[(N[Sinh[x], $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\log \left(\frac{\sinh x}{x}\right)
\end{array}
(FPCore (x)
:precision binary64
(let* ((t_0 (/ (sinh x) x)))
(if (<= t_0 1.001)
(fma 0.16666666666666666 (* x x) (* -0.005555555555555556 (pow x 4.0)))
(if (<= t_0 1e+245)
(log t_0)
(*
2.0
(log
(fma
0.0006944444444444445
(pow x 4.0)
(+ 1.0 (* (* x x) 0.08333333333333333)))))))))
double code(double x) {
double t_0 = sinh(x) / x;
double tmp;
if (t_0 <= 1.001) {
tmp = fma(0.16666666666666666, (x * x), (-0.005555555555555556 * pow(x, 4.0)));
} else if (t_0 <= 1e+245) {
tmp = log(t_0);
} else {
tmp = 2.0 * log(fma(0.0006944444444444445, pow(x, 4.0), (1.0 + ((x * x) * 0.08333333333333333))));
}
return tmp;
}
function code(x) t_0 = Float64(sinh(x) / x) tmp = 0.0 if (t_0 <= 1.001) tmp = fma(0.16666666666666666, Float64(x * x), Float64(-0.005555555555555556 * (x ^ 4.0))); elseif (t_0 <= 1e+245) tmp = log(t_0); else tmp = Float64(2.0 * log(fma(0.0006944444444444445, (x ^ 4.0), Float64(1.0 + Float64(Float64(x * x) * 0.08333333333333333))))); end return tmp end
code[x_] := Block[{t$95$0 = N[(N[Sinh[x], $MachinePrecision] / x), $MachinePrecision]}, If[LessEqual[t$95$0, 1.001], N[(0.16666666666666666 * N[(x * x), $MachinePrecision] + N[(-0.005555555555555556 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1e+245], N[Log[t$95$0], $MachinePrecision], N[(2.0 * N[Log[N[(0.0006944444444444445 * N[Power[x, 4.0], $MachinePrecision] + N[(1.0 + N[(N[(x * x), $MachinePrecision] * 0.08333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sinh x}{x}\\
\mathbf{if}\;t_0 \leq 1.001:\\
\;\;\;\;\mathsf{fma}\left(0.16666666666666666, x \cdot x, -0.005555555555555556 \cdot {x}^{4}\right)\\
\mathbf{elif}\;t_0 \leq 10^{+245}:\\
\;\;\;\;\log t_0\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \log \left(\mathsf{fma}\left(0.0006944444444444445, {x}^{4}, 1 + \left(x \cdot x\right) \cdot 0.08333333333333333\right)\right)\\
\end{array}
\end{array}
if (/.f64 (sinh.f64 x) x) < 1.0009999999999999Initial program 58.2%
Taylor expanded in x around 0 99.8%
fma-def99.8%
unpow299.8%
Simplified99.8%
if 1.0009999999999999 < (/.f64 (sinh.f64 x) x) < 1.00000000000000004e245Initial program 95.9%
if 1.00000000000000004e245 < (/.f64 (sinh.f64 x) x) Initial program 3.2%
add-cbrt-cube3.2%
pow1/33.2%
pow33.2%
Applied egg-rr3.2%
unpow1/33.2%
rem-cbrt-cube3.2%
add-sqr-sqrt3.2%
log-prod3.2%
Applied egg-rr3.2%
count-23.2%
Simplified3.2%
Taylor expanded in x around 0 13.5%
fma-def13.5%
*-commutative13.5%
unpow213.5%
Simplified13.5%
Final simplification96.3%
(FPCore (x)
:precision binary64
(let* ((t_0 (/ (sinh x) x)))
(if (<= t_0 1.001)
(fma 0.16666666666666666 (* x x) (* -0.005555555555555556 (pow x 4.0)))
(if (<= t_0 1e+245)
(log t_0)
(+ (log (* (pow x 6.0) 0.0001984126984126984)) (/ 42.0 (* x x)))))))
double code(double x) {
double t_0 = sinh(x) / x;
double tmp;
if (t_0 <= 1.001) {
tmp = fma(0.16666666666666666, (x * x), (-0.005555555555555556 * pow(x, 4.0)));
} else if (t_0 <= 1e+245) {
tmp = log(t_0);
} else {
tmp = log((pow(x, 6.0) * 0.0001984126984126984)) + (42.0 / (x * x));
}
return tmp;
}
function code(x) t_0 = Float64(sinh(x) / x) tmp = 0.0 if (t_0 <= 1.001) tmp = fma(0.16666666666666666, Float64(x * x), Float64(-0.005555555555555556 * (x ^ 4.0))); elseif (t_0 <= 1e+245) tmp = log(t_0); else tmp = Float64(log(Float64((x ^ 6.0) * 0.0001984126984126984)) + Float64(42.0 / Float64(x * x))); end return tmp end
code[x_] := Block[{t$95$0 = N[(N[Sinh[x], $MachinePrecision] / x), $MachinePrecision]}, If[LessEqual[t$95$0, 1.001], N[(0.16666666666666666 * N[(x * x), $MachinePrecision] + N[(-0.005555555555555556 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1e+245], N[Log[t$95$0], $MachinePrecision], N[(N[Log[N[(N[Power[x, 6.0], $MachinePrecision] * 0.0001984126984126984), $MachinePrecision]], $MachinePrecision] + N[(42.0 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sinh x}{x}\\
\mathbf{if}\;t_0 \leq 1.001:\\
\;\;\;\;\mathsf{fma}\left(0.16666666666666666, x \cdot x, -0.005555555555555556 \cdot {x}^{4}\right)\\
\mathbf{elif}\;t_0 \leq 10^{+245}:\\
\;\;\;\;\log t_0\\
\mathbf{else}:\\
\;\;\;\;\log \left({x}^{6} \cdot 0.0001984126984126984\right) + \frac{42}{x \cdot x}\\
\end{array}
\end{array}
if (/.f64 (sinh.f64 x) x) < 1.0009999999999999Initial program 58.2%
Taylor expanded in x around 0 99.8%
fma-def99.8%
unpow299.8%
Simplified99.8%
if 1.0009999999999999 < (/.f64 (sinh.f64 x) x) < 1.00000000000000004e245Initial program 95.9%
if 1.00000000000000004e245 < (/.f64 (sinh.f64 x) x) Initial program 3.2%
Taylor expanded in x around 0 13.4%
Taylor expanded in x around inf 6.8%
associate-+r+6.8%
log-rec6.8%
distribute-rgt-neg-out6.8%
distribute-lft-neg-in6.8%
metadata-eval6.8%
log-pow13.4%
log-prod13.4%
associate-*r/13.4%
metadata-eval13.4%
unpow213.4%
Simplified13.4%
Final simplification96.3%
(FPCore (x)
:precision binary64
(let* ((t_0 (/ (sinh x) x)))
(if (<= t_0 1.001)
(+ (* -0.005555555555555556 (pow x 4.0)) (* x (* 0.16666666666666666 x)))
(if (<= t_0 1e+245)
(log t_0)
(log (* (pow x 4.0) 0.008333333333333333))))))
double code(double x) {
double t_0 = sinh(x) / x;
double tmp;
if (t_0 <= 1.001) {
tmp = (-0.005555555555555556 * pow(x, 4.0)) + (x * (0.16666666666666666 * x));
} else if (t_0 <= 1e+245) {
tmp = log(t_0);
} else {
tmp = log((pow(x, 4.0) * 0.008333333333333333));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = sinh(x) / x
if (t_0 <= 1.001d0) then
tmp = ((-0.005555555555555556d0) * (x ** 4.0d0)) + (x * (0.16666666666666666d0 * x))
else if (t_0 <= 1d+245) then
tmp = log(t_0)
else
tmp = log(((x ** 4.0d0) * 0.008333333333333333d0))
end if
code = tmp
end function
public static double code(double x) {
double t_0 = Math.sinh(x) / x;
double tmp;
if (t_0 <= 1.001) {
tmp = (-0.005555555555555556 * Math.pow(x, 4.0)) + (x * (0.16666666666666666 * x));
} else if (t_0 <= 1e+245) {
tmp = Math.log(t_0);
} else {
tmp = Math.log((Math.pow(x, 4.0) * 0.008333333333333333));
}
return tmp;
}
def code(x): t_0 = math.sinh(x) / x tmp = 0 if t_0 <= 1.001: tmp = (-0.005555555555555556 * math.pow(x, 4.0)) + (x * (0.16666666666666666 * x)) elif t_0 <= 1e+245: tmp = math.log(t_0) else: tmp = math.log((math.pow(x, 4.0) * 0.008333333333333333)) return tmp
function code(x) t_0 = Float64(sinh(x) / x) tmp = 0.0 if (t_0 <= 1.001) tmp = Float64(Float64(-0.005555555555555556 * (x ^ 4.0)) + Float64(x * Float64(0.16666666666666666 * x))); elseif (t_0 <= 1e+245) tmp = log(t_0); else tmp = log(Float64((x ^ 4.0) * 0.008333333333333333)); end return tmp end
function tmp_2 = code(x) t_0 = sinh(x) / x; tmp = 0.0; if (t_0 <= 1.001) tmp = (-0.005555555555555556 * (x ^ 4.0)) + (x * (0.16666666666666666 * x)); elseif (t_0 <= 1e+245) tmp = log(t_0); else tmp = log(((x ^ 4.0) * 0.008333333333333333)); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(N[Sinh[x], $MachinePrecision] / x), $MachinePrecision]}, If[LessEqual[t$95$0, 1.001], N[(N[(-0.005555555555555556 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] + N[(x * N[(0.16666666666666666 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1e+245], N[Log[t$95$0], $MachinePrecision], N[Log[N[(N[Power[x, 4.0], $MachinePrecision] * 0.008333333333333333), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sinh x}{x}\\
\mathbf{if}\;t_0 \leq 1.001:\\
\;\;\;\;-0.005555555555555556 \cdot {x}^{4} + x \cdot \left(0.16666666666666666 \cdot x\right)\\
\mathbf{elif}\;t_0 \leq 10^{+245}:\\
\;\;\;\;\log t_0\\
\mathbf{else}:\\
\;\;\;\;\log \left({x}^{4} \cdot 0.008333333333333333\right)\\
\end{array}
\end{array}
if (/.f64 (sinh.f64 x) x) < 1.0009999999999999Initial program 58.2%
Taylor expanded in x around 0 58.2%
associate-+r+58.2%
fma-def58.2%
unpow258.2%
*-commutative58.2%
Simplified58.2%
Taylor expanded in x around 0 99.8%
fma-def99.8%
unpow299.8%
*-commutative99.8%
Simplified99.8%
fma-udef99.8%
+-commutative99.8%
*-commutative99.8%
associate-*l*99.7%
Applied egg-rr99.7%
if 1.0009999999999999 < (/.f64 (sinh.f64 x) x) < 1.00000000000000004e245Initial program 95.9%
if 1.00000000000000004e245 < (/.f64 (sinh.f64 x) x) Initial program 3.2%
Taylor expanded in x around 0 13.3%
associate-+r+13.3%
fma-def13.3%
unpow213.3%
*-commutative13.3%
Simplified13.3%
Taylor expanded in x around inf 6.7%
log-rec6.7%
neg-mul-16.7%
associate-*r*6.7%
metadata-eval6.7%
log-pow13.3%
log-prod13.3%
Simplified13.3%
Final simplification96.2%
(FPCore (x)
:precision binary64
(let* ((t_0 (/ (sinh x) x)))
(if (<= t_0 1.001)
(+ (* -0.005555555555555556 (pow x 4.0)) (* x (* 0.16666666666666666 x)))
(if (<= t_0 1e+245)
(log t_0)
(log (* (pow x 6.0) 0.0001984126984126984))))))
double code(double x) {
double t_0 = sinh(x) / x;
double tmp;
if (t_0 <= 1.001) {
tmp = (-0.005555555555555556 * pow(x, 4.0)) + (x * (0.16666666666666666 * x));
} else if (t_0 <= 1e+245) {
tmp = log(t_0);
} else {
tmp = log((pow(x, 6.0) * 0.0001984126984126984));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = sinh(x) / x
if (t_0 <= 1.001d0) then
tmp = ((-0.005555555555555556d0) * (x ** 4.0d0)) + (x * (0.16666666666666666d0 * x))
else if (t_0 <= 1d+245) then
tmp = log(t_0)
else
tmp = log(((x ** 6.0d0) * 0.0001984126984126984d0))
end if
code = tmp
end function
public static double code(double x) {
double t_0 = Math.sinh(x) / x;
double tmp;
if (t_0 <= 1.001) {
tmp = (-0.005555555555555556 * Math.pow(x, 4.0)) + (x * (0.16666666666666666 * x));
} else if (t_0 <= 1e+245) {
tmp = Math.log(t_0);
} else {
tmp = Math.log((Math.pow(x, 6.0) * 0.0001984126984126984));
}
return tmp;
}
def code(x): t_0 = math.sinh(x) / x tmp = 0 if t_0 <= 1.001: tmp = (-0.005555555555555556 * math.pow(x, 4.0)) + (x * (0.16666666666666666 * x)) elif t_0 <= 1e+245: tmp = math.log(t_0) else: tmp = math.log((math.pow(x, 6.0) * 0.0001984126984126984)) return tmp
function code(x) t_0 = Float64(sinh(x) / x) tmp = 0.0 if (t_0 <= 1.001) tmp = Float64(Float64(-0.005555555555555556 * (x ^ 4.0)) + Float64(x * Float64(0.16666666666666666 * x))); elseif (t_0 <= 1e+245) tmp = log(t_0); else tmp = log(Float64((x ^ 6.0) * 0.0001984126984126984)); end return tmp end
function tmp_2 = code(x) t_0 = sinh(x) / x; tmp = 0.0; if (t_0 <= 1.001) tmp = (-0.005555555555555556 * (x ^ 4.0)) + (x * (0.16666666666666666 * x)); elseif (t_0 <= 1e+245) tmp = log(t_0); else tmp = log(((x ^ 6.0) * 0.0001984126984126984)); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(N[Sinh[x], $MachinePrecision] / x), $MachinePrecision]}, If[LessEqual[t$95$0, 1.001], N[(N[(-0.005555555555555556 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] + N[(x * N[(0.16666666666666666 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1e+245], N[Log[t$95$0], $MachinePrecision], N[Log[N[(N[Power[x, 6.0], $MachinePrecision] * 0.0001984126984126984), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sinh x}{x}\\
\mathbf{if}\;t_0 \leq 1.001:\\
\;\;\;\;-0.005555555555555556 \cdot {x}^{4} + x \cdot \left(0.16666666666666666 \cdot x\right)\\
\mathbf{elif}\;t_0 \leq 10^{+245}:\\
\;\;\;\;\log t_0\\
\mathbf{else}:\\
\;\;\;\;\log \left({x}^{6} \cdot 0.0001984126984126984\right)\\
\end{array}
\end{array}
if (/.f64 (sinh.f64 x) x) < 1.0009999999999999Initial program 58.2%
Taylor expanded in x around 0 58.2%
associate-+r+58.2%
fma-def58.2%
unpow258.2%
*-commutative58.2%
Simplified58.2%
Taylor expanded in x around 0 99.8%
fma-def99.8%
unpow299.8%
*-commutative99.8%
Simplified99.8%
fma-udef99.8%
+-commutative99.8%
*-commutative99.8%
associate-*l*99.7%
Applied egg-rr99.7%
if 1.0009999999999999 < (/.f64 (sinh.f64 x) x) < 1.00000000000000004e245Initial program 95.9%
if 1.00000000000000004e245 < (/.f64 (sinh.f64 x) x) Initial program 3.2%
Taylor expanded in x around 0 13.4%
Taylor expanded in x around inf 6.8%
log-rec6.8%
distribute-rgt-neg-out6.8%
distribute-lft-neg-in6.8%
metadata-eval6.8%
log-pow13.4%
log-prod13.4%
Simplified13.4%
Final simplification96.2%
(FPCore (x)
:precision binary64
(let* ((t_0 (/ (sinh x) x)))
(if (<= t_0 1.001)
(fma 0.16666666666666666 (* x x) (* -0.005555555555555556 (pow x 4.0)))
(if (<= t_0 1e+245)
(log t_0)
(log (* (pow x 6.0) 0.0001984126984126984))))))
double code(double x) {
double t_0 = sinh(x) / x;
double tmp;
if (t_0 <= 1.001) {
tmp = fma(0.16666666666666666, (x * x), (-0.005555555555555556 * pow(x, 4.0)));
} else if (t_0 <= 1e+245) {
tmp = log(t_0);
} else {
tmp = log((pow(x, 6.0) * 0.0001984126984126984));
}
return tmp;
}
function code(x) t_0 = Float64(sinh(x) / x) tmp = 0.0 if (t_0 <= 1.001) tmp = fma(0.16666666666666666, Float64(x * x), Float64(-0.005555555555555556 * (x ^ 4.0))); elseif (t_0 <= 1e+245) tmp = log(t_0); else tmp = log(Float64((x ^ 6.0) * 0.0001984126984126984)); end return tmp end
code[x_] := Block[{t$95$0 = N[(N[Sinh[x], $MachinePrecision] / x), $MachinePrecision]}, If[LessEqual[t$95$0, 1.001], N[(0.16666666666666666 * N[(x * x), $MachinePrecision] + N[(-0.005555555555555556 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1e+245], N[Log[t$95$0], $MachinePrecision], N[Log[N[(N[Power[x, 6.0], $MachinePrecision] * 0.0001984126984126984), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sinh x}{x}\\
\mathbf{if}\;t_0 \leq 1.001:\\
\;\;\;\;\mathsf{fma}\left(0.16666666666666666, x \cdot x, -0.005555555555555556 \cdot {x}^{4}\right)\\
\mathbf{elif}\;t_0 \leq 10^{+245}:\\
\;\;\;\;\log t_0\\
\mathbf{else}:\\
\;\;\;\;\log \left({x}^{6} \cdot 0.0001984126984126984\right)\\
\end{array}
\end{array}
if (/.f64 (sinh.f64 x) x) < 1.0009999999999999Initial program 58.2%
Taylor expanded in x around 0 99.8%
fma-def99.8%
unpow299.8%
Simplified99.8%
if 1.0009999999999999 < (/.f64 (sinh.f64 x) x) < 1.00000000000000004e245Initial program 95.9%
if 1.00000000000000004e245 < (/.f64 (sinh.f64 x) x) Initial program 3.2%
Taylor expanded in x around 0 13.4%
Taylor expanded in x around inf 6.8%
log-rec6.8%
distribute-rgt-neg-out6.8%
distribute-lft-neg-in6.8%
metadata-eval6.8%
log-pow13.4%
log-prod13.4%
Simplified13.4%
Final simplification96.3%
(FPCore (x)
:precision binary64
(let* ((t_0 (/ (sinh x) x)))
(if (<= t_0 1.001)
(+ (* -0.005555555555555556 (pow x 4.0)) (* x (* 0.16666666666666666 x)))
(if (<= t_0 1e+245)
(log t_0)
(* 2.0 (log1p (* x (* x 0.08333333333333333))))))))
double code(double x) {
double t_0 = sinh(x) / x;
double tmp;
if (t_0 <= 1.001) {
tmp = (-0.005555555555555556 * pow(x, 4.0)) + (x * (0.16666666666666666 * x));
} else if (t_0 <= 1e+245) {
tmp = log(t_0);
} else {
tmp = 2.0 * log1p((x * (x * 0.08333333333333333)));
}
return tmp;
}
public static double code(double x) {
double t_0 = Math.sinh(x) / x;
double tmp;
if (t_0 <= 1.001) {
tmp = (-0.005555555555555556 * Math.pow(x, 4.0)) + (x * (0.16666666666666666 * x));
} else if (t_0 <= 1e+245) {
tmp = Math.log(t_0);
} else {
tmp = 2.0 * Math.log1p((x * (x * 0.08333333333333333)));
}
return tmp;
}
def code(x): t_0 = math.sinh(x) / x tmp = 0 if t_0 <= 1.001: tmp = (-0.005555555555555556 * math.pow(x, 4.0)) + (x * (0.16666666666666666 * x)) elif t_0 <= 1e+245: tmp = math.log(t_0) else: tmp = 2.0 * math.log1p((x * (x * 0.08333333333333333))) return tmp
function code(x) t_0 = Float64(sinh(x) / x) tmp = 0.0 if (t_0 <= 1.001) tmp = Float64(Float64(-0.005555555555555556 * (x ^ 4.0)) + Float64(x * Float64(0.16666666666666666 * x))); elseif (t_0 <= 1e+245) tmp = log(t_0); else tmp = Float64(2.0 * log1p(Float64(x * Float64(x * 0.08333333333333333)))); end return tmp end
code[x_] := Block[{t$95$0 = N[(N[Sinh[x], $MachinePrecision] / x), $MachinePrecision]}, If[LessEqual[t$95$0, 1.001], N[(N[(-0.005555555555555556 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] + N[(x * N[(0.16666666666666666 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1e+245], N[Log[t$95$0], $MachinePrecision], N[(2.0 * N[Log[1 + N[(x * N[(x * 0.08333333333333333), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sinh x}{x}\\
\mathbf{if}\;t_0 \leq 1.001:\\
\;\;\;\;-0.005555555555555556 \cdot {x}^{4} + x \cdot \left(0.16666666666666666 \cdot x\right)\\
\mathbf{elif}\;t_0 \leq 10^{+245}:\\
\;\;\;\;\log t_0\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \mathsf{log1p}\left(x \cdot \left(x \cdot 0.08333333333333333\right)\right)\\
\end{array}
\end{array}
if (/.f64 (sinh.f64 x) x) < 1.0009999999999999Initial program 58.2%
Taylor expanded in x around 0 58.2%
associate-+r+58.2%
fma-def58.2%
unpow258.2%
*-commutative58.2%
Simplified58.2%
Taylor expanded in x around 0 99.8%
fma-def99.8%
unpow299.8%
*-commutative99.8%
Simplified99.8%
fma-udef99.8%
+-commutative99.8%
*-commutative99.8%
associate-*l*99.7%
Applied egg-rr99.7%
if 1.0009999999999999 < (/.f64 (sinh.f64 x) x) < 1.00000000000000004e245Initial program 95.9%
if 1.00000000000000004e245 < (/.f64 (sinh.f64 x) x) Initial program 3.2%
add-cbrt-cube3.2%
pow1/33.2%
pow33.2%
Applied egg-rr3.2%
unpow1/33.2%
rem-cbrt-cube3.2%
add-sqr-sqrt3.2%
log-prod3.2%
Applied egg-rr3.2%
count-23.2%
Simplified3.2%
Taylor expanded in x around 0 13.3%
*-commutative13.3%
unpow213.3%
Simplified13.3%
log1p-def13.3%
associate-*r*13.3%
Applied egg-rr13.3%
Final simplification96.2%
(FPCore (x)
:precision binary64
(+
(* 0.16666666666666666 (* x x))
(+
(* -0.005555555555555556 (pow x 4.0))
(+
(* -2.6455026455026456e-5 (pow x 8.0))
(* 0.0003527336860670194 (pow x 6.0))))))
double code(double x) {
return (0.16666666666666666 * (x * x)) + ((-0.005555555555555556 * pow(x, 4.0)) + ((-2.6455026455026456e-5 * pow(x, 8.0)) + (0.0003527336860670194 * pow(x, 6.0))));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (0.16666666666666666d0 * (x * x)) + (((-0.005555555555555556d0) * (x ** 4.0d0)) + (((-2.6455026455026456d-5) * (x ** 8.0d0)) + (0.0003527336860670194d0 * (x ** 6.0d0))))
end function
public static double code(double x) {
return (0.16666666666666666 * (x * x)) + ((-0.005555555555555556 * Math.pow(x, 4.0)) + ((-2.6455026455026456e-5 * Math.pow(x, 8.0)) + (0.0003527336860670194 * Math.pow(x, 6.0))));
}
def code(x): return (0.16666666666666666 * (x * x)) + ((-0.005555555555555556 * math.pow(x, 4.0)) + ((-2.6455026455026456e-5 * math.pow(x, 8.0)) + (0.0003527336860670194 * math.pow(x, 6.0))))
function code(x) return Float64(Float64(0.16666666666666666 * Float64(x * x)) + Float64(Float64(-0.005555555555555556 * (x ^ 4.0)) + Float64(Float64(-2.6455026455026456e-5 * (x ^ 8.0)) + Float64(0.0003527336860670194 * (x ^ 6.0))))) end
function tmp = code(x) tmp = (0.16666666666666666 * (x * x)) + ((-0.005555555555555556 * (x ^ 4.0)) + ((-2.6455026455026456e-5 * (x ^ 8.0)) + (0.0003527336860670194 * (x ^ 6.0)))); end
code[x_] := N[(N[(0.16666666666666666 * N[(x * x), $MachinePrecision]), $MachinePrecision] + N[(N[(-0.005555555555555556 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] + N[(N[(-2.6455026455026456e-5 * N[Power[x, 8.0], $MachinePrecision]), $MachinePrecision] + N[(0.0003527336860670194 * N[Power[x, 6.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.16666666666666666 \cdot \left(x \cdot x\right) + \left(-0.005555555555555556 \cdot {x}^{4} + \left(-2.6455026455026456 \cdot 10^{-5} \cdot {x}^{8} + 0.0003527336860670194 \cdot {x}^{6}\right)\right)
\end{array}
Initial program 56.9%
Taylor expanded in x around 0 94.4%
expm1-log1p-u94.4%
pow294.4%
log1p-udef55.2%
+-commutative55.2%
fma-udef55.2%
expm1-udef55.2%
add-exp-log55.2%
Applied egg-rr55.2%
unpow255.2%
fma-def55.2%
associate--l+94.4%
unpow294.4%
metadata-eval94.4%
Simplified94.4%
Final simplification94.4%
(FPCore (x) :precision binary64 (* 2.0 (log1p (* x (* x 0.08333333333333333)))))
double code(double x) {
return 2.0 * log1p((x * (x * 0.08333333333333333)));
}
public static double code(double x) {
return 2.0 * Math.log1p((x * (x * 0.08333333333333333)));
}
def code(x): return 2.0 * math.log1p((x * (x * 0.08333333333333333)))
function code(x) return Float64(2.0 * log1p(Float64(x * Float64(x * 0.08333333333333333)))) end
code[x_] := N[(2.0 * N[Log[1 + N[(x * N[(x * 0.08333333333333333), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
2 \cdot \mathsf{log1p}\left(x \cdot \left(x \cdot 0.08333333333333333\right)\right)
\end{array}
Initial program 56.9%
add-cbrt-cube56.9%
pow1/356.9%
pow356.9%
Applied egg-rr56.9%
unpow1/356.9%
rem-cbrt-cube56.9%
add-sqr-sqrt56.9%
log-prod56.9%
Applied egg-rr56.9%
count-256.9%
Simplified56.9%
Taylor expanded in x around 0 55.6%
*-commutative55.6%
unpow255.6%
Simplified55.6%
log1p-def94.4%
associate-*r*94.4%
Applied egg-rr94.4%
Final simplification94.4%
(FPCore (x) :precision binary64 (* 0.16666666666666666 (* x x)))
double code(double x) {
return 0.16666666666666666 * (x * x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = 0.16666666666666666d0 * (x * x)
end function
public static double code(double x) {
return 0.16666666666666666 * (x * x);
}
def code(x): return 0.16666666666666666 * (x * x)
function code(x) return Float64(0.16666666666666666 * Float64(x * x)) end
function tmp = code(x) tmp = 0.16666666666666666 * (x * x); end
code[x_] := N[(0.16666666666666666 * N[(x * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.16666666666666666 \cdot \left(x \cdot x\right)
\end{array}
Initial program 56.9%
Taylor expanded in x around 0 94.3%
unpow294.3%
Simplified94.3%
Final simplification94.3%
(FPCore (x)
:precision binary64
(if (< (fabs x) 0.085)
(*
(* x x)
(fma
(fma
(fma -2.6455026455026456e-5 (* x x) 0.0003527336860670194)
(* x x)
-0.005555555555555556)
(* x x)
0.16666666666666666))
(log (/ (sinh x) x))))
double code(double x) {
double tmp;
if (fabs(x) < 0.085) {
tmp = (x * x) * fma(fma(fma(-2.6455026455026456e-5, (x * x), 0.0003527336860670194), (x * x), -0.005555555555555556), (x * x), 0.16666666666666666);
} else {
tmp = log((sinh(x) / x));
}
return tmp;
}
function code(x) tmp = 0.0 if (abs(x) < 0.085) tmp = Float64(Float64(x * x) * fma(fma(fma(-2.6455026455026456e-5, Float64(x * x), 0.0003527336860670194), Float64(x * x), -0.005555555555555556), Float64(x * x), 0.16666666666666666)); else tmp = log(Float64(sinh(x) / x)); end return tmp end
code[x_] := If[Less[N[Abs[x], $MachinePrecision], 0.085], N[(N[(x * x), $MachinePrecision] * N[(N[(N[(-2.6455026455026456e-5 * N[(x * x), $MachinePrecision] + 0.0003527336860670194), $MachinePrecision] * N[(x * x), $MachinePrecision] + -0.005555555555555556), $MachinePrecision] * N[(x * x), $MachinePrecision] + 0.16666666666666666), $MachinePrecision]), $MachinePrecision], N[Log[N[(N[Sinh[x], $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left|x\right| < 0.085:\\
\;\;\;\;\left(x \cdot x\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-2.6455026455026456 \cdot 10^{-5}, x \cdot x, 0.0003527336860670194\right), x \cdot x, -0.005555555555555556\right), x \cdot x, 0.16666666666666666\right)\\
\mathbf{else}:\\
\;\;\;\;\log \left(\frac{\sinh x}{x}\right)\\
\end{array}
\end{array}
herbie shell --seed 2023249
(FPCore (x)
:name "bug500, discussion (missed optimization)"
:precision binary64
:herbie-target
(if (< (fabs x) 0.085) (* (* x x) (fma (fma (fma -2.6455026455026456e-5 (* x x) 0.0003527336860670194) (* x x) -0.005555555555555556) (* x x) 0.16666666666666666)) (log (/ (sinh x) x)))
(log (/ (sinh x) x)))