back to indexFast.ai APL study session 16
Chapters
0:0
28:52 Euler's Identity
59:41 Matrix Division
62:38 Lydia Algebra
00:00:00.000 |
where are you joining us from oh i'm here from uh Iran there right great yeah 00:00:27.360 |
4 30 in the morning oh wow well that's very impressive but it's good yeah really good 00:00:39.040 |
thanks for joining thank you for the session uh codes codes uh uh 67 mines from from capital yeah 00:00:50.080 |
well look at that only three of us lots of people watching the vietro videos but 00:00:57.040 |
not so many people joining us live i guess it's uh hard to maintain the consistency well thank 00:01:03.360 |
you first for joining um that's uh is there anything you wanted to talk about or should we 00:01:09.520 |
keep going oh uh yeah ask me uh both of you ah okay i think you were about to finish the 00:01:24.160 |
glyph yeah i think you finished the let's go have a look and then share my screen 00:01:31.920 |
um so i guess we're doing this one will we the rest 00:01:51.520 |
is this different to upshoe is this like a bigger version of it or something 00:01:57.920 |
oh it's up shoes that is up shoe yeah we've already done that right i think so yeah yeah 00:02:06.080 |
i think so i'm just going to type help just in case it's some weird different version of it 00:02:20.800 |
huh okay never mind um and have we definitely not done iota andaba 00:02:41.840 |
i guess if we did it would have been probably here 00:03:45.840 |
okay so i'm going to guess that it is shift i 00:04:07.520 |
all right we've already got row at this point so that's good 00:04:36.560 |
all right so um iota andaba i guess pretty clearly is showing us the locations of 00:05:01.840 |
and more than that it is replicating them the number of times according to what the number is 00:05:11.120 |
doesn't work on negative numbers doesn't work on floats 00:05:58.400 |
so anything else i should add or anything so it makes sense 00:06:31.200 |
we won't put it in our notebook but i'm sure we try to figure out if we can figure out what this is 00:06:42.160 |
iota row omega oh okay so just the index of that oh why is x here hi isak i see so iota 00:07:12.880 |
is the indices that were with yeah correspond to that to that array 00:07:22.880 |
and okay so um that's our input that's a function that's a function function operator 00:07:42.400 |
that's a function that's a function so this is a fork with three functions does that sound right 00:07:56.160 |
i'm right hooray so we go row of this and then we go 00:08:07.440 |
slash over comma now there's no reason to use over right because it's monadic so we 00:08:18.160 |
could just use jot and get the same thing yes um so first 00:08:53.440 |
i guess this is in case it's like a scalar or something 00:08:58.160 |
okay and then can anyone remember what slash does 00:09:09.200 |
set the replicate i guess that's the monadic right uh over do 00:09:24.640 |
wait uh wait how is this working because monadic slash is not defined 00:10:06.880 |
oh no no no it's dyadic because there's a omega here okay so it's dyadic 00:10:34.640 |
applies the outside functions to both outside arguments 00:10:38.320 |
here yep so this is a dyadic fork and it applies the outside functions to both outside arguments 00:10:56.880 |
so are they just recreating the monadic iota underbar um let's see so this is going to be oh i see 00:11:20.240 |
um so the reason this works is that slash means replicate and 00:11:29.280 |
the left hand side tells me how many things times to replicate the right hand side 00:11:44.320 |
okay so there's a mega slash omega so that's doing the replicate 00:11:53.120 |
and then you've got row of omega as we discussed 00:12:51.600 |
this row is applied to the left down the right 00:13:14.960 |
no so i can put parentheses here right no okay so i'm pausing it wrong oh i'm pausing it wrong 00:13:29.120 |
because of the omegas this is not in parentheses it's not a fork so i'm totally wrong 00:13:36.480 |
um so we actually have to be careful about precedence here without parentheses it's 00:13:42.480 |
going to be there's actually no operators in this version so we uh bind most tightly on the on the 00:13:49.360 |
right so this is actually simply going to be row of omega which is four and then iota which is one 00:13:56.400 |
two three four so it's just going to be that which does give us the answer 00:15:12.640 |
i think we'll line in the docs to say this is how you can define iota underbar 00:15:19.280 |
we've made that a bit faster but i guess it'd be less fun okay yeah 00:15:38.820 |
thank you for your fast cable stuff by the way is that okay 00:15:46.400 |
it was something i wanted for myself i think a lot of people are going to find it really useful 00:15:53.360 |
yeah i hope so i'm i'm right now trying to fight with github actions and trying to get it scheduled 00:16:05.040 |
run update if any of the libraries are if any of the libraries are 00:16:09.280 |
great idea not the latest it'll just update them and then i can 00:16:13.920 |
have a big repository that people can just point to so you don't have to upload their own 00:16:21.760 |
unless they want to now this one i remember doing with claire it's a bit of an odd one 00:17:28.720 |
what's it doing okay so the number of results is the same as the number on the right hand side 00:17:43.520 |
let's start with a numeric one because i think i know this one so what the two four six does 00:18:01.200 |
is it creates a number of groups the first group it creates is less than two and then two to less 00:18:09.520 |
than four and then four to less than six and then greater than or equal to six and so less than two 00:18:19.920 |
will become zero two to less than four will become one four two less than six will become two greater 00:18:32.080 |
than or equal to six will become three so that's why one is less than two so it becomes zero two is 00:18:42.560 |
two less than four so it becomes one and so forth so just tell to these to find break points 00:18:51.840 |
and then it just applies these to those break points and gives you the results 00:18:58.880 |
but be very careful because it's a bit weird that it starts at zero instead of one 00:19:04.160 |
which when i asked about this on the APL discord Marshall Lockburn told me he considers this an 00:19:13.520 |
off by one error in APL although somebody else pointed out it does have some convenient properties 00:19:19.760 |
so you can think of it as like the group number one is the bit defined by 00:19:27.360 |
when you actually get greater than or equal to two so zero is like less than the minimum value 00:19:36.640 |
okay so this is exactly the same thing that for letters these letters are in alphabetical order 00:19:45.360 |
so d is between a and e so it's one y is later than u so it's five 00:20:39.440 |
okay so this is one of these ones with broadcasting built-in 00:21:20.320 |
and it compares subarrays in y which is the right argument 00:22:02.400 |
what are subarrays of this i guess three three is a subarray 00:22:13.200 |
so it's not broadcasting length just three or three three three would give errors right 00:22:39.040 |
yeah so it's this is subarray one i guess this is subarray two so this is the same as as 00:22:46.720 |
this result concatenated with this result how does it decide that three three is one i guess 00:22:54.560 |
it's looking through here to find like a row that contains what exactly would zero three 00:23:03.280 |
give you the same result no i think it's like it's trying to it's basically like looking for 00:23:12.720 |
the first okay i think the issue is um it's it's it's comparing column one and then column two 00:23:24.000 |
and column two would only matter if there was a tie so i think if we went um 00:23:46.080 |
so three three is not bigger than three four three four is but then three five is higher still 00:24:00.160 |
oh greater than or equal to is always going to be there 00:24:05.840 |
yeah so it's saying uh what row which would this slot into by first of all making sure that it's 00:24:14.560 |
greater than or equal to the first column and greater than or equal to the second column so 00:24:19.600 |
this one would have to go here because the second is not greater than or equal to 00:24:24.480 |
but if either of them are greater than the second then it would slot them after right yeah which i 00:24:31.360 |
think is i think it's exactly the same as doing 12 34 35 all right that's basically the same thing right 00:25:28.020 |
and if you want to learn more about this they've got quite extensive examples 00:25:31.540 |
which i suspect means that this is fairly important 00:25:34.740 |
i guess in you know anytime you're trying to place a continuous number into a bunch of buckets 00:25:56.820 |
molly you're very quiet i can't quite hear you probably 00:26:01.540 |
oh uh yeah my mic was long ways away uh histograms yeah yeah 00:26:08.820 |
circle okay i wonder if circle should go in the basic math section 00:26:23.060 |
i kind of mentioned we're going to need other stuff much 00:26:31.700 |
a bit of a big topic i guess circle functions 00:26:58.820 |
write circle hey yeah just remembered i've actually installed the 00:27:08.820 |
oh i guess it's useful to see what button to press anyway okay so it's 00:27:28.740 |
auto which i guess is just called circle yep circle 00:27:51.220 |
i times so i guess that means we could just go 00:27:57.380 |
one at circle one and can we do like that yeah okay seems easy enough 00:28:54.500 |
although at this point we haven't done any kind of 00:29:09.780 |
trainee thing so maybe we should do that in two steps 00:30:27.780 |
it doesn't sound weird so this is pi i this is pi i 00:31:03.380 |
oh i see it's minus one plus 10 to the negative 16 00:31:21.700 |
i which is basically zero so i think what's happened is um i guess is that uh 00:31:29.300 |
this is special case or something in APL dialogue APL to remove the annoying floating point 00:31:38.260 |
residue leftover bit here basically this is close enough to zero i 00:31:43.300 |
for some reason when we do it all in one go it's 00:31:49.620 |
gets it exactly right all right well maybe we won't show that then 00:32:16.900 |
yeah there isn't really a short way to do this so i'm inclined to just provide a link 00:32:40.580 |
to this one right here so i'm going to just give you a quick example of what we're going to do. 00:33:25.700 |
put something on the left and whatever you put on the left to find what function you get 00:35:20.280 |
oh I guess it's but well no okay that makes sense so if we do pi 00:36:15.400 |
because you kind of I was expecting four results I was expecting sine and cos because 00:36:57.560 |
so why do you so what do the two numbers mean 00:37:06.520 |
I I think you're applying each function to each of the er sorry 00:37:16.280 |
each straight function to each of the ones and the right side I need a better vocabulary 00:37:40.840 |
oh right that's exactly what happens by default in APL right is a scalar broadcasts over an array 00:37:49.000 |
but if they're both arrays then they just broadcast to each other yes yes yes you're exactly right 00:38:20.680 |
okay element of we should put with our kind of set related stuff which I guess is where 00:39:02.760 |
means enlist because ml for us is one I remember 00:40:38.680 |
so what it's doing is it's got zero that's got a matrix from one to six 00:40:43.080 |
that's got a array with seven and eight that's got a scalar nine and it just uh flattens them 00:40:49.400 |
and sticks them all together flatten and concatenate I wonder if that does that for 00:41:21.080 |
yeah so this is two by three but this is a single this is oh sorry and then this is 00:41:35.080 |
ranks this is a shape three so I guess this is um doing the broadcasting thing kind of it's 00:42:33.240 |
but yeah this last one's interesting in that it's uh combining these different shapes 00:42:52.200 |
we've ended up with less ones than we started with right 00:43:04.760 |
oh no uh wait am I doing this right okay now I'm reading it wrong so actually yeah sorry 00:43:22.760 |
I forgot I got confused by the precedence yeah so even though there's no space there 00:43:30.200 |
we have to remember this is actually that right okay yeah so it's just flattening it out so it's 00:43:50.680 |
yeah so you've got to be careful to remember that although it prints this like a word nine it's 00:45:01.880 |
is it an okay so is a b c an element of this set no it's not is for an element of this set 00:45:25.080 |
each element of the matrix an element of this set and it puts them in the same order so 00:45:33.880 |
one is not an element two is an element three is not an element so forth 00:45:41.880 |
makes sense so if you if you kind of reversed that and did um like one two three epsilon matt 00:45:50.840 |
would it be searching like the major cells of if matt was on the um the right hand side 00:45:58.680 |
yeah so it's saying okay so still looking cell-wise it's not looking at major cells 00:46:08.840 |
saying is six anywhere in that matrix i think yeah two anywhere in the matrix 00:46:17.000 |
yeah exactly so i think the right the the rank of the right hand side seems totally meaningless 00:46:35.960 |
i i also tried with two matrices and got the same behavior that you would expect there cool 00:48:02.840 |
is b and um a and a is a and a is and i think it's going okay wait no because n is in both 00:48:18.840 |
and that would be zero and that's zero so it should be so i was wrong 00:48:31.080 |
yeah worked for the first two it finds occurrences of x within y 00:49:02.600 |
okay and we're going to try to give the easy examples 00:50:16.600 |
is four by four oh one oh one one oh oh one oh i see 00:51:12.760 |
all right oh i see so it's finding where is like this oh where is this like one one diagonal 00:51:24.680 |
and you can find it here here and here since there are the ones okay 00:51:40.360 |
makes sense yeah i think the the apl wiki seems to have a kind of a 00:51:53.880 |
the inquiry maybe you guys already talked about that i've been i've been in and out of the 00:52:32.680 |
why is there an n here is that actually the little n 00:52:42.040 |
oh no let's see the other shoe on that one and children we've done 00:52:52.680 |
this first two might go under the math i think might go in math yeah i think there's the circle 00:53:00.280 |
star is um log and natural log and the domino looking thing is matrix division and matrix 00:53:08.280 |
inversion i think okay matrix we're going to have to do after we've done rank certainly log we can do 00:54:43.800 |
i think rather than writing that i'd rather write 00:55:45.720 |
but i'll write them down and then we can put them somewhere 00:56:13.000 |
or anybody i believe it's um the um plus so it's the same as division but with the shift key i think 00:56:25.160 |
that one um i think so that doesn't quite look right does it uh that was sorry is that sorry 00:56:37.880 |
that was alt shift slash uh alt shift plus or oh sorry cool 00:57:03.400 |
is there some way to get a good what's a good easy way to get an identity matrix 00:58:21.240 |
here was um i'll put in the chat when my identity function was why is this not working 00:58:27.880 |
have i got it the wrong way around i think i do actually yes 00:58:37.560 |
oh there's a few things happening in the chat i noticed 00:58:53.480 |
i guess it's fine anyway we can see easily enough it's 00:59:39.080 |
i'm not really sure what matrix division means 01:00:37.720 |
okay i haven't quite heard that expression matrix division before but it makes sense 01:00:50.600 |
it's just the opposite of matrix modification 01:00:58.760 |
oh cool the pseudoinverses as well if there's more rows and columns the least squares result 01:01:17.720 |
so i think that's just what's called the pseudo inverse 01:01:19.560 |
it's neat okay linear regression on complex numbers why not 01:01:50.280 |
i thought we've done dot or if we already done it in 01:01:57.160 |
this one situation what do we not do it at all 01:02:02.200 |
i'm not sure we've done it um no that's bad because i've definitely referred to it 01:02:15.560 |
um yeah i think we talked about it a bit um okay well let's pop it underneath a ray 01:05:43.180 |
okay so this is a dot product one times four plus two times five plus three times six 01:06:08.620 |
so this is um and isn't it so this is three equals three and three equals three and three 01:06:15.660 |
equals three and three equals three if i did this would be zero 01:07:34.620 |
let's see i'm reading my own blog post trying to figure out what it means so 01:07:48.380 |
well let's maybe just put it in the forums right after we do it 01:08:10.220 |
and so then they had uh oh yeah then they got a special case 01:08:29.420 |
actually didn't we do that in the competition thing 01:08:51.100 |
because we were doing that oh or maybe we just played with it but we 01:08:56.860 |
i remember we talked about outer product for that gene example 01:09:06.780 |
but um yeah i think i messed it up and didn't quite get it working so that's fine 01:09:17.580 |
all right i think that's it thanks all good to see you