
(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 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);
}
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.0005)
(/
-1.0
(/ N (- -1.0 (/ (- -0.5 (/ (- (/ 0.25 N) 0.3333333333333333) N)) N))))
(- (log (/ N (+ N 1.0))))))
double code(double N) {
double tmp;
if ((log((N + 1.0)) - log(N)) <= 0.0005) {
tmp = -1.0 / (N / (-1.0 - ((-0.5 - (((0.25 / N) - 0.3333333333333333) / N)) / N)));
} else {
tmp = -log((N / (N + 1.0)));
}
return tmp;
}
real(8) function code(n)
real(8), intent (in) :: n
real(8) :: tmp
if ((log((n + 1.0d0)) - log(n)) <= 0.0005d0) then
tmp = (-1.0d0) / (n / ((-1.0d0) - (((-0.5d0) - (((0.25d0 / n) - 0.3333333333333333d0) / n)) / n)))
else
tmp = -log((n / (n + 1.0d0)))
end if
code = tmp
end function
public static double code(double N) {
double tmp;
if ((Math.log((N + 1.0)) - Math.log(N)) <= 0.0005) {
tmp = -1.0 / (N / (-1.0 - ((-0.5 - (((0.25 / N) - 0.3333333333333333) / N)) / N)));
} else {
tmp = -Math.log((N / (N + 1.0)));
}
return tmp;
}
def code(N): tmp = 0 if (math.log((N + 1.0)) - math.log(N)) <= 0.0005: tmp = -1.0 / (N / (-1.0 - ((-0.5 - (((0.25 / N) - 0.3333333333333333) / N)) / N))) else: tmp = -math.log((N / (N + 1.0))) return tmp
function code(N) tmp = 0.0 if (Float64(log(Float64(N + 1.0)) - log(N)) <= 0.0005) 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 = Float64(-log(Float64(N / Float64(N + 1.0)))); end return tmp end
function tmp_2 = code(N) tmp = 0.0; if ((log((N + 1.0)) - log(N)) <= 0.0005) tmp = -1.0 / (N / (-1.0 - ((-0.5 - (((0.25 / N) - 0.3333333333333333) / N)) / N))); else tmp = -log((N / (N + 1.0))); end tmp_2 = tmp; end
code[N_] := If[LessEqual[N[(N[Log[N[(N + 1.0), $MachinePrecision]], $MachinePrecision] - N[Log[N], $MachinePrecision]), $MachinePrecision], 0.0005], 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[(N + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\log \left(N + 1\right) - \log N \leq 0.0005:\\
\;\;\;\;\frac{-1}{\frac{N}{-1 - \frac{-0.5 - \frac{\frac{0.25}{N} - 0.3333333333333333}{N}}{N}}}\\
\mathbf{else}:\\
\;\;\;\;-\log \left(\frac{N}{N + 1}\right)\\
\end{array}
\end{array}
if (-.f64 (log.f64 (+.f64 N #s(literal 1 binary64))) (log.f64 N)) < 5.0000000000000001e-4Initial program 17.2%
+-commutative17.2%
log1p-define17.2%
Simplified17.2%
Taylor expanded in N around inf 99.8%
Simplified99.8%
Taylor expanded in N around -inf 99.8%
mul-1-neg99.8%
unsub-neg99.8%
Simplified99.8%
clear-num99.9%
inv-pow99.9%
+-commutative99.9%
Applied egg-rr99.9%
Simplified99.9%
if 5.0000000000000001e-4 < (-.f64 (log.f64 (+.f64 N #s(literal 1 binary64))) (log.f64 N)) Initial program 90.4%
+-commutative90.4%
log1p-define90.4%
Simplified90.4%
add-log-exp90.4%
log1p-expm1-u90.4%
log1p-undefine90.4%
diff-log90.5%
log1p-undefine90.5%
rem-exp-log90.3%
+-commutative90.3%
add-exp-log90.4%
log1p-undefine90.4%
log1p-expm1-u90.4%
add-exp-log93.2%
Applied egg-rr93.2%
clear-num93.2%
log-div93.9%
metadata-eval93.9%
Applied egg-rr93.9%
neg-sub093.9%
Simplified93.9%
Final simplification99.4%
(FPCore (N)
:precision binary64
(if (<= N 1600.0)
(log (+ 1.0 (/ 1.0 N)))
(/
-1.0
(/ N (- -1.0 (/ (- -0.5 (/ (- (/ 0.25 N) 0.3333333333333333) N)) N))))))
double code(double N) {
double tmp;
if (N <= 1600.0) {
tmp = log((1.0 + (1.0 / N)));
} else {
tmp = -1.0 / (N / (-1.0 - ((-0.5 - (((0.25 / N) - 0.3333333333333333) / N)) / N)));
}
return tmp;
}
real(8) function code(n)
real(8), intent (in) :: n
real(8) :: tmp
if (n <= 1600.0d0) then
tmp = log((1.0d0 + (1.0d0 / n)))
else
tmp = (-1.0d0) / (n / ((-1.0d0) - (((-0.5d0) - (((0.25d0 / n) - 0.3333333333333333d0) / n)) / n)))
end if
code = tmp
end function
public static double code(double N) {
double tmp;
if (N <= 1600.0) {
tmp = Math.log((1.0 + (1.0 / N)));
} else {
tmp = -1.0 / (N / (-1.0 - ((-0.5 - (((0.25 / N) - 0.3333333333333333) / N)) / N)));
}
return tmp;
}
def code(N): tmp = 0 if N <= 1600.0: tmp = math.log((1.0 + (1.0 / N))) else: tmp = -1.0 / (N / (-1.0 - ((-0.5 - (((0.25 / N) - 0.3333333333333333) / N)) / N))) return tmp
function code(N) tmp = 0.0 if (N <= 1600.0) tmp = log(Float64(1.0 + Float64(1.0 / N))); else tmp = Float64(-1.0 / Float64(N / Float64(-1.0 - Float64(Float64(-0.5 - Float64(Float64(Float64(0.25 / N) - 0.3333333333333333) / N)) / N)))); end return tmp end
function tmp_2 = code(N) tmp = 0.0; if (N <= 1600.0) tmp = log((1.0 + (1.0 / N))); else tmp = -1.0 / (N / (-1.0 - ((-0.5 - (((0.25 / N) - 0.3333333333333333) / N)) / N))); end tmp_2 = tmp; end
code[N_] := If[LessEqual[N, 1600.0], N[Log[N[(1.0 + N[(1.0 / N), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 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}
\\
\begin{array}{l}
\mathbf{if}\;N \leq 1600:\\
\;\;\;\;\log \left(1 + \frac{1}{N}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{\frac{N}{-1 - \frac{-0.5 - \frac{\frac{0.25}{N} - 0.3333333333333333}{N}}{N}}}\\
\end{array}
\end{array}
if N < 1600Initial program 90.4%
+-commutative90.4%
log1p-define90.4%
Simplified90.4%
add-log-exp90.4%
log1p-expm1-u90.4%
log1p-undefine90.4%
diff-log90.5%
log1p-undefine90.5%
rem-exp-log90.3%
+-commutative90.3%
add-exp-log90.4%
log1p-undefine90.4%
log1p-expm1-u90.4%
add-exp-log93.2%
Applied egg-rr93.2%
Taylor expanded in N around 0 93.2%
metadata-eval93.2%
remove-double-neg93.2%
distribute-neg-in93.2%
distribute-neg-frac93.2%
distribute-neg-frac293.2%
*-rgt-identity93.2%
associate-*r/93.0%
*-commutative93.0%
+-commutative93.0%
distribute-rgt-in92.9%
*-rgt-identity92.9%
distribute-rgt-neg-in92.9%
metadata-eval92.9%
associate-*r*92.9%
mul-1-neg92.9%
distribute-frac-neg292.9%
remove-double-neg92.9%
rgt-mult-inverse93.4%
associate-*r/93.4%
metadata-eval93.4%
distribute-neg-frac293.4%
distribute-neg-frac93.4%
metadata-eval93.4%
Simplified93.4%
if 1600 < N Initial program 17.2%
+-commutative17.2%
log1p-define17.2%
Simplified17.2%
Taylor expanded in N around inf 99.8%
Simplified99.8%
Taylor expanded in N around -inf 99.8%
mul-1-neg99.8%
unsub-neg99.8%
Simplified99.8%
clear-num99.9%
inv-pow99.9%
+-commutative99.9%
Applied egg-rr99.9%
Simplified99.9%
Final simplification99.4%
(FPCore (N)
:precision binary64
(/
1.0
(*
N
(+
1.0
(/
(+ 0.5 (/ (- (* (/ 1.0 N) 0.041666666666666664) 0.08333333333333333) N))
N)))))
double code(double N) {
return 1.0 / (N * (1.0 + ((0.5 + ((((1.0 / N) * 0.041666666666666664) - 0.08333333333333333) / N)) / N)));
}
real(8) function code(n)
real(8), intent (in) :: n
code = 1.0d0 / (n * (1.0d0 + ((0.5d0 + ((((1.0d0 / n) * 0.041666666666666664d0) - 0.08333333333333333d0) / n)) / n)))
end function
public static double code(double N) {
return 1.0 / (N * (1.0 + ((0.5 + ((((1.0 / N) * 0.041666666666666664) - 0.08333333333333333) / N)) / N)));
}
def code(N): return 1.0 / (N * (1.0 + ((0.5 + ((((1.0 / N) * 0.041666666666666664) - 0.08333333333333333) / N)) / N)))
function code(N) return Float64(1.0 / Float64(N * Float64(1.0 + Float64(Float64(0.5 + Float64(Float64(Float64(Float64(1.0 / N) * 0.041666666666666664) - 0.08333333333333333) / N)) / N)))) end
function tmp = code(N) tmp = 1.0 / (N * (1.0 + ((0.5 + ((((1.0 / N) * 0.041666666666666664) - 0.08333333333333333) / N)) / N))); end
code[N_] := N[(1.0 / N[(N * N[(1.0 + N[(N[(0.5 + N[(N[(N[(N[(1.0 / N), $MachinePrecision] * 0.041666666666666664), $MachinePrecision] - 0.08333333333333333), $MachinePrecision] / N), $MachinePrecision]), $MachinePrecision] / N), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{N \cdot \left(1 + \frac{0.5 + \frac{\frac{1}{N} \cdot 0.041666666666666664 - 0.08333333333333333}{N}}{N}\right)}
\end{array}
Initial program 22.9%
+-commutative22.9%
log1p-define22.9%
Simplified22.9%
Taylor expanded in N around inf 96.6%
Simplified96.7%
Taylor expanded in N around -inf 96.7%
mul-1-neg96.7%
unsub-neg96.7%
Simplified96.7%
clear-num96.7%
inv-pow96.7%
+-commutative96.7%
Applied egg-rr96.7%
Simplified96.7%
Taylor expanded in N around -inf 97.0%
Final simplification97.0%
(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 22.9%
+-commutative22.9%
log1p-define22.9%
Simplified22.9%
Taylor expanded in N around inf 96.6%
Simplified96.7%
Taylor expanded in N around -inf 96.7%
mul-1-neg96.7%
unsub-neg96.7%
Simplified96.7%
clear-num96.7%
inv-pow96.7%
+-commutative96.7%
Applied egg-rr96.7%
Simplified96.7%
Final simplification96.7%
(FPCore (N) :precision binary64 (/ (- 1.0 (/ (+ 0.5 (/ (+ (/ 0.25 N) -0.3333333333333333) N)) N)) N))
double code(double N) {
return (1.0 - ((0.5 + (((0.25 / N) + -0.3333333333333333) / N)) / N)) / N;
}
real(8) function code(n)
real(8), intent (in) :: n
code = (1.0d0 - ((0.5d0 + (((0.25d0 / n) + (-0.3333333333333333d0)) / n)) / n)) / n
end function
public static double code(double N) {
return (1.0 - ((0.5 + (((0.25 / N) + -0.3333333333333333) / N)) / N)) / N;
}
def code(N): return (1.0 - ((0.5 + (((0.25 / N) + -0.3333333333333333) / N)) / N)) / N
function code(N) return Float64(Float64(1.0 - Float64(Float64(0.5 + Float64(Float64(Float64(0.25 / N) + -0.3333333333333333) / N)) / N)) / N) end
function tmp = code(N) tmp = (1.0 - ((0.5 + (((0.25 / N) + -0.3333333333333333) / N)) / N)) / 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), $MachinePrecision]
\begin{array}{l}
\\
\frac{1 - \frac{0.5 + \frac{\frac{0.25}{N} + -0.3333333333333333}{N}}{N}}{N}
\end{array}
Initial program 22.9%
+-commutative22.9%
log1p-define22.9%
Simplified22.9%
Taylor expanded in N around inf 96.6%
Simplified96.7%
Taylor expanded in N around -inf 96.7%
mul-1-neg96.7%
unsub-neg96.7%
Simplified96.7%
Final simplification96.7%
(FPCore (N) :precision binary64 (/ -1.0 (* N (- -1.0 (/ (+ 0.5 (/ -0.08333333333333333 N)) N)))))
double code(double N) {
return -1.0 / (N * (-1.0 - ((0.5 + (-0.08333333333333333 / N)) / N)));
}
real(8) function code(n)
real(8), intent (in) :: n
code = (-1.0d0) / (n * ((-1.0d0) - ((0.5d0 + ((-0.08333333333333333d0) / n)) / n)))
end function
public static double code(double N) {
return -1.0 / (N * (-1.0 - ((0.5 + (-0.08333333333333333 / N)) / N)));
}
def code(N): return -1.0 / (N * (-1.0 - ((0.5 + (-0.08333333333333333 / N)) / N)))
function code(N) return Float64(-1.0 / Float64(N * Float64(-1.0 - Float64(Float64(0.5 + Float64(-0.08333333333333333 / N)) / N)))) end
function tmp = code(N) tmp = -1.0 / (N * (-1.0 - ((0.5 + (-0.08333333333333333 / N)) / N))); end
code[N_] := N[(-1.0 / N[(N * N[(-1.0 - N[(N[(0.5 + N[(-0.08333333333333333 / N), $MachinePrecision]), $MachinePrecision] / N), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{-1}{N \cdot \left(-1 - \frac{0.5 + \frac{-0.08333333333333333}{N}}{N}\right)}
\end{array}
Initial program 22.9%
+-commutative22.9%
log1p-define22.9%
Simplified22.9%
Taylor expanded in N around inf 96.6%
Simplified96.7%
Taylor expanded in N around -inf 96.7%
mul-1-neg96.7%
unsub-neg96.7%
Simplified96.7%
clear-num96.7%
inv-pow96.7%
+-commutative96.7%
Applied egg-rr96.7%
Simplified96.7%
Taylor expanded in N around inf 95.8%
associate--l+95.8%
associate-*r/95.8%
metadata-eval95.8%
unpow295.8%
associate-/r*95.8%
metadata-eval95.8%
associate-*r/95.8%
div-sub95.8%
sub-neg95.8%
associate-*r/95.8%
metadata-eval95.8%
distribute-neg-frac95.8%
metadata-eval95.8%
Simplified95.8%
Final simplification95.8%
(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;
}
real(8) function code(n)
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 22.9%
+-commutative22.9%
log1p-define22.9%
Simplified22.9%
Taylor expanded in N around inf 95.3%
associate--l+95.3%
unpow295.3%
associate-/r*95.3%
metadata-eval95.3%
associate-*r/95.3%
associate-*r/95.3%
metadata-eval95.3%
div-sub95.3%
sub-neg95.3%
metadata-eval95.3%
+-commutative95.3%
associate-*r/95.3%
metadata-eval95.3%
Simplified95.3%
(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(-1.0 / Float64(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[(-1.0 / N[(N * N[(-1.0 - N[(0.5 / N), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{-1}{N \cdot \left(-1 - \frac{0.5}{N}\right)}
\end{array}
Initial program 22.9%
+-commutative22.9%
log1p-define22.9%
Simplified22.9%
Taylor expanded in N around inf 96.6%
Simplified96.7%
Taylor expanded in N around -inf 96.7%
mul-1-neg96.7%
unsub-neg96.7%
Simplified96.7%
clear-num96.7%
inv-pow96.7%
+-commutative96.7%
Applied egg-rr96.7%
Simplified96.7%
Taylor expanded in N around inf 93.3%
associate-*r/93.3%
metadata-eval93.3%
Simplified93.3%
Final simplification93.3%
(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 22.9%
+-commutative22.9%
log1p-define22.9%
Simplified22.9%
Taylor expanded in N around inf 92.7%
associate-*r/92.7%
metadata-eval92.7%
Simplified92.7%
(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 22.9%
+-commutative22.9%
log1p-define22.9%
Simplified22.9%
Taylor expanded in N around inf 85.0%
(FPCore (N) :precision binary64 0.0)
double code(double N) {
return 0.0;
}
real(8) function code(n)
real(8), intent (in) :: n
code = 0.0d0
end function
public static double code(double N) {
return 0.0;
}
def code(N): return 0.0
function code(N) return 0.0 end
function tmp = code(N) tmp = 0.0; end
code[N_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 22.9%
+-commutative22.9%
log1p-define22.9%
Simplified22.9%
sub-neg22.9%
+-commutative22.9%
add-sqr-sqrt23.4%
distribute-rgt-neg-in23.4%
fma-define24.8%
Applied egg-rr24.8%
Taylor expanded in N around inf 3.3%
distribute-rgt1-in3.3%
metadata-eval3.3%
mul0-lft3.3%
Simplified3.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}
herbie shell --seed 2024113
(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)))
(- (log (+ N 1.0)) (log N)))