Skip to content

Instantly share code, notes, and snippets.

@jiahao
Created September 25, 2018 01:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jiahao/88a195996bc61415ba09c645d41a589b to your computer and use it in GitHub Desktop.
Save jiahao/88a195996bc61415ba09c645d41a589b to your computer and use it in GitHub Desktop.
# 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