Here's a problem I've been trying to tackle for a while... I have a 1D numpy array/list/sequence of numbers, like so:
However, there is a certain condition my sequence has to meet: the y-displacement shall not exceed a factor of 2x (relative to the neighbouring point/element). For example, this particular sequence does not meet this requirement in certain indices:
- Green: OK
- Red: Not OK; exceeds a factor of $2$
The goal is to modify the array (ideally with as few insertions of new elements as possible), so that the steps are not as steep, and the <2x condition is met. Any ideas how one might do this?
I've tried a few things with np.linspace and squaring it (**2) to produce a quadratic sequence, but I haven't fully figured it out yet.
In its original visual, the problem looks like this (X axis only) - the goal is to generate a grid (mesh) to a structure for physics simulations, and >2x steps should generally be avoided:


