2020-07-16 07:05:28 -0600 | commented question | Built-in tools for fast extraction of tuples of a given grade with respect to grading on [1, 2, ..., n] @mwageringel Thanks a lot :-) |
2020-07-12 12:37:33 -0600 | asked a question | Built-in tools for fast extraction of tuples of a given grade with respect to grading on [1, 2, ..., n] Hi, Note that I have just posted the same question on Stack Overflow. I am in the process of coding 2 mathematical combinatorial operations that I want to iterate (as) many times (as possible), so speed is obviously crucial. Here is an example of what I want to do as fast and efficiently as possible for any positive integer n and any grading (see example below). Remark: This is a self-motivated question coming from mathematical experimentations with Sage. Many thanks in advance for your help. Example: Let us take n = 6, and the set S = {1, 2, ..., n} = {1, 2, 3, 4, 5, 6}. There are binomial(6, 2) = 15 couples
in increasing order that we can extract from S. The built-in tool I was advised to use in order to obtain the above list is the following:
Question 0: Is there anything faster in Python? Now let me choose a grading on the set S in the form of a function from S to {1, 2, 3} grading: 1, 2, 3 --> 1 and 4, 5 --> 2 and 6 --> 3 I have decided to store this function as a dictionary as follows:
With respect to this grading, we can compute the grade of elements, couples, or tuples constructed from S. Examples: - grade(2) = 1 - grade(5) = 2 - grade((2, 5)) = grade(2) + grade(5) = 1 + 2 = 3 - grade((2, 3, 5)) = 1 + 1 + 2 = 5 1 - First Construction: I want all the couples with grade equal to g0 = 4. Here is an obvious way to do it, which is built naively on the previous lines of code:
This yields
as desired. Question 1: Is there a built-in way to obtain gradedList and/or what is the fastest way to do this with Python? 2 - Second Construction: Now I want to extract all the increasing 3-tuples (i, j, k) with grade equal to 4, and which starts with i = 1. In other terms, I want the following list:
Of course, this can be obtained as follows:
Question 2: Is there a built-in way to obtain secondGradedList and/or what is the fastest way to do this with Python? Thanks, Julien |
2020-07-03 07:32:53 -0600 | asked a question | Right choice for a dictionary of matrices with non constant coefficients. Hi, K is any field. I need to store matrices in a dictionary. Some of them have constant coefficients in K (let M1 be such a matrix), and some have non constant coefficients, say these coeffcients are functions from t to K (let M2 be such a matrix). I need to get M2 from the dictionary, and then be able to manipulate it as if it was a function of t. (T) In particular, I need to be able to manipulate the matrices obtained from M2 by setting t to be equal to some specific values. Since my functions are polynomials for now, I have tried doing something like this:
But then I don't know how to proceed to perform the task (T). And I have the feeling that there are much better options. What should I do? Thanks. |
2020-05-27 15:26:56 -0600 | commented question | Matrix of the composition with the quotient map @tmonteil An alternative would be to know how to obtain the coordinates of every $\theta(u)$ in the basis of Q, knowing the coordinates of $\phi(u)$ in the canonical basis of $\mathbb{C}^4$. |
2020-05-27 14:03:57 -0600 | commented question | Matrix of the composition with the quotient map I have a basis of U and I am able to compute $\phi(u)$ for every $u$ in this basis. So I build the matrix M myself: this is now my input. I am looking for the shortest path to get the matrix N. |
2020-05-27 08:54:24 -0600 | asked a question | Hypermatrices? Hi all, I want to store and manipulate arrays of $n\times n\times n$ numbers $$x_{ijk}\quad\text{where}\quad 0\leq i, j, k\leq n-1$$ with Sage. Here is what I have been doing so far:
etc... Remark: So $X$ is a so called 3-hypermatrix. Question: Are NumPy arrays my best option when handling hypermatrices with Sage? Precision: I will need to manipulate lists of such hypermatrices, and even hypermatrices whose elements will be hypermatrices, e.g. $$X_{ijk}^{(abcd)}$$ and loop over such lists, e.g. for a ..., for b ..., for c ..., do ... with the 3-hypermatrix $X^{(abcd)}$. |
2020-05-27 08:01:38 -0600 | asked a question | Matrix of the composition with the quotient map Hi all, In this question, I learned how to obtain a basis for a quotient vector space. Here is a summary of the code:
So Q is the quotient vector space $\mathrm{Ker}B/\mathrm{Im}A$ and the command
returns a matrix whose rows are vectors of $\mathbb{C}^4$ which constitute a set of representatives for a basis of Q. Now I have a linear map $$\phi:U\longrightarrow\mathbb{C}^4$$ such that $\mathrm{Im}\phi\subseteq V$, and its composition with the quotient map $V\longrightarrow Q=V/W$, namely $$\theta:U\longrightarrow Q.$$ I have fixed a basis of $U$ (which has dimension 3) and I have the matrix of $\phi$, say $M$, with respect to that basis at the origin, and the canonical basis of $\mathbb{C}^4$ at the end. So $M$ is $4\times 3$. Question: What is the command that will give me the $2\times 3$ matrix $N$ of $\theta$ with the same basis of $U$ at the origin, and the basis of $Q$ mentioned above at the end? Thanks for your help. |
2020-05-25 14:25:50 -0600 | commented answer | Basis for such a quotient vector space Great, thanks a lot. |
2020-05-25 12:26:58 -0600 | asked a question | Basis for such a quotient vector space Hi all, Here is my code:
This way W is the range of the linear map $$A:\mathbb{Q}^3\longrightarrow\mathbb{Q}^4,$$ V is the nullspace of $$B:\mathbb{Q}^4\longrightarrow\mathbb{Q}^5,$$ Since BA=0, W is a subspace of V. and the command V/W returns in particular the dimension of the quotient vector space V/W which is equal to 2. What I want is a basis of V/W, i.e. 2 vectors of $\mathbb{Q}^4$ which are in V, in the form of a 2x4 matrix the same way V.basis_matrix() returns a basis for V. How can I do this? Thanks! |
2019-12-25 11:38:45 -0600 | received badge | ● Editor (source) |
2019-12-25 11:05:00 -0600 | asked a question | error message: <input>:2: DeprecationWarning: invalid escape sequence \( Hi, I have a few interacts which were working nicely until this morning. But now I get this error message: <input>:2: DeprecationWarning: invalid escape sequence \( Here is an example: https://tinyurl.com/r5ocq9f Can you tell me what is wrong, and what I should do to fix it? Thanks! Julien |
2019-09-06 11:14:08 -0600 | received badge | ● Famous Question (source) |
2018-12-30 13:02:09 -0600 | received badge | ● Notable Question (source) |
2018-09-08 18:15:47 -0600 | received badge | ● Popular Question (source) |
2018-03-26 12:53:47 -0600 | asked a question | Using accented letters in interact selectors I would like to use accented letters when displaying the options of my input under the selector method. To be more precise, 'I'd like to have ellipsoïde and à deux nappes, for instance. Thanks. Here is the interact. And here is the code: |
2018-01-29 08:11:21 -0600 | received badge | ● Nice Question (source) |
2018-01-28 16:20:47 -0600 | asked a question | plots of complex numbers Say I want to plot the 6 solutions of the following complex equation. What is the best practice? EDIT by @tmonteil: to lower dependency between Sage services in the long term, here is the code provided in the sagecell: |
2018-01-27 12:50:50 -0600 | received badge | ● Supporter (source) |
2018-01-25 16:31:39 -0600 | asked a question | pretty_print in interact labels I have written the following interact. How cant I get the labels right? For instance, I'd rather have $N_0$ rather than N0. Can I achieve this with pretty_print? |
2018-01-19 14:11:30 -0600 | commented answer | @interact : Fix the default rendering Thanks kcrisman! |
2018-01-19 14:11:04 -0600 | received badge | ● Scholar (source) |
2018-01-18 09:45:46 -0600 | asked a question | @interact : Fix the default rendering I have created the following interact. It plots the partial sums of a series up to N, et prints out the last one. The default rendering yields a DeprecationWarning and does not show the partial sum value. When you update the data, the rendering is fine. How can I fix this? |
2015-11-06 19:14:25 -0600 | received badge | ● Famous Question (source) |
2015-06-19 18:28:21 -0600 | received badge | ● Notable Question (source) |
2015-06-19 18:28:21 -0600 | received badge | ● Popular Question (source) |
2014-08-11 10:05:38 -0600 | received badge | ● Student (source) |
2014-08-08 10:42:03 -0600 | asked a question | How to reset variables? I am using the Sage-6.2 app on an iMac (Mavericks). I have solved a couple of linear systems in my running worksheet for which the solution set requires a parameter. I am now at 'r7'. How do I reset this back to 'r1'? Also, is there something equivalent to Maple's 'restart'? |