I met a problem when playing with the numerical difference provided by mathematica. My aim is to test the accuracy of the high-order numerical derivative. The code is below Nx = 512; u0 = 0; uN = 5.0; du = (uN - u0)/Nx; ugrid = du Range[0, Nx]; C0 = Sin[Pi #/uN] & /@ ugrid; order = 3; der = 6; exact1 = D[Sin[u Pi/uN], {u, der}]; exact2 = Table[ exact1, {u, ugrid[[1]], ugrid[[-1]], ugrid[[2]] - ugrid[[1]]}]; num = NDSolve`FiniteDifferenceDerivative[Derivative[der], ugrid, C0, "DifferenceOrder" -> order]; ListPlot[{Transpose[{ugrid, exact2}], Transpose[{ugrid, num}]}]
The result looks like this ![enter image description here](https://i.stack.imgur.com/pzPlz.png)
However, when I place the code in a dynamic module to play with the order of derivatives and number of points
Manipulate[Nx=2^pow;u0=0;uN=5;du=(uN-u0)/Nx;
ugrid=du Range[0,Nx];
C0=Sin[Pi #/uN]& /@ugrid;
exact1=D[Sin[Pi u/uN],{u,der}];
exact2=Table[exact1,{u,ugrid[[1]],ugrid[[-1]],ugrid[[2]]-ugrid[[1]]}];
num=NDSolve`FiniteDifferenceDerivative[Derivative[der],ugrid,C0,"DifferenceOrder"->order];
ListPlot[{Transpose[{ugrid,exact2}],Transpose[{ugrid,num}]}],{{pow,9,Dynamic["Points: "<>ToString[2^pow]]},4,15,1},{{order,3,Dynamic["Order: "<>ToString[order]]},1,15,1},{{der,6,Dynamic["Deriv: "<>ToString[der]]},1,18,1},ContinuousAction->False,LabelStyle->"Text"]
The result looks pretty good ![enter image description here](https://i.stack.imgur.com/PV4G0.png)
I'm not sure what the dynamic module does such that they generate different results with the normal one.