
(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.00002)
(* x (* x (+ 0.16666666666666666 (* (pow x 2.0) -0.005555555555555556))))
(if (<= t_0 1e+72)
(log t_0)
(log (+ 1.0 (* (pow x 2.0) 0.16666666666666666)))))))
double code(double x) {
double t_0 = sinh(x) / x;
double tmp;
if (t_0 <= 1.00002) {
tmp = x * (x * (0.16666666666666666 + (pow(x, 2.0) * -0.005555555555555556)));
} else if (t_0 <= 1e+72) {
tmp = log(t_0);
} else {
tmp = log((1.0 + (pow(x, 2.0) * 0.16666666666666666)));
}
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.00002d0) then
tmp = x * (x * (0.16666666666666666d0 + ((x ** 2.0d0) * (-0.005555555555555556d0))))
else if (t_0 <= 1d+72) then
tmp = log(t_0)
else
tmp = log((1.0d0 + ((x ** 2.0d0) * 0.16666666666666666d0)))
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.00002) {
tmp = x * (x * (0.16666666666666666 + (Math.pow(x, 2.0) * -0.005555555555555556)));
} else if (t_0 <= 1e+72) {
tmp = Math.log(t_0);
} else {
tmp = Math.log((1.0 + (Math.pow(x, 2.0) * 0.16666666666666666)));
}
return tmp;
}
def code(x): t_0 = math.sinh(x) / x tmp = 0 if t_0 <= 1.00002: tmp = x * (x * (0.16666666666666666 + (math.pow(x, 2.0) * -0.005555555555555556))) elif t_0 <= 1e+72: tmp = math.log(t_0) else: tmp = math.log((1.0 + (math.pow(x, 2.0) * 0.16666666666666666))) return tmp
function code(x) t_0 = Float64(sinh(x) / x) tmp = 0.0 if (t_0 <= 1.00002) tmp = Float64(x * Float64(x * Float64(0.16666666666666666 + Float64((x ^ 2.0) * -0.005555555555555556)))); elseif (t_0 <= 1e+72) tmp = log(t_0); else tmp = log(Float64(1.0 + Float64((x ^ 2.0) * 0.16666666666666666))); end return tmp end
function tmp_2 = code(x) t_0 = sinh(x) / x; tmp = 0.0; if (t_0 <= 1.00002) tmp = x * (x * (0.16666666666666666 + ((x ^ 2.0) * -0.005555555555555556))); elseif (t_0 <= 1e+72) tmp = log(t_0); else tmp = log((1.0 + ((x ^ 2.0) * 0.16666666666666666))); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(N[Sinh[x], $MachinePrecision] / x), $MachinePrecision]}, If[LessEqual[t$95$0, 1.00002], N[(x * N[(x * N[(0.16666666666666666 + N[(N[Power[x, 2.0], $MachinePrecision] * -0.005555555555555556), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1e+72], N[Log[t$95$0], $MachinePrecision], N[Log[N[(1.0 + N[(N[Power[x, 2.0], $MachinePrecision] * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sinh x}{x}\\
\mathbf{if}\;t\_0 \leq 1.00002:\\
\;\;\;\;x \cdot \left(x \cdot \left(0.16666666666666666 + {x}^{2} \cdot -0.005555555555555556\right)\right)\\
\mathbf{elif}\;t\_0 \leq 10^{+72}:\\
\;\;\;\;\log t\_0\\
\mathbf{else}:\\
\;\;\;\;\log \left(1 + {x}^{2} \cdot 0.16666666666666666\right)\\
\end{array}
\end{array}
if (/.f64 (sinh.f64 x) x) < 1.00001999999999991Initial program 50.6%
Taylor expanded in x around 0 99.6%
*-commutative99.6%
Simplified99.6%
add-sqr-sqrt99.4%
pow299.4%
sqrt-prod99.5%
sqrt-pow199.5%
metadata-eval99.5%
pow199.5%
+-commutative99.5%
fma-define99.5%
Applied egg-rr99.5%
unpow299.5%
swap-sqr99.6%
add-sqr-sqrt99.6%
associate-*l*99.6%
Applied egg-rr99.6%
fma-undefine99.6%
Applied egg-rr99.6%
if 1.00001999999999991 < (/.f64 (sinh.f64 x) x) < 9.99999999999999944e71Initial program 96.1%
if 9.99999999999999944e71 < (/.f64 (sinh.f64 x) x) Initial program 3.2%
Taylor expanded in x around 0 12.3%
+-commutative12.3%
Simplified12.3%
Final simplification96.8%
(FPCore (x)
:precision binary64
(let* ((t_0 (/ (sinh x) x)))
(if (<= t_0 1.00002)
(* x (* x (+ 0.16666666666666666 (* (pow x 2.0) -0.005555555555555556))))
(if (<= t_0 1e+72)
(log t_0)
(- (log 0.16666666666666666) (* (log x) -2.0))))))
double code(double x) {
double t_0 = sinh(x) / x;
double tmp;
if (t_0 <= 1.00002) {
tmp = x * (x * (0.16666666666666666 + (pow(x, 2.0) * -0.005555555555555556)));
} else if (t_0 <= 1e+72) {
tmp = log(t_0);
} else {
tmp = log(0.16666666666666666) - (log(x) * -2.0);
}
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.00002d0) then
tmp = x * (x * (0.16666666666666666d0 + ((x ** 2.0d0) * (-0.005555555555555556d0))))
else if (t_0 <= 1d+72) then
tmp = log(t_0)
else
tmp = log(0.16666666666666666d0) - (log(x) * (-2.0d0))
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.00002) {
tmp = x * (x * (0.16666666666666666 + (Math.pow(x, 2.0) * -0.005555555555555556)));
} else if (t_0 <= 1e+72) {
tmp = Math.log(t_0);
} else {
tmp = Math.log(0.16666666666666666) - (Math.log(x) * -2.0);
}
return tmp;
}
def code(x): t_0 = math.sinh(x) / x tmp = 0 if t_0 <= 1.00002: tmp = x * (x * (0.16666666666666666 + (math.pow(x, 2.0) * -0.005555555555555556))) elif t_0 <= 1e+72: tmp = math.log(t_0) else: tmp = math.log(0.16666666666666666) - (math.log(x) * -2.0) return tmp
function code(x) t_0 = Float64(sinh(x) / x) tmp = 0.0 if (t_0 <= 1.00002) tmp = Float64(x * Float64(x * Float64(0.16666666666666666 + Float64((x ^ 2.0) * -0.005555555555555556)))); elseif (t_0 <= 1e+72) tmp = log(t_0); else tmp = Float64(log(0.16666666666666666) - Float64(log(x) * -2.0)); end return tmp end
function tmp_2 = code(x) t_0 = sinh(x) / x; tmp = 0.0; if (t_0 <= 1.00002) tmp = x * (x * (0.16666666666666666 + ((x ^ 2.0) * -0.005555555555555556))); elseif (t_0 <= 1e+72) tmp = log(t_0); else tmp = log(0.16666666666666666) - (log(x) * -2.0); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(N[Sinh[x], $MachinePrecision] / x), $MachinePrecision]}, If[LessEqual[t$95$0, 1.00002], N[(x * N[(x * N[(0.16666666666666666 + N[(N[Power[x, 2.0], $MachinePrecision] * -0.005555555555555556), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1e+72], N[Log[t$95$0], $MachinePrecision], N[(N[Log[0.16666666666666666], $MachinePrecision] - N[(N[Log[x], $MachinePrecision] * -2.0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sinh x}{x}\\
\mathbf{if}\;t\_0 \leq 1.00002:\\
\;\;\;\;x \cdot \left(x \cdot \left(0.16666666666666666 + {x}^{2} \cdot -0.005555555555555556\right)\right)\\
\mathbf{elif}\;t\_0 \leq 10^{+72}:\\
\;\;\;\;\log t\_0\\
\mathbf{else}:\\
\;\;\;\;\log 0.16666666666666666 - \log x \cdot -2\\
\end{array}
\end{array}
if (/.f64 (sinh.f64 x) x) < 1.00001999999999991Initial program 50.6%
Taylor expanded in x around 0 99.6%
*-commutative99.6%
Simplified99.6%
add-sqr-sqrt99.4%
pow299.4%
sqrt-prod99.5%
sqrt-pow199.5%
metadata-eval99.5%
pow199.5%
+-commutative99.5%
fma-define99.5%
Applied egg-rr99.5%
unpow299.5%
swap-sqr99.6%
add-sqr-sqrt99.6%
associate-*l*99.6%
Applied egg-rr99.6%
fma-undefine99.6%
Applied egg-rr99.6%
if 1.00001999999999991 < (/.f64 (sinh.f64 x) x) < 9.99999999999999944e71Initial program 96.1%
if 9.99999999999999944e71 < (/.f64 (sinh.f64 x) x) Initial program 3.2%
Taylor expanded in x around 0 12.3%
distribute-rgt-in12.3%
*-lft-identity12.3%
associate-*l*12.3%
unpow212.3%
unpow312.3%
Simplified12.3%
Taylor expanded in x around inf 9.1%
*-commutative9.1%
log-rec9.1%
distribute-lft-neg-out9.1%
unsub-neg9.1%
Simplified9.1%
Final simplification96.7%
(FPCore (x)
:precision binary64
(let* ((t_0 (/ (sinh x) x)))
(if (<= t_0 1.00002)
(* x (* x (+ 0.16666666666666666 (* (pow x 2.0) -0.005555555555555556))))
(if (<= t_0 1e+72)
(log t_0)
(+ -1.0 (+ 1.0 (* (pow x 2.0) 0.16666666666666666)))))))
double code(double x) {
double t_0 = sinh(x) / x;
double tmp;
if (t_0 <= 1.00002) {
tmp = x * (x * (0.16666666666666666 + (pow(x, 2.0) * -0.005555555555555556)));
} else if (t_0 <= 1e+72) {
tmp = log(t_0);
} else {
tmp = -1.0 + (1.0 + (pow(x, 2.0) * 0.16666666666666666));
}
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.00002d0) then
tmp = x * (x * (0.16666666666666666d0 + ((x ** 2.0d0) * (-0.005555555555555556d0))))
else if (t_0 <= 1d+72) then
tmp = log(t_0)
else
tmp = (-1.0d0) + (1.0d0 + ((x ** 2.0d0) * 0.16666666666666666d0))
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.00002) {
tmp = x * (x * (0.16666666666666666 + (Math.pow(x, 2.0) * -0.005555555555555556)));
} else if (t_0 <= 1e+72) {
tmp = Math.log(t_0);
} else {
tmp = -1.0 + (1.0 + (Math.pow(x, 2.0) * 0.16666666666666666));
}
return tmp;
}
def code(x): t_0 = math.sinh(x) / x tmp = 0 if t_0 <= 1.00002: tmp = x * (x * (0.16666666666666666 + (math.pow(x, 2.0) * -0.005555555555555556))) elif t_0 <= 1e+72: tmp = math.log(t_0) else: tmp = -1.0 + (1.0 + (math.pow(x, 2.0) * 0.16666666666666666)) return tmp
function code(x) t_0 = Float64(sinh(x) / x) tmp = 0.0 if (t_0 <= 1.00002) tmp = Float64(x * Float64(x * Float64(0.16666666666666666 + Float64((x ^ 2.0) * -0.005555555555555556)))); elseif (t_0 <= 1e+72) tmp = log(t_0); else tmp = Float64(-1.0 + Float64(1.0 + Float64((x ^ 2.0) * 0.16666666666666666))); end return tmp end
function tmp_2 = code(x) t_0 = sinh(x) / x; tmp = 0.0; if (t_0 <= 1.00002) tmp = x * (x * (0.16666666666666666 + ((x ^ 2.0) * -0.005555555555555556))); elseif (t_0 <= 1e+72) tmp = log(t_0); else tmp = -1.0 + (1.0 + ((x ^ 2.0) * 0.16666666666666666)); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(N[Sinh[x], $MachinePrecision] / x), $MachinePrecision]}, If[LessEqual[t$95$0, 1.00002], N[(x * N[(x * N[(0.16666666666666666 + N[(N[Power[x, 2.0], $MachinePrecision] * -0.005555555555555556), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1e+72], N[Log[t$95$0], $MachinePrecision], N[(-1.0 + N[(1.0 + N[(N[Power[x, 2.0], $MachinePrecision] * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sinh x}{x}\\
\mathbf{if}\;t\_0 \leq 1.00002:\\
\;\;\;\;x \cdot \left(x \cdot \left(0.16666666666666666 + {x}^{2} \cdot -0.005555555555555556\right)\right)\\
\mathbf{elif}\;t\_0 \leq 10^{+72}:\\
\;\;\;\;\log t\_0\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(1 + {x}^{2} \cdot 0.16666666666666666\right)\\
\end{array}
\end{array}
if (/.f64 (sinh.f64 x) x) < 1.00001999999999991Initial program 50.6%
Taylor expanded in x around 0 99.6%
*-commutative99.6%
Simplified99.6%
add-sqr-sqrt99.4%
pow299.4%
sqrt-prod99.5%
sqrt-pow199.5%
metadata-eval99.5%
pow199.5%
+-commutative99.5%
fma-define99.5%
Applied egg-rr99.5%
unpow299.5%
swap-sqr99.6%
add-sqr-sqrt99.6%
associate-*l*99.6%
Applied egg-rr99.6%
fma-undefine99.6%
Applied egg-rr99.6%
if 1.00001999999999991 < (/.f64 (sinh.f64 x) x) < 9.99999999999999944e71Initial program 96.1%
if 9.99999999999999944e71 < (/.f64 (sinh.f64 x) x) Initial program 3.2%
expm1-log1p-u3.2%
expm1-undefine3.2%
log1p-undefine3.2%
rem-exp-log3.2%
Applied egg-rr3.2%
Taylor expanded in x around 0 12.0%
Final simplification96.8%
(FPCore (x)
:precision binary64
(let* ((t_0 (/ (sinh x) x)))
(if (<= t_0 1.00002)
(* x (* x (+ 0.16666666666666666 (* (pow x 2.0) -0.005555555555555556))))
(+ -1.0 (+ 1.0 (log t_0))))))
double code(double x) {
double t_0 = sinh(x) / x;
double tmp;
if (t_0 <= 1.00002) {
tmp = x * (x * (0.16666666666666666 + (pow(x, 2.0) * -0.005555555555555556)));
} else {
tmp = -1.0 + (1.0 + log(t_0));
}
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.00002d0) then
tmp = x * (x * (0.16666666666666666d0 + ((x ** 2.0d0) * (-0.005555555555555556d0))))
else
tmp = (-1.0d0) + (1.0d0 + log(t_0))
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.00002) {
tmp = x * (x * (0.16666666666666666 + (Math.pow(x, 2.0) * -0.005555555555555556)));
} else {
tmp = -1.0 + (1.0 + Math.log(t_0));
}
return tmp;
}
def code(x): t_0 = math.sinh(x) / x tmp = 0 if t_0 <= 1.00002: tmp = x * (x * (0.16666666666666666 + (math.pow(x, 2.0) * -0.005555555555555556))) else: tmp = -1.0 + (1.0 + math.log(t_0)) return tmp
function code(x) t_0 = Float64(sinh(x) / x) tmp = 0.0 if (t_0 <= 1.00002) tmp = Float64(x * Float64(x * Float64(0.16666666666666666 + Float64((x ^ 2.0) * -0.005555555555555556)))); else tmp = Float64(-1.0 + Float64(1.0 + log(t_0))); end return tmp end
function tmp_2 = code(x) t_0 = sinh(x) / x; tmp = 0.0; if (t_0 <= 1.00002) tmp = x * (x * (0.16666666666666666 + ((x ^ 2.0) * -0.005555555555555556))); else tmp = -1.0 + (1.0 + log(t_0)); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(N[Sinh[x], $MachinePrecision] / x), $MachinePrecision]}, If[LessEqual[t$95$0, 1.00002], N[(x * N[(x * N[(0.16666666666666666 + N[(N[Power[x, 2.0], $MachinePrecision] * -0.005555555555555556), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(1.0 + N[Log[t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sinh x}{x}\\
\mathbf{if}\;t\_0 \leq 1.00002:\\
\;\;\;\;x \cdot \left(x \cdot \left(0.16666666666666666 + {x}^{2} \cdot -0.005555555555555556\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(1 + \log t\_0\right)\\
\end{array}
\end{array}
if (/.f64 (sinh.f64 x) x) < 1.00001999999999991Initial program 50.6%
Taylor expanded in x around 0 99.6%
*-commutative99.6%
Simplified99.6%
add-sqr-sqrt99.4%
pow299.4%
sqrt-prod99.5%
sqrt-pow199.5%
metadata-eval99.5%
pow199.5%
+-commutative99.5%
fma-define99.5%
Applied egg-rr99.5%
unpow299.5%
swap-sqr99.6%
add-sqr-sqrt99.6%
associate-*l*99.6%
Applied egg-rr99.6%
fma-undefine99.6%
Applied egg-rr99.6%
if 1.00001999999999991 < (/.f64 (sinh.f64 x) x) Initial program 38.9%
expm1-log1p-u38.6%
expm1-undefine38.7%
log1p-undefine38.7%
rem-exp-log39.0%
Applied egg-rr39.0%
Final simplification96.6%
(FPCore (x)
:precision binary64
(*
(pow x 2.0)
(+
0.16666666666666666
(*
(pow x 2.0)
(- (* (pow x 2.0) 0.0003527336860670194) 0.005555555555555556)))))
double code(double x) {
return pow(x, 2.0) * (0.16666666666666666 + (pow(x, 2.0) * ((pow(x, 2.0) * 0.0003527336860670194) - 0.005555555555555556)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (x ** 2.0d0) * (0.16666666666666666d0 + ((x ** 2.0d0) * (((x ** 2.0d0) * 0.0003527336860670194d0) - 0.005555555555555556d0)))
end function
public static double code(double x) {
return Math.pow(x, 2.0) * (0.16666666666666666 + (Math.pow(x, 2.0) * ((Math.pow(x, 2.0) * 0.0003527336860670194) - 0.005555555555555556)));
}
def code(x): return math.pow(x, 2.0) * (0.16666666666666666 + (math.pow(x, 2.0) * ((math.pow(x, 2.0) * 0.0003527336860670194) - 0.005555555555555556)))
function code(x) return Float64((x ^ 2.0) * Float64(0.16666666666666666 + Float64((x ^ 2.0) * Float64(Float64((x ^ 2.0) * 0.0003527336860670194) - 0.005555555555555556)))) end
function tmp = code(x) tmp = (x ^ 2.0) * (0.16666666666666666 + ((x ^ 2.0) * (((x ^ 2.0) * 0.0003527336860670194) - 0.005555555555555556))); end
code[x_] := N[(N[Power[x, 2.0], $MachinePrecision] * N[(0.16666666666666666 + N[(N[Power[x, 2.0], $MachinePrecision] * N[(N[(N[Power[x, 2.0], $MachinePrecision] * 0.0003527336860670194), $MachinePrecision] - 0.005555555555555556), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{x}^{2} \cdot \left(0.16666666666666666 + {x}^{2} \cdot \left({x}^{2} \cdot 0.0003527336860670194 - 0.005555555555555556\right)\right)
\end{array}
Initial program 50.0%
Taylor expanded in x around 0 95.5%
Final simplification95.5%
(FPCore (x) :precision binary64 (if (<= x 0.008) (* x (* x (+ 0.16666666666666666 (* (pow x 2.0) -0.005555555555555556)))) (- (log (pow (/ (sinh x) x) -1.0)))))
double code(double x) {
double tmp;
if (x <= 0.008) {
tmp = x * (x * (0.16666666666666666 + (pow(x, 2.0) * -0.005555555555555556)));
} else {
tmp = -log(pow((sinh(x) / x), -1.0));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 0.008d0) then
tmp = x * (x * (0.16666666666666666d0 + ((x ** 2.0d0) * (-0.005555555555555556d0))))
else
tmp = -log(((sinh(x) / x) ** (-1.0d0)))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 0.008) {
tmp = x * (x * (0.16666666666666666 + (Math.pow(x, 2.0) * -0.005555555555555556)));
} else {
tmp = -Math.log(Math.pow((Math.sinh(x) / x), -1.0));
}
return tmp;
}
def code(x): tmp = 0 if x <= 0.008: tmp = x * (x * (0.16666666666666666 + (math.pow(x, 2.0) * -0.005555555555555556))) else: tmp = -math.log(math.pow((math.sinh(x) / x), -1.0)) return tmp
function code(x) tmp = 0.0 if (x <= 0.008) tmp = Float64(x * Float64(x * Float64(0.16666666666666666 + Float64((x ^ 2.0) * -0.005555555555555556)))); else tmp = Float64(-log((Float64(sinh(x) / x) ^ -1.0))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 0.008) tmp = x * (x * (0.16666666666666666 + ((x ^ 2.0) * -0.005555555555555556))); else tmp = -log(((sinh(x) / x) ^ -1.0)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 0.008], N[(x * N[(x * N[(0.16666666666666666 + N[(N[Power[x, 2.0], $MachinePrecision] * -0.005555555555555556), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-N[Log[N[Power[N[(N[Sinh[x], $MachinePrecision] / x), $MachinePrecision], -1.0], $MachinePrecision]], $MachinePrecision])]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.008:\\
\;\;\;\;x \cdot \left(x \cdot \left(0.16666666666666666 + {x}^{2} \cdot -0.005555555555555556\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-\log \left({\left(\frac{\sinh x}{x}\right)}^{-1}\right)\\
\end{array}
\end{array}
if x < 0.0080000000000000002Initial program 50.4%
Taylor expanded in x around 0 98.4%
*-commutative98.4%
Simplified98.4%
add-sqr-sqrt98.1%
pow298.1%
sqrt-prod98.3%
sqrt-pow198.3%
metadata-eval98.3%
pow198.3%
+-commutative98.3%
fma-define98.3%
Applied egg-rr98.3%
unpow298.3%
swap-sqr98.4%
add-sqr-sqrt98.4%
associate-*l*98.4%
Applied egg-rr98.4%
fma-undefine98.4%
Applied egg-rr98.4%
if 0.0080000000000000002 < x Initial program 40.0%
clear-num40.0%
neg-log39.7%
Applied egg-rr39.7%
clear-num40.3%
inv-pow40.3%
Applied egg-rr40.3%
Final simplification96.2%
(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 50.0%
expm1-log1p-u49.9%
expm1-undefine50.0%
log1p-undefine50.0%
rem-exp-log50.0%
Applied egg-rr50.0%
Taylor expanded in x around 0 48.7%
add-exp-log48.7%
*-commutative48.7%
log1p-define48.7%
expm1-define95.0%
expm1-log1p-u95.0%
*-commutative95.0%
unpow295.0%
associate-*r*95.0%
Applied egg-rr95.0%
Final simplification95.0%
(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 2024089
(FPCore (x)
:name "bug500, discussion (missed optimization)"
:precision binary64
:alt
(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)))