HyperMath

Addition

Addition

Previous topic Next topic No expanding text in this topic  

Addition

Previous topic Next topic JavaScript is required for expanding text JavaScript is required for the print function  

Addition is supported by the plus operator, +, just like for scalars.

Vectors can be added as long as they have the same dimensions.  It is an element by element addition.  The result is a vector.

> x = [1, 2, 3]; y = [4 5 6]

> print(x + y)

[Matrix] (1 x 3)

5        7        9

A scalar can also be added to a vector.  In this case, all elements are added to the vector.

> print(x + 10)

[Matrix] (1 x 3)

11        12        13

For a matrix, the dimensions have to match as well.  It is an element by element addition.  Scalars can be added, too, just like to vectors.

> x = [1, 2, 3;4, 5, 6]; y = [10, 20, 30; 40, 50, 60];

> print(x + y)

[Matrix] (2 x 3)

11        22        33

44        55        66

Addition for vector and matrices of complex data is supported.