ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 29 Feb 2020 04:21:11 +0100How to compose two functionshttps://ask.sagemath.org/question/50113/how-to-compose-two-functions/Suppose I have a function f(x)=x^2+1
What is the command to compose it with itself twice or thrice?
I was using:
f= (x^2+1)
g= lambda t: (t^2+1)
f(*g)
or
sage: g = lambda t: (t^2+1)
sage: f = lambda x: (x^+1)
sage: f(*g(t))
or
sage: x = var('x')
sage: f=x^2+1
sage: compose(f, 3, x)
Nothing works! Also, I don't know how to use the Dynamical system code in this case here.
Also, it would be of great help if you can give me one example command for the composition of two different functions
e.g f(x)=x^2+1 and g(x)=x^3+2 if it is not obvious from the answer of the composition of the same function twice.ArnabSat, 29 Feb 2020 04:21:11 +0100https://ask.sagemath.org/question/50113/plotting complicated functionhttps://ask.sagemath.org/question/46495/plotting-complicated-function/*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?PusheenMoewSun, 12 May 2019 19:43:57 +0200https://ask.sagemath.org/question/46495/