I have a set of numerical data of 1501 points, in the form of $\{x_i,a_i\}$ which I uploaded to here and here.

I need to compute the numerical derivative of this data. In particular, I need the quantities

\begin{equation} C=\frac{1}{\left| \frac{da}{dx} \right|}, \hspace{1cm} D = C' = \frac{dC}{dx} \end{equation}

To do this, I interpolated the data given in the link,

data = Get["https://pastebin.com/raw/Ccvm7Bgp"];
Interp = Interpolation[data];
Plot[Interp[x], {x, 0, x[[1501]]}, PlotRange -> All]


Then I computed C by

DInterp[x_] := Interp'[x];
C[x_] := 1/Abs[DInterp[x]];

But DInterp and, consequently, C (shown below) are very noisy, let alone sC'$:

This is the derivative of the interpolation, Dinterp

This is the derivative of the interpolation, Dinterp

This is C

This is C

How can I solve this? I need to determine $C$ and $C'$ very precisely, how to I get rid of the noise to achieve this?

  • 2
    $\begingroup$ Not at a computer right now, but one look at your axes tells me you chose a poor scaling of your variables. $\endgroup$ Sep 30, 2018 at 16:43
  • 2
    $\begingroup$ The numbers you are working with are so small that your computations can not be made accurately enough using machine arithmetic. You can try rescaling as J.M. suggests or maybe try working with arbitrary precision arithmetic. $\endgroup$
    – m_goldberg
    Sep 30, 2018 at 17:04
  • $\begingroup$ Somewhat related: mathematica.stackexchange.com/q/90130/1871 $\endgroup$
    – xzczd
    Sep 30, 2018 at 17:05
  • 1
    $\begingroup$ Just tested your data, only to encounter Interpolation::inddp warning. Also, something is apparently wrong with {x, 0, x[[1501]]}. Please double-check your code sample. $\endgroup$
    – xzczd
    Sep 30, 2018 at 17:12
  • $\begingroup$ J.M. and m_goldberg, thank you for the replies. Would it make any difference working with different accuracies? xzczd, I meant to write {x, 0, data[[1501,1]]}, not use x in both places, sorry about that. $\endgroup$
    – Sth99
    Sep 30, 2018 at 17:30


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.