HW 5 - Derivatives with splitting arrays #133
chrisbergen4
started this conversation in
General
Replies: 1 comment
-
ddy_f=(y[2:]-2y[1:-1]-3y[:-2])/(x[2:]-x[1:-1])**2; ddy_b=(y[2:]-2*y[1:-1]+y[:-2])/(x[2:]-x[1:-1])**2; how does this code look? the difference between the two derivative methods is pretty large, but I dont know where I could be going wrong |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I get how when splitting the arrays to find f(xi+1) or f(xi+2) we would split the array like y[1:] and y[2:], since its just pushing forward the array. But for f(xi - 1) or f(xi - 2), I'm confused how to shift the arrays backwards. Should be just add 2 to each of those, so that f(xi - 1) becomes f(xi + 1), and f(xi - 2) becomes f(xi) ?
Beta Was this translation helpful? Give feedback.
All reactions