# array arithmetics vs matrix multiplication#571

Open
opened this issue Aug 28, 2018 · 6 comments
Open

# array arithmetics vs matrix multiplication #571

opened this issue Aug 28, 2018 · 6 comments
Labels
type:discussion Discussion or feedback about the lesson

### thawn commented Aug 28, 2018

 In section 01-numpy the following statement deals with array arithmetics: If, instead of taking an array and doing arithmetic with a single value (as above), you did the arithmetic operation with another array of the same shape, the operation will be done on corresponding elements of the two arrays. It may be useful to mention that this is different from proper matrix multiplication which can be performed with numpy if you convert the array to a matrix object. The text was updated successfully, but these errors were encountered:
added the type:discussion Discussion or feedback about the lesson label Sep 19, 2018

### annefou commented Sep 19, 2018

 personally I would not mention matrix; I don't think adding matrices would help to understand arrays.

### maxim-belkin commented Sep 19, 2018

 I think the point that @thawn is trying to make is that multiplication (`*`) is element-wise and not a cross product, what might some people expect ```import numpy a = numpy.array([1, 2, 3]) b = numpy.array([4, 5, 6]) a * b # element-wise multiplication >>> array([ 4, 10, 18]) numpy.cross(a, b) # cross product >>> array([-3, 6, -3])```

### thawn commented Sep 20, 2018

 @maxim-belkin that's exactly the point I was trying to make. particularly people who are used to MATLAB, where matrix multiplication is the default for two-dimensional arrays, the behaviour of Python may be surprising. I think one sentence just saying it is not matrix multiplication but element wise multiplication would be sufficient. if you want to be perfect you would also link the words "matrix multiplication" to the documentation of how that works with numpy ;-).

### annefou commented Sep 22, 2018

 Ok. It sounds good. Thanks.

### maxim-belkin commented Sep 22, 2018

 While difference between element-wise multiplication and cross products is significant, I'm not sure we should talk about it while explaining the material. How about we add a note about element-wise multiplication vs cross product to instructor notes?

### annefou commented Sep 23, 2018

 Very good idea. So instructors can answer to questions and help to clarify only when needed.