
(FPCore (N) :precision binary64 (- (log (+ N 1.0)) (log N)))
double code(double N) {
return log((N + 1.0)) - log(N);
}
real(8) function code(n)
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}
Sampling outcomes in binary64 precision:
Herbie found 12 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);
}
real(8) function code(n)
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
(if (<= (- (log (+ N 1.0)) (log N)) 0.0006)
(/
-1.0
(/ N (- -1.0 (/ (- -0.5 (/ (+ (/ 0.25 N) -0.3333333333333333) N)) N))))
(exp (log (log (/ (+ N 1.0) N))))))
double code(double N) {
double tmp;
if ((log((N + 1.0)) - log(N)) <= 0.0006) {
tmp = -1.0 / (N / (-1.0 - ((-0.5 - (((0.25 / N) + -0.3333333333333333) / N)) / N)));
} else {
tmp = exp(log(log(((N + 1.0) / N))));
}
return tmp;
}
real(8) function code(n)
real(8), intent (in) :: n
real(8) :: tmp
if ((log((n + 1.0d0)) - log(n)) <= 0.0006d0) then
tmp = (-1.0d0) / (n / ((-1.0d0) - (((-0.5d0) - (((0.25d0 / n) + (-0.3333333333333333d0)) / n)) / n)))
else
tmp = exp(log(log(((n + 1.0d0) / n))))
end if
code = tmp
end function
public static double code(double N) {
double tmp;
if ((Math.log((N + 1.0)) - Math.log(N)) <= 0.0006) {
tmp = -1.0 / (N / (-1.0 - ((-0.5 - (((0.25 / N) + -0.3333333333333333) / N)) / N)));
} else {
tmp = Math.exp(Math.log(Math.log(((N + 1.0) / N))));
}
return tmp;
}
def code(N): tmp = 0 if (math.log((N + 1.0)) - math.log(N)) <= 0.0006: tmp = -1.0 / (N / (-1.0 - ((-0.5 - (((0.25 / N) + -0.3333333333333333) / N)) / N))) else: tmp = math.exp(math.log(math.log(((N + 1.0) / N)))) return tmp
function code(N) tmp = 0.0 if (Float64(log(Float64(N + 1.0)) - log(N)) <= 0.0006) tmp = Float64(-1.0 / Float64(N / Float64(-1.0 - Float64(Float64(-0.5 - Float64(Float64(Float64(0.25 / N) + -0.3333333333333333) / N)) / N)))); else tmp = exp(log(log(Float64(Float64(N + 1.0) / N)))); end return tmp end
function tmp_2 = code(N) tmp = 0.0; if ((log((N + 1.0)) - log(N)) <= 0.0006) tmp = -1.0 / (N / (-1.0 - ((-0.5 - (((0.25 / N) + -0.3333333333333333) / N)) / N))); else tmp = exp(log(log(((N + 1.0) / N)))); end tmp_2 = tmp; end
code[N_] := If[LessEqual[N[(N[Log[N[(N + 1.0), $MachinePrecision]], $MachinePrecision] - N[Log[N], $MachinePrecision]), $MachinePrecision], 0.0006], N[(-1.0 / N[(N / N[(-1.0 - N[(N[(-0.5 - N[(N[(N[(0.25 / N), $MachinePrecision] + -0.3333333333333333), $MachinePrecision] / N), $MachinePrecision]), $MachinePrecision] / N), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Exp[N[Log[N[Log[N[(N[(N + 1.0), $MachinePrecision] / N), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\log \left(N + 1\right) - \log N \leq 0.0006:\\
\;\;\;\;\frac{-1}{\frac{N}{-1 - \frac{-0.5 - \frac{\frac{0.25}{N} + -0.3333333333333333}{N}}{N}}}\\
\mathbf{else}:\\
\;\;\;\;e^{\log \log \left(\frac{N + 1}{N}\right)}\\
\end{array}
\end{array}
if (-.f64 (log.f64 (+.f64 N #s(literal 1 binary64))) (log.f64 N)) < 5.99999999999999947e-4Initial program 15.6%
+-commutative15.6%
log1p-define15.6%
Simplified15.6%
Taylor expanded in N around -inf 99.8%
mul-1-neg99.8%
distribute-neg-frac299.8%
Simplified99.8%
Taylor expanded in N around -inf 99.8%
Simplified99.8%
clear-num99.9%
inv-pow99.9%
Applied egg-rr99.9%
unpow-199.9%
*-lft-identity99.9%
Simplified99.9%
if 5.99999999999999947e-4 < (-.f64 (log.f64 (+.f64 N #s(literal 1 binary64))) (log.f64 N)) Initial program 92.4%
+-commutative92.4%
log1p-define92.7%
Simplified92.7%
add-exp-log92.8%
Applied egg-rr92.8%
add-log-exp92.8%
log1p-expm1-u92.8%
log1p-undefine92.8%
diff-log92.6%
log1p-undefine92.6%
rem-exp-log93.0%
+-commutative93.0%
add-exp-log92.9%
log1p-undefine92.9%
log1p-expm1-u92.9%
add-exp-log94.4%
Applied egg-rr94.4%
Final simplification99.5%
(FPCore (N)
:precision binary64
(if (<= (- (log (+ N 1.0)) (log N)) 0.0006)
(/
-1.0
(/ N (- -1.0 (/ (- -0.5 (/ (+ (/ 0.25 N) -0.3333333333333333) N)) N))))
(log (/ (+ N 1.0) N))))
double code(double N) {
double tmp;
if ((log((N + 1.0)) - log(N)) <= 0.0006) {
tmp = -1.0 / (N / (-1.0 - ((-0.5 - (((0.25 / N) + -0.3333333333333333) / N)) / N)));
} else {
tmp = log(((N + 1.0) / N));
}
return tmp;
}
real(8) function code(n)
real(8), intent (in) :: n
real(8) :: tmp
if ((log((n + 1.0d0)) - log(n)) <= 0.0006d0) then
tmp = (-1.0d0) / (n / ((-1.0d0) - (((-0.5d0) - (((0.25d0 / n) + (-0.3333333333333333d0)) / n)) / n)))
else
tmp = log(((n + 1.0d0) / n))
end if
code = tmp
end function
public static double code(double N) {
double tmp;
if ((Math.log((N + 1.0)) - Math.log(N)) <= 0.0006) {
tmp = -1.0 / (N / (-1.0 - ((-0.5 - (((0.25 / N) + -0.3333333333333333) / N)) / N)));
} else {
tmp = Math.log(((N + 1.0) / N));
}
return tmp;
}
def code(N): tmp = 0 if (math.log((N + 1.0)) - math.log(N)) <= 0.0006: tmp = -1.0 / (N / (-1.0 - ((-0.5 - (((0.25 / N) + -0.3333333333333333) / N)) / N))) else: tmp = math.log(((N + 1.0) / N)) return tmp
function code(N) tmp = 0.0 if (Float64(log(Float64(N + 1.0)) - log(N)) <= 0.0006) tmp = Float64(-1.0 / Float64(N / Float64(-1.0 - Float64(Float64(-0.5 - Float64(Float64(Float64(0.25 / N) + -0.3333333333333333) / N)) / N)))); else tmp = log(Float64(Float64(N + 1.0) / N)); end return tmp end
function tmp_2 = code(N) tmp = 0.0; if ((log((N + 1.0)) - log(N)) <= 0.0006) tmp = -1.0 / (N / (-1.0 - ((-0.5 - (((0.25 / N) + -0.3333333333333333) / N)) / N))); else tmp = log(((N + 1.0) / N)); end tmp_2 = tmp; end
code[N_] := If[LessEqual[N[(N[Log[N[(N + 1.0), $MachinePrecision]], $MachinePrecision] - N[Log[N], $MachinePrecision]), $MachinePrecision], 0.0006], N[(-1.0 / N[(N / N[(-1.0 - N[(N[(-0.5 - N[(N[(N[(0.25 / N), $MachinePrecision] + -0.3333333333333333), $MachinePrecision] / N), $MachinePrecision]), $MachinePrecision] / N), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Log[N[(N[(N + 1.0), $MachinePrecision] / N), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\log \left(N + 1\right) - \log N \leq 0.0006:\\
\;\;\;\;\frac{-1}{\frac{N}{-1 - \frac{-0.5 - \frac{\frac{0.25}{N} + -0.3333333333333333}{N}}{N}}}\\
\mathbf{else}:\\
\;\;\;\;\log \left(\frac{N + 1}{N}\right)\\
\end{array}
\end{array}
if (-.f64 (log.f64 (+.f64 N #s(literal 1 binary64))) (log.f64 N)) < 5.99999999999999947e-4Initial program 15.6%
+-commutative15.6%
log1p-define15.6%
Simplified15.6%
Taylor expanded in N around -inf 99.8%
mul-1-neg99.8%
distribute-neg-frac299.8%
Simplified99.8%
Taylor expanded in N around -inf 99.8%
Simplified99.8%
clear-num99.9%
inv-pow99.9%
Applied egg-rr99.9%
unpow-199.9%
*-lft-identity99.9%
Simplified99.9%
if 5.99999999999999947e-4 < (-.f64 (log.f64 (+.f64 N #s(literal 1 binary64))) (log.f64 N)) Initial program 92.4%
+-commutative92.4%
log1p-define92.7%
Simplified92.7%
add-log-exp92.8%
log1p-expm1-u92.8%
log1p-undefine92.8%
diff-log92.6%
log1p-undefine92.6%
rem-exp-log93.0%
+-commutative93.0%
add-exp-log92.9%
log1p-undefine92.9%
log1p-expm1-u92.9%
add-exp-log94.4%
Applied egg-rr94.3%
Final simplification99.5%
(FPCore (N) :precision binary64 (/ -1.0 (/ N (- -1.0 (/ (- -0.5 (/ (+ (/ 0.25 N) -0.3333333333333333) N)) N)))))
double code(double N) {
return -1.0 / (N / (-1.0 - ((-0.5 - (((0.25 / N) + -0.3333333333333333) / N)) / N)));
}
real(8) function code(n)
real(8), intent (in) :: n
code = (-1.0d0) / (n / ((-1.0d0) - (((-0.5d0) - (((0.25d0 / n) + (-0.3333333333333333d0)) / n)) / n)))
end function
public static double code(double N) {
return -1.0 / (N / (-1.0 - ((-0.5 - (((0.25 / N) + -0.3333333333333333) / N)) / N)));
}
def code(N): return -1.0 / (N / (-1.0 - ((-0.5 - (((0.25 / N) + -0.3333333333333333) / N)) / N)))
function code(N) return Float64(-1.0 / Float64(N / Float64(-1.0 - Float64(Float64(-0.5 - Float64(Float64(Float64(0.25 / N) + -0.3333333333333333) / N)) / N)))) end
function tmp = code(N) tmp = -1.0 / (N / (-1.0 - ((-0.5 - (((0.25 / N) + -0.3333333333333333) / N)) / N))); end
code[N_] := N[(-1.0 / N[(N / N[(-1.0 - N[(N[(-0.5 - N[(N[(N[(0.25 / N), $MachinePrecision] + -0.3333333333333333), $MachinePrecision] / N), $MachinePrecision]), $MachinePrecision] / N), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{-1}{\frac{N}{-1 - \frac{-0.5 - \frac{\frac{0.25}{N} + -0.3333333333333333}{N}}{N}}}
\end{array}
Initial program 21.3%
+-commutative21.3%
log1p-define21.3%
Simplified21.3%
Taylor expanded in N around -inf 96.3%
mul-1-neg96.3%
distribute-neg-frac296.3%
Simplified96.3%
Taylor expanded in N around -inf 96.3%
Simplified96.3%
clear-num96.4%
inv-pow96.4%
Applied egg-rr96.4%
unpow-196.4%
*-lft-identity96.4%
Simplified96.4%
Final simplification96.4%
(FPCore (N) :precision binary64 (* (- -1.0 (/ (- -0.5 (/ (+ (/ 0.25 N) -0.3333333333333333) N)) N)) (/ -1.0 N)))
double code(double N) {
return (-1.0 - ((-0.5 - (((0.25 / N) + -0.3333333333333333) / N)) / N)) * (-1.0 / N);
}
real(8) function code(n)
real(8), intent (in) :: n
code = ((-1.0d0) - (((-0.5d0) - (((0.25d0 / n) + (-0.3333333333333333d0)) / n)) / n)) * ((-1.0d0) / n)
end function
public static double code(double N) {
return (-1.0 - ((-0.5 - (((0.25 / N) + -0.3333333333333333) / N)) / N)) * (-1.0 / N);
}
def code(N): return (-1.0 - ((-0.5 - (((0.25 / N) + -0.3333333333333333) / N)) / N)) * (-1.0 / N)
function code(N) return Float64(Float64(-1.0 - Float64(Float64(-0.5 - Float64(Float64(Float64(0.25 / N) + -0.3333333333333333) / N)) / N)) * Float64(-1.0 / N)) end
function tmp = code(N) tmp = (-1.0 - ((-0.5 - (((0.25 / N) + -0.3333333333333333) / N)) / N)) * (-1.0 / N); end
code[N_] := N[(N[(-1.0 - N[(N[(-0.5 - N[(N[(N[(0.25 / N), $MachinePrecision] + -0.3333333333333333), $MachinePrecision] / N), $MachinePrecision]), $MachinePrecision] / N), $MachinePrecision]), $MachinePrecision] * N[(-1.0 / N), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(-1 - \frac{-0.5 - \frac{\frac{0.25}{N} + -0.3333333333333333}{N}}{N}\right) \cdot \frac{-1}{N}
\end{array}
Initial program 21.3%
+-commutative21.3%
log1p-define21.3%
Simplified21.3%
Taylor expanded in N around -inf 96.3%
mul-1-neg96.3%
distribute-neg-frac296.3%
Simplified96.3%
div-inv96.3%
add-sqr-sqrt0.0%
sqrt-unprod1.7%
sqr-neg1.7%
sqrt-prod1.7%
add-sqr-sqrt1.7%
frac-2neg1.7%
metadata-eval1.7%
add-sqr-sqrt0.0%
sqrt-unprod96.3%
sqr-neg96.3%
sqrt-prod95.6%
add-sqr-sqrt96.3%
Applied egg-rr96.3%
(FPCore (N) :precision binary64 (/ (+ (/ (+ -0.5 (/ (+ 0.3333333333333333 (/ -0.25 N)) N)) N) 1.0) N))
double code(double N) {
return (((-0.5 + ((0.3333333333333333 + (-0.25 / N)) / N)) / N) + 1.0) / N;
}
real(8) function code(n)
real(8), intent (in) :: n
code = ((((-0.5d0) + ((0.3333333333333333d0 + ((-0.25d0) / n)) / n)) / n) + 1.0d0) / n
end function
public static double code(double N) {
return (((-0.5 + ((0.3333333333333333 + (-0.25 / N)) / N)) / N) + 1.0) / N;
}
def code(N): return (((-0.5 + ((0.3333333333333333 + (-0.25 / N)) / N)) / N) + 1.0) / N
function code(N) return Float64(Float64(Float64(Float64(-0.5 + Float64(Float64(0.3333333333333333 + Float64(-0.25 / N)) / N)) / N) + 1.0) / N) end
function tmp = code(N) tmp = (((-0.5 + ((0.3333333333333333 + (-0.25 / N)) / N)) / N) + 1.0) / N; end
code[N_] := N[(N[(N[(N[(-0.5 + N[(N[(0.3333333333333333 + N[(-0.25 / N), $MachinePrecision]), $MachinePrecision] / N), $MachinePrecision]), $MachinePrecision] / N), $MachinePrecision] + 1.0), $MachinePrecision] / N), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{-0.5 + \frac{0.3333333333333333 + \frac{-0.25}{N}}{N}}{N} + 1}{N}
\end{array}
Initial program 21.3%
+-commutative21.3%
log1p-define21.3%
Simplified21.3%
Taylor expanded in N around -inf 96.3%
mul-1-neg96.3%
distribute-neg-frac296.3%
Simplified96.3%
Taylor expanded in N around -inf 96.3%
Simplified96.3%
Final simplification96.3%
(FPCore (N) :precision binary64 (* (/ -1.0 N) (+ -1.0 (/ (- (/ -0.3333333333333333 N) -0.5) N))))
double code(double N) {
return (-1.0 / N) * (-1.0 + (((-0.3333333333333333 / N) - -0.5) / N));
}
real(8) function code(n)
real(8), intent (in) :: n
code = ((-1.0d0) / n) * ((-1.0d0) + ((((-0.3333333333333333d0) / n) - (-0.5d0)) / n))
end function
public static double code(double N) {
return (-1.0 / N) * (-1.0 + (((-0.3333333333333333 / N) - -0.5) / N));
}
def code(N): return (-1.0 / N) * (-1.0 + (((-0.3333333333333333 / N) - -0.5) / N))
function code(N) return Float64(Float64(-1.0 / N) * Float64(-1.0 + Float64(Float64(Float64(-0.3333333333333333 / N) - -0.5) / N))) end
function tmp = code(N) tmp = (-1.0 / N) * (-1.0 + (((-0.3333333333333333 / N) - -0.5) / N)); end
code[N_] := N[(N[(-1.0 / N), $MachinePrecision] * N[(-1.0 + N[(N[(N[(-0.3333333333333333 / N), $MachinePrecision] - -0.5), $MachinePrecision] / N), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{-1}{N} \cdot \left(-1 + \frac{\frac{-0.3333333333333333}{N} - -0.5}{N}\right)
\end{array}
Initial program 21.3%
+-commutative21.3%
log1p-define21.3%
Simplified21.3%
Taylor expanded in N around -inf 96.3%
mul-1-neg96.3%
distribute-neg-frac296.3%
Simplified96.3%
div-inv96.3%
add-sqr-sqrt0.0%
sqrt-unprod1.7%
sqr-neg1.7%
sqrt-prod1.7%
add-sqr-sqrt1.7%
frac-2neg1.7%
metadata-eval1.7%
add-sqr-sqrt0.0%
sqrt-unprod96.3%
sqr-neg96.3%
sqrt-prod95.6%
add-sqr-sqrt96.3%
Applied egg-rr96.3%
Taylor expanded in N around inf 95.2%
Final simplification95.2%
(FPCore (N) :precision binary64 (/ (+ (/ (+ -0.5 (/ 0.3333333333333333 N)) N) 1.0) N))
double code(double N) {
return (((-0.5 + (0.3333333333333333 / N)) / N) + 1.0) / N;
}
real(8) function code(n)
real(8), intent (in) :: n
code = ((((-0.5d0) + (0.3333333333333333d0 / n)) / n) + 1.0d0) / n
end function
public static double code(double N) {
return (((-0.5 + (0.3333333333333333 / N)) / N) + 1.0) / N;
}
def code(N): return (((-0.5 + (0.3333333333333333 / N)) / N) + 1.0) / N
function code(N) return Float64(Float64(Float64(Float64(-0.5 + Float64(0.3333333333333333 / N)) / N) + 1.0) / N) end
function tmp = code(N) tmp = (((-0.5 + (0.3333333333333333 / N)) / N) + 1.0) / N; end
code[N_] := N[(N[(N[(N[(-0.5 + N[(0.3333333333333333 / N), $MachinePrecision]), $MachinePrecision] / N), $MachinePrecision] + 1.0), $MachinePrecision] / N), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{-0.5 + \frac{0.3333333333333333}{N}}{N} + 1}{N}
\end{array}
Initial program 21.3%
+-commutative21.3%
log1p-define21.3%
Simplified21.3%
Taylor expanded in N around inf 95.1%
associate--l+95.2%
unpow295.2%
associate-/r*95.2%
metadata-eval95.2%
associate-*r/95.2%
associate-*r/95.2%
metadata-eval95.2%
div-sub95.2%
sub-neg95.2%
metadata-eval95.2%
+-commutative95.2%
associate-*r/95.2%
metadata-eval95.2%
Simplified95.2%
Final simplification95.2%
(FPCore (N) :precision binary64 (* (/ -1.0 N) (- -1.0 (/ -0.5 N))))
double code(double N) {
return (-1.0 / N) * (-1.0 - (-0.5 / N));
}
real(8) function code(n)
real(8), intent (in) :: n
code = ((-1.0d0) / n) * ((-1.0d0) - ((-0.5d0) / n))
end function
public static double code(double N) {
return (-1.0 / N) * (-1.0 - (-0.5 / N));
}
def code(N): return (-1.0 / N) * (-1.0 - (-0.5 / N))
function code(N) return Float64(Float64(-1.0 / N) * Float64(-1.0 - Float64(-0.5 / N))) end
function tmp = code(N) tmp = (-1.0 / N) * (-1.0 - (-0.5 / N)); end
code[N_] := N[(N[(-1.0 / N), $MachinePrecision] * N[(-1.0 - N[(-0.5 / N), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{-1}{N} \cdot \left(-1 - \frac{-0.5}{N}\right)
\end{array}
Initial program 21.3%
+-commutative21.3%
log1p-define21.3%
Simplified21.3%
Taylor expanded in N around -inf 96.3%
mul-1-neg96.3%
distribute-neg-frac296.3%
Simplified96.3%
div-inv96.3%
add-sqr-sqrt0.0%
sqrt-unprod1.7%
sqr-neg1.7%
sqrt-prod1.7%
add-sqr-sqrt1.7%
frac-2neg1.7%
metadata-eval1.7%
add-sqr-sqrt0.0%
sqrt-unprod96.3%
sqr-neg96.3%
sqrt-prod95.6%
add-sqr-sqrt96.3%
Applied egg-rr96.3%
Taylor expanded in N around inf 93.0%
Final simplification93.0%
(FPCore (N) :precision binary64 (/ (- 1.0 (/ 0.5 N)) N))
double code(double N) {
return (1.0 - (0.5 / N)) / N;
}
real(8) function code(n)
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 21.3%
+-commutative21.3%
log1p-define21.3%
Simplified21.3%
Taylor expanded in N around inf 93.0%
associate-*r/93.0%
metadata-eval93.0%
Simplified93.0%
(FPCore (N) :precision binary64 (/ 1.0 N))
double code(double N) {
return 1.0 / N;
}
real(8) function code(n)
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 21.3%
+-commutative21.3%
log1p-define21.3%
Simplified21.3%
Taylor expanded in N around inf 86.2%
(FPCore (N) :precision binary64 (+ N -0.5))
double code(double N) {
return N + -0.5;
}
real(8) function code(n)
real(8), intent (in) :: n
code = n + (-0.5d0)
end function
public static double code(double N) {
return N + -0.5;
}
def code(N): return N + -0.5
function code(N) return Float64(N + -0.5) end
function tmp = code(N) tmp = N + -0.5; end
code[N_] := N[(N + -0.5), $MachinePrecision]
\begin{array}{l}
\\
N + -0.5
\end{array}
Initial program 21.3%
+-commutative21.3%
log1p-define21.3%
Simplified21.3%
Taylor expanded in N around inf 93.0%
associate-*r/93.0%
metadata-eval93.0%
Simplified93.0%
div-sub93.0%
rem-exp-log88.6%
neg-log88.6%
add-sqr-sqrt0.0%
sqrt-unprod8.3%
sqr-neg8.3%
unpow28.3%
sqrt-pow18.3%
metadata-eval8.3%
pow18.3%
add-exp-log8.3%
Applied egg-rr8.3%
associate-/l*8.3%
*-inverses8.3%
cancel-sign-sub-inv8.3%
metadata-eval8.3%
metadata-eval8.3%
Simplified8.3%
(FPCore (N) :precision binary64 N)
double code(double N) {
return N;
}
real(8) function code(n)
real(8), intent (in) :: n
code = n
end function
public static double code(double N) {
return N;
}
def code(N): return N
function code(N) return N end
function tmp = code(N) tmp = N; end
code[N_] := N
\begin{array}{l}
\\
N
\end{array}
Initial program 21.3%
+-commutative21.3%
log1p-define21.3%
Simplified21.3%
Taylor expanded in N around inf 93.0%
associate-*r/93.0%
metadata-eval93.0%
Simplified93.0%
div-sub93.0%
rem-exp-log88.6%
neg-log88.6%
add-sqr-sqrt0.0%
sqrt-unprod8.3%
sqr-neg8.3%
unpow28.3%
sqrt-pow18.3%
metadata-eval8.3%
pow18.3%
add-exp-log8.3%
Applied egg-rr8.3%
associate-/l*8.3%
*-inverses8.3%
cancel-sign-sub-inv8.3%
metadata-eval8.3%
metadata-eval8.3%
Simplified8.3%
Taylor expanded in N around inf 8.3%
(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)));
}
real(8) function code(n)
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)));
}
real(8) function code(n)
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 2024181
(FPCore (N)
:name "2log (problem 3.3.6)"
:precision binary64
:pre (and (> N 1.0) (< N 1e+40))
:alt
(! :herbie-platform default (log1p (/ 1 N)))
:alt
(! :herbie-platform default (log (+ 1 (/ 1 N))))
:alt
(! :herbie-platform default (+ (/ 1 N) (/ -1 (* 2 (pow N 2))) (/ 1 (* 3 (pow N 3))) (/ -1 (* 4 (pow N 4)))))
(- (log (+ N 1.0)) (log N)))