## ⊕ and ⊗

**Forum rules**

This forum is for discussing APL-related issues. If you think that the subject is off-topic, then the Chat forum is probably a better place for your thoughts !

3 posts
• Page

**1**of**1**### ⊕ and ⊗

This post is a condensed and expanded version of the APL Chat Forum post j. from 2020-04-09.

From [Hui and Kromberg 2020]:

It’s not everyday you come across a function whose peers are - (negate and minus) and ÷ (reciprocal and divide). An example of using this function:

Exercise: If you were to design a Unicode symbol for j., what would you use? Unicode has 2*21 codepoints, and if you are going to use a new glyph the number of possibilities is virtually unlimited. So how hard can it be?

Suggested Symbols

U+0248 . . Ray Cannon

U+2214 . . Morten Kromberg

U+27C0 . . Roger Hui

U+2BA2 . . Veli-Matti Jantunen

U+27F2 . . Veli-Matti Jantunen

U+2A02 . . Veli-Matti Jantunen

U+2A30 . . Veli-Matti Jantunen

U+233E . . Adám Brudzewsky

When new APL symbols are contemplated, there are various considerations.

Roger Hui: Unicode doesn’t solve all the symbol problems. For example, what symbol would you use to for the “j” function, 0j1×⍵ (0j1 is sqrt ¯1) and ⍺+0j1×⍵? You are free to specify every pixel of symbol.

Guy Steele: Here is my suggestion: the overall structure of the symbol is (monadic or dyadic) plus, but the arrow arc indicates a 90-degree counterclockwise rotation of the right-hand operand (exploiting, as a visual pun, the similarity of a plus sign to the axes of an Argand diagram).

Guy Steele: In effect, this amounts to a suggestion that the monadic form actually be defined as +0j1×⍵.

Roger Hui: A couple of things to consider: Euler’s formula is *∘j = cos j sin, and Euler’s identity is 0=1+*j○1 (*⍵ is exp(⍵) and ○⍵ is pi times ⍵).

Roger Hui: Another design issue is a name or names for this function.

Guy Steele: Looks good to me!

Guy Steele: The names are indeed a separate problem.

Guy Steele: For the monadic form I might suggest “turn”. I have no good idea for the dyadic form.

Roger Hui: Not a deal breaker, but consider the idea of the monadic case being +0j1×⍵ instead of 0j1×⍵:

Roger Hui: Hey, is this language design by Slack? ☺

Guy Steele: Argh, sorry, my mind is still in 1978. I forgot monadic + had been upgraded to mean “conjugate”.

So, “never mind” on that point.

Guy Steele: I know some other languages that look like they were designed on Slack. ☺

Guy Steele: Anyway, you asked the question on Slack, so I figured someone should reply.

Roger Hui: A basic fact to remember: Complex numbers can be constructed as ordered pairs of real numbers, similar to how integers can be constructed as ordered pairs of natural numbers and rational numbers as ordered pairs of integers. For complex numbers, the function j, defined as {⍺←0 ⋄ ⍺+0j1×⍵}, plays the same role as - for integers and ÷ for rational numbers, in both the monadic and dyadic sense.

As I said, it is not everyday you come across a function which is peer to - and ÷.

Guy Steele: But one difference is that a=--a and a=÷÷a, but in general a=j j a is false. But we can say that a=j j j j a, and similarly for that others.

Guy Steele: Anyway, to conclude: at least you got one answer to your challenge. ☺ I don’t care if you change the pixels—or discard the idea entirely. Purely for fun.

Guy Steele: And thanks again for a great talk and discussion.

Roger Hui: I should say that this thread is typical of what happens in APL design. If this thread continues further, I would point out that a=÷÷a is not true either for all rational numbers a (i.e. not true for a=0). Conversely, a=-j j a, which is not bad. Etc. etc.

Current Thinking

Adám Brudzewsky writes:

On further reflection, I like the ⊕ symbol for j←{⍺←0 ⋄ ⍺+0j1×⍵}. If there are existing interpretation of it this one should predominate, if the function is as important as I think it is. (Peer to - and ÷, etc.)

Moreover, complex numbers are commonly represented by magnitude and phase. So if you have a magnitude and phase, how do you get the number so represented? Why k←{⍺←1 ⋄ ⍺×*0j1×⍵} (or {⍺←1 ⋄ ⍺×*⊕⍵}) of course. And what symbol would you use? ⊗ (Monadic ⊗, with a default magnitude of 1, gets you a point on the unit circle.)

Names for the two functions are still open questions.

From [Hui and Kromberg 2020]:

For example, the dialect J has the scalar function j. defined by {⍺←0 ⋄ ⍺+⍵×0j1}¨; that is, a scalar function whose monadic definition is ⍵×0j1 and whose dyadic definition is ⍺+⍵×0j1. (The APL numeric constant ajb is a+b×√−1 or a+ib in conventional mathematical notation.) If complex numbers are in the language, would you specify this as a primitive? A possible answer Hui 2016c, §8:Complex numbers can be constructed as ordered pairs of real numbers, similar to how integers can be constructed as ordered pairs of natural numbers and rational numbers as ordered pairs of integers. For complex numbers, j. plays the same role as - for integers and ÷ for rational numbers.

We don’t know that this is the answer; Iverson designed the primitive and it was implemented without further discussion. We should have asked him about it.

It’s not everyday you come across a function whose peers are - (negate and minus) and ÷ (reciprocal and divide). An example of using this function:

j←{⍺←0 ⋄ ⍺+⍵×0j1}¨

sin←1∘○

cos←2∘○

(*∘j = cos j sin) j⌿?2 3 5⍴0 ⍝ Euler’s formula on random numbers

1 1 1 1 1

1 1 1 1 1

1 1 1 1 1

Exercise: If you were to design a Unicode symbol for j., what would you use? Unicode has 2*21 codepoints, and if you are going to use a new glyph the number of possibilities is virtually unlimited. So how hard can it be?

Suggested Symbols

U+0248 . . Ray Cannon

U+2214 . . Morten Kromberg

U+27C0 . . Roger Hui

U+2BA2 . . Veli-Matti Jantunen

U+27F2 . . Veli-Matti Jantunen

U+2A02 . . Veli-Matti Jantunen

U+2A30 . . Veli-Matti Jantunen

U+233E . . Adám Brudzewsky

When new APL symbols are contemplated, there are various considerations.

- Is the functionality to be denoted worth having a symbol?
- Do you want to use an existing glyph, or create a new one?
- Can you easily write/draw the glyph on paper, on a white (black) board, etc.? Can you easily distinguish it from other scrawls?
- Entering the symbol on a keyboard.
- Adding the glyph to various fonts.
- Creating a <strike>catchy</strike> mnemonic name for it.
- In mathematics, symbols like + and × are heavily overloaded with the meaning disambiguated from context. I am not sure that it would be a good idea to use up + (×) overstruck with . for the function {⍺←0 ⋄ ⍺+0j1×⍵}, because why is this function more worthwhile than other kinds of plus or times?
- etc.

Roger Hui: Unicode doesn’t solve all the symbol problems. For example, what symbol would you use to for the “j” function, 0j1×⍵ (0j1 is sqrt ¯1) and ⍺+0j1×⍵? You are free to specify every pixel of symbol.

Guy Steele: Here is my suggestion: the overall structure of the symbol is (monadic or dyadic) plus, but the arrow arc indicates a 90-degree counterclockwise rotation of the right-hand operand (exploiting, as a visual pun, the similarity of a plus sign to the axes of an Argand diagram).

Guy Steele: In effect, this amounts to a suggestion that the monadic form actually be defined as +0j1×⍵.

Roger Hui: A couple of things to consider: Euler’s formula is *∘j = cos j sin, and Euler’s identity is 0=1+*j○1 (*⍵ is exp(⍵) and ○⍵ is pi times ⍵).

Roger Hui: Another design issue is a name or names for this function.

Guy Steele: Looks good to me!

Guy Steele: The names are indeed a separate problem.

Guy Steele: For the monadic form I might suggest “turn”. I have no good idea for the dyadic form.

Roger Hui: Not a deal breaker, but consider the idea of the monadic case being +0j1×⍵ instead of 0j1×⍵:

(*∘+∘j = cos j sin) 0.7

0

(*∘j = cos j sin) 0.7

1

Roger Hui: Hey, is this language design by Slack? ☺

Guy Steele: Argh, sorry, my mind is still in 1978. I forgot monadic + had been upgraded to mean “conjugate”.

So, “never mind” on that point.

Guy Steele: I know some other languages that look like they were designed on Slack. ☺

Guy Steele: Anyway, you asked the question on Slack, so I figured someone should reply.

Roger Hui: A basic fact to remember: Complex numbers can be constructed as ordered pairs of real numbers, similar to how integers can be constructed as ordered pairs of natural numbers and rational numbers as ordered pairs of integers. For complex numbers, the function j, defined as {⍺←0 ⋄ ⍺+0j1×⍵}, plays the same role as - for integers and ÷ for rational numbers, in both the monadic and dyadic sense.

As I said, it is not everyday you come across a function which is peer to - and ÷.

Guy Steele: But one difference is that a=--a and a=÷÷a, but in general a=j j a is false. But we can say that a=j j j j a, and similarly for that others.

Guy Steele: Anyway, to conclude: at least you got one answer to your challenge. ☺ I don’t care if you change the pixels—or discard the idea entirely. Purely for fun.

Guy Steele: And thanks again for a great talk and discussion.

Roger Hui: I should say that this thread is typical of what happens in APL design. If this thread continues further, I would point out that a=÷÷a is not true either for all rational numbers a (i.e. not true for a=0). Conversely, a=-j j a, which is not bad. Etc. etc.

Current Thinking

Adám Brudzewsky writes:

Steele’s suggestion gave me an idea. hints at the “circular” (i.e. imaginary) part being on the right. The monadic form has the right-identity element (0) as “default left argument” just like - and ÷.

However, I’d probably go for ⊕ because:Oh, and Euler’s formula turns out beautiful (to my taste) with it:

- it is more clearly related to ○ (for which the monadic form is also a simple multiplication)
- it consists of two overstruck basic APL symbols
- it looks more harmonic (in my eyes)

. . . 0 = 1+*⊕○1

. . . 0 = 1+*○⊕1

On further reflection, I like the ⊕ symbol for j←{⍺←0 ⋄ ⍺+0j1×⍵}. If there are existing interpretation of it this one should predominate, if the function is as important as I think it is. (Peer to - and ÷, etc.)

Moreover, complex numbers are commonly represented by magnitude and phase. So if you have a magnitude and phase, how do you get the number so represented? Why k←{⍺←1 ⋄ ⍺×*0j1×⍵} (or {⍺←1 ⋄ ⍺×*⊕⍵}) of course. And what symbol would you use? ⊗ (Monadic ⊗, with a default magnitude of 1, gets you a point on the unit circle.)

Names for the two functions are still open questions.

- Roger|Dyalog
**Posts:**238**Joined:**Thu Jul 28, 2011 10:53 am

### Re: ⊕ and ⊗

Isn't the overstrike of a "St Andrews cross multiply" inscribed within a circle the traditional symbol for Kronecker product, and wouldn't that be confusing if APL used it for something else?

- tclviii-dyalog
**Posts:**28**Joined:**Tue Mar 02, 2010 6:04 pm

### Re: ⊕ and ⊗

The Kronecker product in APL is either A×⍤0 2⊢B or A∘.×⊂B or ⊃⍪⌿,/A∘.×⊂B , and are more general.

In any case, I think the arguments for ⊕ are strong and are made stronger by the arguments for ⊗, and will prevail in the long term (e.g. 100 years).

In any case, I think the arguments for ⊕ are strong and are made stronger by the arguments for ⊗, and will prevail in the long term (e.g. 100 years).

- Roger|Dyalog
**Posts:**238**Joined:**Thu Jul 28, 2011 10:53 am

3 posts
• Page

**1**of**1**### Who is online

Users browsing this forum: No registered users and 1 guest

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group