PodSearch

Under the Radar

185: Advanced Math

 

00:00:00 ◼   ► Welcome to Under the Radar,

00:00:01 ◼   ► a show about independent iOS app development.

00:00:04 ◼   ► I'm Marco Arment.

00:00:05 ◼   ► - And I'm David Smith.

00:00:06 ◼   ► Under the Radar is never longer than 30 minutes,

00:00:08 ◼   ► so let's get started.

00:00:09 ◼   ► - So Dave, I don't know about you,

00:00:11 ◼   ► but in school, I was really good at math,

00:00:14 ◼   ► only up to a certain point.

00:00:18 ◼   ► Maybe like middle of high school.

00:00:20 ◼   ► Once we started getting into more advanced math topics,

00:00:24 ◼   ► like I think for me the boundary was calculus.

00:00:27 ◼   ► I didn't take calculus till college,

00:00:28 ◼   ► and I was terrible at it, and I failed it twice,

00:00:32 ◼   ► and never went and retook it,

00:00:33 ◼   ► and never really learned calculus.

00:00:35 ◼   ► I failed linear algebra also twice,

00:00:37 ◼   ► doing advanced matrix operations and stuff like that,

00:00:40 ◼   ► and never retook that, never fixed that.

00:00:44 ◼   ► Anything involving really advanced calculations like that,

00:00:47 ◼   ► that wasn't just basically combinations of basic,

00:00:51 ◼   ► the basic four calculator operations,

00:00:53 ◼   ► or stuff like that.

00:00:55 ◼   ► I was very bad at, or never learned,

00:00:58 ◼   ► or tried to learn and failed at.

00:01:00 ◼   ► And yet we work in a field where our tools

00:01:04 ◼   ► are super fast math machines that do what we tell them to,

00:01:08 ◼   ► and that we often need math for.

00:01:12 ◼   ► And I think it's funny that a lot of programming

00:01:15 ◼   ► does indeed need math, but it's mostly the simpler math

00:01:19 ◼   ► that I was really good at already.

00:01:20 ◼   ► It's mostly elementary, middle, and maybe high school math.

00:01:24 ◼   ► But it's not, most programmers don't have to do things

00:01:27 ◼   ► like calculus or linear algebra, or theory proofs

00:01:31 ◼   ► and everything like that in their regular work,

00:01:33 ◼   ► or any of their work really.

00:01:34 ◼   ► I think those are specialties.

00:01:36 ◼   ► But I do occasionally run into some need

00:01:39 ◼   ► for a better understanding of math than what I have.

00:01:45 ◼   ► And I'm curious, does this happen to you too,

00:01:48 ◼   ► and how do you solve it?

00:01:50 ◼   ► - Yes, so A, it happens all the time.

00:01:53 ◼   ► And it is like one of the,

00:01:56 ◼   ► it's almost like a running joke in my house,

00:01:57 ◼   ► where all of a sudden, it's sort of like a scene

00:01:59 ◼   ► out of Beautiful Mind, and my desk just becomes

00:02:01 ◼   ► just strewn with papers, filled with scrawled formulas

00:02:05 ◼   ► all over the place, because I'm not particularly,

00:02:08 ◼   ► yeah, I had a similar experience with math.

00:02:10 ◼   ► I can do, through Algebra II trig,

00:02:13 ◼   ► was sort of like, I think I took,

00:02:17 ◼   ► that was the last level of math where,

00:02:20 ◼   ► and I feel like that's the level of where math

00:02:22 ◼   ► is still intuitive to some degree,

00:02:25 ◼   ► but it's based on tangible, understandable things,

00:02:29 ◼   ► in a way that like addition, when you teach it to a child,

00:02:32 ◼   ► is like, I have one apple, and I get another apple,

00:02:36 ◼   ► how many apples do I have?

00:02:37 ◼   ► It's like, well, you have two.

00:02:39 ◼   ► And there's an intuitive and like a,

00:02:42 ◼   ► something concrete that you can wrap your head around.

00:02:44 ◼   ► And then you get to a certain point in math,

00:02:46 ◼   ► and it stops being that.

00:02:49 ◼   ► And it becomes this much more abstract,

00:02:53 ◼   ► sort of theoretical thing that I can sort of understand,

00:02:57 ◼   ► that in calculus, what you're doing is you're calculating

00:03:00 ◼   ► the area under a curve, or the slope of a line.

00:03:04 ◼   ► That is fundamentally what most of calculus is doing.

00:03:08 ◼   ► But just knowing that that's functionally what you're doing,

00:03:12 ◼   ► actually how you go about doing that,

00:03:15 ◼   ► very quickly becomes this totally abstract concept,

00:03:19 ◼   ► where how do you know what the slope of a sine curve is?

00:03:22 ◼   ► And it's like, well, that's like through deep magic.

00:03:26 ◼   ► I don't know.

00:03:26 ◼   ► All I learned at a certain point was that

00:03:29 ◼   ► this is the formula, and I can apply this formula,

00:03:32 ◼   ► and I can get the right answer.

00:03:33 ◼   ► But I never had a intuitive understanding

00:03:36 ◼   ► of anything beyond, yeah, that's sort of like

00:03:38 ◼   ► that algebra two trig area.

00:03:40 ◼   ► Like trigonometry is where it starts to kind of,

00:03:43 ◼   ► I'm hitting the limit where I understand that I'm like,

00:03:46 ◼   ► the ratio between two lengths of a triangle,

00:03:51 ◼   ► that that ratio is related to the angle of the corner,

00:03:54 ◼   ► and things like that.

00:03:55 ◼   ► Like it's sort of concrete and sort of understandable,

00:03:58 ◼   ► but beyond that, it kind of falls apart.

00:04:00 ◼   ► But this happens all the time.

00:04:03 ◼   ► And I feel like often what is most kind of frustrating

00:04:07 ◼   ► is that this math shows up in places where you can,

00:04:12 ◼   ► it's like at this boundary between a feature being

00:04:15 ◼   ► like all right, and a feature being really cool.

00:04:18 ◼   ► Like there's this, if you wanted the extra flourish,

00:04:20 ◼   ► if you wanted to be that little bit cooler,

00:04:22 ◼   ► or do a little bit, like something a little bit fancier,

00:04:25 ◼   ► is where the math starts to show up.

00:04:27 ◼   ► Where the straightforward way is, you see,

00:04:31 ◼   ► it's like that's when you're dealing with just like

00:04:32 ◼   ► simple rectangles and moving them around

00:04:35 ◼   ► in straightforward way.

00:04:36 ◼   ► But if you want to have like a cool curve

00:04:38 ◼   ► when you're doing an animation,

00:04:39 ◼   ► or you want to make the shape of something

00:04:41 ◼   ► not just be plain, but be sort of advanced,

00:04:46 ◼   ► or even moreover what I've been running into

00:04:49 ◼   ► a lot recently in my work is,

00:04:51 ◼   ► there's a naive solution to a problem,

00:04:54 ◼   ► and then there's the accurate solution to the problem.

00:04:58 ◼   ► And the naive solution is really straightforward

00:05:00 ◼   ► and easy to work with.

00:05:02 ◼   ► But the actual solution that is like sort of correct

00:05:05 ◼   ► in physics or correct in detail is where all of a sudden

00:05:09 ◼   ► now I need to pull out all of the math

00:05:11 ◼   ► and go and spend a lot of time just like researching online.

00:05:15 ◼   ► And a lot of it is the unfortunate kind of research

00:05:17 ◼   ► where I feel like I solve this problem a lot

00:05:20 ◼   ► by trying to find, learn just enough

00:05:23 ◼   ► that I can find the right formula

00:05:25 ◼   ► that I can apply and get the right answer,

00:05:27 ◼   ► even if I don't understand what I'm doing.

00:05:30 ◼   ► Like there's a ton of the math that I was using

00:05:32 ◼   ► for like my moon project where it's like,

00:05:35 ◼   ► I don't understand, I have no idea why

00:05:38 ◼   ► like this equation gives me the, you know,

00:05:40 ◼   ► the longitude of the moon right now.

00:05:43 ◼   ► But it does.

00:05:44 ◼   ► And it works.

00:05:45 ◼   ► And once I can like, I'm just like empirically verifying it

00:05:48 ◼   ► and then going like finding, you know, the NASA table

00:05:51 ◼   ► where it's like, you know, I can get a table

00:05:53 ◼   ► that forecasts the values of certain things

00:05:55 ◼   ► over different times.

00:05:56 ◼   ► My values match their values like plus or minus

00:05:59 ◼   ► a small error percent, and then I'm good.

00:06:01 ◼   ► And I don't need to understand why the formula works

00:06:04 ◼   ► or what's going on necessarily, but like that is,

00:06:06 ◼   ► that is a situation that has happened

00:06:08 ◼   ► so often to me recently.

00:06:10 ◼   ► - Yeah, it happens to me probably every few months

00:06:13 ◼   ► where I will be tackling a feature

00:06:15 ◼   ► or trying to figure out, you know, some weird edge case

00:06:18 ◼   ► or something where I will quickly realize like,

00:06:21 ◼   ► you know what, I could use more advanced mathematical

00:06:24 ◼   ► knowledge than what I have to solve this.

00:06:25 ◼   ► Or I need more advanced knowledge to solve this.

00:06:28 ◼   ► And for me, like you know, like another big hole

00:06:29 ◼   ► in my knowledge is most kind of advanced stats

00:06:33 ◼   ► and like data analysis.

00:06:35 ◼   ► Like I can't do like data mining.

00:06:37 ◼   ► I still don't understand machine learning at all.

00:06:40 ◼   ► And I'm almost, I haven't really tried it,

00:06:43 ◼   ► but you know, there's huge areas of that

00:06:45 ◼   ► where I feel like I either have fallen behind

00:06:48 ◼   ► or was never even in the race that I probably

00:06:51 ◼   ► should familiarize myself with.

00:06:53 ◼   ► But even, you know, basic stuff like if I'm trying

00:06:55 ◼   ► to figure out a pattern in a bunch of data I have,

00:06:58 ◼   ► and I'm trying to figure out like yeah,

00:06:59 ◼   ► I can calculate like the average and stuff.

00:07:01 ◼   ► But if I try to go beyond that, to be like all right,

00:07:04 ◼   ► what if I like, you know, try to find clusters

00:07:06 ◼   ► of meaningful data or I try to find, try to, you know,

00:07:09 ◼   ► rule out the outliers and you know, focus only

00:07:12 ◼   ► on the middle, like that's all like much more

00:07:15 ◼   ► advanced math than anything I ever actually

00:07:17 ◼   ► officially learned.

00:07:18 ◼   ► And sometimes you can take advantage of libraries

00:07:21 ◼   ► or functions or formulas you can find online

00:07:23 ◼   ► to do it for you.

00:07:25 ◼   ► Sometimes you just kind of fudge it and you kind of like,

00:07:27 ◼   ► all right, well, I guess I'll figure out how to do this

00:07:30 ◼   ► myself with the knowledge I have without actually

00:07:33 ◼   ► looking up the right way to do it.

00:07:35 ◼   ► And sometimes you can get an approximate solution

00:07:36 ◼   ► that kind of works.

00:07:37 ◼   ► Sometimes you accidentally come upon the actual solution

00:07:40 ◼   ► without even realizing it, although that's less common.

00:07:43 ◼   ► And I find that like a lot of times the kind of like

00:07:48 ◼   ► half fake hack solution that you kind of stumble upon

00:07:52 ◼   ► by doing it naively is often good enough

00:07:55 ◼   ► and is often fast enough.

00:07:56 ◼   ► And in fact, there's lots of methods that you can find

00:08:00 ◼   ► online of like, of you know, major apps or especially games.

00:08:03 ◼   ► Games often take a lot of shortcuts for performance

00:08:06 ◼   ► where they did some kind of rough approximation

00:08:09 ◼   ► of something and that proved to be good enough

00:08:13 ◼   ► or close enough for their purposes.

00:08:15 ◼   ► And that saved them either from having to know

00:08:19 ◼   ► a more advanced version or saved the computing time

00:08:21 ◼   ► of the computer having to do a more advanced version.

00:08:24 ◼   ► - Yeah, and that good enough is such a, like,

00:08:26 ◼   ► I feel like in weird ways, like, 'cause part of me

00:08:30 ◼   ► as a developer, I enjoy solving like the hard problem

00:08:33 ◼   ► and doing it well.

00:08:34 ◼   ► Like, that's part of what I like doing.

00:08:37 ◼   ► But it's so often the, like, is this, it's like the increase

00:08:41 ◼   ► in effort to have the correct answer versus a close answer

00:08:45 ◼   ► is, you know, is wildly disproportionate.

00:08:50 ◼   ► Like I was thinking recently, I was doing a thing.

00:08:52 ◼   ► So I, you know, I had, if you imagine you're trying to show

00:08:55 ◼   ► the color and associate it with a temperature, you know,

00:08:58 ◼   ► so this is for like a weather display.

00:09:00 ◼   ► Like in some ways, like the first version of this that I did

00:09:04 ◼   ► was a, like I just did the super naive version

00:09:07 ◼   ► where if you take the hue of like, you know,

00:09:10 ◼   ► it starts like a hue zero or in, you know, in UI color.

00:09:15 ◼   ► And that's red.

00:09:18 ◼   ► And if you go up to about like 220-ish, that's like blue.

00:09:23 ◼   ► And in between it goes like red, orange, yellow, green

00:09:27 ◼   ► to blue, like it's, you know, sort of as you would expect.

00:09:29 ◼   ► And the super simple version I did initially was just like,

00:09:32 ◼   ► well, I'll take like the temperature in,

00:09:36 ◼   ► and say I do it like in Fahrenheit from zero to 120,

00:09:40 ◼   ► work out like what percent of that is,

00:09:42 ◼   ► and then just like map that onto the hue.

00:09:44 ◼   ► And so when it's really hot, it'll be, you know, red.

00:09:47 ◼   ► And then when it's really cold, it'll be really blue.

00:09:50 ◼   ► And like that sort of works.

00:09:51 ◼   ► But then I started, you start to get like,

00:09:53 ◼   ► well, what if I wanted to make it a little bit like,

00:09:55 ◼   ► like have a more consistent visual appearance to it

00:09:59 ◼   ► or have a more, like a thoughtful,

00:10:02 ◼   ► or like I could have different points along the way.

00:10:05 ◼   ► Well, then I need to start to be getting

00:10:06 ◼   ► into like color blending.

00:10:07 ◼   ► And color blending is this whole crazy,

00:10:10 ◼   ► like you see one of these things,

00:10:11 ◼   ► like you open the first box,

00:10:13 ◼   ► like you pick the book off the shelf that says color blending

00:10:16 ◼   ► and you're like, oh, that's interesting.

00:10:17 ◼   ► And you can just like, the first version is just do like,

00:10:19 ◼   ► you know, I pick the points along the curve

00:10:21 ◼   ► that I want the colors to be,

00:10:23 ◼   ► and then I'll just do like a linear interpolation

00:10:24 ◼   ► between like the RGB values at each point,

00:10:27 ◼   ► which like mostly works.

00:10:30 ◼   ► But then you can have these weird like middle,

00:10:31 ◼   ► mid points in between your interpolations

00:10:33 ◼   ► where like the color isn't really what you want,

00:10:35 ◼   ► but that is like the color that you just asked for,

00:10:38 ◼   ► where you were, what you really start to get into,

00:10:40 ◼   ► like then you get into like color perception

00:10:42 ◼   ► and how people are sensitive to different colors

00:10:44 ◼   ► at different intensities.

00:10:47 ◼   ► So, so like a yellow and a blue and a red,

00:10:51 ◼   ► like at a constant hue, if you keep the saturation

00:10:54 ◼   ► and like the brightness the same,

00:10:56 ◼   ► like one of them will look darker than the other.

00:10:58 ◼   ► And so you can end up with these weird cases

00:11:00 ◼   ► where if you're just blending between them,

00:11:02 ◼   ► like it looks as though the color is getting like brighter

00:11:04 ◼   ► and darker in weird and uncomfortable ways.

00:11:08 ◼   ► And that's because of the way people perceive color.

00:11:11 ◼   ► That is, you know, way,

00:11:13 ◼   ► all of a sudden you're starting to get like,

00:11:14 ◼   ► even beyond math, you're starting to get into like biology

00:11:16 ◼   ► and the way that the rods and cones in your eyes work.

00:11:19 ◼   ► And it's like, at a certain point, it's like, okay,

00:11:21 ◼   ► I'm just gonna close this book

00:11:23 ◼   ► and I'm gonna start with the simple version again,

00:11:26 ◼   ► because the effort to get it perceptually correct

00:11:29 ◼   ► has probably now over, like exceeded the actual increase

00:11:33 ◼   ► in quality that I would get by opening up this math.

00:11:36 ◼   ► And like, that's an example where like,

00:11:37 ◼   ► I ended up going with a fairly simple version

00:11:40 ◼   ► that kind of mostly works

00:11:41 ◼   ► and doesn't deal with all the weird image perception issues,

00:11:44 ◼   ► but gives me a pretty good answer

00:11:46 ◼   ► that looks pretty good most of the time.

00:11:49 ◼   ► And it's like, okay.

00:11:50 ◼   ► Or you can do the other classic thing where in programming,

00:11:53 ◼   ► where I find like I often will take,

00:11:55 ◼   ► like there's a weird place that my 80% solution works,

00:12:00 ◼   ► but except for like in this, you know,

00:12:01 ◼   ► in this temperature case,

00:12:02 ◼   ► it's like except for between 60 and 70 degrees,

00:12:06 ◼   ► my color looks wrong.

00:12:07 ◼   ► And so I just like have an if statement

00:12:09 ◼   ► that if the temperature is between 60 and 70,

00:12:12 ◼   ► change it in this way.

00:12:13 ◼   ► That's not like mathematically correct.

00:12:15 ◼   ► It's not like this beautiful, smooth curve.

00:12:17 ◼   ► And if you really look closely between like, you know,

00:12:19 ◼   ► this like one degree, one way, one degree the other,

00:12:22 ◼   ► you can notice this, you know, discontinuity in the curve.

00:12:25 ◼   ► It's like, you know, like you could,

00:12:27 ◼   ► but I only ever display like one color

00:12:29 ◼   ► on the screen at a time, so you know, it's probably fine.

00:12:33 ◼   ► And like that's this kind of,

00:12:34 ◼   ► this place where you find where you're trying to like,

00:12:36 ◼   ► where on this math spectrum do I actually wanna be?

00:12:39 ◼   ► Like do I wanna go like go crazy down the rabbit hole

00:12:43 ◼   ► and then come up on the other side

00:12:44 ◼   ► with this perfect solution that is like technically correct?

00:12:48 ◼   ► Or do I want something that's, you know,

00:12:49 ◼   ► mostly good and looks fine?

00:12:52 ◼   ► - I mean, and you know, an example like that,

00:12:54 ◼   ► like you could even do something even dumber and simpler,

00:12:57 ◼   ► you just have a lookup table

00:12:58 ◼   ► for like integer temperature values.

00:13:00 ◼   ► Because does it really matter

00:13:02 ◼   ► if you have a slightly different color

00:13:05 ◼   ► for 60 degrees versus 60.5 degrees?

00:13:08 ◼   ► - Sure.

00:13:09 ◼   ► - Like it probably doesn't matter that much.

00:13:10 ◼   ► I bet nobody would ever notice.

00:13:12 ◼   ► And so you could actually just like run the basic formula,

00:13:15 ◼   ► get the colors, map them to a lookup table

00:13:17 ◼   ► for each temperature scale, and then just look at it

00:13:19 ◼   ► and say like, which of these look wrong?

00:13:20 ◼   ► And then just manually adjust the ones

00:13:22 ◼   ► like for those buckets.

00:13:24 ◼   ► And it would be a heck of a lot faster in performance.

00:13:26 ◼   ► It wouldn't really cost you much memory.

00:13:28 ◼   ► And it would actually be a reasonable solution

00:13:31 ◼   ► to that problem since in this particular application,

00:13:34 ◼   ► you don't need a smooth blending between intervals.

00:13:38 ◼   ► Because no one is dragging a slider around,

00:13:41 ◼   ► adjusting the temperature in a smooth floating point domain

00:13:45 ◼   ► and making it so that they have to see

00:13:47 ◼   ► these nice little gradients going.

00:13:49 ◼   ► And like you actually could do

00:13:50 ◼   ► something even simpler than that.

00:13:52 ◼   ► I feel like there's a lot of cases like that

00:13:54 ◼   ► where we have opportunities for simplification

00:13:58 ◼   ► or optimization like that that we don't think about

00:14:01 ◼   ► 'cause we want like the theoretically best solution.

00:14:03 ◼   ► Like this function, it won't work for floating point values

00:14:08 ◼   ► in this certain range here.

00:14:09 ◼   ► But it's like okay, well do you ever have those?

00:14:11 ◼   ► Or does it matter if you just round those

00:14:13 ◼   ► to the nearest integer first and then do the operation?

00:14:15 ◼   ► And in a whole bunch of applications,

00:14:17 ◼   ► the answer is no, it doesn't matter.

00:14:18 ◼   ► Just make it work for what you will ever actually see.

00:14:23 ◼   ► And if it doesn't quite look right

00:14:24 ◼   ► or doesn't quite draw right for these really weird edge cases

00:14:28 ◼   ► that literally your app will never, it should never happen,

00:14:31 ◼   ► it doesn't really matter

00:14:32 ◼   ► whether it was theoretically right or not.

00:14:34 ◼   ► - Yeah, and the lookup table example I think is a great one.

00:14:36 ◼   ► Like I also, it makes me think of,

00:14:38 ◼   ► with all my moon calculations,

00:14:40 ◼   ► at one point what I was trying to do

00:14:42 ◼   ► is show the timing of the new and full moons in the app.

00:14:48 ◼   ► So you can say like essentially jump,

00:14:50 ◼   ► but you can kind of jump forward in time

00:14:52 ◼   ► and know like when is the actual next full moon gonna occur?

00:14:56 ◼   ► And I went down the rabbit hole of trying to work out

00:14:58 ◼   ► like how do you calculate that?

00:15:00 ◼   ► And it turns out it is just like, it's not even a book.

00:15:03 ◼   ► It's like a collection of books and 17 people's lives

00:15:07 ◼   ► to try and understand how you calculate when this is.

00:15:11 ◼   ► And I go down this road for like maybe half a day.

00:15:13 ◼   ► And in the end, I just like realize,

00:15:16 ◼   ► okay, NASA has published a list of the full and new moon

00:15:21 ◼   ► for the next hundred years.

00:15:24 ◼   ► I'll grab like 10 years of those

00:15:25 ◼   ► and just take the number that NASA has calculated

00:15:28 ◼   ► and just hard code it in the app.

00:15:30 ◼   ► And if I wanna know when the next one is,

00:15:31 ◼   ► I'll just see like when's the next,

00:15:32 ◼   ► when's the one greater than my current one?

00:15:35 ◼   ► And I just have, I think I go 10 years into the future

00:15:38 ◼   ► and it's like, well, in 10 years,

00:15:39 ◼   ► the app will stop working in that particular way.

00:15:41 ◼   ► And either I will have fixed it and extended it

00:15:44 ◼   ► or the app won't exist or I won't care.

00:15:46 ◼   ► And like that, like, or similarly,

00:15:50 ◼   ► I did the same thing for like lunar eclipses,

00:15:52 ◼   ► which is like something like,

00:15:53 ◼   ► it worked out well in that particular case

00:15:55 ◼   ► 'cause like lunar eclipses, there aren't one for a while,

00:15:57 ◼   ► so I don't need to worry about that particular feature.

00:15:59 ◼   ► But when it does become our niche,

00:16:00 ◼   ► I'll just hard code the values

00:16:01 ◼   ► because I know when they're supposed to happen.

00:16:03 ◼   ► Rather than like trying to calculate

00:16:06 ◼   ► based on your current coordinate,

00:16:08 ◼   ► what the, when you would perceive one,

00:16:09 ◼   ► which is like a theoretically possible math problem.

00:16:13 ◼   ► But like just hard coding the value, that worked just as well.

00:16:16 ◼   ► - We are sponsored this week by Linode.

00:16:18 ◼   ► Whether you're working on a personal project

00:16:19 ◼   ► or managing your enterprise's entire infrastructure,

00:16:21 ◼   ► Linode has the pricing, support, and scale you need

00:16:24 ◼   ► to take your project to the next level.

00:16:26 ◼   ► They have 11 data centers worldwide,

00:16:28 ◼   ► including their newest data center in Sydney, Australia.

00:16:31 ◼   ► With their enterprise-grade hardware,

00:16:32 ◼   ► S3-compatible storage option,

00:16:34 ◼   ► and their next generation network,

00:16:35 ◼   ► Linode delivers the performance you expect

00:16:37 ◼   ► at a surprisingly good price.

00:16:39 ◼   ► I use Linode, Dave uses Linode,

00:16:41 ◼   ► I gotta say I am super happy with it.

00:16:43 ◼   ► I've been with them for almost a decade.

00:16:44 ◼   ► I have all of Overcast hosted there,

00:16:46 ◼   ► I have my personal site server hosted there.

00:16:48 ◼   ► It's just wonderful.

00:16:50 ◼   ► You can get started today on Linode with a $20 credit.

00:16:53 ◼   ► You get access to native SSD storage,

00:16:55 ◼   ► their 40 gigabit network, industry leading processors.

00:16:59 ◼   ► You get root access to your server

00:17:00 ◼   ► along with an API version four now

00:17:02 ◼   ► and a Python CLI tool to automate setup if you want to.

00:17:05 ◼   ► Their nano plans start as low as $5 a month,

00:17:08 ◼   ► and they have lots of stuff above and beyond that

00:17:10 ◼   ► if you have higher needs.

00:17:11 ◼   ► Including things like dedicated CPU plans

00:17:13 ◼   ► with physical cores reserved just for you.

00:17:15 ◼   ► GPU compute plans, a whole bunch of other stuff.

00:17:17 ◼   ► So, go to linode.com/radar

00:17:21 ◼   ► and use promo code radar2020

00:17:23 ◼   ► when creating a new Linode account.

00:17:24 ◼   ► You get a $20 credit towards your next project.

00:17:26 ◼   ► And by the way, they're hiring.

00:17:27 ◼   ► If that interests you, go to linode.com/careers.

00:17:30 ◼   ► Anyway, that URL for the $20 credit one more time

00:17:33 ◼   ► is linode.com/radar, promo code radar2020.

00:17:37 ◼   ► Our thanks to Linode for their support of this show

00:17:40 ◼   ► and all of Relay FM.

00:17:41 ◼   ► - So I've got to imagine with a lot of your sound processing,

00:17:45 ◼   ► like there's gotta be a huge amount of math

00:17:48 ◼   ► and like even, I mean at a certain point,

00:17:50 ◼   ► like super complicated math,

00:17:52 ◼   ► where you start to get into like Fourier analysis

00:17:54 ◼   ► and the like things that are very beyond what I,

00:17:58 ◼   ► I don't really even know which they involve,

00:18:00 ◼   ► but I've gotta imagine things like Voice Boost 2

00:18:02 ◼   ► that you just were working on.

00:18:04 ◼   ► Like that's gotta involve a lot of this kind of like,

00:18:07 ◼   ► there's a lot of theoretical math

00:18:08 ◼   ► that you have to deal with.

00:18:09 ◼   ► Is that something that you have to like deal with

00:18:11 ◼   ► the actual like formulas and equations for

00:18:13 ◼   ► or is it, at a certain point it becomes very like empirical

00:18:16 ◼   ► and you're just comparing numbers

00:18:18 ◼   ► and like multiplying and dividing them as needed?

00:18:21 ◼   ► - It's interesting, like I,

00:18:23 ◼   ► and I have no formal training in signal processing

00:18:27 ◼   ► or anything like this and so,

00:18:29 ◼   ► and what I have to deal with when processing sound

00:18:31 ◼   ► is a lot of signal processing stuff.

00:18:33 ◼   ► You know, it's stuff like filters and you know, bi-quads

00:18:38 ◼   ► and yeah, you mentioned that the FFT, you know,

00:18:40 ◼   ► stuff like that.

00:18:41 ◼   ► I'm actually lucky that Overcast currently does not use

00:18:43 ◼   ► an FFT for anything.

00:18:44 ◼   ► The only time I've ever actually used one in Overcast

00:18:46 ◼   ► was in the very early versions when I had like

00:18:49 ◼   ► the peak meters that were frequency sensitive,

00:18:51 ◼   ► the animatability artwork.

00:18:53 ◼   ► - Sure.

00:18:54 ◼   ► - I don't do that anymore 'cause it was a little bit

00:18:56 ◼   ► expensive for performance and it looked a little bit

00:18:58 ◼   ► intrusive on the screen.

00:18:59 ◼   ► People didn't like it as much as I thought they would.

00:19:01 ◼   ► So now I just do the little peak meters and the pause button.

00:19:04 ◼   ► Yes, I know in the current app store version they're gone.

00:19:06 ◼   ► Don't worry, they're coming back.

00:19:07 ◼   ► They're in the beta right now.

00:19:09 ◼   ► And that's just doing amplitude so I don't have to separate

00:19:11 ◼   ► the frequency so it's much simpler.

00:19:13 ◼   ► But I've had to learn a lot of DSP stuff.

00:19:17 ◼   ► And fortunately, most of it is like you learn a couple

00:19:23 ◼   ► of concepts like how you can't just apply different gain

00:19:28 ◼   ► per sample as it's curving and expect it to sound correct

00:19:31 ◼   ► 'cause it won't.

00:19:32 ◼   ► Or you know, things like doing basic look ahead,

00:19:35 ◼   ► doing like attack release timing.

00:19:38 ◼   ► But most of that is a very, very large amount of very,

00:19:41 ◼   ► very simple map operations.

00:19:43 ◼   ► It's you know, multiplication, it's addition.

00:19:46 ◼   ► One of the only weird things was that sound is perceived,

00:19:51 ◼   ► as you mentioned, like with the color example,

00:19:53 ◼   ► like the way it's represented is with you know,

00:19:56 ◼   ► regular values from one to zero to negative one

00:20:00 ◼   ► as it goes like up and then back down like when you see

00:20:02 ◼   ► the waveform graph.

00:20:04 ◼   ► So it's like one to negative one in the float domain

00:20:06 ◼   ► and with zero in the middle.

00:20:07 ◼   ► But the way it's actually perceived by humans is not linear,

00:20:11 ◼   ► it's logarithmic because of the decibel scale.

00:20:15 ◼   ► And so I do a lot of operations in the decibel domain

00:20:19 ◼   ► to make them sound better.

00:20:20 ◼   ► And this is one of those examples where like,

00:20:23 ◼   ► it doesn't, I don't really need to do it in the decimal,

00:20:26 ◼   ► in the log domain.

00:20:27 ◼   ► I could do it in the linear domain and it would sound okay

00:20:30 ◼   ► and most people wouldn't notice.

00:20:31 ◼   ► But because we perceive sound in the log domain,

00:20:35 ◼   ► the more I could do in that domain, the better it would be.

00:20:38 ◼   ► But also, logarithms are a complicated operation

00:20:41 ◼   ► for computers to do.

00:20:42 ◼   ► And so you gotta be careful like not to do too many

00:20:44 ◼   ► conversions back and forth or not to try to like

00:20:47 ◼   ► interpolate the log at every single point of something.

00:20:49 ◼   ► Like there's all sorts of optimization potential.

00:20:51 ◼   ► And there's also things like approximation functions.

00:20:55 ◼   ► Where like, there are fast logarithm approximation

00:20:59 ◼   ► algorithms out there that like, they get you kind of

00:21:02 ◼   ► part of the way there.

00:21:03 ◼   ► And sometimes that's good enough.

00:21:05 ◼   ► Sometimes you know, if you have like,

00:21:07 ◼   ► if your approximation is good to like three decimal places,

00:21:10 ◼   ► like that's actually pretty good for your purposes.

00:21:12 ◼   ► In some context it's not.

00:21:14 ◼   ► And so there was a whole bunch of figuring that kind

00:21:19 ◼   ► of stuff out.

00:21:20 ◼   ► But for the most part, most of the math I'm doing is like,

00:21:23 ◼   ► vector based, which is like, you know,

00:21:26 ◼   ► basically look at the accelerate library

00:21:27 ◼   ► and the VDSB functions that Apple provides.

00:21:30 ◼   ► And it's mostly just applying the basic operations,

00:21:35 ◼   ► like addition, subtraction, multiplication,

00:21:37 ◼   ► to vectors of floats, which is just a fancy word

00:21:40 ◼   ► for arrays of floats.

00:21:41 ◼   ► So you have like a float array of like a thousand floats

00:21:44 ◼   ► and alright, these are the next thousand samples.

00:21:45 ◼   ► And you can say alright, what's the maximum magnitude

00:21:48 ◼   ► of, in this thing, which is like, you know,

00:21:51 ◼   ► basically the absolute value maximum.

00:21:53 ◼   ► And so you can say alright, that's the peak.

00:21:55 ◼   ► So when I'm rendering my peak samples,

00:21:57 ◼   ► I can say alright, take a look at this next block

00:22:00 ◼   ► and what's the maximum magnitude, VDSB max m g v, bam.

00:22:04 ◼   ► These function names make no sense when you're first

00:22:07 ◼   ► looking at them, but as you get used to them,

00:22:08 ◼   ► you kind of pick up the convention.

00:22:10 ◼   ► There is a convention.

00:22:11 ◼   ► And so then you can rattle them off and sound really crazy.

00:22:16 ◼   ► And then so you can call these functions on them

00:22:18 ◼   ► and it basically like rips right through it.

00:22:20 ◼   ► It's like these functions are so fast.

00:22:22 ◼   ► And then I have the maximum amplitude value,

00:22:24 ◼   ► and maximum absolute amplitude value in the next block

00:22:27 ◼   ► of samples and that gives me my peak value

00:22:29 ◼   ► for my peak meter display.

00:22:30 ◼   ► So like the concepts and learning what these do

00:22:35 ◼   ► looks intimidating from the outside because you have

00:22:36 ◼   ► all these like mysteriously named functions

00:22:39 ◼   ► and you're operating on very large amounts of data,

00:22:42 ◼   ► but really what you're doing is very simple operations.

00:22:44 ◼   ► And the challenge for me was more in learning

00:22:48 ◼   ► like how to manipulate sound to do what I wanted

00:22:51 ◼   ► in like basic techniques, but it wasn't so much about

00:22:54 ◼   ► like the math behind it.

00:22:56 ◼   ► The only exception to that is I had to do some amount

00:23:00 ◼   ► of figuring out bi-quads, which is like a method of,

00:23:03 ◼   ► if you ever want to implement like an EQ or frequency

00:23:07 ◼   ► modification, the way I thought naively that you did it,

00:23:11 ◼   ► I assumed that you would use an FFT to transfer

00:23:15 ◼   ► from the time domain to the frequency domain,

00:23:18 ◼   ► modify like whatever bucket you wanted a frequency,

00:23:21 ◼   ► is like change this value from you know,

00:23:23 ◼   ► .7 to .6, that'll drop that frequency,

00:23:25 ◼   ► and then do an inverse FFT and put it back.

00:23:27 ◼   ► And it turns out that isn't how you do it at all.

00:23:30 ◼   ► You can do things that way, but it's much more complicated

00:23:33 ◼   ► and way slower and you have to do a lot of other things

00:23:36 ◼   ► to make it not you know, suck or distort the sound

00:23:39 ◼   ► in weird ways.

00:23:40 ◼   ► And so you can also use a thing called a bi-quad filter

00:23:43 ◼   ► that is way simpler and this is what everything does.

00:23:45 ◼   ► Like pretty much any kind of like EQ or filter thing

00:23:49 ◼   ► that you see in apps, the iTunes EQ,

00:23:52 ◼   ► all that stuff is just bi-quad filters.

00:23:54 ◼   ► And I had no idea what those were or how they worked.

00:23:57 ◼   ► And I still don't.

00:23:59 ◼   ► I like, all I know is that I found some equations

00:24:02 ◼   ► for how to generate like the numbers to plug into

00:24:05 ◼   ► the bi-quad filter and there's a VDSB bi-quad function

00:24:09 ◼   ► that does the calculation for me.

00:24:11 ◼   ► So all I did was like how do I make these coefficients?

00:24:14 ◼   ► And I looked up you know, certain formulas,

00:24:16 ◼   ► alright here's how you make a notch filter,

00:24:18 ◼   ► here's how you make a peak filter, like stuff like that.

00:24:21 ◼   ► And then I plug it into this formula that's already there.

00:24:24 ◼   ► So that's an example where like there is some very complex

00:24:27 ◼   ► math behind that that I probably should know

00:24:31 ◼   ► but I didn't have to 'cause the library took care

00:24:33 ◼   ► of most of it for me and some you know, a few days of

00:24:37 ◼   ► you know, web research and Stack Overflow and Google

00:24:39 ◼   ► and stuff took care of the rest.

00:24:42 ◼   ► - The thing you said though like the you probably should know

00:24:45 ◼   ► like I think increasingly I don't,

00:24:48 ◼   ► I'm not sure that's even true.

00:24:49 ◼   ► - Hmm, that's a good point.

00:24:50 ◼   ► Like 'cause I think there's the, this is the like,

00:24:53 ◼   ► this is the root of this problem is it's like,

00:24:55 ◼   ► do you need to like, do you need to understand

00:24:59 ◼   ► the physics of leverage in order to use a hammer?

00:25:01 ◼   ► You know like, would you be more, would you be more capable

00:25:07 ◼   ► or wield it more efficiently if you understood the way

00:25:11 ◼   ► of like, of the way that a lever works and like all of

00:25:14 ◼   ► and like that type of or like the transfer of inertia?

00:25:16 ◼   ► Like there's these things where if you understand

00:25:19 ◼   ► the fundamental, like the underpinnings and the math

00:25:23 ◼   ► and the physics and whatever it is of what's going on,

00:25:25 ◼   ► like you can imagine and I can sort of, I can imagine

00:25:30 ◼   ► myself in this pretend, like this pretend world

00:25:32 ◼   ► where I understand this thing that I, my,

00:25:35 ◼   ► the end result would be better.

00:25:36 ◼   ► And like it probably would be better but almost certainly

00:25:40 ◼   ► not by as much as you would imagine it is.

00:25:43 ◼   ► That like I think increasingly what I find is it's like

00:25:45 ◼   ► if I can understand something enough to know how to use it,

00:25:49 ◼   ► and understand that there might become a point where

00:25:52 ◼   ► there's a bug or an issue or an edge case that I can't

00:25:54 ◼   ► deal with, like that's fine.

00:25:57 ◼   ► But it also means that I don't have to spend like three

00:25:59 ◼   ► years getting a PhD in the subject to like,

00:26:02 ◼   ► because I think what I realize is you hit a point where

00:26:06 ◼   ► the like, there's this massive chasm between the just like

00:26:10 ◼   ► basic intuitive understanding of something and then like

00:26:13 ◼   ► the actual deep understanding.

00:26:15 ◼   ► And it isn't just like, oh, this is like, you know,

00:26:18 ◼   ► a quiet afternoon sipping a cup of coffee on my porch

00:26:21 ◼   ► reading a book.

00:26:22 ◼   ► It's like, no, this is like, I need to go to like college

00:26:25 ◼   ► level classes to like unpack and understand what's going on.

00:26:29 ◼   ► You know, it's like, I don't really understand how

00:26:31 ◼   ► Bezier paths work, like the math behind them.

00:26:35 ◼   ► Like I remember trying to kind of get a sense of what's

00:26:37 ◼   ► going on there.

00:26:39 ◼   ► And it's like, I sort of could maybe get like, I was like,

00:26:42 ◼   ► you know, could crack through like 0.1% of it.

00:26:45 ◼   ► But at a certain point, I'm like, I don't know.

00:26:47 ◼   ► And it's fine.

00:26:48 ◼   ► I just like, you know, move the control point until it looks

00:26:51 ◼   ► correct, and then that's fine.

00:26:54 ◼   ► And like, if I truly understood the math behind it,

00:26:57 ◼   ► maybe that would be better.

00:26:58 ◼   ► But I get a certain point.

00:27:01 ◼   ► Like, I think the key thing in some ways that in with,

00:27:04 ◼   ► like in my relationship with math and my work is

00:27:06 ◼   ► understanding that like, it's, I was there were problems

00:27:09 ◼   ► that I was not solving, or like solutions I was ignoring

00:27:13 ◼   ► because I thought I would have to understand it at a deep

00:27:16 ◼   ► level in order to use it.

00:27:18 ◼   ► And I think increasingly, it's like you, you don't need to

00:27:21 ◼   ► necessarily understand it, you can, it's totally fine and

00:27:24 ◼   ► legitimate to just have a working version of the solution.

00:27:28 ◼   ► And then use that, you know, there's many things in computer

00:27:32 ◼   ► science and in, you know, in the design of applications that

00:27:35 ◼   ► I don't understand.

00:27:36 ◼   ► And I don't need to understand like, I'm not really good on

00:27:39 ◼   ► some of the graphics stuff where like, how, like,

00:27:41 ◼   ► wave frame, frame buffers work, and the display links.

00:27:45 ◼   ► And like, there's these things, these tools that I use when

00:27:47 ◼   ► I'm like making an animation that I really don't understand

00:27:51 ◼   ► that, you know, that the ins and outs of, but I understand

00:27:54 ◼   ► enough to make it work.

00:27:56 ◼   ► And I think that like accepting and being okay with that

00:27:59 ◼   ► is, opens up all these problems to you that you just can,

00:28:03 ◼   ► you can solve now.

00:28:03 ◼   ► Like, cause if you, if you had to understand, what was it,

00:28:06 ◼   ► bicubic?

00:28:07 ◼   ► - Biquads.

00:28:08 ◼   ► - Biquads.

00:28:09 ◼   ► - Yep.

00:28:10 ◼   ► - If you had to understand biquads in order to use biquads,

00:28:12 ◼   ► then you probably wouldn't be using biquads and you wouldn't

00:28:15 ◼   ► have an EQ filter and you wouldn't have features and things

00:28:18 ◼   ► that you know, that would be available to you.

00:28:20 ◼   ► And so I think increasingly I find like, just, it's okay.

00:28:24 ◼   ► Just accept that this is someone else's job in the same way

00:28:27 ◼   ► that I don't design Silicon chips, I just use them.

00:28:30 ◼   ► Like someone else has done the hard work of coming up with

00:28:33 ◼   ► the math and you know, they sure they got a PhD out of it.

00:28:36 ◼   ► And they can put some letters after their name as a result,

00:28:38 ◼   ► but I just want to, you know, use the thing and have it work.

00:28:42 ◼   ► And that's probably good enough for me.

00:28:45 ◼   ► - I guess I usually do feel that same way.

00:28:47 ◼   ► That is usually my philosophy of like, you know,

00:28:49 ◼   ► somebody else can figure out the complex mathematical

00:28:53 ◼   ► details of this thing and I can just use it.

00:28:55 ◼   ► It does occasionally bite you in the butt, like if something

00:28:58 ◼   ► goes wrong or if you're having some kind of massive

00:29:00 ◼   ► performance issue that like, and it does help to understand

00:29:04 ◼   ► some of the underlying stuff then, but that just doesn't

00:29:07 ◼   ► happen very often anymore.

00:29:08 ◼   ► So you actually can just like, let someone else do the

00:29:11 ◼   ► algorithm or the formula, figure it out, and then just

00:29:14 ◼   ► use it.

00:29:15 ◼   ► - Yeah, I think then that's good enough.

00:29:17 ◼   ► And like, it's fun to use math that I learned in high school

00:29:21 ◼   ► that at the time when I was learning it, I thought,

00:29:23 ◼   ► why would I ever use this?

00:29:24 ◼   ► You know, I'm never gonna use trigonometry in my real life.

00:29:27 ◼   ► And it's like, actually I use trigonometry all the time.

00:29:29 ◼   ► - Yeah, me too.

00:29:29 ◼   ► - So if there's any kids listening, it's like trigonometry

00:29:32 ◼   ► is the real stuff, make sure you learn that.

00:29:34 ◼   ► - Yeah, right triangle trig, that's important.

00:29:37 ◼   ► - That's important.

00:29:37 ◼   ► - Not much after that is, but that's important.

00:29:39 ◼   ► - That's important.

00:29:40 ◼   ► Forget about calculus, right triangles is where it's at.

00:29:43 ◼   ► Thanks for listening everybody, and we'll talk to you

00:29:45 ◼   ► in two weeks.

00:29:46 ◼   ► - Bye.

00:29:47 ◼   ► [