2024-04-06 14:14:57 +0200 received badge ● Famous Question (source) 2021-07-13 10:15:55 +0200 received badge ● Popular Question (source) 2021-02-02 22:21:30 +0200 received badge ● Nice Question (source) 2020-12-28 16:41:00 +0200 received badge ● Notable Question (source) 2020-12-28 16:41:00 +0200 received badge ● Popular Question (source) 2020-10-17 01:12:17 +0200 received badge ● Famous Question (source) 2018-10-13 14:32:58 +0200 received badge ● Notable Question (source) 2018-10-13 14:32:58 +0200 received badge ● Famous Question (source) 2018-10-13 14:32:58 +0200 received badge ● Popular Question (source) 2018-08-30 10:01:11 +0200 received badge ● Notable Question (source) 2017-12-31 01:57:12 +0200 received badge ● Popular Question (source) 2017-06-30 20:22:19 +0200 asked a question Integrating complicated expression with two variables I am trying to compute a double integral with respect to variables x and y. I first compute the integral with respect to the variable x: first_int = integral(h, x, 1, 5)  which gives me as an output : integrate(1/(log(abs(x^4 + 13*x^3*y - 30*x^2*y^2 + 2*x*y^3 - 3*x^2*y + x*y^2 + x^2 + x*y + y^2 + 2*x + 13))^log(abs(x^4 + 13*x^3*y - 30*x^2*y^2 + 2*x*y^3 - 3*x^2*y + x*y^2 + x^2 + x*y + y^2 + 2*x + 13))), x, 1, 5)  instead of an expression now only depending on the second variables y. Then, when I try to integrate with respect to the second variable y by writing second_int = first_int.integrate(y, 1, 5)  I get the following output: integrate(integrate(log(abs(x^4 + 13*x^3*y - 30*x^2*y^2 + 2*x*y^3 - 3*x^2*y + x*y^2 + x^2 + x*y + y^2 + 2*x + 13))^(-log(abs(x^4 + 13*x^3*y - 30*x^2*y^2 + 2*x*y^3 - 3*x^2*y + x*y^2 + x^2 + x*y + y^2 + 2*x + 13))), x, 1, 5), y, 1, 5)  finally if I try to write (to get the numerical value) second_int = n(first_int.integrate(y, 1, 5))  I get the error message ValueError: The function to be integrated depends on 2 variables (x, y), and so cannot be integrated in one dimension. Please fix additional variables with the 'params' argument I have tried integrating the same type of function when there is only one variable and the integration works fine, so I am thinking something goes wrong in the double integration but I can't figure out what! Thanks. 2017-06-29 20:23:21 +0200 asked a question Absolute value of a polynomial How can I generate a random polynomial with two variables x, y of fix degree which is not of type : 0)', see assume? for more details) Is y^2-2y+2 positive or negative? 2017-06-27 23:18:40 +0200 asked a question Double-integration and logs I am running into various odd problems while trying to compute a double integral. My code is as follows: x, y = var('x y') ##### Two different ways of generating random polynomials F(x,y) to test double-integration ######## #F = ZZ['x','y'].random_element(4, 1000) F = randint(-1000, 1000)*x**4*y**4 + randint(-1000, 1000)*x**3*y + randint(-1000, 1000)*x**2*y**3 +randint(-1000, 1000)*x + randint(-1000, 1000)*y**2 G = randint(0, 1000)*x**4*y + randint(0, 1000)*x**3 + randint(0, 1000)*x**2*y**2 +randint(0, 1000)*x + randint(0, 1000)*y**4 ###### Defining the function we want to integrate over dx dy ########## f = log(F) ####### Double integration ##### g= integrate(f, x, 1, 2) print 'after integration dx:', g assume(y>0) print n(g.integral(y, 1, 2))  Problems: 1) If I use the random polynomial F generated by .random_element, the integration generates the following error : TypeError: integral() takes exactly one argument (3 given). However, if I use the other one I manually generate, then it integrates okay. If I copy from the terminal the .random_element() polynomial and explicitly write it in my code, then it will also work. Why not directly from the .random_element() function then ? 2) If I set f = F or even f = FG, then the double integral works fine. However, as soon as I introduce the *log function, the calculation never terminates (if I work with an example in the terminal with a log function, then it does integrate properly). Any idea what might cause these weird bugs ? Thanks! 2017-06-27 23:16:14 +0200 asked a question Bugs with double-integration and logs I am running into various odd problems while trying to compute a double integral. My code is as follows: x, y = var('x y') ##### Two different ways of generating random polynomials F(x,y) to test double-integration ######## #F = ZZ['x','y'].random_element(4, 1000) F = randint(-1000, 1000)*x**4*y**4 + randint(-1000, 1000)*x**3*y + randint(-1000, 1000)*x**2*y**3 +randint(-1000, 1000)*x + randint(-1000, 1000)*y**2 G = randint(0, 1000)*x**4*y + randint(0, 1000)*x**3 + randint(0, 1000)*x**2*y**2 +randint(0, 1000)*x + randint(0, 1000)*y**4 ###### Defining the function we want to integrate over dx dy ########## f = log(F) ####### Double integration ##### g= integrate(f, x, 1, 2) print 'after integration dx:', g assume(y>0) print n(g.integral(y, 1, 2)) ` Problems: 1) If I use the random polynomial F generated by .random_element, the integration generates the following error : TypeError: integral() takes exactly one argument (3 given). However, if I use the other one I manually generate, then it integrates okay. If I copy from the terminal the .random_element() polynomial and explicitly write it in my code, then it will also work. Why not directly from the .random_element() function then ? 2) If I set f = F or even f = FG, then the double integral works fine. However, as soon as I introduce the *log function, the calculation never terminates (if I work with an example in the terminal with a log function, then it does integrate properly). Any idea what might cause these weird bugs ? Thanks! 2017-04-21 15:01:22 +0200 commented answer Ideals and commutative rings My matrix is slightly different and has many zeros. Maybe this causes the ring R to be non-commutative. I will have a look. Thanks for your answer! 2017-04-21 14:18:51 +0200 asked a question Ideals and commutative rings I consider a matrix $M$ which I transform into a system of equations similar as this (but with a different $M$) sage: M=matrix(3,3,[1,2,3,4,5,6,7,8,9]) sage: P=PolynomialRing(GF(p),M.nrows(),names="x") sage: (vector(P.gen(i) for i in range(3))*M).list() [x0 + 4x1 + 7x2, 2x0 + 5x1 + 8x2, 3x0 + 6x1 + 9x2] (Example taken from another equation where $p$ is a prime). When I try to create the ideal generated by this system, I get the following error : TypeError: R must be a commutative ring. Any idea how I can fix this? 2017-04-06 16:42:03 +0200 asked a question Mapping a list to some variables for a system of equations I have a list of integers $(a, b, c, d)$ and a system of equations, where each equation has two unknowns. My system looks like $(x0+x4, x1+x4, x2+x4, x3+x4).$ I am trying to evaluate the system in $(a,b,c,d)$. If I write $system(x0=1, x1=2, x3=1, x4=1)$, the system correctly outputs the result of each equation. Now, I would like to do something like $system(x0=a, x1=b, x3=c, x4=d)$ but without having to manually put the variables in. I have tried writing $system(list)$ but the number of variables and unknown doesn't match. Is there any way I can achieve this ? 2017-04-05 23:43:10 +0200 received badge ● Editor (source) 2017-04-05 23:42:45 +0200 asked a question Convert a Free Module Element into a vector I have an element $v$ of type 'sage.modules.free_module_element.FreeModuleElement_generic_dense', concretely I have $(x0, x1, 1)$, which I would like to multiply by a matrix $M$, i.e., have $M*v.$ \ I am trying to convert this element into a vector, but the naive attempt to do $vector(v)$ fails to give me a valid multiplication (TypeError: unsupported operand parent(s) for '*': 'Full MatrixSpace of 2 by 2 dense matrices over Integer Ring' and 'Ambient free module of rank 3 over the integral domain Multivariate Polynomial Ring in x0, x1 over Rational Field'). Is there any way I can do this multiplication ? thanks! 2017-04-04 16:50:13 +0200 received badge ● Scholar (source) 2017-04-04 15:47:50 +0200 received badge ● Student (source) 2017-04-04 10:58:58 +0200 commented answer Transforming a matrix into a system of equations thank you ! I have two additional questions. It seems that your solution gives the column coefficient to a polynomial (and not the rows). Would it be possible to have the row coefficients? One way would be to simple transpose the matrix beforehand. I have tried using M.ncolumns() but it seems to generate an error. Also, is there anyway the last coefficient could be a constant variable (1) (in order to have $ax+by+c$ for example) ? 2017-04-04 05:21:45 +0200 asked a question Transforming a matrix into a system of equations I have a $n \times n$ matrix that I would like to transform into a system of $n$ equations (for $n$ disctinct variables). I am not sure how to proceed (the end goal being to solve the system eventually). The number of variables is not fixed. Should I consider every row of the lattice and map each coefficient $c_{ij}$ to a string that I write as $"c_{11}x_1 + .....+ c_{1n-1}x_n + c_{1n}$. I am hoping there exists a more direct solution. Thanks! 2017-04-04 00:21:15 +0200 asked a question Groebner basis to solve linear system of equations I am trying to solve a linear system of equation modulo some prime $p$. I have a matrix which gives me the coefficients of the polynomials (i.e., first row would be ($a, c, b, d$) for $ax+by+cz+d =0$). I would usually use solve_right(), writing my system as $Ax=b$ mod $p$, but I am intrigued by the use of Groebner basis. I have read about their implementation but I am confused at the notion of ideal to define before solving the system. I would like to solve the system in the ring $Z/pZ$. Also, can I feed a matrix to the function or should I first convert the matrix in a bunch of equations ? Any clarification would be welcome ! 2017-04-03 03:05:23 +0200 commented answer Solving modular systems of equation great, thanks. I'll try the last option. 2017-04-02 20:52:46 +0200 asked a question Solving modular systems of equation I am trying to solve a system of equations mod $p$, for $p$ prime. I have build matrices $A$ and $b$ and I am using the function solve_right() to solve $Ax = b$. But I need to solve $Ax = b$ mod $p$. Is there any functions that could do that ? thanks !