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.Wed, 28 Oct 2020 20:12:20 +0100All rational periodic pointshttps://ask.sagemath.org/question/54066/all-rational-periodic-points/Hello, I am trying to find all rational periodic points of a polynomial. To specify: a periodic point is the point that satisfy $f^n(x)=x$. It is related to dynamical systems in fact. So the current codes that I used are following:
A.<z> = AffineSpace(QQ, 1)
f = DynamicalSystem_affine([2*z^3-3*z^2+1/2])
x=f.dynatomic_polynomial(2)
x.factor()
With this I can find its dynatomic polynomial and factorize it and find rational roots of this polynomial. So this roots corresponds to periodic point of the polynomial of given period. In particular dynatomic polynomial is the polynomial of the form $$\phi_{n,f}(x)=\prod_{d|n}(f^d(x)-x)^{\mu(n/d)}$$ n is period, f is your polynomial and $\mu$ is the mobius function.
But with this code I can find periods up to 8 because of memory limit. The other code that I used is
R.<x> = QQ[]
K.<i> = NumberField(xˆ2+1)
A.<z> = AffineSpace(K,1)
f = DynamicalSystem([zˆ2+i], domain=A)
f.orbit(A(0),4)
But in fact it doesn't fit my purposes.
I have codes that I can get limited information. For example checking up to a period is not advisable. If you know a little bit arithmetic dynamics, you can see what I mean. Silverman-Morton conjecture plays an important role here.
I am waiting for your answers. Thank you so much.nomaddWed, 28 Oct 2020 20:12:20 +0100https://ask.sagemath.org/question/54066/How 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/Class returning coordinates of iteration maps in a dynamical systemhttps://ask.sagemath.org/question/45554/class-returning-coordinates-of-iteration-maps-in-a-dynamical-system/Hi, I'm using sage to study certain rational maps in $1$ dimensional projective space. Specifically I'd like to calculate coordinate maps of $n$-th iteration. I know that there are nth_iterate and nth_iterate_map classes but it seems that nth_iterate class only works on specific points and nth_iterate_map class returns the whole dynamical system, not the coordinate maps. For example, if we define
> sage: P.<x,y>=ProjectiveSpace(QQ,1); f=DynamicalSystem([x^2,y^2],domain=P)
then
> sage: f.nth_iterate(P[x,y],2)
gives an error that it is unable to convert x to an element of Algebraic Field, and
> sage: f.nth_iterate_map(2)
gives a dynamical system as follows.
> Dynamical System of Projective Space of dimension 1 over Algebraic Field
> Defn: Defined on coordinates by sending (x : y) to
> (x^4 : y^4)
What I want is a class, or any method, that returns coordinate maps, probably as a list of maps in $x$ and $y$, of $n$-th iteration. In the previous example, it should return a list $[x^4,y^4]$.
Any help will be appreciated. Thanks in advance!imnotarobotTue, 26 Feb 2019 19:19:20 +0100https://ask.sagemath.org/question/45554/Restricting vector field to a subset of a rectangular regionhttps://ask.sagemath.org/question/29440/restricting-vector-field-to-a-subset-of-a-rectangular-region/ I'm trying to restrict a vector field plot to a specific region of the plane. I found the code for the plot_vector_field3d function online, and just modified that accordingly, but I'm having trouble with the 2d case. plot_vector_field always picks points in a rectangular region, but there's a part of the region I want to skip. Here's what I have so far.
x,y = var('x y')
C = circle((0,0),1)
# useful functions
def norm2((x,y)):
"""
Norm squared of `(x,y)`
"""
return x^2 + y^2
def norm((x,y)):
"""
Norm of `(x,y)`
"""
return norm2((x,y)).sqrt()
def dy(x,y):
r = norm((x,y))
theta = arctan(y/x)
dr = cos(theta)*(1-1/r^2)
dtheta = -sin(theta)*(1+1/r^2)
if r<= 1:
return 0
else:
return dr*cos(theta)-r*sin(theta)*dtheta
def dx(x,y):
r = norm((x,y))
theta = arctan(y/x)
dr = cos(theta)*(1-1/r^2)
dtheta = -sin(theta)*(1+1/r^2)
if r<= 1:
return 0
else:
return dr*sin(theta) + r*cos(theta)*dtheta
VF = plot_vector_field((dx(x,y),dy(x,y)),(x,-2,2),(y,-2,2))
show(VF + C,aspect_ratio=1)
I'm not able to upload an image file, but if you run this, I'm trying to get rid of all of the vectors within the circle.
For comparison, here's the working code in 3d. This generates a flow on a torus, with the vectors only coming from points on or in the torus, instead of the usual plot_vector_field3d, which puts the points on an entire cube. dx, dy, and dz are the functions that give the correct vector components.
twopi = 2 * RDF.pi()
DT = [] # discretized tori
n = 20 # points in the boundary
m = 5 #layers in the torus
#Discretizes T0
for k in xrange(m):
for i in xrange(n):
DT.append((2*cos(i*twopi/(n)), 2*sin(i*twopi/(n)),0))
for j in xrange(n/2):
x0 = (2 + cos(j*twopi/(n/2)))*cos(i*twopi/(n))
y0 = (2 + cos(j*twopi/(n/2)))*sin(i*twopi/(n))
z0 = ((k+1)/m)*sin(j*twopi/(n/2))
DT.append((x0,y0,z0))
points = [vector(DT[i]) for i in range(len(DT))]
vectors = [vector((dx(*point), dy(*point), dz(*point))) for point in points]
max_len = max(v.norm() for v in vectors)
scaled_vectors = [v/max_len for v in vectors]
VF = sum([plot(v,color=hue(v.norm())).translate(p) for v,p in zip(scaled_vectors,points)])
jford1906Mon, 14 Sep 2015 22:01:05 +0200https://ask.sagemath.org/question/29440/