-
-
Notifications
You must be signed in to change notification settings - Fork 480
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow more elementwise simplifications for symbolic matrices #10552
Comments
comment:1
In the code written for #10132 (metric surfaces in 3D), we compute a lot of symbolic matrices with complicated entries which eventually need to be simplified. The current patch adds a method |
Author: Joris Vankerschaver |
comment:2
Thanks for the patch! I am not in a position to review it right now, but it seems fine at a glance. Two comments:
|
comment:3
Ah, sorry to overlook the other simplification methods! I'll get onto it. Also, the code for vectors is now #11335, and I'll update that patch in tandem with this one. One thing that I noticed in the symbolic matrix class is that (for instance) the |
comment:4
Huh, I didn't even notice that these already existed - I should have, and probably even helped review it... sigh. I think the difference here is that we're using Maxima to simplify the whole matrix, instead of doing it elementwise. Maybe that would be better, since Maxima might be faster (especially once we are using the library interface). So the real question is whether there are any simplifications that are better done elementwise than all at once by Maxima. In fact, my guess is that Maxima just does them elementwise in any case, in which case they should all look like they already do - it would be faster, as you point out. So this ticket really is asking to increase the number of methods available. |
comment:5
Replying to @kcrisman:
Good point. I did some comparisons for various matrix sizes of simplify_trig elementwise versus by passing the whole matrix to Maxima, and it seems passing the matrix directly to maxima is about 50% faster. For large-ish matrices (say, 10x10) this is already considerable (1 sec. vs 450 ms. for a random matrix involving sines and cosines). I will therefore use the matrix version wherever available. |
comment:6
Robert Bradshaw proposed a nice way at #11381 of implementing elementwise methods by using the corresponding functionality in |
Simplification methods for matrices |
comment:7
Attachment: sage-symb-matrices.patch.gz We can probably open another ticket for all the expand methods... |
Reviewer: Karl-Dieter Crisman |
comment:8
Good examples, good methods, comprehensive. Passes tests. But there are optional arguments to some of these, which we might as well allow now. For instance Otherwise, really nice. |
comment:9
Thanks a lot for agreeing to review this! I was going over the optional arguments, and for the element-wise methods this is easy to incorporate. However, for the methods that pass the whole matrix to Maxima, I don't know if it's feasible to have the same optional arguments, as that would amount to duplicating the code from the corresponding method in Secondly, I can easily add all element-wise methods, but that would amount to a big increase in not-so-interesting code. As you write in the description, it would be really cool to have a mechanism for adding the corresponding methods from |
comment:10
Instead of duplicating code, it would be better to move the simplification code in |
comment:11
Yes, that's a good idea, but how does Maxima simplify these guys? Do they do it elementwise? |
New version of simplify patch |
comment:12
Attachment: trac-10552-symbolic-matrices.patch.gz I really like the suggestion of moving the simplification methods to somewhere closer to the maxima interface. I would like to look into this, as it would give me a good chance of learning a more complex part of Sage. In the meantime, I've uploaded a new version of the patch (I changed the filename to include the patch number -- the other patch can be deleted), but I'm still in two minds about optional parameters. Adding the |
comment:13
Replying to @jvkersch:
IIRC, Nils Bruin did this for integration, summation, limits, etc. in the library interface to maxima. You can look in the file |
comment:14
See also #12162. Perhaps this should supersede that. |
As with several questions at ask.sagemath. Mike Hansen's answer at the first one seems like a good start:
but it seems reasonable for matrices with symbolic elements to have some of these methods (also vectors, I suppose) without having to use any special terminology.
Open to suggestions on how that might be accomplished without creating a myriad of special methods, but by somehow piggybacking on
symbolic.expression.Expression
methods done elementwise...Putting this under symbolics because it isn't really linear algebra, but that doesn't seem right either.
CC: @jasongrout @rbeezer
Component: symbolics
Keywords: matrix symbolic simplify expand
Author: Joris Vankerschaver
Reviewer: Karl-Dieter Crisman
Issue created by migration from https://trac.sagemath.org/ticket/10552
The text was updated successfully, but these errors were encountered: