Getting from $A$ to $B$ (both constants) given $n$ iterations of $A*=x$. What's the ratio of $n/x$? How to express algorithmically?

30 Views Asked by At

For context, I created code of the form:

A = 0.125
n = 20
x = 1.1
for (int i = 0; i < 20; i++) {
  A = A * x
}
B = A

But I don't necessarily always want to get to this particular $B$ value (0.8409378, unless I miscalculated) via 20 iterations. I may want to get to B via 30 iterations, with $x$ naturally needing modified. But I don't know how to modify $x$ given different values of $n$ such that I get from $A$ to $B$ every time.

How do I algorithmically find this relationship of $x:n$? What is the term for this kind of algorithm in mathematics?

1

There are 1 best solutions below

4
On BEST ANSWER

Solving the equation @the_candyman derived, yields:

$$B=Ax^n$$ $$\sqrt[n]{B}=\sqrt[n]{A}x$$ $$x=\sqrt[n]{\frac BA}$$

So as long as $A$, $B$ and $n$ are known, you can figure out what x is :)