
(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 7 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.00005)
(+ (* (pow x 4.0) -0.005555555555555556) (* x (* x 0.16666666666666666)))
(if (<= t_0 4e+49)
(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.00005) {
tmp = (pow(x, 4.0) * -0.005555555555555556) + (x * (x * 0.16666666666666666));
} else if (t_0 <= 4e+49) {
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.00005d0) then
tmp = ((x ** 4.0d0) * (-0.005555555555555556d0)) + (x * (x * 0.16666666666666666d0))
else if (t_0 <= 4d+49) 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.00005) {
tmp = (Math.pow(x, 4.0) * -0.005555555555555556) + (x * (x * 0.16666666666666666));
} else if (t_0 <= 4e+49) {
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.00005: tmp = (math.pow(x, 4.0) * -0.005555555555555556) + (x * (x * 0.16666666666666666)) elif t_0 <= 4e+49: 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.00005) tmp = Float64(Float64((x ^ 4.0) * -0.005555555555555556) + Float64(x * Float64(x * 0.16666666666666666))); elseif (t_0 <= 4e+49) 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.00005) tmp = ((x ^ 4.0) * -0.005555555555555556) + (x * (x * 0.16666666666666666)); elseif (t_0 <= 4e+49) 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.00005], N[(N[(N[Power[x, 4.0], $MachinePrecision] * -0.005555555555555556), $MachinePrecision] + N[(x * N[(x * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 4e+49], 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.00005:\\
\;\;\;\;{x}^{4} \cdot -0.005555555555555556 + x \cdot \left(x \cdot 0.16666666666666666\right)\\
\mathbf{elif}\;t_0 \leq 4 \cdot 10^{+49}:\\
\;\;\;\;\log t_0\\
\mathbf{else}:\\
\;\;\;\;\log \left({x}^{6} \cdot 0.0001984126984126984\right)\\
\end{array}
\end{array}
if (/.f64 (sinh.f64 x) x) < 1.00005000000000011Initial program 46.5%
Taylor expanded in x around 0 99.7%
add-cbrt-cube66.6%
pow1/365.0%
pow365.0%
*-commutative65.0%
unpow-prod-down65.1%
unpow265.1%
pow-prod-down65.0%
pow-sqr65.1%
metadata-eval65.1%
metadata-eval65.0%
Applied egg-rr65.0%
unpow1/366.6%
Simplified66.6%
metadata-eval66.6%
pow-sqr66.6%
pow-prod-down66.6%
unpow266.6%
metadata-eval66.5%
unpow-prod-down66.5%
*-commutative66.5%
pow366.6%
add-cbrt-cube99.7%
unpow299.7%
associate-*r*99.7%
Applied egg-rr99.7%
if 1.00005000000000011 < (/.f64 (sinh.f64 x) x) < 3.99999999999999979e49Initial program 95.5%
if 3.99999999999999979e49 < (/.f64 (sinh.f64 x) x) Initial program 3.2%
Taylor expanded in x around 0 12.6%
Taylor expanded in x around inf 8.0%
log-rec8.0%
neg-mul-18.0%
associate-*r*8.0%
metadata-eval8.0%
log-pow12.6%
log-prod12.6%
*-commutative12.6%
Simplified12.6%
Final simplification96.9%
(FPCore (x)
:precision binary64
(expm1
(log1p
(log1p
(fma
(pow x 6.0)
0.0001984126984126984
(fma
(pow x 2.0)
0.16666666666666666
(* (pow x 4.0) 0.008333333333333333)))))))
double code(double x) {
return expm1(log1p(log1p(fma(pow(x, 6.0), 0.0001984126984126984, fma(pow(x, 2.0), 0.16666666666666666, (pow(x, 4.0) * 0.008333333333333333))))));
}
function code(x) return expm1(log1p(log1p(fma((x ^ 6.0), 0.0001984126984126984, fma((x ^ 2.0), 0.16666666666666666, Float64((x ^ 4.0) * 0.008333333333333333)))))) end
code[x_] := N[(Exp[N[Log[1 + N[Log[1 + N[(N[Power[x, 6.0], $MachinePrecision] * 0.0001984126984126984 + N[(N[Power[x, 2.0], $MachinePrecision] * 0.16666666666666666 + N[(N[Power[x, 4.0], $MachinePrecision] * 0.008333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{log1p}\left(\mathsf{fma}\left({x}^{6}, 0.0001984126984126984, \mathsf{fma}\left({x}^{2}, 0.16666666666666666, {x}^{4} \cdot 0.008333333333333333\right)\right)\right)\right)\right)
\end{array}
Initial program 46.3%
Taylor expanded in x around 0 45.4%
expm1-log1p-u45.4%
log1p-def95.7%
*-commutative95.7%
fma-def95.7%
+-commutative95.7%
*-commutative95.7%
fma-def95.7%
*-commutative95.7%
Applied egg-rr95.7%
Final simplification95.7%
(FPCore (x)
:precision binary64
(+
(* (pow x 4.0) -0.005555555555555556)
(+
(* -2.6455026455026456e-5 (pow x 8.0))
(+
(* (pow x 6.0) 0.0003527336860670194)
(* (pow x 2.0) 0.16666666666666666)))))
double code(double x) {
return (pow(x, 4.0) * -0.005555555555555556) + ((-2.6455026455026456e-5 * pow(x, 8.0)) + ((pow(x, 6.0) * 0.0003527336860670194) + (pow(x, 2.0) * 0.16666666666666666)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((x ** 4.0d0) * (-0.005555555555555556d0)) + (((-2.6455026455026456d-5) * (x ** 8.0d0)) + (((x ** 6.0d0) * 0.0003527336860670194d0) + ((x ** 2.0d0) * 0.16666666666666666d0)))
end function
public static double code(double x) {
return (Math.pow(x, 4.0) * -0.005555555555555556) + ((-2.6455026455026456e-5 * Math.pow(x, 8.0)) + ((Math.pow(x, 6.0) * 0.0003527336860670194) + (Math.pow(x, 2.0) * 0.16666666666666666)));
}
def code(x): return (math.pow(x, 4.0) * -0.005555555555555556) + ((-2.6455026455026456e-5 * math.pow(x, 8.0)) + ((math.pow(x, 6.0) * 0.0003527336860670194) + (math.pow(x, 2.0) * 0.16666666666666666)))
function code(x) return Float64(Float64((x ^ 4.0) * -0.005555555555555556) + Float64(Float64(-2.6455026455026456e-5 * (x ^ 8.0)) + Float64(Float64((x ^ 6.0) * 0.0003527336860670194) + Float64((x ^ 2.0) * 0.16666666666666666)))) end
function tmp = code(x) tmp = ((x ^ 4.0) * -0.005555555555555556) + ((-2.6455026455026456e-5 * (x ^ 8.0)) + (((x ^ 6.0) * 0.0003527336860670194) + ((x ^ 2.0) * 0.16666666666666666))); end
code[x_] := N[(N[(N[Power[x, 4.0], $MachinePrecision] * -0.005555555555555556), $MachinePrecision] + N[(N[(-2.6455026455026456e-5 * N[Power[x, 8.0], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Power[x, 6.0], $MachinePrecision] * 0.0003527336860670194), $MachinePrecision] + N[(N[Power[x, 2.0], $MachinePrecision] * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{x}^{4} \cdot -0.005555555555555556 + \left(-2.6455026455026456 \cdot 10^{-5} \cdot {x}^{8} + \left({x}^{6} \cdot 0.0003527336860670194 + {x}^{2} \cdot 0.16666666666666666\right)\right)
\end{array}
Initial program 46.3%
Taylor expanded in x around 0 95.2%
Final simplification95.2%
(FPCore (x)
:precision binary64
(let* ((t_0 (/ (sinh x) x)))
(if (<= t_0 1.00005)
(+ (* (pow x 4.0) -0.005555555555555556) (* x (* x 0.16666666666666666)))
(if (<= t_0 4e+49)
(log t_0)
(cbrt (* (pow x 6.0) 0.004629629629629629))))))
double code(double x) {
double t_0 = sinh(x) / x;
double tmp;
if (t_0 <= 1.00005) {
tmp = (pow(x, 4.0) * -0.005555555555555556) + (x * (x * 0.16666666666666666));
} else if (t_0 <= 4e+49) {
tmp = log(t_0);
} else {
tmp = cbrt((pow(x, 6.0) * 0.004629629629629629));
}
return tmp;
}
public static double code(double x) {
double t_0 = Math.sinh(x) / x;
double tmp;
if (t_0 <= 1.00005) {
tmp = (Math.pow(x, 4.0) * -0.005555555555555556) + (x * (x * 0.16666666666666666));
} else if (t_0 <= 4e+49) {
tmp = Math.log(t_0);
} else {
tmp = Math.cbrt((Math.pow(x, 6.0) * 0.004629629629629629));
}
return tmp;
}
function code(x) t_0 = Float64(sinh(x) / x) tmp = 0.0 if (t_0 <= 1.00005) tmp = Float64(Float64((x ^ 4.0) * -0.005555555555555556) + Float64(x * Float64(x * 0.16666666666666666))); elseif (t_0 <= 4e+49) tmp = log(t_0); else tmp = cbrt(Float64((x ^ 6.0) * 0.004629629629629629)); end return tmp end
code[x_] := Block[{t$95$0 = N[(N[Sinh[x], $MachinePrecision] / x), $MachinePrecision]}, If[LessEqual[t$95$0, 1.00005], N[(N[(N[Power[x, 4.0], $MachinePrecision] * -0.005555555555555556), $MachinePrecision] + N[(x * N[(x * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 4e+49], N[Log[t$95$0], $MachinePrecision], N[Power[N[(N[Power[x, 6.0], $MachinePrecision] * 0.004629629629629629), $MachinePrecision], 1/3], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sinh x}{x}\\
\mathbf{if}\;t_0 \leq 1.00005:\\
\;\;\;\;{x}^{4} \cdot -0.005555555555555556 + x \cdot \left(x \cdot 0.16666666666666666\right)\\
\mathbf{elif}\;t_0 \leq 4 \cdot 10^{+49}:\\
\;\;\;\;\log t_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{{x}^{6} \cdot 0.004629629629629629}\\
\end{array}
\end{array}
if (/.f64 (sinh.f64 x) x) < 1.00005000000000011Initial program 46.5%
Taylor expanded in x around 0 99.7%
add-cbrt-cube66.6%
pow1/365.0%
pow365.0%
*-commutative65.0%
unpow-prod-down65.1%
unpow265.1%
pow-prod-down65.0%
pow-sqr65.1%
metadata-eval65.1%
metadata-eval65.0%
Applied egg-rr65.0%
unpow1/366.6%
Simplified66.6%
metadata-eval66.6%
pow-sqr66.6%
pow-prod-down66.6%
unpow266.6%
metadata-eval66.5%
unpow-prod-down66.5%
*-commutative66.5%
pow366.6%
add-cbrt-cube99.7%
unpow299.7%
associate-*r*99.7%
Applied egg-rr99.7%
if 1.00005000000000011 < (/.f64 (sinh.f64 x) x) < 3.99999999999999979e49Initial program 95.5%
if 3.99999999999999979e49 < (/.f64 (sinh.f64 x) x) Initial program 3.2%
Taylor expanded in x around 0 1.5%
Taylor expanded in x around 0 12.1%
*-commutative12.1%
Simplified12.1%
*-commutative12.1%
add-cbrt-cube12.1%
pow312.1%
*-commutative12.1%
unpow-prod-down12.1%
unpow212.1%
pow-prod-down12.1%
pow-prod-up12.1%
metadata-eval12.1%
metadata-eval12.1%
Applied egg-rr12.1%
Final simplification96.9%
(FPCore (x)
:precision binary64
(let* ((t_0 (/ (sinh x) x)) (t_1 (* x (* x 0.16666666666666666))))
(if (<= t_0 1.00005)
(+ (* (pow x 4.0) -0.005555555555555556) t_1)
(if (<= t_0 4e+49) (log t_0) t_1))))
double code(double x) {
double t_0 = sinh(x) / x;
double t_1 = x * (x * 0.16666666666666666);
double tmp;
if (t_0 <= 1.00005) {
tmp = (pow(x, 4.0) * -0.005555555555555556) + t_1;
} else if (t_0 <= 4e+49) {
tmp = log(t_0);
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sinh(x) / x
t_1 = x * (x * 0.16666666666666666d0)
if (t_0 <= 1.00005d0) then
tmp = ((x ** 4.0d0) * (-0.005555555555555556d0)) + t_1
else if (t_0 <= 4d+49) then
tmp = log(t_0)
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x) {
double t_0 = Math.sinh(x) / x;
double t_1 = x * (x * 0.16666666666666666);
double tmp;
if (t_0 <= 1.00005) {
tmp = (Math.pow(x, 4.0) * -0.005555555555555556) + t_1;
} else if (t_0 <= 4e+49) {
tmp = Math.log(t_0);
} else {
tmp = t_1;
}
return tmp;
}
def code(x): t_0 = math.sinh(x) / x t_1 = x * (x * 0.16666666666666666) tmp = 0 if t_0 <= 1.00005: tmp = (math.pow(x, 4.0) * -0.005555555555555556) + t_1 elif t_0 <= 4e+49: tmp = math.log(t_0) else: tmp = t_1 return tmp
function code(x) t_0 = Float64(sinh(x) / x) t_1 = Float64(x * Float64(x * 0.16666666666666666)) tmp = 0.0 if (t_0 <= 1.00005) tmp = Float64(Float64((x ^ 4.0) * -0.005555555555555556) + t_1); elseif (t_0 <= 4e+49) tmp = log(t_0); else tmp = t_1; end return tmp end
function tmp_2 = code(x) t_0 = sinh(x) / x; t_1 = x * (x * 0.16666666666666666); tmp = 0.0; if (t_0 <= 1.00005) tmp = ((x ^ 4.0) * -0.005555555555555556) + t_1; elseif (t_0 <= 4e+49) tmp = log(t_0); else tmp = t_1; end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(N[Sinh[x], $MachinePrecision] / x), $MachinePrecision]}, Block[{t$95$1 = N[(x * N[(x * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 1.00005], N[(N[(N[Power[x, 4.0], $MachinePrecision] * -0.005555555555555556), $MachinePrecision] + t$95$1), $MachinePrecision], If[LessEqual[t$95$0, 4e+49], N[Log[t$95$0], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sinh x}{x}\\
t_1 := x \cdot \left(x \cdot 0.16666666666666666\right)\\
\mathbf{if}\;t_0 \leq 1.00005:\\
\;\;\;\;{x}^{4} \cdot -0.005555555555555556 + t_1\\
\mathbf{elif}\;t_0 \leq 4 \cdot 10^{+49}:\\
\;\;\;\;\log t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if (/.f64 (sinh.f64 x) x) < 1.00005000000000011Initial program 46.5%
Taylor expanded in x around 0 99.7%
add-cbrt-cube66.6%
pow1/365.0%
pow365.0%
*-commutative65.0%
unpow-prod-down65.1%
unpow265.1%
pow-prod-down65.0%
pow-sqr65.1%
metadata-eval65.1%
metadata-eval65.0%
Applied egg-rr65.0%
unpow1/366.6%
Simplified66.6%
metadata-eval66.6%
pow-sqr66.6%
pow-prod-down66.6%
unpow266.6%
metadata-eval66.5%
unpow-prod-down66.5%
*-commutative66.5%
pow366.6%
add-cbrt-cube99.7%
unpow299.7%
associate-*r*99.7%
Applied egg-rr99.7%
if 1.00005000000000011 < (/.f64 (sinh.f64 x) x) < 3.99999999999999979e49Initial program 95.5%
if 3.99999999999999979e49 < (/.f64 (sinh.f64 x) x) Initial program 3.2%
Taylor expanded in x around 0 1.5%
Taylor expanded in x around 0 12.1%
*-commutative12.1%
Simplified12.1%
*-commutative12.1%
add-sqr-sqrt12.1%
sqrt-unprod12.1%
*-commutative12.1%
*-commutative12.1%
swap-sqr12.1%
pow-prod-up12.1%
metadata-eval12.1%
metadata-eval12.1%
Applied egg-rr12.1%
*-commutative12.1%
sqrt-prod12.1%
metadata-eval12.1%
sqrt-pow112.1%
metadata-eval12.1%
unpow212.1%
associate-*l*12.1%
*-commutative12.1%
Applied egg-rr12.1%
Final simplification96.9%
(FPCore (x) :precision binary64 (if (<= (/ (sinh x) x) 1.00005) (+ (* (pow x 4.0) -0.005555555555555556) (* x (* x 0.16666666666666666))) (- (log (/ x (sinh x))))))
double code(double x) {
double tmp;
if ((sinh(x) / x) <= 1.00005) {
tmp = (pow(x, 4.0) * -0.005555555555555556) + (x * (x * 0.16666666666666666));
} else {
tmp = -log((x / sinh(x)));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if ((sinh(x) / x) <= 1.00005d0) then
tmp = ((x ** 4.0d0) * (-0.005555555555555556d0)) + (x * (x * 0.16666666666666666d0))
else
tmp = -log((x / sinh(x)))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if ((Math.sinh(x) / x) <= 1.00005) {
tmp = (Math.pow(x, 4.0) * -0.005555555555555556) + (x * (x * 0.16666666666666666));
} else {
tmp = -Math.log((x / Math.sinh(x)));
}
return tmp;
}
def code(x): tmp = 0 if (math.sinh(x) / x) <= 1.00005: tmp = (math.pow(x, 4.0) * -0.005555555555555556) + (x * (x * 0.16666666666666666)) else: tmp = -math.log((x / math.sinh(x))) return tmp
function code(x) tmp = 0.0 if (Float64(sinh(x) / x) <= 1.00005) tmp = Float64(Float64((x ^ 4.0) * -0.005555555555555556) + Float64(x * Float64(x * 0.16666666666666666))); else tmp = Float64(-log(Float64(x / sinh(x)))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if ((sinh(x) / x) <= 1.00005) tmp = ((x ^ 4.0) * -0.005555555555555556) + (x * (x * 0.16666666666666666)); else tmp = -log((x / sinh(x))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[N[(N[Sinh[x], $MachinePrecision] / x), $MachinePrecision], 1.00005], N[(N[(N[Power[x, 4.0], $MachinePrecision] * -0.005555555555555556), $MachinePrecision] + N[(x * N[(x * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-N[Log[N[(x / N[Sinh[x], $MachinePrecision]), $MachinePrecision]], $MachinePrecision])]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\sinh x}{x} \leq 1.00005:\\
\;\;\;\;{x}^{4} \cdot -0.005555555555555556 + x \cdot \left(x \cdot 0.16666666666666666\right)\\
\mathbf{else}:\\
\;\;\;\;-\log \left(\frac{x}{\sinh x}\right)\\
\end{array}
\end{array}
if (/.f64 (sinh.f64 x) x) < 1.00005000000000011Initial program 46.5%
Taylor expanded in x around 0 99.7%
add-cbrt-cube66.6%
pow1/365.0%
pow365.0%
*-commutative65.0%
unpow-prod-down65.1%
unpow265.1%
pow-prod-down65.0%
pow-sqr65.1%
metadata-eval65.1%
metadata-eval65.0%
Applied egg-rr65.0%
unpow1/366.6%
Simplified66.6%
metadata-eval66.6%
pow-sqr66.6%
pow-prod-down66.6%
unpow266.6%
metadata-eval66.5%
unpow-prod-down66.5%
*-commutative66.5%
pow366.6%
add-cbrt-cube99.7%
unpow299.7%
associate-*r*99.7%
Applied egg-rr99.7%
if 1.00005000000000011 < (/.f64 (sinh.f64 x) x) Initial program 42.7%
clear-num42.7%
neg-log43.1%
Applied egg-rr43.1%
Final simplification96.6%
(FPCore (x) :precision binary64 (* x (* x 0.16666666666666666)))
double code(double x) {
return x * (x * 0.16666666666666666);
}
real(8) function code(x)
real(8), intent (in) :: x
code = x * (x * 0.16666666666666666d0)
end function
public static double code(double x) {
return x * (x * 0.16666666666666666);
}
def code(x): return x * (x * 0.16666666666666666)
function code(x) return Float64(x * Float64(x * 0.16666666666666666)) end
function tmp = code(x) tmp = x * (x * 0.16666666666666666); end
code[x_] := N[(x * N[(x * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(x \cdot 0.16666666666666666\right)
\end{array}
Initial program 46.3%
Taylor expanded in x around 0 94.9%
Taylor expanded in x around 0 95.0%
*-commutative95.0%
Simplified95.0%
*-commutative95.0%
add-sqr-sqrt94.8%
sqrt-unprod71.7%
*-commutative71.7%
*-commutative71.7%
swap-sqr71.7%
pow-prod-up71.7%
metadata-eval71.7%
metadata-eval71.7%
Applied egg-rr71.7%
*-commutative71.7%
sqrt-prod71.8%
metadata-eval71.8%
sqrt-pow195.0%
metadata-eval95.0%
unpow295.0%
associate-*l*95.1%
*-commutative95.1%
Applied egg-rr95.1%
Final simplification95.1%
(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 2023318
(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)))