Created
March 25, 2019 02:57
-
-
Save GregVernon/b1c6ba8e31032a4532c4c3bad060771e to your computer and use it in GitHub Desktop.
Finite Difference Coefficient Generation
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
order = 4 | |
stencil = [-3 -2 -1 0 1] | |
S = zeros(Int64,order+1,length(stencil)) | |
for i = 1:length(stencil) | |
for j = 0:order | |
S[j+1,i] = stencil[i] ^ j | |
end | |
end | |
D = zeros(Int64,order+1) | |
D[order+1] = factorial(order) | |
C = S\D | |
x = range(0,2*pi,length=1000) | |
F = sin.(x) | |
DF = zeros(Float64,1000) | |
for i = 4:999 | |
DF[i] = sum((C .* F[i.+stencil]') ./ (x[2]-x[1])^order) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment