Finding out the peak of a function y(x) asking only whether y(b) > y(2b) for as many bs as we want

28 Views Asked by At

Imagine the following situation.

We have a continuous smooth function y(x), of which we only care about for x >= 0. We know that y(x) is ascending at x = 0, has a peak at some x = x_peak, and then starts descending forever. We want to find x_peak, not necessarily exactly, but say with one (or n) decimal(s) of precision.

We do not know y(x), BUT we can ask a question to an all-knowing computer. We can submit a value, say b, and the computer will tell us which one is bigger, either y(b) or y(2b). We can ask that question as many times as we want for as many values of b as we want. (We can also assume that x_peak is not arbitrarily large, for example let's say we know it's under 10.000.000) Doing that, how can we obtain x_peak?

I'm not too advanced in math but I believe there ought to be a simple algorithm to solve this question, one that narrows the possible range with every question until it can get arbitrarily close to it. But I have no idea how such an algorithm would operate. It's very easy to start, say you start comparing y(2^10) and y(2^9) and narrow down which 2^n is closer to the peak, but I have no idea what to do after that, since the constraint says you can only compare y(m) with y(2m), and not with, say, y(1.01m).

I don't know whether I'm missing something extremely simple or I'm stupidly trying to flatten a sphere.

Edit: Just to clarify, there is only one local maximum in the entire function, and that's at x_peak. The function is always ascending before x_peak and always descending after x_peak, although not necessarily at linear rates.

Edit: And would the problem be possible if rephrased to "You can ask whether y(b) or y(n*b) is bigger, being n an integer bigger than 1"? So not restricting it to n=2.

1

There are 1 best solutions below

0
On BEST ANSWER

There is some $c$ such that $f(c)=f(2c)$, and you can locate these points. Specifically, for $b<c$, your computer will say that $f(b)<f(2b)$, and then at $c$ the computer will switch over to saying that $f(b)>f(2b)$. Unfortunately this is all the information you get! For the types of functions you're describing, the direction of the inequality between $f(b)$ and $f(2b)$ will only switch once, and the point where it switches doesn't depend on the location of the peak, just where $c$ is.

This applies generally for any $n$: the only information you get out of the computer that can tell if $f(b) < f(nb)$ is where the switch-over point is: the $c$ where $f(c) = f(nc)$. For large $n$ this doesn't tell you much about the location of the peak, but if you let $n$ get closer to 1 (like 1.01), you can get the points to narrow in on the peak.