Back to Index

fast.ai APL study session 1


Chapters

0:0
19:59 How To Read the Help
22:50 Install Anaconda
26:43 Monetic Form
52:59 Complex Number

Transcript

- Curious to see how many people join us. Where are you coming to us from, Wayne? - I'm in the US in New Jersey. So if there's any explosions in the background while I'm talking, it's 'cause it's the Fourth of July. - Oh yeah, happy Independence Day. Is that a thing you say?

I don't remember. Do people say happy Independence Day? - I don't think I've ever said that to anybody. I don't know. It just is Independence Day. - Yes. - Yeah, I guess sort of. - How about you, Alex? Where are you? - I'm in the Netherlands. - All right.

Who else is here? Hi, Abhishek. How are you? - Hey, Jeremy. I'm good. - Where are you joining us from? - I'm joining from India. It's quite early in the morning. - Yeah, India's a big place. Whereabouts in India are you? - I'm in Lucknow, near Delhi, northern India.

- And what's the time there? - It's 5.30 a.m. - Wow, Kiryat, are you in India too? - Yeah, I'm in India too. I'm in South of India, actually, in Kerala. - Oh, Kerala. Awesome. Apparently that's really beautiful. I used to work with somebody from Kerala who said I should come visit him one day, but I never managed to.

- Yeah, you definitely don't, yeah. - I'm sure I'd love it. - It's like the one country I've always wanted to visit, but haven't yet. - Oh, I see. I think you should come to any conferences or something like that. - Yeah. - So I want you to try aloo parathas in Delhi, Jeremy, because I know that's the Indian bread you like.

- Yeah. Yeah, there's a lot of Indian foods I like. We do get some pretty decent dosa near here, which is nice. We didn't used to, but now we do, but I'm sure it's nowhere near as good as the dosa that you get in India. I don't think I've ever had an Indian meal I didn't like.

I see Washem is here as well. Thanks for all your help recently, Washem. Although he's muted and de-videoed. Maybe he's being coy. Hi, Tudish, how are you? Also muted and de-videoed. That's fine. - Hello, I'm just- - Oh, here he comes. - Yeah, just hanging around, but yeah. It's July 4th, so.

Yeah, how's your July 4th going so far? - Nothing much right now, but we're gonna have some food and stuff. So yeah, we're preparing, so. - Awesome. - And I guess we'll see what there's any fireworks on TV or something like that. - Yeah. And we've got some Aussies here as well.

Hi, Radek. Hi, Serada. - Hello, hello. - Hello, hello. How are you doing, Radek? - Good, good, so excited for the session. - All right. Well, let's get started, shall we? Has anybody here had any experience with APL or J? Okay. Nobody? - I've played around with it. - Yeah.

I feel like, where are you coming to us from? - I'm in Washington, DC. - And what have you done with it, Felix? - Mostly toy stuff. I was doing Advent of Code last year in APL. - Okay, so you're probably gonna be able to teach us some stuff.

And who else, somebody else said they might've done a little bit, I think. - I've done a little bit less than Felix, but just played around with it. Just started trying to go through a linear algebra course, chapter one in APL. - Okay, awesome. Like, is it a linear algebra in APL course, or you're just like doing a linear algebra course and using APL?

- It's a textbook that is linear. It's a linear algebra textbook, and they chose APL as the-- - Oh, wow, can you share a link to it in the chat? - Yeah, absolutely. - You got any Independence Day things happening today, Isaac? - Just this call. I'm sure there'll be fireworks going on sometime, but I don't know that we're gonna go watch them or anything.

- All right, well, I'm glad there's some folks who hopefully can help us figure things out, 'cause I've got very little background in this, other than teaching my kids some math using APL, and a little bit of playing around with Jay. I was actually on the ArrayCast podcast this morning, so lots of APL things happening in my life today.

Applied linear algebra with APL. All right, I guess I should share my screen so that people can show what you're sharing. Share screen, share. So this is one of the things I like about APL is that there is a bunch of books and whatever around that use APL to teach other things.

Well, let us know how it goes. I've never heard of this one. - Yeah, it looks good so far. I just finished chapter one, section two, so I'm not even completely through chapter one, but if I'm gonna further along, I'll let you know. All right, so hopefully everybody's done step one.

If you haven't yet, that is to install dialogue APL. There is a bunch of different APL interpreters around, but they're not all the same, and dialogue seems to be the one that it's by far the most heavily invested in, and has a bunch of cool things that aren't necessarily in the other APLs.

And I do recommend installing it from their website. You don't have to register or anything. There is a option to download an unregistered version and it works perfectly. So I'm on Windows, but there's also a Mac one, and then there's both Debian or Ubuntu and Red Hat, RPM, whatever, options for Linux.

I think some Linux one doesn't come with a GUI. So I'm not installing this one. Linux at the moment, so I haven't tried this. I'll try it later, but there is a GUI you can download called Ride. Now that comes with the Mac one, and Windows comes with its own GUI.

But there's also, if you go to the latest release here for Ride, you'll find there's RPM and dev for AMD and ARM platforms. So I think you have to install dialogue first and then you install Ride. Okay, so then to run dialogue, yeah, you know, on Mac, command space, type dialogue, or on Windows, hit the Windows button and type dialogue.

Now, one thing I found a little hard to find, which is actually pretty obvious now. I know where it is. There's an increase in the font size. You just do it in the toolbar up here, like so. I can't remember if you have to reboot after you install dialogue or not, 'cause it doesn't install a keyboard.

Now, dialogue, keyboard. Yeah, APL fonts and keyboards. So if you scroll down to the bottom here, it's a little hard to see actually, but there's actually different tabs here. So on Windows, you should find that you can, so there's a language bar with all the different glyphs, right? But you can also hold down control and press the keyboard button to get a glyph.

So there's control A, control J, control hyphen. On Mac, you press back tick this button and then press the letter. So what I did is there's a few ways you can do this. On Windows, I can't remember if Mac does this as well. If you wave your mouse over something in the toolbar, it tells you what button to press to get it.

And then the other thing I did was I just Googled for APL keyboard and I just printed out, oh, that doesn't work 'cause of my background thing. Hang on. Video. I printed out just a picture of an APL keyboard. Which honestly, I haven't referred to too much because the one in the IDE works so right.

- So let's look at Mac OS. We have that little tool tip thing showing up too. - Oh, okay. And I don't know if it's any use or not, but if you want to, in Windows, you can use back tick instead. If you go to Unicode input, you can have it activate a keyboard when you start, which obviously, you'd pick APL and then you can turn on, maybe we have to press Mr.

Tick. Oh, it's weird. Hang on. Well, this is working before I was able to turn on back tick, but for some reason, it's not working. Nevermind. Well, you should be able to click configure layout and turn on a back tick instead, but using control works fine for me. Now in Mac and Windows, the back tick or control keys will just automatically work when you go into the app.

If I run something else. - Jeremy, can you search screen? - Oh, yeah, yeah. Sorry. Search screen. Okay. Thanks for reminding me, Serada. Okay, so that's the control, whatever's. And then, if I go into some other dialog box or some other program, then the control buttons don't work anymore.

So I just get my normal control, I select all. If you want, in Windows, if you want to use the dialog keyboard elsewhere, you can hold down the Windows button and press space, and it'll pop up a list and keep holding down Windows. It'll pop up a list of different keyboards, and you can just choose dialog APL keyboard.

And so now, if I start typing control, I get the dialog ones here. So if you're trying to use like, if you're trying to select something, and then try to copy it with that control C, and it doesn't work, that might be because you actually have the dialog keyboard running, so then you'll just have to hold down Windows and press space to go back to a non-APL keyboard.

For Mac, just go to this APL fonts and keyboards dialog page, and click on macOS, and it'll show you how to enable the keyboard, and then you can change your keyboard layout for Mac. But you don't have to use any of this just to use Ride or the Windows IDE.

This is just if you want to use them outside. So has anybody had any issues with installing? Oh, the other thing to mention is on Linux, if you go to the forum, there is a link here using dialog in Debian. Which describes how to install it, 'cause you do have to install at least one extra thing and possibly two, and chose how to use the keyboard.

And then I see Adam, who actually works at dialog, has kindly added a note here about Ride, which we've already mentioned, so that's good. And so that includes the back tick thingies. All right. Yeah, did anybody have any issues with installing or any other notes? Oh, I see Waspium has mentioned try APL.

Okay, yeah. So I haven't really used this myself, but I know a lot of people talk about it, which is, yeah, APL in your browser. Does this do back tick? Yes, it does. It looks like back tick works here. Cool. So you can use back tick, followed by a letter to put it in there.

And they've also got the, what's this tab? Seven equals tab. Seven, seven tab. Yes. Oh, I see there's multiple ways to type this. So prefix S I think means back tick S. Yes. Okay, so that's how you can read those little thingies, or you can just click on them.

All right. Is everybody able to run APL and type stuff? Okay. Just gel if you can't. Otherwise we'll keep moving on. - I guess with APL, it's not like the conciseness and expressiveness of it means that it's not like you're typing at a hundred words per minute anyway, so.

- Right. Yeah. Yeah, it's more like typing a math equation or something I suppose. Yeah. Charles says going to an obscure programming language course at 2 a.m., what am I doing with my life? We can't help you with that Charles, 'cause we're also all here. Some of them are here on Independence Day.

So everybody here will not be able to empathize with any troubles you're having. Sorry. All right, so. Okay, we're making progress. So I'm gonna run dialogue. Increase the font size. And I don't know if there's a way to turn these off by default, but you can get a bit more space back by clicking on these little various Xs around the place.

I do feel like it would be nice to get some more space by removing the word language bar above the language bar, I'm not showing that much, not much doing much for us, but so be it. All right, so I'll show you, I'm not an expert in this IDE, but it kind of behaves like a normal REPL.

So I can type numbers, I can type expressions. So yeah, the answer from dialogue APO appears on the left and my input appears indented. Something took me a while to realize that you can click on an earlier one with your mouse or go up to it, and then, you know, edit it.

And if I press enter, it actually, this one goes back to what it used to say, and then this, and it'll put my new thing on a new line, which is actually really, really helpful. So I think that's my number one tip that I've found so far. - You can also bind scrolling through history to a hotkey.

- Yes, you can. And I thought it might've even have come with one. I can't find anything that it's working for. Dialogue, APO, keyboard history. No, all right, how do you, all right, how do you do that? Configure? - Preferences. - Yeah, okay, called configure in my one. Probably keyboard shortcuts.

- Yes, and it is called backward or undo, I believe. - Backward or undo, control, shift. - DK. - Back, control, shift, backspace. Control, shift, backspace, there we go. Nice, okay. That's great. All right, so the next thing I wanted to do was get a Jupyter kernel working. 'Cause I'll tell you my plan, and I'll tell you why it's my plan.

Most array programming tutorials, books I've seen kind of like look at one concept at a time and go pretty deep on it, which is not the first AI way to teach things. And I think it's particularly not the right way to teach APO. And the reason for that is that when I look up stuff in the help, so in dialogue for Windows, I can wave over one of these and go down and I can click on more.

And it doesn't always come to the front, but here we go, I get the help. Now, let me explain how to read the help. The help tells you, it shows me up here what the glyph is. And every glyph has a name. So that small circle is called Jot.

And we'll talk about this soon in more detail, but generally speaking, each glyph does two things. Called monadic and dyadic. And each of those things has its own name. So Jot can do either beside or bind. Okay, so we can click on beside. All right, now you can see the problem here is that the examples all use glyphs that we don't know.

And so it's like looking up in a dictionary to learn how to read Chinese when you don't know Chinese. So my plan is to first learn every single glyph, like in as simple a way as possible so that then we can read the documentation. So I think this is something that I haven't seen done before and I'm quite enthused about learning all the glyphs.

So I've been teaching math to my daughter and her best friend, Claire and Gabe, and that's the very idea I told them. We're gonna try and learn all the glyphs and they're just very excited about the idea of like, all of these weird symbols becoming things that we understand and there won't be weird symbols anymore.

So for me, most of these are still weird symbols, to be clear. But yeah, I don't know. Like a lot of them probably won't take long to learn, like obviously these plus minus times divide and these equals, you know? So quite a few of them. So we'll start with the ones that we can recognize.

So yeah, one reason I wanna get Jupyter going is I wanna be able to start writing blog posts about APL. So let's try installing that together. I don't know if anybody's already done it, but I'm gonna go Jupyter APL kernel. - I played around APL a little bit a couple of years ago before I took a break and I found that getting the Jupyter kernel for APL working just kind of worked.

So hopefully that's still the case, but it was really easy to get it going. - All right. So I've already got Jupyter installed on Windows. You can use condor or pip to install it. Probably condor might be a better option. And so now, let's see if this is the right button.

Install dialogue, I've done that. Install anaconda, I've done that. Oh, that's right. They haven't actually got a pip or condor installer for this, which obviously they ought to fix. So we should fix for them. Download this. Fine. Save. Okay. And just recently I found my downloads in Chrome have started taking a ridiculously long time, but it looks like it's finally done.

Okay, so let's unzip that. Okay. And then it's set to run install.bat. Run anyway. Okay, looks like something happened. Okay, let's see if what we wanted to happen happens. So I run Jupyter. Okay. And new, oh, dialogue. Go, baby, go. So now I'm gonna use windows. Oh, allow it to communicate.

That's fine. Okay. So I'm probably gonna have to hit windows space to choose the dialogue keyboard. And okay, cool. So one, one plus one. All right. You're right, Isaac. That was pretty easy. So if somebody on Mac, do you have a, is there like integrated help in ride that gets you access to something like this?

- No, it opens up a website, basically. - Okay, well, that's fine. I was gonna say everything that's in there is also in the website. Let's try searching for that exact thing. And of course, I just tried to hit control T to open up a tab, but that doesn't work 'cause I'm in the dialogue API or keyboard.

Dialogue, language, elements. Here we go. Okay, I opened with navigation. I guess I don't really need the navigation. All right. So I feel like they're, at least these are not in a bad order to learn about them. So let's start with plus. And let's start by learning to read these things.

Okay. So up in the top right here, we've got the glyph. And generally speaking, for functions, they're gonna show us the two things that they can do. They're called monadic and dyadic. Actually, let's start with minus 'cause it's a little easier. Monadic and dyadic. Monadic means that you're gonna put something only on the right-hand side.

Like for example, negate three. That is the monadic form. If you've heard the word monad before and stuff like Haskell, this is not that. This simply means a function that takes one argument. And in APL, you don't write functions like that. Instead, you write your argument after if you have one argument.

And if there are two arguments, you can have a second argument before. So it looks more like math than normal computing. So monadic means one argument. You'll see here that the negate function when applied to three returns like upper hyphen three. This upper hyphen is control two. I gotta say control, but for Mac users, that means back tick, control two.

And this is how you write a minus sign in APL, meaning the constant number negative two. So these are two different things, right? This is a function that negates its argument. This is part of a numeric literal constant, which is the negative number. Now it so happens that the negated function, negate function applied to three and the number negative three are the same thing, but they're different, conceptually different.

This is a single number. This is a function. Okay, so monadic, monadic means it takes one argument and the argument goes on the right. Does that make sense so far? Please tell me if it doesn't. Otherwise, we're gonna keep looking at the help 'cause I wanna show you how I look at the help.

Basically, the help focuses on examples. And the idea is that you can kind of figure things out by looking at the examples. So if you copy the indented bit of the example and paste it, you should get the same result. Now this looks pretty similar to the example we just gave, but you'll see that they've got multiple numbers on the right.

They've got 3.2, negative seven and zero. This is how you create a one-dimensional array or in kind of PyTorch speak, a rank one tensor or in math speak, a vector. You just chuck spaces between them, between numbers. So there's some controversy about whether this is accurate, but I'm just gonna use the word array for everything.

So this is, I gotta call this, for example, the number three, which we call a scalar. I gotta call a rank zero array. Here's a rank one array. So when I say array, I'm gonna include scalars, okay. - So in the minus 3.2 against seven zero. - Yes. - What is this?

- Okay, so that is a list or this is an array containing the numbers 3.2, negative seven and zero. And this is the function that you're applying to it. And so this is the result. Okay, so the result is it's like NumPy. It's applying the function to every element of the array.

So the negative function, negate function by the 3.2 is negative 3.2 applied to negative seven is seven and applied to zero is zero. - So it is a negative function, it's not the minus. - Correct, this is the minus that's part of a literal number. This is the negate function.

- All right, but when you were typing this, did you do control two or did you do minus? - No, this is minus, this is minus. - So minus on the keyboard is the dash. - Yes. - The control two is for the special negative number symbol. - Jeremy, I posted a command in the chat, which will turn boxes on and it'll draw boxes around your list.

So you can see kind of the structure of what you've put in there. - All right, let's do it. Copy. Do you know a way to do this automatically, by the way, when you start APO? 'Cause it feels like what I always want. - I do not. - There we go.

Okay, now I can't quite remember how to read these weird arrow things, but I guess we'll figure it out as we go. But this is basically saying this is, I think this arrow is saying that there is a dimension here. So this is a one dimensional array. And I don't know what the squiggle means.

- Jeremy, I tried this box thing. So you go to the session, next to session, there's a one and two, they have a boxes there. No, not this one, under the, yeah. This one is also turned on the box. - Okay, and does that do the max thingy or?

- What that mean? - There's a style equals max. So like, I don't know. - You can set style of the men and it will draw fewer things. - Okay. - If you just are dealing with larger arrays. - Okay. So I don't know if this one is the men or the max, but that's really useful, Sarada.

Thank you, well spotted. - They're just a box for everything. - Yeah, so about the squiggle, I think there is a difference between a list and a two dimensional array that's three columns in one row. - Yes, absolutely. When you say a list, I think you made a rank one array or a vector.

- Yes. - Yeah, yeah. Okay, we'll come back to that. - So if you do nested lists, you can kind of see what the boxes are really about. - Yeah, well, let's leave that for now. Great. So I think we've got enough now to understand the first piece of documentation.

So that's good. So let's, pop this in a separate window. All right, so, type numbers. And so we should show that one. And then we've got rank one arrays. Rank one arrays. Okay, and then we've got monadic minus. And I guess we could link that to the documentation. Okay, so now if I click on the gate, we're gonna get more information about monadic minus.

All right, and so notice that hyphen in APL is pronounced minus sign or bar. I'm not used to saying things with two names. They normally just have one. And it can mean two things. And the monadic version is called negate. So when people talk about like read out APL expressions, they will often refer to the names of them.

So they'll say negate. Now, this one's interesting. Copy. Let's pop it actually in here. Paste. Now, notice here, this does not mean minus four to zero. This means minus of that. I know there's no space after the minus, but space doesn't have meaning after a function. So that's why two is being negated and negative three is being negated because the minus refers to the whole thing.

And it would be more obvious if there was a space here. Now, if we had written negative four, that would be something else entirely. That would be the number negative four, then the number two, then the number zero. But minus is a function and it applies to its whole right-hand side.

And its whole right-hand side is a rank one array. And that's why we get two goes to negative two, negative three goes to three and so forth. Does that make sense? Okay, so Isaac's just added in the chat something useful, which is that there is also a bookmark that you can drag to your bookmarks bar, which I've actually already done.

And somebody, by the way, maybe as we do these things, could add these to the forum thread, to the forum wiki. So if I click APL here. Yeah, so now we've got all these things. Oh, now it's back to gonna work. Let's try that. Nice. Okay, this is better.

I'm gonna turn off my keyboard. Okay, I'm glad we tried that. So now backtick works. And this is written in JavaScript, so this will be cross platform. All right. So maybe we should show these examples. Okay, minus applied to four, minus applied to negative four. The kind of the APL way and the AERA programming way of like showing things in general, which I quite like, does involve a lot of examples.

Which does like require the reader to like look at the example and figure out what's going on. And this is what I've been doing in teaching the kids some math and APL, is we look at the examples, we paste them into dialogue, and then we say like, oh, who can guess what's happening here?

And it's actually quite a good, it's quite a good exercise, but it requires a little more work perhaps than people are used to. Okay, we got decimals, rank one arrays, one attic minus. So maybe that should be a heading three and then we'll create a heading two, which is this is minus, oopsie daisy.

Oh, backticks, how do I do a real backtick? Crap. Anybody know how to type a backtick? (laughs) - You could temporarily close the JavaScript bar, I guess. - I could, yeah. We could always ask Adam if he knows. I was hoping the backtick, backtick would, give us what we needed.

Is there a backtick in here? I don't think so. - Do you have a numpad? Is it alt? - I do not. - 26 or 126. - I do not. Do you know that off the top of your head? That's a bit crazy. - No, I googled it. - Alt backtick seems to work.

- Huh? - Alt backtick. - Alt backtick. Nope. - Nope. - Oh, what just happened? Whoa, that's a weird thing. Somehow I just pressed a button to put up a terminal. - I was able to do option backtick on, - On Mac. - Hold option and backtick on Mac.

- Yeah. - And that gave me a backtick with an underline and if I entered, turned into a regular backtick. - Huh. - Okay. All right. I'll let them later. Okay, so this was called, minus sign or bar. And this was called negate. Okay, so now I can do dyadic.

So dyadic means it has two arguments. This is called minus or subtract. Okay, so normally two arguments in a function looks like this unless you do what we call infix notation, in which case it looks like this. APL is always infix notation. So to dyadic means it has two arguments.

One argument goes on the left, one argument goes on the right. Okay. Any questions about dyadic versus monadic? So just like in NumPy, you've probably noticed that you can apply a function to an array and the function is applied to each element of the array. Negative of four, negative of two, negative of zero, negative of minus three, negative of minus five.

So we can do the same thing when it's got two arguments. We can have one on the right and then a different argument on the left. Does that make sense? So that's element wise, just like NumPy. Three minus four, two minus five, one minus one. this also works is you can have a rank one array minus a scalar and just like NumPy, it'll broadcast this.

So this is three minus one, two minus one and one minus one and vice versa. One minus three, one minus two, one minus one. - Is there much of a culture of using brackets in this world? - I wouldn't say there's a culture of using parentheses, but I would say there are times you have to use parentheses.

I would say, I can't imagine anybody would use parentheses around this, just like in Python, if you were writing, oopsie dozy, if you were writing 1.5 times 6.2, we know perfectly well that dot binds tighter than times. So in Python, nobody would write this, right? Well, somebody who didn't know that dot binds tighter than asterix would say like, well, this is much clearer, but like, yeah, you know, only the first three times after that, you know perfectly well that this means 1.5 times 6.2 rather than 1.5 times 6.2.

So a razor everywhere in APL, so the idea of parenthesizing this in such an expression would be weird and I've never seen that done. And I guess in general, because the kind of parsing and precedence rules in APL, as you'll discover, are so simple and clear, parentheses generally only seem to be used in real code when they're actually necessary rather than just for clarity.

I would say in something like C++, we see parentheses used for clarity a lot more because for example, in C++ or even in Python, the precedence rules are very complicated and few people remember them and they're easy to misremember. All right, so I feel like we've probably done our first lift, so that's cool.

So our second lift we can do will be plus and dyadic plus is the easy one. So maybe I'll just do some copying and pasting in fact, that's a good way to get a back tick as I put it in my paste buffer. Ha ha, all right. So this one is called conjugate and then the other one will be called plus and the overall thing is called plus sign, that's easy, plus sign and monadic is called conjugate, conjugate and this is called, oh, got it the wrong way.

I know that's fine, I just have to write dyadic, dyadic. Maybe I'll make a copy of this underneath the next time. Okay, so we can basically do the same thing as last time, paste those here and we will replace dash with plus and three plus two is five, rank one array plus rank one array, rank one array plus a scalar which is a rank zero array kind of, they all work.

So hopefully that one is straightforward. Now, conjugate. So it's pretty normal in APL to provide a rank one array to an example, because that way you kind of get to show three examples in one go, right? So it's important to just look at them one at a time. That may be, you know, to start with, we can like do that, but like we shouldn't need to do this for too long because hopefully we've got the idea that to read this, it means plus 1.2 plus zero J4 plus minus five J minus six, which means I think we need to talk about complex numbers, which is cool because we get to talk about some math.

All right, so is anybody on the call? And please don't be shy of saying yes, because we're trying to learn math. Is anybody on the call don't know at all what a complex number is? - Yep. - Yep. Okay, great. So have you ever come across the idea that the square root of minus one is something called I?

- No, I know that I is a thing, but-- - Okay, then is what I is. So basically the idea is that we can, we can square things, which means multiply by itself. So three times three equals nine. And so what do we have to square? That means three squared equals nine.

We'll get ahead of ourselves a little bit and no, let's not, let's just do that. So to write squared, we can also say to the power of two. Be very careful, this means power of in APL, not times. So there's three squared, okay. And there's four squared. And so we can do the opposite and say, what would you have to square to make 16?

And the answer could be either four, 'cause four times four is 16. Or it could also be negative four, 'cause negative four, negative four squared is also 16. You happy so far? So then the question is, okay. Okay, so the question of like, what do you have to square to get to this number is the square root.

So the square root of 16, and we always take the positive, the square root of 16 is four. So then the question is, what's the square root of minus one? And the answer is, oh, it's the number that you would have to multiply by itself to get minus one.

Which of course doesn't exist as a real number. Because minus one times minus one is positive one. So we just make it up. We make up a number and we say, okay, I'm gonna invent a number, I'm gonna call it I. And I is the number that if you square it, you get negative one.

And I can't show you I, pineapples, but I also can't show you negative three pineapples, you know, they're both like invented ideas. I mean, I can't even show you the number two. I can show you the digit two, I can show you two things, but the idea of the number two is a mathematical concept.

So numbers don't necessarily exist. And so a lot of mathematicians say I is considered, is called an imaginary number, but it's not any more imaginary than any other number 'cause all numbers are imaginary. Okay, so you can then create something called a complex number, which is an imaginary number plus a real number added together.

A real number being anything that doesn't have I in it. So for example, here's a real number. Okay, and here's an imaginary number. And so that means that this here is a complex number and there's no way to like reduce that further. We're done. Okay, that is the number three plus I.

You can do things with I, you can multiply it by four and then four times I is four I, that's a number. You can square it and of course you'd get minus one, I squared is minus one, you can multiply I by four and then add three and that gives you the number three plus four I.

So here is the real part and here's the imaginary part. And the whole thing is called a complex number. And you can't like, this is not an equation. I can't do anything to this. This is the number. It's called the number is three plus four I. In APL, we can write complex numbers in a slightly more concise way.

And we write them using a J. On the left-hand side is the real part. On the right-hand side is the imaginary part. So this is zero plus four I, also known as four I. This is negative five plus minus six I, also known as negative five minus six I.

Does that make sense? - So complex numbers always involve I. There aren't any other letters. - Yep, there's no need for anymore. We just need the one extra letter, which is this ability to kind of say like, oh, there's a second bunch of things in the world. And the key reason that complex numbers are really interesting and important is because you take the number line that we all learned, like my daughter learned the lumber line in prep, right?

You can move forward along the number line to get bigger numbers and backward to get smaller numbers. And after you go forward, you can then like undo that with negative to go back to where you started. When you use a complex numbers, you move from a number line to a number plane.

And the Y-axis represents how many I's do you have? And the X-axis represents what the real number is. And so then you can graph it on a Cartesian plane. Like so. So you've got the numbers. - Jeremy, I think you're not sharing the screen. - Okay, I never share my screen.

That's just how I am until you're surrounded, tell me to. Okay, so yeah. So you've got the numbers on this axis and the negative ones on this axis. Yeah, here we go. So here's our number line. Here's our number plane. And so here's three plus four, right? And so, in real number only math, you can multiply by a negative number and it flips it to the other side.

In complex math, you can multiply by I and it rotates it by 90 degrees. I gotta skip the door just a moment. I didn't realize math, I got home, okay. So, yeah, they're used for a lot of things, which kind of expand the world of math to two dimensions.

And they let us work with tuples of two things at a time. So, yeah, they come up a lot in real life. And in fact, in physics, it turns out that our actual real physical world operates according to the laws of complex numbers, not real numbers. So they're very real.

Okay, so-- - It feels like, oh, sorry-- - No, no, no, please I'd like to chat. So interrupt any time, go ahead. - Sure, it kind of feels like a complex number. It's like a shorthand for representing like a 2D or a rank two array as just-- - It's not a rank two array, a rank one array of two items.

- Yeah. - Rank, yes. - Yeah, because you're like using the plane and the unit circle and stuff, it feels like you're trying to represent like that second element of that array is written in terms of its relation to the first element or something like that. - Yeah, yeah, I mean, it's, yeah.

Yeah, I think like getting an intuition for complex numbers is very interesting. And maybe we'll add like a, we should add a forum thread about complex numbers and put some videos there 'cause there's a lot of nice videos about kind of the intuition around this. So I just wanted to come to a question that Charles asked on the chat, which I think is an interesting and good one, which is, can you explain what your motivations are for investing your time in this?

What kind of real world applications are there? Where this being array programming and APL, I guess. So there's a number of, of reasons, not all of which are related to the second part of Charles's question, which is what are the real world applications of this? There certainly are some, at least indirectly, but I'd also say, yeah, it's not my only reason for being interested is not just real world applications, but I think first and foremost for me, math is quite beautiful.

I think it's like a field that can contain a lot of beauty in a very deep aesthetic way, but I'd also say it's an area that frustrates me. Math frustrates me because I find it very kind of inconsistent, and the notation is often very hard to look up, and it's also hard for me to understand what things mean in a very abstract way when I can't experiment with them.

So one thing for me is it helps me understand math. It also helps me teach math. So I'm teaching my daughter math, and there are things which I was finding difficult to teach her until I started teaching her with APL and NumPy. In particular, sequences in series was the first one where I just had no luck teaching her and her friend Gabe sequences in series.

I did a whole hour on it, then we made no progress at all, and then when we did it via learning first some NumPy and some APL and then coming back a week later and then it was easy to explain. So yeah, so one is, you know, I think a way into math, one is a way into teaching math.

Another is I think there's such beauty and power in notation. In our last study group we talked about the power of the notation that is regular expressions, for example. Now APL is a much deeper notation than regular expressions, but like notation, a powerful notation is a key thing used to further human intellectual development, you know?

And you'll see this repeatedly, particularly in mathematics, but also in other areas like physics, things that like just take hundreds of years for very smart people to advance, then somebody finds a notation for that thing and it powers ahead, so things like algebra, for example, dramatically, you know, impacted our ability to develop math.

The notation of numerals that includes the digit zero also dramatically improved our ability as a species to develop mathematics. But you know, other areas like juggling, you know, there was a development of a notation for juggling a few years ago and suddenly there was huge developments in what people were doing 'cause they were able to manipulate the notation and say like, oh, what if we move this over here?

Or you know, you start to create ways to manipulate the symbols in the notation to develop new ideas. So you know, APL is a very powerful notation, not just for math, but for a range of things that can be represented using the similar kind of concepts that we use in math.

For example, one guy has built a GPU compiler using APL and they did their PhD essentially in like APL as a notation for building compilers. So that would be another one. At a more pragmatic level, so I learned a little bit of J before I did any APL, but J is much the same thing.

Yeah, I definitely felt like learning J did more for my programming skills than any other language I've learned because APL as a notation was developed in the late 1950s and so it's been continually developed in the decades since and really quite a kind of independent branch to all the other computer languages.

So APL, JK, the array languages have their own little world. And so if you've not worked with languages from that branch, you miss out on that entire development of thinking. Now we'll say nowadays, numpy and derivatives of that have borrowed a lot of ideas from APL, but in a very kind of impure way.

So I would say also like for somebody doing deep learning and that kind of programming, scientific programming in Python, yeah, I think you'll discover better ways of thinking about these kind of loopless programming, particularly if you then look at things like Einstein notation or INOPS or stuff like that.

Does anybody else have any other kind of reasons that were interested in this or questions about that or anything else? - I guess for me, it's just a different way of thinking. I mean, I'm hoping that as the, I mean, it's always a case you get a big speed up if you can remove a loop and vectorize things and you don't really have a choice but to do that in APL for the most part.

So kind of get a lot better at doing that. - Yeah, yeah. I think also like it's an interesting path into other areas of math, particularly J. J comes with various labs. Which you can run on J. So J is like an APL derivative written by the original author of APL.

And yeah, it comes with all these labs, which are really interestingly kind of thoughtfully put together and basically take you through some pretty interesting mind bending ideas for mathematics. So maybe at some point we'll yeah, morph over to J and try out some labs. All right. So to wrap up today's thing, let's try to finish plus.

So yeah, so dyadic plus, move it up twice there. We've already done, not sharing the screen of course. I'm not sharing my screen 'cause I never remember. Okay, thanks Alex. Okay, so monadic plus is conjugate. So let's learn about that. So when I click on the specific monadic or dyadic version, right?

I'll get, so for example here, conjugate. It'll show me how it's used. And basically it shows that we start with a number y, we apply plus to it and the return value of it is something called r for result or return value. And then in the description, it's gonna tell me what each of these things are.

So it says here, if y is complex, then r the result is y with the imaginary part of all elements negated. If it's real or non-numeric, it's unchanged. So we should be able to view that here. So here, this is real. So the return value should be unchanged, it is.

Okay, this is imaginary, this is complex. The imaginary part is four. So here is the imaginary part negated. Okay, and here is another complex number and this is the imaginary part and here that is negated. So if you think about it on the number plane, conjugate flips just like negative does, but negative flips on the real plane, conjugate flips on the imaginary, sorry, negative flips on the real line, conjugate flips on the imaginary line.

Great. Well, I think we're done here. Does anybody have any questions, issues, anything else? Anything you wanna make sure we cover next time? Appreciate you guys joining. This is gonna be fun. What do we got, 21 participants, that's good. Yeah. - Yeah, I think this is gonna be a lot of fun as we keep going.

- Awesome. Yeah, so I think, you know, like we actually got through more than I expected, to be honest. And I do think we might be able to zip through the glyphs pretty quickly on the whole. I'm gonna assume that people like generally have some reasonable Python background, by the way.

And so sometimes we'll be relying on analogies to Python. And that should make things a bit faster as well. All right, I'm gonna, yeah, I'll pop the videos up on YouTube. I will create a playlist for them. And let's use the forum, yeah, for like, add anything you like, you know, feel free to create new topics about stuff related to array programming that aren't necessarily directly related to anything we've talked about, whatever.

This is all very informal. All right, bye all, thanks. - All righty, thank you everybody. - Thank you Jeremy, thank you everyone.