plotting complicated function

asked 2019-05-12 19:43:57 +0200

PusheenMoew gravatar image

updated 2019-05-15 00:21:35 +0200

slelievre gravatar image

I would like to approximate the sum $$h(a,x) = \frac{-2}{n} \sum_{n=0}^{n-1} log|T_a^n(x)| $$ where $n$ is large like $n= 1000 - 5000$ and for a fixed $a$ $$T_a(x) = \Big|\frac{1}{x}\Big| - \Big\lfloor{\Big|\frac{1}{x}\Big| - 1 +a}\Big\rfloor$$ where $x \in (0,1).$

By fixing $x$ to be a value $x_0 \in (0,1)$, e.g. $x_0 = 1/\pi$, $$h(a, x_0) = h(a, 1/\pi)$$ a function of one variable, and I want to plot a 2D graph of point $(a, h(a, 1/\pi))$, by fixing $n = 2000$, for $a \in [0,1].$

I figure how to calculate the value at one given $a$ using SageMath, for example, when $a = 1$,

T(x) = 1/x - floor(1/x)
s = 0
for k in xrange(0, 1000):
     a = 0
     a = nest(T, k, 0.79)
     b = abs(a)
     c = log(b)
     s = s + c

Then $\frac{-2}{1000}s$ give the approximation for the sum when $x = 0.79$, $n = 1000$, $a = 1$.

But for plotting, I think I need to define the function $h(a, x)$ which is a summation over composition of functions. I tried to use sum and symbolic_sum but failed.

Any help how to achieve this please?

edit retag flag offensive close merge delete


I suspect that you want to write $|T_a(x)|^k$ instead of $T_a^n(x)$, right? Otherwsie, what means $T^n$ here?

Masacroso gravatar imageMasacroso ( 2019-05-13 18:07:26 +0200 )edit

@Masacroso: it means the function $T_a$ is applied $n$ times. For example, $T_a^2(x) = T_a(T_a(x))$.

slelievre gravatar imageslelievre ( 2019-05-15 00:18:21 +0200 )edit

well, in first place note that $$T_a(x)=x^{-1}-\lfloor \lfloor x^{-1}\rfloor +\{x^{-1}\}-r\rfloor=\{x^{-1}\}-\lfloor \{x^{-1}\}-r\rfloor=\{x^{-1}\}+[r>\{x^{-1}\}]$$ for $r\in[0,1]$ and where $[\cdot ]$ is an Iverson bracket and $\{x^{-1}\}$ is the fractional part of $x^{-1}$. But then note that $T_a(T_a((x))$ is not defined when $\{ x^{-1} \}=0$ and $r\le \{x^{-1}\}$.

Masacroso gravatar imageMasacroso ( 2019-05-15 03:33:35 +0200 )edit

In that branch of mathematics, it's usual to study functions that are defined only almost everywhere. The set of measure zero where they are not defined is just disregarded and "does not matter". Of course, when experimenting with a computer, it can turn out to matter.

slelievre gravatar imageslelievre ( 2019-05-15 23:01:54 +0200 )edit