College Precalculus – Full Course with Python Code

freeCodeCamp.org · Intermediate ·🔢 Mathematical Foundations ·2y ago

Key Takeaways

This video course covers college Precalculus concepts with Python code implementation, using tools like Python, Google Colab, and pandas to analyze and visualize data, and apply mathematical operations.

Full Transcript

this college pre-calculus course is different from other college pre-calculus courses like many other ones you will be learning all the concepts from an experienced University Professor but in this course Ed pertowski will also show you how to implement the pre-calculus concepts using python this course is for anyone who wants to learn pre-calculus but especially for those who are learning computer science welcome to pre-calculus with python so we're going to use python on code to do all your math and we're going to look at topics like triangles trigonometry solving triangles finding out all the sides and angles and area of different triangles even starting with just little bits of information we're going to look at a lot of the graphs of the trigonometric functions and one of the things with these graphs is they're repeating patterns so we can graph things like Tides or you know phases of the moon or something like that that a repeating pattern to it and we're going to look at bringing data in and especially data that might have repeating patterns and using trigonometry and other pre-cal tricks that you'll learn to analyze that data and being pre calculus all of this we're going to get uh a little bit further into math what are some things we can do with all these points how can we graph things how can we graph different sorts of functions and how can we solve um maybe some problems you haven't looked at solving yet and then lead up to things like sequences series limits and that brings you up into some things you'll be able to do in calculus so let's dive into it and let's take a look at pre-calculus with python so the first thing we're going to do is set up your collab you might remember this from before but remember click on new more and we're going to click on Google collaboratory and if you don't have that already you can go to connect more apps and you know it might not show up there and you click in here um you can search for uh collab and you know mine's already installed but you could click and then install it if that's the case so you know new but we're not going to do doc or anything more all these other things um Google app script by the way uh is more like uh this runs in all of your documents and sheets and everything and it's kind of based on JavaScript so that's also good but we're going to focus on the python and Google C laboratory there we go you create a new cab give it a title now what you're going to do is you're going to build this throughout the course um like we did in the algebra course so you're going to give this a name um you could even call it uh pre-cal if you want um there you go uh if you something like that um I think in the algebra course I just called it your notebook um and we're going to add to this throughout the course so what you can do is you know it just gives you this code block if you give text and then if you double click if you put uh the hashtag now in the code that would be a comment in here that's going to give it a a title for the table of contents so um you know I might have like uh get data because that's the first thing we're going to do and then you know I'm going to you know I'm going to put the code here um you know code here we'll we'll get to that later I just want to show you that um if I add other text here um you know next topic but notice I'm not putting the hashtag there so over here I go to the table of contents and get data is in there and we can find this so you see you can minimize that so within this topic you can have your two cells and that's what we're going to do we're going to build this throughout the course and yes the first topic is going to be how to get uh data into collab so that then we can do math to it so we'll look at that in in the next uh in the next video so let's take a look at some different ways to bring bring your data into Google collab so uh and all this we're going to have like a m Focus there's much more you can do with grabbing data from different places but our goal here is to get numbers get arrays of numbers and you know then we can do some math to it so I'm going to really focus on that in a few different ways yeah so maybe you have a CSV comma separated values you know that type of file um which can open in a spreadsheet you know like Google Sheets or Excel but you know you can get the CSV directly if you have that online I have this um you know a few of these examples here um yeah this guy um at Florida State he actually has this website that has you know a bunch of different examples so I picked a few of them here so you know we're going to import um all these things pandas uh import files IO all this and I usually like to Define whatever the URL is as its own variable that way you know you keep it organized all these different possib abilities here and then this code doesn't have to change so there we go that built-in pandas function read CSV and all these things I'm going to store them all as table one this and the other examples so that you get the idea that here's all the ways you can get this data in as a table and then now once we have a table we can do all kinds of stuff to it one of the things we're going to do is um uh that function table one. head The Heading and the first few rows this is usually you know you don't let's say you're getting this data and you don't know how big this table is you want you want the heading because you're going to use that for some other things and you know the first few rows you want to get a sense of what what that that data is um so the last line of code here you don't have to put print or anything if I just say table one. now if I just said table one without that head it'll actually just print out the whole table here you don't even need a print statement uh that that may be overwhelming so I just want table one. head and we're just going to see what this looks like here so this one was you know you know cities. CSV and we see we have latitude and longitude of different cities interesting but also just to show you that hey you can have like you know um numbers that you can work with maybe you want to import this into into some sort of uh you know I don't know plotting lines or something like that on on a map there we go so we have that I also want to show supposing and we've seen the heading so I'm going to comment that out now but let's run it instead table one. describe so we see it gives uh certainly all of your headings or your headers that's what you want and then with each of these you get that description of each column this is going to be really important now the count if you're counting something it's going to be integers but somehow it always puts this as a floating point with all these decimals so there we go now we we can look at the count and see first of all that's great all the row all the columns have the same number in them so I'm not going to have in data I like that but there you go mean standard deviation minimum maximum these are also really important minimum and maximum because if I want to think about graphing this or you know some sort of range I get an idea of what I'm looking at here so these are some of the things you know heading the describe I'm going to show uh this other one here so if I comment this out and if I have this um let's do this one um the people one actually maybe I'll skip this one the people one that's kind of NE it's there's like there's like four things in there all right um letter frequency um let's see we have this and I'm going to show you this just again just some tables as some examples here and from some document it has each letter and the frequency how often this came up and what percentage it was um there we go now we might know from stat other statistics that e would be the most common and we see that you know shows up 12.6% of the time which for one out of the 26 letters you know instead of showing up you know less than 4% of the time if it was all evenly distributed no e shows up 12.6% of the time so there you go just interesting and we could have this described now notice um if you have both of these I didn't comment out the heading or the describe see notice no print statement so just saying table one. head table one. describe it ignores this or it was going to do this but then when we had this it just bumped that out of out of the contention so even if you didn't comment that out you know without the print statement just saying that last line you know table one. describe that's the that's the thing it's going to run and so we see you know um frequency count um scientific notation even though it didn't need it so 2.6 time 10 to the first power is 26 there we go mean median so just some interesting things so I just want to show you this so this is one way um that we can have uh you know the uh you know different URL and some of the key things we want just stored as a table and then something The Heading or the describe now you could also upload the CSV and this this is all the code you need it will give you you know this creates this dialogue um this files dialogue so then if we're going to call it uploaded so that you know if if I had this without the uploaded equals I mean it has a file dialogue but it might not do anything meaningful whatever you pick it's going to store it then whatever you pick it's going to store it as this variable and then that this is the way to get the file name so whatever you just selected to upload and you know it's going to pick that one um yes you're going to iterate through exactly one thing so that's why you can just say next so there's your file name and I'm saying that this is a CSV so that way I already know that I'm going to do read CSV um file name and once again what am I doing I I could actually just have this without the table one equals and again it'll do that but it's not going to really accompl anything I want to store it again as table one so now I have this you know uh data frame table and from that storing it is table one we can do all kinds of other things so pretty cool maybe I have a table on a web page and remember we see a lot of web pages um that have tables the couple examples I have are you know Wikipedia Pages you might have with you know a web page with a lot of tables so this one uh my importing you know pandas I'm going to read read HTML and I'm going to you know just knowing I'm not just reading a table or CSV I'm reading the website read HTML but this one I'm going to store it as a variable tables so that's going to be my list of tables and we see I do want to print this so this you can use this for exploratory situations you know there are how many tables all right well I just stored that as all my tables here and I can say now having already looked at this like I might not even need you know these last two lines at first I could just or these last three lines I could just print out this one you know how many tables do I have um I happen to already look at this I'm like oh table number four that's the one I that I want so you see now I'm just going to have this tables element number four from that array and again what am I doing stored it as table one and I'm going to print that out now there we go it happens to be different managers and the years and wins and losses I I just thought that was an interesting thing because we can have some uh names and dates fine but I also have a bunch of numbers I can use wins losses winning percentage there we go so you know that that's the one I decided to pick now notice um you know I picked this one um Wikipedia for the Philadelphia Phillies because the Phillies but you know I also put another one you know Cricut World Cup and similar similar data if you want to analyze that and now we can do some other things with this one also once I have this stored so let's say I run this block of code and now this table is stored as table one I can continue that and I don't have to go through like once you import that it's good for the session which can be hours or up to like 20 or 30 minutes of inactivity if you aren't running any code um you know this this cell or another one you know for like 2030 minutes it still might stay there in you know the current memory if not um then you might have to go you know you leave and come back then you might have to go and run that other one but that that's this is good for anytime you're in reporting all this great now now I have all this I don't have to go through and do that again now we can say this and what I did is just you know as just to show some of the things we did I just calculated my own uh winning percentage just because so just to show you so I can have this table one because now that I have that I see all my headings so I'm going to take table one wins and table one losses so you see looking at this I can pick these table headers and this is going to be an array np. array because I'm going to I already imported numpy even in that previous code cell and I'm going to create a numpy array from there wins and losses and then what I did is I just made my own average equals wins divided by you know wins plus losses you could print that out you know I just put that in there but here's what else I did um I created another table column so now I have table one average this didn't exist before that equals this so I create this average which is you know if these are numpy arrays look at this I can make this other uh array of all the averages and then I can create a new column now that's there so I could print this and I could have like you know manager winning percentage and then now that I created that I can just add this other there we go I probably don't you don't really need the extra space average I can create this other column so now I'm going to print table one now first of all notice it did print it and you know really this create this python creating the averages it really just to you know this table was correct in in the winning percentages um the pyth python calculation just takes it to more decimal places but that's okay the other thing these subtle things notice this time I decided to use a print statement which I didn't before and just notice the subtle differences if if I do print this is what it looks like whereas this is what it looks like if I didn't use the print statement and early on I like doing this it tends to format it in a way that might be easier to read at first um but if I already know that it's going to be just a few columns I just might want to use the print St and it really just it it just displays it differently um you know that's that's all so pretty cool things you can do um I'm going to do another example here again reading you know URL um so importing everything um date time and calendar we're going to use that later but you see this one again I'm just going to here's the URL of you know again I just picked place you know Tides I think that's pretty interesting because you know goes up and down that's going to link with some stuff we do later with periodic data and now the URL um again my array of tables and we'll see this now if if I just comment these out you see because if you're doing something exploratory maybe you're not as familiar with this site or you're like oh how many I see it but how many of them are really formatted as tables we can run this and it'll say boom there's only one table there we go so knowing that there's only one table then I can go back to this this and say oh okay print table zero and again I'm using the print statement you could just put table zero without the print statement that's fine um there we go um I happen to know that you know this is not going to be too big to be overwhelming and then we have all this so Tides date time and the height in feet high tide low tide high tide low tide there we go and it should alternate I think yes it should alternate so there we go now this next line I may or may you know I don't necessarily need to do this I could have just kept tables zero element zero um but just to be consistent I'm just doing the same thing converting it to this variable table one because now um we can do anything you know if I had a bunch of other code you know boil plate code of all different things I want to do with table one now I now I've stored that as this variable so there we go and again table one. head so notice this I'm printing it and then when I do this without the print statement we'll see how it formats it a little bit differently oh because I already printed it here so um instead of scrolling down I'm going to comment this out there we go yep so there you know that's another way to print it now what I want to show you with this is continuing this example if I want to do some math to this again connecting with some things we're going to do later with periodic data and being able to graph this but I have a date and a time which is of course AM and PM so down here continuing that example I'm trying some different things I'm going to convert all this to uh all that date and time look at this I have you know the day the month the day and all this time I want to convert this to some sort of numerical data that I can graph so I'm going to take this time list date list and I'm going to create these arrays hours minutes days and convert this to Epoch time so I'm going to call it Epoch array and really that's going to count the minutes from a certain point um by default it goes to January 1st 1970 so you know that's a way to make you know compare times because you can convert everything to this and then you have everything consistent minutes since January 1st 1970 so I'm going to go through this you know I have my time list and I'm I'm going to Loop through this for T and time list I'm going to split it I know it's a time so it's going to have the and then I'm going to take the first part convert it to an integer that's going to be the hour I'm going to take the second part and I know that that's minutes so I'm going to convert it to an integer but I'm going to take it just that first part because I I know we had AM and PM so I just want the first part as minutes but then if the last two digits say PM then um and this if statement I put the Co in and I did not make it on the second line that works um if you just have one little thing you can do it all in one line so my if statement here if the last two digits are PM or last two characters are PM then I'm going to add 11 into the hours um and there we go so I'm going to each time then I'm going to for each of those then I'm going to append the hour array append the minute array um I and then you could do this I commented it out here but you could print it out to then show okay what do my times look like just to see that it's right that it is doing what you want it to do so a lot of times when you're trying some things you know let's say exploratory you can print things out to test it out and then I'm going to go to date but now notice I'm going to have this date well I wanted to skip over the I I just want the day um and this is just because for this particular data I'm just going to grab everything that I already know is in the same month so that that really is why so I'm skipping over the day of the week I'm skipping over the all August so I'm skipping over the next three characters and I just want starting at character 8 to the end of the array and then that's going to be just the number so then I'm going to cast it as an integer and append it to that and then now I have my hour and my minute my day I'm going to store this you know in the range so in range of the length of that so all of these are the are the same so I I'm just I just picked one list and the length of that so now um see in in that range so notice if I say d in date list it's going to D is going to be each element in that date list but C in range I don't want each element I just want the number how long this is so now I'm going to convert this to a date time so you know I it's going to be this year this month and then each one day hour minute and then seconds I'm just going to make it all0 seconds because now I have that T I can uh convert that to a Time topple calendar. time GM which is grenage meantime and cast as that as an integer so this this line here then converts all that to an Epoch array pretty cool um we'll print that out but we'll get to that in a second and then I just want the the heights to float numbers so um you know table one. feet it's all height and feet um uh so that's why I call it f array because H was already done for hours so I can't use H for height so f for feet and I'm going through each of those and I'm G to append this so the first four parts so I'm taking that substring which is just the heighten feet or the first three 0 1 two three um because they all work out to three characters in that array so it works out I'm going to get those three which will be the number cast it as a float because they all have decimals appended to that so just showing you some some of these acrobatics that you can do hey you have a table I I I know I have numbers in here and I know it's numbers I want to work with and I'm going to print out that array so just to show you what this looks like so you see that first one is going to be the array of times um there we go and the next one is going to be the array of heights and once we have these two arrays you can do anything with them you can bring them into um you know some sort of graphing utility you can you know graph and do all kinds of things with that so you know pretty cool um we'll get to that other graphing later but I this is really all about getting this data into some sort of math form getting it from different places and into some sort of math form now I have two arrays of numbers that I can do math to I can graph or whatever you may have data in your Google spreadsheet um there we go and this is another one I you you you need to authenticate um you know you mount you can mount your Google Drive um so I have this um this Google code snippet if you're looking in Google cab down on the left hand side it you know it looks like brackets you'd have like an HTML or XML tag in you know you can click on that and it'll bring up various code Snippets you can search through them and then when you pick one you can even insert it like right in here um I inserted I I modified a tiny bit uh just to simplify what I wanted to do but there we go so you can get these code Snippets authorizing this um all these Imports you know and and you know the code Snippets help because see this like creds comma space uncore um equals default these are the things you know I I I would never think of that on the off the top of my head and there we go so I'm going to authorize this and I'm going to open um I just I I I made a silly uh spreadsheet with just a few lines comparing file types so that's the name of it and then do sheet one there we go um but all I'm doing is authorizing this and then I'm storing this first sheet in here I open that file that I wanted first sheet and I'm ref in as that value variable work worksheet notice I didn't have print statement nothing else happened but now I can continue that and now it's already stored there as that variable worksheet and I can keep going back to that and working with that doing different things and I don't have to like make that connection with the Google drive again every time you know um this and you know if you're ever doing things with Google app script the fewer calls to the Google Drive the better so if you can like call at once and get everything you need and then work from there that's that's great so you know now I have worksheet and so I'm going to use that variable worksheet doget all values and I'm going to store that as rows so this is pretty cool I can print rows um if if you know what your uh you know how you like it's your it's your Google sheet and you know how how much stuff this is and it's not too much you might even just say print r and just print all of it you can do that um and then I'm going to print the length and here's what I'm doing oh what I'm going to do is I will uh print this uh print the length of the rows it it it it's just a a silly sheet but it's fine so I'll print the rows how many and then now I I just want what I did is I made uh the third column the other ones have words the third column has numbers in it so um I'm going to create this integer array and number in range all right so the length of this and what it does is even though you have this spread sheet each row is its own element so now I have um you know I can say the length of the rows here and that's going to that's going to be how many rows even though each row will have an element so it's a it ends up being a two-dimensional array here this rows when I say get all values it ends up being a two- dimensional array rows columns okay so um and I have a header so my range I I want to started it at one because zero would be the header all right so now I have that range uh and I'm just going to go through these numbers I know they're numbers so I just call the variable numb so here's what I'm going to do remember it's a two-dimensional array so for each one I know this is the third row so I want the numb is what row it is and then I know or it's the third column so I know it's what row is numb that's what we're We're looping through and I know it's the third column so that's why this is a two remember start at zero so there we go I know that I'm going to take the you know going down that column you know each row and then I know the numbers but I need to make sure I cast it as an integer and then I'm going to append this to the integer array so there we go and there we go I so again ways to get to this and now once again I have an integer array now what you could have is you could you know you could have a length of rows and it's just a sequential count so um you could store this um you know as you know X or something you know you could you could always make this you know like x equals um length you know you could you could always have a a a variable like this x equals the length of rows and that way you know you know it's sequential and you could you could count up through that as some index or something like that and then now you have this array of all these values in each row and and you could pair them up then okay you know plot um different things you can do so again ways to get data in from different places and you know select hey I might have columns with words in it um you know this course we're talking about math so we're going to skip those but even when they have numbers I need to get it in the right form usually some sort of array and then I can do some other stuff with it and I'm not going to go through all the different file types but just as an example you can let's say if it was you know XLS with or without that X so all our Excel files if that's online as a URL and you can work this you know sometimes people upload it to their website some people have it as something on GitHub um all that it all works you can see if it was just uploaded from your local drive you can use the other ex the previous example here of of um just uploading a file from your computer but if it's anywhere online um there we go it's an Excel file and just knowing that I'm going to do this pd. read Excel and once I have that now it's stored as a sheet and I can you know print it out or display the heading the header so I just wanted to show you this this works out as long as you are pointing to an Excel file there you go um because if it was pointing to um actually I this I this this this would work for a Google sheet too um but also you can use that URL as well if it's a public Google sheet that would work too so just all these different file types you know how you can get um you know all this all this different data in Google Drive and as as you make this you know from different things you know you can even make them all headers so you have some examples of you know you you can have a table of contents for all the different ways that you can bring this in and remember table of contents you know if you're putting this in there you put the hashtag which in the python code would be a comment but in here it would mark it as a as a head as a headache so some things you can do getting data from different places bring it into bring it into collab and now all different ways get a table um you can do some a lot of things with it get different arrays and then we can do some math to it so now let's get into some of the math that we can do with all this stuff so we'll take a look at that stuff next so I just want to briefly talk about drawing lines on the graph even when there's no function really but you can get a bunch of points and you can write the code so most of this we're going to talk about with the code but just to give you the perspective you could have you know a few points and you could write the code to rather than develop a function say hey I'm going to draw from this point and it's line to this point line to this point line to this point line to this point and you can finish it up and close it out and go back to the first point and make a shape or you could create all these other drawings or shapes that you want um whether it be to make art or whether it be to represent data that is definitely not a function so there's a lot of different things you can do it doesn't have to be a math function but there's still some code you can do to get data from a list or something and we'll look at that and you know represent it in different ways and sometimes times maybe you can draw lines and uh represent different shapes that way and we'll look at some applications of that so let's look at the code so let's look at drawing lines with code and sometimes on like introductory learn how to write code uh activities you'll find things but this is the full code that also work things like this but this is the full code that works behind the scenes so we're going to import a few things um I'm going to import uh map plot library and I'm going to import this other one um from within the same Library path and then again from the same Library patches and we'll see how they come into play so I still want to set up an array or two arrays one of them an array of each vertex and then I'm going to create another array of all the different steps I'm going to do so if I wanted to just do this one at a time I could do this here's here would be my starting point I'm going to take this vertex array verts do append and I'm going to append this 0 0 notice um I do use decimal places um I I want to make it uh floating Point numbers rather than definite integers um so I have this you know I'm going to append this X and it's going to end up being an X x y coordinate notice the double parentheses and everything and then to each step steps. a pen that's going to be the first step it's going to be path. move to and so the first step is going to be I'm going to move to this point 0 0 and I could just continue adding I'm going to add a line now verts do append to2 so now this is my second point and notice this one is path line to so move to will give you the path you know that's where essentially a starting point without Drawing the Line and then line two will go from that point to this one with with a line and this is where I could keep going and you know I could always put you know more here as many lines as I want but I'm just going to show this simple I'm going to start here draw a line to this point all right and then now here's the graph uh as before um set up the graph I'm going to set up the Axis and for here you know five in every direction that's going to be fine for what we're doing so this is where we get I'm going to create this variable called path and what it is is this python on function path and it's going to take these arguments of these two arrays verts steps so you know that function I'm going to store as the variable path because then I'm going to use that agre this other variable called patch and then it's going to work on this python function patches. path patch and then this variable path is what in the parentheses so probably easier to write the code than to say all this path path patches patches path P patch path anyway so then on my other variable axe for axis I'm going to add patch that python function and then patch so we see create the vert create the two arrays and they go into this function for this variable then I'm going to use this variable in here to create this variable and I'm going to use that variable in here when I'm going to add them to my Axis and then I'm going to show it so if you were going to draw lines it it really is good to start out with your array you know you have your Imports and your arrays that won't change and then all this however many points you want you can just add add them all right here and then all this graphing code doesn't have to change so this is just going to be a simple line when we run this there we go I didn't even draw XY AIS Lines Just 0 02 22 draw this line all right if I wanted to put more I could and here's what I'm going to do I'm going to append this and if I drew another line so maybe I'm going to call this two -2 I'll go draw a line down to that one and then I'm going to do one more thing which is going to be I'm going to go back to 0 0 my original point and so that gets its own special close poly function so I can move the point and then draw you know start there line to that line to that and then close the poly going back to the original and you see as many different points as I want to create here I'll run this and there we go boom boom boom makes a triangle all right good times and there we have it so I'm going to show you a couple things that we can add and tweak to this you can definitely do these all each step and sometimes that helps because then you can really just picture you know that what lines up you know this point and then going line to that point this point close poly but you can create your arrays right out of the gate and here I'm G to create my array verts and you see just each point in this array and then I just call this one codes but here's the array of steps and you just have to me uh uh keep track of lining these up also notice um I can continue it on one line like I did with verts or I can hit enter and then just put them in line here here comma and then on the next line and put the array here which it actually is just fine to have a comma at the very end of this array that works out so then we just match it up you see move to line that first point line two that second point and then you just keep track line two line two line two close poly and I should have one 2 3 4 5 6 7 1 2 3 4 5 6 7 and that works out so just another way I could Define all these especially if I know what points I have this might this method might be easier and I'm still going to use that same code um B see vers and then codes because I need that and then I stop the variable here for patch but I can add some other things you see I can change the face color and I can change the line withd so let's take a look at that now it was a light blue but if I just say blue here it makes it this nice uh royal blue and the line width you see it makes it a little bit thicker pretty cool so I mean you know let your artistic mind go and see what you know different things you can create just by drawing lines and you know running it this way pretty cool things and you know this is again just scratching the surface you can build upon this and do all kinds of all kinds of cool things with this so I I'll leave that up to your imagination right now we're going to talk about trigonometry and trigonometry this long word we can break it down into three parts so try means three gone means shape you know like polygons and metry means measurement so metric would make it an adjective like the metric system but with a Y we make it a noun so trigonometry and these old Greek words we read them backwards so it's the measurement of shapes with three sides triangle class as as many of my students mentioned so let's uh focus on triangles with right angles so our right triangles we will get even beyond the right triangles so trigonometry applies to a lot of things and we really can break down anything into triangles any other shape can be made up of triangles so that's why it becomes so uh Central to figuring out a lot of other things and with that we're going to start with right triangles so the reference angles here and the reference side it's all these relationships to the sides and the angles so if I call this angle a then this side is a cross from so it's the opposite side so instead of saying a cross from we're going to say opposite kind of mean the same thing but the these are the uh this is the notation we usually use in in trigonometry so if that's the opposite side now then this would be the adjacent side but notice they're adjacent meaning meaning next to but notice from this angle I have two sides that are next to it but the hypotenuse is always its own thing and the hypotenuse is the you know the longest side it's across from the right angle so since I have two sides that are adjacent to angle a but one of them is the hypotenuse so then the other one I'm just going to call the adjacent side so now I have from angle a the opposite side the adjacent side and the hypotenuse now again these are reference to how they relate so if I was talking about angle b instead then this side is no longer the adjacent side and that's no longer the opposite side then if it's angle B this is the adjacent side and then this is the opposite side because now this one would be across from angle B this one would be to and then hypotenuse is still its own thing now this matters because in figuring out a lot of things about triangles we set up these ratios relating to the sides and the angles so we're going to talk about three main ratios and then um later on we'll add three more um which are you know the inverse the the reciprocal of these three but these three main ratios and you you'll we'll see as we talk more about uh trigonometry how this comes up in different ways so we have the sign is our first ratio and the sign of whatever Angle now officially I'd put it in parentheses because this is a function but you'll see a lot of times you know in the notation people might skip the parenthesis um certainly as you get into writing the code we need the parentheses again this is a function so the sign of whatever angle is the ratio of the opposite side over the hypotenuse and I'm just going to abbreviate those here so that's the so when I say the sign it's the relationship so if I was talking about the sign of angle B you know whatever the measure of this opposite side divided by whatever the measure of the hypotenuse and that's this ratio and if that's a certain angle no matter how big the triangle is that ratio you know the sign of 30° a sign of 35° it's the same each time you know you can plug that into your calculator s of 35° and that's a constant so I get that relationship the opposite over the hypotenuse and notice remember the hypotenuse is the longest side so the opposite side's always going to be shorter um you know we're going to have these decimal numbers um usually really long decimal numbers but we may round it to like four decimal places and we'll also look at some other patterns in that too so the other relationship is the cosine of whatever angle I'm just going to call it angle B for now and the cosine is the adjacent side over the hypotenuse so that's the coine ratio the adjacent side over the hypotenuse and then the tangent is the relationship of the opposite over the adjacent so now with these three ratios one of the things we might notice is that if I you any now having all three of these depending on what situation I have or what angles or sides I might know or not know I can use one of these three it you know that that it'll apply so that's why it's good to have these three the sign the cosine and the tangent and later on we'll look at like how they all uh where we got these numbers from how they all relate so a lot of things that we're going to do in in uh trigonometry we'll we'll learn one thing and then that'll come back around again when we learn the next thing oh it relates to this it's it's very like you know it's not linear it it's very uh circular and all kinds of you know hyperlinks in your knowledge uh when we talk about trigonometry so uh it you'll find it to be a pretty interesting subject so I have these three you know um ratios how can we remember these ratios well there's that you know s opposite over hypotenuse cosine adjacent over hypotenuse um tangent so and also remember it is the same ratio whatever angle I'm talking about so if instead of angle B I was talking about angle a you know whatever you know it's the s or cosine of that angle and then you know that's that's still the relationship so how can we remember these there's one um interesting way that a lot of people found so s is opposite over hypotenuse so cosine with a big c is adjacent over hypotenuse and then tangent with a big T is opposite over adjacent so if we write it like that then uh and a lot of people then pronounce this as soaa it's catchy because then you oh soaa so you know this is the soaa is the numic device that you know Le leads us through um our journey of trigonometry and so we follow soaa and that reminds us that s cosine tangent and what the ratios are because they're going to be very useful and we're going to look at how we can use these ratios to figure out some things um if I don't know an angle if I don't know a side I can I can figure this out and that's what we're going to do next all right so here's how to draw the triangle in code and I want to show you this because it's going to be relevant we'll use this as a display and we you might remember that P plot we'll import that um import display import math for some of the things we use and time because I comment this out here but you could delay for like 1 second you know the drawing of each line to make it more dramatic so I just want to include that as a possibility and remember we set up the subplots here and I'm going to set this axis this is how I decided to set set it up for this triangle the x value goes from -2 to 12 the Y value goes from -2 to 8 and I'm not going to draw any other lines to show The X and Y AIS but that just seems to be a decent size window here then I will display this text which is the letter A I'll display that at this 0 01 and here I'm going to draw a Red Dot at that point well what does that mean I'm drawing the points for my triangle so this line draws one one line for the triangle from X from the remember these are the X values as an array these are the Y values so the line goes from 1 one to 71 and it's going to be blue then we go from 71 to 74 that vertical line is going to be blue and back to that original 11 and then to the other point 74 that line will be blue and we'll display it like I said don't you know you could draw each of these lines um and pause and make it dramatic also the fact that I'm drawing a bunch of these lines python wants to draw each of these as a different uh grid Al together so every time I do that that clear out put inight um doing that after each line here um enables it to uh not have multiple graphs so then I'm going to have the text there we go adjacent side the text opposite side and then we see you know I just tinkered with this and this was a good place to put it text that say hypotenuse so when we draw this then it ends up drawing our triangle here so we see a DOT that I'm going to label angle a and because this is angle a this is the adjacent side it's next to it now the hypotenuse is also next to angle a but the hypotenuse is always its own thing as we were talking about this other uh complimentary point or angle that's B and the right angle would be C so from a we have the adjacent and then opposite because it's on the opposite side of the triangle just as a way to show you that you can draw the triangles with code um we'll we'll Tinker with that and uh draw some other triangles too so that'll be a good basis so what can we do with this we can um get the S cosine and tangent functions for each of those angles now we'll talk about radians in more detail um it's another way to measure angles um related to you know one radian is about 50 something degrees because it's the measure of the radius along the outside of the triangle we'll we'll talk about that in more details but the short answer here is that all of our trig functions use radians so if I want my angle in degrees then inside my trig function I just have to convert it to radians and so that's why I imported math and we'll do math. radians so math. cosine but it radians um tend to be a lot lower numbers so you'd get your answer and you that doesn't make any sense so um I just for now we'll do the angle in degrees and convert it to radians inside there so what I have is there we go U given that angle and you know change the angle we can just change this one variable there and we'll calculate the sign and I switch these for some reason the S the cosine and the tangent so I just saved them as these variables s c and T so the S cosine and the tangent and then we're going to round it four decimal places is good most of these will be really long decimals if you let it go so four decimal places is good and then we're going to calculate the sign and print the sign cosine and tangent so looking at that angle a and it'll print out s and I pick 30° so the S of 30° is 0.5 cosign is 866 which this one actually works out to something else a little bit more elegant if it wasn't a decimal but we'll get we'll get to that later too and the tangent is 5744 again four decimal places that's good so there we go and once we're talking about doing Cod code with this hey maybe I have this one angle but I also want the complimentary angle so you remember I didn't label it up here but the other angle that's not the right angle would be angle B and so the complimentary angle once I know angle a then B is just 90 minus a and if I want both then I'm going to change my variables here sa a CA and ta for S cosine and tangent [Music] and I just usually remember them or think about them in the same order so you really don't have to but there we go so s cosine tangent and then I'm going to print it out s cosine tangent and then I put this down here so the S cosine tangent of B and that's what we'll have S cosine and tangent of B and we'll print it out the S cosine and tangent of B so when we run this there we go so we have our s co sign sign tangent but then we also have the other angle would be 60 so the s cosine and tangent of angle 60 so there we go and we there's we're just starting to dive into a lot of these patterns here so this is just the beginning just noticing how for whatever angle you can easily find S cosine and tangent as well as those three trig values for the complimentary angle all right so not bad one of the other things remember all these trig functions they are constants so the S of 60 is always 866 and knowing that then whatever the sides are if I know one remember it's if it's opposite over hypotenuse if I know one of the sides I can figure out the other and just as a another thing we can do we can Loop through you know the sign and you know I just decided to go from you know 0 to 180 and the only thing here I'm going to import is math and I'm going to Loop through the sign and just show you that for a second here so notice this one I didn't round it python will round it and jump all the way down there so s of 0 0 um and just degrees I just got to you know one degree and we see these little T you know a lot of decimal numbers a lot of decimal places but look at the really tiny numbers zer0.1 and you know we keep going I'm already past the sign of 30 which oh because that work notice that worked out uh you see it really is 0.5 or 1/2 the sign of 30 um sometimes the way python calculates things you know it doesn't round it but that really is uh 0.5 is the exact answer and then we get to all these others and we get down to 789 and this one did round it properly the sign of 90 is exactly one and what do we notice about these values let's go somewhere around here so look at the sign of 89999 847 and the sign of 91 999 847 the sign of 889 99 390 and sign of 92. 99939 we're going to dive into some of these patterns here but for right now looking at the S cosine and tangent and you see it'll go back down so the sign of 180 um is actually zero so um now this next thing supposing I know those ratios so this is whatever those those sides are if I divide them um you know whatever those sides are then I can figure out if I you know this is the ratio and U you know if I know the angle I know one of the sides I can figure out the other but supposing I know both sides but I don't know the angle and so that's an inverse function you know the sign of I'm expecting angle and then the answer is this ratio which you know for like 161 would be like 325 so supposing I know that ratio um I know the two sides I can divide them get the ratio but I don't know the angle inverse function and the reason why it's a sign is because the full word is arc sign um another way to look at this as inverse sign and there's some other notation for that so you know now we get AR sign and if I do the arc sign let's say I knew this ratio you know four over five um so the opposite side would be four the

Original Description

Learn college Precalculus from an experienced university mathematics professor. You will also learn how to implement all the Precalculus concepts using the Python programming language. 💻 Code: https://colab.research.google.com/drive/1Wn8CLlR__gQAMmGrC2DL6YqglTTrsviN ✏️ Ed Pratowski developed this course for freeCodeCamp.org. ⭐️ Contents ⭐️ ⌨️ (00:00:00) Introduction ⌨️ (00:04:48) Get Data ⌨️ (00:36:17) Draw Lines ⌨️ (00:46:19) Trigonometry basics ⌨️ (01:06:16) Solve Right Triangles ⌨️ (01:25:01) Degrees and radians ⌨️ (01:37:08) Unit Circle ⌨️ (01:59:28) Trigonometry and Graphing ⌨️ (02:18:35) The Six Trig Graphs ⌨️ (02:30:48) Transforming Trig Graphs ⌨️ (02:53:14) Periodic Data and Prediction ⌨️ (03:04:52) Build a Clock with Trigonometry ⌨️ (03:21:38) Law of Sines ⌨️ (03:35:46) Law of Cosines ⌨️ (03:47:44) Area of any Triangle ⌨️ (03:50:57) Solve Any Triangle ⌨️ (04:09:03) Triangle from Any Three Points ⌨️ (04:23:09) Certification 4 Walkthrough ⌨️ (06:11:22) Matrix Addition and Subtraction ⌨️ (06:17:24) Matrix Multiplication ⌨️ (06:26:01) Inverse of a Matrix ⌨️ (06:35:03) Use a Matrix to Solve a System ⌨️ (06:46:53) Use a Matrix to Develop an Equation ⌨️ (06:56:15) Encoding and Decoding Messages ⌨️ (07:27:34) Inverse Matrix to Solve a System ⌨️ (07:43:13) Complex Numbers ⌨️ (07:58:31) Graphing the Mandelbrot Set ⌨️ (08:10:41) Sum of a Series ⌨️ (08:32:08) The Number e as a Series ⌨️ (08:37:48) How e relates to Sine and Cosine ⌨️ (08:47:54) The Beautiful Math Formula ⌨️ (09:05:00) Probability ⌨️ (09:15:18) Pascal and the Triangle ⌨️ (09:26:45) More Probability Applications ⌨️ (09:44:52) The Math of Gambling ⌨️ (09:53:40) Certification 5 Walkthrough ⌨️ (11:16:10) Organize Your Colab Notebook ⌨️ (11:41:51) A Few More Useful Formulas ⌨️ (10:59:43) Simplify Trig Expressions ⌨️ (12:02:30) Conclusion 🎉 Thanks to our Champion and Sponsor supporters: 👾 davthecoder 👾 jedi-or-sith 👾 南宮千影 👾 Agustín Kussrow 👾 Nattira Maneerat 👾 Heather Wcislo 👾 Serhiy Kalinets 👾
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from freeCodeCamp.org · freeCodeCamp.org · 0 of 60

← Previous Next →
1 React: Production Server Setup Part 2 - Live Coding with Jesse
React: Production Server Setup Part 2 - Live Coding with Jesse
freeCodeCamp.org
2 cookies vs localStorage vs sessionStorage - Beau teaches JavaScript
cookies vs localStorage vs sessionStorage - Beau teaches JavaScript
freeCodeCamp.org
3 Browser history tutorial - Beau teaches JavaScript
Browser history tutorial - Beau teaches JavaScript
freeCodeCamp.org
4 Graph Data Structure Intro (inc. adjacency list, adjacency matrix, incidence matrix)
Graph Data Structure Intro (inc. adjacency list, adjacency matrix, incidence matrix)
freeCodeCamp.org
5 React: Parameterized Routing with Next.js - Live Coding with Jesse
React: Parameterized Routing with Next.js - Live Coding with Jesse
freeCodeCamp.org
6 React: Dealing with jQuery Issues - Live Coding with Jesse
React: Dealing with jQuery Issues - Live Coding with Jesse
freeCodeCamp.org
7 setInterval and setTimeout: timing events - Beau teaches JavaScript
setInterval and setTimeout: timing events - Beau teaches JavaScript
freeCodeCamp.org
8 Browser and Device Testing - Live Coding with Jesse
Browser and Device Testing - Live Coding with Jesse
freeCodeCamp.org
9 Last Minute Updates - Live Coding with Jesse
Last Minute Updates - Live Coding with Jesse
freeCodeCamp.org
10 Post Launch Updates - Live Coding with Jesse
Post Launch Updates - Live Coding with Jesse
freeCodeCamp.org
11 React: Setting Up Google Analytics - Live Coding with Jesse
React: Setting Up Google Analytics - Live Coding with Jesse
freeCodeCamp.org
12 React: Masonry Layout - Live Coding with Jesse
React: Masonry Layout - Live Coding with Jesse
freeCodeCamp.org
13 Load Balancing Digital Ocean Droplets - Live Coding with Jesse
Load Balancing Digital Ocean Droplets - Live Coding with Jesse
freeCodeCamp.org
14 try, catch, finally, throw - error handling in JavaScript
try, catch, finally, throw - error handling in JavaScript
freeCodeCamp.org
15 Load Balancing: SSL Passthrough Setup - Live Coding with Jesse
Load Balancing: SSL Passthrough Setup - Live Coding with Jesse
freeCodeCamp.org
16 Graphs: breadth-first search - Beau teaches JavaScript
Graphs: breadth-first search - Beau teaches JavaScript
freeCodeCamp.org
17 React: Masonry Layout Part 2 - Live Coding with Jesse
React: Masonry Layout Part 2 - Live Coding with Jesse
freeCodeCamp.org
18 React: WordPress API Live Search - Live Coding with Jesse
React: WordPress API Live Search - Live Coding with Jesse
freeCodeCamp.org
19 Creating WordPress Custom Post Types - Live Coding With Jesse
Creating WordPress Custom Post Types - Live Coding With Jesse
freeCodeCamp.org
20 Dates - Beau teaches JavaScript
Dates - Beau teaches JavaScript
freeCodeCamp.org
21 Miscellaneous Front End Updates - Live Coding with Jesse
Miscellaneous Front End Updates - Live Coding with Jesse
freeCodeCamp.org
22 Merging a Pull Request from GitHub - Live Coding with Jesse
Merging a Pull Request from GitHub - Live Coding with Jesse
freeCodeCamp.org
23 React + Prettier + Standard JS - Live Coding with Jesse
React + Prettier + Standard JS - Live Coding with Jesse
freeCodeCamp.org
24 React: Sortable Responsive Table - Live Coding with Jesse
React: Sortable Responsive Table - Live Coding with Jesse
freeCodeCamp.org
25 Geolocation Sorting by Distance - Live Coding with Jesse
Geolocation Sorting by Distance - Live Coding with Jesse
freeCodeCamp.org
26 Tradeoff Matrix - Agile Software Development
Tradeoff Matrix - Agile Software Development
freeCodeCamp.org
27 The Definition of Ready - Agile Software Development
The Definition of Ready - Agile Software Development
freeCodeCamp.org
28 Getting first React job without experience - Ask Preethi
Getting first React job without experience - Ask Preethi
freeCodeCamp.org
29 React: Google Analytics Click Tracking - Live Coding with Jesse
React: Google Analytics Click Tracking - Live Coding with Jesse
freeCodeCamp.org
30 Submitting a PR to an Open Source Project - Live Coding with Jesse
Submitting a PR to an Open Source Project - Live Coding with Jesse
freeCodeCamp.org
31 Should I go back to school to get CS degree? - Ask Preethi
Should I go back to school to get CS degree? - Ask Preethi
freeCodeCamp.org
32 Hero Section CSS Changes - Live Coding with Jesse
Hero Section CSS Changes - Live Coding with Jesse
freeCodeCamp.org
33 Working Agreement - Agile Software Development
Working Agreement - Agile Software Development
freeCodeCamp.org
34 A day at Pennybox with Co-Founder Reji Eapen
A day at Pennybox with Co-Founder Reji Eapen
freeCodeCamp.org
35 React: Sorting and Filtering Data - Live Coding with Jesse
React: Sorting and Filtering Data - Live Coding with Jesse
freeCodeCamp.org
36 React: Sorting and Filtering Data Part 2 - Live Coding with Jesse
React: Sorting and Filtering Data Part 2 - Live Coding with Jesse
freeCodeCamp.org
37 React: Building a New UI - Live Coding with Jesse
React: Building a New UI - Live Coding with Jesse
freeCodeCamp.org
38 Definition of Done - Agile Software Development
Definition of Done - Agile Software Development
freeCodeCamp.org
39 Getting started with jQuery (tutorial) - Beau teaches JavaScript
Getting started with jQuery (tutorial) - Beau teaches JavaScript
freeCodeCamp.org
40 Making a React Blog with WordPress Content - Live Coding with Jesse
Making a React Blog with WordPress Content - Live Coding with Jesse
freeCodeCamp.org
41 React, NextJS, CSS - Live Coding with Jesse
React, NextJS, CSS - Live Coding with Jesse
freeCodeCamp.org
42 jQuery events - Beau teaches JavaScript
jQuery events - Beau teaches JavaScript
freeCodeCamp.org
43 React/NextJS Routing and WordPress API Custom Types - Live Coding with Jesse
React/NextJS Routing and WordPress API Custom Types - Live Coding with Jesse
freeCodeCamp.org
44 React: Working with API Data - Live Coding with Jesse
React: Working with API Data - Live Coding with Jesse
freeCodeCamp.org
45 React: Refactoring Components - Live Streaming with Jesse
React: Refactoring Components - Live Streaming with Jesse
freeCodeCamp.org
46 jQuery effects - Beau teaches JavaScript
jQuery effects - Beau teaches JavaScript
freeCodeCamp.org
47 More React Refactoring - Live Coding with Jesse
More React Refactoring - Live Coding with Jesse
freeCodeCamp.org
48 animate in jQuery - Beau teaches JavaScript
animate in jQuery - Beau teaches JavaScript
freeCodeCamp.org
49 "Finishing" My React Site - Live Coding with Jesse
"Finishing" My React Site - Live Coding with Jesse
freeCodeCamp.org
50 Starting a New React Project (P2D1) - Live Coding with Jesse
Starting a New React Project (P2D1) - Live Coding with Jesse
freeCodeCamp.org
51 React Project 2 Day 2: Learning Material UI - Live Coding with Jesse
React Project 2 Day 2: Learning Material UI - Live Coding with Jesse
freeCodeCamp.org
52 The Agile Manifesto - Agile Software Development
The Agile Manifesto - Agile Software Development
freeCodeCamp.org
53 jQuery: get and set with http, text, val, and attr - Beau teaches JavaScript
jQuery: get and set with http, text, val, and attr - Beau teaches JavaScript
freeCodeCamp.org
54 React Project 2 Day 3 - Live Coding with Jesse
React Project 2 Day 3 - Live Coding with Jesse
freeCodeCamp.org
55 The INVEST approach to product backlog items
The INVEST approach to product backlog items
freeCodeCamp.org
56 React Project 2 Day 4 - Live Coding with Jesse
React Project 2 Day 4 - Live Coding with Jesse
freeCodeCamp.org
57 Chickens and Pigs - Agile Software Development
Chickens and Pigs - Agile Software Development
freeCodeCamp.org
58 React Project 2 Day 5 - Live Coding with Jesse
React Project 2 Day 5 - Live Coding with Jesse
freeCodeCamp.org
59 jQuery: add and remove DOM elements - Beau teaches JavaScript
jQuery: add and remove DOM elements - Beau teaches JavaScript
freeCodeCamp.org
60 React Project 2 Day 6 - Live Coding with Jesse
React Project 2 Day 6 - Live Coding with Jesse
freeCodeCamp.org

This video course teaches college Precalculus concepts with Python code implementation, covering topics like trigonometry, graphing, and data analysis. Students will learn how to apply mathematical operations to data, analyze and visualize data using Python, and implement machine learning concepts.

Key Takeaways
  1. Set up Google Colab and create a new notebook
  2. Import necessary libraries and load data
  3. Apply mathematical operations to data
  4. Analyze and visualize data using Python
  5. Implement machine learning concepts using Python
  6. Use pandas to read and manipulate data
  7. Use matplotlib to visualize data
  8. Apply trigonometric concepts to solve problems
💡 Precalculus concepts can be applied to real-world problems using Python code implementation, and machine learning algorithms can be used to analyze and visualize data.

Related Reads

Up next
Marks Weightage | Quantitative Aptitude CA Foundation September 2026 | ABC Analysis | Nithin
ArivuPro Academy
Watch →