2023-05-31 20:10:56 +0200 | received badge | ● Famous Question (source) |
2023-05-22 12:31:37 +0200 | received badge | ● Notable Question (source) |
2023-03-19 00:36:47 +0200 | received badge | ● Famous Question (source) |
2022-01-27 04:28:34 +0200 | received badge | ● Famous Question (source) |
2021-11-06 07:10:41 +0200 | received badge | ● Popular Question (source) |
2021-05-06 19:03:44 +0200 | received badge | ● Notable Question (source) |
2021-04-28 10:50:44 +0200 | received badge | ● Popular Question (source) |
2021-04-28 10:50:44 +0200 | received badge | ● Notable Question (source) |
2020-09-28 21:31:22 +0200 | commented answer | How to implement 'derivative' in ExpressionTreeWalker Yes!! That works. Thanks!! |
2020-09-28 12:20:09 +0200 | received badge | ● Nice Question (source) |
2020-09-28 03:49:17 +0200 | commented answer | What is the difference between SR.var() and var()? I am not sure I follow the design decision. This looks like two different name spaces. One is the Python one which seems to be where the interface lives, the other a sage one to which there is just indirect access. Is that correct? And why would omitting the assignment on the second one does not cause the same problem as in the first one? |
2020-09-28 03:49:17 +0200 | received badge | ● Commentator |
2020-09-28 00:59:48 +0200 | asked a question | How to implement 'derivative' in ExpressionTreeWalker I am trying to implement a method that requires traversing the expression tree. I have no problem with arithmetic functions, but I can't figure out how to deal with derivatives. Take this simple implementation for example: If you run it in the following: The following error occurs: If that line is changed to: The result becomes: That is the derivative operator is removed and substituted for the argument of the operator. ExpressionTreeWalker is poorly documented at best, and I can't figure out what is expected as a return value from the derivative method (my first attempt comes from looking at the existing implementation). What am I missing? |
2020-09-27 20:27:55 +0200 | asked a question | What is the difference between SR.var() and var()? Is this a bug? If you type: However, this works: |
2020-07-17 00:13:02 +0200 | received badge | ● Nice Question (source) |
2020-07-17 00:12:27 +0200 | received badge | ● Popular Question (source) |
2019-10-28 08:03:56 +0200 | received badge | ● Teacher (source) |
2019-10-28 08:03:56 +0200 | received badge | ● Self-Learner (source) |
2019-10-28 01:01:09 +0200 | commented answer | How to iterate over symbolic coefficients I believe your answer provides the path to the only reliable choice. I think I have to walk the tree of what I assume to be mostly a polynomial looking at sums and products of elements and expanding the substitution in all of those cases, but stopping at anything else such as division and exponentiation and removing the substitution on those subtrees. Although conceptually it works, I can't see the path for doing that in code. Your example enumerates the tree backwards from this, which means that I would have to account for all (unknown) cases, instead of known ones such as sums and products. I still get the feeling that a properly defined symbolic ring would be able to do this, but I don't see how. |
2019-10-25 14:33:56 +0200 | answered a question | How to iterate over symbolic coefficients Leaving this answer as a warning. I decided to go in the direction of @tmontell 's answer, although I can see multiple ways to get the functions to do what I want in specific instances, there are too many corner cases that will cause problems in the future. Although @tmonteil answer walks the structure, I believe this is simpler to implement and understand. This answer does what I need, at least for the cases that I am handling by hand (instead of programmatically): WARNING: There is an issue where if I simplify before applying the final substitution these do not work, I can't see a reason for that. This question might illuminate the reason. Definitions: Note that the definitions of R is critical, a & b_s are not the same as the variables being used (see answer: map functions into polynomial coefficients). The actual operations: This set of operations do what I need, now all that is left is to transform exd into a proper polynomial so I can manipulate its coefficients. Which results in: Some cleanup might be needed, and there are some issues (e.g., PolynomialRing does not support "show()" for some reason), and in some cases the substitution breaks for no apparent reason (a bug?). But I think it does what is needed. Any suggestions on how to improve this? |
2019-10-25 14:00:13 +0200 | commented question | How can I map functions into polynomial coefficients @vdelecroix A typo |
2019-10-25 13:58:40 +0200 | received badge | ● Scholar (source) |
2019-10-25 13:52:10 +0200 | commented answer | How can I map functions into polynomial coefficients Thanks! That works. I guess the generator syntax is critical as R.<a,c> = Poly... definitively does not work. But why is the "show" method not implemented on a PolynomialRing???? |
2019-10-25 03:07:32 +0200 | asked a question | How can I map functions into polynomial coefficients Let's say I have the following expression (from a wide range of possibilities) : And I want to extract the coefficients of the polynomial over the polynomial ring over a & c, so that these result in: How can I define the polynomial ring? How can I map an existing expression that defines "pol" (which is the result of other manipulations) into such ring? |
2019-10-20 05:26:09 +0200 | commented answer | How to iterate over symbolic coefficients I might have found a much simpler and general way to solve my specific issue that just involves a couple of function manipulations, I'll try to implement it and post it as soon as I get a chance by the end of this coming week. |
2019-10-19 04:02:04 +0200 | commented answer | How to iterate over symbolic coefficients Yikes, thanks!! It will take me a while to digest that, I was hoping for some simpler pattern matching. Could this be easily extended to other non-linear functions such as log(x), sin(x), etc.? Or particular cases would have to be treated one by one (e.g., by iterating through a list of all nonlinear functions). I don't know enough to see if there are edge cases, but I will definitively look into TreeWalker. |
2019-10-19 03:56:05 +0200 | received badge | ● Supporter (source) |
2019-10-19 00:17:33 +0200 | received badge | ● Student (source) |
2019-10-18 22:22:27 +0200 | commented answer | How to iterate over symbolic coefficients @tmontel I added some clarification to the question. I hope that covers it. |
2019-10-18 22:21:52 +0200 | received badge | ● Editor (source) |
2019-10-18 15:41:26 +0200 | commented question | How to iterate over symbolic coefficients @tmontell They are supposed to remain unknown until I can coerce the final output of a long set of operations into a numeric framework. |
2019-10-18 15:09:41 +0200 | commented question | How to iterate over symbolic coefficients I don't have experience with either, but it's obvious to me that a polynomial ring is what I want and a symbolic ring might provide me with the proper iteration tools. When I tried the polynomial ring of polynomial coefficients I kept getting errors due to the same variable being used on the exponents and the monomials. I have no idea about the symbolic ring or how to use it, but given that this is just a minor step in a long process doing things by hand is not an option. |
2019-10-18 15:08:10 +0200 | commented answer | How to iterate over symbolic coefficients I know that with playing around with the expressions I can get Sage to do it, but this is just a minor step in a complicated process, so I need a reliable and automatable method that goes beyond simple pattern matching. Iterating though the non-monomial elements seems to be the ticket, but I don't know how to do that. |
2019-10-18 10:56:27 +0200 | asked a question | How to iterate over symbolic coefficients I am a relative newbie to Sage but not to algebraic manipulation in general. I have a family of expressions with non-linear coefficients which I am not sure how best to represent. In the end it has to be an (infinite) ring of polynomials representing a Volterra space, but I have the same terms inside non-linear functions (which I need to evaluate to a known value) and as the polynomial variables. Here is an example, where simple symbolic manipulation doesn't work: Producing: When what I want is: How can I iterate over non-linear elements (exponent and the arguments to any non-monomial terms) carrying out direct substitutions, while leaving monomials alone. I want the result to remain as a polynomial ring on b_s Clarification: The intent is to use the code for a generic non-linear construct. It's intended to handle any general non-linear expression in L2, but these are manipulated to belong to a class of Volterra polynomials with non-linear coefficients. like the log(x) and x^bm on the above example. Those are the coefficients of the monomials. Idealy whatever process I follow should be able to identify the non-monomial coefficients in the expression and remove the monomial terms from them by doing the substitution b_s = b_m. Basically: Which would make the resulting expression strictly a polynomial ring on b_s with non-linear coefficients on x and b_m. |