2021-02-17 02:01:22 +0200 received badge ● Editor (source) 2021-02-17 02:00:44 +0200 asked a question Sagemath 9.2 Product function Bug In sagemath 9.2 the product function have a bug in multiplication. var('q') var('jt') ((q^(2/3)+q**(2/5))*(product(1 -q**jt, jt, 1 , 31) * q**(1 /24 ))).expand()  returned a result with leading series to be (Both wrong in the powers and the coefficients ) ...+ 2*q^(121/24) - 2*q^(49/24) - 2*q^(25/24) + 2*q^(1/24)  while ((q^(2/3)+q**(2/5))*(product(1 -q**jt, jt, 1 , 31) * q**(1 /24 )).expand()).expand()  returned a result with leading series to be ...+ q^(653/120) - q^(65/24) - q^(293/120) - q^(41/24) - q^(173/120) + q^(17/24) + q^(53/120)  Notice that both ((q^(2/3)+q**(2/5))*(product(1 -q**jt, jt, 1 , 30) * q**(1 /24 ))).expand() ((q^(2/3)+q**(2/5))*(product(1 -q**jt, jt, 1 , 30) * q**(1 /24 )).expand()).expand()  returned a result with leading series to be ...+ q^(653/120) - q^(65/24) - q^(293/120) - q^(41/24) - q^(173/120) + q^(17/24) + q^(53/120)  2021-01-22 01:31:27 +0200 received badge ● Scholar (source) 2021-01-21 07:10:55 +0200 asked a question 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/tuto... 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? 2020-12-10 04:34:57 +0200 commented answer Very different matrix inverse result in complex ring CC and in real ring RR while entry only contain real elements In CC from numpy.linalg import inv as np_inv matrix(np_inv(rho_num_S))*rho_num_S  returned 0.9999999999999999 and 0.9999999999999999 for one of the entry where rho_num_S^-1*rho_num_S  returned 1.07087986853908 and 0.723606797749979 for two of the entry. where in RR both expression returned 1.00000... I don't have enough space to copy the function but you can try couple of square matrix of higher order. For the interest in our project, default matrix inverse operation in CC worked for square matrix of 3 by 3, but failed for square matrix of 6 by 6, and default matrix inverse operation in RR worked for square matrix 6 by 6 but failed for square matrix of 10 by 10. But so far, the inverse function provided by numpy package had been working for all those cases. 2020-12-10 04:27:07 +0200 commented answer Very different matrix inverse result in complex ring CC and in real ring RR while entry only contain real elements But this happened to invertible matrix as well. The above result was only for demonstration, since it was calculated with float precision. I encountered this in a project where an invertible matrix calculated in CC had a very different inverse than the one calculated with RR. And a final result ought to be 0 but returned 0.0354399342695375 - 0.109072902259946*I. One observation was that the invertible matrix calculated in CC was almost 1e2 times less preciece than the standard numpy matrix. After I used RR and complete the matrix inverse by directly calling the inverse function in numpy package, the result then returned correctly. There was something very wrong with the precision control of matrix inverse in CC. 2020-12-10 02:27:12 +0200 received badge ● Nice Question (source) 2020-12-10 01:11:16 +0200 asked a question Very different matrix inverse result in complex ring CC and in real ring RR while entry only contain real elements I would use an dramatized example here but it was encountered during a project as well. Suppose two matrix consisted of the same entry of only real elements. However, one was in the real domain RR, and one was in the complex domain CC. The inverse of the complex matrix and the real matrix different significantly. Example: test_S=matrix(RR,5) for ix in range(0,5): for iy in range(0,5): test_S[ix,iy]=sin(ix+iy)*sin(iy+1);  and test_S_CC=matrix(CC,5) for ix in range(0,5): for iy in range(0,5): test_S_CC[ix,iy]=sin(ix+iy)*sin(iy+1);  which returned test_S [ 0.000000000000000 0.765147401234293 0.128320060202457 -0.106799974237582 0.725716283876408] [ 0.708073418273571 0.826821810431806 0.0199148566748170 0.572750016904307 0.919535764538226] [ 0.765147401234293 0.128320060202457 -0.106799974237582 0.725716283876408 0.267938303940044] [ 0.118748392158235 -0.688158561598754 -0.135323401369264 0.211462346264655 -0.630000397639817] [ -0.636827341031836 -0.871947375471875 -0.0394311173578842 -0.497209097294248 -0.948719639025321]  test_S_CC [ 0.000000000000000 0.765147401234293 0.128320060202457 -0.106799974237582 0.725716283876408] [ 0.708073418273571 0.826821810431806 0.0199148566748170 0.572750016904307 0.919535764538226] [ 0.765147401234293 0.128320060202457 -0.106799974237582 0.725716283876408 0.267938303940044] [ 0.118748392158235 -0.688158561598754 -0.135323401369264 0.211462346264655 -0.630000397639817] [ -0.636827341031836 -0.871947375471875 -0.0394311173578842 -0.497209097294248 -0.948719639025321]  However, their inverse (test_S)^-1 [ 2.87043424444896e15 -9.36229301025494e15 1.13569572695379e16 -8.12065238284797e15 1.72141024999095e15] [-1.10320559226948e15 3.19497062929143e15 5.27553667803348e15 -7.22878751888619e15 8.54302211670640e15] [ 1.94664421070014e16 -3.02112860544102e15 0.000000000000000 1.80143985094820e16 0.000000000000000] [ 8.29739198582516e14 9.39732200089164e15 -1.02939420054183e16 1.02939420054183e16 0.000000000000000] [-2.15677123538261e15 -1.45141888820365e15 -7.07708512872506e15 5.95118522188244e15 -9.00719925474099e15]  (test_S_CC)^-1 [-1.00798918109020e16 1.87532050063097e15 1.07471168476593e16 -2.09935440833922e16 1.10831351979113e16] [ 2.64758058163658e15 7.44366790239271e15 -8.04492396917722e15 9.82621377301499e15 4.42753908914828e14] [ 2.35701470124050e16 -4.71646526274252e15 1.02939420054183e16 1.08658276723860e16 9.15017067148291e15] [ 1.53627372015977e16 -1.32579194813951e15 -1.02939420054183e16 2.51629693465780e16 -9.15017067148291e15] [-4.69821640166124e15 -7.20926442861200e15 5.14697100270914e15 -8.57828500451523e15 -3.43131400180609e15]  where (test_S)^(-1)-test_S_CC^(-1) [ 1.29503260553510e16 -1.12376135108859e16 6.09840421878568e14 1.28728917005442e16 -9.36172494792037e15] [-3.75078617390606e15 -4.24869727310128e15 1.33204606472107e16 -1.70550012919012e16 8.10026820779157e15] [-4.10370490540364e15 1.69533665730150e15 -1.02939420054183e16 7.14857083709603e15 -9.15017067148291e15] [-1.45329980030152e16 1.07231139490312e16 0.000000000000000 -1.48690273411597e16 9.15017067148291e15] [ 2.54144516627863e15 5.75784554040835e15 -1.22240561314342e16 1.45294702263977e16 -5.57588525293490e15]  Is this a bug? How to fix the issue? 2020-09-15 19:10:08 +0200 asked a question How to fix mod(17,7)=3 and yet -mod(17,7)=4? In sageMath 9.1, I encountered the following issue mod(17,7) returned a result of 3 while -mod(17,7) automatically rearranged the number(-3) in the module group into the group element 4. How would I simply obtain -3 as what the code was instead of 4? 2020-09-08 19:45:11 +0200 received badge ● Supporter (source) 2020-09-07 09:26:14 +0200 received badge ● Student (source) 2020-09-07 03:52:51 +0200 asked a question Sage symbolic math simplification error In sagemath version 9.1, the code product(1-q^x, x, 1, N) returned -(-1)^N*product(q^x - 1, x, 1, N) while the correct result ought to be (-1)^N*product(q^x - 1, x, 1, N) What went wrong? Where did this sign change come from?