3-d order derivative

2 views (last 30 days)
Max Demesh
Max Demesh on 13 Feb 2022
Commented: Matt J on 14 Feb 2022
Dear all,
there is the following problem with the calculation of a 3-d order derivative.
I have two vectors of lambda and refractive index, respectively. I take the 3-d order derivative using a gradient().
When I use a relatively small number of points (for example 3000) , I get a smooth plot.
In the case of more points (30 000) there is some oscillation in the plot.
What is the reason of such behavior?
Thank you a lot.
Max Demesh
Max Demesh on 13 Feb 2022
What do you mean by "use more points"?
I mean, that I make the differences smaller and increase the accuracy.
Moreover, if I find the analytical function and then take the 3-d order derivative, I obtain smooth plots in any case.

Sign in to comment.

Answers (3)

Catalytic on 13 Feb 2022
If the points are too close together, the difference between neighbours will be so small as to be dominated by floating point errors
  1 Comment
Max Demesh
Max Demesh on 13 Feb 2022
It seems to be true. Using non SI base units do not help.
I guess in this case there is no way to solve this issue.
P.S. For the 2-nd derivative there is no problem for any number of points.

Sign in to comment.

Matt J
Matt J on 13 Feb 2022
You could try diff(x,3)
Matt J
Matt J on 14 Feb 2022
Why care whether its forward or central? For a smooth curve, it should work out the same.

Sign in to comment.

Max Demesh
Max Demesh on 14 Feb 2022

Community Treasure Hunt

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

Start Hunting!

Translated by