numerical derivate and central difference

can anyone help me with this function, please?
find numerical derivative of f(x) = tan−1(?) at x = 2 using central difference scheme where is x is in radians. Use different values of step size h in central difference scheme and compare with true value of the derivative by plotting error for the different h. f(x) means function of x.

2 件のコメント

Ameer Hamza
Ameer Hamza 2020 年 5 月 10 日
This seems like a homework question. What have you already tried?
payam abubakr
payam abubakr 2020 年 5 月 10 日
i have tried nothing because i don't knoe how to start.
appreciate your help

サインインしてコメントする。

回答 (1 件)

Jim Riggs
Jim Riggs 2020 年 5 月 10 日
編集済み: Jim Riggs 2020 年 5 月 10 日

1 投票

Here are some Numerical difference formulas using the central difference method (substitute dt = h).
You can find more formulas with even higher accuracy on wikipedia. (see "numerical differentiation" and also "finite difference coefficient"

4 件のコメント

payam abubakr
payam abubakr 2020 年 5 月 11 日
we are taught online, and i cannot understand it like that.
can you help me with the codes, please?
Jim Riggs
Jim Riggs 2020 年 5 月 11 日
編集済み: Jim Riggs 2020 年 5 月 12 日
Since this looks like homework, you should give it a try first, or ask a more specific coding question.
I offer the following explanation of the central difference method;
Central difference is a method to estimate derivatives of numerically sampled data. The method, as described here, requires that the data is sampled at a constant spacing, h, i.e. h is the spacing of the values on the x (independent) axis.
For a given sample (point "i"), we want to find the first derivative (y'), which is the slope of the tangent line at point i. This can be approximated using difference formulas (e.g. forward, backward, central). The central difference formula is more accurate than the other two, because it uses data on either side of the point of interest (point i), so point i is "in the center" of the data being used.
To calculate the slope at point i, we take the change in Y-distance (delta Y) divided by the change in the X-disrtance (delta X). Using the central difference, the change in the Y-distance is y(i+1) - y(i-1) and the X-distance is two samples, which is 2h. You can easily see this in the diagram, below. The red line is the approximation of the slope at point i, which you can see is a pretty good approximation when we translate it to go through point i (the red dashed line).
This is the simplest form of the central difference formula, and hopefuly this will help you understand the equations I posted above. The first derivative is y', so you can see that this equation matches the above figure (just substitude dt = h).
(The second group of equations (with error of order dt4) is just a more accurate method which uses two points on either side of point i)
So, given a series of data sampled at uniform spacing h on the x axis, assume that the data is in the form of two vectors X() and Y(). h = X(i+1) -X(i) and is the X-distance between samples.
The derivative (using the central difference) is given by
dy(i) = (Y(i+1) - Y(i-1))/2/h
Suppose further that there are n points in both X() and Y(). Note that since the calculation uses Y(i+1) and Y(i-1), i can only have values of 2 to n-1
payam abubakr
payam abubakr 2020 年 5 月 12 日
thank you
Muhammad Hammad Malik
Muhammad Hammad Malik 2021 年 2 月 14 日
編集済み: Muhammad Hammad Malik 2021 年 2 月 14 日
@Jim Riggs @payam abubakri also want to calculate gradient(central difference) with window size=10smples with 50% overlap to previous window using attached equation.could you pls help. Thanks

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangePolynomials についてさらに検索

質問済み:

2020 年 5 月 10 日

編集済み:

2021 年 2 月 14 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by