S
S
shadrap2020-12-12 15:18:13
C++ / C#
shadrap, 2020-12-12 15:18:13

How to write an algorithm for the intersection of the graphs of two functions with a certain level of tolerance?

Hello!
There is a task to program an algorithm for the intersection of the graphs of two functions, with a set "proximity level" for the values ​​of these functions. Roughly speaking, the values ​​of the dP/dT function decrease, and the dH values ​​increase, and at some point they may intersect or pass close to each other at the "proximity level". The task is to find the intersection when some values ​​​​increase, while others decrease.
What has been done: data from functions are accumulated in arrays over time. A trend detection function has been written - values ​​increase or decrease with the assignment of weight coefficients to values ​​at different points in time.
How to define an intersection? - Is it trivial to compare arrays in a loop, each time counting the difference between the values, and if it satisfies the "closeness level", then consider the intersection to have happened? Or is there some better option? How to overcome noise or random values?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
dmshar, 2020-12-12
@dmshar

Not very clear, but still.
First, functions can intersect even when both of them grow or both fall. Just at different speeds. Did you intentionally dismiss this case?
Secondly, it is not clear, do you have all the measurement points accumulated in advance or do you solve the problem as the points arrive? If the latter, then there is nothing to think about, just measure the distance between the values ​​​​and make a decision.
By the way, it is not clear whether your data comes at one moment, or at different ones. In the second case, you simply cannot get by with distance - you need to look for possible intersections of functions between measurement points. It's not difficult, but still.
Further. If the data is still available "batch accumulated" - then the easiest way is to use, for example, the same Pandas to build the corresponding DataFrame, in which the intersection point (or intersection points) is located using one line of a logical condition. And the ordering of points, if they are not measured at the same time, is also a standard procedure in Pandas.

M
mayton2019, 2020-12-12
@mayton2019

If the function is continuous and if given in a table. Then it is possible to interpolate the values ​​on the intervals between points at least along any smooth curve of the polynomial type. And then it turns out that despite the fact that the discrete points were not close enough to each other, and the interpolated segments approached a certain "epsilon".
That is, the condition of the problem most likely lacks details.

X
xmoonlight, 2020-12-14
@xmoonlight

The task is to find the intersection when some values ​​​​increase, while others decrease.
We're talking about resonance, right?
If so, then we need a system of two inequalities (the so-called "trigger"), the solution of which depends on the input parameters (coordinates of function points) with a tolerance of r (based on the parametric equation of the circle).
As soon as the system has a solution, this will mean that the functions have "crossed".

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question