Numerical differentiation of discrete data in python | complete tutorial

preview_player
Показать описание
In this video we are going to learn how to perform numerical differentiation of some discrete experimental data in python. Here, we will be using three different techniques to calculate the numerical derivative of some discrete set of data points. The following methods will be used
1. forward difference method
2. backwards difference method
3.Centered difference

Furthermore, we will also learn another simple way to do numerical differentiation using the numpy module .Please stay tuned and watch till the end. #python #pythonprogramming
Don't forget to Subscribe "Dr Manab" YouTube channel to get updates of all upcoming videos. Thanks for watching.

Thank you !!
Рекомендации по теме
Комментарии
Автор

Thank you very much! You helped me with my probset in Comphy!

vallesprincessc.
Автор

I think the data for the plot are zero at the boarder. Try to run this code with a simple function y = X**3, the derivation is Y' = 3*X**2 the last point is wrong due to the difference because you can get always for y' => n-1 point where n is the length of the X. How do you solve this issue?

import matplotlib.pyplot as plt
import numpy as np

dx = 1
x_values = np.arange(-10, 11, dx)
#print(x_values)
y = x_values**3
#print(y)

# let us use backward derivative formula
dyforward = np.zeros_like(y)
# for the first elment use farward difference
#dyforward[0] = (y[1] - y[0]) / dx

for i in range(0, len(y)-1):
dyforward[i] = (y[i+1] - y[i]) / dx
# for the last data point backward difference
#dyforward[-1] = (y[-1] - y[-2]) / dx

plt.figure()
plt.subplot(2, 1, 1)
plt.plot(x_values, y, label='f(x) = x^3')
plt.legend()
plt.subplot(2, 1, 2)
plt.plot(x_values, dyforward, label="f'(x)=3*x^2")
plt.legend()
#plt.show()

robertodilorenzo
Автор

how is the code for the numerical integration of discrete data?

luo