I am applying a 6th order Finite-Difference differentiation scheme as seen in http://www.scholarpedia.org/article/Method_of_lines/example_implementation/dss006
There seems to be severe numerical/floating-point issues with this scheme. The result is very sensitive to the values in the vector with which the FD matrix is pre-multiplied with.
For example, the gradient of a 10*1 vector with identical values is all zeros. For example, applying the following 10*10 matrix
-1764 4320 -5400 4800 -2700 864 -120 0 0 0
-120 -924 1800 -1200 600 -180 24 0 0 0
24 -288 -420 960 -360 96 -12 0 0 0
-12 108 -540 0 540 -108 12 0 0 0
0 -12 108 -540 0 540 -108 12 0 0
0 0 -12 108 -540 0 540 -108 12 0
0 0 0 -12 108 -540 0 540 -108 12
0 0 0 12 -96 360 -960 420 288 -24
0 0 0 -24 180 -600 1200 -1800 924 120
0 0 0 120 -864 2700 -4800 5400 -4320 1764
to a 10x1 vector 25545.007*ones(10,1)
results in [6.1118e-10, -2.3574e-09, -1.266e-09, -3.638e-10, -3.638e-10, -3.638e-10, -3.638e-10, 2.0082e-09, -6.1118e-10, -9.8225e-09]
whereas the correct answer is a 10x1 zero vector. The result produced by the second derivative matrix on the same set of vectors is even worse, with numbers of the order of 1e3 instead of zeros!
When I try this same first-derivative FD matrix on a slightly different vector 25545.007*ones(10,1)
, this works and produces the right answer (i.e. zero vector). These results have been double-checked on MATLAB, Python(Numpy) and Mathematica using standard double-precision arithmetic. The exact numerical values differ in each of the software, but the order of magnitude remains similiar to the above results.
Why is the scheme so sensitive to a vector that differs only by 1e-3? I really need high accuracy and such numerical issues mean that my solution values in downstream computations become unreliable and doesn't lend confidence in the overall solutions.
Is there a better way to implement this? Perhaps there exists an alternative recommended scheme for such scenarios? I am unable to introduce variable-precision arithmetic libraries, due to the project's complexities and their inherent slowness.