-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
DOC: gradient uses 1st order central difference in the interior #8605
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Thanks @drabach. For future reference, follow the commit message template in |
Beside the typo |
What do you mean with "3 point stencil"? A central difference (first order or second order) always uses 3 points - that's why it is called "central". But that does not refer to the order. To explain the problem with the documentation I have as a user of this function: To have the first value here it is (2-1)/1 = 1 and the second value is (4-1)/2=1.5. I assume like stated in the documentation that the equal spaced difference is one - so at the beginning I divide by 1 and in the middle I have to divide by 2 and so on - finite differences of first order in both cases? |
@drabach the number of points used to compute the approximation is usually referred as "stencil". In this case, for central difference we are using indexes i-1, i , i+1 therefore a "3 point stencil". |
When you update the documentation maybe some reference for the definition of the terms "first order" and "second order" difference would clarify things. When I use "my" definition for second order differences I get different results for the gradient function, namely : |
ok, now I see what you are saying and we are both right, we are just using the term order for different things. (IMHO the wikipedia page it is not very clear on this since it is mixing the two things). |
For the gradient function for array-likes I corrected the documentation and the comments. The implementation was correct just the documentation stated that the second order central difference would be used. Instead the first order difference is used (like it should be).