NDSolve`FiniteDifferenceDerivative is a very helpful function to calculate numerical derivatives. It is explained in the tutorial The Numerical Method of Lines in more detail.
Here I found the reference BENGT FORNBERG:CALCULATION OF WEIGHTS IN FINITE DIFFERENCE FORMULAS which explains how the weights are to be calculated in the one dimensional case.
I couldn't find a similar reference for the two dimensional case.
My question:
- How is the differentiation matrix evaluated in this case, especially at boundary meshpoints?
- Are there additional helpful references in the Mathematica documentation?
Thanks!
regular grid first! $\endgroup$SeedRandom[123]; d1 = 4; d2 = 5; xgrid = Accumulate@RandomReal[1, d1]; ygrid = Accumulate@RandomReal[1, d2]; fdd = NDSolve`FiniteDifferenceDerivative[##, DifferenceOrder -> 2] &; func02 = fdd[{0, 2}, {xgrid, ygrid}]; func2 = fdd[2, ygrid]; {mat2, mat02} = #@"DifferentiationMatrix" & /@ {func2, func02}; SparseArray[Band[{1, 1}] -> Table[mat2, d1]] == mat02I don't think this will help one understanding the irregular cases. $\endgroup$