How to express a formula that iterates over itself n number of times?

703 Views Asked by At

I'm not very good at math so I might use the wrong words when searching for an answer (i even don't know what tags to apply).

I have an expression in a loop and the only way I can explain it is something like this.

x = h
Loop n times
  x = k*x
end loop
Result = x

h is the initial value of x. For each loop x = k*x n is the number of loops After n loops x now hold the result.

How do I express this mathematically?

2

There are 2 best solutions below

0
On BEST ANSWER

Initially, $x=h$. After one iteration, $x'=kx=kh$. After two iterations, $x''=kx'=kkh=k^2h$. More generally, after $n$ iterations,

$$x^{(n)}=k^nh.$$


In a more mathematical language, you have the recurrent sequence defined by

$$x_0=h,\\x_n=kx_{n-1}.$$

0
On

First of all: there are no problems in "not being good at math". If you want a math solution, them you're free to come at SE and ask.

For your question, we can start by $x_0 = h$.

Then, we define $f(x)$ (or $f\circ x$) as whatever is in the loop: $f\circ x = k\cdot x$.

As the result is the end of the iteration of the loop (with start at $x_0$), we can use the recomposition¹ notation. Letting $y$ be your result:

$$ y = \underbrace{f(f(\cdots f(x_0)\cdots ))}_{n \textrm{ times } f(\textrm{ something })} = \underbrace{f\circ f\circ\cdots f\circ x_0}_{n \textrm{ times } f\,\circ\textrm{ something}} = f\overset n\circ (x_0) $$

But for your case, in specific, as $f\circ x = kx$, we have

$$ y = f\overset n\circ (x_0) = (kx)\overset n\circ (x_0) = (k^n x)\circ(x_0) = k^n x_0 $$

Note:

  1. Recomposing is composing again
  2. Some prefer notating $f^{\circ n} x$
  3. f \overset{n}\circ x evaluates to $f \overset{n}\circ x$