we will go beyond the abstract, how will latex go beyond the abstract, if you remove this end document there, why do not we put it little here. So, we will compile until here now. So, all this text instead of what I am doing is for the purpose of explanation in order to save time, this entire tech file is already written, thanks to our FOSSI employees. Now, I am just moving the end document lower and lower, so that more and more of the tech file will get compiled by PDF latex, this for our convenience, actually what you would have to do is you would have to type all this on your own terminal. So, there is this end abstract, after that we have gone to section, so there is a slash section, section name has come as introduction, then there is some content here, psi pi, how it is supposed to be pronounced is written here. So, there is actually no underline here, it is just you do not have to type an underline. So, after the break I will set the terminal, so that these things are more readable. So, there is open code, this open code again is different from this particular code which is closed code, the vertical code in latex is closed code. In latex you need separate symbols for opening and closing code, in Microsoft office, in open office, the same symbol will automatically work as open or closed, depending on first all odd occurrences of that symbol will be open, all even occurrences will be closed, but that is not how latex works, perhaps this is my only discontent with latex, that open or closed you have to tell it explicitly. So, with where is the symbol, this symbol is again above the tab key, above the tab key that symbol below the tilde, that symbol will mean open, if you put two of it will be double codes, double open codes and double closed code. So, why do not we compile this now, so here Glimpset sci-pi for C is the author, abstract is come, some font, this particular content has come in the actual font, this is the actual 10 point font, why 10 point, because notice that in our document class we did not give any arguments, optional arguments, that is why the default is 10 point, section has already got numbered as 1, section name has come here in bold larger font, then the main content, what has come after section comes like this, notice that let me make this little larger, this is open source of sci-pi itself, it is name of a package within python, how is it pronounced sci-pi, sci just like in sci or in scientific, sci for scientific, pi for python, pi. So, this is the content, do not worry about this content, why because you can type anything, what we should be worried about are these question marks, why did this question mark come, you will see a little later in this course, right now we are concerned with this, we are concerned with how to get certain things in italics, in different font, octave, these are all italics font, somebody has asked normally below abstract we have keywords, extremely important, how do you put the keywords, somebody has asked on chat, after the abstract we put keywords, extremely important comment, we will address this right away, that is another question on chat, I tried giving latex file name in command prompt, but I got an error in include graphics, why should I use PDF latex only, so the error about latex versus PDF latex, its significance in graphics that is something we will see a little later, for the specific person who asked about whether to use latex or PDF latex, because you use latex, graphics is giving a problem for that purpose, go to use package and just comment that line, use graphics, use package graphics, if you comment it, it will work, why because up to now anyway we do not have any figure, we do not have any graphics yet, so it will not matter, if you comment out that line, why use package graphics you have included, but you have anyway not use graphics features, that is why you can just comment out that line and do latex if you want, I would recommend that you use PDF latex, so that you are in sync with us, but then if you want to use latex, you please comment out that line, use package, let us go back here and see on the top, we commented out listings, because somebody said there is an error, graphics, please note actually there are two packages, graphics is the one, is the correct spelling actually, but graphics with the x is a another package, these are two different packages, whether graphics will work on latex or not, we are anyway not using a graphics features, we are not having any figure into our document, why do not we just comment it out now, when we have a graphics, when we have a figure in our PDF file or when we have a, when we want to include a figure into our document, then we have to use this package, if you use it unnecessarily, PDF latex seems to not give an error, latex now wants to, graphics certain packages work only for PDF latex, I was telling, so graphics with the x I think is such a package, color, color also is not anyway being used, you can comment that out if you want, no math symbol has been used, you can also comment that, listings give an error to somebody, that is why we ask that you just comment it out now, if it is not giving an error just let it be, so that same particular document has got created, this time without the graphics, graphics with the x, without that x, graphics package, we were, the next important question is how to insert keywords, so I am sure there is a way to put keywords, so let me just tell you what I do, I say keyword should be also be in bold, keyword 1, keyword 2, some people also put keyword between, separated between semicolons or semicolons, so we can always put it like this, because we want it to be in bold, we have put slash bf, bf stands for bold phase, how to put it, slash bf will suddenly make everything that comes after it in bold, but it will end up making the whole rest of the document bold, we do not want that, that is why we have enclosed it between curly brackets, curly brackets means that particular slash bf whatever you have put there will have its effect only between those curly brackets, its effect will not spill out, spill out to the rest of the document, so that is the meaning of curly bracket, if you just put slash bf you can check that the rest of the document will become bold phase, maybe rest of the document will not become bold phase, because look it may not come out of this environment, these environments are also like some borders, certain effects will not spill out, spill out of the environment, but whether that will spill or not you can check, meanwhile you can put this curly bracket that is certainly safe, if you do this then we have put this keywords, keywords has come, keyword 1, keyword 2, they have come in the same font as abstract, but they have come as bold because we put slash bf, rest of the document has not become bold either because we have enclosed slash bf between curly brackets or because at least curly brackets is certainly going to have this effect that the effect that bf will not make the rest of the document bold, environment abstract might also ensure that the effect does not go out, these are the things we typed, keyword 1, keyword 2, we forgot a space between here, so this is sticking, let us go back to our tech file, you can put a space, if it is the last character on that line and here is first character, then automatically space is left here, now keyword space has come here because end of the line character here, here, this is how one puts keywords, keywords typically if you want them to be in bold, this is how we can do it, if there is another way to do it you can try that also, you will have to look up on the net, at least I use this because this is really easy anyway, if it were really complicated I would have searched on the net, somebody has said even after typing end document after the make title, I am getting 7 pages after compilation, I strongly think you have not saved the document, open the document in an editor, open the tech file in an editor, whatever changes you make you have to save it, then only from the prompt when you do pdf latex, the latest, the saved version is all that will get compiled, if it is somebody is saying it is already saved, then you just open the document and see what is there remaining, there cannot be 7, 6 blank pages, I am sure that there is a problem at your end, you send the tech file to us, we will compile it, there has to be error at your end, I was just answering somebody's question on chat, what is the next thing we will see, section, we already saw introduction section, why are there no chapters, directly we have sections, because we are using document class article, in a article, in a conference paper article or a journal paper article, in a article you do not have section, you do not have chapters in an article, in a article you will directly have sections, when will you have chapters in reports, in books, in books certainly we have lots of chapters, if you are expecting to write your document in chapters, then most likely you are writing a report or a book, in that case you should go and choose document class book, because we are writing document class article, let us just verify this, we have to verify two things, this is my tech file, look I have said document class article, what I had not told was, I had not specified the font size, let us specify 12 pt, pt stands for point, 12 points, that is the way of indicating the size of the font, there is nothing latex about this, this is used in Microsoft windows environment also, the font size is specified in the points, pt, 12 pt means larger, why default is 10 points, I am saving it now, now document has become little larger font sizes, font sizes have become larger, also we are saying that directly we have introduction, because we have section names, so let us go back to this, section, when you say section, whatever comes in the curly brackets is the name of the section, inside section is where you will put sub section, then you can have sub sub section, any number of sub sub sub, any number of sections, sub sections, all these are automatically numbered, we do not have to give the numbers, it is very important that we should not be specifying the numbers, never specify any of these numbers, when will you specify the number, if you are going to say pi is equal to 3.1415, only those places you have to put the numbers, whatever numbers like section 1, section 2, those numbers latex will generate, latex will generate it and put the numbers automatically, not just for convenience, it is extremely important that you do not put the numbers, you will never put table numbers, you will never put equation numbers, you will not put chapter numbers, sub section numbers, figure numbers, these numbers you should not put yourself, why you should not put yourself, you might say I want to put the numbers, why should latex put, I will put it, this you might say this is some optional feature, no this is not optional feature, latex and only latex should put this, why, because if you decide some particular equation is equation 4.2, if you think that some particular section is section 1, later on if you put another section before this, then the number would have to be changed manually, but if you allow latex to automatically generate this number, then latex will compile it, that is when you have to compile it 2 times, that is when it will automatically know that this section has, is the second time it occurs, the second time the section command is called inside the document, it will automatically be section number 2, similarly sub section numbers, sub sub section numbers, all these numbers should come automatically only, please never make a mistake of putting equation numbers, section numbers, but when you are in the document when you are referring to, please see equation number 4.3, how do you know which number will get generated, how do you know if the number will change or not, what to do there we will vary little later today, for now section numbers are generated automatically, not just generated automatically, you should use only that automatic generation feature, never try to put the number yourself, never try to quote the generated number yourself, there might be a situation that you do not want the number to come, sometimes for appendix for example, you do not want appendix to be chapter number 18, it is appendix, there are certain sections for which you want the section title to come exactly like the title of any section comes large, bold, but you do not want the number to come, so if you put a star slash section star, then that number will get prevented, this is what we can see in our document. So, here is our section, here we will put a star, where are we putting the star, section star curly bracket introduction, this star is not like an optional argument, it is not to be put in square brackets, as soon as you put a star not just for section, in most places where number gets generated, if you put a star number will not get this, number will not get generated, number will be disabled there, so why do not we save this file, go back to the command prompt, let I get and look introduction has again come in big bold font, number has not come here, this is the important difference that has happened because we put a star, page number of course has got generated, this is a first page, there is only one page, any other, let us see the next thing in the slides, for longer documents we use report or book, that is where first you will have chapter, inside the chapter is where you will have sections, you will have chapter 1, chapter 2, then subsection, section numbers, section, if inside chapter number 1, you will have sections numbered as 1.1, 1.2, 1.3, this is exactly the way we want for a book or a report, this particular one, just a name that we had to choose for the first chapter, it could also be introduction, the first chapter typically we call introduction, chapter introduction, introduction in curly brackets, sections have some numbers, typically subsections we do not put numbers, if you want the subsections also to have numbers, then so this is like a depth, first top level is chapters, the book is organized into chapters, then the chapters are organized into sections, the sections are organized are suborganized, sub-suborganized into subsections, in that sense this is like depth, so there is one counter, there are various counters in latex, these counters are all automatic, we never have to know about it, until you have to set it, so if this sec num depth, if you think that subsection also should have numbers, then you can set counter the depth of the sec number, section numbering, the sec num depth is some particular counter that if you set 3, then the subsections will also get ordered, whether 3 or 4 or 5, this you can do trial and error, do not worry about these things, because these settings we do only once in a while, and that too for big projects, for books, chapters, how do you, had we not covered this in the slide, how would you do this, typically latex enough help is there on the net, and such things are there in any guide, any latex document guide, if you just do set counter, if you look for set counter pdf latex on Google, you will get all the counters, appendix comes at the end, they automatically do not have numbers, that is the meaning of appendix, unless you want appendix 1, appendix 2, then often there are also numbered as a 1, a 2, a 3, they are given as large size as sections, as chapters depending on whether it is article or book, slash appendix will do these things, table of contents extremely important, we want in our book for example, that the table of content is generated automatically, why because we do not know which particular chapter will begin in which page, even if you know now, tomorrow you include a figure, and suddenly the document has become little longer, and the chapters are beginning at different page number now. So, table of content is something that that is something that should be automatically generated, all the page numbers and all will come. So, what you can try later is you should just compile, and you should compile 2 times, why because first time it will find out what all section names are there, what all chapter names are there, and it is written on to one talk file, TOC file, TOC means table of contents, that same file name dot TOC is a extension, and when you recompile that time this table of content is actually built. So, table of content when you put that command into your tech file, when you put into your tech file, where will you put it, typically we want table of content to come after the title of the book, table of content we require only for books, we do not put it for articles, unless the article is very big, we do not put a table of content for the article. In the document class article if you put table of content what happens is something you can check yourself. Table of content is what we will put typically in a book or a report, if you have done document class report or document class book, table of content you will put after the title page, wherever you put the table of contents that is where the table of contents will appear, but it will appear only after you have compiled at least 2 times, why because the first time the TOC file is generated, first time latex will read line by line, find out where all which all page numbers the chapters are occurring, all that information is written into a TOC file, but table of content was anyway supposed to come in the second page of that book, first page was title page, second page, when it was generating the second page it did not know, where all the chapters will begin, that is why you have to recompile this, when I do recompile again again it is in general not essential, it is essential for example, when you want table of contents. Any book number, any section number, all this page figures, all the numbers come by themselves, if you want some, if you want the table of contents to in addition have some things, if you also wanted to have some extra information, then you can also use add contents line, this is some particular command that will tell you in the table of contents also add this, section intro, these are optional things, if you want all the sections that are generated to come, you can do this automatically, but some of them which are unnumbered, if you want to include them, this is how one does, references, bibliographies, how to do them that we will see later. Now, we have to come back to that particular topic that how did that word MATLAB, octave, how did those words appear in italics, those things is what we will see now, open code which is also called accent, that is the left code, that is the opening a code, close code which is also called apostrophe, when you want apostrophe, when you say Roshan's motorcycle, Roshan's motorcycle that apostrophe there you get by putting the vertical code, that is also the right code, the closing code. So, double code just use the same symbol 2 times, if you use the same symbol 2 times, they will occur very close to each other in the final document and it will indeed be a double code, yeah we can try this, we can try this in our tech file, here is our tech file, use sorry why do not I use open code for opening and close code for apostrophe, like Roshan's motorcycle, strange, as I said do not worry about the underlines, when you type underline then will not come, here is the document we have written, use open code for opening, yeah and close code for apostrophe or closing, like Prashan's, here notice how this is different from this, yeah we can make a larger font, this is open code, open code is different from this, here we have apostrophe, this see open and close are really different, this is one thing even though you do not have to specify open and close separately in most other packages, the font is not as nice as this, but then while you may or may not spend so much time admiring the font, please do not make a mistake of this opening and closing, yeah open code, open opening a code always use the open code symbol that is sitting right above the tab key, slash m that gives emphasis, emphasis to the text, yeah, will it be italics, whether it is italics or not we will see very soon, but if you are writing in normal Roman font, whatever you want in italics, whatever you want it to be in emphasized way for that you will use slash m symbol, yeah we will see that very soon, slash left, slash right center, these are things you can both use as a command and as an environment, yeah we can quickly see some examples of this now, so let us go back to this, here there was a slash m, slash m was opening there and it was closing here, yeah here is where m closes, emphasis from here up to here, yeah we can go for a smaller word, example of very emphasized text, if you want to emphasize something, then underline is not a good thing anymore, once you just put it in different font automatically that gets more attention, I have to use underline or bold is not the recommended way, that is if you want extremely lots and lots of emphasis, that is when you will make the font sizes larger or bold or underline, if you want just some moderate more emphasis then just use m, so let us write this compile this here, see here it has become very emphasized, this is the part in which off word, off word was outside the slash m curly brackets, then we started a slash m and everything this entire thing was given as an argument to the slash m command, so this is the recommended way to have a different font, why we should not use italics font, because some environment will automatically change the font, that time slash m will itself change the font, as long as the font of the few words are different, you are happy about this, somebody said font size except 10 or 12 could not be used with example documents, is there any way to increase it, yeah 10, 11, 12 these are the three things that are default, unless its presentation the other fonts are not available to the best of my understanding, we will quickly take a question from Rajlokshmi engineering college Chennai, please ask. Sir how to get the same font as latex as your name, latex itself, we will say latex, as I said T-A-X is like in technology latex, so latex itself has made a special command for itself, latex is written in some very nice font, are there any other questions before we start answering this, if please hold on let us just try this, so here if you do slash latex, slash latex is a command when you compile, when you do latex, when you compile it then you get this, yeah latex very soon we all will acknowledge that latex is very special and if it is so special, so look they have made a nice when you inside latex they have made this, that latex L will be big, A will be small, T again, E is slightly below X, yeah it is very hard to make these letters come in slightly different fonts, slightly above slightly below, in general these are hard, because it is so hard latex has made one such command for itself, latex will automatically become very nicely, so this is more like some we always write God with G capital, yeah like that, latex has made this nice symbol for itself, yeah any other questions about font size changes that we will see, but about latex it is very hard to do this, how to make this A go slightly above slightly below, these are things are, these are very much possible, but we will not see in this course, we will not see that in this course, these are things that are doable using picture, using picture begin picture end picture where you can put negative spaces go slightly above slightly below, but for latex if you want latex just use slash latex, let me just show the command L capital T capital X capital, only these three capital, yeah other two smalls, you might notice that first I had typed all small, so all the latex commands are very much case sensitive capital or small if you make a mistake in the commands it will give an error, it is unlikely that both capital and small are an error, look at this, so it is giving an error, yeah undefined control sequence, now that we have got this error, this is a good time for me to stop and tell, look we have not come to the command prompt, yeah this is where we will start discussing about this for the next few minutes, but notice that why it has given this error because latex command has not been typed correctly, what is incorrect about it capital small we have gone wrong, yeah. So, with that we will come back to this discussion about command prompt, so now coming to this problem that you when you are compiling then it said that when you are compiling on this particular line there is a problem, yeah it just says undefined control sequence, of course here also there is something undefined, actually this is the cause that there is some question mark coming again again, yeah how to resolve this we will see a little later, but notice that this is only a warning, you will pay close attention to what is only a warning and what is an error, because it is an error it says undefined control, it says an error and look it has ended with question mark, yeah that was not how we had actually our dollar prompt, our dollar prompt was this was our dollar prompt and when we do pdf latex it ends with the question mark, yeah whatever your prompt was it will end with the question mark, because it found something that is an undefined control sequence, yeah it is expecting for you to type something, if you do not know what to type press x and come back to the prompt x is what you will type to come back to the command prompt, now this is regular linux command prompt the terminal prompt about which we discussed in so much detail one week ago, but then as soon as you press x no pages of output, yeah of course there is still some output here that is because that this one was already compiled the previous time, this one was this is still existing, but now in the new compilation no pages of output have been created, why we why had no created it actually found an error and when it asked you the question mark when it asked you we pressed x, x is like exit what else could we do now again we try to latex there is an error actually it says undefined control sequence we are supposed to read all this, yeah all this reading is avoided if you use Kyle that is why I hate this integrated environments until you become used to all this, yeah Kyle also inside some information will be there for sure what one can do is so when it says undefined control sequence what are the various commands that are visible slash m is one command slash latex is another command one of these two commands do not exist they are undefined undefined control sequence either slash latex or slash m is undefined it is undefined that much hint is already being given, yeah luckily it was undefined control sequence so you know one of the commands do not exist that I did not remember that LT x have to be capital we do not have to remember so many commands as soon as you see that something undefined control sequence I knew it had to be with this capital small thing instead of pressing x one can press enter, yeah in spite of there being an error you press enter and now it has created output written on this, yeah we actually we did not remove the error the latex error the undefined control sequence we did not remove we just press enter instead of exiting we press enter and now output written let us go back to our output and see what has happened, yeah it has it has that latex has nothing has come on the screen so wherever that error was there there it will just ignore it will ignore whatever that command was supposed to do, yeah this to ignore that error you go ahead and compiling it is a extremely bad practice I see more and more of this with various students in our IT also that they do not remove the latex errors they just compile whenever there is an error for example they do whenever there is an error they just press enter if there are plenty of errors of course here there is only one error you press enter once it did not encounter any error let me tell you a shortcut if there are hundred errors you can press R R means it will go to so called running mode, yeah see ok entering non-stop mode latex provides you do not want to remove errors ok entering non-stop mode any further hundred modes and hundred errors it will not remove it will not stop for you of course if there is a error the document will not get compiled properly so let me warn you always you will keep track whether you have come back to the command prompt or not in other words whether you could do PDF latex without any errors so these are errors on the other hand there were some undefined references these are just warnings, yeah please pay close attention to what is an error what is a warning and in any of your assignments if you submit if you submit a tech file that does not even latex properly which is giving errors not just giving zero marks we are going to give negative marks let me warn you yeah please please do not tell us later that we did not warn you let me warn you again if you come to the prompt that means your latex perform without any errors coming to the prompt is top priority if it does not if your tech file that you submit does not latex properly does not latex properly means there are some errors you do not come back to the prompt when we will latex it see we will latex it here and see then we will give you negative marks ok so we are connected to Jaipur college cook us for a question from there please ask yes I have created the table of content file using add table of content but can you tell me the way how to get this file or how can read the file what command I should use on the latex prompt ok if I understand your question is that when you put slash table of contents into the tech file you compile it as I said you have to compile it two times then the table of contents has got generated if you have put slash table of contents it will get generated it will also come in the final PDF file it will come in the output already that we do not have to actually go and see the TOC file the TOC file we are not required to open and see what is written there it will have some information it will have what information this chapter begins on this page number this file this chapter begins on this page number this section begins on this page number this information is there in some nice formatted way I would recommend all of you to see it out of curiosity why only out of curiosity because the document that is getting generate the PDF file will anyway have table of contents page if there if there are many sections and chapters it will have two three pages of table of contents but the TOC file we do not have to open and certainly we should never edit the TOC file why we should not be editing the TOC file TOC file is automatically generated you spend lot of hours editing it you you think that some font size should be larger chapter name that comes in the table of contents page is not coming in good font you want to change the font you change all the font you do PDF latex once and the TOC file is again overwritten all your efforts in editing that file are gone based hence TOC file you can open and see out of curiosity editing it is totally useless unless you are sure this is the last time you will do PDF latex I have done in my in the past I didn't know how to change some particular font size so I went and edited the TOC file directly because I knew this was the last time if you are going to do PDF latex again it will override the TOC file any other question did I answer your question okay we are connected to Rajakshmi engineering college Chennai for a question from there so how can I add graphic the question is how can we add images and figures into our particular document this is indeed a very important topic we will cover it very soon it is there in our slides we will cover it very soon


My name is Rain Revere and I'm a smart contract developer. I'm the lead architect at Shapeshift Prism and I'm also the co-founder of Maiden. I've been doing smart contract development for a couple of years and our team has learned so much along the way and it's really an honor to be here and to be able to share some of those lessons with you.  I'm a trans woman and I love this work and the community is so amazing and so it's such an honor to be able to share some of this expertise and really dig into the details. So when I was thinking about what I could possibly share, I wanted to give something that was really practical and so this talk is going to be pretty straightforward. We've got lots of things that we learn doing smart contract development in the real world so that means production level handling lots of Ether on the live network which as you can imagine has a lot of responsibility that comes with that. So what you can expect from this talk is that I'm going to go from low level to high level. So all of these are pretty practical tips for all the smart contract developers in here and I'm going to start with the code and we're going to go over some details, some patterns that I've learned and our team has learned from and then we're going to end on some higher level patterns especially when it comes to being a leader on your team. How do you lead as a smart contract development engineer? So first the low level patterns. Central logging is something that took me a little while to find my way to and when you design your smart contracts, you want to modularize things, right? We all know that as software developers but there's some quirks in the EVM at least at this time that you may not think about ahead of time but actually lead to a system that is more maintainable and is able to respond and communicate with your server or whatever other architecture you have.  In a multi-contract system, logs or events that are fired are really an important way to track what's happening on-chain. All of your off-chain activity is going to be based on different events that are firing and when you are firing events from different contracts you generally have to monitor those events separately so each contract you're going to be watching those events and so if you have a multi-contract system there's actually a lot of benefits to using a single logger contract and so when you have a single logger contract all of those events will fire from the same contract and are easier to monitor so let me just show you how that looks. So here's an example of the logger contract and what we have here is a whitelist that maps addresses of contracts to a simple boolean that says whether it's been approved or not. So this is where it handles multiple contracts. So those addresses are of contracts and you have a modifier that's a simple requirement that the sender is indeed in that whitelist and so the modifier whitelisted is provided here and then you can have any event, here the event is called registered so that's the red text with the two superscripts and the registered event is simply forwarded from the log registered function. So if you have the owner which is provided with the owner super contract and then the only owner modifier, pretty standard you can have an owner contract that is able to register all the contracts in the system so contract A, contract B, contract C all of those would be an authorized contract to be able to register those and if that authorized address was set in creation then you know exactly who has the ability to register new contracts and then those contracts have the ability to call log registered or any event. So that's an example of central logging and that's been super helpful for us to be able to handle large numbers of events from lots of different contracts in a multi contract system. The next one I want to show you is the idea of modular libraries. So libraries in Solidity, if you're not aware already are a way of deploying code once that other contracts can use over and over and when you have a multi contract system or you're deploying a new contract for every iteration of something there's a lot of gas costs in that and if you can reference, if you can link a library that's going to save a lot of gas compared to implementing compared to deploying all the contracts again. So libraries are well known to provide that gas saving mechanism and the idea of modular libraries is the idea that you can link multiple libraries together in order to provide some abstraction layers. So these are all like architectural patterns for you to have more maintainable smart contract code. So what does this look like? A modular library is one in which the contract itself doesn't have to know about all of the different modules and so it's a way to encapsulate functionality within a library in order to have some separation. Now libraries are linked and all of the calls end up appearing internal so this doesn't actually provide, this is more of an organizational strategy than changing the actual access levels. So here's an example for the Prism Projects we have a library called Prism Lib and there's a lot of different pieces of data and libraries that have functions that operate on that data and as a way to break it into smaller pieces one good method is to have a data struct in each of the libraries that's defined in each of the libraries and then that can be included in the contract and so you have nested levels of data so the struct is defined, you can see in the blue with the number one is the data struct and then that's being expected to pass into each of the functions so the rebalance function on the Prism Lib is going to ask for the prismlib.data and then the nested nature comes from the fact that portfoliolib has its own portfoliolib we can assume is that libb and it's being imported somewhere else so portfoliolib we can assume has its own data struct so portfoliolib can be accessed the functions can be called in portfoliolib and the data is contained within that lib and so there's an abstraction there if you notice we're not passing the entire prismlib.data to the rebalance portfoliolib.rebalance function we're only passing self.portfoliolib so the second red instance number two and so that way portfoliolib.rebalance or any other functions in portfoliolib don't have to know about anything else in the data so this ends up being a pretty standard abstraction and hiding mechanism but something that we haven't seen a lot about in the wild with library development but we found it to be a really great architectural pattern for prism so now we get to the last of the low level patterns that I want to share with you and this is a higher lower level pattern and this is an idea that has been shared in other talks here the idea of the blockchain as a court system and this didn't come to me until much later in the development of prism but the opportunity to save a massive amount of on-chain computation exists when you treat the blockchain as a court system or an arbiter which means that you assume that parties are acting in best with goodwill, in best interest but you have a mechanism that if something goes wrong, if one party says the other is not fulfilling their obligation then you can run an actual smart contract as if you're bringing it to court and when you run that, when you execute that smart contract then you're using the blockchain to orbit to be the arbiter of that transaction so what does that look like? so here we have a contract this is just a general, you have some users and there's going to be a counterparty the other end of the deal and you're using the smart contract the naive approach would be to execute everything on the smart contract when you have arbitration built in then instead, as I described you assume that both parties are acting cooperatively and correctly but you have the mechanism in place for a dispute resolution process so the top interaction here is where the user, through the smart contract interacts with the counterparty there's not any execution there's really nothing happening there there's not code that's being executed on-chain maybe just a hash that's stored that both parties can use to evaluate off-chain what's happening so user A maybe sends some ether to the contract after a certain amount of time the counterparty is expected to send ether back or some transaction occurs and at this level it's really up to the counterparty whether they want to do that or not now if the counterparty doesn't do their part you have a time window a week, a month, whatever the time window is where the user can file a dispute and that's all on-chain so there's a time window, the funds are locked up and so imagine user B has a problem and says yeah the counterparty didn't do their job so they send a dispute resolution transaction and this time the whatever business logic needed to be executed which could be quite expensive is going to be fully executed and because it is deterministic the winner of the dispute will always win so the beauty of this is that the incentivization is such that if you know you're going to lose you would never do the wrong thing so the counterparty has zero interest and the reason you force that incentivization to be aligned so strictly is that you say if you lose the dispute you basically lose all of your money so you punish the person for behaving against the expected behavior and so when done right there's really no incentive to go against the expected behavior you have user A acting expecting a certain thing back from the counterparty or the counterparty doing their job the threat of the dispute resolution process incentivizes the counterparty to do their part and the beauty here is that you're not actually executing the full contract logic on chain it's just user A doing their thing and the counterparty doing their thing so I see this as a potentially huge pattern that can be used across smart contracts in order to optimize reduce execution time and this is something that could be put to good effect on a lot of projects okay how's everybody doing you still with me the developers are the developers are like yeah this is cool okay so we have some higher level patterns and these are for you as well these are also for developers if you spend more than a couple years working in the software industry I hate to break it to you but you're going to have to do some things other than coding you're going to have to learn some other skills and some of those are going to be technical skills and some of those are less technical but what are the higher level patterns that allow you to be successful as a smart contract developer not just when you're in solidity land working with your team when you're making judgment calls when you're making important decisions about the direction of your product that the rest of your team is looking to you for so one is something that I call role analysis this isn't a technical term but role analysis how do you analyze the roles in the smart contract and this is something that you can use this is simply an approach to smart contract development and design and you can use it at any stage of the process so if you're designing a smart contract from scratch who is interacting with the system that's the main question you're asking here who is interacting with the system and what are their incentives and how does the behavior how are their behaviors going to derive from the functions that you expose to these different roles so I use this both in the design process but I also use this throughout the entire career of the smart contract system when you're iterating and you're adding new features there's always going to be adjustments to the behaviors of the different users and the different roles that are interacting with your system so to be a really good smart contract developer you have to understand all of the roles of individuals interacting with your contract what their different incentives are and how that affects the overall functioning of the system this is like the essence of the game theoretic nature of decentralized smart contracts so just some examples the prism contract for shapeshift prism has a few simple roles it has a buyer, a seller, and an oracle and with prism the buyer purchases a contract, a portfolio of different digital assets the seller is putting up collateral to ensure that those assets can be paid off depending on whether the portfolio goes up or down and then the oracle is another entity that's providing the prices that determines the value of the portfolio so different roles and even these simple three roles have involved a high level a high degree of analysis an ongoing analysis and the trust implications are well understood as the contract develops and becomes more sophisticated another example is a salt loan let's say you were doing a loan that was backed by digital assets that was collateralized by digital assets in this case you have a borrower someone who's borrowing cash and then you have a lender who's offering that cash but then locking up the collateral in this case you have salt as a kind of multi-sig arbiter to make sure that if anything funky happens with the other two salt is in there and can have the last word this is an example from a talk yesterday the liquid pledging contract was really I thought really brilliant idea to combine fund management with liquid and here there could be many arrangements but a simple arrangement is to have a giver who's providing some ether and they want that to go to a good cause or a good project they don't have time to do that themselves or they want to trust someone else so they delegate that to another role and that delegate is going to choose the project and eventually a reviewer is going to say yes these milestones have been accomplished and that goes through a simple concept but it goes really far and it really is what can separate someone who just knows solidity from someone who can design maintain and scale smart contracts on a live network context dependence is another skill that comes with experience and is something that is really valued on a team and by this I mean analyzing when one action is true in one situation the same action might not be true in another situation I know this is really scary for a lot of you I didn't get into development to deal with fuzziness and ambiguity either I love really straight forward and deterministic systems but the truth is any complicated problem is going to depend on a lot of context so one example in this space is that you hear a lot of best practices best practices are great but when they turn into hard and fast rules you can really miss out on the nuances of the situation so one I see a lot is send versus withdraw patterns and the advice out there is to always have the user withdraw never do a send so it's like push versus pull never do a send and I actually don't like this advice because it's often just taken without much thought why don't we do a send well we don't do a send because there's vulnerabilities if you're trying to send to multiple people you have to be aware that any one person their fallback function could throw they could use up all the gas they could use up most of the gas so there's risks to sending to multiple parties okay I understand that there are also situations where maybe you don't want for the user experience they don't have another transaction you don't want them to have to do that transaction so maybe the send would be appropriate in those cases keeping in mind this dictum of it depends on a professor in grad school who this was in my counseling program and it was beautiful every time anybody asked well what if you're working with this client and they do this what should I do she always answered she thought about it and then she said well it depends and that would be her answer every time so with skill and experience comes an incredible awareness of context and that's what makes you to think about context dependence and lastly I want to say leadership in blockchain at the developer level because contracts are immutable technical debt is much costlier so when you're making decisions as a lead engineer you have to make a lot of judgment calls because that code might be on chain for a long time and that's something to keep in mind thank you so much I'm going to share go over the patterns we talked about central logging modular libraries and arbitration as architectural patterns at a lower level and then at the higher level I hope you can take some of these concepts away about leading your team being more dependent on context and then bringing role analysis to everything you do thank you very much


So how do you, um, balance between like your relationships and your career? I'll be, I'll be, I don't want to say I'll be bushy and I'll be playing man, but I kind of Let it be what it's going to be.  He's gonna talk this game and then I know no I let you know I'm gonna put my career before you in every way shape or form until I'm able to suffice for me and you Okay, so unless you're gonna add to this and rock with this I'm sorry. I know it may sound real crazy, but it's just what it is. It's a part of the lifestyle. Yeah You know, I'm saying until I'm able to do what I got to do for us


Welcome back, lecture 9, Math 241. We left a problem on the table yesterday, so let's pick back up with that, and we'll be able to go into our next application of integration, which is volume. So the thing that's going to carry over in just about every application in chapter 6 is that we're going to break what it is that we're trying to find area under a curve, area between two curves, volume, which we'll start on today. We're going to break it into pieces, we'll try to analyze a description of one of those pieces, one of those little skinny little rectangles, one of those little slices of volume, whether it's a desk or a washer or whatever it is, cylindrical shell. We'll talk about the kind of generic description of that piece, and then we'll let integration add together an infinite number of those pieces for us. So remember what that funny looking integration s is related to, it's related to that other s, that sigma s, which is a summation of an infinite amount of things. So that's kind of how we're going to handle just about everything in chapter 6 as far as an application of integration. So we had a couple of parametric equations, and we wanted the area under that cycloid, one of the little loops of the cycloid, and we finished class yesterday with this equation. This is related to f of x dx from a to b, which we use in finding area under a curve. And f of x is really the same as y, we've treated it that way to this point, and y in the parametric equation was defined as a function of t, excuse me, a function of theta. This was what y was defined to be in terms of theta. f of x dx, well dx, this is the derivative of what x was defined to be in terms of theta. And then we're going to be integrating with respect to theta, so these values are kind of starting and stopping values as far as theta is concerned. So it's the same format, it looks a little different, it looks significantly different, but it still is kind of f of x dx in the integrand, and our limits are in terms of theta now, so therefore we'll be integrating with respect to theta. So we left with that, anything that we can simplify by pulling out in front of that. What things have to stay to the right of the integral sign, and what things can we bring out front? Bring out the r times the r, so we can bring out an r squared. And once we do that, we have one minus cosine theta, we have two of those, so that thing times itself d theta. So let's square that, two of the three terms that we'll generate will be kind of easily integrable, the third we're going to have to mess with a little bit more. So we'll square one minus cosine theta, we'll get one, the middle term ought to be twice their product, and the last term, which is a little bit of a stubborn term is that last term squared, which would be cosine squared. So we've got r squared times the integral of one d theta, gosh I can do that one, minus two integral of cosine theta d theta, I can do that one too. The last one is a little stubborn, but we've done this before. What did we do when we encountered either a sine squared or a cosine squared or a sine to the fourth, cosine to the sixth, we're stuck with an even power of sine or cosine. Okay, so we had that double angle or half angle identity formula, so for cosine squared of theta, what are we going to replace it with? Two theta, does that work? Now let's suppose you forget that, how could we come up with that in 45 seconds or less? I'll be honest with you, at this very moment I don't know that that's right. I mean I trust the two people that gave me that, but if I had to come up with that on my own right now, I don't know that I could do that. So do you have a backup if the memory fails? Yes. Cosine of two theta equals cosine squared theta minus sine squared theta. Okay, I would start with that. Cosine of two theta, that's a double angle identity, is that right? And if you have to go a step back from that, it would actually be cosine of theta plus theta, right? Cosine theta, cosine theta, minus sine theta, sine theta, so anyway you could get to that point. Well we want the cosine squared, so I guess we want to keep this around, right? And we want to, we're stuck with this, but we can get rid of sine squared and replace it with what? One minus cosine squared? Yes. I guess I'd better hurry because I said 45 seconds or less, right? What's cosine squared minus a negative cosine squared? Two cosine squared minus one, so what's left to do? Kind of validate that we're using the right double angle identity here, okay? So we'd need to add one to both sides and take half of each side. Does that work? I don't know if that's 45 seconds or less, but it's not too much to validate that we in fact have the correct substitution for cosine squared. Questions or issues with that? What if we wanted sine squared and you forget it? Can we still use this? And replace, keep that and replace that, right? With one minus sine squared. How does it differ from this one? One minus, right? Still got a half out in front, one minus cosine of two theta. So if we replace that in there, let's go ahead and integrate the things that we can integrate. What's the integral of one d theta? Would be theta? What's the integral of cosine theta d theta? So you're really asking yourself what has cosine for its derivative, right? Sine. Would be sine. And now for cosine squared we're going to replace it with this double angle identity. I'll bring the one half out in front. Okay, all this is the same. Let's get to the new part. We're going to have a one half. And then we're going to be integrating once again one d theta. What's that? Theta. Theta again. And we're going to be integrating cosine two theta d theta. Let u equal two theta. We need a what? Two in the integrand. Correct for it with a half out front? One half. We've already got the other one half. Sine. Sine two theta. So we've got everything at least either integrated. Well, everything's integrated now. This is done. All we have to do is evaluate. It's done. Evaluate from zero to two pi. And now we've integrated each piece of this so we could also evaluate from zero to two pi. So, and that's kind of typical I guess with a x in terms of theta and y in terms of theta that you're going to get stuck with something that requires this kind of substitution. So we're kind of stuck with a cosine squared. But we've handled that before. We just kind of have to dig back into what we substituted for that previously. Anybody question kind of how to get to an answer from this point? Everybody feel confident? You can plug in zero and two pi and subtract and get a solution. And that would be the area under one of the loops of the cycloid. I usually don't talk on my cell phone when I come from my office to here. And like yesterday it was really pretty and all the snows on the ground kind of contemplate different things. I talk enough. I don't need to talk additionally on the cell phone. Sometimes I get a call. I urge you to do that by the way is to kind of have some contemplation time rather than get out of class and you know start dialing everybody and where are you going? What's for lunch? You know, constant chatter. That's kind of what the world is like right now a little bit but just deny that sometimes. My cell phone's off right now. Sometimes I just leave it off and it's just wonderful. So when I walk places I get to look at nature and snow and you know it's just beautiful. I urge you to do that to turn the cell phone off. But I was doing that contemplation thing. You've already heard that before. Hemachinicole and Chandler and Kelly and Kate. Sorry you had to hear it again. But I was contemplating the fact that I didn't think I did a great job of the diagram yesterday of the cycloid. So let's address this once again and see if I can kind of fill in. So we've got this circle, circular something, that's here we're putting a dot on it and we're going to roll it along the desktop, this line, the x-axis and as we roll this circle along this thing tracks out what amounts to a cycloid and when we've rolled it along so that the circle is right back where we started, the dot on the circle is right back here. This is what I felt like I didn't do an adequate job of. Now we said to simplify things that the radius would be one, that helps but it doesn't have to be one. If we've rolled this thing along and we've tracked the position of that dot and it now is right back where it started we said that was 2 pi but in reality it's only 2 pi if the radius is one but isn't that distance from here to here the circumference of that circle, is that correct? So as you roll it out and the dot is right back where it started this ought to be the circumference and if the radius is one the circumference is 2 pi probably didn't do a good job with that yesterday so let's let me try to clean that up today. If it's not one what is the circumference? 2 pi times the radius. So if the radius is one it is 2 pi well we plotted a point yesterday and I kind of had to backtrack because I had already said that this was pi and this was 2 pi, well that's only true when the radius is one. If the radius is just open-ended and it's r then we would say this would be 2 pi r and this would be pi r, right? So I think we ended up with a point that we were trying to plot that was in fact pi r and I said let's make r equal to one just to make it fit the diagram but if r is not one this thing still works you won't be integrating from 0 to 2 pi you'd be integrating from 0 to 2 pi r and if you want to do it in terms of r that's fine you could have a final answer in terms of r we did the problem where r was one so this was pi and this was 2 pi but it can be done, let r just be r some open-ended number see what weird things I contemplate when I walk from here to Harrelson but I knew that I had not done justice to that yesterday let's go into 6.2 so remember the skinny little rectangle concept we want an infinite number of those added together we do that not by this summation but remember as we have an infinite number of these skinny little things that we're adding together that s, that Greek sigma becomes this s, the integration so we are able to add an infinite number of these things together as long as we describe them right here so if we describe one of them and we tell it where to start and where to end then we're in business we've added an infinite number of those things together so in 6.2 we're going to take I guess three distinctly different looks at volume and we're going to slice it up these are volumes of solids of revolution so we're going to have a figure in the plane we're going to rotate it around some axis either the x-axis or the y-axis or a line that's parallel to the x or y-axis and we're going to generate some three dimensional figure and we're going to use this concept of getting skinny little pieces or slices of it and add them all together using integral calculus so it is an application of integration this is probably way overly simplified but let's say we have some f of x in the plane and we start and stop the region bounded by f of x with some vertical line x equals a and x equals b so we start and stop it just like we did with the area and we want that region that's bounded by this vertical line, this vertical line the curve itself and the x-axis and we want to revolve that around the x-axis so here is our axis of revolution so I'm not going to be good at this but I have some pictures that are better than mine and you have shaded pictures in your book in section 6.2 much better than what I'm going to come up with here but if you can envision taking that region holding this fixed right here as an axis of revolution spinning that around the x-axis you'll come up with a three dimensional solid and it looks something like that and I'll show a picture that's better than this so you can envision this solid 3D figure our job is to first of all create the pieces that we can describe one of them it represents all of them and then we integrate it that adds together an infinite number of these skinny little pieces or slices together from where we tell it to start to where we tell it to stop so one of these slices much thicker than we actually want it to be we really want it to be as thin as we could possibly make them stack them all side to side and we have all the volume that we want from x equals a to x equals b but there's one of the slices now how do we form the slices so we're going to slice it up perpendicular to the axis of revolution so our axis of revolution is the x-axis so we form our slices this way chopping it up perpendicular to the axis of revolution we need to describe how much volume there is in this slice and hoping that all the slices and you may actually want to draw several of them to see that if we describe one of them in that fashion are they all really described by that same description so here's our slice actually let's position it a little differently that slice on its edge looks like this all of them do so what's the volume of something that looks like this what is it first of all that's a cylinder right little short squatty little cylinder what's the volume of a cylinder pi r squared h now if you know that then you can do any of these volume problems if you know that the volume of a cylinder is pi r squared h then you're going to be able to do this that'll kind of start you know you can memorize other formulas if you want to but this is the one that will kind of go all the way back to the volume of a cylinder that will get you started so we need to be able to describe the radius of each slice that we generate which is a little disc, a solid disc in this case everybody agree that those are solid if we take that region spin it around the x-axis we don't have anything hollow in the middle it's a solid disc here's a better picture this one at the bottom is what we're dealing with I'm trying some different colors I really have a problem with light blue so I'm trying some different colors even though we kind of have a stack of light blue paper up here not my favorite color so we've got this function we take the region they've divided theirs up into skinny little rectangles that's fine but when we revolve that around the x-axis we slice it up perpendicular to the axis of revolution and we get a bunch of discs, solid discs so that's what we're dealing with now how skinny do we want them to be a whole lot skinnier than this picture paper thin, in fact, even skinnier than paper thin we want our thickness to approach zero so what is the thickness what would we say that is? that's a delta x on this picture we want the thickness, which is the height really isn't it of each little short squatty cylinder we want that to diminish to practically zero when we allow that to happen then we have zero error we get the exact volume of this figure now that's if we're going around the x-axis where the x-axis is the axis of revolution we might take a curve and say the y-axis is the axis of revolution so we take this region, bounded y equals some initial value y equals some terminal value spin that around the y-axis we get a figure that looks like this since we're going around the y-axis we chop it up perpendicular to the axis of revolution and that creates solid discs in this fashion so these are really the same if we can describe one of the discs in this case a solid disc we'll use integral calculus to add them all together from beginning y value to ending y value so up here again we want the thickness to approach zero well what is the thickness up here it's a delta y so we're going to have dy's in our integrand and we're going to be integrating from y something y0 to y1 down here we're going to have a dx in the integrand and we're going to be integrating from x0 to xn but it's the same process now that's if we use one of the two axes as the axis of revolution and we might use a line that's parallel to them and we'll hopefully have enough time to look at an example I don't know, not looking good but at some point in time, maybe not today we'll get to that example as well so each piece is a solid disc and we want to find the volume alright, first example pictures help, pictures aren't absolutely necessary but pictures I think are going to help you to decide if do we have a solid disc well that's all we have at this point so that's what the first example is going to be but the next example is not going to be a solid disc we'll have to analyze how we find its volume so let's take, let's make it pretty simple and I've got a better picture of this so we're not just going to depend on my picture let's take the region bounded by y equals x squared x equals negative 1 x equals 1 and the x axis and we're going to take that region and we're going to spin it around the x axis so we'll have this three-dimensional solid so y equals x squared plus 1 looks like this negative 1 to 1 so there's the region that we're going to spin around the x axis so I think it helps to get that symmetric image again whether that helps give it a three-dimensional feel I don't know but it helps me kind of decide what I'm dealing with so I'll try to give this a little three-dimensional feel and I want to chop it up, slice it up perpendicular to the axis of revolution so there's a representative piece or slice so if we take that bounded region spin it around the x axis can you visualize the three-dimensional solid that we have? does that slice or that piece seem to represent any other slice or piece that I could draw? so if we can describe what the volume of this one is all of them are pretty much the same do they all have as we start at the axis of revolution and go out to generate the radius that's the radius would all of them have that same line segment as their radius? not that same one but could we describe it in such a way that it represents the radius of every disc? I think we can so from the x axis up to a point on the curve that's going to be the radius so we're going to I said that that would get you started it can get you started that's the volume of one of these little discs one of these little cylinders but we're going to need to know what the radius is how would you describe coming from the x axis up to a point on the curve what is that typically? that's f of x that's how we plot the point we put it into the function we go over that many units x units but we go up f of x units so the radius seems to be y or f of x what about the height or thickness what's the thickness of this particular slice or disc? it's going to be an increment of x some little small distance in terms of x that's created by how we chopped it up so it's going to be a delta x or I guess a little further down the road it's going to be a dx in the integrand we've got a better picture of this because mine is not all that good so here's a better picture of what we're dealing with here's our curve y equal x squared plus one stopping at one starting at negative one it's a solid three-dimensional solid and one of the slices or discs is pictured here so we need the radius now they have this described as w sub i squared plus one wherever we are w sub i we would put that into the function that's just telling you that that distance is the f of whatever the x value we're plugging in so if it's w sub i we'd plug it into this function and we'd get w sub i squared plus one so better figure but we don't have to be quite so subscripted that we put in all of the subscripted values we'll describe one of them we know what integral calculus does it adds them all up for us so pi this number we'll just bring it out front where are we starting these little pieces or slices negative one and that is an x value and aren't we going to be integrating with respect to x we are because we're going to have a dx in the integrand and we're going to stop it at one that's where to start and stop the skinny little discs pi is already taken care of we want the radius squared what is the radius it's the y value and what is the y value for this particular function x squared plus one so that's our radius squared and our height of each disc is an increment of x a little delta x which in the integrand for us becomes a dx so there's the integral calculus problem that will get us the volume of this three-dimensional region questions about getting to that point so that'll get you started pi r squared h volume of a cylinder if you want to memorize more beyond that then that's completely up to you but that should work so we've got a square this x squared plus one well maybe if we don't have to that's not squared if we don't have to use a u substitution can we let u equal x squared plus one we could try I don't think it's going to work why is it not going to work because we don't have another x in the integrand we need another x for du right we can't manufacture variable quantities inside the integrand we could change any problem we wanted to if we could do that so we are forced to square it first term squared twice their product last term squared it's not going to be bad so we're going to integrate x to the fourth dx x to the fifth over five integrate two x squared with respect to x two-thirds x cubed correct me if I'm wrong now and integrate one with respect to x I think I can handle that one negative one to one so we're going to have one-fifth plus two-thirds plus one and what all the negatives stay negative right everything's odd so negative one-fifth minus two-thirds minus one everybody feel confident you can put all that together right we're going to have two-fifths plus four-thirds plus two add that together multiply it by pi that's the number of cubic units of volume right that's the volume of a three-dimensional region questions about that integration is not going to be the hard part I mean occasionally we'll have to do some testy little double-angle identity or something like that that we've already done before but when you get to that point you're three-fourths of the way there questions before that one gets moved what would change if we took a similar shaped region and wrapped it around the y-axis instead of the x-axis our thickness or height would be delta y we'd be going from a y-value some initial y-value to some terminal y-value basically nothing changes right you just reference all your disks on how they're related how the radius is related to the y-axis instead of the x-axis okay let's try this picture and see how we think the region is going to be different from what we've looked at so far in terms of a solid disk we want to take the region bounded by these curves this is kind of a bizarre way to give you the equation but I'm giving it to you the way it was written I don't think this is a problem in this book I think I got it out of another source so we've got a parabola and a line two vertical lines and we want to take this region we're going to do two problems with this diagram we'll draw the diagram the first time let's go around the x-axis so it kind of looks like it's going to be the same type problem it's actually going to be very different so if we solve this for y this would be y equals x squared plus 2 very similar to what we had now we've got another line if we solve that for 2y 2y would be x plus 2 and therefore y would be one-half x plus 1 is that right? I think that's right so y equals x squared plus 2 and I'm going to start at x equals 0 so I don't need the other part of that so I want to start at x equals 0 stop at x equals 1 and the other one is this line y equals one-half x plus 1 so the y-intercept is 1 and the slope is one-half so there's our region that's bounded by the parabola of the line and the two vertical lines x equals 0 and x equals 1 so we want to go around the x-axis a little different isn't it? what's the result that's going to be different? why is this a different problem? it's not bounded by the x-axis okay we don't have the region all the way down to the x-axis like we did before or in the reverse situation we don't have it all the way over to the y-axis so when we take this and we spin it around the x-axis I'm not going to clutter it too much but this is going to probably clutter it what about that disk once we take that region and spin it around the x-axis it's missing some volume out of the middle so the disk is not a solid disk depending on the part of the country you're from it's either a washer or a washer I grew up where this was a washer but I've adapted and now I call it a washer but it's one of those two it's something that looks like this a donut or a bagel we'll go with that too but all those conjure up the idea that there's something missing right in the middle so this is not a solid disk it's a washer so we're not going to be able to start with pi r squared h because that's a solid disk so we need to come up with what the volume of a washer would be so a washer is really the entire solid disk minus the part that's missing out of the middle so if we want to come up with something like this we'll start out with the entire solid disk and we'll subtract out the volume that's missing so we're going to have two radii here so let's call one capital R and the other one lowercase r so how much volume is there in the larger solid disk pi capital R squared h does that work and the other one has a lowercase r pi R squared h so we'll kind of approach this from what we have done which is very Ossobellian if you want to know what that is look up David Ossobel is a psychologist and that was his method of cognition is the way we're doing this right here I'm an Ossobellian learner myself look it up you might be as well so if we want to come up with a volume of this can't we take this guy and subtract this from it what do they have in common that we could factor out front and h or let me put the h at the end because the h is going to be a dx or a dy right so we usually have that at the end of the integrand capital R we can call the outer radius and this lowercase r we can call the inner radius there's the volume of a washer does that work now don't take outer radius minus inner radius and then square the result that's not what we have it's the outer radius squared minus the inner radius squared so that's our volume that's our description of a washer regardless of where that washer is located how it's positioned in the plane if we slice up our three dimensional region and each slice is not a solid disc but rather a washer then we're going to come back to this thing right here here's a better picture I said I would come up with a better picture so if we have some region we've revolved it around the x-axis and we have something like this and the dotted lines show you the part of the volume that's actually missing in there and you slice it up perpendicular to the axis of revolution you're going to get one of these does that work and we just need to make sure we don't count the volume that's in here so we do that by taking the outer radius subtracting the inner radius from it and in this case our thickness or height is delta x and this would be from it looks like on this diagram from A to B so that's what one of our slices is going to be we describe one of the slices what does the little elongated S do it adds together an infinite number of these skinny little slices for us Chandler you had a question yeah I guess I set it up differently and it's I think I just did it wrong, never mind is that right? can you see that slice? my figure I didn't kind of draw the three-dimensional version because it's going to get cluttered in a hurry and you're going to see that you're going to lose the fact that this is missing some volume out of the middle so you might just want to kind of visualize what that looks like and then picture one of your slices so we had these curves y equal x squared plus 2 and y equal one-half x plus 1 so I'm going to refer back to this diagram sorry it's going to get kind of cluttered we're going to need the outer radius well the outer radius comes from the axis of revolution which is right here so from here all the way out to this curve describe to me what that distance is isn't that the y value of every point on this curve right? so the outer radius is really y on the parabola and what is y on the parabola? x squared plus 2 so our outer radius is the y value on the I'll just put a sub p y value on the parabola which is x squared plus 2 so that's our capital R our lower case R it's going to get cluttered I'm already overlapping what's this distance from the x axis up to here which is really the inner radius that's the y value on the line that's right and the y value on the line is one-half x plus 1 right? so we'll farm the pi out to the front we're starting we're going to integrate with respect to x so we're going to start this at 0 and end at 1 capital R was x squared plus 2 that's the outer radius we're going to square that we're going to subtract from that the square of the inner radius inner radius was the y value on the line so that's capital R squared minus lower case R squared and what's the height or thickness dx delta x so again when we get to this point we're probably two-thirds to three-fourths of the way done with the problem and this should be kind of old stuff let's see what it looks like any questions before we go just a little bit further so we'll square that x to the fourth plus 4 x squared plus 4 we'll square one-half x one-fourth x squared the middle term would be twice their product what's the middle term? x so we're going to have an x to the fourth how many x squared three-and-a-half, seven-halves x squared does that work? oh sorry, 3.75 where'd I get seven-halves? so what do we have there? 15-fourths I need to check my arithmetic thank you so we got 4x squared minus a fourth x squared 15-fourths x squared we've got a what? minus x and a plus 3 everybody feel confident you can integrate each of those separate terms once you're done integrating what are you going to get when you plug in zero? everything's going to have an x in it so those will all be zero so you're going to get whatever you get when you plug in one so again the integration is not going to be the difficult part it's the setup identifying capital R identifying little r outer radius, inner radius that should be the volume of this region which has part of the volume missing out of the inside each slice is a washer alright we're out of time we're going to take this same problem and this next time go around a line it's parallel to the x-axis instead and see how that changes things I will see you tomorrow


So now that the AC Introduction series is complete, if you are new to the channel, welcome aboard and thanks for watching. This is actually a indie game development and 3D animation channel, and generally what I do here is organize important information that computer artists need in the shortest, most concise tutorial videos possible. And the next up on our list is Special Effects in Unreal 5. So let's talk about the specific targets that we will be aiming to learn to cover over the next few weeks. Special Effects is something that I've always wanted to take a good stab at because in today's world, good special effects can really carry your game super far. And just to demonstrate what I mean, I just wanted to go through with you guys and analyze one of my favorite fight scenes of all time. Fight scenes are specifically what we're going to try and recreate in Unreal 5. So these are the kind of effects that I'm going to be focused on. So I just wanted to analyze Saitama vs. Janos with you guys and tell you what parts of it that I noticed that I really want to try and learn to recreate. I was going to show you the whole fight scene first, but that got me a copyright claim, so I'll leave a link to it in the description. OK, so right off the bat, there are two things I really want to do. The first is make the molten power glow off the character and the steam coming off of those glowing areas. I really think that's what sells this scene for the battle that's about to come. I don't know how difficult steam is to do in Unreal, but that will be one of the first things that we try and figure out. Now here, even though there's no character animation going on, I like the flow of the cape. You have to learn how to do some cloth and dress and skirt physics, but more importantly, the dust blowing in the wind is a really nice effect to that. While it's simple, I think it really adds to the sense of depth in the scene.  I love how the color is tinted where it goes from blue to orange, just like in a real fighter jet engine. Also, you see those little circular pulses of energy coming out? That's pretty sick. It's a nice small detail, but it really makes things look better. Then immediately after we have dirt and rocks flying off the ground, rubble is going to be a huge part of making cool looking fight scenes in Unreal. And of course, we have the screen shake to add the feeling of power coming from the scene. I really think a lot of people underestimate how important screen shake is, so we're going to have to look into that too.  Explosions are a super important part of any fight scene. Then we have the giant dust clouds form. I think a lot of people overlook how important dust is in a fight, but it's kind of a serious part of any real looking scene. And again, we have the circular pulses of power that we need to figure out, but this one is a bit more fiery, whereas the other one was kind of more clean. Now I love this trick, and what I love about it is the wind circle around combined with the electric lightning when he's doing it. It really adds a sense of speed and power while he's performing this move. And once again, notice the rocks flying up in the background that really sell the destruction of the environment. Something else to notice here is the entire thing is slow motion. The clothes and the hair are actually still moving quite a bit. This is probably the cleanest looking ways to demonstrate slow-mo in action. And while it's not really realistic, I think it just looks really cool. So this is the way I'm going to try and look to build some of the systems in Unreal where the characters are moving in complete slow-mo, but their clothing is actually still waving in the wind a little bit. Now when we get to this scene, something I really want to try and create a system for is the ferociously fast blurry backgrounds that you see behind the character. It's not a real background, but what it does is highlight how fast the character is moving to the viewer. Here we have the same background effect, but this time you can actually make out what the environment is vaguely supposed to represent. Off the top of my head as a developer, I'm thinking we're probably going to need to create a few different sets of these blurry backgrounds for our fight scenes, probably a forest, mountains, a desert, rocks, ocean, sky, and then the arbitrary speed blur that we can change colors for when we need. If we just had those, that should probably be enough for most of the fights. More fireballs, but this time we can see the sparks flying out, which is always a cool little effect. So we're going to need to learn how to make sparks. And I don't know what this is called, but the little twirly gig energy trails are super dope. I have no clue how that works, but hopefully it's not too difficult. And again, the super fast blurry abstract background, the debris, the lightning, the slow mo clothing in the wind. I mean, oh my God, those are probably the four most important things that we're going to need. OK, now here in this scene really highlights why I think the dust is so important, because I promise without the dust and the airwaves, this scene would probably not look as cool. And this kick, the animation was actually super simple. He literally just brought his foot up. But what prepares you for the force is the moving air trails in the background and the electricity that's about to come thundering down. And again, we have the blurry speed background. And I don't know if you could see it, but there's like these little tiny speed lines on the edges of the frame that really highlight how fast he's going. I'm guessing that's probably a post filter camera thing will probably have to do, but we'll figure that out later. Boom. OK, beautiful, destructible environments. Luckily, we just finished learning about destructible environments in Unreal. So that's not going to be too big of a problem. We'll just have to figure out how to add the electricity, the dust, the debris and the rubble on top of it. And I think you should probably start seeing a pattern here. Like a lot of these fight scenes are just different combinations of those main special effects that I just listed, you know, the environment, the rubble, the dust, the lightning, the energy pulses. So I think once we just have those basic elements, we can probably mix and mash them together to make pretty much all the effects that we see here. Now, I don't know what this is called. It's like a JJ Abrams lens flare monstrosity, but it's hella cool looking. And I'd like to see if we can get something close if possible.  Mid-firing during the cannon is, I love that effect. We're definitely going to try and replicate that later. I've actually never noticed this, but the way Saitama dodges this move is by jumping from this rock to the second rock, and then straight up into the sky to avoid the whole blast. And what did I tell you? The circle energy pulse thing, destructible environments, dust everywhere, debris, fires, smoke, good lighting. If we can just figure those things out, I think our fight scenes will probably get a lot more mileage. Now, here's a bit of a different take on these circular pulse things. It looks like there's two kinds. The first is the fast one, where you can barely see them. And the second one is this lingering, kind of slow moving one that fades away. I don't know how different those would be to make, but we're going to try. Okay, can we talk about this awesome speed blur thing? I have a bit of a confession to make to you guys, and that is I have a soft spot for these really, really basic cliche anime teleportation effects. I'm sorry, I don't care what anyone says or does, but these little flash steps, so-need-o blurs, will never stop being cool to me.  Anyway, continuing the fight, we got missile trails, which are always cool, but then we have this really cool effect that's like a combination of motion blurs after image and teleportation stuff. I know in 2D, this stuff is really just drawn in, but in 3D, we're going to have to figure out a way to try and get a similar looking effect. Also, everything being a blur, including the background, I think adds to the chaos that the viewer is probably experiencing. And you know something else that I'm realizing is a very important selling point in this fight scene, and that is the ability to have slow-mo dust and debris moving when the character is completely still. I know Unreal has some features that let you freeze the global time for the game. Like when you press pause, it tells the whole game to stop time, but I don't know how that system changes when you want the environment to slow down, but you want the player to stop completely. So that's a question we're going to have to answer later on, but hopefully we'll figure that out later. HUD and GUIs, yes, luckily, we figured out most of that in Unreal already, so that really shouldn't be a problem because we just got to find an artist who makes cool buttons and stuff and basically just replace the default UI stuff with that. Next little detail here is the force impact effects that you can see when he clamps his hands. It's like the air explodes, not really dust, but that's an effect that I'd like to try and have, and I love this scene. It's not just because it's funny, but it's also because I have this cool sword slash effect, which, yeah, we're gonna need a lot of slash effects, but from a character animation standpoint, nothing in the frame changed. From this point to this point, everything cool in this scene is literally just a special effect. It was all debris, dust, wave of motion, and camera shake. And of course, you got the afterimage teleportation effects, and again, I know this is a common 2D thing, these black pointy speed lines. I wonder if there is a material or a shader we can use for this in 3D. I love the air pulse circles around his fist when he punches. It's kind of like the stuff we saw when Captain Falcon was fighting Lucina, and the rest is basically just screen shake, debris, dust, and wind. So as you can tell, there's a bunch of stuff on the list that we're gonna try and take a stab at here in Unreal. Obviously, we're probably not gonna figure everything out, but at a minimum as a developer, I think it's important for us to at least understand how the construction of this stuff works and how to create them if we absolutely need to.  So in those emergency situations, as the developer, I always think it's a good idea for you to just know how it works. So if you join me next video, we will start our dive into special effects in Unreal 5. Thank you so much for watching and as always, hope you have a fantastic day and I'll see you around.