
(FPCore (N) :precision binary64 (- (log (+ N 1.0)) (log N)))
double code(double N) {
return log((N + 1.0)) - log(N);
}
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(n)
use fmin_fmax_functions
real(8), intent (in) :: n
code = log((n + 1.0d0)) - log(n)
end function
public static double code(double N) {
return Math.log((N + 1.0)) - Math.log(N);
}
def code(N): return math.log((N + 1.0)) - math.log(N)
function code(N) return Float64(log(Float64(N + 1.0)) - log(N)) end
function tmp = code(N) tmp = log((N + 1.0)) - log(N); end
code[N_] := N[(N[Log[N[(N + 1.0), $MachinePrecision]], $MachinePrecision] - N[Log[N], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\log \left(N + 1\right) - \log N
\end{array}
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (N) :precision binary64 (- (log (+ N 1.0)) (log N)))
double code(double N) {
return log((N + 1.0)) - log(N);
}
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(n)
use fmin_fmax_functions
real(8), intent (in) :: n
code = log((n + 1.0d0)) - log(n)
end function
public static double code(double N) {
return Math.log((N + 1.0)) - Math.log(N);
}
def code(N): return math.log((N + 1.0)) - math.log(N)
function code(N) return Float64(log(Float64(N + 1.0)) - log(N)) end
function tmp = code(N) tmp = log((N + 1.0)) - log(N); end
code[N_] := N[(N[Log[N[(N + 1.0), $MachinePrecision]], $MachinePrecision] - N[Log[N], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\log \left(N + 1\right) - \log N
\end{array}
(FPCore (N)
:precision binary64
(let* ((t_0 (log (- N -1.0))) (t_1 (pow t_0 1.5)))
(if (<= N 820.0)
(/
(- (* t_1 t_1) (exp (* (log (log N)) 3.0)))
(fma t_0 t_0 (fma (log N) (log N) (* t_0 (log N)))))
(/ (- 1.0 (/ (- 0.5 (/ (- 0.3333333333333333 (/ 0.25 N)) N)) N)) N))))
double code(double N) {
double t_0 = log((N - -1.0));
double t_1 = pow(t_0, 1.5);
double tmp;
if (N <= 820.0) {
tmp = ((t_1 * t_1) - exp((log(log(N)) * 3.0))) / fma(t_0, t_0, fma(log(N), log(N), (t_0 * log(N))));
} else {
tmp = (1.0 - ((0.5 - ((0.3333333333333333 - (0.25 / N)) / N)) / N)) / N;
}
return tmp;
}
function code(N) t_0 = log(Float64(N - -1.0)) t_1 = t_0 ^ 1.5 tmp = 0.0 if (N <= 820.0) tmp = Float64(Float64(Float64(t_1 * t_1) - exp(Float64(log(log(N)) * 3.0))) / fma(t_0, t_0, fma(log(N), log(N), Float64(t_0 * log(N))))); else tmp = Float64(Float64(1.0 - Float64(Float64(0.5 - Float64(Float64(0.3333333333333333 - Float64(0.25 / N)) / N)) / N)) / N); end return tmp end
code[N_] := Block[{t$95$0 = N[Log[N[(N - -1.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[t$95$0, 1.5], $MachinePrecision]}, If[LessEqual[N, 820.0], N[(N[(N[(t$95$1 * t$95$1), $MachinePrecision] - N[Exp[N[(N[Log[N[Log[N], $MachinePrecision]], $MachinePrecision] * 3.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 * t$95$0 + N[(N[Log[N], $MachinePrecision] * N[Log[N], $MachinePrecision] + N[(t$95$0 * N[Log[N], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - N[(N[(0.5 - N[(N[(0.3333333333333333 - N[(0.25 / N), $MachinePrecision]), $MachinePrecision] / N), $MachinePrecision]), $MachinePrecision] / N), $MachinePrecision]), $MachinePrecision] / N), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log \left(N - -1\right)\\
t_1 := {t\_0}^{1.5}\\
\mathbf{if}\;N \leq 820:\\
\;\;\;\;\frac{t\_1 \cdot t\_1 - e^{\log \log N \cdot 3}}{\mathsf{fma}\left(t\_0, t\_0, \mathsf{fma}\left(\log N, \log N, t\_0 \cdot \log N\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - \frac{0.5 - \frac{0.3333333333333333 - \frac{0.25}{N}}{N}}{N}}{N}\\
\end{array}
\end{array}
if N < 820Initial program 92.6%
lift-+.f64N/A
lift-log.f64N/A
+-commutativeN/A
lower-log1p.f6492.6
Applied rewrites92.6%
lift--.f64N/A
lift-log1p.f64N/A
lift-log.f64N/A
+-commutativeN/A
metadata-evalN/A
negate-subN/A
flip3--N/A
lower-/.f64N/A
lower--.f64N/A
lower-pow.f64N/A
lift-log.f64N/A
lift--.f64N/A
lower-pow.f64N/A
lift-log.f64N/A
lower-fma.f64N/A
Applied rewrites92.4%
lift-log.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lower-exp.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lift-log.f6491.6
Applied rewrites91.6%
lift-pow.f64N/A
lift--.f64N/A
lift-log.f64N/A
sqr-powN/A
lower-*.f64N/A
metadata-evalN/A
lower-pow.f64N/A
lift-log.f64N/A
lift--.f64N/A
metadata-evalN/A
lower-pow.f64N/A
lift-log.f64N/A
lift--.f6491.4
Applied rewrites91.4%
if 820 < N Initial program 18.9%
Taylor expanded in N around -inf
mul-1-negN/A
distribute-neg-fracN/A
lower-/.f64N/A
Applied rewrites99.7%
(FPCore (N)
:precision binary64
(let* ((t_0 (log (- N -1.0))))
(if (<= N 850.0)
(/
(- (pow t_0 3.0) (exp (* (log (log N)) 3.0)))
(fma t_0 t_0 (fma (log N) (log N) (* t_0 (log N)))))
(/ (- 1.0 (/ (- 0.5 (/ (- 0.3333333333333333 (/ 0.25 N)) N)) N)) N))))
double code(double N) {
double t_0 = log((N - -1.0));
double tmp;
if (N <= 850.0) {
tmp = (pow(t_0, 3.0) - exp((log(log(N)) * 3.0))) / fma(t_0, t_0, fma(log(N), log(N), (t_0 * log(N))));
} else {
tmp = (1.0 - ((0.5 - ((0.3333333333333333 - (0.25 / N)) / N)) / N)) / N;
}
return tmp;
}
function code(N) t_0 = log(Float64(N - -1.0)) tmp = 0.0 if (N <= 850.0) tmp = Float64(Float64((t_0 ^ 3.0) - exp(Float64(log(log(N)) * 3.0))) / fma(t_0, t_0, fma(log(N), log(N), Float64(t_0 * log(N))))); else tmp = Float64(Float64(1.0 - Float64(Float64(0.5 - Float64(Float64(0.3333333333333333 - Float64(0.25 / N)) / N)) / N)) / N); end return tmp end
code[N_] := Block[{t$95$0 = N[Log[N[(N - -1.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N, 850.0], N[(N[(N[Power[t$95$0, 3.0], $MachinePrecision] - N[Exp[N[(N[Log[N[Log[N], $MachinePrecision]], $MachinePrecision] * 3.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 * t$95$0 + N[(N[Log[N], $MachinePrecision] * N[Log[N], $MachinePrecision] + N[(t$95$0 * N[Log[N], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - N[(N[(0.5 - N[(N[(0.3333333333333333 - N[(0.25 / N), $MachinePrecision]), $MachinePrecision] / N), $MachinePrecision]), $MachinePrecision] / N), $MachinePrecision]), $MachinePrecision] / N), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log \left(N - -1\right)\\
\mathbf{if}\;N \leq 850:\\
\;\;\;\;\frac{{t\_0}^{3} - e^{\log \log N \cdot 3}}{\mathsf{fma}\left(t\_0, t\_0, \mathsf{fma}\left(\log N, \log N, t\_0 \cdot \log N\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - \frac{0.5 - \frac{0.3333333333333333 - \frac{0.25}{N}}{N}}{N}}{N}\\
\end{array}
\end{array}
if N < 850Initial program 92.6%
lift-+.f64N/A
lift-log.f64N/A
+-commutativeN/A
lower-log1p.f6492.5
Applied rewrites92.5%
lift--.f64N/A
lift-log1p.f64N/A
lift-log.f64N/A
+-commutativeN/A
metadata-evalN/A
negate-subN/A
flip3--N/A
lower-/.f64N/A
lower--.f64N/A
lower-pow.f64N/A
lift-log.f64N/A
lift--.f64N/A
lower-pow.f64N/A
lift-log.f64N/A
lower-fma.f64N/A
Applied rewrites92.4%
lift-log.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lower-exp.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lift-log.f6491.6
Applied rewrites91.6%
if 850 < N Initial program 18.9%
Taylor expanded in N around -inf
mul-1-negN/A
distribute-neg-fracN/A
lower-/.f64N/A
Applied rewrites99.7%
(FPCore (N)
:precision binary64
(let* ((t_0 (log (- N -1.0))))
(if (<= N 880.0)
(/
(- (pow t_0 3.0) (pow (log N) 3.0))
(fma t_0 t_0 (fma (log N) (log N) (* t_0 (log N)))))
(/ (- 1.0 (/ (- 0.5 (/ (- 0.3333333333333333 (/ 0.25 N)) N)) N)) N))))
double code(double N) {
double t_0 = log((N - -1.0));
double tmp;
if (N <= 880.0) {
tmp = (pow(t_0, 3.0) - pow(log(N), 3.0)) / fma(t_0, t_0, fma(log(N), log(N), (t_0 * log(N))));
} else {
tmp = (1.0 - ((0.5 - ((0.3333333333333333 - (0.25 / N)) / N)) / N)) / N;
}
return tmp;
}
function code(N) t_0 = log(Float64(N - -1.0)) tmp = 0.0 if (N <= 880.0) tmp = Float64(Float64((t_0 ^ 3.0) - (log(N) ^ 3.0)) / fma(t_0, t_0, fma(log(N), log(N), Float64(t_0 * log(N))))); else tmp = Float64(Float64(1.0 - Float64(Float64(0.5 - Float64(Float64(0.3333333333333333 - Float64(0.25 / N)) / N)) / N)) / N); end return tmp end
code[N_] := Block[{t$95$0 = N[Log[N[(N - -1.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N, 880.0], N[(N[(N[Power[t$95$0, 3.0], $MachinePrecision] - N[Power[N[Log[N], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 * t$95$0 + N[(N[Log[N], $MachinePrecision] * N[Log[N], $MachinePrecision] + N[(t$95$0 * N[Log[N], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - N[(N[(0.5 - N[(N[(0.3333333333333333 - N[(0.25 / N), $MachinePrecision]), $MachinePrecision] / N), $MachinePrecision]), $MachinePrecision] / N), $MachinePrecision]), $MachinePrecision] / N), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log \left(N - -1\right)\\
\mathbf{if}\;N \leq 880:\\
\;\;\;\;\frac{{t\_0}^{3} - {\log N}^{3}}{\mathsf{fma}\left(t\_0, t\_0, \mathsf{fma}\left(\log N, \log N, t\_0 \cdot \log N\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - \frac{0.5 - \frac{0.3333333333333333 - \frac{0.25}{N}}{N}}{N}}{N}\\
\end{array}
\end{array}
if N < 880Initial program 92.5%
lift-+.f64N/A
lift-log.f64N/A
+-commutativeN/A
lower-log1p.f6492.5
Applied rewrites92.5%
lift--.f64N/A
lift-log1p.f64N/A
lift-log.f64N/A
+-commutativeN/A
metadata-evalN/A
negate-subN/A
flip3--N/A
lower-/.f64N/A
lower--.f64N/A
lower-pow.f64N/A
lift-log.f64N/A
lift--.f64N/A
lower-pow.f64N/A
lift-log.f64N/A
lower-fma.f64N/A
Applied rewrites92.4%
if 880 < N Initial program 18.8%
Taylor expanded in N around -inf
mul-1-negN/A
distribute-neg-fracN/A
lower-/.f64N/A
Applied rewrites99.7%
(FPCore (N)
:precision binary64
(let* ((t_0 (log (- N -1.0))))
(if (<= N 880.0)
(/
(- (pow t_0 3.0) (pow (log N) 3.0))
(fma (log N) (+ (log N) t_0) (* t_0 t_0)))
(/ (- 1.0 (/ (- 0.5 (/ (- 0.3333333333333333 (/ 0.25 N)) N)) N)) N))))
double code(double N) {
double t_0 = log((N - -1.0));
double tmp;
if (N <= 880.0) {
tmp = (pow(t_0, 3.0) - pow(log(N), 3.0)) / fma(log(N), (log(N) + t_0), (t_0 * t_0));
} else {
tmp = (1.0 - ((0.5 - ((0.3333333333333333 - (0.25 / N)) / N)) / N)) / N;
}
return tmp;
}
function code(N) t_0 = log(Float64(N - -1.0)) tmp = 0.0 if (N <= 880.0) tmp = Float64(Float64((t_0 ^ 3.0) - (log(N) ^ 3.0)) / fma(log(N), Float64(log(N) + t_0), Float64(t_0 * t_0))); else tmp = Float64(Float64(1.0 - Float64(Float64(0.5 - Float64(Float64(0.3333333333333333 - Float64(0.25 / N)) / N)) / N)) / N); end return tmp end
code[N_] := Block[{t$95$0 = N[Log[N[(N - -1.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N, 880.0], N[(N[(N[Power[t$95$0, 3.0], $MachinePrecision] - N[Power[N[Log[N], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision] / N[(N[Log[N], $MachinePrecision] * N[(N[Log[N], $MachinePrecision] + t$95$0), $MachinePrecision] + N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - N[(N[(0.5 - N[(N[(0.3333333333333333 - N[(0.25 / N), $MachinePrecision]), $MachinePrecision] / N), $MachinePrecision]), $MachinePrecision] / N), $MachinePrecision]), $MachinePrecision] / N), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log \left(N - -1\right)\\
\mathbf{if}\;N \leq 880:\\
\;\;\;\;\frac{{t\_0}^{3} - {\log N}^{3}}{\mathsf{fma}\left(\log N, \log N + t\_0, t\_0 \cdot t\_0\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - \frac{0.5 - \frac{0.3333333333333333 - \frac{0.25}{N}}{N}}{N}}{N}\\
\end{array}
\end{array}
if N < 880Initial program 92.5%
lift--.f64N/A
lift-+.f64N/A
lift-log.f64N/A
lift-log.f64N/A
flip3--N/A
lower-/.f64N/A
lower--.f64N/A
lower-pow.f64N/A
lift-log.f64N/A
metadata-evalN/A
negate-sub-reverseN/A
lower--.f64N/A
lower-pow.f64N/A
lift-log.f64N/A
+-commutativeN/A
Applied rewrites92.4%
if 880 < N Initial program 18.8%
Taylor expanded in N around -inf
mul-1-negN/A
distribute-neg-fracN/A
lower-/.f64N/A
Applied rewrites99.7%
(FPCore (N) :precision binary64 (if (<= N 1200.0) (- (log1p N) (log N)) (/ (- 1.0 (/ (- 0.5 (/ (- 0.3333333333333333 (/ 0.25 N)) N)) N)) N)))
double code(double N) {
double tmp;
if (N <= 1200.0) {
tmp = log1p(N) - log(N);
} else {
tmp = (1.0 - ((0.5 - ((0.3333333333333333 - (0.25 / N)) / N)) / N)) / N;
}
return tmp;
}
public static double code(double N) {
double tmp;
if (N <= 1200.0) {
tmp = Math.log1p(N) - Math.log(N);
} else {
tmp = (1.0 - ((0.5 - ((0.3333333333333333 - (0.25 / N)) / N)) / N)) / N;
}
return tmp;
}
def code(N): tmp = 0 if N <= 1200.0: tmp = math.log1p(N) - math.log(N) else: tmp = (1.0 - ((0.5 - ((0.3333333333333333 - (0.25 / N)) / N)) / N)) / N return tmp
function code(N) tmp = 0.0 if (N <= 1200.0) tmp = Float64(log1p(N) - log(N)); else tmp = Float64(Float64(1.0 - Float64(Float64(0.5 - Float64(Float64(0.3333333333333333 - Float64(0.25 / N)) / N)) / N)) / N); end return tmp end
code[N_] := If[LessEqual[N, 1200.0], N[(N[Log[1 + N], $MachinePrecision] - N[Log[N], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - N[(N[(0.5 - N[(N[(0.3333333333333333 - N[(0.25 / N), $MachinePrecision]), $MachinePrecision] / N), $MachinePrecision]), $MachinePrecision] / N), $MachinePrecision]), $MachinePrecision] / N), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;N \leq 1200:\\
\;\;\;\;\mathsf{log1p}\left(N\right) - \log N\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - \frac{0.5 - \frac{0.3333333333333333 - \frac{0.25}{N}}{N}}{N}}{N}\\
\end{array}
\end{array}
if N < 1200Initial program 92.1%
lift-+.f64N/A
lift-log.f64N/A
+-commutativeN/A
lower-log1p.f6492.1
Applied rewrites92.1%
if 1200 < N Initial program 18.6%
Taylor expanded in N around -inf
mul-1-negN/A
distribute-neg-fracN/A
lower-/.f64N/A
Applied rewrites99.7%
(FPCore (N) :precision binary64 (if (<= N 4500.0) (- (log1p N) (log N)) (/ (- 1.0 (/ (- 0.5 (/ 0.3333333333333333 N)) N)) N)))
double code(double N) {
double tmp;
if (N <= 4500.0) {
tmp = log1p(N) - log(N);
} else {
tmp = (1.0 - ((0.5 - (0.3333333333333333 / N)) / N)) / N;
}
return tmp;
}
public static double code(double N) {
double tmp;
if (N <= 4500.0) {
tmp = Math.log1p(N) - Math.log(N);
} else {
tmp = (1.0 - ((0.5 - (0.3333333333333333 / N)) / N)) / N;
}
return tmp;
}
def code(N): tmp = 0 if N <= 4500.0: tmp = math.log1p(N) - math.log(N) else: tmp = (1.0 - ((0.5 - (0.3333333333333333 / N)) / N)) / N return tmp
function code(N) tmp = 0.0 if (N <= 4500.0) tmp = Float64(log1p(N) - log(N)); else tmp = Float64(Float64(1.0 - Float64(Float64(0.5 - Float64(0.3333333333333333 / N)) / N)) / N); end return tmp end
code[N_] := If[LessEqual[N, 4500.0], N[(N[Log[1 + N], $MachinePrecision] - N[Log[N], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - N[(N[(0.5 - N[(0.3333333333333333 / N), $MachinePrecision]), $MachinePrecision] / N), $MachinePrecision]), $MachinePrecision] / N), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;N \leq 4500:\\
\;\;\;\;\mathsf{log1p}\left(N\right) - \log N\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - \frac{0.5 - \frac{0.3333333333333333}{N}}{N}}{N}\\
\end{array}
\end{array}
if N < 4500Initial program 90.3%
lift-+.f64N/A
lift-log.f64N/A
+-commutativeN/A
lower-log1p.f6490.3
Applied rewrites90.3%
if 4500 < N Initial program 17.5%
Taylor expanded in N around inf
negate-sub2N/A
Applied rewrites99.5%
(FPCore (N) :precision binary64 (if (<= N 4500.0) (- (log (- N -1.0)) (log N)) (/ (- 1.0 (/ (- 0.5 (/ 0.3333333333333333 N)) N)) N)))
double code(double N) {
double tmp;
if (N <= 4500.0) {
tmp = log((N - -1.0)) - log(N);
} else {
tmp = (1.0 - ((0.5 - (0.3333333333333333 / N)) / N)) / N;
}
return tmp;
}
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(n)
use fmin_fmax_functions
real(8), intent (in) :: n
real(8) :: tmp
if (n <= 4500.0d0) then
tmp = log((n - (-1.0d0))) - log(n)
else
tmp = (1.0d0 - ((0.5d0 - (0.3333333333333333d0 / n)) / n)) / n
end if
code = tmp
end function
public static double code(double N) {
double tmp;
if (N <= 4500.0) {
tmp = Math.log((N - -1.0)) - Math.log(N);
} else {
tmp = (1.0 - ((0.5 - (0.3333333333333333 / N)) / N)) / N;
}
return tmp;
}
def code(N): tmp = 0 if N <= 4500.0: tmp = math.log((N - -1.0)) - math.log(N) else: tmp = (1.0 - ((0.5 - (0.3333333333333333 / N)) / N)) / N return tmp
function code(N) tmp = 0.0 if (N <= 4500.0) tmp = Float64(log(Float64(N - -1.0)) - log(N)); else tmp = Float64(Float64(1.0 - Float64(Float64(0.5 - Float64(0.3333333333333333 / N)) / N)) / N); end return tmp end
function tmp_2 = code(N) tmp = 0.0; if (N <= 4500.0) tmp = log((N - -1.0)) - log(N); else tmp = (1.0 - ((0.5 - (0.3333333333333333 / N)) / N)) / N; end tmp_2 = tmp; end
code[N_] := If[LessEqual[N, 4500.0], N[(N[Log[N[(N - -1.0), $MachinePrecision]], $MachinePrecision] - N[Log[N], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - N[(N[(0.5 - N[(0.3333333333333333 / N), $MachinePrecision]), $MachinePrecision] / N), $MachinePrecision]), $MachinePrecision] / N), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;N \leq 4500:\\
\;\;\;\;\log \left(N - -1\right) - \log N\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - \frac{0.5 - \frac{0.3333333333333333}{N}}{N}}{N}\\
\end{array}
\end{array}
if N < 4500Initial program 90.3%
lift-+.f64N/A
metadata-evalN/A
negate-sub-reverseN/A
lower--.f6490.3
Applied rewrites90.3%
if 4500 < N Initial program 17.5%
Taylor expanded in N around inf
negate-sub2N/A
Applied rewrites99.5%
(FPCore (N) :precision binary64 (/ (- 1.0 (/ (- 0.5 (/ 0.3333333333333333 N)) N)) N))
double code(double N) {
return (1.0 - ((0.5 - (0.3333333333333333 / N)) / N)) / N;
}
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(n)
use fmin_fmax_functions
real(8), intent (in) :: n
code = (1.0d0 - ((0.5d0 - (0.3333333333333333d0 / n)) / n)) / n
end function
public static double code(double N) {
return (1.0 - ((0.5 - (0.3333333333333333 / N)) / N)) / N;
}
def code(N): return (1.0 - ((0.5 - (0.3333333333333333 / N)) / N)) / N
function code(N) return Float64(Float64(1.0 - Float64(Float64(0.5 - Float64(0.3333333333333333 / N)) / N)) / N) end
function tmp = code(N) tmp = (1.0 - ((0.5 - (0.3333333333333333 / N)) / N)) / N; end
code[N_] := N[(N[(1.0 - N[(N[(0.5 - N[(0.3333333333333333 / N), $MachinePrecision]), $MachinePrecision] / N), $MachinePrecision]), $MachinePrecision] / N), $MachinePrecision]
\begin{array}{l}
\\
\frac{1 - \frac{0.5 - \frac{0.3333333333333333}{N}}{N}}{N}
\end{array}
Initial program 23.9%
Taylor expanded in N around inf
negate-sub2N/A
Applied rewrites95.1%
(FPCore (N) :precision binary64 (/ (- 1.0 (/ 0.5 N)) N))
double code(double N) {
return (1.0 - (0.5 / N)) / N;
}
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(n)
use fmin_fmax_functions
real(8), intent (in) :: n
code = (1.0d0 - (0.5d0 / n)) / n
end function
public static double code(double N) {
return (1.0 - (0.5 / N)) / N;
}
def code(N): return (1.0 - (0.5 / N)) / N
function code(N) return Float64(Float64(1.0 - Float64(0.5 / N)) / N) end
function tmp = code(N) tmp = (1.0 - (0.5 / N)) / N; end
code[N_] := N[(N[(1.0 - N[(0.5 / N), $MachinePrecision]), $MachinePrecision] / N), $MachinePrecision]
\begin{array}{l}
\\
\frac{1 - \frac{0.5}{N}}{N}
\end{array}
Initial program 23.9%
Taylor expanded in N around inf
lower-/.f64N/A
lower--.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f6492.5
Applied rewrites92.5%
(FPCore (N) :precision binary64 (/ (- N 0.5) (* N N)))
double code(double N) {
return (N - 0.5) / (N * N);
}
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(n)
use fmin_fmax_functions
real(8), intent (in) :: n
code = (n - 0.5d0) / (n * n)
end function
public static double code(double N) {
return (N - 0.5) / (N * N);
}
def code(N): return (N - 0.5) / (N * N)
function code(N) return Float64(Float64(N - 0.5) / Float64(N * N)) end
function tmp = code(N) tmp = (N - 0.5) / (N * N); end
code[N_] := N[(N[(N - 0.5), $MachinePrecision] / N[(N * N), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{N - 0.5}{N \cdot N}
\end{array}
Initial program 23.9%
lift--.f64N/A
lift-+.f64N/A
lift-log.f64N/A
lift-log.f64N/A
flip--N/A
lower-/.f64N/A
Applied rewrites23.9%
Taylor expanded in N around inf
lower-/.f64N/A
lower--.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f6492.5
Applied rewrites92.5%
Taylor expanded in N around 0
lower-/.f64N/A
lower--.f64N/A
pow2N/A
lift-*.f6492.2
Applied rewrites92.2%
(FPCore (N) :precision binary64 (/ 1.0 N))
double code(double N) {
return 1.0 / N;
}
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(n)
use fmin_fmax_functions
real(8), intent (in) :: n
code = 1.0d0 / n
end function
public static double code(double N) {
return 1.0 / N;
}
def code(N): return 1.0 / N
function code(N) return Float64(1.0 / N) end
function tmp = code(N) tmp = 1.0 / N; end
code[N_] := N[(1.0 / N), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{N}
\end{array}
Initial program 23.9%
Taylor expanded in N around inf
lower-/.f6484.5
Applied rewrites84.5%
(FPCore (N) :precision binary64 (log1p (/ 1.0 N)))
double code(double N) {
return log1p((1.0 / N));
}
public static double code(double N) {
return Math.log1p((1.0 / N));
}
def code(N): return math.log1p((1.0 / N))
function code(N) return log1p(Float64(1.0 / N)) end
code[N_] := N[Log[1 + N[(1.0 / N), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\mathsf{log1p}\left(\frac{1}{N}\right)
\end{array}
(FPCore (N) :precision binary64 (log (+ 1.0 (/ 1.0 N))))
double code(double N) {
return log((1.0 + (1.0 / N)));
}
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(n)
use fmin_fmax_functions
real(8), intent (in) :: n
code = log((1.0d0 + (1.0d0 / n)))
end function
public static double code(double N) {
return Math.log((1.0 + (1.0 / N)));
}
def code(N): return math.log((1.0 + (1.0 / N)))
function code(N) return log(Float64(1.0 + Float64(1.0 / N))) end
function tmp = code(N) tmp = log((1.0 + (1.0 / N))); end
code[N_] := N[Log[N[(1.0 + N[(1.0 / N), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\log \left(1 + \frac{1}{N}\right)
\end{array}
(FPCore (N) :precision binary64 (+ (+ (+ (/ 1.0 N) (/ -1.0 (* 2.0 (pow N 2.0)))) (/ 1.0 (* 3.0 (pow N 3.0)))) (/ -1.0 (* 4.0 (pow N 4.0)))))
double code(double N) {
return (((1.0 / N) + (-1.0 / (2.0 * pow(N, 2.0)))) + (1.0 / (3.0 * pow(N, 3.0)))) + (-1.0 / (4.0 * pow(N, 4.0)));
}
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(n)
use fmin_fmax_functions
real(8), intent (in) :: n
code = (((1.0d0 / n) + ((-1.0d0) / (2.0d0 * (n ** 2.0d0)))) + (1.0d0 / (3.0d0 * (n ** 3.0d0)))) + ((-1.0d0) / (4.0d0 * (n ** 4.0d0)))
end function
public static double code(double N) {
return (((1.0 / N) + (-1.0 / (2.0 * Math.pow(N, 2.0)))) + (1.0 / (3.0 * Math.pow(N, 3.0)))) + (-1.0 / (4.0 * Math.pow(N, 4.0)));
}
def code(N): return (((1.0 / N) + (-1.0 / (2.0 * math.pow(N, 2.0)))) + (1.0 / (3.0 * math.pow(N, 3.0)))) + (-1.0 / (4.0 * math.pow(N, 4.0)))
function code(N) return Float64(Float64(Float64(Float64(1.0 / N) + Float64(-1.0 / Float64(2.0 * (N ^ 2.0)))) + Float64(1.0 / Float64(3.0 * (N ^ 3.0)))) + Float64(-1.0 / Float64(4.0 * (N ^ 4.0)))) end
function tmp = code(N) tmp = (((1.0 / N) + (-1.0 / (2.0 * (N ^ 2.0)))) + (1.0 / (3.0 * (N ^ 3.0)))) + (-1.0 / (4.0 * (N ^ 4.0))); end
code[N_] := N[(N[(N[(N[(1.0 / N), $MachinePrecision] + N[(-1.0 / N[(2.0 * N[Power[N, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[(3.0 * N[Power[N, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-1.0 / N[(4.0 * N[Power[N, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\frac{1}{N} + \frac{-1}{2 \cdot {N}^{2}}\right) + \frac{1}{3 \cdot {N}^{3}}\right) + \frac{-1}{4 \cdot {N}^{4}}
\end{array}
herbie shell --seed 2025119
(FPCore (N)
:name "2log (problem 3.3.6)"
:precision binary64
:pre (and (> N 1.0) (< N 1e+40))
:alt
(! :herbie-platform c (log1p (/ 1 N)))
:alt
(! :herbie-platform c (log (+ 1 (/ 1 N))))
:alt
(! :herbie-platform c (+ (/ 1 N) (/ -1 (* 2 (pow N 2))) (/ 1 (* 3 (pow N 3))) (/ -1 (* 4 (pow N 4)))))
(- (log (+ N 1.0)) (log N)))