Vocabulary/plus

 + y Conjugate

Rank 0 -- operates on individual atoms of y, producing a result of the same shape -- WHY IS THIS IMPORTANT?

The complex conjugate of the number y

```   + 3
3
+ 3j5
3j_5
```

Common uses

1. Test z is real not complex

```   if. z=+z do.
...
end.
```

2. Find the real part of z

```   z=: 3j4
-: z+ +z   NB. (-:) is: Halve
3
```

A better solution is 9&o. (see Circle Functions (o.).

1. Complex conjugates are a pair of complex numbers, both having the same real part, but with imaginary parts of equal magnitude and opposite signs.

If y is real, then (+y) is the same as y

```   + 7 0 _7
7 0 _7
```

2. J supports complex numbers and returns them as required by a calculation.

The way to write the scalar numeral having real part 3 and imaginary part 4i is: (3j4).

```   sqrt=: 3 : 'y^0.5'  NB. (sqrt y) is y to the power of 0.5
sqrt=: ^&0.5        NB. (tacit alternative)
sqrt 49
7
sqrt _1
0j1
+ sqrt _1
0j_1
|sqrt _1   NB. The sq root of _1 has magnitude 1
1
| z=: 3j4  NB. vector repn of z is 3-4-5 triangle
5             NB. hence its magnitude is the hypotenuse
+ z
3j_4
| +z       NB. Conjugate of z has same magnitude as z
5
```

 x + y Plus

Rank 0 0 -- operates on individual atoms of x and y, producing a result of the same shape -- WHY IS THIS IMPORTANT?

Adds two numeric nouns: x and y

```   2 + 3
5
```

Either or both of x, y can be atoms.

```   x=: 5
y=: 2 3 4

x + y
7 8 9
y + x
7 8 9
```

Common uses

1. Increment an array by the same amount throughout

```   100 + 0 1 2
100 101 102
```

2. Sum the numbers in a given list

```   +/0 1 2 3
6
```

Related primitives

Minus (-)

1. If both x and y are arrays, they must agree.

```   x=: 100 200
y=: 2 3\$i.6

x + y
100 101 102
203 204 205
x=: 100 200 300
x + y
|length error
|   x    +y[x=:100 200 300[y=:2 3\$i.6
```

Note however the use of Rank (") to add 1-cells of x and y

```   x +"1 y
100 201 302
103 204 305
```

Use These Combinations

Combinations using x + y that have exceptionally good performance include:

 What It Does Type; Precisions; Ranks Syntax Primitives permitted in place of f Variants; Restrictions Benefits; Bug Warnings Count number of places where  x f y is true Permitted: Boolean, integer, floating point, byte, symbol (not unicode). x and y need not be the same precision. x ([: +/ f) y x +/@:f y = ~: < <: > >: e. E. Permitted: (f!:0) (parentheses obligatory!) to force exact comparison. J recognizes FLO only if f returns an atom or list. Avoids computing entire  x f y Bug warning: if f is e. it does (,@e.) rather than e. regardless of ranks of arguments
 What it does Type; Precisions; Ranks Syntax Variants; Restrictions Benefits; Bug Warnings Count number of cells of y that match m-items +/@e.&m y Bug warning: it does (,@e.) rather than e. Reductions on infixes Boolean, integer, floating-point x +/\ y <. >. in place of + much faster than alternatives Mean on infixes integer and floating-point x (+/%#)\ y x positive *. = ~: in place of + much faster than alternatives Boolean reductions on partitions Boolean x +//. y = <. >. +. * *. ~: in place of + avoids building argument cells Reductions on partitions integer, floating-point x +//. y <. >. in place of + avoids building argument cells Find mean of each partition x (+/ % #)/. y avoids building argument cells Polynomial Multiplication x +//.@(*/) y avoids building argument cells Polynomial Multiplication (Boolean) Boolean x ~://.@(*./) y x ~://.@(+./) y x +//.@(*./) y x +//.@(+./) y avoids building argument cells Sum along diagonals +//. y avoids building argument cells Mean with rank (+/ % #) y Supported as a primitive by (+/ % #)"n