Assume that I have a non-equidistant grid of $n$ nodes, as follows:
ClearAll["Global`*"];
n = 10;
SeedRandom[123];
nx = Sort@RandomReal[{-1, 6}, n]
If I want to compute the differentiation matrix in Mathematica, I simply use the command NDSolve`FiniteDifferenceDerivative
as follows:
opt = "DifferenceOrder" -> 2;
dudx = NDSolve`FiniteDifferenceDerivative[1, nx, opt]["DifferentiationMatrix"];
dudx // MatrixForm
This computes the weights of an FD method which is very useful when solving a differential equation.
Is there a way to compute a similar matrix based on the finite element method (FEM), I mean with FEM accuracy? Maybe, a computation of a stiffness matrix could help?
Can we test and compare the performance of such two matrices (based on FD and FEM) for approximating a derivative of a function or a simple differential equation?
I would be thankful if someone write some hints to derive such a matrix with FEM methodology.