0

I have an array of numbers that represents a function. I have times30 and positions30 which represent the time intervals and displacement intervals respectively. I do not have the exact equation for this function. I want to find the time this function crosses the x-axis for the first time, or even the time when the position30 number first comes closes to 0.

The function looks like:

enter image description here

You can see that the first x-intercept is between 0-5 seconds. But how can I find the exact value of time at that point? I read this post(from list of integers, get number closest to a given value) but my list shouldn't be sorted.

NoLand'sMan
  • 534
  • 1
  • 3
  • 17

1 Answers1

0

Iterate over pairs of times[i-1] and times[i] and find first such for which positions[i-1] and positions[i] have different sign.

hgrey
  • 3,033
  • 17
  • 21