2023-05-19 14:32:09 +0100 | received badge | ● Popular Question (source) |
2022-10-14 17:42:34 +0100 | received badge | ● Famous Question (source) |
2021-06-28 21:37:59 +0100 | received badge | ● Notable Question (source) |
2021-06-28 21:37:59 +0100 | received badge | ● Popular Question (source) |
2018-01-23 19:33:04 +0100 | asked a question | recursively solve and substitute I'm working on a pretty complicated problem (theoretically, not necessarily computationally). I'm not sure how to distill my question down to a simple example. But basically I have a system of equations over the ring of polynomials (or power series) over the symbolic ring. I want to be able to recursively solve for one symbolic function in terms of another, substitute the solution, and repeat. The ultimate goal is to extract relevant data all as a function of some positive integer k. It seems like I should be able to build a loop to do this, but I'm new to sage and programming in general. I haven't been able to find anything quite like what I'm trying to do online. So I'm asking for suggestions. Here are some more details: I have several polynomial expressions which I plug into a formal matrix valued function and perform a series of algebraic manipulations. In the end I get a matrix whose entries are polynomials in the a(j)'s and f(j)'s. I want to recursively solve for the f(j)'s in terms of the a(j)'s so as to diagonalize this matrix expression. I can do this "by hand" but I want a function that will just spit out the end result. For example I know that f(2) = 1/4a(2k-2) for any k. I've tried, for example: Here A0(k) is a previously defined matrix expression and f0(k,j) is a function that solves for f(j). This code actually runs but then trying to call A1(2), etc., leads to errors. Another attempt was to define and then try to define a function of k in terms of the A1(k,j)'s using the sum() command. (In the code above coef(A,j) is a function that returns the coefficient of the z^j term in a polynomial over a ring of matrices). The problem with this last attempt is that A1(k,j) for j bigger than 2 returns terms that include f(2), f(3), etc. I need something that solves for f(2), substitutes this value for f(2) into all future computations; then solves for f(3), substitutes this values for f(3) into all future computations; and so on until f(2*k). I apologize if this question is too broad somehow. In looking over some of the literature on loops, solve(), substitute(), etc., I haven't found anything quite like this. Any suggestions? And thank you. |
2017-12-20 18:03:05 +0100 | commented answer | working with coefficients of formal series But also, what makes the difference in whether Sage returns the expanded expression or the just something like |
2017-12-20 18:00:51 +0100 | commented answer | working with coefficients of formal series Ideally, we would leave n as a variable, only specifying n=3 when necessary to return meaningful results. Something more like: ... |
2017-12-20 15:44:55 +0100 | asked a question | working with coefficients of formal series I want to define a truncated series or polynomial of arbitrary degree and then work algebraically with the polynomial to solve for various quantities in terms of the coefficients. When I write something like this returns But if I try to define an arbitrary polynomial of this type returns What is the crucial difference here? I had a similar problem when working with truncated power series over the ring How do I get sage to work with the series and also give info about the coefficients, i.e. multiply series expressions but then expand them out in z? I've tried |
2017-12-19 22:36:51 +0100 | received badge | ● Supporter (source) |
2017-12-19 22:35:31 +0100 | received badge | ● Scholar (source) |
2017-12-19 22:33:44 +0100 | asked a question | truncated exponential series over ring of matrices over symbolic ring I want to do the following: I then want to define a function as the first several terms of the exponential series exp(gamma). Something like This will return an error like: 'too many values to unpack' I only want to work with this function formally until I need to specify a value of n and eventually solve for the value f(i), g(i) in terms of some other parameters (yet to be defined in this code). What are some ways to clean this up so I can work with the truncated power series with matrix coefficients? A possibly simpler but related question is how does one build a function that will sum several powers of a matrix? |
2017-12-07 01:41:01 +0100 | received badge | ● Student (source) |
2017-12-07 01:35:49 +0100 | asked a question | polynomial with matrix coefficients Is there a way in sage to work with polynomials or power series over a ring of matrices? For example, I can write something like: z=var('z') A=matrix([[z^2+z+1,z],[0,z^2]]) But then lets say I do some transformations and want to recover from the result the matrix coefficient of a particular term. With the matrix above I can write something like A[0,1].coefficient(z) or A[1,0].coefficient(z) to try to get the individual entries. But what I want is a function that takes A.coefficient(z,2) and returns [1 0] [0 1] Is there a way to do this? |
2017-12-07 01:35:49 +0100 | asked a question | computing the square root of a polynomial with variable coefficients I am new to sage and programming in general. I want to compute the power series representation of the square root of a polynomial with variable coefficients. Here is my attempt: i,z=var('i,z') c=function('c') p=sum(c(i)*z^i,i,0,6) sqrt(p) This returns sqrt(z^6c(6) + z^5c(5) + z^4c(4) + z^3c(3) + z^2c(2) + zc(1) + c(0)). How can I get sage to return a power series expression? |
2017-12-07 01:35:49 +0100 | asked a question | square root of a polynomial with variable coefficients I want to calculate the square root of a polynomial with variable coefficients in sage. For example: i,z=var('i,z') c=function('c') p=sum(c(i)*z^i,i,0,6) sqrt(p) returns sqrt(z^6c(6) + z^5c(5) + z^4c(4) + z^3c(3) + z^2c(2) + zc(1) + c(0)) I want a Taylor or Laurent expansion in z. How do I get this? |