In principle, if a function is specified that produces such output for different parameters:

I want to quickly find the first x in which the function is 0. So, with the parameters that create the blue curve over x, I want to find x = 134. For the green curve, I want to find x = 56, etc.
I think that the function will always decrease monotonously until it reaches zero, but I'm not quite sure.
Function is not necessarily monotonously reduced.
I am sure that it will hit only once and then remain zero.
I am currently rudely forcing it by iterating over the x values ββuntil it reaches zero, but I need something that is better for getting educated guesses (based on the slope?) And iterating.
Ideally, I want to use something already baked ( since 90% of programmers can't even write binary search correctly ), for example something from scipy.optimize , but it seems like everyone wants to find either a global minimum or a zero intersection.
(This function is a kind of distance to the RGB cube for a given color in the Lch color space (thus, basically creating the "reliable clip for RGB" function), but since the display between IRGB and LCh may vary depending on the library and with such parameters , as a light source, etc. I think itβs best to just try a few values ββuntil the correct one is found, and not try to reprogram the value directly?)
source share