You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
sagemathgh-36845: Give more precise answer on symbolic power of a matrix
- Changed _matrix_power_symbolic function to consider mk=0 case
- Changed the _matrix_power_symbolic function to handle all the cases
- Created tests covering the changes
This PR improves the answer given by _matrix_power_symbolic() function,
which involves finding the symbolic power of a matrix, and also gives
more precise answer on evalution. eg, before, when we were evaluating
the zeroth power of a matrix sometimes it was giving wrong answer like
below,
```python
sage: n = var("n")
sage: A = matrix(ZZ, [[1,-1], [-1,1]])
sage: An = A^(n)
[ 1/2*2^n -1/2*2^n]
[-1/2*2^n 1/2*2^n]
sage: An({n:0})
[ 1/2 -1/2]
[-1/2 1/2]
```
Here, for n=0, it is not giving an identity matrix which is wrong, but
after the change it will give answer as below,
```python
sage: n = var("n")
sage: A = matrix(ZZ, [[1,-1], [-1,1]])
sage: An = A^(n)
[ 1/2*2^(2*n + 1) + 1/2*kronecker_delta(0, 2*n + 1) -1/2*2^(2*n
+ 1) + 1/2*kronecker_delta(0, 2*n + 1)]
[-1/2*2^(2*n + 1) + 1/2*kronecker_delta(0, 2*n + 1) 1/2*2^(2*n
+ 1) + 1/2*kronecker_delta(0, 2*n + 1)]
sage: An({n:0})
[1 0]
[0 1]
```
Also, This patch fixessagemath#36838 . The function, _matrix_power_symbolic()
was giving symbolic power
of a nilpotent matrix as a null matrix but the correct answer should be
represented
in the form of kronecker_delta() function. In the case of mk=0,
simplifying only binomial
term should work because afterall the form 0^(n-i) should be simplifed
to kronecker_delta() function and no further simplification is needed.
And in every other case it is simplifying whole term so it will handle
all other cases.
<!-- ^^^^^
Please provide a concise, informative and self-explanatory title.
Don't put issue numbers in there, do this in the PR body below.
For example, instead of "Fixessagemath#1234" use "Introduce new method to
calculate 1+1"
-->
<!-- Describe your changes here in detail -->
<!-- Why is this change required? What problem does it solve? -->
<!-- If this PR resolves an open issue, please link to it here. For
example "Fixessagemath#12345". -->
<!-- If your change requires a documentation PR, please link it
appropriately. -->
### 📝 Checklist
<!-- Put an `x` in all the boxes that apply. -->
<!-- If your change requires a documentation PR, please link it
appropriately -->
<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
<!-- Feel free to remove irrelevant items. -->
- [x] The title is concise, informative, and self-explanatory.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [x] I have created tests covering the changes.
### ⌛ Dependencies
<!-- List all open PRs that this PR logically depends on
- sagemath#12345: short description why this is a dependency
- sagemath#34567: ...
-->
<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
None
URL: sagemath#36845
Reported by: Ruchit Jagodara
Reviewer(s): Dima Pasechnik, phul-ste, Ruchit Jagodara
0 commit comments