Skip to content

Files

Latest commit

e60aa15 · Aug 28, 2019

History

History
This branch is 21 commits behind csc-training/hpc-python:master.

finite-difference

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Jan 22, 2018
Aug 28, 2019

Finite-difference

Vectorization is crucial for obtaining good performance with NumPy.

Derivatives can be calculated numerically with the finite-difference method as:

img

Construct 1D Numpy array containing the values of xi in the interval [0,π/2] with spacing Δx=0.1. Evaluate numerically the derivative of sin in this interval (excluding the end points) using the above formula. Try to avoid for loops. Compare the result to function cos in the same interval.