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.Sun, 01 Oct 2023 15:50:02 +0200Rational parametrization of affine curvehttps://ask.sagemath.org/question/73676/rational-parametrization-of-affine-curve/Why is there error evaluating this?
B.<x,y> = AffineSpace(QQ,2)
p=Curve([3*x^2 + 2*y^2 - 5],B)
p.rational_parameterization()azerbajdzanSun, 01 Oct 2023 15:50:02 +0200https://ask.sagemath.org/question/73676/Getting exact answers when using eigenvectors_right()https://ask.sagemath.org/question/66147/getting-exact-answers-when-using-eigenvectors_right/ I am trying to compute complex eigenvectors for a matrix that has two distinct complex eigenvalues. Is there a way to get the exact coefficients?
For example:
A=matrix(QQ,2,2,[3, -13, 5,1])
A.eigenvectors_right()
Gives me:
[(2 + 8*I,
[
(1, 0.07692307692307692? - 0.6153846153846154?*I)
],
1),
(2 - 8*I,
[
(1, 0.07692307692307692? + 0.6153846153846154?*I)
],
1)]
Is there any way to make it give me integer or rational Re and Im for the eigenvectors?
Thank you!
TatiMon, 30 Jan 2023 19:09:59 +0100https://ask.sagemath.org/question/66147/Solving a system of equations over the field of rational functions in Qhttps://ask.sagemath.org/question/65029/solving-a-system-of-equations-over-the-field-of-rational-functions-in-q/ I have a system of equations over the field of rational functions with coefficients in Q:
g == x^2 (r + b+1), r == x^3 (g + b+1), b == x (r + g+1),
where g, r and b are unknown rational functions with coefficients in Q. How do I solve this with Sage?
Thank you!MalteThu, 24 Nov 2022 10:30:01 +0100https://ask.sagemath.org/question/65029/Rational variablehttps://ask.sagemath.org/question/64398/rational-variable/ How would one define the domain of a symbolic variable to be rational? For a real variable $a$ it would be var('a', domain='real') or var('a', domain='RR'). However, it seems that the domain can only be 'complex', 'real', 'positive' or 'integer'. Is there a reason for this and how would one get around this if one needs to define a rational variable?AlAnGeToWed, 12 Oct 2022 03:43:59 +0200https://ask.sagemath.org/question/64398/Degree of a rational map and the corresponding map between function fieldshttps://ask.sagemath.org/question/63229/degree-of-a-rational-map-and-the-corresponding-map-between-function-fields/Let $X$ and $Y$ be two curves defined over $\mathbb{F}_q $ and $f:X \rightarrow Y$ be a separable rational map. Then there is field embedding
$$
f^\ast : \mathbb{F}_q (Y) \rightarrow \mathbb{F}_q (X)
$$ defined by
$f^\ast(\alpha) = \alpha \circ f$.
The degree of $f$ is then defined to be $[\mathbb{F}_q (X) : f^\ast(\mathbb{F}_q (Y))]$.
If I take two curves $X$ and $Y$ in sagemath over some $\mathbb{F}_q $ in sagemath, is there any way to automatically get the map $f^\ast$ and degree of $f$?DodulWed, 13 Jul 2022 08:56:42 +0200https://ask.sagemath.org/question/63229/simplify rational expressionhttps://ask.sagemath.org/question/58434/simplify-rational-expression/Hi
W10,SageMath 9.2
I wanted to answer this [question](https://www.maths-forum.com/cafe-mathematique/sagemath-t235617.html), but I realized that myself, I was not able to answer it ! ;-(
how to simplify eq below ?
var('a,b,c,d',domain='real')
assume (d!=0)
eq=(a+b)/(c*d)==3/d
print(eq)
print (eq.simplify())
print(eq.simplify_full())
print(eq.simplify_rational())
print(eq.simplify_rational())ortolljFri, 13 Aug 2021 10:24:20 +0200https://ask.sagemath.org/question/58434/How to import rings in python modulehttps://ask.sagemath.org/question/55403/how-to-import-rings-in-python-module/I'm trying to build a sage 9 code into a format of python module with .py file, and run the module in the sage command line. Most of the issue could be fixed through this webpage https://doc.sagemath.org/html/en/tutorial/programming.html by importing packages with command line such as
import_statements('is_integer')
i.e. set up the sage environment manually. However, a built in mechanism in sage was the usage of rings. i.e.
1/3 in sage automatically returned 1/3 in rational ring, but when put the code in python module and run it in sage command line.
sage: module_name.value1
was in class 'float' or 'int'
How to set up the environment so that the module could run operation in sage rings automatically?ShoutOutAndCalculateThu, 21 Jan 2021 07:10:55 +0100https://ask.sagemath.org/question/55403/Solving system of polynomial equations over rationalshttps://ask.sagemath.org/question/49112/solving-system-of-polynomial-equations-over-rationals/I want to solve a system of polynomial equations but I need only rational solutions. What is the best method to do it in Sage?
For example:
Input:
R.<a1,b1,b2,c1,c2> = QQ[]
J = R.ideal(5*(9 + 2*a1^2 - b2), 5*(-324 + 4*a1*b1 + b2^2 - c2), 10*(729 + 2*a1 + b1^2 + 243*b2 - 9*b2^2 + 2*a1*c1 + b2*c2), 5*(6561 + 4*b1 - 2916*b2 + 4*b1*c1 + 486*c2 - 36*b2*c2 + c2^2), 2*(-59048 + 10*c1 + 5*c1^2 - 7290*c2 - 45*c2^2))
J.variety()
Output:
[]
Or example with some solutions (same as above but added constant 1889566 to last equation):
Input:
R.<a1,b1,b2,c1,c2> = QQ[]
J = R.ideal(5*(9 + 2*a1^2 - b2), 5*(-324 + 4*a1*b1 + b2^2 - c2),
10*(729 + 2*a1 + b1^2 + 243*b2 - 9*b2^2 + 2*a1*c1 + b2*c2),
5*(6561 + 4*b1 - 2916*b2 + 4*b1*c1 + 486*c2 - 36*b2*c2 + c2^2),
2*(-59048 + 10*c1 + 5*c1^2 - 7290*c2 - 45*c2^2)+1889566)
J.variety()
Output:
[{a1: 0, c1: 0, b1: 0, b2: 9, c2: -243},
{a1: 0, c1: -2, b1: 0, b2: 9, c2: -243}]
> **It takes quite a lot of time for the output to appear, while in Mathematica
> it takes a second. So is there a
> better method in Sage than the one I
> used?**azerbajdzanSat, 21 Dec 2019 17:10:21 +0100https://ask.sagemath.org/question/49112/1.5 as a fractionhttps://ask.sagemath.org/question/48536/15-as-a-fraction/ I know that 3รท2=1.5, but how do you write 1.5 in fraction form.CoolTue, 29 Oct 2019 01:48:01 +0100https://ask.sagemath.org/question/48536/How do I save a rational matrix for Mathematica and Matlab to read?https://ask.sagemath.org/question/45141/how-do-i-save-a-rational-matrix-for-mathematica-and-matlab-to-read/Hi,
I create a rational matrix (rather large, say 1000x1000), and I want to save it in a file that can be read by Mathematica or MATLAB (with symbolic toolbox). Is there a simple way to do that?
Right now, I use
o = open('file.txt','w')
o.write(str(A))
o.close()
where A is the matrix. However, it has these "[" and "]" at the beginning of line that makes it difficult for Mathetmatica and MATLAB to read. Any suggestions would be appreciated.raykanWed, 23 Jan 2019 05:01:12 +0100https://ask.sagemath.org/question/45141/Enumerating lattice points in rational polytopeshttps://ask.sagemath.org/question/39135/enumerating-lattice-points-in-rational-polytopes/ Is there a way to ask Sage to count the number of lattice points in a rational polytope, say a polytope with vertices (0,0,0,0), (0,0,0,7), (0,0,7/2,7/2), (0,7/3,7/3,7/3),(7/4,7/4,7/4,7/4)?ProfHeimerThu, 12 Oct 2017 05:04:05 +0200https://ask.sagemath.org/question/39135/rational numbers with cythonhttps://ask.sagemath.org/question/33154/rational-numbers-with-cython/ I want to work efficiently with rational numbers under the context %cython but I don`t know how. Can anyone suggest any ideas? Thank you.
An example:
%cython
def rational_partitions(n):
sol = [i/n for i in range(n)]
for a in sol[0:-1]:
for b in sol[1:]:
k=2
while abs(b-a)/k>1/n:
sol.append(abs(b-a)/k)
k += 1
return sol
rational_partitions(10)rafarob32Wed, 20 Apr 2016 17:07:20 +0200https://ask.sagemath.org/question/33154/Integer result for fractionhttps://ask.sagemath.org/question/32347/integer-result-for-fraction/ Hi!
Can somebody explain me this strange behavior of Sage :
for p in range(1,10):
for q in range(1,10):
print p/q
Then `p/q` return the integer division.
However:
for p in range(1,10):
print p/7
give rational results.
A solution is to use `Rational(p)/Rational(q)` instead of `p/q`. But it is not an explanation.
Thanks,
Arnaud
Arnaud1418Wed, 27 Jan 2016 20:12:43 +0100https://ask.sagemath.org/question/32347/Cast expression to rational numberhttps://ask.sagemath.org/question/32195/cast-expression-to-rational-number/ Hello,
I am trying to perform the ceil() function on the result of a square root operation. My code is as follows:
x = 10
x = x.sqrt()
x = x.ceil()
However, I get the following error:
AttributeError: 'sage.symbolic.expression.Expression' object has no attribute 'ceil'
I have tried searching the the documentation, but I can't seem to find a straight forward way to "flatten" this expression to a rational number. How can I go about this?
Thanks,sagenibbleThu, 14 Jan 2016 16:09:56 +0100https://ask.sagemath.org/question/32195/finding rational points on an elliptic curvehttps://ask.sagemath.org/question/25314/finding-rational-points-on-an-elliptic-curve/ Consider the following elliptic curve
$y^2=(x+1540)(x-508)(x-65024)$.
It is trivial that the points $P_1(-1540,0)$, $P_2(508,0)$ and $P_3(65024,0)$ lie on this curve.
It is also quite easy to find four other integer points $P_4(-508, 262128)$, $P_5(-508, -262128)$,
$P_6(130556, 33552384)$ and $P_7(130556, -33552384)$.
I want to find some other **rational** points on this curve. If one uses the usual group law we obtain that for every $1\le i \le j \le 7$ we have $P_i+P_j=P_k$ for some $1\le k\le 7$. Thus we fail to obtain any new points.
Any suggestion would be appreciated.
dan_ismailescuSun, 21 Dec 2014 16:47:32 +0100https://ask.sagemath.org/question/25314/