On 12 July 2015 at 11:57, avi kaur <kauravi...@gmail.com> wrote: > Hello > > I figured out that when we add a number to a matrix, It adds this > number to all the elements at diagonal of matrix. for example: > > sage: a > [ 1 2 2 6] > [ 4 6 2 5] > [56 7 4 8] > [ 8 3 9 6] > sage: a + 2 > [ 3 2 2 6] > [ 4 8 2 5] > [56 7 6 8] > [ 8 3 9 8] > > As you can see in above example. When we multiply or divide it with > some value, It processes all the elements of matrix but not in the > case of adding operation. >
This is not a bug; it makes perfect sense. When multiplying by a scalar the effect is as you observe since the ring of square matrices has a well-define scalar multiplication. When adding a matrix to a scalar Sage first converts the scalar to the corresponding element of the ring, which is that scalar times the identity matrix, and then adds. I have tried to avoid highbrow algebraic terminology in this explanation sicne I do not know your background, but you will know that in the definition of the characteristic polynomial of A as det(A-lambda), you only subtract lambda from the diagonal elements of A. John Cremona > > > -- > Avi kaur > Blog: https://avikashyap620.wordpress.com > "There is no lacking of opportunity, The thing is you do not want to > see It" > > -- > You received this message because you are subscribed to the Google Groups > "sage-support" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to sage-support+unsubscr...@googlegroups.com. > To post to this group, send email to sage-support@googlegroups.com. > Visit this group at http://groups.google.com/group/sage-support. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.