Skip to content

Incorrect centered finite differences expression in colors module #941

@rhdtownsend

Description

@rhdtownsend

In the compute_derivatives_at_point() subroutine of the hermite_interp.f90 module in colors, the expression used to calculate centered finite differences,

df_dx = (f(i + 1, j, k) - f(i - 1, j, k))/(2.0_dp*dx)

will give incorrect results when the grid isn't uniformly spaced -- you can appreciate this from the fact that dx = x(i+1) - x(i), and so x(i-1) is not used.

As an example, applying this formula to the function y(x) = 3x + 1 sampled at x = 0, 1, 1.5 yields a slope 3.5, rather than 3.

Metadata

Metadata

Labels

colorscolors moduleinvalidThis doesn't seem right

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions