Group Abstract Group Abstract

Message Boards Message Boards

Finding the Derivative of an Interpolated Function

Posted 2 years ago

Comparison between the derivatives of the symbolic function and the interpolated function:

 ex = Cos[x];

d = Interpolation[Table[ex, {x, 0 \[Degree], 360 \[Degree], 1 \[Degree]}], InterpolationOrder -> 6];

Plot[{d[t], d'[t]}, {t, 1, 361}]

Plot[{ex, D[ex, x]} // Evaluate, {x, 0 \[Degree], 360 \[Degree]}]

For example for x = 45[Degree]:

The results for the symbolic and interpolated functions are identical:

{Cos[45 \[Degree]], d[46]}
{1/Sqrt[2], 1/Sqrt[2]}

But for derivatives, the results are different. That's it?

{D[ex, x] /. x -> 45 \[Degree], d'[46]} // N
{-0.707107, -0.0123413}

Regards,

Sinval

POSTED BY: Sinval Santos
5 Replies
Posted 2 years ago

Thanks for your attention Henrik. I will correct my error.

Also thank you for the attention Gianluca. This procedure worked.

POSTED BY: Sinval Santos

I don't know what you wanted as the correct result. The way you have set up your Interpolation, its domain is the interval [1, 361] of the reals, and knows nothing of degrees. This way the two derivatives agree:

f = Interpolation[Table[{x, Cos[x]}, {x, 0 °, 360 °, 1 °}], 
  InterpolationOrder -> 6]
f'[45 °] // N
POSTED BY: Gianluca Gorni
Posted 2 years ago
POSTED BY: Sinval Santos
POSTED BY: Henrik Schachner

This is because you have:

enter image description here

POSTED BY: Henrik Schachner
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard