-
-
Notifications
You must be signed in to change notification settings - Fork 488
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
Convert factorization to symbolic expression #17624
Comments
Commit: |
Author: Ralf Stephan |
New commits:
|
comment:3
While the coercion seems to work as expected, it does not solve the " sage: R.<a,b> = QQ[]
sage: m = matrix([[a^2-b^2, a^3-a*b^2], [a*b + b^2, -77*a+77*b]])
sage: m.apply_map(factor)
Traceback (most recent call last):
...
TypeError: x must be a list |
comment:4
Well it doesn't work with integers, either:
and so is clearly not a problem of this ticket. Of course you need to explicitly cast to
It's just that the string crutch is no longer needed. |
comment:5
OTOH I just found a bug (77?). |
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:8
It seems that the following, using SR's "factor", works pretty well for the problem in the question:
The problem with doing it the other way around is that the intermediate result would have to be a matrix with elements coming from ... Factorization? While we could have that, it would require a significant design and refactoring effort. Do we have a good reason to do that? With factorizations themselves convertible to SR (which is quite reasonable and easy to do, as rws shows) one can do:
which is not hacky, albeit a bit verbose. It's basically "apply_map" spelled out. |
comment:9
I think it's safer to explicitly convert the unit also to |
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:11
I thought that would be done by giving it second for multiplication? |
comment:12
Replying to @rwst:
Well, I think it's better to be explicit. But your comment inspired me that you should do this instead:
|
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:14
So, assuming |
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:16
Replying to @nbruin:
Is there any real obstacle to making Factorizations Elements of their universe()? |
comment:17
Replying to @mezzarobba:
But that parent couldn't possibly be a ring (what's the sum of 2 factorisations?), so you wouldn't be able to make matrices over it. |
comment:18
Replying to @jdemeyer:
When the universe is a ring, |
comment:19
Replying to @mezzarobba:
I don't think that this will work properly. Within the current |
Reviewer: Jeroen Demeyer |
Changed branch from u/rws/coerce_factorization_of_polynomial_to_symbolic_expression to |
Dealing with polynomial rings is nice, but the fact that they always present their content in fully expanded form can make it hard to read results. For a single polynomial, computing its factorization can help. But for e.g. a vector or matrix composed of factorizations, this is not possible.
It would be nice if the
apply_map(factor)
call would simply work, returning a matrix of symbolic expressions to help reading that matrix. The detour viastr
is a very hackish workaround, in my opinion.Note that SR will automatically expand some things, as evidenced by the coeffcicient 77 in the example above. I guess that could only be avoided if we could have matrices of factorizations. That would be a viable alternative, and might be worth its own ticket, but I think coercion to SR might have other benefits as well, so this ticket here is about that coercion.
Component: symbolics
Author: Ralf Stephan
Branch/Commit:
9c461e3
Reviewer: Jeroen Demeyer
Issue created by migration from https://trac.sagemath.org/ticket/17624
The text was updated successfully, but these errors were encountered: