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.Thu, 24 Nov 2022 10:30:01 +0100Solving 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/splitting of primes in extension fieldshttps://ask.sagemath.org/question/64725/splitting-of-primes-in-extension-fields/Call L the maximal real subfield of the cyclotomic field of order 148.
The field L has a quartic subfield — call it K.
I want to see how a prime ideal of K splits in the top field L.
I defined L and K as follows.
sage: C.<a> = CyclotomicField(148)
sage: g = a + a**-1
sage: L.<b> = NumberField(g.minpoly())
sage: subfields = L.subfields()
sage: K = subfields[3][0]
sage: K
Number Field in b3 with defining polynomial x^4 - 37*x^2 + 333
sage: I=K.ideal(37)
sage: F=I.factor()
sage: (Fractional ideal (37, b3))^4
sage: P=list[F]
sage: P
(Fractional ideal (37, b3), 4)
sage: P1= P[0];P1
Fractional ideal (37, b3)
I would like to see how the prime ideal P1 of K factor in the top field L. I tried the following code.
sage: O = L.ring_of_integers()
sage: J = O.P1
But I got the error: No compatible natural embeddings found for Number Field in b with defining polynomial x^36 - 37*x^34 + 629*x^32 - 6512*x^30 + 45880*x^28 - 232841*x^26 + 878787*x^24 - 2510820*x^22 + 5476185*x^20 - 9126975*x^18 + 11560835*x^16 - 10994920*x^14 + 7696444*x^12 - 3848222*x^10 + 1314610*x^8 - 286824*x^6 + 35853*x^4 - 2109*x^2 + 37 and Number Field in b3 with defining polynomial x^4 - 37*x^2 + 333
Could you please help me with this? Thank you.RashadTue, 01 Nov 2022 17:17:32 +0100https://ask.sagemath.org/question/64725/Problem with various type in linear programminghttps://ask.sagemath.org/question/63893/problem-with-various-type-in-linear-programming/ The following program is well defined
f(x) = 4*x-0.9*x^2
lr=6
pas=1# 0.5,0.25
lsp=lr/pas
X=[n(pas*i,14) for i in range(0,Integer(lr/pas))]
pente=[diff(f(x),x).subs(x=X[i]) for i in range(0,Integer(lsp))]
optim_1 = MixedIntegerLinearProgram(maximization=False, solver = "GLPK")
x = optim_1.new_variable(integer=False, indices=[0..len(X)+1]) # les nouvelles variables seront x[1]... x[7]}
for i in range(0, len(X)):
optim_1.add_constraint(x[len(X)+1]<=pente[i]*(x[i]-X[i]))
optim_1.set_objective(x[len(X)+1])
optim_1.show()
but unfortunatelly for me the constraints are
optim_1.add_constraint(x[len(X)+1]<=pente[i]*(x[i]-X[i])+f(X[i])
But in that case, I raise the error ` unsupported operand parent(s) for +: 'Linear functions over Real Double Field' and 'Symbolic Ring'`. I perfectly uderstand the problem but I do not know. I do not know in what type to transform f(X[i]), if this is the problem.CyrilleFri, 02 Sep 2022 16:28:37 +0200https://ask.sagemath.org/question/63893/Problem with various type in linear programminghttps://ask.sagemath.org/question/63892/problem-with-various-type-in-linear-programming/ The following program is well defined
f(x) = 4*x-0.9*x^2
lr=6
pas=1# 0.5,0.25
lsp=lr/pas
X=[n(pas*i,14) for i in range(0,Integer(lr/pas))]
pente=[diff(f(x),x).subs(x=X[i]) for i in range(0,Integer(lsp))]
optim_1 = MixedIntegerLinearProgram(maximization=False, solver = "GLPK")
x = optim_1.new_variable(integer=False, indices=[0..len(X)+1]) # les nouvelles variables seront x[1]... x[7]}
for i in range(0, len(X)):
optim_1.add_constraint(x[len(X)+1]<=pente[i]*(x[i]-X[i]))
optim_1.set_objective(x[len(X)+1])
optim_1.show()
but unfortunatelly for me the constraints are
optim_1.add_constraint(x[len(X)+1]<=pente[i]*(x[i]-X[i])+f(X[i])
But in that case, I raise the error ` unsupported operand parent(s) for +: 'Linear functions over Real Double Field' and 'Symbolic Ring'`. I perfectly uderstand the problem but I do not know. I do not know in what type to transform f(X[i]), if this is the problem.CyrilleFri, 02 Sep 2022 16:28:33 +0200https://ask.sagemath.org/question/63892/Algebra of functions f:Z_3 -> Rhttps://ask.sagemath.org/question/45402/algebra-of-functions-fz_3-r/ I want to create an implementation of an algebra of functions with domain {0,1,2} and range in R. The sum and the product is the usual pointwise sum and product. I have the idea of represent it as a 3 dimensional vectors with the usual sum of vectors, bot I need implement a new product.
The implementation of this algebra will be used for create a polynomial system of equations that I need to solve, so the implementation should be compatible with the procedure indicated in the entry titled *Find algebraic solutions to system of polynomial equations*
If someone have any idea please help me.
Thanks in advance.JulioNAQSat, 09 Feb 2019 22:01:49 +0100https://ask.sagemath.org/question/45402/Finding a p-value in goodness of fit testhttps://ask.sagemath.org/question/37481/finding-a-p-value-in-goodness-of-fit-test/I'm trying to find the p-value in a goodness of fit test comparing a set of observed values to a set of expected values. In Maple I can do it with **ChiSquareGoodnessOfFitTest(Ob, Ex, level = 0.5, summarize = true)**, but I can't figure out its equivalence in Sage.
There's a function **sage.stats.r.ttest(x, y)**, but when I run it on my sets, it says the p-value is 1 (it's supposed to be 0.00001778, as in Maple).
The sets for reference are *expected=[47.04, 25.48, 31.36, 39.2, 25.48, 27.44]*, *observed=[42, 35, 9, 41, 41, 28]*.Ross1856Mon, 01 May 2017 17:59:12 +0200https://ask.sagemath.org/question/37481/How to Plot/Graph/Show a system of linear equationshttps://ask.sagemath.org/question/36780/how-to-plotgraphshow-a-system-of-linear-equations/Disclaimer: I'm new to Sage Math and Linear equations.
Background: Google will plot/graph this search: "plot 3x+4y"
Questions:
1. In Sage Math, how can I show similar output as Google?
2. Is there a better way, in 2D or 3D, to plot the following? 3x+4y=2.5 AND 5x-4y=25.5 ?
x, y = var('x,y')
a=3*x+4*y==2.5
b=5*x-4*y==25.5
p1=implicit_plot(a, (x,-2,5), (y,-4,4), axes="true", aspect_ratio=1)
p2=implicit_plot(b, (x,-2,5), (y,-4,4), axes="true", aspect_ratio=1)
show(p1+p2)mellow-yellowWed, 01 Mar 2017 22:07:21 +0100https://ask.sagemath.org/question/36780/About p-th root of unity in \bar Q_phttps://ask.sagemath.org/question/36594/about-p-th-root-of-unity-in-bar-q_p/ I am wondering if anyone knows
1. How to define Q_p[\mu_p] in sage, where \mu_p is a primitive p-th root of unity in \bar Q_p.
2. How to write b=\mu_p.
3. Solve a quadratic equation x^2+a_1x+a_2=0, where a_1 and a_2 are both in Q_p[\mu_p].
4. Is log function defined on Q_p[\mu_p] .
Thank you in advance!mathcrazy1Mon, 13 Feb 2017 03:35:06 +0100https://ask.sagemath.org/question/36594/Finding prime factorization of ideals in number ringshttps://ask.sagemath.org/question/35209/finding-prime-factorization-of-ideals-in-number-rings/Let $K$ be a number field and $O_K$ its ring of algebraic integers. Let $p\in\mathbb{Z}$ be a rational prime. I want to find the factorization of the ideal $pO_K$. What is the syntax for this ?
For clarity, I request you to demonstrate with an example (say $K=\mathbb{Q}(\sqrt{2}+i)$ and $p=2$ and $p=3$).nebuckandazzerFri, 21 Oct 2016 15:28:30 +0200https://ask.sagemath.org/question/35209/irreducibility of a polynomialhttps://ask.sagemath.org/question/34244/irreducibility-of-a-polynomial/If f $f(x)$ is a polynomial, i know that the command $f.factor()$ gives the factorization of f. But I am interested in knowing whether the polynomial is irreducible or not, not its factors. Is there any command for that ? nebuckandazzerTue, 26 Jul 2016 22:54:08 +0200https://ask.sagemath.org/question/34244/Solving a system of equations using mpmath.findroothttps://ask.sagemath.org/question/32678/solving-a-system-of-equations-using-mpmathfindroot/ Hi All,
A few weeks ago, the code below, which was designed to compute some points was working perfectly.
After compiling it a few days ago, I got :
ValueError: Could not find root within given tolerance. (7235.55 > 2.1684e-19)
Try another starting point or tweak arguments.
Please I will be very pleased if someone could help me solve this problem. Thanks for your understanding
import mpmath
theta=pi/12
p1=vector([0,0,0])
p2=vector([-12,0,0])
p3=vector([1/24,-17/24*sqrt(287),0])
#Calcul du point p4
x4,r4=var('x4,r4')
T4=solve([(p1[0]-x4)^2+(p1[1]-r4*cos(theta))^2+(p1[2]-r4*sin(theta))^2==25,(p2[0]-x4)^2+(p2[1]-r4*cos(theta))^2+(p2[2]-r4*sin(theta))^2==100],x4,r4,solution_dict=True)
a=T4[0].values()
b=T4[1].values()
p4=vector([a[1],0,0])
if b[0]<0:
p4[1]=a[0]*cos(theta)
p4[2]=a[0]*sin(theta)
else:
p4[1]=b[0]*cos(theta)
p4[2]=b[0]*sin(theta)
var(" x5 y5 z5 x6 y6 z6 x7 y7 z7")
eq25 = (p2[0]-x5)^2+(p2[1]-y5)^2+(p2[2]-z5)^2-100 == 0
eq46 = (p4[0]-x6)^2+(p4[1]-y6)^2+(p4[2]-z6)^2-144 == 0
eq45 = (p4[0]-x5)^2+(p4[1]-y5)^2+(p4[2]-z5)^2-121 == 0
eq16 = (p1[0]-x6)^2+(p1[1]-y6)^2+(p1[2]-z6)^2-100 == 0
eq27 = (p2[0]-x7)^2+(p2[1]-y7)^2+(p2[2]-z7)^2-144 == 0
eq37 = (p3[0]-x7)^2+(p3[1]-y7)^2+(p3[2]-z7)^2-144 == 0
eq56 = (x6-x5)^2+(y6-y5)^2+(z6-z5)^2-144 == 0
eq67 = (x6-x7)^2+(y6-y7)^2+(z6-z7)^2-100 == 0
eq57 = (x7-x5)^2+(y7-y5)^2+(z7-z5)^2-25 == 0
# Calcul des points p5, p6, et p7
f= [lambda x5,y5,z5,x6,y6,z6,x7,y7,z7: eq25.lhs().subs(x5=RR(x5), y5=RR(y5), z5=RR(z5), x6=RR(x6), y6=RR(y6), z6=RR(z6), x7=RR(x7), y7=RR(y7), z7=RR(z7)),
lambda x5,y5,z5,x6,y6,z6,x7,y7,z7: eq46.lhs().subs(x5=RR(x5), y5=RR(y5), z5=RR(z5), x6=RR(x6), y6=RR(y6), z6=RR(z6), x7=RR(x7), y7=RR(y7), z7=RR(z7)),
lambda x5,y5,z5,x6,y6,z6,x7,y7,z7: eq45.lhs().subs(x5=RR(x5), y5=RR(y5), z5=RR(z5), x6=RR(x6), y6=RR(y6), z6=RR(z6), x7=RR(x7), y7=RR(y7), z7=RR(z7)),
lambda x5,y5,z5,x6,y6,z6,x7,y7,z7: eq16.lhs().subs(x5=RR(x5), y5=RR(y5), z5=RR(z5), x6=RR(x6), y6=RR(y6), z6=RR(z6), x7=RR(x7), y7=RR(y7), z7=RR(z7)),
lambda x5,y5,z5,x6,y6,z6,x7,y7,z7: eq27.lhs().subs(x5=RR(x5), y5=RR(y5), z5=RR(z5), x6=RR(x6), y6=RR(y6), z6=RR(z6), x7=RR(x7), y7=RR(y7), z7=RR(z7)),
lambda x5,y5,z5,x6,y6,z6,x7,y7,z7: eq37.lhs().subs(x5=RR(x5), y5=RR(y5), z5=RR(z5), x6=RR(x6), y6=RR(y6), z6=RR(z6), x7=RR(x7), y7=RR(y7), z7=RR(z7)),
lambda x5,y5,z5,x6,y6,z6,x7,y7,z7: eq56.lhs().subs(x5=RR(x5), y5=RR(y5), z5=RR(z5), x6=RR(x6), y6=RR(y6), z6=RR(z6), x7=RR(x7), y7=RR(y7), z7=RR(z7)),
lambda x5,y5,z5,x6,y6,z6,x7,y7,z7: eq67.lhs().subs(x5=RR(x5), y5=RR(y5), z5=RR(z5), x6=RR(x6), y6=RR(y6), z6=RR(z6), x7=RR(x7), y7=RR(y7), z7=RR(z7)),
lambda x5,y5,z5,x6,y6,z6,x7,y7,z7: eq57.lhs().subs(x5=RR(x5), y5=RR(y5), z5=RR(z5), x6=RR(x6), y6=RR(y6), z6=RR(z6), x7=RR(x7), y7=RR(y7), z7=RR(z7))]
found_root = mpmath.findroot(f, (-5,-6,-3.5, 3.5, 0.1,-9,-5,-5,-8))
found_root = Matrix(RR, found_root.tolist())
p5=vector([found_root[0][0], found_root[1][0], found_root[2][0]])
p6=vector([found_root[3][0], found_root[4][0], found_root[5][0]])
p7=vector([found_root[6][0], found_root[7][0], found_root[8][0]])
print p5
cyrilleSat, 27 Feb 2016 08:55:33 +0100https://ask.sagemath.org/question/32678/