ASKSAGE: Sage Q&A Forum - Latest question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 18 Jan 2021 09:41:46 -0600How can I compute a fixed field over the p-adicshttps://ask.sagemath.org/question/55336/how-can-i-compute-a-fixed-field-over-the-p-adics/I have problems to implement the following set up:
I want to have a field $K = \mathbb{Q}_3$ and an extension $L = \mathbb{Q}_3(\alpha)$ over $K$ where $f:=\min_K(\alpha) = x^4 - 3x^2 + 18$. This extension has degree $4$ and ramification index $2$. Furthermore, let $F/K$ be the unique unramified extension of $K$ of degree $4$ which is generated by a primitive $5$-th root of unity $\zeta_5$.
Then one can show that $\varphi: \alpha \mapsto \frac{(2 \alpha^2 - 3)\sqrt{-\frac{2}{7}}}{\alpha},$ $\zeta_5 \mapsto \zeta_5^3$ is an element of the Galois group of $LF/K$. Now let $L' = (LF)^{\langle \varphi \rangle}$. This must be a quadratic and totally ramified extension of $K$. There are only two possibilities for that: $K(\sqrt{3})$ or $K(\sqrt{-3})$.
**Question**: How to determine whether $L' = K(\sqrt{3})$ or $L' = K(\sqrt{-3})$ (or equivalently, $\varphi(\sqrt{3}) = \sqrt{3}$ or $\varphi(\sqrt{-3}) = \sqrt{-3}$)?
Since I only have only superficial knowledge about Sage, I was not even able to set up the easy things like the field $L$ properly. When I use
K = Qp(3)
R.<x> = ZZ[]
f = x^4 - 3*x^2 + 18
L.<alpha> = K.extension(f)
I get an error that my polynomial $f$ must be either unramified or Eisenstein (which of course does not exist since $L/K$ is neither unramified nor totally ramified). Furthermore, I have no idea how to approach with my problem with Sage otherwise. And since computation by hand is pretty hard in this case (I already tried!), it would be nice to solve with problem here, so I can use it for similar computations in the future.
Could you please help me with this problem?RotdatMon, 18 Jan 2021 09:41:46 -0600https://ask.sagemath.org/question/55336/How to do low degree computation in a Free Algebra ?https://ask.sagemath.org/question/55269/how-to-do-low-degree-computation-in-a-free-algebra/Say $F$ is a free algebra over $n$ generators of degree $1$, and i want to compute in this algebra but i only need to get my expressions up to degree $k$. For example, if $k=2$, $(ab +a)*b$ should be $ab$.
For now, i have been doing the computation and truncating everything above degree $k$, but the time complexity is too high when i launch a big computation.
I am actually asking how to compute in the tensor Algebra $T(V)$ modulo $T_{\geq k}(V)$. For free Lie algebras, this can be done using nilpotent Lie algebras, (for example `L = LieAlgebra(QQ, 3, step=3)` implements a 3-nilpotent free Lie algebra). How to do this with free algebras ?qfaesThu, 14 Jan 2021 09:03:58 -0600https://ask.sagemath.org/question/55269/Determine Two quadratic form is integer congruence (rational equivalent)?https://ask.sagemath.org/question/55294/determine-two-quadratic-form-is-integer-congruence-rational-equivalent/Fix $n \\geq 2$ and consider $A,B \\in \\operatorname{GL}(n,\\mathbb{Z}).$
We know that we have the Smith normal form.
One can find $U, V \\in \\operatorname{SL}(n,\\mathbb{Z})$ such that $A=UDV.$
Likewise for $B$. The Smith normal form is easy to compute using Mathematica.
We also call two matrices $A,B$ congruent if there exists
$X \\in \\operatorname{PSL}(n,\\mathbb{Z})$ such that $X^TAX=B$.
Now we have the following: if two matrices are congruent, then they have the same $D$.
But now, given two 4 by 4 matrices with same Smith normal form $D$,
how to verify they are congruent?
An if they are, how to find a matrix $X$ such that $X^T A X = B$.
To be more specific, suppose
$A = \\begin{bmatrix}
2 & -1 & -1 & -1 \\\\
-1 & 2 & 0 & 0 \\\\
-1 & 0 & 2 & 0 \\\\
-1 & 0 & 0 & 2 \\\\
\\end{bmatrix}$
and
$B = \\begin{bmatrix}
4 & -6 & 4 & -2 \\\\
-6 & 12 & -8 & 4 \\\\
4 & -8 & 6 & -3 \\\\
-2 & 4 & -3 & 2 \\\\
\\end{bmatrix}.$
I want to ask whether $A,B$ are congruent. Here is how far I got.
$A$, $B$ both have the same Smith normal form
$D = \\begin{bmatrix}
1 & 0 & 0 & 0 \\\\
0 & 1 & 0 & 0 \\\\
0 & 0 & 2 & 0 \\\\
0 & 0 & 0 & 2 \\\\
\\end{bmatrix}.$
So they define the same integer lattices.
But I do not know whether they are congruent.
I suspect they are congruent but I have no idea how to prove it.
Any ideas or comments are really appreciated.
By the way, $A$ is the Cartan matrix of $SO(8).$
I think it will not help.
I used Sage and typed them in as quadratic forms.
But I found that the `is_rationally_isometric` function only works
for number field but not integers ring (if I use integers,
there will be an error like no real_embedding).
The `is_rationally_isometric` is True.
But I do not know whether they are isometric over the integers.
If the answer is true, can I find such X?
sage: A = QuadraticForm(QQ, 4, [4, -12, 8, -4, 12, -16, 8, 6, -6, 2])
sage: print(A)
sage: A1 = QuadraticForm(QQ, 4, [2, -2, -2, -2, 2, 0, 0, 2, 0, 2])
sage: print(A1)
sage: A1.is_rationally_isometric(A)
TrueGracecatFri, 15 Jan 2021 20:33:07 -0600https://ask.sagemath.org/question/55294/How to compute in the Tensor Algebra $T(V)$ ?https://ask.sagemath.org/question/55256/how-to-compute-in-the-tensor-algebra-tv/I need to make some computations in low degree in the Tensor algebra $T(V)$ of a rational vector space $V$, but i cannot find a good way of doing this. I could use FreeAlgebras, but then i cannot get access to the summands in my element : for example i want to be able to retrieve $a$ $b$ and $c$ from the element $a*b*c $ (whenever the element is homogeneous).
The reason for this is I need to define a 'cycle' function that associates $Wa$ to a tensor $aW$ when $W$ is a tensor and $a \in V$.qfaesWed, 13 Jan 2021 09:21:54 -0600https://ask.sagemath.org/question/55256/Matrix-scalar and vector-scalar operationshttps://ask.sagemath.org/question/54844/matrix-scalar-and-vector-scalar-operations/ Consider :
sage: b=vector([var("b_{}".format(u)) for u in (1..3)])
sage: B=matrix(b).transpose()*matrix(b)
Unsurprisingly :
sage: B*x
[ b_1^2*x b_1*b_2*x b_1*b_3*x]
[b_1*b_2*x b_2^2*x b_2*b_3*x]
[b_1*b_3*x b_2*b_3*x b_3^2*x]
This is less obvious (but intuitively compatible with associativity) :
sage: B+x
[b_1^2 + x b_1*b_2 b_1*b_3]
[ b_1*b_2 b_2^2 + x b_2*b_3]
[ b_1*b_3 b_2*b_3 b_3^2 + x]
This also is unsurprising :
sage: b*x
(b_1*x, b_2*x, b_3*x)
But there is nothing "obviously expectable" from this :
sage: b+x
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-29-58bd66da7aa5> in <module>
----> 1 b+x
/usr/local/sage-9/local/lib/python3.9/site-packages/sage/structure/element.pyx in sage.structure.element.Element.__add__ (build/cythonized/sage/structure/element.c:10988)()
1230 # Left and right are Sage elements => use coercion model
1231 if BOTH_ARE_ELEMENT(cl):
-> 1232 return coercion_model.bin_op(left, right, add)
1233
1234 cdef long value
/usr/local/sage-9/local/lib/python3.9/site-packages/sage/structure/coerce.pyx in sage.structure.coerce.CoercionModel.bin_op (build/cythonized/sage/structure/coerce.c:11708)()
1248 # We should really include the underlying error.
1249 # This causes so much headache.
-> 1250 raise bin_op_exception(op, x, y)
1251
1252 cpdef canonical_coercion(self, x, y):
TypeError: unsupported operand parent(s) for +: 'Vector space of dimension 3 over Symbolic Ring' and 'Symbolic Ring'
However,
sage: vector([u+x for u in b])
(b_1 + x, b_2 + x, b_3 + x)
would be a possible candidate, but I have trouble visualizing the consequences in the rest of algebraic computation rules in Sage. Is this documented ?Emmanuel CharpentierTue, 22 Dec 2020 14:02:35 -0600https://ask.sagemath.org/question/54844/Erasing some of the decimals in a listhttps://ask.sagemath.org/question/54401/erasing-some-of-the-decimals-in-a-list/ This is a nice table to the reserve of the to long decimals
A=[[10,10,10,10,10,10,10,10,10,10],[100,0,0,0,0,0,0,0,0,0],[11.1,11.1,11.1,11.1,11.1,11.1,11.1,11.1,11.1,0]
,[20,20,20,20,20,0,0,0,0,0],[50,25,12.5,6.25,3.125,1.56,0.78,0.39,0.19,0.09]]
t=table(A,header_row=["$1$","$2$","$3$","$4$","$5$","$6$","$7$","$8$","$9$","$10$"],header_column=["","Équi-Rep","Tout pour un","Un déshérité","Injuste pour 1/2","$5$","Injuste croissante"])
show(t)
I have tried to construct a function `f(x)=round(x,2)` and then to use `A.map_apply(f)` but this doesnot works since
`f(x)=round(x,2)` generates an error. How shouild I do ?CyrilleThu, 26 Nov 2020 12:11:43 -0600https://ask.sagemath.org/question/54401/Klee-Minty cube vertices for D=5https://ask.sagemath.org/question/54366/klee-minty-cube-vertices-for-d5/According to [Wikipedia](https://en.wikipedia.org/wiki/Klee–Minty_cube)
(but this is well known), A Klee-Minty cube in $D$ dimensions is defined by
$x_1\leq 5$
$4 x_1 + x_2 \leq 25$
$8 x_1 + 4 x_2 + x_3 \leq 125$
$16 x_1 + 8 x_2 + 4 x_3 + x_4 \leq 625$
$32 x_1+ 16 x_2 + 8 x_3 + 4 x_4 + x_5 \leq 3125$
$\vdots \vdots$
$2^D x_1 + 2^{D-1} x_2 + 2^{D-2} x_3 + \ldots + 4 x_{D-1} + x_D \leq 5^D$
$x_1 \geq 0$
$x_2 \geq 0$
$x_3 \geq 0$
$x_4 \geq 0$
$x_5 \geq 0$
This polyhedron has $2^D$ vertices. How can I find them?
I have tried the following code for $D = 5$ --- that is 32 vertices.
A = matrix(QQ, 10, 5,
[0, 0, 0, 0, -1,
0, 0, 0, -1, -4,
0, 0, -1, -4, -8,
0, -1, -4, -8, -16,
-1, -4, -8, -16, -32,
1, 0, 0, 0, 0,
0, 1, 0, 0, 0,
0, 0, 1, 0, 0,
0, 0, 0, 1, 0,
0, 0, 0, 0, 1])
show(LatexExpr(r"\text{A = }"), A)
b = vector(QQ, [5, 254, 125, 625, 3125, 0, 0, 0, 0, 0])
show(LatexExpr(r"\text{b = }"), b)
c = vector(QQ, [2^4, 2^3, 2^2, 2^1, 2^0])
show(LatexExpr(r"\text{c = }"), c)
AA = matrix(list(list([b]) + list(transpose(A))))
show(transpose(AA))
pol = Polyhedron(ieqs=AA)
pol.Hrepresentation()
But I am far away from the account and some of the vertices
are in the negative part of the hyperplane (which is impossible).
Need some help to decipher my mistake(s). Thanks.CyrilleMon, 23 Nov 2020 10:04:16 -0600https://ask.sagemath.org/question/54366/All 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 14:12:20 -0500https://ask.sagemath.org/question/54066/Reuse of already entered parametershttps://ask.sagemath.org/question/48206/reuse-of-already-entered-parameters/ I would like to know if there is a general procedure to reuse some already enter parameters. For instance In
> MixedIntegerLinearProgram
one can enter an inequation as
> p.add_constraint( a[1,1]*x[0] + a[1,2]*x[1] + c[1,3]*x[2] >= b [1])
and now I need a[1, 1] ..., a[1, 3] and b[1]
to write
>pol = Polyhedron(ieqs = [[-b [1], a[1, 1], a[1, 2]],...].
And when the result of a calculaton is verbose --- composed of strings and numbers ---, how to keep only the interesting part ?
CyrilleSun, 06 Oct 2019 12:03:35 -0500https://ask.sagemath.org/question/48206/apply map in multiple dimensionhttps://ask.sagemath.org/question/53817/apply-map-in-multiple-dimension/ I have a this list
ver1=[(0.00,0.50,0.75),(0.00,−0.50,0.75),(0.50,0.75,0.00),(0.50,−0.75,0.00)]
I want apply the function `f(x,y, z)` say `0.3*ver[0][0]+ 0.7*ver[1][0]+ 0.2*ver[2][0]` to each 3-tuple of this function. I know that map do it but the exemples are for for only one variable not for 3.
I have tried to transform ver1 in matrix but after I do not know how to proceed. Perhaps it is not possible ?CyrilleSat, 10 Oct 2020 09:42:30 -0500https://ask.sagemath.org/question/53817/Seemingly false answer by bool()https://ask.sagemath.org/question/53775/seemingly-false-answer-by-bool/I plot the inequalities
var("x_1","x_2")
eq1=solve(3*x_1+4*x_2==14,x_2)
eq2=solve(5*x_1+6*x_2==-8,x_2)
eq3=solve(4*x_1-7*x_2==18,x_2)
eq4=solve(2*x_1-3*x_2==-8,x_2)
b=10
p=plot([eq1[0].rhs(),eq2[0].rhs(),eq3[0].rhs(),eq4[0].rhs()], (x_1, 0,b),color=["#c72b91","#2b37c7", "#cb7b2b","#2bcb4b"],axes_labels=["$x_1$","$x_2$"],legend_label=[r"$%s$"%latex(eq1[0].rhs()),r"$%s$"%latex(eq2[0].rhs()),r"$%s$"%latex(eq3[0].rhs()),r"$%s$"%latex(eq4[0].rhs())])
show(p)
which shows that the `eq1` is always above for any $x\geq 0$ to `eq2`. The same for `eq4`. But there is an intersection with `eq3`. So the following code shoud return true for both `bool`. And this is not the case.
assume(x_1 >0)
show(bool(eq1[0][0].rhs()>eq2[0][0].rhs()))
show(bool(eq3[0][0].rhs()>eq2[0][0].rhs()))
and this is confirmed by the fact that
solve(eq3[0][0].rhs()>eq3[0][0].rhs()
return for solution `eq2[0][0]`, which is a way to answer to the same question that the one ask with `bool`. Is it my error ?CyrilleWed, 07 Oct 2020 23:41:28 -0500https://ask.sagemath.org/question/53775/Solve in inequalities return two separate solutions. Could they be gathered ?https://ask.sagemath.org/question/53776/solve-in-inequalities-return-two-separate-solutions-could-they-be-gathered/In the following code, I wonder if there is a way to ask `solve()` to return only one solution with $\leq$ and not one for $<$ and one for $=$.
var('x_1','x_2')
eq2=solve(5*x_1+6*x_2<-8,x_1)
eq4=solve(2*x_1-3*x_2<-8,x_1)
l1=solve(eq4[0][0].rhs()>eq2[0][0].rhs(),x_1)
l2=solve(eq4[0][0].rhs()>=eq2[0][0].rhs(),x_2)
show(l1)
show(l2)CyrilleWed, 07 Oct 2020 23:49:01 -0500https://ask.sagemath.org/question/53776/To give a name to an append listhttps://ask.sagemath.org/question/53725/to-give-a-name-to-an-append-list/If I code this
A = matrix([[1/2, 1/4, 0], [1, 3, -1], [1, 1, 0]])
b = vector([5, 18,10])
c = vector([102, 303, -100])
t = matrix(A.augment(b))
c = c.list()
c.append(0)
show(t, c)
SageMath returns what is expected.
But if I want to change the name of `c.append(0)`?
It returns `None`, so I cannot reuse the augmented vector.CyrilleMon, 05 Oct 2020 02:48:16 -0500https://ask.sagemath.org/question/53725/Compute radical and idempotents of a quotient algebrahttps://ask.sagemath.org/question/10350/compute-radical-and-idempotents-of-a-quotient-algebra/I tried the following:
R.<x, y> = PolynomialRing(QQ, 2)
I = Ideal(x^2, y^2)
S = R.quotient(I)
I have the following question:
**I would like to compute with Sage the Jacobson radical of the algebra S,
all primitive orthogonal idempotents and the central idempotents.**
Of course, you can compute this by hand, but I am interested in more
complicated examples, too (also in matrix algebras), but wanted to
start with this simple example.
Since I am relatively new to Sage, I unfortunately do not know how to compute this.
I would be grateful for any help.BernFri, 12 Jul 2013 03:50:17 -0500https://ask.sagemath.org/question/10350/Splitting a list into sub-listhttps://ask.sagemath.org/question/53605/splitting-a-list-into-sub-list/I have not find the way do do this split `A=[1, 2, 3, 4, 6, 8, 2, 7, 9]` in such a way to obtain `A=[[1, 2, 3], [4, 6, 8], [2, 7, 9]]` --- simply for the cazse where `len(A)= k len(sublist)`.CyrilleSat, 26 Sep 2020 03:55:46 -0500https://ask.sagemath.org/question/53605/Concatenation of listshttps://ask.sagemath.org/question/53643/concatenation-of-lists/Starting from a list of lists and some extra lists,
I want to combine them in various ways.
Suppose I have the following lists:
- a list of lists
A = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
- two extra lists
U = [100, 200, 300]
V = [40, 50, 60]
How to extend `A` using `U` and `V` to obtain
B = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [100, 200, 300]]
C = [[1, 2, 3, 100], [4, 5, 6, 200], [7, 8, 9, 300]]
D = [[1, 2, 3, 100], [4, 5, 6, 200], [7, 8, 9, 300], [40, 50, 60, a]]
for a given `a`.
I have the same question with matrices and vectors.
And is there a mechanism to go back to lists from matrices and vectors?CyrilleMon, 28 Sep 2020 11:22:41 -0500https://ask.sagemath.org/question/53643/Pedagogical Fourier Motzkinhttps://ask.sagemath.org/question/53451/pedagogical-fourier-motzkin/ I want to decompose Fourier-Motzkin algorithm for educational reasons. Suppose I have
z_1=solve(4*x_2<=100,x_2)[0][0]
z_2=solve(-35*x_2<=-3,x_2)[0][0]
z_3=solve(12*x_2 <= 72,x_2)[0][0]
z_4=solve(1-1*x_2 <= 40,x_2)[0][0]
show(z_1,", ",z_2,", ",z_3,", ",z_4)
How coud I select the `z_i` according to the inequality sign and construct 2 sets. CyrilleSun, 13 Sep 2020 22:56:52 -0500https://ask.sagemath.org/question/53451/Can't do simple algebraic divisionhttps://ask.sagemath.org/question/52792/cant-do-simple-algebraic-division/Why can't I do a simple division with Sage?
All I get out is what I put in.
I can do this by hand easily but no matter what method
or option I try I get the same answer.
In: (3*x^3+x^2-3*x+5)/(x+1)
Out: (3*x^3 + x^2 - 3*x + 5)/(x + 1)cybervigilanteFri, 31 Jul 2020 22:01:46 -0500https://ask.sagemath.org/question/52792/Creating a matrix from blockhttps://ask.sagemath.org/question/52763/creating-a-matrix-from-block/ Suppose I have the following elements
A=matrix([[1, 2, 3, 4],[4, 3, 2, 1],[2, 4, 3, 1]])
b=vector([10, 20, 30])
c=vector([1, -2, 3, -1])
II=identity_matrix(3)
z=zero_vector(4)
Now I would like to construct a block matrix
A I | b
c z | 0
0 being a scalar
the | being facultative. I have tried many combination with block_matrix but with any success
CyrilleThu, 30 Jul 2020 16:08:50 -0500https://ask.sagemath.org/question/52763/Pre-set memory limit reached - Gaperrorhttps://ask.sagemath.org/question/52555/pre-set-memory-limit-reached-gaperror/ Hello everyone, I am using a Sage code to compute galois group of a polynomial of degree 24. It is a symbolic polynomial so this code gives possible galois groups. When I run it for lower degrees it gives output but when the polynomial has degree 24 it doesn't compute. Because it computes subgroups of a group of order over 264 million. I know it is very hard to find these groups but i need it. I tried so hard for 3 weeks or more. I use sagemathcell, cocalc and Oracle Virtual Box. I tried so many things but they didn't work. It gives GAPerror: reached pre-set memory limit OR runtime error Gap produced error output, error, variable $sage37 must have a value. I guess the problem is computing conjugacy classes of subgroups. How can I eliminate this Gap error?
P.S1: I am very beginner at Sage. My knowledge about coding, programming etc. is very small.
P.S2: I cannot write the code here because it doesn't belong to me. I found it on internet. But if you want to see I can send you the link.nomaddSat, 18 Jul 2020 06:53:37 -0500https://ask.sagemath.org/question/52555/equation does not simplify due to fractional exponenthttps://ask.sagemath.org/question/52543/equation-does-not-simplify-due-to-fractional-exponent/ The following equation does not seem to simplify due to the fact there is a fractional power in one of the variables im seeking to solve for. The code I have is:
k=var('k')
solve(k == 50*k^(3/5),k)
Out: [k == 50*k^(3/5)]
is there anyway to fix this?EconJohnFri, 17 Jul 2020 15:41:55 -0500https://ask.sagemath.org/question/52543/$e^\left({\frac{-alog(x1)}{a+b}+\frac{alog(x1)}{a+b}+\frac{alog(x2)}{a+b}-\frac{alog(x3)}{a+b}}\right)$ does not simplify in sagehttps://ask.sagemath.org/question/52531/eleftfrac-alogx1abfracalogx1abfracalogx2ab-fracalogx3abright-does-not-simplify-in-sage/I'm running the following code in sage but the answer is not simplified all the way:
eq=e^(-a*log(x1)/(a+b)+a*log(x1)/(a+b)+a*log(x2)/(a+b)-a*log(x3)/(a+b))
eq
Out: [e^(a*log(x2)/(a + b) - a*log(x3)/(a + b))]
show(eq)
$$e^{\left(\frac{alog(x2)}{a + b} - \frac{alog(x3)}{a + b}\right)}$$
what I wanted to get is along the lines of
$$\left(\frac{x_2}{x_3}\right)^\frac{1}{a+b}$$
I've tried using `simplify_full()` with no success. any help is appreciated.EconJohnFri, 17 Jul 2020 13:13:18 -0500https://ask.sagemath.org/question/52531/Unknown exponents causing problem to not be solvedhttps://ask.sagemath.org/question/52516/unknown-exponents-causing-problem-to-not-be-solved/Right now im trying to solve one of the problems i've encountered using sage and it seems like im onto something. However I've encountered a kink at `step3` in my code.
x1, x2, l, p1, p2, a, b, R= var('x1, x2, l, p1, p2, a, b, R')
U = x1^a*x2^b
m = p1*x1+p2*x2;
L = m+ l * (R-U);
dLdx = L.diff(x1);
dLdy = L.diff(x2);
dLdl = L.diff(l);
step1=solve([dLdx == 0, dLdy == 0, dLdl == 0], p1, p2, R)
step2=solve(step1[0][0].rhs()/step1[0][1].rhs()==p1/p2,x1)
step3=solve(U.subs(step2)==R,x2)
step3
Out: x2^b == R/(a*p2*x2/(b*p1))^a
being that I want to isolate `x2` im not sure why its power `b` is not just moved over.
why is this the case?
----------
Note: The following code works
x1, x2, l, p1, p2, a, b, Ubar= var('x1, x2, l, p1, p2, a, b, Ubar')
assume(x1>0,x2>0,a>0,b>0)
U = x1*x2
m = p1*x1+p2*x2;
L = m+ l * (Ubar-U);
dLdx = L.diff(x1);
dLdy = L.diff(x2);
dLdl = L.diff(l);
step1=solve([dLdx == 0, dLdy == 0, dLdl == 0], p1, p2, Ubar)
step2=solve(step1[0][0].rhs()/step1[0][1].rhs()==p1/p2,x1)
step3good2=solve(U.subs(step2)==Ubar,x2)
step4good1=solve(step2[0].subs(step3Good2),x1)
step3good2
Out: [x2 == sqrt(R*p1/p2)]
step4good1
Out: [x1 == sqrt(R*p1/p2)*p2/p1]
This works because I'm considering a case where our utility function has no exponents `a` and `b`. What am I missing from my code?EconJohnThu, 16 Jul 2020 15:57:04 -0500https://ask.sagemath.org/question/52516/Dealing with undefined exponents in SAGEhttps://ask.sagemath.org/question/52507/dealing-with-undefined-exponents-in-sage/I've been playing with sage a bit and have been running into a number of walls in terms of getting analytical solutions so I decided to check if my beliefs are true about SAGE's difficulty with trying to solve the following algebraic problem in sage.
$$x^a-c=0, c\geq0$$
on paper if we were to solve for this problem on paper we get
$$x^*=c^{\frac{1}{a}}$$
What is simply done on paper seems to be an issue to run in sage:
x,a,c = var('x a c')
solve(x^a - c== 0)
This code does not work and wont give me the simple pen and paper solution to this problem. why is this the case?EconJohnThu, 16 Jul 2020 11:06:03 -0500https://ask.sagemath.org/question/52507/Checking what the span is for a vectorhttps://ask.sagemath.org/question/52485/checking-what-the-span-is-for-a-vector/Let's assume I have a vector called v1 and I have a matrix called Matrix.
Let us assume that the vector is in the span of the rows of Matrix. How would I know what the linear combination is? Here is what I do know. Let's assume this is a m by n matrix. I do know there is the span function. So
I can do something like make a list of vectors out of the Matrix. Say something like make an empty list ListofVectors=[].
i=0
while i< m:
ListofVectors.append(M[i])
i+=1
Now doing
v1 in span(ListofVectors)
will give me true assuming v1 is in the span. However, is there a function that tells me what the coefficients are for each term. For example, the vector v1=[3,2,1] for the ListofVectors being [1,1,1], [1,0,0], and [0,1,0] should give me coefficients 1,2,1 respectively as 1*[1,1,1] + 2*[1,0,0] + 1*[0,1,0] gives [3,2,1].
whatupmattWed, 15 Jul 2020 17:20:50 -0500https://ask.sagemath.org/question/52485/ipynb notebook for Beezer's Linear Algebra supplementhttps://ask.sagemath.org/question/52446/ipynb-notebook-for-beezers-linear-algebra-supplement/I'm reading Beezer's Sagemath workbook that accompanies his Linear Algebra book. He says there is a Sagemath format
workbook that is more usable than the pdf. I've searched Everywhere including his page and every referenced page, but can't find it to download. Anyone know where it is? I don't know why he'd mention there is an ipynb notebook but make it impossible to find 😀cybervigilanteSun, 12 Jul 2020 17:45:30 -0500https://ask.sagemath.org/question/52446/exact computations with algebraic numbershttps://ask.sagemath.org/question/52362/exact-computations-with-algebraic-numbers/I'm trying to do exact computations with algebraic numbers. In particular, I know to expect integer answers like `1`, `0`, and `3` at the end of my computations, but I'm getting something slightly off.
I noticed that if I run
sage: r = sqrt(2)
sage: a = AA(r)
sage: b = AA(1/r)
sage: c = a*b
Then I get:
sage: c
1.000000000000000?
Is this being handled in the computer as exactly `1`? Otherwise, how can I do exact computations with algebraic numbers in Sage? I obtain the algebraic numbers I'm working with using `algdep()` to find a polynomial and `.roots(QQbar)` to find the roots of that polynomial.b897069Mon, 06 Jul 2020 14:18:17 -0500https://ask.sagemath.org/question/52362/How to organize a list according to an other listhttps://ask.sagemath.org/question/52297/how-to-organize-a-list-according-to-an-other-list/Here is a problem that resists all my tentatives. Say I have 2 lists of same length
X=[1.1, 2.5, 5.0, 6.01, 12.5, 18.4, 7.8, 14.9, 20, 13.6]
Y=[13.1, 21.5, 53.0, 16.21, 2.45, 8.94, 4.18, 12.8, 17.7, 13.6]
The first one has already been organized in sublists
Xc=[[12.5, 5.0, 20], [7.8, 1.1, 18.4], [6.01, 14.9, 2.5, 13.6]]
What I want to achieve is to construct a list `Yc` composed of sublists such that if `X [i]` belongs to `Xc[j]`, `Y[i]` belongs to `Yc[j]`.
**Ps** I know that the title is a bad description of what I want to achieve.CyrilleThu, 02 Jul 2020 02:02:26 -0500https://ask.sagemath.org/question/52297/Vectorial divisionhttps://ask.sagemath.org/question/52162/vectorial-division/If $\boldsymbol{D}$ is a matrix. One can easily compute
r1=[(D[j+1]-D[j]) for j in range(D.nrows()-1)]
but is there a simple way to compute :
r1=[(D[j+1]-D[j])/D[j] for j in range(D.nrows()-1)]CyrilleMon, 22 Jun 2020 18:09:31 -0500https://ask.sagemath.org/question/52162/A Zip problemhttps://ask.sagemath.org/question/52083/a-zip-problem/ I have two list of the same length
x=[10188.4, 3533.88, 773.924, 0.000000, 0.000000, 3749.69, 0.000000, 0.000000, 0.000000, 3395.03]
y=[163.350, 514.050, 864.750, 1215.45, 1566.15, 1916.85, 2267.55, 2618.25, 2968.95, 3319.65]
when i try
zip(x,y)
the result is `<zip object at 0x6fcd7907988>`CyrilleFri, 19 Jun 2020 04:13:34 -0500https://ask.sagemath.org/question/52083/