0

As title says:

$$A^N - B^N = C,$$ $A,B,C$ are known, solve for $N$. This is substracted from a bigger formula where this N is one of the parameters to be calculated.

I have tried it with: $$X = A^Y \Rightarrow Y=\frac{\log(X)}{\log(A)}.$$ But this doesnt work for this version. I have been stuck on in for 8 hours already and a solution would really help me out. By calculating it by myself I tried the following: $A = 5$, $B = 2$.

For $C = 3$, $N = 1$.

For $C = 21$, $N = 2$.

For $C = 117$, $N = 3$.

But that's with simply filling in $N$. Which is not allowed since I need to find it by a algorithm/formula for a vision project.

Sorry for duplicate.

Travis Willse
  • 99,363

1 Answers1

0

You won't find a nice algebraic formula for general parameters. It looks like you are restricting $A,B,C,N$ to natural numbers-are you? You can do pretty well by ignoring the $B$ term to start, so take your first try to be $N=\left \lceil \frac {\log C}{\log A}\right \rceil$ then just count upward for $N$ until you find the one that is right. If you don't restrict $N$ to naturals, you want a one dimensional root finder. You have a good first guess (take off the ceilings).

Added: for a very simple approach in the reals, not as fast as Newton-Raphson but easy to program, take $N_0=\frac{\log C}{\log A}$, then $N_{i+1}=\frac {\log C-B^{N_i}}{\log A}$ and iterate to convergence. If $N$ is reasonably large $B^N$ will be well less than $A^N$ this should converge nicely.

Ross Millikan
  • 374,822
  • For the first calculations I indeed only tried it with natural numbers, so i could calculate them easy myself. In the case where it will be used every number can be a real number. The problem with counting upward is the size of the count, which can in-/decrease but can take a while because of precision. – Bram Goderie Sep 17 '14 at 06:26
  • That is why you want a root finder in the real case. Once you try a couple cases, it uses the error of those to evaluate the next step. This problem should yield easily to Newton-Raphson You have a good starting value-use the equation above without the ceiling. – Ross Millikan Sep 17 '14 at 14:39