Numerical Derivatives in Mathematica

  • Mathematica
  • Thread starter Moonshine
  • Start date
  • #1
32
0

Main Question or Discussion Point

I have some data in a text file. I want to import this data into Mathematica, and then I want to calculate the numerical derivatives of this data. In particular, I need to find the y value where the first derivative is equal to zero.

I can import data. I can use the ND function for numerical derivativess, but I'm unsure how to accomplish the rest.

The data follows a sine curve with increasing amplitude. Do I need to fit the data first somehow?

Any help is appreciated. I'm kind of a beginner when it comes to Mathematica.
 

Answers and Replies

  • #2
29,566
5,888
I would use an interpolating function. You can take derivatives of interpolated functions which would allow you to simply solve for where they equal 0.
 
  • #3
32
0
Thanks, but I'm having a problem still.

I have my data imported, and I plotted it using ListPlot. It is a sin like curve with increasing amplitude as the x-values increase.

I'm thinking that the data is not in the form that InterpolationFunction expects.

I'm pretty new to mathematica, so any help is appreciated.
 
  • #4
29,566
5,888
Don't use InterpolationFunction, use just Interpolation. It expects the data in the form {{x1,f1},{x2,f2},...} where xi is the ith x-value and fi is the corresponding value f(xi).
 
  • #5
32
0
I tried that one too, but I receive the following error:

Interpolation::inder :
The order-2 derivative of {0.08028, 0.01704} is not a tensor of rank 2 with dimensions 2.>>


I'm not sure what this means. Thanks for your help.
 
  • #6
32
0
Okay, I think I have it working now.

My data had an extra { at the beginning and the end. Now, when I type

f = Interpolation[data]

The output is

InterpolatingFunction[{{0.02007,10.035}},<>]

Which I believe is the proper output.

Now, can I've tried the following code to get the zero values, and I think it is wrong.

NSolve[f' == 0, x]

Any help is appreciated. Thanks!
 
  • #7
29,566
5,888
You will want to use FindRoot instead of NSolve, and you need to put in an x before you can solve for it. E.g. f'[x] instead of f'
 

Related Threads on Numerical Derivatives in Mathematica

Replies
8
Views
2K
Replies
1
Views
4K
Replies
4
Views
2K
Replies
3
Views
2K
Replies
5
Views
2K
Replies
1
Views
2K
Top