I want to calculate the derivative at a point, but I do not want to use the built-in derivative function D
.
I began with this definition of the derivative
,
which resulted in: Limit[ #, h -> 0] & /@ { (f[x + h, y] - f[x, y])/ h.
But, I want to calculate the derivative at a point with the definition
.
One aim is to increase the accuracy of the calculation by using a set of set of $x$$i$ (a numerical grid), where the spacing from one grid point to the next is $∆x$. For example, $∆x$ = 0.001, a grid of 10,000 points ($i$ = 1, . . . , 10000) would span a spatial range of 10 units in $x$.
I'm thinking one of these forms would be ideal for $x$$i$ ...
xi = i∆x xi = (i − im) ∆x xi = i∆x − xm,
but I'm not sure which is best.
Ultimately, I want to take a function $f$ of two variables, for example
f[x_, n_] := - Sum [Sin[j x] /j, {j, 1, n}],
at the grid points $x$$i$, and run through the grid, applying the derivative at a point equation (involving two neighbors for each derivative point). Then, after having the first derivative on the entire grid, calculate the second derivative on the grid, involving two first-derivative neighbors. Finally, I want to display the results on a plot.
My first thought is to use a do loop, a couple of arrays, and ListPlot
, but I'm not sure exactly how to proceed, as I've just started with Mathematica.