Contents Previous Next Subchapters

Addition
Syntax left value + right value
See Also subtraction , multiplication , division

Description
Element-by-element addition of two values that are integer, real, double-precision, or complex. (One, but not both, of the values may be logical.)

Tutorial

Adding Scalars
If you enter
     1 + 2
O-Matrix will respond
     3

Adding Matrices
If you enter
     x = {[1, 2, 3], [4, 5, 6]}
     y = {[1, 1, 1], [1, 1, 1]}
     x + y
O-Matrix will print
     {
     [ 2 , 3 , 4 ]
     [ 5 , 6 , 7 ]
     }

Adding Scalars to Matrices
If one value is a scalar and the other is a matrix, O-Matrix will add the scalar to each element of the matrix. Entering
     x = {[1, 2, 3], [4, 5, 6]}
     x + 1
will result in
     {
     [ 2 , 3 , 4 ]
     [ 5 , 6 , 7 ]
     }

Reference
If the value types do not agree, O-Matrix will coerce the values as detailed in the coercion table.