Created
September 25, 2018 01:20
-
-
Save jiahao/88a195996bc61415ba09c645d41a589b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Compute the nth elementary symmetric function (elementary symmetric polynomial) of a a 1D iterable x | |
# This is the THIRD esf | |
function esf(n, x) | |
summand = zero(eltype(x)) | |
for j1 = 1:n, j2 = 1:j1-1, j3 = 1:j2-1 | |
summand += x[j1]*x[j2]*x[j3] | |
end | |
return summand | |
end | |
function bernoulli(k, γ) | |
n = length(γ) | |
c = zeros(k) | |
for i=1:k | |
c[i] = esf(i, x) | |
end | |
return factorial(k)*(-1)^k*todd(k, c) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment