Welcome back to migrating a WPF app to .NET Core 3. We're up to the third step of the migration process, which is actually fixing build issues and adjusting to account for API differences between .NET framework and .NET Core. As you may remember, we've already done the preparation and the CS project creation. So now we're ready to go in and try to build the project and make necessary changes to get things up and running. So in general, the sorts of things that we're going to have to change are we're going to have to add some packages that we weren't referencing before to include APIs that maybe aren't in the .NET Core runtime package. This especially would include window-specific APIs like registry, ACLs, WCF client APIs. These are types and methods that work on .NET Core, but aren't included in the .NET Core runtime package by default because they don't work cross-platform. Of course, .NET Core itself runs on Linux, Mac, Windows. So there's actually a helper meta package called Microsoft Windows Compatibility. I'll how about Nuget to show you that, that we're going to want to add. So Microsoft.Windows.Compatibility. In general, if you're porting a WPF or a WinForms app to .NET Core, you'll probably just want to add this reference upfront because it's going to be useful. We also will have to make some small differences where one code path is necessary on .NET Core, another one is necessary on .NET Framework. We can use a pound ifs for that and constant definitions that will allow us to differentiate between when we're building for .NET Core and when we're building for .NET Framework. Then as we go through this, we'll also want to be aware of just the things that we'll need to change. These things all would have showed up in the portability report at the very beginning. But if you want to go learn more, you can go out to a documentation where we talk about some of the APIs that are different between .NET Framework.NET Core. App domains are different. Many of the App domain APIs are still available. So if you're just using App domain APIs to get information about the domain, that's likely to work, but creating new App domains is not supported. Remotings is another one where some pieces of remoting like proxying can be done with system reflection dispatch proxy and stuff like that. But most of the IPC portions of remoting no longer work, so you'll need an alternative for that. Code access security is no longer supported. Security should not be done at the managed code level. It should be done at the system level. So these are sorts of things that we may run into. In this particular app, I don't use any of these APIs because I understand that these are not supported and I wanted this to be a project that was reasonable to port quickly. But in your own apps, these are things that may require a little bit more re-architecture. You might want to think about those up front before you dive into the porting process. So let's go ahead and demo fixing some compilation errors. There's going to be a few here. Well, start in Visual Studio like I did before. I'll do some of this in Visual Studio, some of it from the command line. Actually, the first error we're going to see, it may be belonged in the previous video. Something I see here is that this is actually an error trying to build the original.net framework project that we started from, that we haven't really changed yet. The issue is that it says there's no reference for .net framework 472. I need to rerun Nougat Restore. The reason it's giving me this is remember that for this porting effort, I decided to put the .csproj files for the .net core project and the .net framework project in the same directory. That's one of a few different ways you can set this up. It's just as good as any, but they each have their own unique challenges. The unique challenge of having them in the same directory is exactly this. What's happening here, if I come to the right window, we have this project.assets.json that's created when we restore. It gets put in our intermediate output folder. This is restored for .net core app 3.0, because this is the file that was generated when we did a .net restore on our new .net core project. So there's a conflict here between the output paths for our new .net core project and our previous .net framework project. So what we're going to want to do is we're going to update these so that they're building to different locations. Now the obvious way to do that would be to come into the .csproj and add a base output path is something base intermediate output path to something else, but that doesn't work initially because we're using this SDK attribute. Let me tell you what this is. So in the new project file format, you can specify an SDK and that will automatically import some props and targets files that you need to build that project type. So in this case, we're using the Windows desktop SDK. As part of importing those props, it's going to make use of the intermediate output path so that if you change it later, it won't have an effect. So if I were to set some properties here for my intermediate output path, that's too late. And I already will have restored things or built to the wrong folders. So there's a couple of ways to work around that. One option is to not use an SDK. Instead, you can get rid of this part of the project element and you can just import the necessary props and targets files yourself and you can put them a little bit farther down, maybe, in your csproj file so that you have an opportunity to change things beforehand. The other possibility is that you can use what's called a directory.build.props file. Let me show you how that works. If I add directory.build.props, by convention, MSBuild knows to look for files named directory.build.props or directory.targets or directory.build.targets in the same folder as the project that it's building or in any parent or ancestor directory. And if it finds one of those files, then it uses whatever props or targets are in there and applies them to the project as if they were in that project file. And so we can use this as a way and this is actually processed prior to any of the SDK stuff. So by having a directory.build.props file, we're able to change things like the intermediate output path before the SDK kicks in and so it will take effect. If you're interested to read more about this challenge and the different ways of solving it, there is, let me find it here. Here we go. There's a GitHub issue that I think does a good job explaining why this is important and how to solve the problem. So here, I've got the Microsoft MSBuild GitHub repository and look at issue 1603. There are some good explanations in here that you can read about how to solve this problem. So for us, I think the easiest thing is just to use a directory.build.props file. So I'm going to say here in that file that my base output path is gonna be MSBuildProjectDirectory slash out slash the project name slash bin. Similarly, I'm going to use this Similarly, the base intermediate output path will be the same path but with OBJ. So now what that means is I can get rid of bin and OBJ hopefully unless VS has them locked. And when I build, both of these projects can build and they'll build to their own folders in the bin and OBJ directories. Therefore, when I do a .NET restore, I'll get two separate project.assets.json files. One in, you know, bean trader client dot c, bean trader client slash OBJ and one in bean trader client dot core slash OBJ. So if I come back over here, this point I should be able to rebuild the solution and it should pick up that change. Okay, awesome, it did. I've got the warning from using a .NET Framework 4.6 package, which remember is allowed and in this case should be fine. So I ignore the warning. We've just got this error about a property on my maps metro window not being available. Well remember one of the things we changed in the previous video was we updated some NuGet packages to get versions that target .NET core and one of the ones we updated was the my apps package and I guess I can't navigate from there but I can hop in here and do it. And what we're discovering is that some APIs have changed previously. There was a property on the metro window type called title caps, but now there is not. Instead, if I search for like title, there are some other properties we have title character casing which is going to do the same thing but it's a slightly more flexible API. So this is a difference between my apps metro 165 and 2.0. In general, when you upgrade your NuGet packages, especially if you upgrade across a major version boundary, you're likely to find these sorts of small differences and you may need to make some changes to make sure that things are going to work using the new versions. So in this case, the fix is very simple. Instead of using title caps, we can use title, what was it, it was title character casing and the value will be, it's not auto completing form, maybe I can come over here and see that the value needs to be normal. Okay, there we go. Having made that change, I can now build and that should take care of that error. I'm actually going to build both my projects separately because I do want to make sure as we're making changes, I want to keep building the .NET framework version of this project to make sure that it builds. Sure enough, it succeeds, it builds successfully. That's good. That means that this title character casing property must exist on my apps metro 165 and 2.0. If it only was on 2.0, then I might have to have differences in how .NET Core .NET framework versions of this project set this property or maybe the simplest thing, I can just update the previous project to also use the newer version of the NuGet package so that the code that they share will be the same. In this particular case, that's not necessary because the API that I'm using now is available on both versions, so it works fine. Okay, so we're able to build the old project. That's good. We've got separate option bin folders. Let's go ahead and hop out to the console and I'm going to do a .NET build. And again, we've got the two project files, so I have to specify which one I'm building. I'm doing a .NET build on BeanTrader Client Core. So let's check this out. That's interesting. So that's complaining about auto-generated XAML source not being available. I find that this is still sometimes a little bit flaky if I have VS open as well because VS is building in the background. So I mean, most people won't be using both the command line and Visual Studio at the same time. If you are and you see these sorts of errors, they could be transient and you just need to rebuild. Okay, now we've got 196 errors. So, you know, not too bad. I've ported projects to .NET Core that had way more than that and you're going to see that these actually will be able to take care of these pretty quickly. Just sort of glancing through them. I'm seeing a lot of this thing already contains a definition for. There's a lot of things that already, it seems like they're being defined multiple times. And if we start looking at some of these files, what we're going to realize, BeanTrader Client Core Obj and BeanTrader Client Obj, WPF is going to build some source automatically for your XAML pages and drop it in the intermediate output folder. That stuff gets picked up, it gets built, great. However, we're picking up things from the wrong intermediate output folder here. Look, we're picking things up from the .NET Frameworks folder. And of course, you know, this is the sort of thing you're going to run into from time to time because we have this new style csproj file that automatically includes all the cs files that are under it. And so, we moved the output folders but they're still underneath the path where we have our csproj files. So we need to explicitly come in here and if there are folders, maybe output folders for different projects and other things like that, you want to exclude those from being auto included. So I'm going to remove from compiling anything that's under out BeanTrader Client and any subdirectory under that that is unrelated to this project. So I'm going to ignore that part of the output folder. And that should make a big difference. Come back in here. We get 102 errors, so we're making some progress. Now these errors appear to mostly be related to not being able to find types for WCF communication. Now remember, I was saying that when you have a .NET Core app, by default it's going to include the .NET Core runtime assemblies, things like the base class libraries and some core file IO APIs, anything that's in that core cross platform .NET Core product. But there are a lot of packages that don't get included by default because they don't make sense in all scenarios. One of the ones that doesn't make sense in all scenarios is these service model APIs. So these need to be added in a separate package. Now there's different ways we can go about this. If we didn't know where these lived, if we weren't sure, there's a few ways we can go investigate. One very useful website that you might want to check out is called APIs of .NET. Let me take you out there. It's a catalog of all of the .NET APIs so I could search for something like system service model, operation contract attribute is one way and I can see that beginning with .NET Core 3.0 this is available for .NET Core so that's good news, previously it wasn't. But I can see the assembly it's in is system service model primitives. So that's going to give me an idea of what sort of package I might need to include that in my project. So if I search for system service model primitives, sure enough there's a NuGet package with that name. Now this particular package, being called primitives, it gives me a clue that probably I don't want to include this directly. There's probably a higher level system service model package that depends on this. If I search for system service model, sure enough we've got system service model, net TCP, system service model duplex. Well I'm using net TCP duplex communication so those are probably the things I'm going to need. I can come over here and now it's pretty easy to do a .NET add to bean trader client core.csproj, package system.servicemodel.duplex and once that's finished I'll do system.servicemodel.nettcp. Now I went through that to show you some of the websites and some of the process I use when I'm trying to figure out where a particular API came from so that I can include the right .NET related NuGet package. For many of these things though, you won't even need to do this if you preemptively include the Microsoft Windows compatibility package that I mentioned in an earlier video. This is a meta package that includes many useful .NET framework packages that can be used on .NET Core but aren't useful in cross-platform scenarios. So they're not in the box automatically but if you know you're only going to be running on Windows like with a WPF or a WinForms app then you can add a reference to Microsoft Windows compatibility and that's going to pull in for you your registry APIs, some Codem APIs, some directory services and IO stuff, some crypto APIs that have different signatures than the cross-plat alternatives, some service model stuff, some ACLs APIs. These are all things that are available on .NET Core but you wouldn't get if you were running on a different OS. So let's go ahead and add this package as well because we do have registry usage. We're going to use some of these APIs and I didn't add it initially because I wanted you to see these errors and how we fix them but in your own porting I would recommend you just add this up front. It'll save you a little hassle because now if we come in and we build we're going to find it's a lot cleaner. In fact, we're down to let's see, a single error. So you see that cleaned a lot up. So it says that TradingViewModel2 doesn't implement an interface member. Okay, let's go check out this old unused ViewModel file and see what this is all about. Okay, it implements, I notify property changed but it doesn't have a property changed event. So yeah, the error is correct. This will not compile. This is not good C sharp. So how did this get in here if our .NET Framework project compiled? Where's this thing live? This is under ViewModels. Here it is, right here. But you know, if I look at my old project it's not there. This C sharp file is on disk but it's not included in the project previously. And of course I did this on purpose. You can see I put a comment here that this is just here for demonstration purposes but this is a pattern that I see a lot when I'm working with customers. They might have a lot of C sharp files on disk that weren't being used and that's fine with the old CS project format. They're ignored if they're not mentioned in the project file but now with the new project file we automatically include everything. So just be aware that in a migration scenario if you've got extra sources sitting around on disk we're gonna try and build it. Now if you had a lot of these you might want to change the CS project. You might want to not auto include everything under under the current directory and you might want to explicitly just include the C sharp files you know that you need and you could copy that list from the old project. But in this case it's just one file. If it's sort of scoped you can just add a compiler remove the same way we did for items that were in the other projects output path or even easier if this is something you actually don't need. If it's not being used for reference or something if you really truly don't need it anymore take this opportunity to clean up your disk and just delete it. And at this point now that was that last error so let's go ahead and do a .NET build and see what happens. Okay we've got 11 more errors. So it went up because the C sharp compiler is a two pass compiler. During its first pass it just looks at method signatures that tries to make sure that all of your references are available and that they line up. And those were the errors we were fixing up until now. You know that interfaces are implemented properly and so on. Well now that we've addressed those problems this C sharp compiler is successful enough that it moves on to its second passes which is where it actually looks at implementation. So it's actually trying to turn our C sharp into IL at this point. And so now taking a look at the implementation of our methods there's a second round of errors that the C sharp compiler finds. So you're gonna see this sort of two phase pattern when you're working on a project with a lot of issues. And you know especially if you're doing like a migration from one .NET platform to another. We're at about 20 minutes now though and I don't want each of these individual videos to get too long so I'm gonna end this one and in the next video in session four we'll go ahead and we'll finish fixing the remaining compilation errors that we have from this second pass and we'll get this project actually building on .NET Core.


Again, here we go ready, ready, welcome folks. This is Tom and Tommy O'Brien. We appreciate your growling and problem with us. Always remember, folks, whatever you think about, you bring about whatever you focus on grows. Hope everyone's having a great day, safe day. It's a TGIF. And let's make it a great weekend, folks. Now, we're going to read the floor agreements, OK? To master love, you have to practice love. The out-of-relationship is a whole mastery. The only way to reach mastery is with practice. To master relationship is therefore about action, not about attaining knowledge. That's right. Mockin' wise, let's take a look at it out here. We have the Dow Industries up $7.40. That's right. I love it. Good boy. NASDAQ up $153. S&Ps up $0.68. Gold, gold contract down to $28.70 at $9.66 an ounce. We have silver down $0.45 of $0.27. We're going to the show. You're doing the show. At $23.71, light sweet crude. Light sweet crude up $1.58. $71.68 a barrel, notes and bonds. That's right, notes and bonds. The 10-year note down $28 ticks at $1.1327, the 30-year off $29 at $1.2730, and $king dollar. $king dollar right now is trading. Good boy. $4.46. We got a tiger here, folks. At $104.066, the year is at $107. The yen is at a price point of $139. The British pound is at $124.01 US dollar. Offer numbers<PHONE_NUMBER>. Give us a call, folks. I want to know what's going on in your world. And the world of the S&Ps, let's take a look at it. You wouldn't believe it, folks. It's so cool. So picture, Tommy brings Tommy into the office. And he knows that we have a couple floors here. We actually have three floors. But anyway, he brings him in, and he says, OK, let's go down. We got to do the show, literally, OK? So it's so cool. It's amazing. That's right. We do a growl for them. Do a growl for them. Rawr! Another one, another one. Oh, that's a little one. Big one. Rawr! Good boy. OK, so S&Ps. You talk about Tim Ord. We're doing the workshop next week, folks. I mean, this is a total break topside, man. This is like we were talking about the swing point yesterday. But we have $6 and 1 half dollars in one day. It's pretty amazing. And now you're right next to the swing. The swing we're talking about is at 431. And yesterday, it seemed like a long way off. Well, guess what? You're up $6 and 1 half dollars right now. You're right next to it. This is going to coincide with the end of window dressing. So we'll see where that shakes out. Now, what it's also going to do is that this is where we broke downtown. So this is going to be a crucial area. Going to be a crucial area, Tom, to get through. What will happen, which is under the tunnel. OK, ready? Go ahead. Oh, good boy. So we take a look at the.  Oh, you did that. Good.   OK, it shut. So we take a look at the queues. The queues there, they're at 371 that they were looking at. And yes, that seems like a far away today. But guess what? All's it's going to take is a couple good days. And then you're going to see that 371 area. Gold. Gold contract. We take a look at the gold. No, we can't do that one, Tom. Oh, look at that. That's a good try. Thank you, guys. That's a good shot. OK, let's take a look at the gold contract. So we take a look at the gold contract. So this is down on volume today. And today we see down, folks. 1903 is the number.  Today you're down with 198,000. And this wants to get back to its strength. Just one second, pal. Sorry. And the strength that we're talking about inside this contract is right where it took off from the beginning. That's where this sets up. In fact, this is pretty cool. Watch this. It actually sets up at the top of the strength. So I expect we're going to get there. Now, good old the King Dala. The King Dala show. King Dala. Yeah, you are on the show. Hey, I think you're on the Tom O'Brien show. I think your name's Tom O'Brien, too. You can see what King Dala did. King Dala bottom line has rejected lower price today at 103, 382, and wants higher price. So volume-wise out here, let's see what we're going to do. We're going to come in with on the indices right now. This is big volume, folks, OK? Well, it's not that big, actually. 532 million on the NYSE. And if we take a look at the composite. We're in the door. OK. It's shut. There we go. How about that? Is that good? I don't think. OK, here we go. I just shut. Oh, good boy. I want to, yeah, see this composite. Well, we're not going to, we're not going to, that would probably do about 4 billion shares. That's what we'll probably do. Hey, can you tell the audience, I want to show them how you can count. 2, 0, 4, 6, 8, 10, no, 11, go ahead. 21, good boy, come on. Yeah, what's after 22, 25, 27, 33, 34. No, you got to do the next one. Good boy, 36, 38, what's after 40? Body 1. Body 1. How's that, folks? You got 24, well, he's 27 months old. I'm not sure. What are you going to count after, mommy, 60? I think he can count up to 60, folks. Stay right there, folks, we'll come right back. We have the, needless to say, you know what's so funny, folks, picture this. His ABC's in school. One of the Tigers said that. His ABC's are going to be A to B equals C to D. We'll come right back. We have exciting news, Tigers. This June, Tim Ord of the Ord Oracle will be hosting two webinars, providing insight into his renowned market timing methodologies. On June 8, Tim will delve into the S&P 500, teaching sentiment indicators, identifying market bottoms and divergence, and so much more. On June 15, Tim pivots to the gold market, taking a look at cycle analysis, ratio studies, advanced decline indicators, and other important tools for analyzing this sector. Sign up today on tfnn.com, tfnn, educating investors. Currencies, commodities, and bond markets are as important as ever right now with how they're driving the volatility in equity markets across the globe, which is why it's a great time to try out Teddy Kegstad's Tiger Forex Report. Teddy Kegstad breaks down the forex markets every Monday using his 30 plus years of experience as a trading veteran of futures, forex, stocks, and options. Teddy releases his weekly Tiger Forex Report every Monday morning with coverage of all the major currency pairs, including the dollar index, the euro dollar, pound dollar, dollar Swiss, dollar yen, as well as many more. And he also has weekly coverage of the crude oil market and the 30-year T-bonds as they both influence forex markets tremendously. When you sign up for the Tiger Forex Report, you also gain instant access to Teddy's 60-minute webinar archive he just hosted, forex strategies, and fundamentals, what is behind the Tiger Forex Report. For all the details and to start your 30-day Tiger Forex Report subscription today, visit the front page of tfnn.com. tfnn, educating investors. Are you looking for a way to consistently add winning trades to your portfolio?


They've never heard of Qiraat. They've never heard of the Ahrufa Saba'a So they'll bring like a Quran. It says Malik Yawm-e-Din, Malik with a dagger alif And another Quran says Malik Yawm-e-Din, Malik Malik. Oh two different Quran's and then the Muslim The Du'at that are very young Right, they're there and they're doing their best They start going they have this cognitive dissonance and you wrote this Quran You this is a fabrication you're calling this a fabrication. Yeah.


I have a bowling ball attached to a cable that is mounted in the ceiling. I'm putting the bowling ball to my chin and I'm going to let it go. What's going to happen? The bowling ball starts at the height of my chin, it swings through the bottom of its motion right up toward the other camera and then it swings back. What can energy tell us about the end of this story? Let's take a final but fairly deep dive into energy by looking at a concept we've been dancing around this entire time and that is the conservation of energy. The key ideas that we will explore in this section of the course are as follows. We are going to come to understand that energy can change forms. We've seen this already with kinetic and potential energy but we're going to explore other forms that energy can take in a given physical system. We are going to learn from all of this and this is reflective of the observation of the natural world that energy is neither created from nothing nor entirely destroyed but transformed from one form to another in the course of a system of moving parts or components. We will understand the mathematical description of energy conservation. We're going to come at it from a few different directions starting with mechanical concepts and moving more generally into larger energy concepts and we will explore the implications of the conservation of energy because this subject is deep and these implications apply not only to the mundane activities of everyday life but quite literally to the whole of the cosmos itself. That energy is conserved is a principle of nature and I really cannot emphasize enough not only that this is a remarkable fact of our universe but how crucial a fact this actually is that this quantity that we have labeled energy we can quantify it even if we have a conceptually difficult time defining it especially considering a system where nothing can enter and nothing can exit the system no thing can reach in and act on the system no thing can escape the system we will find that this quantity is in fact entirely conserved and I'll come back to this notion which I've sketched a bit cartoonishly here of what is known as an isolated and closed system but this is a crucial piece of this whole framework of energy conservation. So that is to say if we were able to develop a means by which a system so for instance and consider something as simple as a ball attached to a rope hanging from the ceiling if we could find a way to utterly wall this system of matter off such that nothing can get in and nothing can get out nothing can leave it not even atoms transmitting their motions to other atoms outside the wall the wall is truly impenetrable if we can then having walled off the system account for all ways in which energy can simply be distributed inside the system we will observe that energy may change form but it is neither created nor destroyed and as I've kind of implying in this impassioned commentary on this subject figuring this remarkable fact of nature out for the very first time was a long effort and it was an immense effort I'm only going to cherry pick a moment from history but there are many of them and and I would simply ask you to consider and this is a good place to maybe pause and go dig around in a history book or on the internet say Wikipedia consider the experiments of the French chemists they were a husband and wife team Levoisier and Paul's Levoisier is famously known for being the chemist's chemist he was the one in collaboration with Paul's his wife who not only documented remarkably detailed and controlled experiments turning chemistry from more the science of alchemy into the rigorous quantitative science we know today but because of these extremely careful well documented well illustrated quantitative experiments with chemical transformations together these two were able to show for instance that the mass of matter before and after chemical reactions was the same that is in the chemical reactions that Levoisier and Paul's were considering if you put in a bunch of reactants and get out a bunch of products the mass of the reactants is equal to the mass of the products nothing is lost or gained from the system in the process of chemically reacting and to do this Levoisier for instance had to conceive of invent design and build a whole new generation of apparatuses entirely devoted to keeping gases from escaping which was not easy so you can imagine the level of meticulousness that is required to demonstrate that the mass you put into chemical reactions at least for the ones that these two were considering was equal to the mass coming out accounting for not one lost drop of material the whole time this is not easy now originally their principle of conservation that they observed was this conservation of mass but generally speaking from this kind of experiment where you are extremely dutiful if not pedantic in the methodology that you bring to accounting for things in an experiment they were at the minimum able to show that there are conserved quantities in nature and ultimately not their work alone but the work of dozens of chemists and physicists and mathematicians would come to realize that it's not mass per se but more generally energy that nature conserves let's focus on a specific conservation statement that is perhaps the more approachable of the conservation concepts will explore today and that's because it involves only say isolated systems where conservative forces at work that is there are forces at work that can store energy in the form of potential energy and of course release energy from potential energy into other forms we're going to define a kind of energy mechanical energy explicitly as the sum of kinetic and potential energies in a system so consider the situation illustrated at the beginning of the lecture and verbally again a few minutes ago of a large ball like a bowling ball affixed to a cable the cable is attached to the ceiling here we can raise the ball up and now it is storing gravitational potential energy it's configuration with respect to the earth is that it is a it is a higher altitude than where it wants to be the lowest point of its swing and and then we let it go and and we take that stored potential energy and we convert it into the kinetic energy of the motion of the bowling ball swinging on the cable we saw this illustrated at the beginning of the video we're excluding situations where non-conservative force acts now as you can imagine from a you know classroom experiment like a swinging bowling ball it's pretty hard to isolate the bowling ball from non-conservative forces like drag or friction friction may play a role for instance where the cable hooks into the ceiling and those two parts can rub against each other of course drag the resistance of the motion of the bowling ball through the air the only way I can get rid of that is to suck all the air out of the demonstration room and then it would be impossible for me to participate in the demonstration but nonetheless we can idealize this situation and imagine that it's somehow possible to get rid of all these non-conservative forces and isolate a system entirely governed only by conservative forces and so we can define the total mechanical energy in a given moment of time as E sub MEC for mechanical as the sum of kinetic and potential energy at any given moment so the bowling ball halfway from its starting point down to the bottom point of its swing has some blend of kinetic energy and potential energy it has a non-zero velocity but it's also not at the bottom of its swing yet so it's still in a configuration above the surface of the earth which is not representative of its lowest potential energy point the conservation of mechanical energy then requires that the following statement be true at some initial time ti and at some final time tf where I'm taking the final time to be greater later than the initial time that statement is that the mechanical energy at the final time must be equal to the mechanical energy at the initial time in other words the sum of the kinetic and potential energies at the later time tf is unchanged and equal to the sum of the kinetic and potential energies at the earlier time ti that is a statement of conservation the left side equals the right side the total mechanical energy at the later time equals the total mechanical energy at the earlier time now that doesn't mean the kinetic energy is the same and it doesn't mean that the potential energy is the same but it does require that the sum of those two things be the same and many careful experiments have been done isolating systems from non-conservative forces that show that this in fact is realized in nature now if we then apply our past knowledge from studies of work and specially work done by conservative forces and now integrate that into this framework of the conservation of mechanical energy that the total mechanical energy at a later time tf is the same as the mechanical energy say at an earlier time ti we will have almost come to the equation I just showed you the conservation of mechanical energy let me show you one way that you can get to that statement we know from our earlier exploration of for instance gravity that the following statement is true that the change in kinetic energy of an object which is the final kinetic energy minus the initial kinetic energy will be equal to the work and in our case we're considering the work done by a conservative force like gravity so we saw a way that we could get to this relationship earlier we do in a sense we derived a form of this equation delta k equals w earlier and we also saw when thinking about potential energy and especially changes in potential energy that changes in potential energy are equal to the negative of the work done by a conservative force so we have a statement about kinetic energy changes and work and we have a statement about potential energy changes and that same work so it is therefore a very small leap from those statements those perhaps observations of a physical system or the mathematical statements that describe those observations to what turns out to be the conservation of mechanical energy once we just as define the mechanical energy is the sum of kinetic and potential and we start from this realization that delta k equals w and w equals the negative of delta u then we can substitute for the kinetic energies k final minus k initial that's the definition of delta k and of course we can substitute for delta u with the final and initial potential energies again delta u is u f minus u i we have this overall minus sign relating the two differences and if we shuffle this equation around algebraically very quickly will arrive at the following statement that given these conservative forces that can store energy in configuration in the form of a potential energy but also give that back and transform potential energy into kinetic energy we find that it should be true that k f plus u f equals k i plus u i that is that mechanical energy at some later time t f is the same as the mechanical energy at some earlier time t i we have come full circle we have gone from concepts and considerations of conservative forces and we have seen now how we can get to a statement of the conservation of mechanical energy now what are the implications of this observation about mechanical energy and its conservation well there are some relatively deep implications from these relationships let's take a look one is that if in fact a system can be isolated in such a way that only conservative forces can act then it will be true that this relationship absolutely holds i didn't only have to think about gravity on the previous slide i could have summed up a whole bunch of conservative forces without even knowing what they are just knowing that they have an associated potential energy that they satisfy the requirement that the work by that force done in going from point a to point b is the negative of the work done in going from point b to point a that's the definition of a conservative force just using those definitions if it's possible to establish this kind of isolation so that no energy can flow into or out of a mechanical system then this relationship must absolutely hold so practically speaking how can you imagine doing this it's fine to deal with idealizations but you know you've got to build something and so what considerations would you take in constructing a system where you want this statement to be true and so you have to isolate it as much as possible well first of all friction can obviously be immensely reduced and would be a nuisance in isolating a system from changes in in in energy like kinetic energy and potential energy you could greatly reduce that to some negligible or almost zero level by choosing your materials correctly you know picking materials that if they have to be in contact have extremely low coefficients of friction when in contact or you could augment surfaces where it's not possible to change materials by altering them chemically by placing other materials in between them that themselves have extremely low coefficients of friction so you can imagine lubricating a surface with water or grease or oil or something like a solid lubricant like graphite there are many options available in the real world to try to do this and you can play this game and you can try to get rid of a non-conservative force friction another non-conservative force of course is drag and drag could be immensely reduced by spending a lot of effort intellectual mechanical design and so forth on reducing the drag coefficient and you have to do that through aerodynamic engineering you have to alter the three-dimensional shape of an object as it moves through a fluid to get the lowest drag coefficient possible or you could find a way to alter the orientation of the object to present the smallest possible cross-sectional area as that object moves through the fluid you could also remove the fluid so if drag is a problem try getting rid of the fluid you could try operating for instance in an airless environment if air drag is a problem that's what's known as vacuum when you take all the air out of a closed system and then you're able to hold that state of pressure inside the system with no air in it now these are engineering challenges these are design challenges it may not be possible to do all of this and we'll come back in a little bit and view the conservation of energy overall not just mechanical energy but many other kinds of energy all added together from the possibility that it's not practical feasible or achievable to get rid of non-conservative forces conservative forces can store energy and release it from a potential energy non-conservative forces sap energy and really give nothing back to the mechanical system so getting rid of those non-conservative forces is of course important now if you've managed to as ideally as possible establish such conditions then it should be found and repeated experiments have demonstrated this that the total mechanical energy of any state any configuration of a system of objects of this isolated system with as many non-conservative forces reduced to zero or as low as possible as is achievable you'll find the total mechanical energy at any earlier time of any configuration of the system is equal to the total mechanical energy at any later time in any other configuration of the system i think one very interesting system to look at is not the bowling ball on a cable not the simple pendulum that i started off this lecture video with but rather with something known as the chaotic double pendulum a much more complicated pendulum system of masses that can pivot uh it seems like only a simple extension of the simple pendulum where you have one pivot point and one mass that can uh that can be swung around the chaotic double pendulum if you can do this in a very low drag environment with a very low friction series of joints can basically take its mechanical energy and move semi indefinitely changing energy from kinetic to potential to kinetic to potential to kinetic to potential in various parts of the system take a look at one of these chaotic pendulums filmed by a professor that works with our department john faderusso and and see what this looks like in a in a mechanical system which is very isolated and you have injected energy into it to get it moving but then taken the source of the energy injection away and just watch the mechanical energy go in the system this is a fascinating system to watch so what we've seen is that once we put in the energy required to get the chaotic pendulum spinning there's usually a handle or a dial on one of these demonstrations that you twist that provides the initial kick but then you take your hand away and the system after that is almost a completely closed system where energy changes from potential to kinetic we can watch this system moving energy around in its mechanical buckets from kinetic to potential and back and forth in complicated ways but it never overall if you account for the motions gains any energy and because of the reduced friction and drag it loses energy very slowly over time to this non-conservative forces this chaotic double pendulum demonstration is a really excellent demonstration that there are buckets for energy kinetic and potential and total mechanical energy is a fixed number even while energy is subdivided amongst the buckets in different way it's a really beautiful and and mesmerizing demonstration of this here's a much simpler demonstration of this sort of concept that the total mechanical energy is a fixed number once it's established and that energy can move around in the sort of conceptual buckets in which it can go it can be in kinetic it can be in potential those two things can trade off of the amount of energy that's in any one of them at any time but you can never exceed the original total that you put in so to illustrate this we have here one of the p-h-e-t FET simulators of physics principles this one is known as energy skate park and we're going to look at the very basic demonstration of this conservation of mechanical energy concept that we've just been looking at in the more complicated chaotic double pendulum we saw live in a museum i have here a skater that i can move around and place on this track before i do that let me turn on a coordinate system so that we can more easily see that for instance i'm going to place her at a certain height on this parabolic half pipe that we have here in the computer simulation all right so i can i can pick her up and i can put her at you know roughly call this four meters or so above the bottom of the of this parabolic half pipe that we have in here and when i let her go i will no longer be exerting the force that's holding her in place the force that i exerted to move her up to this spot i have established a certain amount of mechanical energy for this system that is the skater skateboard half pipe system once i let go gravity is the only force that can act and gravity is a conservative force and so we would expect that because i'm starting her at rest with no kinetic energy up the side of the half pipe at about four meters above the bottom that this is the most potential energy she will ever have and because mechanical energy has to be conserved which means the sum of kinetic and potential energy has to be conserved because at the beginning kinetic energy is zero it must be true that kinetic energy can never exceed taking all of the potential energy out of the potential energy bucket and that consequently when kinetic energy is converted back to potential energy that that potential energy can never exceed the original value that it started that would be a statement of conservation of total mechanical energy so i'm going to let her go and let her start skating in this parabolic half pipe let's observe what happens so indeed she falls down to the bottom of the half pipe and then rolls up the other side but doesn't go over four meters because that configuration four meters above the ground was the most potential energy she was ever going to have in fact that mgh that's represented by the height of four meters whatever her mass is if we take that i multiply it by g and times h that's the most mechanical energy she can ever have because i started her with no kinetic energy and so the sum of kinetic and potential energies at time zero was only potential energy mgh now it can move around it's becoming motion and then it's becoming potential energy and then it's becoming motion again as we see she gets to the bottom of the parabola but it never exceeds the amount that was originally put in now friction and drag have been turned off in this simulation now to sort of better illustrate that there are these buckets into which energy can be placed but whose total is never exceeded if i turn on this bar graph we'll see here the yellow representing the total mechanical energy that i started her with and we can see that when she gets to the top of her motion where's where she started it's all potential but then it trades off to all kinetic at the bottom when she gets to zero height and then it returns to all potential and you see this lovely dance between the two possible places that we can put this mechanical energy potential dialing up the kinetic until it's maximum then dialing up the potential until it's maximum but never exceeding the total the total never changes so this in a nice little computer simulation that you can play with in any web browser will give you some more of a feel for conservation of energy and how that total energy can move around in the various forms that it can be in but the sum never exceeds the total that you began with now there's another deep implication of these energy concepts that we've explored so far and that has to do with energy and forces and this is not something that you are going to see in a typical introductory physics course or textbook but the reason i'm putting it here is because if any of you go an inch beyond the introductory physics level you are going to start running into these ideas fairly quickly and in fact these ideas are transferable to any other force that's conservative that you will investigate and one of those is the electromagnetic force the electric force for instance is described by something called Coulomb's law and it describes a force that is conservative in the same way that gravity or the spring force is conservative these conclusions apply equally validly to that force and so any force and there are at least a few of them that you can write down a description for and determine that it is a conservative force everything i'm about to tell you applies and what's really important about this is that because underneath all of reality or a whole bunch of conservative forces working together to create the structure of reality that we see at the macroscopic scale at the most microscopic scales it is this description of forces and energy that is the most convenient and the most successful at describing extremely complex things that are happening in nature so for instance let us recall the relationship between potential energy and the work done by a force which i'll label f with a subscript x in only one dimension i'm going to do this entire analysis for now in only one dimension to sort of simplify this a little bit for you the change in potential energy will be equal to the negative of the work done by this force and grossly speaking if we're talking about a constant force acting over a displacement this will then be equal to the negative of the force times the displacement now let's consider not large changes in potential energy or displacements big delta u's big delta x's but infinitesimal changes and also the possibility that the force itself is a function of distance position in space that when you subtly change the location in space that the force is acting the force itself also changes we've encountered um one of these directly so far and that is the spring force but there are other forces for instance the force described by coulomb's law for electricity the electric force that is similarly variable based on position and once we get into the depths of gravity and we see the the the force description of gravity at its most specific level at the introductory physics course approach you'll see that gravity too has this this behavior overall over large larger distances than we normally think about near the surface of the earth so let's consider infinitesimal changes in in potential energy and infinitesimal displacements in space so we're going to take this from a gross average kind of consideration to a differential tiny displacements in these things consideration of course now we're getting into calculus we're talking about small changes and their overall effects on nature so we're transforming delta u to this quantity du which means small changes in u infinitesimal almost zero sized and we're changing delta x to dx where this dx is a singular symbol that similarly means infinitesimal nearly zero sized changes in position so then we will find that the total potential energy is the sum of all of these little changes in potential energy okay so this is the integral of these little du's if i take a whole bunch of little changes in potential energy and i add them all up i should get the big change in potential energy okay that's just the definition of the integral it's a big sum over tiny things well but we we know how to write u in terms of work and specifically in terms of force acting over some displacement so we can rewrite this integral as the negative of the integral of f sub x dx that is the negative of the sum of the application of this force over all the tiny little displacements over which the force acts remember what the integral is the integral tries to answer the following question what what original function if i had taken the derivative of it say with respect to x in this case would have yielded f sub x the answer to the integral is the antiderivative it is the reverse of doing the derivative it's taking the question what function can i write down whose derivative gives me the force in this case the antiderivative being the reverse of the derivative has a property and that is if i take the derivative of the antiderivative i get back the original function that i originally had in the integral the so-called integrand so what if i take the derivative of both sides of the above equation i take the derivative of u with respect to x and i take the derivative of negative integral fx dx with respect to x well the left side of the equation will be one thing and the right side of the equation will just be negative f it will just return to me back the integrand of the integral so that is it will simply return to me f sub x if we undo the action of the integral and instead apply the derivative to the left hand side we learn something truly deep about forces and energy that is that having now taken the derivative of both sides of the equation with respect to x and undoing the integral on the right hand side to get back the integrand we find the following that the negative of the spatial derivative of the potential energy is equal to the force that is the force that has been exerted is relatable to the way in which the potential energy varies in space for a given physical system okay so what this tells us is that force and changes in potential energy are directly relatable to one another and you can see from the above why it was probably almost inevitable that mechanics again newton's laws equations of motion all that stuff would have been reformulated in terms of energy concepts rather than starting from the more complicated vector-based force concepts energy being a scalar is a lot easier to work with but force being a vector can be determined from energy using the action of the derivative with respect to spatial considerations like x y and z so this may be in your textbook but something that won't be in your textbook is what i show you next nonetheless this bridges you to the future of mechanics something that if you were really going to go and write a simulation of a complicated mechanical system in a computer or to develop calculations by hand of a more complicated physical system you would never do what we've been doing up till now in the course you would start from this energy-based mechanics and work back to forces and equations of motion and i'll show you why here's a glimpse of the future specifically classical mechanics and its energy foundation the force associated with a conservative actor like gravity or the spring force or even as you'll glimpse in the second semester of this course Coulomb's law the electric force the force associated with a conservative actor in general is a vector it has direction and magnitude that vector however can in general be determined directly from the potential energy associated with the force written as a function of its coordinate so for instance potential energy might vary with x or y or z coordinate the potential energy of a ball held above the earth is much higher at a higher altitude than it is at a lower altitude so we see already we have some intuitive sense the potential energy varies with position or can vary with position in general in three dimensions i might write this as u as a function of r vector where r vector contains three components x y and z so then the force associated with the changes in potential energy in space would be the negative of the spatial derivative of u with respect to coordinates so in this case d r vector this is meant to be a three-dimensional differential quantity in space you can write this out as a vector so it it winds up being an x component negative du dx again x component lies in the i hat direction negative du dy in the j hat direction and negative du dz in the k hat direction now as a sneak preview of both energy-based classical mechanics but also teasing third semester calculus if you haven't had it yet so-called vector calculus one can define the following vector this symbol here is known as the nabla it takes its name from the harp after which it is similarly shaped which is a bit triangular in shape so this quantity here nabla with a vector hat over it is defined as the x y and z components of this above differential operation so d with respect to x d with respect to y and d with respect to z this is known as the gradient operator it tells you in three dimensions how something changes in space so for instance it can tell us how potential energy changes with spatial location and thus in a more general way we learn that force is the negative of the gradient of potential energy that is it's the negative of changes in three dimensions of the potential energy in space and that can be represented in an equation form as f vector equals negative nabla vector u this symbol is often in verbal communication shorthanded as del so you'll hear this as f vector equals negative del u where del is a vector operator acting on a scalar quantity u and of course what's most stunning about this is that from a simple numerical concept like energy a vector arises out of the mathematical ashes of all of this i always found this quite stunning and when it was first shown to me i was completely blindsided by these concepts i wasn't expecting them i wasn't prepared for them the first time i saw them and i kind of had my ego handed to me on a platter i'm hoping that by showing this to you although i don't expect you to use this in this course i don't want you to be surprised that energy can be used to reformulate mechanics concepts and actually in a much more compact way in a way that allows you to handle far more complexity as a result now historically where all of this comes from is from the work of Joseph Louis Lagrange who lived from 1736 to 1813 and William Rowan Hamilton who lived from 1805 to 1865 you know the period of time during which they lived as with Coulomb and other people that i've mentioned in previous lectures but also people you'll encounter in the second semester of this course they all live during times of extreme revolution in society in government but also in science mathematics and the arts the this is a revolutionary period for our species at least in in europe and in the american continent and so um it's no surprise that a lot of great ideas bubbled up from these periods as people began to challenge conventions and norms and to think outside of the sort of boxes that they had been in for a long time this thinking outside of boxes allowed for the potential for complex problems that are normally difficult to handle in newtons formulation of mechanics the way we've been learning forces so far in this course in a much more compact and elegant way and the methodology that i'll i'll mention here was developed by Lagrange and Hamilton and it much more readily allows for the solution of complex problems so for instance note although i've not pointed this out before that kinetic energy depends on position but not just position the time derivative of position so for instance velocity is by definition the time rate of change of position so dx dt that in a compact mathematical notation is often written x dot so x dot just means dx dt so we can reformulate kinetic energy as a function of dx dt i mean it was always in there we just never thought about it so kinetic energy is one half mv squared v can be written as dx dt and we can compactify that in notation to x dot and so we see that kinetic energy is a function of x dot of velocity okay we knew that but i'm just stating it now in a general sense explicitly potential energy in contrast depends not on the time derivative of position but on position itself so u is a function of not the time derivative of x but just x what Lagrange and Hamilton developed and over their long period of work came to realize is that it's possible to define quantities that are easy to write down maybe a little difficult to use but in using them you can develop an extremely complex set of equations that normally would be very hard to come up with on your own so for instance one quantity that can be written down is what is known as now at least as the Lagrangian of a system it's nothing particularly fancy it's merely take all the kinetic energy in the system all the ways that kinetic energy can manifest in a system and subtract from it all the ways in which potential energy can be stored in a system k is a function of the time derivative of x x dot u is a function of position x so we have half of this equation depending on time change of position and the other half depending only on position take the difference of these two halves this thing is called the Lagrangian and it turns out that what they figured out especially using Hamilton's approaches to calculus and considerations of what changes and what stays the same in all of this you can get all the equations of motion all those equations we kind of waved our hands at and wrote down early on all the equations of motion for any system no matter how complex can be determined by simply solving the following equation that is the derivative of the Lagrangian with respect to space minus the derivative of the Lagrangian with respect to changes in position the time derivative of that the difference of these two things is equal to zero solve that equation and you will be able to get all the equations of motion for a complicated system or a simple system so of course this is overkill for simple systems but for complicated system this approach is quite powerful lends itself readily to numerical computational methods and is the preferred way of actually modeling complicated systems that involve more than one thing that can move or even more than a couple of things that can move you'll find that it doesn't take much to get a complicated mechanical system let's look at some more lessons from the conservation of mechanical energy so from this seemingly simple equation that the mechanical energy of a system is equal to the sum of its kinetic energies that depends on the speeds of things within the system and its potential energies which depend on positions within the system we learn a few things about motion so first we learn that if there is a place in space and again let's think about one dimension here so some place along the x axis and let me label that as x prime there might be more than one x prime let's imagine there's at least one place where the kinetic energy of the system is zero which of course implies that the speed of any potential moving parts in the system is also zero in that case we achieve a situation where the mechanical energy is entirely found in potential energy and again this is at that place in space all right so this is u is a function of x and specifically evaluated at x equals x prime this is a special place in the motion it is what is known as a turning point of the motion that is the object essentially can proceed no further past this point if an for instance a moving object imagine a ball moving upward into the air when it hits a place where all of the mechanical energy available to that ball is stored in its relationship its orientation with respect to the earth there is no more place from which it can draw energy for kinetic energy and at that point a ball which had been moving up into the air will stop and its motion will turn around and reverse so you can see why this is called a turning point of the motion an object can proceed no further the motion should reverse as energy is then depleted from potential and returned to kinetic so i've given you this example but i want to emphasize this one more time think of this case of throwing a ball up into the air the ball rises it slows its motion comes to a stop and then the motion reverses the turning point of that motion in this specific example is when the mechanical energy is equal to mgh where h is the maximum height of the ball of mass m at that point we know that the kinetic energy is exactly equal to zero and so it must be true that the speed is exactly equal to zero now let's consider another series of lessons from the conservation of mechanical energy again mechanical energy is the sum of kinetic energy and potential energy within a system isolated from non-conservative forces uh what are some other things we can observe here well since force is given by the negative of the rate of change of potential energy with respect to displacement so f equals negative the du dx the first derivative of the potential energy with respect to position and again thinking in one dimension we learned something about other key points in the motion regarding specifically force or forces so for instance if there are locations in position such that again the mechanical energy is entirely equal to potential energy and the change in potential energy with respect to position is zero that is all positions have equally valued potential energies then there can be no kinetic energy and no change in the state of motion since du dx is equal to the net force on the system this tells us that since du dx is equal to zero there are no net forces this is a special location in space or a set of locations in space that are known as neutral equilibrium equilibrium is the case where the sum of forces is equal to zero and this is a special kind of neutral equilibrium no matter where we place an object in space u has the same value du dx is zero there are no net forces in the system a good example of this would be a ball resting on a very flat table such that the gravitational potential energy of the ball is the same at all locations on the surface of the table no matter where that ball is placed there is no spatial rate of change of potential energy and so there are no net forces the ball simply sits on the table it cannot move up or down and there is no reason for it to move in any other direction say in the plane of the table because the net forces are zero du dx is zero now in contrast with that if there are locations in x which i'll denote as x with a subscript zero where it is true that du dx is zero but where even a slight displacement from that location in space will move the object to a place where du dx is less than zero is negative then what that tells us is that anywhere this object moves away from this special place where there are no net forces are places in space where the rate of change of potential energy is negative that is the potential energy is decreasing in any other location in space even a teeny tiny displacement from the special location x zero if it's true that du dx is less than zero because f is equal to negative du dx it will be true that the force on this object will be greater than zero and acceleration will then further displace the object from x zero think about it as a runaway acceleration these are points of unstable equilibrium so they are equilibrium locations it is true that at exactly that spot there are no net forces acting on the object but even a slight perturbation even a slight jolt to the system the slightest nudge changing the position of the object say a ball will suddenly put the ball in a place where du dx is less than zero and there is a net positive force which further decreases potential energy a good example of this is taking a little metal ball and placing it very carefully on top of our curved surface right at the tippy top of that curved surface there is a place where gravity doesn't have a component that can pull the ball down but if i even slightly disturb the system say by pounding on the table near the ball the ball falls right down either to the left or to the right this is an unstable equilibrium point yes it's an equilibrium point but even the slightest disturbance so-called perturbation in mathematical terms to this system will cause the object to begin to accelerate under a external force in this case gravity in contrast with unstable equilibrium points there are places also which we can denote x zero where even a slight displacement from that from that special place puts the object in a location where du dx is greater than zero that is the object experience is a force that tends to want to push it back to where it came from not accelerate it further away from where it came from think for instance about a spring force a spring force is a restoring force when you stretch a spring away from its equilibrium point the spring wants to pull you back to the equilibrium point these are in general places for a system where you have what are known as stable equilibrium you have a situation where an object slightly disturbed or perturbed from this special location will experience a force that wants to restore it back to that location so a good example of this would be a ball sitting on the bottom of a curved track like the bottom of a roller coaster loop the ball sits at the bottom it can go no lower and if i nudge the ball away from that bottom location gravity exerts a force that tends to want to push it back down toward the equilibrium point so it will rattle back and forth passing through the equilibrium point over and over and over again of course in a system like the one i'm showing you here with friction this motion will eventually wear down and the ball will come to rest back at the stable equilibrium point at the bottom of the track but this is a good way to visualize these things stable equilibrium points are places that if i slightly nudge a system away from that point a force will try to restore it back unstable equilibrium points are places where if i nudge the system away from it a kind of runaway acceleration will occur the object will not tend to go back to that equilibrium point and then finally we have these neutral equilibrium points and these are places where a slight nudge of the object away from its current location keeps it in a place where it's still true that there is no change in potential energy and so there will be no net forces it will simply sit at this new location in space now we've danced around this a little bit but what about external forces we've been thinking about closed and isolated systems we've been ignoring non-conservative forces or really even the possibility for any additional force conservative or non-conservative to reach into the system and alter it somehow by adding or taking mechanical energy away but what if there is the possibility of such a force what if you know a good example being the the ball thrown up into the air what if i stick my hand out as the ball is falling and act on the ball with my hand now that's an external force suddenly gravity is competing against my hand and my hand has the ability to add or take mechanical energy from the system because i am a chemical organism i can store energy in the form of fats and sugars i can convert them on demand to things like ATP i can make my muscles do work so i am a storehouse of chemical energy and i can put energy in or i can take energy out of a system as a result of doing work or having work done on me so let's include this possibility let's add additional changes in kinetic and potential energy that could be possible if such a general force can reach in and do work or have work done on it by the system so we simply extend our definition of changes in kinetic energy and changes in potential energy to include the fact that work can be done on the system right so we know that work is equal to the change in kinetic energy and work is equal to the negative of the change in potential energy so any work that's done on a system with a fixed amount of kinetic and potential energy will cause changes in one or both of these things now when w is equal to zero that is when no work is done on or by any external force then of course we recover the conservation of mechanical energy the sum of the changes in kinetic and potential energy will be zero but when w is not equal to zero when we have such an external force we learn instead that the work done by or on that force is equal to the change in the total mechanical energy of the system delta k plus delta u so external forces have the ability to put new energy into a once closed and isolated mechanical system or sap energy out of that system so now we can think about non-conservative forces and we're going to use friction as an example of this so just as we might imagine some external force like my hand for instance intervening in the ball gravity earth system and putting some more mechanical energy into the closed system by acting on one or more of its parts we can imagine a force that saps energy from a closed system and non-conservative forces do just that so let's consider a block of mass m that's pulled along a surface okay and it's accelerated up to some initial speed v zero but it may continue to accelerate after that depending on the net force acting on the object all right so let's say i pull on that block by using a string attached to the block and i exert a force f now at all times friction will act to oppose the motion if the surface in contact with the block has friction and i know that there's a friction force f sub k the block is moving this is kinetic friction now i do work and friction does work and if the block is accelerating during this process then we know thanks to newton's second law that the sum of the forces must be equal to the mass times that acceleration so the force i exert big f minus the force exerted by kinetic friction f sub k is equal to m times a now we can figure out what acceleration is by thinking back to equations of motion we have an equation of motion that relates v squared the velocity at any time t to v not squared plus 2a delta x and we can rewrite that equation we can substitute with velocities v squared minus v not squared over 2 delta x we can put this into newton's second law equation here and from this we learn that the difference in the force i exert and the force exerted by kinetic friction is equal to mass times this thing i've just substituted so i have for instance m times v squared and m times v not squared and oh look both of these terms are divided by a two so i have a one half mv squared and a one half mv not squared this is the final kinetic energy this is the initial kinetic energy so this entire equation can be recast into an energy equation and i find that the difference in the force i exert and the force exerted by friction is equal to one over the displacement times the difference in kinetic energies or delta k over delta x now this is just considering a block that's moving at a constant gravitational potential energy moving along a horizontal surface for instance where there are no rises and falls in the block so that i'm not going further from the earth or closer to the earth but in general i could imagine this block is for instance being pulled down a ramp or pulled up a ramp and then it might start with some initial gravitational potential energy and later on after sliding some distance along the surface of the incline it might have a different gravitational potential energy so it will be true in general moving the delta x to the left side of the equation that my force times delta x minus the kinetic friction force times delta x will be equal to the sum of the changes in the kinetic and potential energies which of course looks familiar this is the change in mechanical energy of the system so this is just a kind of recasting now with specific forces me pulling on an object the object having friction do work against its motion here are the forces and the displacements on the left so these are works and this is a change in total mechanical energy we see a specific example of something causing a change in mechanical energy in a system and so we see that what's going to happen here is that friction is going to take energy out of the block gravity system all right so now especially if the force of friction is in excess of the force i can exert on the brick to overcome friction then we'll find that the change in mechanical energy will be less than zero but nonetheless i have to keep putting work into this system with my external force in order to keep this acceleration going or in fact even to keep a constant velocity going i have to do this i have to put energy into this system because friction keeps taking it away all right if i don't do that total mechanical energy of the system will continue to decline over time and eventually it will go to zero and the block will simply stop moving but the question here is where the heck is all that energy going where is that lost kinetic energy going where is that lost gravitational potential energy going where's the lost work that i'm putting in to overcome friction going and if you do very careful measurements of systems like this where friction for instance or drag plays a role what you'll find is that the energy that is being sapped away by friction or drag is going into heat it heats the block it heats the surface on which the block is sliding effectively energy is being transferred into atoms through collisions and the collisions cause the atoms to vibrate and smack into other atoms and this vibration this increased vibrational energy in materials this is what we call heat so when you touch a pan that's on the stove and you burn yourself it's because the atoms in the metal in the pan are moving so fast that they crash into the atoms in the chemicals that make up your skin and tear the atoms out of their current locations in space which causes physical damage to things like cell membranes and so this is why a severe burn will cause your flesh to basically die it's because you have essentially sliced open your cells and cause tremendous cellular damage all because of the kinetic energy of those fast moving atoms in the hot pan but that's not the only place go that this energy goes if you slide a block across a table it'll make a noise that sound sound is another kind of a thermal like energy it has to do with the motion of the microscopic components of material in this case the collisions of the molecules or atoms in the surface that are vibrating with air molecules which then transmits those vibrations through the air that's what we call sound so we might represent the total energy of this complicated block gravity surface system by trying to account for this energy and i'm going to write it as follows that the total energy of the system is not just the mechanical energy because that gets sapped away by friction for instance but in addition there's this other kind of energy this energy of the internal motion of the material its parts start getting jiggled around by collisions i'll call that thermal energy and so really the total energy of this system considering the surface the block me pulling on it and the friction force is the kinetic energy plus the potential energy plus the thermal energy at any given moment in time so i've talked about using careful measurement to try to demonstrate to yourself that when friction exists between two surfaces that are in contact with each other that mechanical energy will be lost into this thermal energy but can i demonstrate this to you i think there's no more dramatic and direct demonstration of this fact then the lighting of a match a match is just usually a piece of water paper with some chemicals at the end if you actually expose those chemicals directly to what you would traditionally think of as heat energy for instance the the flame that comes off of the end of a lighter or a candle well then of course those chemicals burst immediately into into flame heat suddenly initiates the chemical reaction that then causes fire at the end of the match but i can demonstrate to you as well that friction is capable of igniting that chemical reaction by striking the match rubbing the match's head against a rough surface which equally well ignites the match into flame it triggers the chemical reaction that starts the fire and of course this is the whole point of a match it's to convert friction into heat energy which then triggers a chemical reaction that begins a fire burning that's what makes them so convenient so now we can quite generally think about the conservation of energy in a system in the real world there are not just non-conservative forces it's almost impossible without very special care to remove all of friction or all of drag all of these non-conservative forces so we have to write down as general as possible an equation to account for all the ways that energy can be represented in a true physical system and so we would probably write down something and in fact we will write down something that's actually more like what follows so imagine that there is in fact external forces that can act on a system so that work would be represented by w it could be many forces that are acting in concert or some against others but nonetheless in net there will be a net work done by external forces on a system now that system can contain energy in various forms it can be in kinetic energy it can be stored in potential energy it could be in thermal energy and as you'll encounter as you move forward in the study of engineering physics chemistry and other subjects there are other forms of energy internal energy so for instance you possess internal energy in the sense that you are a large chemical storage device that is capable of taking in sugars and fats and converting those either into short-term energy ATP which your cells have to actively burn in order to execute metabolic processes but it can also be put into long-term storage in your body in the form of fat cells for instance so you are a chemical storage device your body is a processor for converting stored chemical energy into things like mechanical energy think of the motions of your arms or legs you know turning your head from side to side that's all mechanical work that's being done by your body atomic and molecular systems well you know atoms are are in a sense rigid things but molecules don't have to be molecules or bound states of atoms and those bound states can twist with respect to one another they can stretch with respect to one another and they can rotate so it's possible for systems to store energy in other forms in internal forms that are not obvious to the eye but which nonetheless represent the storage of energy so there could be vibration or rotation you could store it in the form of chemical energy which can be burned later and released in the form of mechanical energy so in that case work done by external forces would be equal to the sum of the changes of the mechanical energy and the thermal energy and the internal energy that in turn is equal to the change in total energy that is caused by the network done by those external forces now for a closed and isolated system which we started with in this whole conversation which we will now return to closed and isolated means there are no external forces that can reach into the system from outside an act then it will be true that that work done by external forces is zero and thus the sum of the changes in mechanical, thermal, and internal energy must be zero that is to say in a closed and isolated system on which no forces can act the total energy in that system doesn't change it may move from one form to another a loss of mechanical energy may represent a gain in thermal energy but in net the total energy will not change and is thus conserved delta e total is zero in this case now it is worth noting that this has been the observation of countless experiments and it's not that people set out these days to challenge the conservation of energy but nonetheless because it is such a fundamental and underlying concept of almost everything that we do now when we build system engineer systems test the laws of nature we inadvertently always wind up testing the conservation of energy and to date no violations of this law have been observed despite the fact that it's essentially tested by every activity humans carry out now in technology so because it has never been observed to be violated it is truly taken as a fundamental law of nature that in in a system where energy can either enter nor leave through the action of work by external forces there will be no net change in the energy in that system it can change forms within the system but it cannot leave or enter the system in principle for instance because we believe that the universe itself is a closed and isolated system out of which nothing can leak and into which nothing can be gained since the universe came into being and across the entirety of the whole universe the energy that was available from the beginning of time has remained unchanged since the beginning of time now we have tested this in various ways and so far it seems at the grossest largest scales of the cosmos that that has been true but nonetheless it would be interesting to observe that that has not been true and would teach us something deep about the universe if we could observe it but today we have not observed that and in fact as far as we can tell the total amount of energy present at the beginning of time is still present in the whole of the cosmos today you know some of it may be bound up in stars some of it may have been lost from now very cold regions of the cosmos but on average the total amount has not changed so it may have been redistributed internally within the cosmos but it is neither going up nor down it's merely changing internal form and this claim from the conservation of energy principle has deep implications for the cosmos which we continue to test with experiments today and so far we have seen no violation of this principle and so accepting this principle as a law of nature it teaches us a great deal about the evolution of the universe over its 13.78 billion year life but you might ask why is energy conserved okay it's fantastic that you can do experiments and you can see that it's conserved but why why why why why is the question humans always want to know the answer to and i can give you an answer that's partially satisfying and partially unsatisfying physics is really going to teach you most deeply about the the deepest house of things and it will give you answers to many why's but as often happens when you answer one question you raise a few more or at least one more and here's a good one we're going to trade the question of the conservation of energy for a different question the answer to the why of energy conservation it went way beyond the discoveries of people like Dushatale and Lavoisier and Gottfried Leibniz and so forth all of these people Newton and Lagrange and Hamilton and so forth i've mentioned a few of these people but lots and lots of people were wrestling with questions related to energy and energy conservation but the why of it would have to wait until the late 19 teens early 1920s when an absolutely brilliant young mathematical physicist named Emmy Nether was very active in her field she faced the usual challenges of women pursuing scientific careers in her day she was not taken very seriously and in fact in the system in which she was looking for work in her field which was the German system at the time women were actively barred from having positions that would allow them to for instance take credit for their work they could not achieve the highest levels of academic prominence in their field even if they were as good or better than their male counterparts. Emmy was hired by a math department that was very interested in showing up the status quo by bringing in a really fantastic mathematician and showing all the colleagues in the other departments that these policies were sort of nonsense but it wouldn't be until after world war one when a lot of young men had died in Germany in war that the the academic system would be opened up so that people like Emmy could actually seek permanent positions and get the credit that they so richly deserved for their work. Her most famous work is summarized in what are known as Nether's theorems which I did not really learn about until graduate school and so that's why I'm telling you about them now because they have deep implications for the entirety of the cosmos from its founding to today to its fate and one of the things that she noted was that when a mathematical theory of nature okay a coherent consistent predictive mathematical description that accurately reveals the character of nature has a special property known as a continuous symmetry then it will have an associated conserved quantity so if you can show in a mathematical theory that you have written down that it has some kind of transformation that when continuously made leaves the system of equations invariant it will also have associated with that symmetry a conserved quantity and the known mathematical theory of nature and the way we've been looking at it you can think of this as the laws of mechanics like Newton's laws but also electricity and magnetism these these theories taken together as a description of nature are invariant against shifts in time even continuous changes in time the form of the equations remains unchanged when you shift time around continuously this implies via another's theorems that there is an internal quantity that's conserved and if you work through the mathematics of it and you assess what is the quantity that's conserved under this specific symmetry it turns out it's what we call energy that is conserved so why is energy conserved in the universe energy is conserved in the universe because fundamentally the universe is robust it is invariant against continuous transformations in time it doesn't matter whether the laws of physics are written down now or now they're the same and because of that the universe is invariant to overall changes in energy energy is conserved so there's an answer why is energy conserved but it raises another question why is the universe invariant under continuous transformations of time i hope you can figure that out no one else has it's a fantastic observation about the natural world it has not been shown to be violated in any way and the why of it would of course be a deep answer to one of the deepest questions that we as human beings have about the entirety of the universe let's return to the demonstration that i started this lecture video with i take a bowling ball affixed to a cable attached to the ceiling i place it on my chin and then i'm going to release the ball it starts with no kinetic energy and all potential energy it now falls to the bottom of its motion where it has all kinetic energy and then it swings up toward the second camera where it stops it has only potential energy the motion reverses and now it heads back toward my face i would predict that absolutely nothing would happen and i would be right the ball actually doesn't get to my chin it comes up a little low and that's because it's lost energy to other forms like friction drag and even the motion of the cable during the swing so let's review the key ideas that we have explored in this section of the course we have come to understand that energy can change forms as we have touched on earlier but it is neither created from nothing nor entirely destroyed and certainly speaking about the whole of the universe which seems to behave as a closed and isolated system that is universally true in small scale within pockets of the universe one has to very tightly control the conditions to isolate the system for instance from external forces non non-conservative or conservative forces but once you are able to do that it is observed there locally instead of globally to be true that in fact energy is conserved we have explored the mathematical description of energy conservation it's not the worst thing in the world it's that the total energy is equal to the sum of the energy in each of its parts and that that total absent external forces can never change and so for a closed and isolated system it will be universally true that while energy may change forms from mechanical to thermal to internal and back and forth it will never overall change its total value and we have explored the implications some of them quite deep and cosmic about the very fabric of reality and why the universe behaves the way that it does by looking at this observed feature of nature the conservation of energy I have teased to you nother's theorems which are a deeper explanation of the relationship between a conserved quantity and a mathematical symmetry when a mathematical theory is invariant under some transformation it implies a certain kind of transformation it implies a certain kind of conserved quantity though there is a deep connection between these two things why that is and why the universe is robust for instance about continuous changes in in time well that's a deep question that I hope some of you might one day answer no one else has figured it out yet but maybe somebody will so I hope you have enjoyed this look at the conservation of energy both its local implications for building mechanical systems and thinking about their designs but also globally how this issue touches on the deepest questions of reality that human beings have and so you may just be thinking about a simple mechanical system that's how a lot of these considerations get started but it turns out that those simple considerations much as in relative motion just the relative motion of two things and what each observer observes in each other's frame of reference these have profound implications for the nature of reality and we will see more of this as we continue to tie these ideas together in this course and in future courses