Skip to content

first_order only differs from second_order at the endpoints #104

@pavelkomarov

Description

@pavelkomarov

To calculate the first location, first_order does a diff diff, duplicates the first and last locations with an hstack, and then takes the mean of [:-1] and [1:] indexings of this array.

That gives the first location of the result $= \frac{\frac{x_1 - x_0}{dt} + \frac{x_1 - x_0}{dt}}{2} = \frac{x_1 - x_0}{dt}$.

But then the not-endpoints are doing second-order center-differencing, because

$$\frac{\frac{x_n - x_{n-1}}{dt} + \frac{x_{n+1} - x_n}{dt}}{2} = \frac{x_{n+1} - x_{n-1}}{2dt}$$.

This is the same as what second_order is doing for its central points. So first_order isn't truly first order, except at the endpoints.

Metadata

Metadata

Assignees

Labels

researchwhen a task requires some experimentation or diving into papers and math

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions