I would like to go for search for this given functional equation using either java or python $f(x+1) = f(x)^2-1$

98 Views Asked by At

I would like to go for search for this given functional equation using either java or python $$ f(x+1) = f(x)^2-1 $$ $$ f(0) = 1 $$ I don't know where to start. I know how to graph in pycharm. I know basics in animation like object collision in java. I don't know how to go for estimation search for functional equations or in other manners any search whatsoever. If some one can give me both the algorithm and the manner for which I can program it, I would be glad.

1

There are 1 best solutions below

7
On BEST ANSWER

Let's look at some of its algebraic properties on the integers $\mathbb Z$.

For negative initial values, this immediately squares to become positive and for absolute values of $2$ or above, this will naturally grow exceedingly fast.

For moderate values, the square will instead push it down. If $f(x)=0$, then $f(x+1)=0^2-1=-1$ and if $f(x)=\pm 1$, then $f(x+1)=(\pm 1)^2-1=0$. In other words, once you touch the ground, you'll forever bounce down and back again.

So this is akin to $-r(x,x_0,y_0)\cdot\frac{1}{2}\cdot(1-(-1)^x)$ for some $r$ shirking with $x$.

On the reals, you may find some variation of functions with trigonometric relations (alla those of $\sin(\pi x)-1$).

I wrote you your python script and for the values I display here all values eventually end up in that pendulum.

enter image description here

import matplotlib.pyplot as plt

x0 = -5
xfin = 10
xs = range(x0, xfin)

num_ys = 30
y_max = 1.5
y0s = [y_max * y / num_ys for y in range(-num_ys, num_ys)]

for y0 in y0s:

    def f(x):
        return y0 if x==x0 else f(x - 1)**2 - 1

    ys = map(f, xs)

    plt.plot(xs, ys)

plt.show()

If efficiency should be a concern, note that here in this implementation of constructing the ys, I do some unnecessary re-computation.