ASKSAGE: Sage Q&A Forum - Latest question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 18 Apr 2019 10:29:09 -0500Intersection of polynomial Ideals over $\mathbb{R}$http://ask.sagemath.org/question/46258/intersection-of-polynomial-ideals-over-mathbbr/I am trying to compute the intersection of Ideals over $\mathbb{R}[x,y]$, but I get problems from the coefficient $\frac{1}{\sqrt{2}}$. This is my code:
R.<x,y>=PolynomialRing(RR,order='lex')
I=Ideal([(x^2+y^2-1),(x*y),(y^3-y)])
I5=Ideal([x-1/sqrt(2),y-1/sqrt(2)])
I6=Ideal([x+1/sqrt(2),y-1/sqrt(2)])
I7=Ideal([x+1/sqrt(2),y+1/sqrt(2)])
I8=Ideal([x-1/sqrt(2),y+1/sqrt(2)])
J=I.intersection(I5,I6,I7,I8)
and this is the error I get:
TypeError: Intersection is only available for ideals of the same ring.
So when I ask if
I5 in R
the answer is False. I also tried with QQbar but same result, can someone explain this?
Thanks!
EDIT: I also tried with $\frac{\sqrt{2}}{2}$ instead of $\frac{1}{\sqrt{2}}$ and I get the same error.LeghThu, 18 Apr 2019 10:29:09 -0500http://ask.sagemath.org/question/46258/Trouble finding intersection of two functionshttp://ask.sagemath.org/question/44019/trouble-finding-intersection-of-two-functions/ Hi all,
I'm still pretty new using SageMath, but I'm trying to duplicate functionality that I've been able to do in wolfram alpha
Wolfram Input:
Intersection points of [//math:90000 1.03^x//] and [//math:63000 1.095^x//]
So far I've been able to recreate and graph these functions very easily using SageMath, but I'm having a difficult time using the solve function to actually return a numerical value for the intersection point itself.
My SageMath code looks like:
x = var('x')
f1 = (63000*((1.095)^x))
f2 = (90000*((1.03)^x))
ans=solve(f2==f1,x)
print ans
print n(ans[0].rhs())
ans prints as
"[
219^x == 1/35*200^(x - 1)*103^x*100^(-x + 2)
]"
And I get an error "TypeError: cannot evaluate symbolic expression numerically" in my attempts to resolve it to an approximate number.
Can anyone tell me what I'm doing wrong?lgushurstMon, 22 Oct 2018 00:51:55 -0500http://ask.sagemath.org/question/44019/Finding intersection of two lists?http://ask.sagemath.org/question/36829/finding-intersection-of-two-lists/Hello, guys. First of all, I'm very new to Sage and also to this forum, so please be generous for my question...
So, suppose we have
c=[[0, 1, 2, 3], [0, 1, 2, 4], [0, 1, 3, 4], [0, 2, 3, 4], [1, 2, 3, 4]],
d=[[0, 1, 2, 3], [0, 1, 3, 4], [0, 2, 3, 4], [9, 8, 7, 6]]
I would like to get
[[0, 1, 2, 3], [0, 1, 3, 4], [0, 2, 3, 4]]
which is intersection of c and d. Is there a way to do this?
Thank you for any help.sssageeeeSat, 04 Mar 2017 14:48:54 -0600http://ask.sagemath.org/question/36829/Plot the intersection of two surfaces (or solutions of a system of eqs)http://ask.sagemath.org/question/33418/plot-the-intersection-of-two-surfaces-or-solutions-of-a-system-of-eqs/ Hi everybody,
I'd like to plot the solutions of the system
$$(X + Y )(X − Z^3)=0,$$
$$XY + Y^2=0.$$
in 3D, I mean, the set of points (X,Y,Z) in IR^3 that verify the system. I don't know how to do it. I was searching how to plot the intersection of both surfaces, but neither I could. ¿Could anyone tell me how to do it?
Thanks in advanceMinkowskiMon, 16 May 2016 11:03:59 -0500http://ask.sagemath.org/question/33418/Constructing subgroups by intersectionhttp://ask.sagemath.org/question/25955/constructing-subgroups-by-intersection/ I'd like to construct a subgroup of $Sp\left(4,\mathbb{Z}\right)$ of the form:
$$G_0\left(N\right) = M\left(N\right)
\cap {Sp}\left(4,\mathbb{Z}\right)$$
where $M\left(N\right)$ is a $4\times4$ matrix over the integer ring with elements that are multiples of the integer $N$. I think I know how to construct such an $M\left(N\right)$ for a given $N$, but how does one then construct such a subgroup $G_0\left(N\right)$? Thanks!JimereeFri, 27 Feb 2015 12:03:03 -0600http://ask.sagemath.org/question/25955/curves in a plane, find intersecting points?http://ask.sagemath.org/question/24353/curves-in-a-plane-find-intersecting-points/can anyone please help???
Let n be your ID number and consider the curves in the plane R2 that are defined by the equations, y2 = x3 − nx and xy = 1. At how many points do these curves intersect?fionaTue, 30 Sep 2014 16:49:15 -0500http://ask.sagemath.org/question/24353/Error intersecting polyhedrahttp://ask.sagemath.org/question/10202/error-intersecting-polyhedra/I have a dictionary of polyhedra which I want to consider various intersections and unions of. For now, my dictionary has four polyhedra in it. When running the following for loop:
v={} # contains coordinates of the tetrahedron, centered at (0,0,0)
v[1] = vector([1,0,-1/sqrt(2)])
v[2] = vector([-1,0,-1/sqrt(2)])
v[3] = vector([0,1,1/sqrt(2)])
v[4] = vector([0,-1,1/sqrt(2)])
V = {1,2,3,4}
b={} # will contain coordinates of vertices of the subdivision of the tetrahedron
for X in powerset(V):
q = len(X)
if q > 0:
b[tuple(X)] = (1/q)*sum([v[i] for i in X])
poly_int = Polyhedron([b[key] for key in b.keys()]) # this is a tetrahedron containing
# all of my polyhedra
for i in [1,2,3,4]:
poly_int = poly[i] & poly_int
I get a very nasty error:
AttributeError: 'Polyhedra_RDF_cdd_with_category.element_class'
object has no attribute '_Vrepresentation'
(The traceback for the error is quite long. I can include it if needed.)
Manually computing
poly[1] & poly[2] & poly[3] & poly[4]
gives the same error. HOWEVER, if instead I compute
(poly[1] & poly[2]) & (poly[3] & poly[4])
I get no errors. While this is a fine workaround for this particular case, I'm scripting these intersections and need some way to actually compute these intersections automatically. Using something like
poly[1].intersection(poly[2]) # etc.
doesn't help either. Any thoughts?BillThu, 06 Jun 2013 10:13:30 -0500http://ask.sagemath.org/question/10202/Intersection of a line and a planehttp://ask.sagemath.org/question/9855/intersection-of-a-line-and-a-plane/Hi,
I have a line described by points (1, 0, 1), (4, -2, 2) and a plane x + y + z = 6. If solve by hand I get the point of intersection as (7, -4, 3). But in sage, I don't find any intersection point. My code in sage is as follows:
P = Polyhedron(eqns=[(-6,1,1,1)])
L = [[1, 0, 1], [4, -2, 2]]
L1 = Polyhedron(L)
intersect = L1.intersection(P)
Output is "The empty polyhedron in QQ^3". Whats wrong here? my calculation by hand or my code?
assadabbasiTue, 26 Feb 2013 17:03:37 -0600http://ask.sagemath.org/question/9855/Intersection of a hyperplane with a polytope (intersection in 9D)http://ask.sagemath.org/question/9829/intersection-of-a-hyperplane-with-a-polytope-intersection-in-9d/Hi,
I have a hyperplane given by equation:
2/3*x1 + 2/3*x2 + 2/3*x3 - 1/3*x4 - 1/3*x5 - 1/3*x6 - 1/3*x7 -1/3*x8 - 1/3*x9 = 1
and a polytope with nine vertices:
P = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [-8/9, 1/9, 1/9, 1/9, 1/9, 1/9, 1/9, 1/9, 1/9], [-7/9, -7/9, 2/9, 2/9, 2/9, 2/9, 2/9, 2/9, 2/9], [-2/3, -2/3, -2/3, 1/3, 1/3, 1/3, 1/3, 1/3, 1/3], [-5/9, -5/9, -5/9, -5/9, 4/9, 4/9, 4/9, 4/9, 4/9], [-4/9, -4/9, -4/9, -4/9, -4/9, 5/9, 5/9, 5/9, 5/9], [-1/3, -1/3, -1/3, -1/3, -1/3, -1/3, 2/3, 2/3, 2/3], [-2/9, -2/9, -2/9, -2/9, -2/9, -2/9, -2/9, 7/9, 7/9], [-1/9, -1/9, -1/9, -1/9, -1/9, -1/9, -1/9, -1/9, 8/9]]
Each vertex in this polytope is connected to other eight vertices with a line.
I have tried with the following approach but I am unable to get the correct result.
First I created a polyhedron from the equation of the hyperplane as follows:
Hplane1 = Polyhedron(eqns=[(-3,2,2,2,-1,-1,-1,-1,-1,-1)])
Next I used this code to find the intersection between hyperplane and the line connected by every two vertices of the Polytope 'P'
for j in range(len(P)):
for i in range(len(P)):
if i != j:
a = Polyhedron( vertices = [P[i], P[j]])
b = a.intersection(Hplane1)
print(b)
I know the this hyperplane and the polytope have some intersection points but I am unable to calculate them. Any help/suggestion will be highly appreciated.
ThanksassadabbasiThu, 21 Feb 2013 17:27:14 -0600http://ask.sagemath.org/question/9829/Intersection of a Cube with two planes and resulting polyhedronhttp://ask.sagemath.org/question/9818/intersection-of-a-cube-with-two-planes-and-resulting-polyhedron/Hi,
I am new to sage and trying to solve a problem where I have two planes cutting a cube. How can I find the resulting polytope/polyhedron as a result of this cut.
cube = polytopes.n_cube(3)
cube.Hrepresentation()
plane1 = Polyhedron(eqns=[(0,1,0,0)])
plane2 = Polyhedron(eqns=[(1,0,0,-1)])
Please also tell me that what is meant by `eqns=[(0,1,0,0)]` in sage? what equality it represent? similarly `eqns=[(1,0,0,-1)]` ?
Thanks
assadabbasiMon, 18 Feb 2013 17:21:51 -0600http://ask.sagemath.org/question/9818/