doi
stringlengths
17
24
transcript
stringlengths
305
148k
abstract
stringlengths
5
6.38k
10.5446/19965 (DOI)
Okay, I'd like to introduce Durgel Matthews to you. Okay, Durgel is currently one of our Pycan UK guys. Now in two months time that may be different because he comes from Scotland. And in contrast to Germany which has unified we seem to be possibly deconstructing in the UK. So after that we may call it the disunited kingdom. Anyway carry on. Thanks John. Cool, yeah so I'm a Pycan Easter and I'm a skier that's like two of my favorite things and as John said I'm Durgel I live in Glasgow. I am a developer at Red Hat where I work on OpenStack day-to-day and that's my Twitter. It's Durgel with a zero rather than O but yeah and that's my my GitHub and various other things as well. But this project is nothing to do with work. This is obviously like a side project of mine something I've been working on for around six months on and off and that kind of thing. So just to talk about home automation I'll first sort of define what it is about home automation that interests me the things that I'm sort of aiming to do and I kind of like to split it into three different categories. So the first one's monitoring it's like what is happening now in my house? What is the temperature? How much electricity am I using right now? The next one is historical data so this is sort of collecting this over time and hopefully identifying trends and learning something from it and then adapting. This one will take a lot longer to pay off and I probably don't have enough data yet because seasons change things so much and how you sort of behave. And then the last one's pretty obvious it's controlling so it's like I want to turn the lights on I want to turn something off I want to sort of turn off power sockets overnight because I'm not going to be using the TV like between 2 a.m. and 6 a.m. or something ever and you can just stop things using a bit of power and standby so that's kind of the things I've been doing. So yeah then for my setup there's sort of the brains of operation at the moment is a Raspberry Pi. I've actually bought a big old own black that I'm going to move to just for a bit more speed essentially and then the sort of the core communication of everything is using a device from a company called RFX com which is a TRX RFX radio transceiver so I use that for sending or receiving and sort of communicating between all these devices. It's a radio device that works on 4 through 3 megahertz and one of the things that surprised me about getting into this is how many companies make devices which work on this frequency and that's been quite nice because I kind of figured I'd have to support a bunch of other things but so far I've managed to avoid it. I might look into Bluetooth more energy because it's quite neat but for now it's not really on my radar fully. So just to sort of quickly go through the devices and let you see what they are this is what the the actual radio thing looks like. It's not particularly attractive but it works well and it's a serial device that works over USB so you can just see the micro USB input there. It works well but the only thing I have issues I live in like a really old house from like 1900 or sorry 1920s I should say and some of the walls really block the signals but otherwise it's really good. Then for electricity I use there's a company called Al and they make this device which is the LCM 160 I think and basically there's a little clip on the left that you can attach to the cable going to your electricity meter and then every minute it sends out a packet which is got like the current watts and the total watts and then you can just pick this up and I'll show you that in a minute. And you can get a display with it it's kind of it's more expensive you buy it with the display side if you're actually quite serious about doing some of this stuff I'd recommend not getting it. I got it originally because I wasn't sure if I'd get bored of this project so I wanted to at least be able to see the data somewhere because otherwise it's useful so just having radio waves. Then temperature humidity is again pretty boring in terms of looking at a device and it updates every minute again so roughly and it just spits out the temperature and humidity of wherever you have left it. I've got these kind of scattered around my house so you can kind of start to see what's going on in different rooms. And then sockets and light switches from a company called Lightwave RF. These are just remotely controllable so you can turn them on and off. The one thing I should have made a bit clearer. So the electricity readings and the temperature humidity they are transmit only. They basically send a message and assume somebody is going to receive it. With the switches and sockets they are received only so you kind of have to send something and assume they have had you. And the way it works is you put them into a learning mode and you send a command with an ID. They remember that ID and then if you send a game with the ID they will listen to. So yeah, to kind of give you an idea of how the data looks like. This is an example packet coming from one of the electricity devices. I'm kind of going through this stuff fairly quickly because it's not that interesting but I didn't want anyone to have a like not really understand what I was using at all or like how it worked underneath. So that's the kind of take away from this bit. So this is an 18-bike packet and there's a sort of a similar standard for all of them but they vary after the first four bytes. So the first byte the X11 tells you that it's a 17-bike packet so it's the length of the packet but excluding the first byte. And then 5a is the so it's the hex for the the sort of the family of devices so I know it's an electricity monitor and then 01 tells me that it's that specific L and then after that it can vary depending on the first three sort of things. So you've got to really look into the spec and that's quite hard to get your hands on. The guy who makes the RFX com you can get the sort of the SDK but you've got to sign an NDA for it so you can't actually give out the SDK to anyone else. His reason being is he doesn't want anyone to ask some questions it isn't a real programmer. He just does not want to support this thing basically to anyone else. Yeah and that at the bottom there that then just shows the actual extracted data from that packet so the there's the ID the total watts and the current watts. That's basically all you get out from that. There's other things like battery level but yeah I mean that's the interesting data. And with a system like this we basically the whole thing is like an event stream and there's just stuff happening all the time and you just have to sort of react based on what was going on. So some of these are like incoming and some are outgoing so the likes is like an outgoing thing I'm sending that message to say I want to turn on a light then I get readings from a room some of them on through one room and so on and then an electricity reading and it just continues over and over. So that's kind of what drew me to something like Async.io. Well actually I kind of wanted an event loop. I wanted something where I could react on events and it seemed like quite an obvious match to me but then I wanted to play with new stuff so that's what actually brought me to Async.io and now we'll sort of move on to that part of the talk. This is how the packing documentation describes Async.io. I personally don't find that a very useful description it's kind of unless you are already familiar with a lot of the internal terminology it's really it's kind of confusing. Daniel poked on a talk earlier this week and he went into a lot of more detail in sort of event loops. It was actually the title is a G event talk but he went into a lot more detail about event loops and how Async.io works so if you want to really understand that in a lot more depth you should watch that one check out there's some good talks by Guido on Async.io as well. It's fairly new so there's not a huge amount out there but there are some good videos. But basically I sort of the dumb really dumb version of what an event loop is is it that it spatches sorry it waits for and dispatches events and then calls an appropriate handler for that event. Oh yeah and just sort of before I move on to this because one of the things about Async.io is it's Python 3. It can have a little show of hands of who's using Python 3 at the moment sort of in work or anything that okay it's this one number and keep your hand up if you have used Async.io all right so that's probably about half the Python 3 people so you're all in at least 3.3 then so that's good. Right yeah so let's look on some code this first example here is it's kind of a dumb down example it's just Python right there's no nothing non-standard here this isn't Async.io yet at all. One of the things that Guido is sort of pushing for is that the Async.io code should just read like normal Python when you strip everything out so I kind of proved this fact by going to the documentation taking one of their Async.io examples removed all the Async.io special bits and now just works like a normal normal code so basically what we're doing here is where we've got a function which calls out to an expensive compute function and then we would get a result from that so just to turn that into like a non-blocking operation you just need to do a few minor adjustments so you'll see here that we so we put on a decorator on each function and then when calling the expensive sorry we're going to call them compute and when calling the sleep we use the yield from so basically when that happens we suspend the code routine so we'll go into print we'll get to the results and when it yields to compute that will then be suspended and then we go into the compute function and then it is suspended when it gets to sleep and then it kind of moves up and down the stack like that so I'll just quickly skip back again so you can kind of see the difference because it's really it's fairly small there they're really quite similar apart from the decorator the the yield from and then there's a little bit down at the bottom which kicks off the event loop which is kind of ugly I think but you only really do it typically once per app you can use multiple event loops but that's a fairly advanced feature so to move on to something that's a little bit more relevant to what I've been doing I never actually mentioned this device because it's really quite simple stuff but I've got like a webcam which you can just access over the network so you can just make a request to a URL grab the image and then store it and why I was trying to do is I wanted a recent image that I would just store and have it in a convenient place so I update every five seconds and I just have one it's so when I want to view the live stream that's fine but I don't want to load that on every page I want to like a nice recent image just to show in someone browsing the website which I'll show later as well yeah so basically I'm using here I'm using this async I there's another library called AI or HTTP which is like a async I request clone essentially and then there's an async I read this library which again is just like another another library written for async I go to and write the redis and this is actually one of the sort of the pain points that I find we're working with async I always suddenly have to start looking for libraries which support the the protocols in the way that it's working so you've got to kind of rethink things and it's like you're suddenly back it a really small standard library or sorry not standard library a really small ecosystem of things you can use it'll be non-blocking but again if you read this function you will find that it's really fairly straightforward to read so if you ignore the coroutine decorator and the yield from its simple procedural code which would otherwise work as normal but instead it's got it's yielding to creating the connection that's yielding to downloading the image and then yielding to the redis so it's all non-blocking and then it just repeats every five seconds so I'm just pulling down an image every five seconds I've got stored in redis which is convenient although I actually stopped using this approach this is something I was just messing around with but I thought it should demonstrate quite well there's a bunch of different libraries that are useful the main reason I was trying to do is I didn't want to write to an SD card on a rush-by-py every five seconds and eventually burn the thing up okay so Python RFH com is a nice and coy based library for working with the the radio device so this is something that I've been writing there are other Python libraries for working with the RFH com but there are no other ACI and co libraries and some there's one that uses twisted and I they've actually done a reasonable abstraction for the transport protocol so I did think about just writing a difference of transport for it but some of the code choices I kind of objected to so I decided to write my own and I saw the a reach quit when it it starts suppressing errors but having since I wrote this myself it's fairly new and it's currently limited to devices I support but it is working fairly well and I'm adding things when people are sort of helping me up with testing so the the problem I found is when I I got into this as new TAs and current I walked straight away into the the callback trap it's kind of like the the very simple model and this this gets kind of ugly easily in this particular app it's really fairly simple so I'm basically setting up the transport I'm passing it the serial device I want to read and the the event loop I'm running on and then the callback I want to be called it works fine but it just doesn't it doesn't really feel very elegant and it's a there's a sort of a bunch of pitfalls with callbacks and you kind of the biggest one really is it breaks out of your standard Python development flow I'm still working on a better solution for this and if there's anyone that's like familiar with ace and car then I would love some help the the problem is some of the APIs are restricted to callbacks only so I use the the low-level function for calling the file descriptors and that expects a callback so I need to somehow go from I want I want this callback when I can read the serial device but then I want to move to this of the generators and futures and I found that a bit tricky so far so this is showing another example this is something I've actually found quite useful with the yield from is you can be more explicit about how you sort of when you've yielded to the event loop it allows you to do a combination of blocking and non-blocking operations so this is actually kind of pseudo Python which is just copied and then reduced down a bit from the code because when I'm doing the setup of the the radio device I need to reset it and then I've got to wait a period of time and then send us a status packet to check that it's ready and if you get the timing of this wrong it just doesn't work right so I wanted to be more blocking in the way I was doing it but then afterwards I wanted to not be blocking so it kind of switches to then using the yield from where I set the mode which is how I enable and disable different protocols and I'm not sure how you do something like this in CG event when you want to have a mixture of things when you've got the monkey patching happening so for the that's kind of like the data collection and how I've been working with that kind of thing and with the actual physical devices and then presenting the the results on the dashboard that I've written so it's a fairly simple web app and it's kind of a side to the the bits I find interesting the talk so I'm kind of skip over this fairly quickly it uses flask ready says well can we bootstrap and basically it's just a way of viewing this data sort of graphing it so I've I've got like a sort of a simple time series which I implemented although that turned out to be a big mistake I have to say to write your own and and all the code for this is on my github so if anyone actually wants to dive in or try and use it they can do the code is horrific this has been kind of like the dashboard it's gonna be like my play area and I'm slowly spinning stuff off to actually make more reusable stuff which is tested and not just terrible yeah no yeah that's kind of why I'm blazing over it it's just yeah it doesn't just for the mic it doesn't use a flask at all which is sorry it doesn't use a sinker and the fast web app yeah so this is kind of what the results of what I'm seeing so this is just like the default view which shows you the the 24-hour period of what's going on in my house and I kind of cut out to remove some of the more sensitive information but you can get the idea so that's like the LTC uses aggregated over the day and at the top and then that's the sort of the current readings at the bottom so you can kind of see things happening like when an oven's been turned or you're boiling a kettle you get huge spikes and the the one that I try and get down as long as possible is at the beginning there's this sort of idle period where we're sleeping or we're not in the house and that's really when you're wasting a lot of energy a lot of the time just because there's stuff in you so the things are happening and you're not there to take advantage of it and then just to show another graph we've got the this is humidity and temperature it was in my lounge it was like when we had a really hot period we do have them occasionally in Glasgow and that as the afternoon comes round the sun goes right into the living room and it just thought you see the temperature rock up okay so to sort of move on to some of the lessons I've been learning with this project I'm finding asian co is pretty nice to work with but it does feel quite a low level this is one of the actual points of it they want the ideas to have further abstractions added on top so I'm hoping that say twisted is probably gonna support it and that might aid their portopioid and three I don't have a clue if they're actually doing that but I'd be surprised if it's not on the cards at some point the ecosystem is young so it's at the moment it's quite it's quite tricky doing things there's not a huge amount of examples or documentation out there so when you're learning about this and go it's kind of tricky and most people are doing a building like services or they're doing I guess network traffic and things there's not really anyone else that I found doing sort of serial devices or messing around with these particular API so if you go looking for examples in GitHub I can find how to scrape websites that's fine but yeah doing some of this doesn't isn't really that popular with Python 3.4 right yeah and the other sort of the key thing is I should have used graphite for my my data collection and writing your own reddit time series is actually fairly easy but it's just a bit of a pain in the ass if you want to maintain it and yeah the reason I didn't I was just being really lazy about actually getting set up and I just wanted something running so I started just inserting data into postgres and it's kind of slowly moved but Redis on a Raspberry Pi is actually still amazingly slow okay I think I've kind of touched on most other things but the the coroutines of futures is something that they when you're working with them they feel a lot nicer to work with so there were some in my examples I probably didn't call them out that well what are they sort of the difference between the two but the problem with as I was saying with the APIs is it's it's hard to know how you can use callbacks in futures when the documentation is explicitly just defining only callbacks so the kind of confusion between two is a bit tricky and that's what really is about everything for me so I went through that a little quick but yeah I'd be happy to take some questions if anyone has some. Thank you. Have we any questions? Okay. Just a quick question what sort of money is involved there in these? Oh it's an expensive hobby. 100,000? I've spent a few hundred I guess I could actually go and find I can give you links to all the devices you want to find them they're pretty easy to buy on Amazon. It's tricky knowing what is compatible which is partly why I wanted to list everything at the beginning but yeah it does get quite expensive because you're kind of like oh I could just buy another one of these but yeah it's an expensive hobby so I'm definitely not saving money by cutting down my electricity usage yet. Okay I have a question as well are there any civil devices for monitoring gas consumption? So this is kind of odd because there's like there's an area blocked out on the speck for it and there's actually is to find how it will work but I can't find anyone selling them so I've been trying to think of creative ways to do this only option I thought of is a webcam and OCR in the number but that seems a bit crazy. Hi, so you've wired up your house, your plugs that you can ping and what about the security of all this? So I could drive up by your house and switch everything off perhaps. In theory you could do some of that the so the range isn't that great on the on the devices yeah so if you set outside and you listen to the packets I was sending and then you just need to take the IDs and then you can turn things on enough you wouldn't know what you were turning on enough necessarily. Well that'd be kind of fun to watch the light switch on and off wouldn't it? One of my friends is doing a similar thing but he's been doing it with Node.js and stuff and I was considering going out and like trying to troll them just like setting up a Raspberry Pi with like a battery pack and things take the car out next to his house and see. Yeah and given that this talk is being live streamed on the internet will be available on YouTube you don't have any concerns about the... I don't think I included my address bit. Good point, good point. Thank you very much. What about higher level web frameworks and I think I would you know if anybody is doing any work on doing that sort of thing in Python at the moment and if there's anything that's particularly difficult about that? I don't really know to be honest. I did spot I think there's somebody's done a port of Flask. They just seem like I was already feel like I've been learning a bunch as a web developer all this kind of bikes and stuff is a bit odd to me so I feel like I've been learning a lot but then I started looking at Mesa and Co web framework options and I was like I don't have time for this so I just went with the Flask approach which seemed simple enough. But yeah I've actually been kind of regretting that in a way because I then ended up writing my own rest framework on top of Flask right? So ideally what I want is an async arrow rest framework because I can just do the UIO and JavaScript that would be much nicer. Hey you said something about a gas meter reading just now about an idea of looking at it with a webcam. I don't know if your gas meter is also from the 20s then you're probably out of luck but usually these meters have like an infrared beep like for every cubic meter or so you can look into that. Cool I'll take a look at the one extra ratio I have is my gas meter is outside so I just like weather considerations but RF right? Yeah well I'll have a look. Thanks. Do you have any support for like motion sensors or? Yeah so there's the the company that makes the switches in the sockets they've also got actually loads of people make them but I've got some from the same company the PIR sensors. I'm not doing a huge amount with them yet so that's still kind of work in progress but yeah I mean so in my the one thing I've got is in the hallway I'm turning on the light when it's dark and so if you're like going to the lute nighttime the lights turn on for you that's my girlfriend's my favorite feature I think. Thank you. Anyone else? Oh well thank you to all that's been interesting. Hi let's know my question if you would have choice Python 2.7 which technologies would you have choice for the library? Yeah so if I done it in 2.7 I would probably went with twisted simply because they have got serial support included in the twisted standard library I don't know what they call it so that would have been a lot easier. I ended up having to kind of figure out a bunch of stuff there which I wasn't too familiar with. So yeah twisted would have been a good choice I think. Well you've certainly provoked some interest there. I expect all the euro of Pythonesis will have their houses automated next year. If anyone else wants to try my code out as I say it's all on GitHub so I'd be happy to help anyone because it is good fun. Thank you and 12.30 out chef.
Dougal Matthews - Using asyncio (aka Tulip) for home automation This talk will cover the new asyncio library in Python 3.4 (also known as Tulip) and will use the area of home automation as a case study to explore its features. This talk will be based on code using Python 3.3+. Home automation is a growing area and the number of devices and potential applications is huge. From monitoring electricity usage to the temperature inside or outside your house to remote control of lights and other appliances the options are almost endless. However, managing and monitoring these devices is typically a problem that works best with event driven applications. This is where asnycio comes in, it was originally proposed in PEP 3156 by our BDFL, Guido van Rossum. Asyncio aims to bring a clear approach to the python ecosystem and borrows from a number of existing solutions to come up with something clean and modern for the Python stdlib. ----- This talk will cover the new asyncio library in Python 3.4 (also known as Tulip) and will use the area of home automation as a case study to explore its features. This talk will be based on code using Python 3.3+. Home automation is a growing area and the number of devices and potential applications is huge. From monitoring electricity usage to the temperature inside or outside your house to remote control of lights and other appliances the options are almost endless. However, managing and monitoring these devices is typically a problem that works best with event driven applications. This is where asnycio comes in, it was originally proposed in PEP 3156 by our BDFL, Guido van Rossum. Asyncio aims to bring a clear approach to the python ecosystem and borrows from a number of existing solutions to come up with something clean and modern for the Python stdlib. This talk will introduce asyncio and use it within the context of home automation and dealing with multiple event driven devices. Therefore we will cover asyncio and the lessions learned from using different devices in this context. Some of the devices that will be used include: - Raspberry Pi - RFXCom's RFXtrx, USB serial tranciever. - Owl CM160 electricity tracker. - Oregon scientific thermometers. - Foscam IP cameras. This talk will also briefly cover the previous solution I used which was developed with Twisted and compare it briefly with my new code using asyncio.
10.5446/19963 (DOI)
So our next speaker is Dmitry Trovimov and his talk is Python Debugger Uncovered. Dmitry is a developer of the PyCharm IDE. Hi, my name is Dmitry. Today I will speak about Python Debugger. First, I will introduce myself and this talk. I work for JetBrains and the last four years I developed PyCharm and Debugger is among the other things that I do. And often when I say people that I develop a Python Debugger, they say, wow, that's kind of hard or complex. But I'd like to show you in this talk that developing a Python Debugger is quite an easy task. There is no rocket science here. But in the first place, why do we need debuggers actually? As Brian Kerrigan wrote in his book, debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are by definition not smart enough to debug it. And what we do normally, we always, or often, but I think rather always, write our code as cleverly as possible. And as a result, we have bugs that spoil our code and then we need to find those bugs and we have problems. The only thing that can actually save us is good debug tool. And we'll look how to implement one. So there are a lot of Python Debuggers, but I roughly divide them into big groups. First one, Python Debuggers that are implemented in Python itself. And those are PDB, PyCharm Debugger and PyDev Debugger. Actually, PyCharm Debugger is a fork of PyDev Debugger. It was forked four years ago and it gained a lot of new features. And now we're in a very strange situation when we develop this PyCharm Debugger separately and Fabio, the maintainer of PyDev, develops it separately and we exchange the fixes and backport features. But we're now in some kind of process to stop the situation, but I'll tell about it in the end of my presentation. So Python Debuggers implemented in Python. The most advantage of such debuggers is that they are platform independent. They can run on C Python, JITON, PyPy, on Python. That's why that is because they're written in pure Python. But the problem with this debugger is that they can be broken by user code. Because they run the same Python interpreter, you can just write something like clear CIS modules and Debugger will evaporate from the memory and it won't work anymore. The second group of debuggers are those that are implemented in C. The main debuggers are VIN, PDB and VINC. They work only for C Python, but they don't interfere with user code. So they work better for such cases like debug of GVENT or Twisted Code. But that is actually not a problem for Python Debuggers written in Python because all those cases can be solved, but you need to make something for that. So how to implement Python Debugger? Actually, many languages provide developers of debuggers some kind of API to develop Debugger. And Python is a bit different in this case. It provides only one function to develop Debugger, this function is called CsetTrace. And if we look into the Python documentation, we see that you can set trace function and it will be called every time you get any event in the Python interpreter. And event can be a call of function, execution of a line, or return from a function, or exception, or if you use some kind of C bindings, then it can be called C function and return from the C function or C exception. So when we want to implement our debugger and we see this documentation and we realize that this is the only one function that we can use, we can get a bit scary because it's very primitive and we feel very constrained. But as we know, constrained brings creativity. So as I show you, because of that fact that we are constrained a lot, we can implement a lot more features than actually exist in normal languages like Java and C++ and so on. So trace function, how can we use it? Here we implement a simple trace function. That is a function with three arguments. The first one is frame. That actually is the top of our call stack. This is the context which has local variables. The event that we get and some arcs are dependent on the event. And we print just which event we get and on which line we get. The line that we can access from the frame. So we import our C module, set trace and then we have some simple code we iterate for within a range and print the division of some arithmetic expression. Let's look what we have. So after we have set our trace function on the first line, that will be line number nine, actually it will be line number 13, but we have call of the function that is declared on number nine. We have a call. Then we have execution of a line number 10. Then we have execution of a line number 11. And after that, we got the first output. When the iteration continues, we are again on the line number 10, on the line number 11, and we get gain output. And on the third iteration, we have an exception. So execution terminates. And you see that we have in this short program, we have all four Python events that are possible. Call, line, exception and return. So actually that shows us that developing debugger with the help of trace functions is possible. So let's develop simple console debugger. To test it, we use a sample program that is simply a retothense sieve. It's a function that gets n as a parameter and prints all the primes between two and n. And here are our command line debugger. It's actually only 23 lines, and it works. I'll just tell you about how it is implemented, and then I'll show it in work. It has two main parts. The first part is trace function. As we've seen before, we get events. And here, except just printing all the events, we have a breakpoint. There is only one breakpoint. And if the current execution equals to this breakpoint line, we do the simple thing. We just read the input from console, and we handle commands from console. There are three possible commands. The first command is frame. If you get it, we just print all variables. The second command is see. It's for continue inspired by GDB. And we continue to the next execution of the breakpoint. And any other string is just treated like any expression that is evaluated. And the second part of this simple debugger is the main part. We get here from command line arguments the line of the breakpoint file to be debugged. And then we set our trace function as trace function and execute this file. So let's look how it works. So you see we execute our simple debugger. We set our breakpoint to the line number six. And we pass our dot pi as our sample program. So the debugger stops somewhere. And we type frame, and we see that we have three variables. That's our index, our multiple set. That is empty now. We continue. And we get to the first prime. We print our frame again, and we see that our index is three, and multiple set is all even numbers. So we can continue, continue, continue. And if we don't want to read all this frame, we can... No, that doesn't work. Print. We can print just the things that we are interested in. So, voila, we have our simple debugger just implemented in 23 lines of Python code. But this debugger is a bit not full-fledged. It can be used, actually. It's not very convenient because we can set only one breakpoint. And normally, we run our program, and we need to place breakpoints somehow interactively. And actually, here, you can pass while true as an expression that will hang the whole process. And it's not very convenient to read our frames in a console view. We need some kind of tree for that, or some kind of UI. So, thinking about that, we came to the idea that we need a visual debugger. And if we need visual debugger, we need some multitasking. And for this, we need some kind of architecture. And this architecture can look something like that. The left, you see our debugger interface. And on the right, you see the Python process that is being debugged. They communicate between each other within socket connection that allows us to run them on different machines and to allow remote debugging, for example. And our debugger interface sends breakpoints and commands to the Python process and gets back events, threads, frames, evaluated values. So, on the Python process, to handle this communication, we need two threads for reading, writing. We use threads here because we don't need actually performance. And GIL is not a problem for us, but we need cross-platform work. We need this to work on JITAN and all versions of Python. So, we just use threads and it works good. And here we have read a thread, write a thread, and it's a user thread. So, if we talk about communication, then we need to find a protocol. The protocol for this communication will be quite simple. Every message is just a line and separated by line separation. And all the data inside this line is divided by tab separation. The first one is command ID, the second one, command type, and then we have different arguments that depend on command type. So, command types can be set breakpoint, resume, get thread, get frame, evaluate expression. And, for example, for a message, get thread, we generate some ID and the response for that, it will have the same ID. And this will make us to know that this is a response for this very request. So, this is very simple protocol, but it's very powerful, actually. So, we can get responses for our request or we can get not. But if we want to get responses, we can get exactly the same responses for this request that we want. So, it's very simple and very powerful. So, on the side of ID, we assume, we will not go into ID details, we'll focus on the Python code, but we assume that ID creates server socket for us and it launched a script that is being debugged. With the command line, it passes socket address and passes the sample program as an argument or debugger. So, let's look how our code will be. It's quite simple also. The main code looks like that. We initiate our debugger and, first of all, we make a socket connection. Socket connection is very simple. We create a socket and connect to it. It is already opened on the side of the ID. The next, we initialize our network communication. It's very simple. We just create a thread and start them. How can we look... Sorry. How can we look at the thread? It just, in a cycle until it is killed, it reads data from the socket and finds line separation. It thinks that it gets the whole message that can be parsed. Then we parse message just by splitting it by tabs, which read the first element as an idea of the command, the second as a type of the command, and we put this in our process queue. The writer is implemented by the same. So what's next? The next is a bit more interesting. We run our program. To do that, first we set our trace function, and then we wait for a command from ID to start, because at this point, we need to be sure that all the data from ID has just arrived, that breakpoints are set. When we get a command from ID to start, we execute our file. The most interesting part is our trace function. It's actually also very simple. We handle here line events. We take from the frame the line number and the file name, and we see if we have breakpoints for this file, if we have breakpoints for this file, and if we do have breakpoints for this line, then we just send a message to our ID that we need to suspend, and we wait in this point in a cycle for resume message from ID. So execution is suspended here. We don't execute commands anymore. We just wait for the message from ID to resume. And if you don't have breakpoints for this file, we don't trace this context because it will optimize a lot our tracing. So I can show you how it looks like. Font is a bit small, but I think it's okay. We have our dense sample program. And we debug it, and we just stop. So that is a... It looks strange on the screen, I think. Okay. So actually, that's it. We just implemented a visual debugger that communicates with interface. But we lack now very important features. The first one is conditional breakpoints. It's ability to set... It's demo effect. I don't know. I see this the first time. I can show... Wait a second. Okay. So we need to implement conditional breakpoints, step over step into smart step into. We need to make it work on Python 2.4 to 3.4. And we would like to implement multiprocess debugging. And I'll show you now that it's also very, very, very simple. So how do we implement our conditional breakpoints? We just enhance our trace function that we see if we have any condition. Condition is just a Python expression that is related to true or false. We see if we have any condition expression, we evaluate it. And if it is true, if it is false, we don't stop on this breakpoint. So voila, we have conditional breakpoints. Exceptional breakpoints. To trace exception breakpoints, we need to trace... To handle somehow exception event. And we do that very simple. We get our exception time from arguments. And we see if we have exception breakpoint for this exception type. If we do have, we suspend. If we don't have, we don't suspend. So step into step over smart step into and run to line. These functions are very simple. I'd like to show you whether you... Maybe you don't know what a smart step intro will show you. Okay, now it's okay. So step spy. Okay, so step into is just going inside the function that is executed. Step over is skipping. The execution of the function going on the next step. And we see that we have a smart step into the function. So step into is just going inside the function that is executed. Step over is skipping. The execution of the function going on the next line. And smart step into is just the possibility to step into of the selected function. And go to line is actually going to the specific line that you can select in your editor. So how is it implemented? It's very simple. It's totally simple. Step into is just resume and stop on the next line. Step over is just step into, but we step on the next line in the same frame. We remember which frame was it when we received step over message. Then the execution goes somewhere inside. And when we return to this stack frame, we stop there. And smart step into is just step into, but we stop on the line of the selected function. And run to line is just temporary break point which we remove after we reached it. So these four features are implemented just in, I don't know, a couple of lines. Each. So what about support of Python.4 and all versions of Python and all interpreters? How? Actually, that's not the best part of the code. Because when you need to support all versions, you code very fast lines like this. You need to handle all differences in standard library. But that's okay, actually. You can collect it in only one file and it will not spoil the rest. So multiprocess debugger. That is the point that I like the most. Because this feature shows us how our constraints that we have in Python, only one API function to implement debugger allows us to make something better than in different languages. For example, you cannot debug multiple processes in Java easily. But Python, due to its dynamic nature and due to the fact that we implement all by hand, allows us to do that. If we go to the Python standard library documentation again, we see that all new processes in the end use OS, the functions of the OS model like that exact way and spawn way and there are a dozen, maybe. First of all, the fork function is executed normally and then some of this function. So what we can do in Python, we can just monkey patch them and we do that this way. We take OS model function and replace it with our new exact function. And in our exact function, we call the original function with patched arguments. And the patching of arguments is very simple. If it is Python executed, we leave it and then add our debugger script in front of the real arguments and host and port that we already have. And what happens in practice is that our new process that is about to launch, it first launched inside the debugger, the debugger connects to the IDE and then the debugger code executes this new process. So we have debugging of the new process like debugging of the new thread, actually. What we have learned today, we just saw that it's very simple to trace Python code and it's very, very simple to make a simple console debugger. And also it's very simple to implement a real visual debugger. But what for? I encourage you actually to contribute. There are a lot of features that can be implemented in this field. And they can be implemented by you or with your help. I don't say actually that we give up, that we stop and develop the debugger. We actually make a lot of work. But if you help to solve your daily problems, it will be great. And the sources where the best place to look are the first one is the link to debugger in PyCharm, open source repository and the second one is the link to PyDev debugger on GitHub. But there is one moment that I'd like to tell about. Now there is a work in progress, there is a merged version of PyCharm and PyDev debugger. The repository is already created. It's called PyDev.debugger. It has no code yet because the repository was created just the last week and it has some development branches. But stay tuned, in short time we get a merged version of PyDev and PyCharm debugger with all the union of different features that have both of the ID. And also documentation will be there so it will be possible to contribute to this project and to learn how it is all implemented. So that's all. If you have any questions, you can ask. I will start with a simple question. Is there a console client for your debugger agent or are you aware of anything like that? Not yet. I think that after we establish this merged debugger with PyDev, we will make one. That's great. Now for a harder one. Have you considered data watchpoints and how hard would those be in a garbage collector language? We considered to implement that but we have not evaluated the performance problems that can be there. I think it definitely was worth to try but I cannot say nothing about real production limitations of that feature. Is it possible for the debugger to modify the flow of the program? Can I skip the execution of single lines or suppress exceptions? Actually, it's not possible in Python. It is partly possible so you can hack the byte code that you get but it won't work in all cases. As for suppressing, no. I think no, you cannot suppress the exception that is raised and not code. I have a question. It's nice when you run your programs in development environment and you can run them with your debugger but when you run programs in production, they are usually not instrumented but they still fail sometimes and you want to troubleshoot and debug them. What is the current state of Python debugging for the uninstrumented processes? That's actually the first one. Stay tuned. I hope it will arrive soon. It's not yet there but it is the first on the list. Any more questions from anyone? That will be the end of the session then. Thank you to meet you. Thank you.
Dmitry Trofimov - Python Debugger Uncovered This talk will explain how to implement a debugger for Python. We'll start with setting a simple trace function, then look how it is implemented in modern IDEs like PyCharm and Pydev. Then we go further in the details and uncover the tricks used to implement some cool features like exception handling and multiprocess debugging. ----- Presentation describes how to implement debugger for Python and has 4 parts: * Tracing Python code Explains how to use trace function * Debugger Architecture Explains which parts consists of a modern full-fledged debugger. * A Bit of Details Explains how to make code to work for all python versions and implementations, survive gevent monkey-patching etc. * Cool Features Explains how to implement exception handling and multiprocess debugging
10.5446/19961 (DOI)
Hi, good morning, all of you. I hope everybody can hear me at the back too. Cool. My name is Konrad Modi. I work for a travel company back in India known as Make-Made.com. Today I'm here to present a topic which I call design considerations while developing, evaluating, or deploying your own distributed task processing system. Why I say developing, evaluating, or deploying is because you might start with your own stuff. You might want to write a framework right from the scratch. You might be evaluating a lot of frameworks that are available in the market for distributed task processing. Or you've shortlisted one, but now you want to deploy one of them. So these are basically my learnings over the past year, past year and a half that I've been playing around a framework known as Cilry, that what are the essential components a distributed task processing system should have that one can evaluate in other systems or while designing one from scratch, one can keep in mind. What I'll be doing today is I'll be defining the nitty gritties of what jobs is, how you process tasks is. So for example, this example that you can see over the image over here, these are the few workflows that I designed back at my office using Cilry precisely. We'll be talking about how to design these stuff, what are the considerations that I take for all these tasks, what Cilry is all about, a brief overview. I would not dig much deep into Cilry, probably because I think you might want to evaluate different solutions as well, but I would love to talk about Cilry after the talk as well. Design choices, in terms of design choices, I've tried and formed four different components that you should evaluate within a system, be it scheduling, be it task management, be it worker management, be it admin part of it and the reporting part of it. And finally, we're going to talk about different workflows and the other tools that are available right now in the open source community. I firmly believe that everyone sitting over here has a use case for distributed task processing, so it would be great if you could think of your own use case and then try to connect to my talk at the moment. I have my own set of use cases that I've tried and solved with distributed task processing systems. You might be having your own systems. So it would be great if you could just connect with your use cases and then think about this as a talk, so that will really help you understand what we're going to talk about in the next 30 minutes or so. So what is a task and what do you mean by distributed task processing? There are a few examples that I've written that I am taking care of using the distributed task processing systems, but essentially for me, task is a subset of a job. So let's say a job is I want to send email to 1 million users. Now that's a complete job for me. How I will break that job into smaller tasks is I need to fetch a list of 1 million users that I need to send an email on. I probably need to apply a filter that what email needs to be sent to what customer and then probably I'll use my SMTV server to send those emails. So what I've done over here is I've picked up a job of sending emails and distributed and divided that into smaller, smaller tasks. Now as we divide them into tasks, we now get into a scenario where we will start running into problems. For example, what you need is an asynchronous task queue because each email that you need to send does not depend on the previous customer. Each customer is an individual user for me, so I really need not wait for one email to be sent completely and then the next one to be sent. I can fire them in parallel. The other thing I need is distributed message processing. One server will not suffice for me, so I need different number of machines to fire all those things for me. Support in real-time processing plus schedule tasks. What that means is I might want to send all of them right now or I might want to schedule them basis say next week, next month, after 20 days, after 25 days and stuff like that. So what Cilry lets me do is it lets me do all these things very easily. It is very simple to get started with. I'll show you a small demo of how easy it is to install Cilry and then get started with it. It only takes you five minutes to do that, to write your first task and make it asynchronous. That's what I'm going to talk about. Flexible and reliable. All the design considerations that we're going to talk about today are configurable via arguments in Cilry. So that really makes it very flexible and powerful for me. Everything is message parsing. So what that means is you have a broker. I usually use RabbitMQ for that. So everything that I need to communicate to my workers in form of tasks or say inspect the state of the workers, I do it via RabbitMQ. So all I need to do is throw a message on the message queue and the workers then take care of that. Out of the box for operational and management of the system. What that means is I know there is a system and now I deploy it. It is working fine for me until it breaks down. Now I need to figure out what point did the system break on, why did it break and stuff like that. So Cilry itself comes with a lot of tools that help you manage the system better. Plus, people have written wrappers over it and they are open source so you can adapt to them and then see how the inner working of Cilry is performing for you. For example, how many tasks is a worker performing? What's the latency of per task that the worker is performing? Do I need to improve that? Do I need to? Or is it working fine? Is my message queue dying? Is my message queue right or not? So all these things come out of the box and you can use them to manage the system better. Then these are the few use cases as I was mentioning earlier. So for example, I was writing a monitoring tool system wherein our use case was to pull the database, get some queries out of it and train it on a trending system. Now we are talking about hundreds of queries per minute over here. These are all business matrices so per minute value is very important for all of them. What we needed was a solution where I can find fire hundreds of queries on my database. Assuming my database would scale to that extent. What I wanted to write was a layer that can fire the queries, get the result and trend that. So that is one of the major use cases that we are solving using Cilry right now. This is a very rough architecture of what Cilry looks like. So you can consider that as a web application. You can consider that as one of your tasks that is basically doing asynchronous processing. So think of it as you are uploading photographs to Facebook, right? Until your photographs are done uploading, you are not stopped from using Facebook, right? You are still able to use Facebook and other features. Similar is the case with YouTube, right? So that is what is happening is the back end processing. That is what is happening in the async at the back end. You need not want the users to wait until you are done with your processing. So for example, you perform an action on the website. So you perform an action on the website, the task gets into the task queue, you have your workers that will execute the task queue and probably you want the result back in the DB or some other layer or you don't want the result and that is where the feedback loop for the web application is come. We will be majorly talking on the green, purple and the yellow parts today. This is how easy it is to install Cilry. What it does is you just do a pip install Cilry. I will probably show a demo of this. So I have already installed Cilry on my system. Now I have to define a Cilry config that basically tells me which broker I am going to use. So I am using AMPQ right now and RabatMQ for that. So I have defined that it is on my local host and use the AMPQB broker for that. Over here, I am not concerned about what will be the result of my task. All I am concerned is the task should get fired in parallel and in asynchronous nature. After I am done with the configuration, I will then define a task.py file wherein I write my functions what need to get executed. Before that, I will just load my configuration file and these are few demo tasks that I have loaded over here. These are simple Python functions, so it is very easy for you if you have a current application that you have written in Python and you now want to migrate to Cilry. So Cilry, because of the nature of how it absorbs tasks, you can simply convert your Python code into a Cilry task very easily. You need not rewrite much of the code for that purpose. So let's start Cilry instance. So now I am telling Cilry to start the instance with task.py as the task file for it and with the concurrency level of one. So this is what starts a Cilry instance on my machine. Now how do I execute tasks? Let's say task is equal to add is the function and I want to add two numbers. So now I fired the command and it says I have received a task.add. This is the unique ID that it assigns to each task that comes in Cilry so that it can keep track of that and it basically added two numbers and printed the results. Over here I can see the status, what happened to my task. It has successfully completed itself so it would give me success. If I say what was the result of the task, it would give me four. So this is how easy it is to get started with Cilry and do stuff for you. And this is all it takes actually to write your own task. So what you need to take care of is task.py file and then you can call them. Your front end from where I'm calling the task will not wait for your task to finish. So for example, if you put a sleep of say 60 seconds in your add function, when you do a t is equal to add or delay, it will still fire it and you will get the console back. So now with the ID that you got, you can then call back the message and say what was the result, what was the success. So you can put a check whether the query is still running or has it finished. If yes, then what is the result? Coming back to design choices, so this is what I was mentioning that I have tried and formed four wrappers around it. One is the scheduling capabilities of the distributed task processing system that you have. How do you manage your tasks in the system? What are the worker management and how do you do admin and reporting part of it? Because at the end of the day, you want to see how your workers are performing, how well did the tasks go, how many of them failed, how many of them were successful. So scheduling capabilities can be in the form of immediate execution or in the form of scheduled tasks. Both of them have their own limitations and their own pros. So you should evaluate a system that has both these qualities. Silvery lets you do both of them. Even if you are scheduling tasks, you can put a crontab style entry in the system where you say I want to execute it every morning 7.30 am or you can even do a humanized form of entry where you can say I want to execute this query every Monday. Apart from that, you can set interval based events as well. For example, I want to execute this every 15 seconds. I want to execute this every 30 seconds. Even if you are not satisfied with that, it lets you do a countdown approach as well. Fire this query after 10 seconds. So you will just put the countdown over there so it will start counting down 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 and then it will fire whatever task you assigned to it. This comes in pretty useful when you have to do jobs like cleanup and stuff. So for example, I have fired one task. I know after this task has been fired, 90 seconds after this task, I want to fire another task. So countdown approach really helps you do that. We are going to talk about that when we move to the workflow section. Task management is a bit tedious in terms of understanding what kind of tasks do you have and how do you want to manage that. For example, you want to priority your execution. Say I have two machines. One machine connects to my primary database, which is pretty scalable and pretty fast. One machine connects to my secondary database, which is not that good. And I know that primary database will always give me faster results so I can fire more number of queries on my primary database rather than my secondary database. It's just an example. So you can have those kind of priority executions using Cilry. All you need to do is define two queues, probably one fast queue and one slow queue. And when you push tasks, all you need to do is push the faster task on whatever queue you want to have and the slower task on the slower queue. The workers will read one of those queues and pick up the task. You can have a worker that can read both the queues. You can have a worker that reads only one of the queues. So that's flexible in that manner. Based on OS, so say you are a multi-OS environment, you have CentOS machines, you have Vantu machines, you have Windows machines as well, and you have workers aligned to all of them. Now syntactically, your operations might be different. Say, for example, you just want to fire a query on database. It would be different on a Windows box and it would be different on a Linux box. So I can have both the workers running, I can have both the queues, and then Cilry will help me take care of that. How I do it is I have one queue that is for Windows box and I have one queue that is for Linux boxes. And when I fire my jobs, I will make sure what message goes and what queues, and the worker will take care of that. So in that sense, I'm still managing my different environments with the same system that I have. Based on hardware capabilities, we've already discussed this. You have one machine that can process a large amount of data. You have one smaller machine which cannot process that amount of data. So it's basically how you configure your workers. One can be running on concurrency of four, one can be running on concurrency of five. So that's basically how we define all the stuff. Conflict management, suppose I unleash 10 messages on my messaging queue and all 10 of them need to be processed. So now there are five workers, five of them will pick one-man tasks. Now there might be a conflict. What happens to the sixth task? Who picks them? Whether my task gets picked again by some other message or not. So all those things you can configure in Cilry and say that you need to process a message only once, you need to execute a task only once. If not, one of the solutions that I use is put a lock on the task using Redis. So what I do is whenever I pick up a task, I put a lock that I'm executing this task so no one else, no other worker will be able to pick that task up for me. Once I'm done with that task, I will release the lock and then anybody else can pick that up as well. Exception handling is pretty straightforward. So say you're connecting to a third-party API and now that's giving you a timeout. What will happen is your systems will then start to fail and you want to put a retry mechanism over here. So what Cilry lets you do is it lets you retry a particular task immediately. It even lets you retry a particular task at a given amount of time and even lets you retry it for a specific number of times. So for example, I would say if it fails for five times with an interval of five minutes, then only send me an alert. That means there is a failure which is not intermittent. So I would like to dig down into that kind of stuff. So these kinds of retries and exception handling is available in Cilry. You can explicitly expire your task. Say I'm firing a task but I want you to expire after 20 seconds. If you take longer, expire for me. Don't wait for me to come and kill you. So Cilry will let you do all this expirations and all that stuff. So you have time limits which are soft and hard. Soft is wait for the task to finish and then expire. Hard is just expire irrespective of the state of the task. You can also set that at the worker layer. So for example, I have a worker that is processing a lot of tasks. Now my worker goes down. What happens to the messages that the worker was handling? So Cilry lets you do that with something known as acknowledgment later is equal to true. So in my task, if I set acknowledgment later is equal to true, that means whenever my task will finish, I will send an acknowledgment to the message queue that this task has been taken care of. If the task is not completed and my machine goes down, all those messages will get replayed via Cilry. That means something went wrong with the worker machine. They were not acknowledged. Hence they were not processed. So Cilry will let you do that via configuration change itself. When we say task, I want to send tasks. That is what we said when we did add.delay. When a task is processing, I want to see the various states of the task. I want to perform certain actions. For example, I want to see whether the task was received or not. I want to see whether the task is running or not. I probably want to revoke that task. I want to pause it or I want to permanently kill it. So these are few attributes with a task that one should take care of in mind. Your system should allow you to do that. You should even have controls like pause. For example, you are firing some stuff and you want to pause that for a moment. I don't want to do that. Probably I know that something has went wrong with one of my layers. So I want to pause this set of tasks and continue later. I want to kill them for now or I permanently want to delete them from my queue. So Cilry has something known as purging. So say you have one million messages on your queue that need to still get processed, but you know that this task no longer needs to be done. What you simply do is do a Cilry purge. It will purge all your tasks from your message queue and make it empty so that they don't get processed. So you really do not need to restart your queues to make the queues empty. You can simply do a purge that will help you do that. Now comes worker management. So each task flows to a particular worker. A worker has multiple processes running it where it will process them. Now when we say workers, I want to start a worker. I want to stop a worker. That's simple. I want to do a warm shutdown. That means when I say shutdown, finish all the tasks and then go down. Or I want to do a cold shutdown. Just shut it down right now. I don't care what state you are in. So in case you don't have acknowledgement true, then your message will be lost. If you have acknowledgement true, then your message will be there. If a task fails, I want to have the trace back with me. Why did the task fail? So Cilry as a system lets you do that. It lets you import the trace back. It's whatever happened to your task. What line did it fail and how it failed? Hard beat, which workers are online, which workers are offline? So Cilry maintains a hard beat mode where in I know this worker is up or this worker is now. That is very important in a distributed task processing system. Say you have 10 workers and you want to make sure all of them are up or one of them is failing so that you can assign the proper tasks to them. In case you don't have an online offline model, then it becomes very challenging for you. Worker inspection, Cilry lets you broadcast message to all the workers for its own monitoring and status health purposes. For example, I would simply do Cilry inspect worker one. It will go to the worker, tell the worker, give me all your stats, I need to collect it. It will get me all the stats and then send it back to the command center. Why it helps is it helps me broadcast messages to a lot of workers. So even if I want to kill a particular task, this broadcast message will let me do it. So worker inspection comes into play when you have to see what number of tasks are being performed on my worker, how much time is each task taking on my worker and stuff like that. Autoscale, up and autoscale down. So for example, currently I am running with a concurrency of two because I don't have much message on my message queue. But now there are a lot of messages coming on my queue. So you can configure Cilry to reach at its maximum level. So how Cilry does it, it says I will only run at a concurrency level which is maximum for me as the number of cores you have in your system. So if you have eight cores and you are running at a concurrency of two, in the autoscale mode it will be able to run at the concurrency level of eight and then come down back to two again after it sees that the throttling is not there and the peak traffic has gone down. It will not let you scale across machines so it's not that you can auto deploy a machine of Cilry and start running over it. Cilry does not come out of the box with that but you can have solutions to that as well. Assigning a new worker machine is very easy in Cilry. All you need to do is just start a Cilry instance like I did on my machine. So say you have a message queue with four workers, they are processing a lot of tasks and you suddenly need to spawn four new machines. All you need to do is do a Cilry instance start on all those four machines. Cilry will take care of reading the messages from the stream and allocating the task to them. Cilry does not ship your code to the machine. So if you have four different machines, it will not take care of shipping your task.py file. You have to make sure before the workers come up, your task.py file is already on the machine. If it's not there, it will start giving you errors. Also if you change something in the task.py file, probably you add a new task or make some changes, you have to restart your workers. Otherwise it will not get infected. So you will have to probably do worker by worker restarts or however you want to do it. That totally depends on what kind of changes you are making. Then is the admin and reporting. I fired a task from console but that does not stop me from going to admin section and scheduling a few tasks. I'm sorry about the font that might not be clear to people sitting at the back. So what it's basically doing is I give a name to my task and then I say, okay, this is the task that you need to run. Run it at a particular frequency or run it immediately. And these are the arguments to my particular task. So that helps you do schedule jobs from an admin perspective. So you have already written your task.py file like an add function. Now you just want to control it from the admin section. You need not write Python code for that. All you need to do is select your task from here, say add, give it arguments, specify the time when you want to run and it will run it for you. In a full production system, you want to see how it's running. So this is a utility known as Flare that comes with Cilry. You have to do a pip install Flare for that. It will give you a list of workers that are up and running right now, the number of tasks that they have completed, the number of tasks that they are currently doing. You can have more details on that in terms of at a worker level, what are the tasks that are getting executed, what are the arguments, and what is the result. Also what it lets you do is historical trending of how my tasks have performed in the past and how much of them are going slow, how much of them are going fast. Coming to workflows, now all the tasks that we talked about like add function or test, they are like one task and you are just simply adding them. When you are designing workflows, there comes a situation when you want to do one task, after that task you want to do another task, probably do two tasks together and then do a third task, do four tasks together and stuff like that. So silvery comes with what is known as canvas that lets you design your own workflows. So for example, these are the five kinds of workflows that you can do, one is change, so what will change do is it will link tasks together. So what that means is add four and four, after that add five to it. So that means until the output of first becomes the input of another. So add takes two arguments, over here in the first add.s I am doing two arguments, four comma four, but in the second part I am just doing five. So that means it is going to take input for four comma four which is eight and then add it to five. So the output of this would be 13. So this helps you change your various tasks. You might come to a situation where you want to say, I don't want to do a chaining, these are my four tasks, just fire them in parallel. So all you do is add s, two comma two and add s, four comma four, it will fire them in parallel. So you cannot wait for the first one to finish or the second one to finish. You can do a code. So code is nothing, it is basically doing a set of tasks and after the set of tasks has been done, do another function for me. So it is more of a header and photo kind of thing. So you have five tasks, one of those five tasks has done executing, execute the six tasks for me. So it is more of group and change together that forms a code for you. Sticks is very interesting because it helps you divide your jobs into number of smaller instances. So for example, recently I was working on an exercise in my office. What we had to do was we had to process four million documents. But four million documents could not be processed together. That's obvious. So the system that we had to process on had a limitation that it could process only six documents together. Now I wanted a system where I can release all the four million documents on my message queue but execute them six at a time. So chunks is what it lets you do. So first argument is in chunk is basically a tuple. So for example, you will release all the IDs for four million. If you are processing four million users, you will release four million user IDs. And then after the comma, you say process them with the concurrency level of, for example, in this example, it is ten. You can say in my case it was six. So what it will do is it will pick up six user IDs, process them. Whenever one of them gets finished, pick up another one. So it will not wait for all six of them to finish. But as in when one finishes, it will make sure at a given point of time only six of them are getting fired. So that is what chunk lets you do it. One of the examples that I had pasted on the front slide was task trees. So cilry by default does not come with something known as task tree. You have to add a module which is known as cilry task tree that lets you do a task in this manner. So you define a tree. In the tree, you say first perform task A. When the task A is done, I want to do task B. Two instances of task B. When both of them are done, I want to do task C, task C, task C. So this is a simple task tree that you can define. So cilry task tree is what comes as a savior for you. Tools available in the market. There is a new tool known as job task stick. It is majorly for web applications that require user action to be performed asynchronously. It is built over cilry itself but gives a lot of other functions that help you manage user facing asynchronous jobs. So job task is something that if you are a web developer looking for asynchronous thing, you should definitely go and look. Major thing that is missing in cilry right now is a DAG kind of workflow. I cannot define a workflow in DAG. So if you are specifically looking for something in DAG definition, then you should go and look at DAG oba. I haven't used it in production. I have just done a simple hello world program for that. For at least that purpose, it works fine. If you are into Hadoop and writing a lot of map reduce programs and you need a framework like cilry, it was open sourced by Spotify a couple of years back. It is a pretty decent tool. It lets you do map reduce jobs and define task workflows over that. So do give it a try. Those three were from the python world. The other three are majorly on the Hadoop world but they are majorly on the Java side. But yes, they perform similar functions, not in depth as what cilry performs but somewhat helps you define the workflows in that. That's all for today. Thank you and open for questions. Thank you very much for the presentation. If you have any questions, please come up to the microphones. Go ahead. Hi. Thanks for the talk. Is it possible for the publisher of a task to update the task later and not just workflow updates like suspension but that actually the parameters would be updated? And conversely, is it possible that if the task while processing finds something out, give status updates to the publisher without actually finishing? So the question is basically playing on the intermediate state of the task. Probably when I publish a task, I want to kill that task at the running state or if it finds some anomaly or a business logic, then you need to perform another set of tasks. So how I would do in terms of cilry is I can call a task within a task. So for example, say I'm running a task that defines the second part of your question where you want to perform something else while you're performing a main logic. So I'm adding two functions, but if I say if your sum comes to be 10, then perform this particular function. So from there, I can redirect my control from the main task to the sub-task. While executing the function, there is nothing that I can do based on the ID and kill that task at that particular instance of time. So that's pretty much it. Thank you for the talk. I've seen in your slide that there's a web interface for adding tasks and that I can have a schedule and repeat. Do you think what are the pros and cons of using this instead of a Chrome tab, for example? So the question is more on using the admin part of it while scheduling jobs and why not use Cron's for that? So Cron's are good up to some extent, but as I mentioned, when you have to define complex workflows, Cron will not suffice for you for that. For that purpose, you have to use systems like Cilry for that. And Cron's necessary will at a given point of time not help you scale in a lot of parallel processing that you need to do. Given on pros and cons of using admin interface, so I might not be using admin interface to submit new jobs, but I'm surely using admin interface to control my jobs. For example, I want to pause a certain job at the moment, so I would go to my admin panel and pause the particular job or say, I don't want to execute you for the next five days because I'm running into some problem. So that is where the admin panel helps me a lot rather than going on the console and doing that stuff. Hi. You've talked about tasks that act late. So let's say we have such a task and it's in the middle of processing and the worker dies. When will the task be re-queued? So as I mentioned, his question is, when does the task get re-queued? If my while processing the task, the worker dies. So now there are two sides to this question. One is handling retries. So you explicitly have exceptions that you know can cause your task to fail. If you've taken care of that, then you have to, then all you need to do is just add a retry mechanism in that particular exception block. Because where you do not know when it's going to fail, what will happen if the worker dies and that is not supposed to happen, you obviously have to do a manual digging and figure out why the worker died. In case you do not explicitly mention that acknowledgment should be true, in that case you will lose your message. If you define that acknowledgment has to be true, then worker will always tell the message layer that I have processed this message. Or if you want intermediate logic that I was telling about, so whenever a task is being performed, I keep a tab in my radius that this task has been performed and whether it has finished or not. So if it has not finished, I know something went wrong. But obviously if your worker dies, then you have to go to your system and see what happened. If your worker dies, no new message will come to your worker, but yes, you'll have to see what happened to all the messages that they were on your system. So if you're aware of the situations, what exceptions can come, it's better to have exception handling and put retries manually. For scenarios where you don't know what's going to happen, so you write your own there. Your slides mentioned that you can kill a task. How does that actually work and can you ask the task to gracefully clean up the resources it was using and things like that? Yes. Basically each task has an ID and when I'm firing that ID, so I usually do it by the admin panel. I go there, select and kill my particular task. So each ID is assigned. Each message is assigned with an ID in Cilry. So each ID, what will it do is you have one ID and you can always track what is happening with that particular ID. Now, once you delete that particular task, deletion means removing it from the system itself. It will never get executed again. That means for that moment I'm killing it, but whenever it is scheduled to happen next, it will then happen again. So you have to define whether you want to delete your task permanently or you just want to kill it for the time being. So a task that is running and I kill it, what actually happens is the process killed? So it's not the process killed. Process will only get killed if you kill the worker. So a worker will have say N number of processes. If you kill the worker, all your processes get killed. If you kill a particular task, only that task basically gets killed. The other task will still continue to happen on your worker machine. And how is the killed task terminated? So it's basically it gets float on the message queue and then Cilry takes care of it that I don't want to execute this message anymore. Probably you might run into a situation which I am not aware of that killed this particular task when I'm done execution of the whole scenario. So for example, say your task takes 20 seconds to get executed. You say that, okay, let it finish and then do not re-execute that again. So I have not played with that kind of task, but surely there should be an option to do that. I think the question also is what about tasks that have already been started? So can you kill tasks that already have been started? I think that's the question. So his question was more on what happens when I kill a task and how do I restart it? If the task is scheduled, then it's easy to kill. But if it's scheduled and it's already running. Yeah, so my answer to that is there can be two ways to do that. One is wait for the task to finish and then kill it. Intermediate task killing, I am not very sure how Cilry would handle that and what would be the state of your... So say, take an example when you're doing a SCP of your file, right? So that really leaves you in the middle of the problem that what has been transferred and what has not been transferred because you cannot remove the copy from your server, right? So it's going to be an intermediate state and that is where you have to take a call that how do you perform these kind of actions, whether you kill it right there and then or you wait for the copy to finish and then kill it. Hello. Thank you for the talk. Just a clarification related to the earlier question on the other side. You're using RabbitMQ as your broker, yeah? So if you pick up a tab. If you pick up a message and you don't hack it and then if your client dies on RabbitMQ, that message will be re-queued. I don't understand why you're using Redis as a locking mechanism so no one else picks it up. So yes. So I was using Redis as a locking mechanism because I wanted to make sure that while I am executing that task, no one else would do it because it is still on that layer. Now because so how RabbitMQ by default works is if anybody picks up the message, it will not be there on the queue itself. So no one else will get to understand why the ID is over there. If it's on a queue and something picks up from the RabbitMQ broker and doesn't hack it, that message is sort of like, okay, I've sent it until I get the hack. It's in a state. Acknowledgement is not by default in Cilry. Acknowledgement you have to explicitly state that I want to make this worker a task as a knowledge task. So earlier when we were using Cilry, that acknowledgement feature was not there. And so I was not doing that acknowledgement is equal to true. So I will not wait for every task to finish and then replay the message again back in the queue. What you are saying is make sense that in that scenario, what you'll do is I will wait for every task and the acknowledgement and then the other task will get picked up. But in normal scenarios where you are okay with few failures of your task, you would say let it flow and acknowledge, if it gets into the exception block, I will retry it. If it gets fails, let it drop by. I think the mechanism is the same. If your task dies, if the worker blows up, that's basically it's a disconnect without an acknowledgement. Yes. A task is recued. If I am explicitly stating acknowledgement is true. Okay. All right. Thank you. Okay. We have time for two more questions. So. For example, I have a task that does synchronization of the content and this task spawns another task that does the publish. How can I be sure that the publish task is picked up by the same worker as the synchronization was done? Otherwise, maybe it will be picked up by other worker and it will be a mess because publish can be done before the sync is done. So that usually tends to be a problem when you are doing a lot of tasks. You want to make sure the same worker should pick up the same task because probably you have intermediate data or whatever stuff you have. And when you have multiple machines, that becomes more of the problem because your data is local on that particular machine. Right? Usually in Cilry, when you are firing the query, once a worker machine picks up the task, the whole all-side of tasks will be performed by the worker machine. It is not that I have four tasks to be done. In a chain, I have four tasks. One worker will pick up one task. The second task gets picked up by some other worker. So Cilry will take care of you in that sense that the complete chain has to be performed by one side of worker and not by multiple workers in that particular sense. So your data, if you are generating some intermediate temporary files and reading from that intermediate temporary file on the other task, that will be taken care of. But otherwise, for that scenario, if you are doing that kind of stuff, you have to have a common caching layer or stuff which everybody can read then. So for example, you say that each task returns a result. I will publish back that result onto some message queue. And whenever other task picks up the same task, it has to read that message queue. In that scenario, you have to bring a common layer across all your workers for you then. You mentioned RabbitMQ. Do you have any experience with Redis Broker or other brokers? Yes. So Cilry is not limited to just one broker. You can have your own choice of brokers. So you can use Redis Broker as well for whatever I'm using RabbitMQ for. So you can have your Redis running there. And you can have architecture. Cilry also does not limit you with one broker. So you can have multiple brokers as well. So you can have a mixture of RabbitMQ, Redis and other stuff to do that stuff for you. What was your highest throughput through a salary system? Like normally this task queuing looks like, send out emails is quite a few tasks. It was a long time running. So majorly, what are the challenges for us was a long running job that I was mentioning about. So 4 million users that we need to process. So that job ran for about three days. So we had to make sure that the Cilry workers are processing correctly and they're not dying because if they're dying, we were in an intermediate state. What happened? What happened wrong? So there was not high throughput involved, but a long running task involved in that scenario. The other scenario that we've seen is I want to make sure that all my tasks run well in the same amount of time. So again, if you're talking about throughput in terms of number of events per second, I don't have a number of that because we are not reaching that scale in the current scenario. All the Cilry production users that we have is more on long running tasks or tasks that are very complex in terms of data flows. But for events per second, I don't have a number, but yes, there are some benchmarking available that proves that. Thanks for the presentation. Thanks for the questions. Thank you.
konarkmodi - Design considerations while Evaluating, Developing, Deploying a distributed task processing system With the growing world of web, there are numerous use-cases which require tasks to be executed in an asynchronous manner and in a distributed fashion. Celery is one of the most robust, scalable, extendable and easy-to-implement frameworks available for distributed task processing. While developing applications using Celery, I have had considerable experience in terms of what design choices one should be aware of while evaluating an existing system or developing one's own system from scratch.
10.5446/19960 (DOI)
Thank you all for coming. So my name is Denny. I've been doing Python development for a couple of years now, mostly web development and some tooling and CLIs. I also do a lot of sysadmin devop stuff and I like to automate as much as I can. I work for a small Python shop based in... You probably already use a full blown VM like virtual box and possibly vagrant and stuff like that. The most important thing to me is that containers are fast. So starting a container is measured in milliseconds. Most of the time you can start hundreds and hundreds of containers and that's all because there's a minimal overhead because containers share the same kernel and therefore it's much easier to access resources like disk, network, etc. Also images aren't copied for every container that we run from them. Rather, like I said, containers only save disks to disk. This is due to a technology called UnionFS. So all of this should make it easy to run your whole production stack locally and you should do that because it's very important for everybody on the team, for every workstation to have the same versions of libraries and databases and everything on every workstation and this goes all the way down to C libraries. So how do we run a container? We use the Docker run command. We say with the tflag which base or parent image to use and we supply a command to run. The iflag denotes that we want to run it interactively so we don't want the process to go into the background whereas if we supply the dflag we are going to run the container in the background and notice that we didn't have to supply a command here because the command was baked into the image and it's only overridden if user supply is another command. You can also use tags to have different versions of your images, for example, to denote versions of your database and so on. So you would use Docker PS command to list all the running containers that you have on your machine. That shows you among other things the container ID which you can then supply to the logs command to get the logs that your service is writing to standard output. You can also use stop kill and start commands to restart the container, stop it or kill it. So by default the stop command sends a term signal to the process inside the container but it has a default timeout after which it sends the kill signal. So that's a little bit about containers. Now we are going to talk about images. Actually you can build images manually and when I talk about images I don't mean base images like the Debian images we saw before. I mean your images are going to be based on a parent image like image for POSGRES or a cache or something like that. So you would run a bash prompt interactively from a Debian image, for instance. You would type in your commands to install your services, configure them and whatnot. Then you would grab the ID with the Docker PS command and then you would commit that container to a new image. So the commit command creates a new image. You can then use the Docker tag command to tag that image with a version perhaps or something else. You can also rename it, give it another name. So the username prefix is important for pushing to the central hub. So as I said, a hub is a hosted central repository of private and public images. The images that aren't prefixed with the username are maintained, images maintained by the core team. Images done by the community are prefixed with the username and you need to, before you can push an image to the central repository to be able to share it, you need to log in to the hub. So that was a way to manually build your images. A better way is to use Docker files. So it's a small DSL that you would use to describe what files to add to the image, what commands to run and what ports to expose. Also you supply the baked in command to run if no other command is supplied via the command line. And you just use the Docker build command to point it to the directory where the Docker file is located and you name your image and it will build the image for you. So most of you are probably thinking about what do I do on a Mac because Docker requires a Linux kernel. So a Docker consists of a Docker daemon which is basically just a HTTP API. And the Docker CLI, the command line interface that I just showed just talks to the HTTP API. Having that in mind, there's a helper application called boot to Docker which is the official way to run Docker on Mac which basically uses virtual box and sets everything up, basically uses virtual box and sets everything up on your Mac so you can use the CLI to communicate with the Docker process running in the virtual box instance. Okay, so those were the basics of how you would use Docker to manipulate images and containers but how does that help you in your development environment? It's really important to run services and the same version of services that you run in production locally so that way you always know if something works on your workstation that it should work on production as well. So you eliminate a lot of bugs not just between workstation and production but between two workstations. So what we have here is an instance of running an example of running a Postgres database. So we exposed default port that the container exposes and we map it to the same port on the host so we can connect to it from the host. If we didn't supply a host port, Docker would generate one for us and configure all the port forwarding and whatnot. Also containers themselves are ephemal which means that when you start a container you write some files then you stop it and run another container from that image. The changes that you did in the last container are gone. This is because the image itself is immutable and you just started the new container from point zero. This is troublesome if we want to run a database because we want to save our tables and our database data. And the way to deal with this is to use volumes and we tell it to mount the host directory inside the container in the place where the database is going to write the data. So every time we run another container we will still have our database data retained. This is another slightly more portable way which is to have one container for your data which doesn't even actually have to run for this to work. So one container for your data that exposes a volume and then we use the volumes from flag to mount that folder, that data folder inside the running container that actually runs the post-bress process. I like to host the version more for my development environment at least because I like to... I run the clean command a lot so I delete most of the stopped containers and this way I don't have to worry about deleting my test database data. So I've shown examples of how to run services in a container but what's the benefit of running your web app in a container? So basically you simplify the runtime a lot. You make sure that everyone on the team uses the same version of all the dependencies. This is something that virtual and should be for in the Python world at least but this isn't true for C libraries as everybody knows that's ever tried to compile the... install the Python imaging library so you would... you mostly saw warnings at the end that told you that some image formats aren't supported and basically this eliminates that problem. So you don't have stuff working on one workstation and not working on another because of missing C libraries. Also an added benefit is that you can use links. Links is a feature the Docker provides for letting containers talk to each other in a way. So you would start... you would name and start your Postgres container and you would use the link flag to link that Postgres container with this name inside your web app container which means that... which basically does... allows the Django app container to be able to communicate with the Postgres container via the host name provided here. Also it exports a lot of environment variables, ports and IP addresses and whatnot so you can use that to bake those environment variables in your Django settings file or whatnot. So how do you automate all of this? Because presumably not everybody... everyone on the team needs to know how to run Docker. I use make files a lot so I built a lot of targets or make commands for running each service. So just a one-liner command to run a Postgres database or a queue or whatnot. And I also have commands that can bring up the whole development environment for that particular project. But sometimes, best scripts and make files aren't enough. So remember I said that the Docker daemon is just an HTTP API. So there's a project called Docker Pi. It's the official Python wrapper for that API. It's available on PyPI and it lets you do, I think, all of the things that you can do on the command line interface and there are other wrappers in other languages but to my knowledge this is the most complete one. I could be wrong but I think it's so. So it lets you... you could write in pure Python your whole script for bringing up your whole development environment. But what if you use Ansible or Chef or Puppet or any other of the provisioning tools? You can basically use both of them together. So an Ansible example would be that you could use a Docker file to just bootstrap the environment that Ansible needs to run and then run your playbook to provision a database inside that image. Another option is to have Ansible or Puppet or Chef connect to the local IP address of the container. But this is bad because for that to work you need to have SSHD or another agent running inside the container for the provisioning tool to be able to communicate with it. And for that to work you also need some kind of supervisor which can be Upstart or SystemD or SupervisorD which would allow you to run multiple processes inside the same container. This isn't considered best practice. So Docker advises you to run one process per container. So it's a lot easier to update just one component of your system or just not update it but possibly change it for another component. So for instance if you had SSHD in there, if there is an Excel vulnerability, you basically need to update that whole container which you might have, which you possibly could avoid it if you didn't have that process running in there. Also there's another project called FIG. The best way to describe FIG is as vagrant for Docker. So what vagrant does for virtual box, in my mind FIG does for Docker, you use YAML syntax and you can describe how to build your images, what ports to expose to which container to link your web app container. It also supports automatically downloading images from the central hub. And with one command you can basically have a swarm of containers running without the rest of the team needing to know how the internals of how this works. Also I read like an hour ago that FIG is becoming part of Docker so there's probably going to be some interesting development there. It was announced on their blog. So in summary, I hope I've convinced you that you should run your production stack in development environment because Docker makes it easy. Not all of the team need to be able to install all these services on their workstations. You use the same environment everywhere, not just workstation versus production but on all of the workstations and it should make your upgrade process more easy because you can easily rip out one part and change it with like an updated version or a different process. And this all happens transparently to your team. They don't need to know that a new image has been pulled from the central repository. It just works. Also I didn't talk about deployment in this talk because I don't have enough time. But using Docker in this way really simplifies deployment because it enables you to bring in new team members on a project more easily. So imagine that you or your DevOps person have set up the production using all of these images and all you need to do to be able to bring a new person up to speed, well set up their development environment, is supply them with the images that you're already running in production and they don't need to do any other set up. That's it. Thank you. We do have a few minutes for questions and there's the microphone at the back if you want to walk up to it. Hi. Thank you. As you're doing Django development, I was wondering, do you include the Django application code inside your Docker images or do you keep it separated? So it depends on the project. Some projects aren't run inside a container because they're simple by themselves. We just use the supporting services in containers like a database, a queue. But other projects have a Docker file committed in the repo and on deploy you just rebuild that Docker file to have the latest version of your source repository inside an image. Okay. So you include the code inside the Docker image? Yeah. You use the add command in the Docker file to include the directory code inside the Docker image. Great. Thank you. I have got one question which is probably very stupid. How do you edit code inside a repository inside Docker container? So you would use volumes for that so you can mount your working directory inside a running container in a known path. So when you edit the code on your local machine, it's automatically visible inside the runtime inside the Docker container. That makes perfect sense. Another question. Usually you can't use the central repository for anything other than public stuff. What do you do with your own builds or with your own applications? Where do you own data? Can you somehow put that into a custom or your private, own private central repository? So the hub does allow for private repositories but it's not a free feature. But there's an open source component that's called the registry which you can install which is Python powered. You can install on your server and you can use that for pushing your private images. Also sometimes if it's a small image, maybe you don't need to rebuild, maybe you don't need to have it deployed on a central hub but you can just rebuild it and deploy. Depends on your use case. Yes, the problem is for example with European regulations you wouldn't be allowed to trust the Docker central repository with quite a few of what you would want to put there. Thank you. Thank you. Hi, quick question, do you have any tips about automated deployment from continuous integration? You have always your master branch which is deployable and then you deploy automatically from to production from that master and do you have any tips like build images or not build images, just do it on the fly on the servers? What's the best practice for that because I'm struggling with that right now, how to do it like perfectly? I'm not sure there is a best practice yet. So how do you do it? Because there's a lot of solutions that don't necessarily work the same way in the sense that you can, if you get tired of one that you can use another. It's something that Docker team is trying to fix I think with an introduction with a new library. But the most simplest way I think that you can accomplish that is basically just have a deploy trigger on GitHub or whatever if the build passes to trigger the server to just rebuild the new image with a new tag, so the latest version. And then you switch your load balancing software or proxy software like Nginx or whatever to point to that new image. That way if it doesn't work you can just switch back to the old one. So spawning new one, new Docker container if it's fine, then okay, persistive and the other ones like going down. Cool, thanks. Thank you. I think that's unfortunately all the question time we have but you can find Denny outside if you want to ask him. If you can just thank Denny again.
Deni Bertovic - Supercharge your development environment using Docker These days applications are getting more and more complex. It's becoming quite difficult to keep track of all the different components an application needs to function (a database, an AMQP, a web server, a document store...). It keeps getting harder and harder to setup new development environments and to bring new developers into the team. Stuff works on one dev machine but doesn't on others? Code breaks often when deployed to production even though all tests were passing and it worked on the dev machine? The idea of this talk is to convey how important it is that we have our development environment as close to production as possible. That means setting up all those various services on your laptop/workstation. ----- In this talk I am going to show how to utilize light weight lxc containers using docker, and make your development process much more straightforward. How to share container images among your development team and be sure that everyone is running the exact same stack. Do all this without hogging too many resources, without the need for complex provisioning scripts and management systems. And above all else, how to do it fast! Rough Guidelines: 1. Describe what is LXC (Linux containers) 2. Benefits of using containers instead of traditional VM's 2. Explain where Docker comes in 3. Show how to build simple containers using Dockefile syntax 4. What are container images and how to share them 5. How to share private container images 6. Tips and tricks on how to automate
10.5446/19959 (DOI)
garfyd Wahyw hwnnw i ymmiwch ar amliydydd heddwun lleolion am felly mwych awr yw iawn ar ei reveladau? Ywaf ag charges ond ein bod sy'n ddau ein cael ei gawyaeth yn rhythmicolaeth, Mi awes recapio prospects, r supervision, assembling the company, and establish interestINDT. Yn ym 5-2-3. Actually if you're going to leave early, then leave quietly so we can hear what people are asking. And hear Dave's answers. All right, so it's really great you're all here, it's great to see so many people, …east – yw dweuddiadau, pe Oedd am rhai ddir, gallwn вид holl o ddweudio. Whom idd неidodd ein gwybodaeth? Obsor fel ten o'r ryddILL 것도ch y meddwl oie'n mewn mudd a wedi'i r shamill. Mae'n go i'r totlun yn ddweud. Felly, rydyn ni'n deif, ac mae'n cael ei ffyrdd. Rydyn ni'n gweithio, mae'n cael ei ffyrdd, mae'n cael ei ffyrdd i'r company. Mae'n gweithio ar y tracpoint. Mae'n cael ei ffyrdd i'r ffyrdd, ac mae'n cael ei ffyrdd i'r ffyrdd. Mae'n gweithio, mae'n gweithio, mae'n gweithio'r gitar, mae'n gweithio, a dwi'n gweithio. Mae'n dweud y cwylio'n ddweud, ac mae'n dweud. Mae'n dweud yw'r dweud yw West Coast Swing, ac mae wedi gweithio i Afghanistan yn 2013, ac mae'n dweud yw'n dweud. Mae'n dweud yw 2013, ac mae'n dweud ar Campaign, ac mae'r dwylo bardzo oedd, i ni Ddeif yn Classgain I mi ynhawnmenig? I taught Afghans in computer science and that kind of stuff. But I want to get away from Star Wars now and towards Chad Eye, the auto completion. So I hope everyone understands what auto completion is here, right? So it's like this thing that pops up when you write code. So Chad Eye is just auto completion for Python. It's kind of a new approach. There has been rope before and there's pie charm. But it's kind of different. It's a project that has grown quite a lot in the last few months even. It has like 1200 stars on GitHub. And it's well tested and it has only been around for two years really. So we kind of have an emphasis on Python 3 and that's because at least I think it's the future of Python. So it works in Python 2 but still like we do a lot of coding in Python 3. So then the base of Chad Eye, what's really important is to have a good type deduction. And that's not as easy as you might think because Python is really dynamic. And it's a different approach than pie charm. Pie charm has this kind of approach where they, or at least I think they have that approach because their code is not open sourced. So sorry. It is open sourced now like the whole completion thing. All right. So that has changed. So anyway, what I thought it is, is like they kind of built this type tree where they just know everywhere the types and like they do it this way. And I do it on a lazy evaluation approach where I'm just moving from place to place. And I try to keep all the values as well to have as much information as possible. And I can show you how I do that. And this is a small example. It's like this string object down there goes like, Chad Eye would now work. You have this completion here. You have capitalized center and so on. And that kind of needs the string object. Well, it needs to know what the string object is. So it goes back and looks where a string object defined. It's like that get at your thing. So it doesn't get at her on the string and name and executes it. So basically what get at her does it. It needs the name. So it goes up there. It kind of puts name the name up her together and then it works. So that's pretty cool because it's that's something you wouldn't expect and not a completion to do. Like, so. Chad eyes, then there's like Chad eyes parser, which is full tolerant. It basically has to be because auto completion doesn't really work like rope. The other older auto completion thing, they kind of use an AST and just delete lines. But that's then they have to kind of iterate that. And if the file is really buggy, they are not able to give you any hints. And so basically with Jedi, you can just like give it anything like you can give it a PHP script. And as long as there's like one Python function there, it will work. So way more important is the fast parser. That's kind of a strange thing that splits up a file into functions and classes. And the idea behind it is that well, you're doing auto completion all the time and you're only changing like one line. So if you change only one line, you shouldn't be reparsing that whole tree. It's just it's just a big waste of time. And so what what Chad eye does, it's basically is basically to get rid of that and just just parse that one function again. And sometimes that's buggy. Like there's that's that's why people sometimes think Jedi is not really good or it's it's buggy or whatever. So if you find a way to reproduce reproduce issues, like we would be really happy. And there's like one fun thing about this is like. If you have Japanese guys as contributors, they will they will fix that. Like they're the most awesome people to to have around an open source project because they always they always kind of go for a performance and and fix things. And so that has happened a few times here in Jedi as well. Then the dynamic nature of Python is like we understand that by by doing. Well, by basically understanding all the get at your stuff and so on. But that doesn't really help a lot because you're not using that. The biggest issue actually of of dynamic stuff in Python is lists and sets because you push into these kind of containers and you expect something out of it. And it's hard to understand it because you push from somewhere and it kind of the other completion has to handle it. Which is as far as I know again, not handled by pie charm pie death and rope and so on. So this is an example like you just kind of Jedi understands it even if it's in a for loop or like in a different function. So you have an annex that is defined as an array you you push two times and you kind of in the end you end up with completions for both in the string. Like you could now say well, but the index is not right. Like it should just be an end. Well, we might work on that, but I don't think it's very important because typically you only have one type in there, but you need to know that one type. And so what we end up with is is and said I said I really understands a lot about Python. So this is this was kind of the introduction towards static analysis because like if you don't understand all those things like decorators generators list comprehension on so on. And so on. Like if you fail to understand just one bit one statement, then you fail to understand the whole kind of thing because Jedi is recursive and like goes from one place to the next. So if you don't understand the list comprehension, you cannot know the type in the end. And Jedi even understand the scriptures like that. That under like almost nobody understands those because they're pretty complicated and there's there's like exceptions that we just from the beginning on said well we were not we're not going to do that. That's metaclass is set at her. And I think a few others like locals and globals modifications and dict modifications and like that crazy stuff, which is just too hard to understand. So this led to the idea of creating a linter or static analysis. And so this this came up when I was writing a proposal for a Euro Python in February or something. And so I was like, oh, auto completion is not going to be that interesting to talk about like it's just auto completion. Everybody wants it, but nobody really cares how it's done. And so I kind of thought well static analysis could be really nice to do with Jedi because we understand the types and we can just do lazy evaluation on everything. So basically evaluate everything so you push. Sorry, you push the lazy away. And first I thought it was slow, but it turns out it's not that slow. It's not as fast as pylint or pyflakes, but it's it's okay. Like I'll show you the results afterwards. And I need yields very good results just like I worked on it for a month or so. And that's not a lot of time like I in comparison to what I worked on Jedi in general it's been like more than two years. So it's just a month. And then it was really fun because there was a talk like who has seen the Haskell keynote. So, and this was fun for me because he just said static analysis is primitive and I'm sitting in there and having a talk about static analysis and how how we will do that in the future in Python. And so, like he says, well that's not going to do it. And there's like pylint compile like the Python compiler and so on and there they suck whatever. And so Jedi, well, it does it. But, well, yeah, but Zynga. So anyway, it, but we have to be fair. There's like it wasn't really working on Monday because I worked on different stuff. I worked most of all on attribute error on attribute attribute errors and type errors from function where you would call like a function with too few arguments or whatever. So, still like I hacked it together in two days and I still drank beer and like so there's it didn't take a lot of time. And so we will work we will definitely work on that like to have a proper, proper type errors for all that kind of cases. And here, here's what I worked on like this is the slide that I wanted to start with originally but then like I kind of changed it. And so this is what what what Jedi really does well. It's like, oh, we have stir dot upper and well we forget a p or something and then it kind of reports it to us the same for like a function that is called with with like an argument with like three arguments instead of two, like that kind of stuff is working really well now. And that's that was my focus in that kind of in that month before Euro Python, which is, which is pretty cool because this is not like this is a very simple example. It works on like pretty crazy stuff. I cannot really show the examples because it's just like very long Python code and then like, but you can just take the example from before with get and like play around with it and it will still find some some error. So we will just give you an example. I like I thought well, I don't really have time to test to test against all the libraries or whatever, but I just like a week ago or so preparing to talk. I thought well, I could just take the most well known library that probably doesn't have any box and so I took request with which is like 4000 lines like you are li three is not included here. And like scanning it takes 15 seconds it yields 51 errors and like 22 errors of those are errors that you want like its compatibility code like imports from, I don't know, like Python to imports, because I scan it in Python three. And so that kind of stuff. And so that's fine if you see those errors and there's like a few bucks and pretty much everything else is related to mixing classes. Now mixing classes is something that I didn't even think about before, but mixing classes in in Chedai is going to be kind of hard to understand because you have this mixing class and the attribute is defined in a class that is different than it than the one it's called it's used in. And so that's kind of special, but we might work around it. I don't know, but it's pretty cool like you get 50 errors or let's let's say you get 22 errors. That's not a lot of false positives and to show you that you still get errors. If there's a mistake, I kind of prepared this now. No, I didn't prepare this, but so if my presentation would close, but yeah, so I don't see it on my screen. So I have to find it. So we can just like first let's let's just scan it. Sorry, it's very small. I forgot to change the size. I think it takes like a few seconds. This module and doesn't yield an error. We change something like this here time C time dot encode remove something. So we have an error now, right? Like it really so it's not just a joke. It works. Yeah, you can, but it's the worst thing ever. Like it's even worse than NumPy, I think, because Chedi is just so comp like the whole idea of running Chedi on Chedi is is basically that you run recursions on recursions. And that's very complicated to understand, but it works like Chedi does kind of a limitation in recursions where like, oh, if you're like 10 levels deep, just ignore the rest and like because you cannot you cannot follow everything. There's just no time for that in other completion. We might change that for static analysis, but yeah. So let's just do one other. Yeah, let's just do another one. What did I change? I don't know. Let's just then change this function. I hope it works. Yeah, like we we get some errors and like you can also like now you would also get pi flakes also yields errors down there. So let's undo it. Let's remove this parameter. So apart from that username thing that is not there, you will not see an error, but let's see the output output here. So it will tell you more because it will tell you well, yeah, the username is not defined like pi flakes does. But it then also tells you kind of in a typical Python way. Oh, basic off string takes exactly one arguments, but to are given. And that's pretty nice. I would like to, but we're undone now with that. So. I want to finish here. So what are we going to do in the future? Why is that not working? Yeah, we brought this for the win. So we will improve static analysis. That's one of our goals now for like the next few weeks at least. And then there's like the goal of adoption in mainstream ideas, which is already ongoing like spider is doing it with a guy called Steven Sylvester. And there's Piedef is interested. And so one of the things we're going to do if we have enough manpower is refactoring. And then there's one thing I'm really excited about. It's the integration of Sebastian crafts Python type annotator, which adds kind of a way to understand NumPy and and built in types way better. He kind of runs a test suite and hacks the Python interpreter to kind of leak every input output type and name. So you kind of know what goes in and what comes out in built in libraries. So that's going to be at Euro Python sprints. We're going to do that. We're at least three people. So if you'd like to join, you're very welcome. And there's like my small future. I've been I've been working on it for quite a long time now. It starts to get financially unsustainable because it's just my savings. They're vanishing. But if you're a company and like you, you want to have really good static analysis. Well, maybe you want to hire me or something. And yeah, alternatives are either Kickstarter or more Japanese guys. So. And yeah. So here's my contacts. There's two things I want to say. The first is like test well and often there's talks, pie test, coverage pie and like for open source stuff. There's also Travis, which are just awesome tools. And if you have like like a library that has a big test coverage, that's just really cool and create libraries if they don't exist. So that's that's really the strength of the of the Python ecosystem. If you ever thought and something should be better, change it. So yeah, we might have time for a question, but probably not. We have so thank you very much Dave. We've got time for one question, I should think. Can you repeat the question Dave? Yeah, so he said he asked what how well would it work with when and then like I wrote a plugin for them called Chedi Vim, which is working pretty well. And there's another plugin called you complete me, which is using Chedi. So they are working really well. There's like three plugins for Emacs. There's two plugins for sublime. There's plugins for a lot of editors. So yeah, I guess that's it. So have a good time. Thank you for coming. Remember Afghanistan is beautiful and like thank you Dave.
Dave Halter - Identifying Bugs Before Runtime With Jedi Finding bugs before runtime has been an incredibly tedious task in Python. Jedi is an autocompletion library with interesting capabilities: It understands a lot of the dynamic features of Python. I will show you how we can use the force of (the) Jedi to identify bugs in your Python code. It's not just another pylint. It's way better. ----- Jedi is an autocompletion library for Python that has gained quite a following over the last year. There are a couple of plugins for the most popular editors (VIM, Sublime, Emacs, etc.) and mainstream IDEs like Spyder are switching to Jedi. Jedi basically tries to redefine the boundaries of autocompletion in dynamic languages. Most people still think that there's no hope for decent autocompletion in Python. This talk will try to argue the opposite, that decent autocompletion is very close. While the first part will be about Jedi, the second part of this talk will discuss the future of dynamic analysis. Dynamic Analysis is what I call the parts that static analysis doesn't cover. The hope is to generate a kind of "compiler" that doesn't execute code but reports additional bugs in your code (AttributeErrors and the like). I still have to work out the details of the presentation. I also have to add that Jedi I'm currently working full-time on Jedi and that there's going to be some major improvements until the conference. Autocompletion and static/dynamic analysis as well as refactoring are hugely important tools for a dynamic language IMHO, because they can improve the only big disadvantage compared to static languages: Finding bugs before running your tool.
10.5446/19958 (DOI)
Mae'r Fyfrwyng頓. W saya'r chwciell iawn. Nidentally i am m chw Verd religion o'ch�oriad dialoghwyn. Ond roeddem o behalfodd e, leadership sy'nreu. Am y cwrdd, mae gen i 밀wyr ond, yma'r fawr �Cret a gyfan ar cefnolaethau my份. Ac allan o gallai'r g ahíw Ng partir, mae am eisiau hwnnwch ar fy nghychynach Pierce conductor o arferfesper o'r model, nid mend countryside procedure program. Gunwch yn y cwrthig yn hyn solwll hona Fywrwyr Tor sean ym S sukwr i momencie I wedi ddefnyddio wych yn iawn, a Lord UC annoying mewn cyllideb o Sand violin decrets ond y dillhyr person evening iawn, ond fe deull sorry. Yn gyffbes boedagay했어 o'r bach yn go. Dyna hwnnw merci i wybodlet deall. Dydnno fydd hynny'n ys jagu. réfaul yna rwyf wedi ddim gwen. traits bairu â Cya kokol y's they piss Ryu Lwydgan. времени ond, ac dyma wo significaEnteria Ryiken terribly vom. i eich yng Nghymru. Mae làw rhagLYF yn y ein hun. Oni, ag y cysesudgin neu cyrFanol, ac yn y maen nhw'n meddwl gyda losent yn yr Unilech slidesan. Roedd teimlo chi'r maid bod pet consultation yn glyfodol diddordeb yn Court Address Cymru o gyllid Lelezor�jąol a'r stakeianhau ychwanegwch ar y cyfnodd a gweithio ar y cyfnodd y dyfodol i'r ysgol ymdweithio, y cyfnodd yn ymdweithio ar y dyfodol i'r cyfnodd yn ymdweithio ar y cyfnodd y dyfodol i'r cyfnodd yn ymdweithio. Dw'n dysb Dowddion inside y log gan fyddai mae gwasanaeth Cymg loafu'r sigbedd yn digwg a roedd eich vidd ardwl dal gan eirian F vìwys fel Gfaith Brannid. Golm'r heb Fanfer yng Ng�raedd, ac â charred gan neill CymussionЯwn i'n mas admission ac yn ymateb otwmddio'r hyderwydd Lord Henry Fyredened uhudaethau'r lefaen Rydy o'r ffordd i launching Rydy mai gyda mor system fydd yma hwrth yr wyllte...? clean python uh enwedig yw'r Llywodraeth yn ymweld 100 yw'r Llywodraeth ar y gweithio y 20 yw'r Llywodraeth. Felly, mae'r ddweud yn ymweld yn ymweld yn y parolel, ond yw'r Llywodraeth yn y ddweud, mae'n ddweud yw'r Llywodraeth. Mae'n ddweud yw'r Llywodraeth, mae'n ddweud yw'r Llywodraeth, ond mae'n ddweud, a yn ddeithas ymweld, mae'n ddweud yw ddweud. Felly, mae'r ddweud yw'r Llywodraeth, ond y gweithio yw yw'r Llywodraeth, yn ymweld yn ymweld yn ymweld, i'w ddweud yw'r Llywodraeth fwy fwy nesaf, gyda'r pwy gwrthwyr yma, ac mor hwn yn ddweud, Re Ac ydych i'r egievedd, bod weithiau hwn gallech dropd cyflopeth ar y bydd wedi cael eu hunain. Felly maeies niechaf ei bwlynd eich dd do. Mae'r ei problemau ei wneud vilwynydd i'n meddwlog. Mae'r rai swerth-, believe it or am y Apartions, ond wrth Unedwno. A gw strengthening rydych yn ôl y Clontoedd Ryddach Cymru Well, greenlets effectively. So, what we're going to do is run each of those reader and writer objects in a single greenlet. So they will be happening effectively concurrently. And the reader is just reading lines from a file and rebroadcasting them. We've got a system of queues so that a broadcast can go to all of the subscribed users. And the second part of this is the code that hooks it together. So after receiving a connection, again this is sort of hosted with the stream server, after receiving a connection we turn it into a file, readName is a function that I've not included in this where we just read one line that is your username and loop until it's a valid username. And then create a queue for the user and split out onto two greenlets to actually just do one direction of the communication at a time and the join all and the try finally ensure that those greenlets when they, because greenlets raise an exception if the connection is lost, it will just remove the user when the connection is lost. So, moving on to some theory. So, talk about async in Python, the first thing I need to talk about is synchronous. So this is a diagram of call stack and obviously call stacks can be arbitrarily deep. So I've got an example of a simple call stack where we want to get some data and that data is, so I don't know, we're going to process that data in the green function. And we want to do one IO operation which is read one line from something, a socket probably, maybe a pipe. So, in synchronous IO, we actually, the code executes following the arrows, get to the point where we block on IO and nothing happens, process, from our point of view, the process just stops there and the kernel then waits for IO and resumes us when that IO is ready. So in fact, it may block more than once, but the everything stays completely intact and the execution continues when the IO is complete and obviously then the line could be returned to the caller which will do some processing and the data is got. So, problems with this kind of model in Python, the performance is not good and the memory usage is not good. So there is an excellent article which I actually failed to include in your novel. So click that hyperlink. So, we'll google that. But it turns out that threads in Python, the gil is not a kernel level object exactly. So threads fight for the CPU attention. So it's actually much, much worse than threads in other languages. So there's also a stack memory. So a thread, the kernel knows about threads and it prepares a bunch of stack. That you can control it with U limit minus S, but it prepares the stack ready to do stuff in C basically. So, not particularly useful for Python, you can turn that limit down quite low, but you won't be able to get high scalability and similarly with processes, you've immediately lost the shared memory space which is useful about threads. A thread is basically a lightweight process, they're very similar kernel level objects. So, I already mentioned this kind of model, but what we're trying to do in all of these IO systems, asynchronous IO systems is when we are doing some IO, we want to jump out of what we're doing to let other things run. So that usually means there is a central place, it always means there is a central place that is waiting on IO, doing all of the things that are processing IO at that moment and resuming the right one when something happens. So, this is what it might look like. So, people were saying last night, don't use select, it doesn't scale, but effectively all of the alternatives to select are just sort of API improvements, but the fundamental code will look a bit like this. So, something registers to want to wait on a file descriptor for read or wait for write, and then an event loop will be started which resumes for some definition of the function resume when that file descriptor has the capability to do that operation. So, if we register a waiter to wait for data being able to read, select will return a list of file descriptors that are on which you would then be able to, so select blocks, select blocks when it returns, it returns those lists, read write error, and each of the items in that list is a file descriptor, and so for every item in the, every file descriptor in the list read is guaranteed that you'll be able to read some number of bytes, which I think is like 512 or something. So, there is at least 512 bytes in the buffer to be read at that point, and error handling, obviously error handling is actually very important in network operation, so I've omitted it for bremity, but a similar thing applies. And then this is the same thing, but sort of slightly modified to show the time out, how the time out part loops interact with that. So, you may be wanting to do IO and blocking on IO, but you also might want to be just blocking for an arbitrary amount of time. So, you could say wait for time out, and then the last argument to select is a time that we want to suspend. And if nothing is returned on read write and error for the duration of that time out, then select will return anyway, and we could do some, process all of the things that we're waiting for time out. Right, so get into different models of what resume might mean. And so, callbacks are the simplest approach that they're used in JavaScript, Tornado IO streams, Twisted Deferd, and Async IO all have this idea of callbacks from the event loop. So, this is the kind of what this does to the stack. Whereas before we had a nice simple definition of what get data, like get data was one thing. Now, I had to break it into, we've had to break the read line function into to do the bit that sets up the getting the line, and the bit that receives the line and, or waits for a whole line perhaps. So, this is a lot more messy, and you notice that I've drawn the return values as sort of, or the return parts as light arrows, because you can't do anything useful with the return values of callbacks. They're not going to a useful place, they're not going to contain any useful data. So, there is actually no way to ever break out of the cycle of callbacks and just turn into nice code where we can return values, which is a really convenient way of programming. So, I've included some examples of callbacks. This is an imaginary HTTP library where I'm making a request to an endpoint and passing in the function that I want to be called, and it's got the ability to load JSON and then. So, because I can't return it, I've got to do something, I've got to call back another callback with the response. And then, if I wanted to link the request that I'm doing to a particular state of, I won't go past arguments effectively, then there's one and one way of doing it, but one way is to use closures. So, the handle response is bound to the, where it's closed over beer ID, so it knows what beer ID is. Which I've not used. I've used callback instead, sorry. But, sort of more practical things, this is something that I encountered a couple of years ago. This is Pico, which is an MQP library, and here we're at sort of four levels of callbacks deep, and this is a simple example. So, in fact, this just declares a queue, but you might want to declare an exchange and bind a queue to an exchange. So, you're sort of six layers of callbacks deep before you've actually received a message. So, I don't like that at all. That's really ugly to me. So, somebody once said, and I don't know, I don't have an attribution for this quote, but callbacks are the new go-to. And we discussed how it's an untidy code structure where you've split everything into tiny little component parts and you're not able to do return values. And also error handling, you notice that the previous example is absolutely no error handling in there. And if I wanted to do error handling for all of those operations, I might want to register an error handler. In fact, Pico, you register the error handler once and then it just arbitrary. Some error happens somewhere in the program, but error handling with callbacks doubles the amount of work that you're doing. So, people don't, and the examples don't, and then people copy the examples, and error handling is just left on the floor. So, a simple approach to dealing with the complexity of callbacks is binding them into a class so that you have... So, rather than having the closure as I demonstrated earlier, you have a class that has methods, sorry, members and methods and things, and the methods, certain methods, are pre-registered as callbacks for certain operations. So, this is something that I wrote once, a bit truncated perhaps, but this is a twisted application wrapping a sub-process and out-received and er-received get called whenever there is a chunk of data. For some reason, the process protocol doesn't let you turn it easily into lines, so I had to write that. And then, how do we break out of this handler that's getting events called... Sorry, methods are being called on the object. How do we turn that into useful things in another part of the program? Had to use something called a deferred queue. I don't really remember the semantics of it, but again, you register callbacks into it, I think. So, this is just a simplification of some of the difficulties of callbacks, but it doesn't really deal with the problem, and you end up using callbacks anyway, and you still have to split your processing into multiple chunks. So, if I wanted to... So, say I'd... So, I'm doing self.q.put here, but if I was to decode the lines at that point and try and do another asynchronous operation, how would I link that asynchronous operation, which is another class, to this class? I've got to... I do it using callbacks, basically. And here's an example from Asyn Cio. So, it's exactly the same kind of thing. There's underlying a system of callbacks, but in Asyn Cio, you have protocols and transports that are paired together. So, your transport is wrapping a type of thing like a... well, a sub-process or a network connection or something like that, an SSL connection, and the protocol is the processing for that. So, it's still callback-based, but you can... wrapping it in a class in... I suppose it's a slightly nicer API where I had to use a process protocol. And that would be different to a protocol that goes over the wire. So, very important to understand the way that I would view... Sorry. I was just really slow when you started... Okay, okay, right. I'll try to do that. Okay, sorry. Where was I? Yeah, so I think the Asyn Cio is slightly nicer than Twisted, because the protocols and the transports are kept separate, whereas in Twisted, they've been combined. But the same problems apply. So, then we get into a more modern technique of generator-based coroutines. So, this is present in Tornado... there's a Tornado.gen module, and this is the... I suppose the key feature in the new Asyn Cio in Python 3.4. And so, what we're doing here is we're using generators, which... So, a generator... when generators were introduced, it was noted they provide coroutine-like features. And a coroutine is really what G event is built in. But in this case, we are using... So, we're trying to suspend operation between the... In the place that in the earlier example of blocking IO, we would have let the operating system call us back. We are using yield and yield from to break out of the stack while preserving those stack frames. And the event loop will... because the event loop is the parent, the event loop knows that we're waiting for something to happen. And it will return us back to the point... it will reassemble the stack when that operation is complete. So, there's literally a division in the middle where the stack is torn down and preserved as generator objects and resumed using send. And there is... one of the advantages of this method is that you can actually return data. So, in Python 3.4... where does yield from? 3.3. So, before Python 3.3, you can actually return a value. You've used generators in earlier Python. You could not have a yield and a return of a value. So, that was a feature that had to be added to make this work. And also, you've used the yield. So, the semantics of yield are now coupled to breaking out of the stack rather than being able to actually use generators as a useful looping tool. So, this is an example of Async.io and using those co-routines. So, this is a very similar example to the stack that I showed there. For some reason, Sphinx wasn't able to highlight something with the yield from in it. So, the Async.io.sleep is a special type of generator that returns an object that when it's yielded all the way through print sum back to the event loop, will resume that generator by sending to print sum from the yield from line into the yield from Async.io.sleep line and letting Async.io.sleep return effectively. And this is what it looks like in Tornado. So, Tornado works on Python 2. So, there is no yield from, there is no return value, but it's usable in Python 2 as well. But you notice that we've had to put yields into the code where really, it doesn't really make sense that we're yielding. So, what is an actual co-routine? So, generators have been described as, or the approach of generators has been described as semi-co-routines, can yield not just to the calling frame, but to anywhere, so any other co-routine. And it doesn't require any collaboration from the other stack frames to do that. So, the top level of the stack frame can just say, hold on, park me, I'm going to call back to the event loop. So, this is a bit what it looks like. So, without having to suspend the stack frame or modify the calling conventions to use yield from, we get to the point at which we block and we just say yield to this event loop and the event loop when it's ready to resume yields back to the point at which this greenlit was suspended. So, it's like blocking in the blocking IO example except instead of blocking at the kernel level, we just suspend this greenlit yield to the event loop and the event loop does what the kernel would have done, which is wait for IO and resumes. So, going back to the ace and coyote example, this is how the same piece of code we've written with geovent rather than having to use yield from. So, the only difference in terms of what you're calling is you're calling geovent.sleep. You don't need to use yield from, you write the code exactly as you would normally write it and somewhere in geovent.sleep, the magic happens where it yields to the event loop and here I'm not even kicking it off from an event loop. So, the fact that I'm using geovent.sleep, geovent.sleep will create the event loop if it doesn't exist. So, there's no, I don't have to be spawned by an event loop. So much simpler. Yes, I think I've said most of those things. In geovent, the event loop is called a hub. So, let me get back to the monkey patching. So, it's possible to just use geovent.monkey to modify the existing sleep function, the time.sleep function, which means, so you have to do that before you import anything, but in case you keep references to the old versions, but it means that any existing code can run without modifications. So, you probably have code somewhere that uses time.sleep. You can make it run using geovent just by starting your program with geovent.monkey, importPatchAllPatchAll, or however you want to express that, or maybe have a launcher that launches your program with geovent, which is an approach that's often used for something like, so it's available in Geo Unicorn, you could just say use a geovent worker and it will do all of that stuff before your program starts. So, to tackle the nastiness of monkey patching, I don't think it's that ugly in this case, because we're not arbitrarily monkey patching bits of the standard library at random times. We're just starting, we're starting Python with a completely different distribution of the standard library that happens to be cooperative multitasking with geovent. It's bundled as a library, rather than having a Python-geovent program, it's bundled as a library so you can choose to use it or not in different ways of calling your code. So, for example, you might have a batch job that runs without asynchronous code because it doesn't need it, and you want to do some CPU stuff or simplify your code by not doing a... Oh, a test is actually better. You don't want to do asynchronous networking stuff in tests, so you might call your business logic as normal code and have it run synchronously, and then just when you switch into production, you're using geovent to do the asynchronous networking. Obviously, you do integration tests with actually running through geovent and that kind of thing. But it's optional to use this. You can use the full power of geovent without doing it. It just means that you can't use existing pure Python libraries. So, I think that's a massive advantage. As I say here, you can't use it. If you're writing a geovent library, you should not rely on monkey patching being present because you don't know if the caller of your library is going to want to do the monkey patching. So, the monkey patching also works with async code using select. So, that immediately means that you can use existing libraries that are doing their own kind of networking or have their own event loop like pika there. You could use pika if you really wanted to deal with all the callbacks. But you need to ensure that it's using the select function rather than ePoll or KQ or any of the other more platform-specific alternatives that are usually better. So, just to quickly run through the kind of features in geovent, you obviously need to be able to spawn a greenlit to allow concurrent operations that don't block each other. So, the fundamental unit of processing IO with geovent is to have these greenlets. You spawn greenlets to each side of a, like a reading or writing side. You can kill greenlets by passing an exception so that when the greenlit is resumed, or sorry, signal that greenlit to be immediately resumable, but when it resumes, that exception will be raised. So, that's actually an advantage over threads because you can't easily do that with threads in Python. And then there's a greenlit pool equivalent to multiprocessing pool or other types of pools. So, if you wanted to do parallelised network operations, that's an easy way to do it. And then there's synchronisation primitives to ensure concurrency between, or to ensure synchronisation between your greenlets. It's worth noting that greenlets never run at the same, actually at the same times, unlike threads. So, these things are slightly less important, but you're, because you know that you're never going to give up control of the CPU until you hit a blocking operation. And message passing, async result is pretty neat. So, you block on a single operation. That's a useful way of turning callbacks back into synchronous programming. So, you want to have a synchronous programming model because it makes it easier. So, async result, you could just say, when this callback is raised, set a value into this async result. And that gives you something that you could block on as a sort of just get. You do asyncresult.get and it will return you the result. Or, if there's an exception, you set the exception and the thing that's waiting on it will actually receive the exception. So, synchronous error handling as well. And this is an example of using the thread killing, the greenlit killing mechanism. So, you can just use a context manager like that and you've automatically got a time out on the contained sections. So, any timers like time.sleep or all blocking operations could be limited by the same time out. And we've already met things like the stream server, but there are whiskey servers and that kind of thing. So, I think I've covered this in a way, but you can have business logic that's completely unaware of GFN and unaware of the... Even without the monkey patching, you can have business logic that's unaware of asynchronousness. And you pass in, say, a file-like object which has been made green and it will... The business logic will hit that and stop without having to change all of your call stack to collaborate in doing this yield from shenanigans to get back to the event loop to be resumed eventually. So, I think that's a huge advantage and I don't really want my business logic to have the idea of asynchronous backends potentially being part of it and also have to deal with the occasional synchronous backend. So, greenlets have all of the advantages of the kind of generator approach, but to sum it up, these things are very light. The stack frames in Python are on the heap, so, yeah, I need to hurry through some stuff. Yeah, no, cogenators. So, it works on Windows as well, I didn't mention that. A disadvantage is that it doesn't work on Python 3 at this time. So, that's a big down of some people. There is a Python 3 branch. There's a Python 3 fork. I've not tried it. It's obviously sort of usable for some things, but that's not finished. But then we're talking about networking operations. If you want to write a network server in Python 2 that chunts bytes around and use Python 3 for your user-facing stuff and do async. That's something that might work for you. Wherever we have locks, we have the possibility of deadlocks, but that may exist in other async frameworks as well. So, one pitfall, the biggest pitfall is doing something that actually blocks instead of doing this fake blocking where we yield to the event loop. So, if you're using any C libraries, they probably do this, and you have to modify the library or use any async support in that library and wrap it up into the G event programming model to avoid blocking. Likewise, if you keep the CPU busy, you'll never yield to any other greenlets. So, this isn't at all for CPU-bound activities, but you can obviously use the ability of the networking features of G event to delegate to synchronous back ends that are doing heavy lifting and return it through your network plumbing applications written in G event. So, I mentioned using one greenlet per direction. You don't want to try and merge these two into one greenlet. You want to do writing in one greenlet and reading in one greenlet because you only want to block in one place at a time. So, the writer, you're actually blocking waiting for a message and sending that message, but you're not blocked on anything important at any particular time. You can obviously use this with multi-processing, and that's a kind of approach that's used in Java and Go and Rust. So, these systems do have green threads and greenlets, but they use multiple threads underneath them. In Python, we'd have to use processes underneath them, but you can still get more scalability out of multi-processing systems by using this approach on multiple processes. And then, a couple of years ago, when I was doing this really heavily, I wrote a micro framework, which I think I gave a lightning talk a couple of years ago saying, never write a micro framework. It was a really stupid idea, but there is one. So, if you want to do G event with a RESTful G event and a green Postgres driver that can do so that your database operations also do this fake blocking kind of thing, then that's built into Nucleon. In Revoltaion at Puka and all of that callback stuff, I wrote an AMQP library that was actually forked from another one called Puka. Whereas most of the AMQP drivers try to be asynchronous through callbacks, this gives you a completely synchronous programming model. So, remote queues can be exposed as local queues and you just iterate through the messages of a queue or loop over getting messages from a queue rather than having a callback called every time a message is available and all of the other AMQP operations as well. So, that's that. Do you have time for questions? We have five minutes of questions roughly. If anybody wants to need to go to another room to another station, doesn't have a question, we would appreciate it if you could be forwarded to have some piece of the question. Otherwise, if you have a question, there's the mic. Just slide on. This is more a comment than a question, but we're skipping over that part real fast. But G-Event only uses the select system call on all operating systems which give suboptimal performance and other platforms like Windows, for example. Somewhere in the heart of G-Event, it will use the most appropriate thing for any particular operating system. It's a horrible choice for cross-platform scalability, but it might be good if you know your target. I think it probably is possible to adapt G-Event to be more Windows compatible because the coroutines approach is sort of completely abstract. You could use it. But now it uses a suboptimal system call on some platforms, so it might be worth knowing if you're going to dabble in G-Event. In fairness, I've never used it on Windows, but I hear it works on Windows. No, me neither, but it's worth knowing. Is there any optimal number of grilllets you can use in the process? Is there any optimal number of grilllets you should use per one process, for example, or range? How many grilllets should you start? How many workers could you start? Oh, grilllets. Oh, start as many grilllets as you want. The grilllets are very, very cheap, so create as many as you need. You can start at like 1,000? Yeah, 10,000 grilllets. 100,000. Who cares? As long as you've got memory. I have a question regarding generators and coroutines. If you use a generator, you yield if you have an asynchronous car to do, and you exactly know that between the yield and the resume, the global state or the shared state may change. In G-Event, you don't see obviously that, for example, time sleep may suspend your green light, and the state may be differently when you wake up again. That's something to be careful of in all of the Async frameworks that you can't really rely on global states. Something that is useful about G-Event is that it has its own thread local object. The monkey patch approach will apply that thread local object as the threading.local. That means that you can have your local state in a thread local object, and I think Flask uses thread locals or something like that. With monkey patching, the Flask global stuff should work. Although I don't think I've ever tried that. Obviously, it's something to be careful about using global state when you're using anything concurrent. Thanks. If G-Event was ported to Python 3, could it be compatible with Async.io? For example, could we use some library in that scenario that's written in the Async.io style? I suspect you probably can. Async.io is completely within Python. It doesn't have any special Python tricks, whereas this one C trick in G-Event and similar systems with coroutines where you could jump to a different stack. Anything completely within Python could potentially run on G-Event. The big hope for Async.io is that the event loop in Async.io will come to be the standard event loop for everything including something like G-Event. You could run an Async.io event loop and have G-Event use that as its event loop, meaning that all of the frameworks like Twisted and Tornado and G-Event and Async.io could all be running on exactly as Async.io. As it is at the moment, you could probably use, because, as I said, Select is one of the things that's patched, you could probably use Tornado and Twisted, their own event loops within G-Event, but actually bringing everything together is an open problem. OK, thanks. Hello, do you have any idea on when G-Event will be ported to Python 3? I think it's a very important dependency for a lot of projects, like hundreds of thousands of projects. We Twisted, I think it's one of those dependencies which needs to be ported right now. So you have any estimate on when? So G-Event has only just reached version 1 at, it was in November last year, that it reached version 1.0. And I don't know how much effort is going into writing a Python 3 compatible G-Event. So, yeah, no answer for that, but if you're interested, get involved. Why not? OK, thanks. Thank you, it was a very insightful presentation. I'd like to ask you where I work, we use Tornado for production and Async.io Python. Sorry, I didn't hear that, it's a bit noisy. Sorry. Tornado? Where I work, we use Tornado as Async.io Python and it works really well, just like G-Event, I myself used G-Event in the past. The problem is that we found a really hard bottleneck and that is the database, because the database we couldn't find an asynchronous ORM. Yeah, right. So it's a huge problem for us, we don't want to use inline queries. So, do you have any idea of an asynchronous ORM or one that's being developed? So, there are ways around it. If you want to do synchronous operations, you can use an actual thread pool or something like that. So, wrap up the synchronous code with or a multi-processing pool so that you are passing the requests using G-Event and receiving the responses using G-Event. But you only have say four blocking workers that are doing database calls. That's one way around it. I think, so in nuclear on I found a way of somebody had already written an example code for how to make the Postgres Psycho PG2 driver coroutine compatible by having the library itself tell you when it wants to block and then you are responsible for doing that kind of blocking. So, it is possible for some drivers, but there are workarounds for others. Okay, thank you. Thank you very much, everyone.
Daniel Pope - gevent: asynchronous I/O made easy gevent provides highly scalable asynchronous I/O without becoming a nest of callbacks, or even needing code changes. Daniel will explain how to get started with gevent, discuss patterns for its use and describe the differences with Twisted, Tornado and Tulip/asyncio. ----- It has been claimed "Callbacks are the new GOTO". Most asynchronous IO libraries use callbacks extensively. gevent uses coroutines to provide highly scalable asynchronous I/O with a synchronous programming model that doesn't need code changes and callbacks. By elegantly monkey patching the Python standard library, both your code and all pure Python libraries become asynchronous too, making a separate collection of protocol implementations (in the style of Twisted) unnecessary. Code written like this is easier to understand, particularly for more junior developers. Crucially, IO errors can be raised at the right places. I will be introducing gevent's programming model, why it's easier, walk through simple code samples, and discuss experiences and metaphors for programming with it.
10.5446/19957 (DOI)
So welcome also from me. We're going to listen to Constanza Kurz and for those of you who don't know Constanza, she is a speaker for the Cars Communication Club. They are very instrumental in Germany for many, many things regarding data privacy. And she has been expert witness to the constitutional court that finally stopped data retention first in Germany and then later on in Europe. But she's also involved in many other legal struggles and she's going to talk a bit about this. And just one statement I'd like to give in regarding that. Many of you probably know Lawrence Lasek who said code is law, right? Maybe you heard of that. What he meant by that is actually that programming determines many things in our societies. And I think we've come to realize that laws and what governments do also influences very much what we can do with programming and how programming is actually used by the government, by secret services. And that's kind of one of the topics that evolved especially in the last year. And again Constanza has launched some actions I think so far in all of the court struggles she's been involved at, she had a 100% success rate, right? So that was, and I hope she continues with that. And in other news she's also a co-writer of very interesting books about the increasing automation that we have in our societies. The German title is Arbiter Frey which means something like out of work, like automated away, something like this. And what we can expect in the next 10 years but this is not the topic of her talk now but also something she is doing. And so I'm very happy to have her and give the keynote to Constanza. Yeah thank you Holger for the very warm words and you of course for the applause since I didn't even start it, thank you very much. Yeah it's one year of Snowden, what's next? And I guess I'm happy to be back in that building as you maybe know I've been here for quite some years because the hacker community had the really largest European Congress here for quite some years and so I'm happy to be back. And speaking in front of another tech community about the Snowden revelations. It's going to be a mixture of of course technical topics but also questions of legalese and of course political questions because after that year of revelations and the revelations will go on of course. We have to ask some questions and we should show as a wider tech community that we care and that we don't accept the way it is and that we try to change it. And I will maybe in the end of the keynote have some ideas what to do about it. Since June last year we learned more and more about American and British and other spies deep appetite for data and information and of course about economics buying and about the technology they use to collect data as well as their hacking skills because they also pay a lot of hackers as we know now. And we know that the spies systematically tap international communication on an industrial scale that's what we know. And the NSA and the GCHQ and the partner services and contractors, metadata repository is capable of storing billions of transactions and events daily. So the question is if there a way to defend against an agency like the NSA with a monstrous budget and where 8,500 NSA contractors have access to the data thinking about economics buying as we know now from the Guardian and other papers revelations. After more than one year of Snowden documents we have to conclude the democratic oversight system failed at each level of oversight. So then let's see how to fix it actually. First we need to analyze what's really going on if we want to fix it of course. And I want to talk a little bit about the surveillance industry that happens to be nowadays. There is a study of privacy international, a research study of surveillance companies that offer their products nowadays. The study is a collection of what is being sold. It's also a categorization of the technologies and also an explanation of what these technologies actually do, can do and cannot do. And those companies as you see here worldwide they are 338. They sell different kinds of technologies for surveillance like cell phone monitoring equipment, interception equipment as in hardware. Of course technologies for internet monitoring, spyware packages that allow users to take complete control over the computers and over mobile devices. They even buy cell spyware packages for law enforcement mostly or secret services that allow the user to take access to all the data and even the camera and microphones. That is the status we have today. It's really an industrial complex and not only monitoring, filtering and censorship technologies but also passive and offensive hacking tools. Privacy international really did go to the marketplaces and to the fairs which are worldwide and took a look at the marketing brochures those companies have. We should have that in mind if we think about the Snowden revelations because there's a reason for all that's buying complex and the reason is simply money. Those companies usually do not take human rights concerns into account or think about the risk of misuse meaning that their products are used to target pro-democracy activists, journalists or any political opposition in regimes or as we know from the Snowden fights now in democracies. Because since those technologies in the last decades were used in regimes only we now know that they are used in democracies as well and the technical tools to defend against it should not only be used in regimes but also in democracies. In the rare case that there are export restrictions because those companies mostly come from the Western sphere and if one of the companies can get any approval to export their surveillance products from one country then they simply do it from another. That's the way it works today. We have on a political agenda the question to ask about export regulations of those technologies not only using it in our democracies. As it is the same for the secret services like NSA and GCHQ this surveillance industry lacks effective oversight or any form of accountability too. We have a problem that comes together with those industrial surveillance complex and the secret services. But really the start of the Snowden year at least on a worldwide scale was the prison scandal, the prison program. What you see here is a picture from orbit which the NASA took and artificially you see the Facebook network plotted on that photo. And I guess since the prison program mostly used social network data and made some videos and video chats and photos the scandal really emerged because most people felt that they have to care about those prison programs because everybody or at least most of the people in the western world are targeted by those mass surveillance programs. Actually I want to talk a little bit about the Pfizer decision. I come to that later. But most important for me is that that program already started in 2007 so we have the situation that those secret services have a social and communication graph from the whole western world with the history of some years. It never happened in the history of mankind actually. They know the communication pattern of everybody who uses that services. And all the companies you see there are cooperating but they do not do this willingly at most but they are legally obliged to do so. And that's why I want to talk a little bit about the Pfizer, the foreign intelligence surveillance act because it's kind of the problem which emerged of course for those companies because this Snowden year is also really a trust crisis in not only between the state and the secret services but also in the rearm of the companies. This worldwide attention to the NSA program in the beginning it was NSA and FBI and CIA and not the British GCHQ started on June 6th last year as you maybe remember. Glenn Greenwald and even MacAskill for the Guardian and Barton Gellman and Laura Poitras for the Washington Post reported on a U.S. domestic collection of foreign internet-related data. They got from a Washington Post from this June 6th. The National Security Agency and the FBI are tapping directly into the central service of nine U.S. internet companies extracting audio, video, chats, photographs, emails, document and connection logs that enable analysts to track foreign targets. So it was really, that's why I quoted this from the law's perspective, it was really intended to target U.S. citizen, not intended to target U.S. citizen but us as in European and everybody else who's not U.S. citizen or on U.S. soil. And so the discussion on a political basis today in the U.S. Congress and the U.S. Senate is just about that domestic spying. It's not a question if that form of spying or mass surveillance will end for people outside U.S. soil or non-U.S. citizen. We should keep that in mind. President is of course the system, the internal computer system that collect this data and that is what two days later on June 8th, the U.S. Director of National Intelligence released in a fact sheet. So what I speak about here is only what is, where's no demand from the U.S. governance side or from Director of National Intelligence. There are some rare cases in that year of revelations that the U.S. government said no. Here is the reporting not correct but mostly they didn't even bother to write a demand. I want to talk a little bit about the fees that is decision because in my opinion in the public sphere it's not quite clear to everybody that this form of mass surveillance is legal in the most forms because of that Pfizer Foreign Intelligence Surveillance Act. Generally speaking, under that Pfizer, any form of electronic surveillance is permissible if there is a probable cause to believe that the target is a foreign agent or foreign power and the primary purpose of the investigation is collection of foreign intelligence information. And in Section 218 of Pfizer even that requirement that foreign intelligence gathering be the primary purpose of the investigation was eliminated. Now it only requires that it be a significant purpose and this act you maybe read about it in the newspapers also established a special secret court composed of hand selected court judges to review the applications for electronic surveillance orders. But this secret court hears only the government's evidence. And the Pfizer court is not revealing any public information concerning electronic surveillance with the exception of an annual report detailing only the number the request made. So the secret Pfizer court is also a very silent court. And this silent court and secret court have never refused a single request in its 21 year history until 2002 when the Boundless US Patriot Act became law. So that is the kind of oversight we have which completely failed. Not speaking about the political oversight but the judges. But allowing secret tribes based on secret evidence with secret outcomes and no public scrutiny to ensure any form of fairness would be a talk on its own. So I stopped talking about that legal site now. Well speaking of the companies, the cooperating companies, then if a company like Google receives a valid Pfizer court order it has of course to deliver any information requested. Of course. So from the beginning and it's even after a year one of the largest scandals and all those revelations they emerged in an interesting discussion about metadata. You see on that picture an example. This is from a Greek scandal some years ago where the whole government, the president and the ministers were tapped. And this is a press conference actually a picture from a press conference where they plotted from one of those surveillance software products so that you see what metadata will be seen at the screen. Of course if you have it on a computer you can interact of course with that. The problem is that metadata and most of that surveillance stuff is really it's abstract in a way I mean it's not really, you cannot really feel the surveillance. If you sit in a cafe and there's somebody really staring at you the whole time then you would maybe say stop doing that. Don't look at my screen don't listen to my phone calls. But if you have that metadata discussion it's not the same as surveillance in a physical word. So what's really at risk here most people don't realize. But the metadata discussion goes on until now and maybe we will have a decision about that from the US Supreme Court later that year or in the next year that is possible. I come back to that metadata later of course. Why they are interested in that metadata so much is because it's significantly easier to collect and store because of the volume of the data and it's much easier to detect any anomaly. Meaning anomalies in personal communication behavior like if they are a person starting to communicate with each other is it maybe on, it's maybe in nighttime. So you can have filters or triggers in any form to detect those anomalies and ask maybe for a special identifier like phone number or E-mail numbers. And it's of course optimal for any form of automatic filtering. So that metadata discussion is not over now. Of course in Europe metadata belongs to the data that is protected by the right privacy. Maybe not the same in the US but we will maybe see from court decision this or next year. After the first revelations about the prison program and the starting metadata discussion, General Kieser-Elektander, the then director of the NSA which is of course a general because the head of the NSA is always a military guy, confirmed in two public hearings of US Congressional Intelligence Review Committees that the NSA collect both domestic and international telephone call metadata from all major US carriers and maintains a database of all such codes for five years. So we now know but actually that is for all the revelations that I speak about here. We just know nothing really changed. The SNN initiative right now in the US Congress to change some of some of those programs but actually it's just for domestic spying. It's not for European. Let's say not for us. The next step in that scandal which is the third one from, or I believe that it's one of the largest scandal is a temporal program. What you see here are commercial undersea cable which we have today. You see a little anomaly because if you would have an undersea cable today then you maybe wouldn't choose that route from UK to New York over the ocean but that come from the telegraph lines more than 100 years ago. And as the telegraph lines were invented actually they didn't know very much about the underground of the ocean so they just took a direct route. And that is the reason that more than 85% maybe of all the connections between the European continent and the Americas goes through the British island and that's why with the temporal program the GCHQ started to be part of the scandal that is the British, one of the British spy agencies. GCHQ wasn't actually exaggerating when it invented the phrase mastering the internet which is the name of one of the programs as to be found in the snow and documents. Within those temporal program some 300 GCHQ plus 250 NSA agents have the task to analyze the data that goes through the undersea cables and this is stored up for up to three days for content and up to 30 days for metadata because the volume is of course not that high. You see we talk about a 20 petabyte that means million gigabytes in that three days. And those events it's really the stuff we do every day on mobile phones and over the internet. So it's not an event like a technical term but it's our communication and our emails and our photos and stuff. And of course it's the same as in the prison program the cooperating companies which are not only the well-known companies like British Datacom or Verizon, it's also the backbone providers because of course part of the temporal program are hardware devices on the places where the undersea cable land on British soil. As we know most of the bits we click is betawrent, YouTube and U-Porn of course and to reduce the sheer volume of the data running through the undersea cables like peer-to-peer downloads. It's discarded of course by filters and this reduces the volume about by 30% maybe. And those filters not only reducing the data volume but also a triggered by words, by email addresses of phone numbers. So the data stream is actually filtered, categorized and stored if it's of any interest. All in all GCHQ and NSA which work as, yeah, it's more like it's really close working together at least in the TEPAWR program. And they use around 40,000 of those triggers to filter and analyze the data that flows over the undersea cable. So we know that for a year now and the question for all the European countries and not only Europe but worldwide actually is what we're going to do about it. We talk about the TEPAWR program here in Europe a lot but there's also an exact duplicate of the program for the PAKnet which is an Asian Pacific undersea cable net. So it's actually a worldwide undersea cable surveillance program. For my opinion at least in Germany the public debate, it's not only Germany, it's worldwide I guess, really changed when one prominent German person and her mobile phone was tapped. And to me it's until now a scandal that only this one tapping of a mobile phone which is Chancellor Angela Merkel of course is really a scandal in the political sphere and not the mass surveillance and the offensive hacking techniques we learn from. I see you agree. And since I don't have the time to follow that chronology of that year step by step because you could really need five hours for that, I just want to have a short break and tell you just in some words what happened afterwards until maybe the end of the year because I guess you remember from reading the newspaper what happened in this year. And June 21 where GCHQ's Temporal Tapping Fiber Opticabits became known which was from the Guardian. In July we also had a attack list, a target list reported by the Guardian about cyber attacks. That was a list of quite a lot of targets worldwide. In July we also learned that the NSA is buying explicitly in Asia and Hong Kong and there are also hacking attempts against China and that the US hacked PAKNAT which is the Asian Pacific Fiber Optic and then Network as I mentioned. And not only from one year or two but from 2009 on. In July 31 we also learned about X-key score which is essential to the NSA users to aggregate nearly everything from the Internet as the Guardian wrote. In August it was just one month later and we all thought it was somehow maybe the revelation stopped. We learned about even more cyber attacks by the US mostly NSA and that were 231 offences operations even in one year. And in September the first time there was really blood on the data because we learned from an article in the Washington Post that the NSA has ties to the US drone attack and that metadata and content data explicitly were dumped into the US drone program. That means that the data triggered the CIA driven drone program and well the Reaper and Predator drone with the Hellfire rocket were sent to mobile phones to deliver the bombs. So actually that was not really reported in Europe very much but in the US it was reported from the Washington Post as I said. And I guess that is a discussion we should follow closely because I think in this year 2014 we will have more of those connections between the CIA drone program and the metadata and content data collection of the NSA. Because if you want to fire a Hellfire rocket then you need the data to know which mobile phone to target. In September we even had the first cyber war attack as defined by the NATO and that was as the GCHQ targeted and spied on Belgacom which the speaker reported. Actually Belgacom is one of the main telecom carriers in Belgium and the GCHQ passively sniffing hacked some of the maintainers of the network and faked linked in pages to target those engineer and they had success and that is really a cyber war attack as defined by the NATO against another NATO country which is Belgacom. That was really interesting because that kind of attack was the first time we heard about that. We even had a location data scandal but it wasn't really reported worldwide because the NSA collection, a mass collection of US cell phone location data was only reported in English and not so much on the European country. So we have also of course not only the communication and social graph from Prism but also a geolocation program which runs geolocation profiles of course. Maybe I stop here. I mean you can read it in the newspapers and I guess as I took a look of all the papers I'm researching for that scandal for about a year now. Some of those reports in the different newspapers not only American and European but also Brazilian and Asian newspapers. I simply forget because all the small scandals in between are really forgotten when you think about the really big scandals we have here and the lack of oversight for that mafia like secret service complex. What we learned from that chronology and I took it on one slide because I wanted to have it in one place. That's what we learned over the months. These are priorities as in targets from those NSA programs. As you clearly see these are the top terrorists we have in the world. The targets are the EU institutions and also the parliament. 80 embassies worldwide, heads of foreign governments and two from those heads we know by name, Brazilian president and German Chancellor Merkel. We also have the top terrorists at the G20 meetings which were tapped. They even invented fake internet cafes to grab the passwords of the teams of the politicians meeting at the G20. Also the OPEC, the World Bank, large companies like the Brazilian Petroba. We have a list of priorities here but we have even more. We also have from the revelation the national intelligence priority framework. This is a kind of matrix from just the part you see here and you don't have to read it. I copied it. You see it in the next slide. It's a matrix of targets as in contents. What is really, what kind of topics are those secret service interested? You would maybe wait for national security issues but I copied it for Germany from that framework. What you see here are the targets in that framework. That is cyber attack counter espionage emerging strategic technologies. Clearly a top terrorist problem. International trade policy, arms export, arms control, foreign policy, objectives, economic and financial stability. What we learned from that year is that it's much more about economics buying than the political discussion and the discussion in the newspaper is about. They always argue with the question of national security but as we know from the revelations it's much more about economics buying. Actually the scantils are much more about power and access to information than about national security. If you see the ideology behind that and I quote that from the deputy attorney general, James Cole, then you have that metaphor of the haystack. He said if you're looking for a needle in the haystack you have to get the haystack first. What we learned from all those programs is that they are piling even more hay. What we also learned and I come to that in a minute is that piling on more hay doesn't really help to find the needle. But before I come back to that ideology I want to talk a little bit about the dimension of what we actually fight against now. That is part of the revelations too. It's so-called black budget. Most German countries you know about the budget, those secret services as in money or receive. When we have the 19 German secret services we know as a population what money we spent on that. That was different in the United States. The black budget revelation was really interesting to take a look at the US national intelligence budget. That is of course you see it here. Over 50 billion dollars a year and that is much more than even some of the politicians in the review committees knew. As I talked to William Binney who has been here in Berlin because we have the commission in the German Bundestag, the NSA Untersuchungsausschuss. We talked about that budget on a podium here in Berlin and he said, okay, that 50 billion dollars per year is not sufficient. And I looked at him like, what do you mean not sufficient? It's not that much or even more. He said it's even more because some of the secret service budgets are in, let's say, in military stuff. It's hiding somewhere. He said in his active time in the NSA the budget was already 80 billion dollars per year and he said that some years ago so it's maybe even more. That meaning he corrected the budget above. I was really staring at him at that moment because I thought 50 billion dollars was quite a lot. If you think about how many nurses you could pay from that or how many rockets you can send to the moon from that money. I'm running a little bit out of time. But I want to talk a little bit about the tailored access operation because most of the scandal in the public sphere talked about the mass surveillance, metadata, content data and the little and the larger scandals. But for me as a hacker it's of course interesting what they do in the tailored access operations and what kind of exploits they really have and what are the methods actually that they are using. In the Snowden papers we know now that the TAO, tailored access operations, has explored against Windows, MacOS, Linux and iOS and some more which are unnamed. Some of those exploits are really zero day exploits but most of them are known. So they spend maybe quite a lot of money to have access to those exploits. And we also learned actually that the gray and black market for computer vulnerabilities or mobile phone vulnerabilities and malware of all kinds, that gray market is paid from those secret service budgets. So we wouldn't even have that gray and black market on that large scale if they wouldn't spend that money on that. They had different methods within the TAO operation. Meaning of course back doors, that's what we expected. It was a manipulation of random number generators because that's a good way to weaken encryption. They had an intent of cooperation with NIST, NIST is a standard institute where every 10 years, new encryption standards are somewhat invented. I shouldn't say invented but NIST was really releasing a press statement and some parts they said yes we did cooperate with secret services. They even tried for that part of the data collection they had which was encrypted to get the master encryption keys with different methods and the programs they have for that called bull run for the NSA and etcher for the GCHQ. They have really $255 million a year and it's if you think about it in fact an anti-security program and it undermines of course the trust we have and the IT systems we use every day. That was really interesting to learn about the offensive strategies from those secret services. They really have a lot of hackers that they pay and it's really hard to change it on the ideological way. If you take a look at the British and the American hacker community it's quite common to work for some years for NSA contractors or even for the NSA itself. It's maybe very different from the European habits. We heard all that and I missed a lot of revelations because I don't have time to collect them all here but I want to talk a little bit about the success. So what about national security? And I copied this from the White House panel which US President Bargul Barma initiated as a commission really run by secret service veterans and even those secret service guy who clearly belong to the intelligence community wrote this in their report. The metadata of the telemedication brings only a modest contribution to the nation's security and there has been no instance in which NSA could say with confidence that the outcome of a terror investigation would have been any different without the metadata. So the stupid phrases we heard in the beginning of that scandal that all that mass surveillance explicitly metadata but also counter data would help against terrorist attack is quite nonsense and we see it in the White House report and the intelligence community itself who is sitting in that commission stated it in its own report. That was really interesting and as you maybe know it wasn't really reported at least not in German. You maybe know and I'm coming to the optimistic part of the talk now. They also targeting a tour. We know from October where the presentation the NSA presentation tour stings were published that tour is really targeting, tour is anonymizing network as you maybe know. And this July the German ID and the Zutatia Zeitung had a publication that explicitly target users, tour users are targeted. That was really interesting because they released some of the filter routes for the deep packet inspection which the NSA and the GCHQ used to have triggers for every tour user and not only tour user but also people who search for information about tour. That was really interesting because right now tour is the only affordable and reliable technology for people in for example China or Iran to communicate encrypted and anonymized with the rest of the world. One of those tour services operated by the Chaos Computer Club here in Germany. And so the data traffic to and from those so-called tour directory servers is being taken into the repositories of the NSA. And that was the reason that we fired again a criminal complaint against Angela Merkel, Anders in Germany, the head of the secret services in Germany and foreign secret services. And mostly everybody who could be maybe responsible for that because I guess at least we don't only need political help and we need technical tools to fight against those NSA must surveillance and especially targeted surveillance like that one but we also should use the laws existing and that's why we fired a criminal complaint against those aggressive surveillance in Germany directly and we just hope that the General Bundesanwalt is a state federal prosecutor to do his job and ask the NSA some questions. I'm not quite sure if this will work out but we even tried. I want to talk a little bit about other ways to defend against those mass surveillance. And a quote here from a GCHQ memo from May 2012 where the GCHQ said our main concern is that references to agency practices, meaning the scale of interception and deletion, could lead to damaging public debate which might lead to legal challenges against the current regime and the scale of interception and retention required would be fairly likely to be challenged on Article 8, the right to privacy grounds and that is exactly what we did because the Article 8 is part of the European Human Rights Convention and the UK different from the US of course ratified that convention in 1951 so it's bounded to that convention. And a big brother watch, open rights group and the English pen and myself, we had a joint application to the European Court of Human Rights in Strasbourg so we try to go the legal way, though I think we should protect ourselves on a technical way to begin with, of course. Maybe in the end of July we will know a little bit more from the court because until now we have so-called Rule 41 which means that all cases prioritized but actually the court although we have that fast track, stopped the process a little bit because of the British Tribunal which is also a secret court on UK soil where groups like Privacy International try to make a case too. And so they waited for that outcome so we just know maybe in a few days where the case goes. We just right now have a catalogue of questions for the British government and also for the German government because I'm a German citizen but until now the German government decided to not really answer any of the questions. But I guess it's just a legal way and we should try that and I'm really very satisfied that a lot of people, thousands of people spent money on that case as we had in just 48 hours the 20,000 pounds we needed for that case together. And this five or six euro come from all over Germany and in just 48 hours we had that sum we needed together. I'm very proud of that and I feel that different from the opinion you read in the newspaper people actually care and they want to support. That's our fear at least. But the legal way is one thing and to put political pressure on those responsible for that. But I think as a tech community first of all we should use encryption and not only use it but implement it. That is what we should do in our normal working habits because we as a tech community should help the normal user because he will rely on us to have working encryption because the NSA, mass surveillance programs, they doesn't scale. If just 10 or 15 percent of users really switch encryption on they get blinded and that's what we actually should do. So that's actually what I demand from you, use encryption but not only use it but implement it. Be as transparent as possible when using encryption in technologies or software you build. That is I guess to rebuild the trust that is lost that is essential for that. So be as transparent as you can. We should not only cut the budgets of the professional peeping tones but also raise the standards in general for the government to look at everyday communication data, metadata, content data, purchase records, medical records and so on. Because by its very nature mass surveillance is neither necessary nor proportionate because these technologies enable the violation of human rights. It's a human rights issue, particularly the right to privacy and also the human rights of freedom of expression. So eavesdropping on that massive scale is simply not acceptable in free society so let's fight it. Thank you. I'm not quite sure Holger, are we supposed to have a question and answer? I don't know. I don't want to be that negative. I hope you have an optimistic feeling right now. There are two microphones, you can go over there or here and we have like let's say five minutes and then we... Is this thing on? Yes. It is. Thank you for these amazing insights. Thank you. I have two questions which are actually basically one. What would happen if one of these companies at some point just says no? And what would happen if all these companies, their CEOs come together and they make the agreement and they say no? Can you tell me? Do you have any insights into that? Well, that is not such a trivial question. That's a really complex question actually. The point is I have maybe to remind you that law-interception techniques are built into all commercial telecommunication networks by law and they have standards, so-called Etsy standards. So the technique to intercept is from a legal perspective necessary to be a commercial telecom carrier in all western countries, meaning that the possibility is already there. And from a legal perspective, not only the US companies but in many European countries too, they are simply obliged to hand over the data. What they could do actually is to switch on encryption to not lock any content and in that way help the users a little bit. What they actually do right now mostly in the US is of course write open letters because they see that the trust crisis is a question of economy right now in the European and Asian markets because they see that mostly the cloud companies that, well, it really drops the partners, not even, they don't have a lot of new contracts but they also have second contracts from agent and European partners demanding from the US companies that they have special privacy contracts to the normal cloud contracts and stuff. And so the pressure from the economics fear to the US administration, it's getting higher. So maybe that trust crisis will be not solved in a political realm but in an economic realm. We have a lot of small companies who say, okay, we build our technology that way that we can't hand over data like in the TOR network or other examples. But we, the huge telecom carriers and internet companies, they don't have a choice. Well, it's interesting because if you step out for a moment and you look at what's happening, it's basically, it's the nation state, an institution with an army, which is very powerful of course, but it's interesting to think what would actually be happening on the enforcement side of things if a group of these companies just agree not to participate. Well, they actually do. Point is that we as users, we tend to use the large companies. So maybe I urge you to think more decentralized. Thank you. Hi. We're here at the Python conference. Gido Van Rassen, the creator of Python, has been working in a company that makes sure we all have our data secure, our most important data secure for the last three years. This company has just acquired a new member of the board of directors, which is Condoleezza Rice, one of the main supporters of massive surveillance, which is working at the same company of the guy who created this beautiful language. What are your thoughts about it? Yes. What you're referring to is actually the so-called revolving door, right? Is that what you meant? The so-called revolving door that you have is a lot of people who switch between companies, contractors, secret services and stuff. That's what you mean? I mean Dropbox. I don't really get to. Well, sorry. Dropbox is a company where you can keep all your most important files in the cloud. Well, Gido Van Rassen is working, the creator of Python is working for that company for the last three years. This company just added a new member to the board of directors, which is Condoleezza Rice, one of the main supporters of massive surveillance, one of the people who explained that it's necessary to have some... Now I get you. Of course, I read it in the news. Maybe since at the Hope 10 in New York, Edward Snowden referred to that case. Maybe most people are aware now. I don't have really any good comment on that. I guess it's not the only case. I feel. I think it's just something we should all think about and maybe talk to Gido about it. Thank you. Okay.感覺?
Constanze Kurz - One year of Snowden, what's next? Since June 2013, disclosed by Edward Snowden, we learn more and more facts about American and British spies’ deep appetite for information, economic spying and the methods they use to collect data. They systematically tapped international communications on a scale that only few people could imagine. But what are the consequences for societies when they now know about the NSA metadata repository capable of taking in billions of "events" daily to collected and analyze? Is there a way to defend against an agency with a monstrous secret budget?
10.5446/19956 (DOI)
you you you you you you you you you you you you you you you you you you you you you you you you you you you you you you you The video operations center is still very active and working right now so they can't come down here. They're sitting up there in the dark. They are Daniel Meisner, Manuel Hartkempa, Florian Larisch, Peter Hasse, Björn Riemer and Peter Körner. So the BCC has been housing us for the last week and for the next two days and I would like to thank them as well and come up here. Pia Sofi-Wilm, Valentin Dreeves, Marc Stender, René Gitter, Mario Hatschief, Dirk Matschei, Dennis Hegemann and Philipp Waldo. These are already a lot of people, however, there is the volunteer organization. So Karina Haupt and Markus Holtermann, can you raise your arms just to show again. Those two guys were organizing even more people. Wait, where's my slide? Ah, there, there we are. These are all the volunteers. Stand up if you see your name. As a reminder for you volunteers, we still need you. We need to dismantle the place and we will give you a barbecue tonight at 8pm for honoring all your services. Additionally, Fabio Plieger, who isn't here yet from the EPS, he says hi and he also says thank you to all the organizers. One more specialty. We're very, very grateful for the work that Pyleides and Django Girls made, did put in here for making Europe even more fantastic experience for everyone. So please give an applause to Patricia, Alexandra Sendecher and Ola Zitarovska. Thank you very much. Christian, both is very nice. Thank you to everybody. Thank you, Christian. Okay, we are not done yet saying thank you. Can you go back? No? Yeah, okay. Of course, this conference wouldn't be possible in the form and it's now without the sponsors and that's why we put all the logos up here for all the sponsors. You can see many of them. And then different levels, please look at the website. We have bronze and silver and gold sponsors that help us to make this conference affordable. And special things I would like to say to our three platinum sponsors and I would like to call their names. So it's Google, HP and RoadCode. Thank you very much for all our sponsors. I think we're not quite done yet because there's a group of people missing that we haven't thanked yet. And actually that's you. That's all of you who came here. We are extremely grateful because without you, all of this would not make sense at all. So thank you to all of you. Please! So to everybody who leaves today, see you next year and have a safe trip home. To everybody else who stays, see you tonight and on Saturday and Sunday, enjoy the sprints, the bar camp and the Pi Data Conference. This leaves only one thing for me to say, oh no, it's starting, great. This leaves only one thing for me to finish with after this slide. Everybody on there? The one thing to say at the end. That Python, dammit! There you go. Good job!!
Conference Closing
10.5446/19955 (DOI)
Today we want to talk about Stackless, former name was Stackless Python, I don't know how many people know about this project already, it is a rather old one. And in the last couple of months a lot of changes have been made, a lot of enhancements which really make Stackless very usable and drop in replacement for C Python and that's mostly the work of my colleagues and one of them is Ansem Khois who is giving the majority of this talk today. I think to do an introduction about what Stackless Python is and then we get to the new things and please interrupt me when I'm quibbling too much, I would do the same for you. So what is Stackless? It has been around since 1998 and had its shadow existence behind regular Python and it is kind of a niche product which tries to do things that normal Python cannot do. So it is called that Stackless is a Python that does not use the C stack. That's a lie because of course it does use the C stack. It does not have problems because of that because the C stack is always built up and removed again so Stackless means that there is no dependency from the C stack and that is the main reason to be able to do task switching and other stuff. So actually Stackless is a Python version that does not keep state on the C stack. It has some state sometimes but at certain times where it can perform some context switch, this stack state is removed completely so it is breathing up and down until something else has to be run. So this is theoretically in an ideal world it would work this way but in the real world, in 90% of all cases it works in this cooperative manner but not always. So Stackless is like C Python. Unless you import the Stackless module there is nothing changed at all. Not even the behavior, the creation of recursion level limits and all of that. It is all original C Python. It can do a little bit more than C Python. So there is Stackless module and you can import the Stackless module and that suddenly creates a lot of new, a few new functions with a lot of possibilities. So it looks a little bit like an extension module but it is no extension module because Stackless Python requires quite a lot of changes to the interpreter. This does not change the way how you use it and it does not change the format of pickled things or anything else but the way the virtual machine is working is different from that from C Python and I think Stackless does it the right way and C Python does not but that is a long fight. I will probably lose in the end. So yeah, what is it about Stackless? You have a little tiny, tiny, tiny, tiny, tiny programs. These tiny programs can be switched forth and back. You can communicate over channels between these tiny programs. The tiny programs are called tasklets. It is similar to so-called micro threats but there are no threats at all. A tasklet is just a tiny piece of program that runs a while and at some point it decides to yield its time slice to someone else and then it continues in another place in the program and that is a difference to C Python. That is something that was invented for C Python in 3.3 or 3.4 I think by using yield from constructions. Stackless had that since 2002 I think. So actually we have tasklets which are a little like coroutines and this can switch freely between each other. And the ability to do so is the way the interpreter is constructed which is non-recursive but it is only doing small cores and going back before it switches to something else. So we have no contention of the C stack which in C Python you have the C stack and if you have three nested cores of a Python function you also have three nested cores of C functions which do this Python function and that is exactly what Stackless does not. Okay, here is a little example. We have some cooperative multitasking. We import Stackless. We define two functions, receiving tasklet and sending tasklet and then we just start them. I did some examples just in order to save me from typing because typing is not so well but we can have some examples afterwards. So let me skim over this. So when the tasklets are communicating you see some protocol where you see that they are jumping from one context to the other and well. Some people might say why don't you just use the greenlet. The greenlet is actually quite famous and very complete and good implementation of task searching. It does that with some technology from Stackless Python which is called hard switching. It does that by slicing the C stack into small pieces and really brute force context switching. So it is quite perfect because the greenlet has been unmaintained for many years and it is always working because it does not know anything about the things it is switching. So it is very stable and very major but it has the drawback that it is slower than Stackless Python and it has some things that it cannot do. So the technology of the greenlet is quite close to Stackless 2.0 where we only had this hard switching grabbing pieces of the stack and moving them around. The soft switching does that in a cooperative manner so the stack is actively unwound and the context switching is built into the interpreter and that is much more work because it is harder to maintain. It is also much more efficient and has some other advantages. We come to that later. So we might talk about the hard switching but I think maybe not now. Hard switching and soft switching is some real difference between Stackless and greenlets. But the real thing actually is with Stackless Python we can pick a program state. So we don't have only the ability to switch around like greenlets can do but we can pick the program state. We can run a program to a certain point then take a snapshot of the program and take that snapshot on another machine or tomorrow or whenever in the cloud and continue the program from where it was picked. So I have a little demonstration that takes a little bit of time. I will show you how to do that. You have a recursive function that calls itself until certain level and then winds back. If you run that then you see the function prints one to nine then some word and then it goes back, comes out of its recursion. And the interesting thing is when we restart that program later on then we can see it continues exactly at the point where the program state was saved and continues to run that part of the execution. Okay. You see the line here. We picked it up or set it to demo. We could have done. If we have an argument with the main function we will load it. That's our, we can ask it. I think we should show it. Yeah, okay. What should I do? Okay. This is, we have that as a running demo as well. I think we should show it right now or later. Now. Okay. So I have, well, do I need to make this bigger? Is it visible? Yeah, it's just perfect. Just fine. Okay. I run the program. This is the recursive run. And it's a little bit enhanced. The example I worked on that yesterday. The recursive function goes to a certain point, comes back and then it says, well, I was recorded on Darwin. So it was recorded on this platform. I can now run it. It has written its output as a pickle into a tasklet.pickle and I can run the program again and give it the pickle as an argument. And you can see here at the point where at the high, that was the program state was written to the pickle. And here where we restarted the pickle, it was, it came out of the recursion. So the stack with all the recursive calls was pickled and was now revived and continued to run. And we can do even more because, so I will now, it's dangerous because I'm now starting Windows. And I have prepared a Windows share. Let me see if it works. Okay. Yeah. We are now in the same, on the same virtual drive in the virtual parallel windows machine. And we have the same program here. And I can run that. Okay. So I started the same program on Windows. It returned from the curtain and tells us I was recorded on Darwin but continued on Win32. And it's actually really the same tasklet pickle we recorded. You look at the timestamp just four minutes from now. And actually we are using this technique in production at large, at important German auto manufacturer automakers to control high-performance computing jobs where you start on the desktop of an engineer running Windows and then move a program to an HPC cluster running Linux. So that's working well. Okay. So we'll do the same thing the other way around and then close the Windows shell because, okay. So I did the same thing here. Now I'm stopping the parallel desktop. And run the same thing on the other side and let's see what it tells us now. Yeah. I was recorded on Win32 but continued on Darwin. So just so everybody believes that we moved a running program from Mac OS X 64 bit to Windows 32 bit and it still works. Okay. Well, that's just a summary of what you already told us. Green light versus Douglas. Okay. Now she skips this slide. Yeah. I think I said it all, right? Okay. So the reason why Douglas really makes a difference is, oh, it's still a bug. We have the persistence. We can use persistence, cloud computing, move running programs around, use a different computer, use a different operating system, do it in a cloud. The cloud is the only thing that I didn't show right now. We can save snapshots. You can also use multiple snapshots and whatever you want. So actually you can do with Douglas everything you can do with regular Python. It's fully compatible to regular C Python and it's much, it's even much more fully compatible now as it was before. Yes, indeed. We fixed some corner cases where extension modules that didn't adhere to the coding standards for Python extension modules didn't work with the Douglas. Unfortunately, there are quite a few and important extension modules of this kind. For instance, PySide. PySide is a very important thing. I'm working with PySide since 2011 and I could not use Douglas Python. It was crazy. In spring this year, this problem has been solved. Now it runs really well with, yeah, right. Actually, I have another thing to show. What you see here is a little puzzle game and this puzzle game is written in a demo from PySide and this runs on top of Douglas Python. So the old problem has been solved. We can, well, and so on. Another little demo is, for instance, a wall. Okay. So we have a little painter demo, painter demo, some different colors which are painted with different styles and certain rotations. So all great things. It's actually stuff for an extra PyQT or PySide talk. I was just so happy that this now really works with Douglas so I had to show that. Last thing, a nice embedded dialogues. Here we go. This is a projection of dialogue into an open GL perspective and so it's very sophisticated use stuff here and you can have that all in Douglas Python now. So yes. I think that was about what I wanted to show and say. And I might pass over to you now. Okay. So there's also a few things that Douglas can use for, Christian doesn't mention yet. So you can use the build as a primitive function that Douglas provides, especially the task is in the channels to build control structures for higher level scheduling paradigm. So we can implement, for instance, C sharp style, async programming or we can implement a go less. Christian could tell something about it. I'm not so into this business. I'm more into the pickling and migration of programs. So now we have seen what's Douglas is and we have to talk about the Douglas project too. The Douglas project, well, who is it? That's all. So we are some, of course, the maintainers and but also all Douglas users. So who is using Staglass? And while there are a few well-known users as a Nagare, I hope I pronounced it correct, web framework is based on Staglass, then CCP Games, the company behind the Eve online multi-user online game, you probably know it, yes, some spacecraft is flying around and so very cool graphics. I can show it here. I have it on the machine. But well, actually, they use Staglass since many years and have bought a large part of their infrastructure on Staglass. Then there are few less known users, customers of the company I work for, science and computing, using Staglass pysons on a few thousand systems. These systems all together have over 100,000 cores. So that's quite a bit. And well, since there are also unknown users, so I recently looked at the access log files of VVV.Staglass.com and I was very surprised to find that we have about 220 downloads of the Windows installer each day and 85 downloads of the source archive. So I don't know who is downloading it, but obviously someone does it. And we also see that 98% of the Windows installer downloads are for Python 2.7 and for the source archives are 96% for Python 2. So it looks like the production usage of the pysons 3 is quite low. So Kerstin already talked about the history and Staglass was formerly known as Staglass Python. I will probably say something about it. And it's invented by Christian and I think the first version was 1.5, is that correct? Yes, the first was Python 1.5 and it was continuation based and much more complicated. So the history is the same Christian knows best, but this talk is not about ancient times and the history of Staglass Python, but about the recent changes. Some more information about the Staglass project who is working on it. We have just a few volunteers, Christian and some Christian, Richard, what's the pronunciation of Richard? It's a Q, yes. That's correct. And myself and all in all we have, it's less than one full time equivalent. So we can't do very much. We have a few resources. That's a Staglass website, Staglass.com. So you can get Staglass Python and that's a primary address for this project. Then we have the documentation. It's now hosted on Reeds and Docs. And that's very fortunate because we can host documentation for every version of Staglass. So that's a really good thing. And since a short time we have moved the development environment to Bitbucket and we have the project Staglass Dev Staglass and also I have a project for Staglass as an installer that can be used with the installer pip. And I have to say we have really, really happy that there's a wonderful infrastructure provided by Bitbucket and Reeds and Docs without this infrastructure. It wouldn't be possible to maintain such a infrastructure. So how can you use Staglass? Well, you have to install it obviously. There are a few options. The simplest and most common way is probably to get the installer from Staglass.com and the installer is available for Windows and for Macintosh OS X. So just download it and install it to the MSI installer. I don't know the format of Macintosh. Yes, and that's something really great because the installer for OS X I used that the first time now. It just replaced my standard CPython from Python.org. It continued to run with all installed extensions because it simply swapped out the interpreter. So I was very pleased with that. It's a great experience now to have installers. I never used installers, but now I'm very keen on that. Sorry. Yes, that's fine. And then we have for the Linux people and also for Windows, if you have Windows and using Virtual End for instance, and quite great to install Staglass. We made an installer, an umbrella installer that's a Staglass Python here. And if you install this umbrella installer with PIP or easy install, it detects your system and then in a second stage downloads a pre-compiled package that only almost only contains the Python library and executable and three or four library modules and installs them in a way that doesn't hurt your existing Python installation. You get a new command SL Python, Staglass Python. And it's working because Staglass is almost CPython, so we have no problem to implant this new command into an existing installation. Of course, in Linux, if you do this for the system Python, you need appropriate access, probably you have to be good. And finally, you can get the source code and compile it just as you can do it for the regular CPython. And if you need something like a debug build or special installation option, then that's the way to go. So if something doesn't work, that's all fine theory, but the practice is sometimes different. But first, Staglass is major, yes. Because the biggest part is just CPython and 2.7 is really solid and it has many users, so usually things work. Staglass 3.3 is also good. That's currently the only maintained version of Python 3. We don't maintain a 3.2 or we don't release a 3.2 anymore because we are at that right now we have Staglass 2.7.8, which is very complete and working. We failed to finish the Python Staglass 3.4 version and we want to do that on the sprint in the next few days. Maybe it works. So it's actually my intent is to support Python 3 as much as possible, but it's quite some hacking and fixing. Yeah, so there are a few bugs in the area of pickling because that's where we have Staglass specific extensions and also Python 3.4 got an extra new version of the pickling protocol. But we invited to participate in this. So if something still doesn't work, we have the mailing list and you can always open an issue on our big bucket site and sometimes you might need commercial support. And well, unfortunately there's a bit of a difficult topic. You can ask Christian, he is probably for help you if you can and you could negotiate an agreement with science and computing, but we are more focused on bigger companies. So the agreement might be too expensive, but we can provide Staglass support around the world 24 hours a day and someone dies a week if it is necessary. I think you had something you wanted to show interactively and we are running out of time. Okay, fine. Yes. Good. I will just go to the reason that one month we switched. I already told it we improved Staglass a bit. Low level tasks with methods are now much more complete. Once the customer introspec scheduling is working more stable, we have a better compatibility with C-Python and the documentation has been updated and we got better debugger support recently. That's very important and a few other bug fixes. We also did something that didn't work out. The documentation, it's now on the read the docs and that's the most important point and it is the regular C-Python documentation and Staglass specific additional chapter. This chapter is now also complete and correct. It wasn't sometimes ago. We also adhere to the Python software foundation, trademark uses policy for the Python and that's the reason we changed the name because as a PSF says you should not use the name Python alone. The source code also contains a well maintained change log file now and our wiki pages still need some love. I probably will go over the technical details very quick. We have a more complete set of low level methods and you can find that in the documentation. It's usually not so interesting but we have an image and it shows you that we have added a state chart of a tasklet. The tasklet is created, it's not alive and then it's alive and scheduled eventually. You see we have added a few red arrows that were available previously so you are no much more flexible. We have an enhanced functionality in the schedulers. It's not long necessary to run the scheduler from the main tasklet. You can run it from every other tasklet or from within the library or something like that. Kristen, well, Johnson implemented it and we were very excited about it but it's fairly new and there are no, I don't know any application of this new functionality yet. And scheduling is no possible using the new method tasklet switch. It simply transfers the control from the caller to the argument of the tasklet switch function and that's independent from the scheduler and it's an atomic operation so you can build your own scheduling based on it. There are known applications, for instance we have in the Stectors Lib that's a library collection of functions you could use for your programs with Stectors. It's not really necessary to use them but there's a module called Async and it's a C-sharp style Async-Kiromus programming and it also provides some futures, Python futures based on tasklets. Can you quickly show your interactive sessions? Yes, yes, yes. So let's move on. Multinterstretch scheduling is probably not so interesting. Subclassing also. We have bug fixes already. Christian showed you the pie side working. We have better debugger support now because we added some hooks for debuggers and we got two new EDAs working. The ringware debugger supports Stectors since ever but now PyDev and also PyCharm is supported. So I will show the PyDev debugger and we have a very, very simple program. It's a demonstration program from the Stectors source and it shows you how to implement a Mutex using channels and tasklets. That's really not important. If you run this program, simply run it. Yes, it has some output. Yes, we have here the three named tasklets and say the tasklet function is this function F and it acquires a lot as a Mutex and then it schedules, it passes the control back to the scheduler and then it releases the Mutex again. If you want to do the expected output, yes, run interleaved into each other. So let's debug it. I already set a break point here and we debug it as a Python run. PyDev switches to the Python debug perspective and we are here so we step over the equation of the tasklets. The debugger is false. So now let's step into and here you see actually the sweats or frame stacks that are known to the debugger. Now I switch here and we see how we got, still the main thread is now F but we got a post main tasklet of main thread. If you look here, yes, that's the run. That was the main task. Now it's a different tasklet running. So let's stop this one. We will get the log that's not surprising because we are the first tasklet. So hey, we are back here. But now if you look, oh, there's another tasklet. So we have no three and you see that's a scheduled tasklet Tix. It was a tasklet we have seen previously and it's sitting here in the schedule and writing to be reactivated. And again, but now if we look, go into log here with, we will see here it blocks, yes, now we have the third tasklet. So you see the debugger perfectly supports the switching between the tasklets and the switching between the context of the execution. And that's important without the support you wouldn't be able to debug this reasonably. So I just continue it and done with it now. And I think we have very few things still to say. Future goals. In the immediate future, we would like to find additional volunteers to help on this. Then stack us 3.4.1. And we also would like to install the pip installer to cover more versions, especially pass and 3. And later, yes, we will probably still need additional volunteers. And I also would like to update the stackless implementation such as contained in PyPy. That's also something we could try on a sprint to work on. Yes. That's a few changes and it's quite a mix of stackless programming with the PyPy guys, maybe interesting. And well, there are some things we also have done that was I think that didn't work out. We had problems with the Visual Studio installer compiler with the old Visual Studio 2008. And then we made a patch to build Python 2.7 with the Visual Studio 2010. And if you don't change the name of the Python DLLs, then you can get serious problems. Because if the DLL was compiled with a different compiler, it uses different runtime library and this can cause all sorts of problems. In the end, we currently can't publish it because we have no resources. So it's a possible violation of the trademark Python. So it's still in our repository, but it's... Well, that's the question. Do we want to support non-existent Python 2.8 in the form of a stackless 2.8 which grabs all the things that are missing from Cpython? Or do we not want to do that? And I know there are a couple of people who think it's a great idea and other people are there who think it's a very bad idea. So we are really undecided and wanted to leave that to hear your opinions about. Should we do something about that? Yes, okay. So surely we can't do it without participation, yes, and probably it would also need some founding us. So that's all and any questions so far?
Christian Tismer/Anselm Kruis - Stackless: Recent advancements and future goals Stackless (formerly known as Stackless-Python) is an enhanced variant of the Python-language. Stackless is best known for its lightweight microthreads. But that's not all. In this talk Stackless core developers demonstrate recent advancements regarding multi-threading, custom-scheduling, debugging with Stackless and explain future plans for Stackless. ----- Stackless: Recent advancements and future goals ------------------------------------------------------- Since Python release 1.5 Stackless Python is an enhanced variant of C-Python. Stackless is best known for its addition of lightweight microthreads (tasklets) and channels. Less known are the recent enhancements that became available with Stackless 2.7.6. In this talk core Stackless developers demonstrate * The improved multi-threading support * How to build custom scheduling primitives based on atomic tasklet operations * The much improved debugger support * ... Stackless recently switched the new master repository from hg.python.org/stackless to bitbucket to allow for a more open development process. We'll summarise our experience and discuss our plans for the future development of Stackless. The talk will be help by Anselm Kruis and Christian Tismer.
10.5446/19954 (DOI)
I want to introduce Chris Klaus who will be talking about, as you can read, Pythonista, all future Python environment for iOS devices. Take it away. Hi, folks. My name is Chris Klaus. I'm relatively new to Python. I started computing on a 64 kilobit Commodore machine way back in the day. I've done basic cobalt, RPG languages you don't even know about anymore. I've also done a lot of Java. I worked for Sun, so working on Java. I worked for seven years for Apple doing development there. Now I work for IBM. What I do for IBM is I do smarter city software. I have a group of architects who help customers do smarter city software. At the end of the day or on a long flight, it's really fun to just break out the iPad and hack on Python. That's what I'm going to try and show you. A little bit about a hobby that I have on off hours, hacking around with Python on iOS devices. Pythonista is written here in Berlin by a gentleman named Oli Zorn. I've never met Oli. I hope to meet him later today for the first time. He writes two products. He writes two iOS apps. The first one is called Pythonista and that's what today's focus is on. The second one also uses Python, but it's much more for workflows. It's called editorial. By workflows, I mean I'm a blogger. I go to various conferences and I write blogs. I want to upload my blog. I might want to do some editing of it. I might want to do all sorts of interactions on the text, convert it to PDF, convert it to HTML, convert it to whatever format and editorial is really slick for that. I personally gravitate towards Pythonista because it's really about writing Python and living in Python, but lots of editorial-type folks, people who deal a lot with text, documents, love editorial and love its workflow. I'll focus mostly on Pythonista today. I'll try to show you a little bit of editorial if we have time later. Just a little bit about what we're going to talk about. What I wanted to do was focus in on this particular issue here. Apple puts a lot of constraints on developers who want to develop applications which are coding platforms for iOS devices. Their principal worry is that you can download scripts that can change the machine. There's a lot of constraints around being able to download code into an environment like Pythonista and upload code. There have been times in the past when Pythonista has been booted out of the app store by Apple because it crossed the lines. We play a very delicate game as a community trying to make sure that what we do with Pythonista doesn't go beyond Apple's guidelines or they actually take the app out of the app store. We have a really strong community with a community forum and I'll show you a little bit of that. The Internet here is lousy so I'm not going to show you it live, but I'll show you a little bit of the UI. There's also specific modules that have been put into Pythonista for dealing with iOS things like graphics and sound and things like that, but also for dealing with third-party things like Dropbox. I'll talk to you a little bit about that. I'm really going to focus most of it on showing you actual apps running. Okay. That's the main webpage for Pythonista. Again, you get the idea. It's a Python environment. It's Python 2.7.6 running on iOS devices. Yes, you can run this on your iPhone. Yes, you can run this on your iPod. Yeah, it's a full environment. It's got a great code editor to it that lets you edit code on the device, but also if you have a Bluetooth keyboard, lots of the people in the community use a separate Bluetooth keyboard and that's the way they enter their text. It's got modules for graphics in touch that I'll show you. It's got just recently added NumPy and Mathplot live so I'll try and show you those. It's now got a GUI toolkit so you can build an application with a graphic designer that looks and feels like a real iOS app like to an iOS user. You can actually put that into the Apple code tool and then you can upload it to the Apple app library. You can make a full feature running app that looks like an iOS app on your iPad and you can put it in the Apple app store. Okay, so the docs are all online. They're also all in the iPad. So that's a beautiful thing. If you're on a plane and you forget about some standard library function call or you forget about some module that Oli has provided in the tool, it's always online. So I'll show you that. It's a full feature 2.7.6. There's very few things that are a little bit special about it but it's really a full feature on 2.7.6. It also includes these special modules that are specific to dealing with the iOS, things like knowing your location, doing reverse geocoding which is really beautiful. So take the location of this device and turn it into an address. So I know the street address of the device at any moment. 2D graphics in a thing called scene, sounds, speech and then this new UI component that lets me create real UI on the iPad that looks and feels like any other iPad app. Then there's tools like clipboard and editor that lets me get at the clipboard of the iOS device and at the editor of the text that I'm dealing with so I can actually manipulate the text of the editor inside. Keychain for passwords and things like that. Next up there's some extra modules that are just great things to have like beautiful soup and requests and these are just modules that lots of users want and so Oli includes them. The difficult thing about this platform is it's not really ready for downloading modules like you might be used to on your Mac or your Windows box, right? So you can't just go out to PyPy and download modules into your device. The community has done a pretty good job of letting you download modules that are pure Python but if modules include C, you really got to work hard to get them into this environment. So again, he includes lots of good libraries right out of the box which are quite useful in particular the Dropbox functionality is really a lifesaver in some instances. Okay. And then last but not least, there's a rarely active community. So this is a snapshot of the community this morning. Somebody's just uploaded a new game that they want to show off to people and get them to collaborate. The second one down here, he's tried to rotate text and he's having trouble and he's asking questions of the community. So a really active community, one around Python, one around Python Easter, one around editorial that are really, really useful. And then last but not least, the community has relatively recently created a Python Easter tools on GitHub. This is really a collection of code that's been specifically built on top of Python Easter. And so it lets the community point to tools and get collaboration around those tools. So through GitHub, we have multiple people editing up tools, games, whatever they might be on the platform. There's other pythons on the iOS and so I thought it would be useful to just talk about those. I think by and large, these are things that are useful to steer clear of with maybe one or two exceptions. So editorial, as I've mentioned, is the sister product and I'd really encourage you to look at it in addition to Python Easter. This new one is called computable and it's just come out. It is an iPython implementation that has MetPly lab and NumPy and all that good stuff. This one is looking good but it's 1.01, right? I mean, it's brand new to the market. So it comes out of Austria and the creator has been a contributor to the Python Easter community and now has come up with this new thing. So it will be interesting to see the dynamic between computable and Python Easter. I think those are really the two to look at in this space. The other ones come from various places around the world, the ones that I really encourage you to steer clear of are these two. They look interesting but they're very long in the tooth and they haven't been supported in many years. So really there's other ones out there but these are the ones I recommend. All right. And so last but not least, this is sort of what it looks like. I have a list of files on the left. I have the file I'm currently working on on the right and that's my last slide. So from now on, we're just going to live inside Python Easter. Okay. So this simple file just uses the speech library. And so what I thought I'd show you is that there's a thing called speech. Are you talking to me? Are you talking to me? Are you talking to me? And if you know taxi driver, it might make sense. So that's just a simple module that Oli's built into the tool that lets me take arbitrary text and pump it through a speech, a text-to-speech engine. It can take multiple languages and is very flexible but sometimes just useful and fun. Okay. So first and foremost, let's start with console. So it's got a standard console like you might be used to. And so if we go over to the console, I can type stuff here. Okay. Standard console that you're all used to. But I can also do graphics to the console. So let me take a simple mathematical formula that draws a star and let me draw out of the console. So I can draw either graphics or pump text into the console. And again, it's the standard Python console that you're used to. So let me clear that. Okay. Next up, there is a module that lets me do a bit more sophisticated graphics. It came after the console graphics. And it's called scene. And so scene is basically I get to use the iOS visual display and do various things with it. So I'll show you a few of these. So when I create a scene, I can either create it in landscape or portrait, right, because the device can turn. And if I do it right, I can create it such that a game or anything else could respond to turns, right, so that my game could play the way. So first thing I'm going to show you a game called Cloud Jump that was initially put up on the forum and people said, you know, the author said hack at it, tell me what you think. So the problem for us is, well, for me is that it's sideways. I'm tilted, right? So I'm going to play if I can. Okay. So now it is tilted. But I'm going to play Cloud Jump. She wants to stay connected. You guys got that? It's one of those. You know, on the iOS devices, you always pick something that's geographically close to each other. They're not exactly secure passwords. There's only, okay. So Cloud Jump lets me bounce off of clouds. And if it's playing for you, you can see that it lets me. No high score, no sounds, no nothing. Okay. So great, great, nice tool that a guy actually built with this young child together. They built this as a programming exercise. And he's actually built three or four of these games, Jumpy Octopus. And there's a Times Table torture that, so he's created these games with his kids. So he put it up on the community and let the community have at it. What the community did was add high scores, add sounds, add the ability to play in either direction, et cetera, et cetera. So if I got a high score, I got to give it my name. And it's a different game. It's got monsters. It's got a different character. I can pick my character, et cetera. And so now it's got sounds. And if I die, it's got explosions, all those sorts of fun things. So again, through the joys of GitHub and Open Community, people can take something that started as simple, make it better and better together. So a lot of what I do use it for is things related to my work. So again, my work is about smarter cities. And I work with cities all around the globe trying to help them figure out how to use data about their city to deal with problems like water and transportation and public safety and things like that. A huge trend in cities is Open Data, where cities are taking their data and they're publishing it to developers and letting the developers to run wild to build apps. And so a lot of what my work has been about is about showing people the art of the possible. So here what I've done is I've taken four data sets and I've had specific formats for them. And I let people go out and create extracts of those data sets that are then stored locally. So again, I'm going to go out to a city's Open Data. I'm going to grab a couple data sets that I want to deal with. I'm going to get on an airplane and I'm going to whack at it with NumPy and Matplotlib. So this is a way for me to deal with the disconnectedness of I want Open Data and I got the tools but I'm on an airplane and the airplane doesn't have Wi-Fi. So a simple app that I'd run for you if we actually had good internet here, but we don't, to grab data sets and put them into a format that can be used for Matplotlib. The other thing that I do around Smarter Cities is we actually sell a tool and that tool helps people run traffic or water, public safety or complex stuff. That tool has a REST API. And so what I can do is build into my iPad the ability to talk to some huge system out in the cloud and use that REST API. So here I have a really nice graphics rich platform that I can create a really slick dashboard for the mayor or for the guy who runs the transportation office and I have a pretty simple straightforward way to go to a REST API and pull out all sorts of real-time data about traffic as it's going to be an hour in the future or where the leaks in my water system, et cetera. So again, I'd show you those but the internet here is lousy. Let me talk to you one last thing about scene and that is color. So this is called tilting color and basically the idea is that I'm looking at the pitch, yaw and roll of the iPad. So I have a sensor in the iPad that tells me the pitch, yaw and roll and I can change the color. This was just to prove that we could build demos and games around pitch, yaw and roll but it's a simple demonstration of what I can do with the scene. So a very short piece of code just grabs the pitch, yaw and roll and lets me play with it and show it off on the scene. Okay, one of the people in the community built a game of life. I'm going to run this so I want to make sure it's going to be okay. And then I think I double tap. Give me one second. Okay, your standard game of life. And again, these things go up and then they get improved by the community. The context module lets me go into the address book of the iOS device so I can go grab all my contacts and do various manipulations of them. This code just goes out and grabs my contacts and uses the geo coding to give me their lat-long of where they live. So I take the address out of the address book and I use the geo coding to turn that into a lat-long. So again, really short piece of code does some interesting things and can be grown on. Recent tweets goes out to Twitter and basically for a user tells me what are their recent tweets. So I can do these sorts of things that you guys can write down. That's my key here if you want. I can go out and go to Twitter or do lots of screen scraping sorts of things with requests and beautiful soup and all those basic tools. Let's talk a little bit about UI. So this is the UI tool that comes with the package. It lets me create all the things that you see here. So I can create labels and buttons and sliders and switches and calendar pickers and all the rest of the usual stuff that people expect out of iOS apps. And basically what it will do is it will create a file that's called pyname.pyui. And so that pyui file really defines a user interface. And I can basically just load in that file at start-up time and I have a UI that's ready cooked, ready to build with. Or if I want, I can build the UI piece by piece by piece in Python. You have your choice. Some people seem to like the design tool and laying out their UI and really making it nice and then just sucking it all in as one piece. Other people like to build it up piece by piece by piece in Python. So let me just show you a little bit of what that looks like in actual reality. So here you can see I can add new objects. And so I can say that I want to create an object. I want to create sub-use of that object, et cetera, et cetera. So just a really slick, slick little addition to the tool. Whether where you are, again, was a simple tool that uses the geolocation of the current object and then uses an open data weather service called Weather Underground, I believe. Just trying to see. No, it's called openweathermap.org. So again, this tool just gets the geolocation of the device, turns that into a city, state, country, and then goes out to the openweathermaps.org and gets the current weather. So it tells me temperature, pressure, humidity, sunrise, sunset, et cetera. So again, simple tools that get created quite rapidly that use the sensors in the device, either the location sensor, the pitch yaw roll sensor, and the touch sensors, the various sensors inside the device. And of course, there's the Zen of Python, right? So this is another thing that just writes to the console. And as it's writing to the console, the import this text, it is doing so on changing the color slightly. All right. Just trying to see if I covered what I wanted to cover. Oh, MatplotLib and NumPy. So here is a plot out of MatplotLib. So if you're used to using these tools and know how to make them go, they're all here, fully functional and quite useful and powerful. I think it's created a lot of excitement in the community. Having tracked Python for iOS for a long time, it was like really a commonly requested thing to get it here. And it's just come to market in the last four months. So it's all in there and people are really starting to go crazy with it. It doesn't have the Python-East environment, doesn't have a search tool to search all the files. So I can do that. So I've created my own. And basically what it does is it goes, grabs all the files and looks for, it's like a grep. It brings up something that's useful. So I can either tap this arrow at the upper right corner of the screen to run or I can tap and hold. And if I tap and hold, it will let me give command line parameters. So you got to, usually when you're typing at the command line, you'd like to give your Python app script other command line parameters so you can run with arguments. And so this tool will do that and bring the text up in the editor with the text highlighted. I think I've showed you what I wanted to show you. I'm open to questions. Go for it. What are the tools? Let me see. Okay. Nope. Nope. Go ahead. Yeah, there's a whole sound library. So let me go there. So this is good because it lets me show you what it looks like to be a developer on the environment. So here's a module called sound. It's got samples. And whenever there's samples, I can actually open those samples in the text editor right away and just run them. Okay. So that plays a short melody. And let me go back. So load effect, play and effect, stop and effect, and set volume. There was also some undocumented features inside the sound library that parties are using. So that's another thing that goes on in the community is people sort of go through the code and find undocumented features that are useful. But a pretty straightforward, simple sound library. So the sound library I presume only works on iOS. Is there anybody who has written something that's kind of a layer above that that has the iOS driver? Maybe then we can try to make it portable. Does that seem like a bit of a limitation? So not particularly for sound, but for other things, I have seen the community build up sort of a wrapper around various libraries, but not for sound that I've seen. There was a question in the back. I actually moved to questions. I'm sorry. No, I'll repeat the questions. I'm sorry. Yeah. So how does it work? Does it only work on the iPad? I can use it for example under the iPad. Okay. So first and foremost, one thing I didn't show you is that I can put certain scripts into a actions menu. These are things that I do often. One of those is Dropbox Sync. And I'm just going to try Dropbox Sync. It probably won't work, but maybe the internet is big enough. So Dropbox Sync lets me push my scripts into Dropbox. I can then get on my Windows box or thankfully my Mac and use those scripts. So moving things onto and off of your device can be done through this community built tool that is built on top of the Dropbox module. The nice thing about that is I can then Dropbox Sync on my iOS device on my phone and I have code base synced between my two iOS devices. Now your question was different than that. Your question was how do I take the app that I built here on my iPad and how do I get it into the Apple App Store? So basically you, what's the code tool that Apple uses? I can't remember what it's called. Xcode. There we go. Basically you take your Python files and you put them into Xcode. And then there's one script, one Python script that you need to run on your Mac to create resources into that project. And then you build that project and it builds down to an iOS executable. And that iOS executable is something that you can put up on the App Store. So again, take the code from here and sync it to your Mac, probably using Dropbox Sync, but there's lots of ways. Second, run the script on your Mac which creates extra resources inside your Xcode project, compile your Xcode project, and you have an iOS app that's ready to go into the iOS App Store. I don't know the answer whether you can run it in the iOS emulator on the Mac. I'm just not familiar enough with that piece of the puzzle to say. My suspicion is that it does not, but I would need to check that. Yeah, so that's an awesome point. It's really, really hard to develop on an iOS device on a touch screen. But we've seen people build really complex games on an iPhone. They sit on a bus every day on their ride home from work, and over 10 days they built a really complex app on their iPhone. So it's a really small screen with really teeny editor and all the line-wrapping problems they have. But I got to tell you that the majority of the serious people who really do work on Pythonista use an external keyboard. It's like essential. I actually don't. I don't use an external keyboard, but most people do. So, yeah, I think you're right that it's hard to develop on the iOS device alone and not be able to emulate on the Mac. And again, I just don't know the answer whether that's doable or not doable. I just don't know. Can you access Excel files? Yeah, yeah, all that stuff. So the question was can you access Excel files and JSON and all that stuff? Yeah. The standard JSON libraries in there, you know, reading through files is really easy. And actually, you know, if you really love file manipulation, definitely check out Editorial 2 because Editorial has workflow to it that Pythonista doesn't for making that easier. There's also lots of conversion capabilities like I want to convert this whole thing to a PDF or I want to convert this whole thing back into Excel. So there's lots of good code snippets and work done by the community to do that. So let me show you two more things. So this is Compute Table. This is not created by Oli. It's sort of a computing product. It is an IPython implementation for the iPad. And so basically, you know, the full IPython story, but, you know, reformatted to work here. And I'm just going to open up a book, whatever they call those. And here you can see all the usual things you'd expect from an IPython world. He's giving you some samples where, you know, he shows you how he computed the logo of the app itself. And so, again, there's that tool which, if you're into IPython and that sort of style, I would definitely recommend. And then last but not least, let me show you Editorial, which might be here. And Editorial is created by Oli. So it's the sister product to Pythonista. And you'll see it looks a bit different. Let me just see if I can find one of these. You can see that it's got more of the IPython look and feel where I can create a user interface that feels like a web page, but it's got more tasks and is more task oriented. And again, based on sort of let's deal with markdown first and foremost, but let's deal with lots of other file formats in addition. Other comments, questions and issues? I'm a big champion of that. I'm a big believer in that. So far, the really the only Python 3 that I know of is really in the other packages that I don't really recommend. So I got to say that there isn't a great Python 3 on iOS today. We bug and pester Oli about it, but for him it's a biggie, right? So a lot of people say they want a single app that's got Python 3 and Python 2. But if you think about that, that's really, really hard from a developer's perspective and from a user's perspective. First from the developer's perspective, he's got to have two sets of docs, two sets of standard libraries, two sets of worries, and debugging in an environment that does both is really hard. The other way to go is to create two separate apps where he's got Python 2 and Python 3. And the thing that he says over and over again is it's a disruptive break for the users. It's going to create a whole lot more questions on the forum about this used to work and now it doesn't work and I don't understand the difference between Python 2 and Python 3. There's still a lot of quandary in the community. So right now, you know, computable is Python 2.7.1, Pythonista and Editorial are 2.7.6. We're just not there with a great Python 3 just yet. Go for it. Is there any way to do that? No. So I can use Dropbox Sync in two directions, right? So I can do that trick. I can mail myself things, right? Pick them up and put them in that way. There's lots of ways in and out. There's, you know, lots of different methods to get text in. I can go screen scrape. I can use requests or URL lib to suck in text. There's lots and lots of ways to get things. There's also a great set of tools that I didn't talk about that let me go at GitHub, right? So, you know, Git Check basically lets me check something into GitHub and retrieve things from GitHub. There's another thing for Dropbox that's much more of a user interface where I pick the file that I want and I just suck in that one file. Yeah, there's lots of ways to get things into and out of GitHub and Dropbox and other techniques. Yeah, so this is so the question is about remote requests. This is where we start crossing the lines that get Apple very nervous. So right now Apple doesn't love Python anyway because Python has got some new momentum that scares them a little bit and they're really trying to get people to Swift, right? They're trying to say, okay, we told you the answer was Objective C but we were only kidding. The answer is now Swift and people are scratching their head about do they really want Swift or not. So they're really, really trying to use this idea that mobile code is a dangerous idea, right? And I came from after I worked at Apple, I worked at Sun. So I don't believe that mobile code is a bad idea. I believe that mobile code with the right security and the right sandboxing and the right understanding is sort of vital to what we need to do in a modern computing platform. But I can tell you that when we cross that line of doing things automatically, where we automatically bring executable content into the environment and execute it without the user's authority or oversight or watching, Apple gets really nervous. And when Apple gets nervous, they actually take the app out of the app store, right? So that has happened and has happened again very recently. So it's a line that is difficult to cross. They really don't want mobile code that happens without user authorization and physical clicking. Does that mean that exact and eval that has its disabled? No, exact and eval, that all works. That all works. Go for it. Is there a way to use a version control system in the iOS? It depends on whether you call GitHub a version control system. No. So this is not a replacement for your PC or your Windows box or your Linux box. And some of the complex things that you can do and just love on those devices you don't have here, you could probably put something together, but is it there today? No, it's not. But join the community and help us out. One minute. Last question. Yep. Why上面 when you say that Should be. Yeah. Yes. that has been my African navigation by myself and support. If you want to try, try to do a lot of the forms you've got to take with that. It's quite good. Not that steel is still in development, but it's definitely consistently close up. If you have to take a little bit of it, I think a little bit of it has a few areas that you're going to have to be mindful of. Yeah, definitely been hearing lately about KIVI and people saying it's really cool. You can put stuff together really fast with a pretty interesting platform. So take a look. Thanks a lot for your time. It's been a real pleasure to speak with you. Thank you.
Chris Clauss - Pythonista: A full-featured Python environment for iOS devices The Pythonista app delivers a full-featured Python development experience on an iPad or an iPhone. This introduction to the app will provide a rapid overview of the Pythonista user experience, features and Community Forum. Then it will focus on a few source code examples of using the GPS to deliver real-time local weather, use the image library to manipulate images and convert documents, use the gyroscope to understand pitch, yaw, and roll, use Dropbox to backup and restore scripts, images, etc.
10.5446/19953 (DOI)
Okay, hi. The next talk is going to be held by Chesney Shepler about big data analytics with Python using stratosphere. Please welcome him. So one thing that I have to raise before is, so between handing this into this talk and actually having it, the strategy project has been accepted in the Apache incubator program and had to be renamed due to a naming conflict and it is now known under the name Apache Flink, being a German term for something that is faster agile. So for the remainder of the talk I will refer to it as Flink since the feature that we, or the main thing that we are presenting today will be part of the actual, one of our first Apache releases. So I'm going to first talk a bit about what Flink in general is and then go into detail about, actually using me here, our new Python API that exposes some features of Flink to Python developers. So what is Apache Flink? It is a distributed runtime for big data analytics, written in Java with a big focus on ease of programming by offering a rich set of operators and automatically optimizing your program. The project started in 2009 as a joint research project by several universities here in Berlin and was then later transferred into an open source project. It is now moving to Apache under the name Flink. It is version 0.52, the last release outside of Apache and the next or six releases scheduled between within the next weeks. Flink operates in the same use space as systems like Apache Spark or Hadoop MapReduce. It shares common traits like scalability and user defined functions, but combines these with database technologies like declarativity and optimization. So a lot of decisions how the system works deep down is left to the system. In writing a program for Flink, what you're essentially creating is some kind of data flow. You have data sources and you have operations on them and output them somehow. So in this case we have some data sources, we have map functions to reduce joins. One thing that sets the Flink part is that these steps are not done step by step. So we don't do the whole map operation and then pass the whole data set that is produced into reduced function. We stream them on the go into the next operation so that in some cases your whole program is running at the same time. The Flink stack looks something like this. So at the very ground you have some storage where you have your data. Flink itself does not depend on any distributed file system so you can work on local files exclusively. How they first work is surprisingly well, especially well, but you cannot serve your data in databases for example. For cluster managers you have also Flink works with several, especially once again. Then we have Flink runtime, optimizer and several APIs built on top of them and different languages. So we have Java API with our main baseline, Scala, Spark, API for graph computation, Meteor one for JSON I believe, currently developing an SQL API and the main reason for me being here is our new Python API which is built on top of the Java API. One thing that is actually pointed out is that all APIs both are the same optimizer and same runtime so they are not very deeply connected with the logic. So in summary the key feature of Flink is that you have various developer APIs that are easy to use. So when you write a program you have one of your write a plan inside the API and they usually find functions while some operations are done on the Java side like grouping and sorting. A lot of the computation is actually done in the API's respective language. The optimization takes care of how certain operations are carried out, how is the join carried out. It takes into account where operations are carried out physically so it tries to place subsequent operations onto the same machine so that you don't juggle the data across the whole cluster. The Flink runtime is its very own system, it's not built on other systems and something that I haven't touched on earlier is that we treat iterations at first class citizens and optimize and separate. So much for Flink in general and we are now going to look at the Python API. So this is a word count example so you want to know how often each word appears in a text this is what you would do. So on the left side you have the plan, basically on the right side you have the user defined functions. So let's just go through it step by step. So first call to get an environment something like I'm writing a new program, think of it as a common route for your program, then apply a FlapMint function to any first read data, a text file so every line is treated as separate string and then apply a FlapMint function to it. We are passing an object of our user defined function and the output type. So the output type we are not very Python like to have to pass it. This is a side effect using the Java API underneath, Java is a very strict type system so if you would like to look at the same program in Java you would see type arguments everywhere. So this is one of the last remnants of that. So the tokenizer does it splits the line to say words and collects them each with an initial count. We then group the data based on the words, partition the resulting data and apply a reduced function to each group separately that sums up the words and then writes the data to the CSV file. The code to execute is as in implies starts the plan. So after you call to read text, data does not contain any data. It is just an abstract representation of the data that really exists once the program is executed. So now where are we interested in Python? Python is already heavily used in data analytics jobs so it just seems like we are fit to provide flinks capabilities to Python developers. It also allows Java developers to access Python's extensive standard and machine learning libraries. So in the grand scheme of things this is how the whole process will look like. So you write your code in Python. When it is executed it creates intermediate representation of your program. It is then funded through a Java API to create an actual flink plan which is then shipped across the class and executed. So the Python functionality, so our user defined functions are stored as serialized data inside the execution graph. So that on the runtime the data flow is something like this. So flink runtime that encompasses everything. You have a Java operator since the plan is in Java internally. You need some encapsulating object for the whole Python operation which when it is... So when the operator is started or opened or created it starts the Python process. These serializes the object we passed in the plan. So tokenize the object in our case for example and then pipes the data through the user defined function. So when dealing with process of different languages it changes the type system and becomes a natural issue. So what we do currently is we have a failure inventory system currently. We just... What we do is we map basic types to each other. As well as tablets and lists are converted to flink tablets. Flink tablets are a fixed length type safe container which is somewhat similar to Python tablets or similar enough that you can use them. So I said really mentally so you can't... These tablets cannot be nested currently. They can't be longer than 20 elements. Just time constraints while we haven't gone to that currently. A more severe problem is of course that we don't use arbitrary objects which is due to the fact that we want to do it properly. So we could use the pickle module to just pickle the data. If it's not one of these basic types then unpickle them when I come back. But there are several use cases where this is not enough. So for example if you want to sort on this data or group on them you end up... It won't work since the sort operations are executed on the Java side. So in order to avoid really ugly programming patterns we decided to leave it out for a while and spend a bit more time on these things. So when we say we support arbitrary objects with our Python API then we actually do. Some of these related to protocols how we exchange time between these processes. So protocol. Initially we use the protocol for those for this. But they were in the end way too slow for us. So we switch to the struct package on the Python side and the Python side and the Java side which works surprisingly well together. So basically right off the box. Since we only changed the protocol around three weeks ago it's pretty much designed currently for the flint type and around the current restrictions for the type system. So a few details will most likely change in the future. But the gist of it is that we serialize the fields and apply few extra data. Independent of the extra data. So for every field that's serialized we apply a type by to it. This can actually be removed for normal data flow since the output is also the same. But for now it's still in there. And then we have this meta byte which is one end useful. Several control forms like I'm the last element and this iterator or I'm the last element that's collected. Things like subject computation. And then we have the size argument which represents a number of elements in your given topic. I'm way too fast. So the Python API is currently provides a subset of the features of the Java API. So you can read data from text files or provide distinct objects within your plan. You can write as text or CSV files and print and standard out. Operation wise we actually support most of them. Most important missing one iterations. Couldn't get on time. For the most part is for something that is the Python API is currently in the stable you can try it out. It's not production ready. So for these testing it is certainly usable. So one thing we're thinking about is for example for the future is an end scala in the Java API you have the option of define or no. I'm going to start differently. The input and output of data is currently completely ended on the Java side by something that is similar to the performance. They define how certain data is read and how they are given to flink. We want to provide the same functionality in the Python API so we can read. So the whole Python is completely ended in Python. Data input to transformations to data. So in order to use the API you tried it on Linux. We want to be more precise on Python 2.7. We know there are two minor issues that prevented to run on Python 3. Just do some type stuff like no long base training. It should generally work on Python 3. So in order to run locally, so you can run it locally just in your PC to try it out. All you have to do is basically download flink, start it and you can already run it. So depending on how fast you download and can move through a terminal you can get it running in a minute basically. For the cluster you need a bit more work so you have to set up flink and configure it and all that sort. As of right now you need an HFS that is used to distribute the files among the clusters. So the flink package as well as the files you provide the distributed automatically among the cluster. So you don't have to do it in the menu. This also means that if you make a change on the main node this change automatically propagated among the cluster which is surprisingly convenient. So I hope I was way too fast. I hope that it could pique your interest a bit in flink. So if you have more, if you want more information you can go on the website flink.incubator.apache.org. If you want to try out the Python interface you can go into this prototype setup and also contains a detailed documentation for the Python API. And then thank you for your attention. Would you like to take some questions? We don't have a microphone here so you would have to repeat the questions. Yes. So do Spark and Stubberspare follow the same kind of strategy? If yes they both are the difference. Could you repeat the second part again? Yeah, no, Spark. Stubberspare and the Spark obviously are the same kind of strategy? Yes, they are similar systems. Why would I choose one of the other? So the question is why should one use flink compared to similar systems like Spark? So one thing that we do better is that we provide better interface iterations or generally a more efficient one. So we try to reuse a lot of operations to prevent repetitive computations. One thing that should be said is that Spark is generally more mature currently. It's a tough question to be honest. Yes, please. So the question was if the data is only replicated or partitioned when executing on the cluster. It is, as far as I know, it is partitioned. Sir, your question was if derniers that power grid. So the question was, got it correctly, what happens when we need a piece of, we partition the data and we need to access another partition from another system, what happens then? I'm actually not sure about that. So I've never looked at that code, to be honest. I've only been with a project for around three months, most of the time I've worked on the Python API. So I'm not very much informed about the really internal deep down stuff in the system. My, constitution, everything about simplifying the writing, there are lots of things going
Chesnay Schepler - Big Data Analytics with Python using Stratosphere Stratosphere is a distributed platform for advanced big data analytics. It features a rich set of operators, advanced, iterative data flows, an efficient runtime, and automatic program optimization. We present Stratophere's new Python programming interface. It allows Python developers to easily get their hands on Big Data. ----- [Stratosphere] is implemented in Java. In 2013 we introduced support for writing Stratosphere programs in Scala. Since Scala also runs in the Java JVM the language integration was easy for Scala. In late 2013, we started to develop a generic language binding framework for Stratosphere to support non-JVM languages such as Python, JavaScript, Ruby but also compiled languages such as C++. The language binding framework uses [Google’s Protocol Buffers] for efficient data serialization and transportation between the languages. Since many “Data Scientists” and machine learning experts are using Python on a daily basis, we decided to use Python as the reference implementation for Stratosphere’s language binding feature. Our talk at the EuroPython 2014 will present how Python developers can leverage the Stratosphere Platform to solve their big data problems. We introduce the most important concepts of Stratosphere such as the operators, connectors to data sources, data flows, the compiler, iterative algorithms and more. Stratosphere is a mature, next generation big-data analytics platform developed by a vibrant [open-source community]. The system is available under the Apache 2.0 license. The project started in 2009 as a joint research project of multiple universities in the Berlin area (Technische Universität, Humboldt Universität and Hasso-Plattner Institut). Nowadays it is an award winning system that has gained worldwide attention in both research and industry.
10.5446/19951 (DOI)
In this session, we're going to have Carl telling us about automatic code reviews, which I'm very interested in. Carl is a refugee from Java land and works as a system administrator. So if you could all please make Carl feel very welcome. Hi. So welcome to my talk, which is about automatic code reviews. This is the long title, which they wouldn't let me put on the program. The general gist of this is that there's really, really cool tools out there. And if people are willing to put in a little bit of effort, you can really get a lot of benefit from static analysis and warnings before they become problems in production. So it's traditional to start with a slide about me. I am a system administrator. I come software janitor at ACVO.org, which means I do, apart from panicking about open SSL, I also do things like continuous integration and all the continuous deployment, that kind of stuff. And as a site project, I run landscape.io, which I'll come to in a second. And then email Twitter, GitHub, blah. So landscape is code reviews and automatic static analysis is a service kind of thing. The idea is that if it's really super easy, like you can click with your GitHub account and just log in and then kind of get all that stuff out straight away, then a lot of people will use it. And this has been going, it's sort of officially launched in November. I've been coding it for more than a year. And there's about 1,500 open source code repositories are on there right now and they're being checked all the time. And it's free for open source. It looks kind of like this. Maybe you've seen this sort of health badge in the top corner there on some GitHub repos occasionally. So the majority of this talk is going to be lessons I've learned while building this, specifically how it pertains to static analysis, code reviews, that kind of thing. So first of all, just want to talk about what's the point to code reviews in general, just in case you're sort of not really into it. Code reviews are really cool because you can catch errors before their problems, especially if you have new developers, people who are new to the language, for example, maybe they come from a different background. For example, as I said, I come from a Java background. And so my Python at the beginning was all like sort of classes everywhere, interfaces everywhere until a colleague of mine looked at it and went, bleh. So and as well, like people new to the company who maybe don't understand how you do things in this company. So that's kind of cool. But it's also a really good learning experience. You can see how other people do things. You can kind of see the things that they are interested in doing and the way that they do things and the techniques they've learned that you don't know about or the other way around. You can teach them something that maybe they don't know. And then business logic errors are pretty important. You don't want someone to put a 15% discount where a 5% discount is kind of the right thing. You don't want someone to accidentally financially cripple your company, that kind of stuff. So like the whole idea in general is just to kind of keep an eye on the code base, I think. And that's what automatic code reviews can give you almost all of this stuff. So they won't give you the business logic side of things. All these tools, all these command line tools, as far as they're concerned, they don't care if it's 15 or 5%. But everything else they can pretty much do. And the great thing is that it happens automatically after every code push. If you put it into your continuous integration, you use Travis or Jenkins or whatever, then this happens all the time and after every push you get a little bit of feedback to see what you just did and whether it was better or worse, which is kind of cool. And you can get, you know, Pep 8, compliance, that kind of stuff. And for me, I really learned by doing pylons and running pylons, especially on all of these, all of my code, I really learned a few things. And yeah, so I'm going to come back to this sort of number to track in the end because I'll talk about that later. So hands up, who knows roughly what's going to happen based on this slide? Okay, that's a fair amount. So this is a fairly common Python gotcha. You have a keyword argument with a default value, which is a list or a dictionary. You do something to the argument you get and then you return it. So let's say you call append one with no arguments, it uses this list, it appends one to an empty list, you get a list of one. Right, you do it again, now you've got two things. Okay, that sucks. And this is really annoying to debug. And like I said, this is a fairly common Python gotcha, but 20% of repositories that landscape checks have this error in them somewhere. So out of 1,500, yeah, 20% of those actually have this error. This is a really, you know, this is something you shouldn't do. And yeah, I'm not going to go into why because you can find that on the internet. But pylons, it will find this for you. And interestingly, even pycharm, which I think is a fantastic IDE and has the best static analysis of any IDE I've tried, will not warn you about this. So here's an example of how automatic code reviews can help you find bugs before they become bugs. This is another one. This is something that I really learned. If you call logging.debug with a string and you want to see the values of foo and bar, you will have the string with formatting parameters and you will kind of squash them in there and then you will call logging.debug. Because this is, apparently, turns out this is the wrong way to do it. What will happen here is that you will interpolate the string and then call logging.debug. And if your logging.debug is, you know, if your logging level is info, warning above whatever, then that logging.debug call is basically no. But you've already wasted time doing the string interpolation. And it turns out that you can pass in foo and bar as arguments to logging.debug and it will interpolate the string for you. That's pretty cool. And I certainly didn't know that. And again, 10% of repositories do this, of the 10% that landscape checks. Then of course, the style guides. So maybe you work with a monster who will write code like this. This is horrible. This person probably uses tabs instead of spaces. So it's nice to have this conformity and style. And again, this talk really isn't about why, but if you want that, you can run pep8.py to enforce conformity with the pep8 style guide, style advisory, I guess you could say. So next slide. So up until now, what I've talked about are things that you can find by checking your code for errors. But a project isn't just the code, especially for web applications. Having old versions of requirements, for example, can be a vulnerability. Ask anyone in the Rails community how that can go horribly wrong. Fortunately Django hasn't had so many problems, but there are consistently security additions to libraries and security bug fixes that come out. So a way you can check this is if you have a virtual environment with all of your dependencies installed, if you're on pip list, I think it's version 1.4, I can't remember exactly. It'll tell you what requirements you have that are old. And this is kind of useful. If you want slightly more involved, there's requires.io in gymnasium.com, which will take your code. I think they only work with GitHub. It certainly requires that it will take your code out of GitHub, it will look at your requires.txt or set of the py. And it will tell you which libraries are using that are out of date. And it will tell you, okay, this one's a security problem, this one's a just regular minor update, that kind of stuff. So this is pretty important, especially for web apps. And there are so many tools out there. Like I really don't have time to go into all of them. PyFlakes is kind of the big one that I'm not going to have time to talk about. And chances are if you use sort of Vim or Emacs, you're probably using a plugin that uses Flake 8 under the hood, which uses PyFlakes again. Frosted is a new fork of PyFlakes, which is a little more maintained. McCabe is really cool. It takes your code and it kind of looks for too many branches. Oh, yeah, sorry, I forgot to mention. You see this little tiny link at the bottom that no one can see because it's too small? This is carlcrowder.com.ep14. All of the things I'm talking about right now, there's links to them on this page. So you don't have to worry about finding these afterwards. You can just go to that page and look at all the links and everything. So yeah, there's all these other tools. Jedi is a pretty interesting new thing, which is the guy who does it is doing a talk on Jedi straight after this talk. And I think it's B07. It's one of the B rooms. David Halter is going to be there doing a talk on that. PyROM is pretty fun. It checks your setup to Py to make sure you're doing the... You're a good citizen if you want to have an open source library. So there's so many tools out there. But these tools exist. Why don't people use them? Well, how can you get the most out of it? Obviously, if you have a brand new project, then setting this kind of stuff up at the beginning is really cool. As your project evolves, you can evolve how you're doing all of this checking and that kind of stuff. But most of us don't have the luxury of starting a new project. You have an existing code base, you have a mature code base, and you run PyLint for the first time and you get like a thousand errors and you look at anything, oh my God, I can't deal with this. So the way to get the most out of it is, well, step number one is understanding what these tools give you. It's not a list of errors. It's a list of suggestions. It is like a code review. Sometimes you're going to have errors. You're going to find problems and you're going to say, okay, yeah, that's a good point. Yeah, that's a bug. But sometimes you're going to find things that are more... Is this right? Is there someone looking over your shoulder and going, are you sure? Which is... That's the attitude to have when looking at the output of these tools. Don't be intimidated by a thousand errors. It doesn't mean you have a thousand errors. The second thing is spend time tuning the tools. All of them are configurable and all of them have variable levels of how much do you care about this? Maybe you don't care about a specific error. You can just turn it off. It's worth doing this. It really is. And I'll come back to that in a second. Again, measure and track over time is my next slide. For me, this is the most important slide or most important concept over this whole thing. You really need to be concentrating on how you've improved or made things worse than last time. You can't just look at the absolute value. So if today is better than yesterday, then you've improved and you're doing well and that's all that matters. So in order to do that, you need to measure and track the output of these things. So as an example, some CI servers like Jenkins have a pilot plugin and you get a little kind of graph over time of how many errors the pilot finds. If you have Graphite or influx DB set up, which you may already have, maybe your ops team have this kind of set up and you can beg them to use it or whatever, it's a really great simple way to pass in numbers and then track these numbers over time. And if you have a nice dashboard in front of this, like Tessera or Grafana, you have this beautiful, pretty page that everyone enjoys looking at, which gives you a little graph that goes up or a little graph that goes down. And if it goes down, you can think, okay, maybe we need to spend time refactoring our code, maybe we need to concentrate on this. And if it goes up, yeah, you can feel good about yourself. At the very least, just do something like pipe the outputs into word counts and see how many errors you had this time compared to last time. If all you have is a number that goes up or down, you're still going to be doing pretty well. And then tuning. So again, all these tools have a way to configure things. I think that the majority of people, when they try Pylon for the first time on a mature code base or all these other tools, but especially Pylon because it's the most involved one, it's kind of the most mature one and it finds the most bugs because it actually does a whole bunch more stuff than say PyFlix does. You can sit there and you can tweak it and you can spend a long time doing this. And it's, again, it's really worth it. If you spend four hours digging through the config, digging through all of the manual pages and all that kind of stuff, trying to figure out what's going on and then apply that to your Pylon RC so that the output is actually relevant to your project, you know, maybe it's four hours, maybe it's a day, but it almost certainly will save you four hours or a day in the future because it'll find bugs or it'll make your project more maintainable. And that means that future problems, future features will be much easier to actually do. So it's worth spending the time and, yeah, again, I don't really have time to kind of go into exactly what you can do, but for example, if you Google around, you will find Pylon RC files that people have already created. Typically, so the second one here, I created this a while ago because it annoyed me that Pylon would warn about things in Django that weren't really warnings. So if you have a Django model, you have a dot objects model manager, that happens at runtime, it's part of the meta programming of Django. So it doesn't exist when Pylon looks at it and therefore Pylon will warn. It will say my model dot objects does not exist. And yeah, it does. So you can write your own custom in plugins or you can tune this with Pylon RC. So the benefit of the plugin approach, which takes a little more time and it's a little more involved, but you can control exactly what kind of things you can, Pylon will turn off or turn on, you can kind of say, okay, I'm going to override this specific error in this specific instance rather than having to turn off all examples of this specific error. So if you're interested in writing a plugin, the documentation on Pylon dot org will help you use this as kind of a reference. It's a little hacky, but it's better than nothing. And yeah, again, spending the time upfront is, it'll make things more useful, I believe. So by this point, I hope you're all kind of thinking, wow, this is really super cool. But if you're still not willing to spend a little time, then I suggest you try out Prospector, which is a tool that came out of Landscape. So the original point of Landscape was, like I say, to try and make things super easy for people to get started. But there was a part of that which was bringing together all these tools, configuring them in a kind of best guess kind of way and adapting them slightly if you were running Django and so on. And I pulled that bit out and moved it into a separate open source project called Prospector, which is a command line tool. And it's really a layer on top of Pylons and PyFlix and Pepe and all this kind of stuff. It does its best to kind of guess what you want. So for example, it turns off a bunch of really picky errors by default, which you can turn on, but by default it tries to make it so that the first time you run it on a big code base, you will get something out of it which is actually useful to you. And you're not sort of swamped by little picky errors. You kind of really see the core of the problem. And yeah, it tries to, from your requirements or text, if you're running Django, it'll try and figure that out and try and use the plugin. So hopefully I'm going to create some more plugins for things like Twisted and other frameworks and try and improve this further and further. So if you really, this is sort of to steal a phrase from Python requests, it's static analysis for humans. I'm trying to make it super easy to start with. And if you need the power, you can have it by just doing it yourself under the hood. But going from zero to now I have static analysis, hopefully this tool will help out. So I kind of sped through this a little bit quicker than I expected. So here is my conclusion, which is essentially, I've already said this several times, but spending time on this will really, really benefit you. And it's about developer cost and that kind of thing. If you spend the time doing it up front, it may seem like it's a little bit like you're not working on features, but it will come back to you in the future. You will benefit from this at some point. And yeah, most important thing is keep track of the metrics. Keep track of what's happening from these tools. Keep track of what they're telling you. Because even if you don't agree with them, if they're telling you less than last time, it's probably because you've got less errors. It's probably because you're doing better. So I've kind of sped through this a whole lot quicker than I expected. But anyway, so this is the big list of links. The top one has links to all the stuff that I just talked about. And yeah, that's pretty much it. I just didn't think it was all that great. Just byラ визуаль ALL ludic fairness R else So, I think that's a real problem. I'm not going to be setting you to be any... The second thing is, I want to give you an idea of a suggestion. If you find something out of the pool of the test, this might be a problem or something, and it's not a problem, it's a question of the sport. And a comment that we've got, so that the next journal that you're going to be talking about, knows this is intentional and doesn't have to be proved or if this is intentional or not. Yeah, so I suppose that wasn't a question exactly. So the first part was the default argument might be intentional and how do you deal with intentional things that the tools find that are problems that are actually on purpose. So, yeah, adding a comment for the next developer is kind of useful, but you're still going to get that error out of the tool. And each of them have kind of ways to turn these things on or off. It's a little more involved, and one thing I'd really like to do with landscape and prospector is have a sort of interactive mode that will help you do that, because you have to dig through the configuration and find out, okay, what is the error code and how do you turn this off? I would suggest I could explain the addition to this deactivating the land code. Yeah, of course, yeah. So not just deactivating the error, but also explaining why it was deactivated. So... We talked about the public part, but how does the user observe the name when I check that in landscape, you didn't type the part of those. So, I think the data underneath that... Not exactly. So, the question is, landscape doesn't actually deal with the configuration files, especially for Pylint. And it's kind of on the roadmap. One of the problems with Pylint is that you can sort of load arbitrary plugins, and there's no real way to sort of do that. So I need to spend a little time figuring out which part of the config I can apply. Prospector will do its best to deal with Tox.ini and set up the CFG for, you know, Pep8, PyFlix, that kind of stuff, but you're right. Landscape, I mean, it's still a work in progress, and there's still a lot to be done. So it doesn't do that for now. And it's really for people who don't do any analysis right now, and they want to start rather than for people who already do it and want a way to graph it, but it's coming. Last question. So I think Prospector is really awesome. How, as a relative newbie to the Python world, how discoverable did you find the testing tools? So I wouldn't say I'm a relative newbie. I've been doing it for like three years or so. Like, I accumulated this knowledge over the course of doing all this stuff. So I forgot to repeat the question which I'm supposed to do, which is how discoverable are the tools? And I think, again, this is maybe something that needs a little work. You tend to, I found out about it from word of mouth. There's no centralized thing. I think Matt, who does full stack Python, mentioned yesterday that he was thinking about sort of adding a separate section on how do you test, how do you do static analysis, that kind of stuff, which I think would be a real benefit. So the tools are on Python testing, and they're also using C++ for Python mining. And I'm the main cleaner for the conversion scan for the product Python development. If you have any interest to know how you can check the secret with the C++ for these federal errors, can you tell me about it? So is the other end Python of all or do you have any here? I will certainly do that. Yeah, cool. I have a question. There's one here behind, he's hiding from you. There is a package called piprot. Piprot, okay. That says the rules are how long, how long are your requirements? Oh, that's pretty cool. So piprot is a tool for, apparently for figuring out how old your requirements are. Yeah, that sounds pretty useful. There's a few. Yeah, I imagine. I listed a bunch of tools that I've heard of, but I'm sure there are many, many more. Yeah. So if you have any questions, then let's say thank you, Carl.
Carl Crowder - Automatic code reviews A lot of great Python tools exist to analyse and report on your codebase, but they can require a lot of initial set up to be useful. Done right, they can be like an automatic code review. This talk will explain how to set up and get the best out of these tools, especially for an existing, mature codebase. ----- Static analysis tools are a great idea in theory, but are not often really used in practice. These tools usually require quite a lot of initial effort to get set up in a way which produces meaningful output for you or your organisation's particular coding style and values. As a result, it's common to see initial enthusiasm replaced by ignoring the tools. Such tools can be incredibly beneficial however, and even go so far as to provide an automatic code review, and this talk will explain what kind of benefits you can get from the tools, as well as explain what you can and cannot expect. This talk is aimed at experienced developers who are interested in improving their coding practices but who have either never tried static analysis tools, or who have not seen the upsides. It will hopefully also be useful to people who do use the tools, perhaps introducing them to new tools or concepts they were not aware of yet.
10.5446/19950 (DOI)
Welcome to the next keynote from Bob Ipholito. I met Bob when he was involved in Lithuania in Vilnius in 2006, where he was also hacking on the PyPy project. He went on doing something very commercially viable. He founded a company around advertising. As it happens, he doesn't need to work anymore for earning money. He can now go to conferences and give interesting talks and play with lots of fun things. One very interesting thing he's also doing is he's involved in MissionBit, which is an educational program in San Francisco for teaching children, high school programming, all kinds of stuff. He's doing that on his own time, simply. He's also sometimes looking for the next big thing to be involved in, but he's not eager to actually get there soon. I'm very happy that we have him here because he also wrote the major HTTP server in Erlang. He has helped evolve the Greenlight Library in Python and lots of different things. I think you've also been involved in the simple JSON parsing stuff. He's done lots of stuff in Python, but also in Erlang and recently also in Haskell. So I think he's a perfect guy to tell us a bit about what Python can learn from Haskell and functional languages. That's you. Thank you very much for inviting me to speak here today. I'm going to tell you about some of the things that I don't like about Python, but starting off, I have done a lot of Python. I've been doing it for a long time since about 2001. Most notably, I'm the author of the Simple JSON library, which I still reluctantly maintain. And I worked on a bunch of Mac-specific stuff, PyObjective-C, and all of that stuff. So either you're welcome or I'm sorry, especially to Ronald over there, who still maintains it as far as I know. And as Holger said, I founded a company called Mochimedia, and I worked there for a while, but not so long after I sold it. I've been using Haskell for a couple of years now. Most notably, I ported the exorcism.io curriculum to there. Curriculum is a website which has programming practice problems in many, many different languages, including Python, but also languages like Swift or F-sharp or Haskell, whatnot. So I worked on the Haskell curriculum, and I provide a lot of code review to people that submit solutions in Haskell. These days, I do a bit of advising and investing. I write up right open source code on the side, and I teach, and I'm on the board of a nonprofit called MissionBid in San Francisco. So we hope to expand beyond that once we've sufficiently covered the San Francisco area. And so before I start ragging on Python, let's just say that Python is not all bad, but I only have 45 minutes to talk, so I'm only going to talk about the bad things. I love Python's community. There are so many great ideas and libraries that come from here. And Python works wonderfully for many users. I'm sure most of you are perfectly happy with Python. And for the issues that do exist, there are often good enough workarounds, like PyPy, Numba, Scython, et cetera. And I'm actually not going to talk too much about Haskell, but suffice it to say that Haskell is not all good. I learn a lot from it. I think it's fantastic, but notably, it has a much smaller community. This non-strict evaluation stuff is just so different from how most other languages evaluate code. Sometimes the documentation, it's not a website with some nice documentation. It's like a post-script file that you download that somebody wrote for their PhD thesis. And that's kind of okay. That's accepted in that community, although that's changing slowly. And it can be intimidating to some, because the terminology mostly comes from mathematics. So you have to become comfortable saying things like monoid, functor, monad, et cetera, which takes people a little time to get used to if they haven't taken a category theory class. And so if you're perfectly happy with Python and don't want it to change even a little bit, you might want to leave now and go downstairs and hang out with all the cool companies in the basement. And I was a lot happier with Python until I started learning other languages like Erlang and Haskell. And I didn't look for other languages until I really hit an area that Python just wasn't very good at. And that's concurrency and network programming. And I feel like I'm a better programmer having learned all of these different approaches to problems. And a nice little quote that I ran across recently, and I think this explains some of what we have in Python today, nasty little paradox. The better something works, the less likely it will be improved. And so these are some of the things that I find that Python makes it hard to do. Python makes it hard to write code that works. It makes it hard to maintain code. It makes it hard to create good abstractions. And it certainly makes it hard to run code efficiently. And so on the correctness topic, you're going to make mistakes in any language. It doesn't matter if it has an amazing type system or anything else. You're going to make mistakes. And the key is to have tools that tell you what those mistakes are. But Python defers all of that to run time. So unless that code path happens, it's not going to tell you anything. The only thing it can tell you is if you use tabs instead of spaces, or maybe if you put a colon in the wrong place. And sadly, the static analysis tools for Python today are very, very primitive. They could be better, but it just hasn't been an active area of research. I think this is because the people that can understand this problem and know a lot about type systems and inference and whatnot basically move on to other languages that support these things more readily. And you can write code in Python that you know is correct. And you do that by writing a lot of tests. But some of these tests are things that it should just be able to do for you. When you write an integer literal somewhere, you know it's not a string, and you shouldn't be able to add it to a string. And so given that, here's a simple example of a perfectly pep 8 compliant Python file that shouldn't do anything. The language guarantees that this code will not work because ints and string are closed. You can't override how they behave. You can't change what plus does. So no matter what, this code is just going to blow up at runtime. And we can very easily just glance at this and know that that's the case. There is no universe to which this code should do anything, unless maybe you're introspecting the byte code and doing something horrible, but don't do that. And so let's see what Python thinks. So we throw the Python compiler at it. We use this nice compile all thing, which I often use in automated testing because it tells me if I screwed up the syntax. And what does it do? Well, nothing. It compiles the file. It's totally fine. I get byte code. No error, no warning, nothing. And so another popular tool for looking at the surface of Python modules is PyFlags. So I run PyFlags. It also tells me absolutely nothing. And so what about Pylint? Okay, so I wrote all these nice doc strings and it's perfectly formatted. So this is 10.0 out of 10. I did nothing wrong here, nothing whatsoever. It runs all these tests and it's perfectly fine Python. But it's obviously not the case. And do better tools exist. Well, I certainly couldn't find anything. And if I couldn't find anything, that's bad. Hi, John. Hey, well, I would love to hear more about that. To my understanding, that's an IDE or something, but maybe we can talk about that in questions after. Okay, so nothing that I could readily find could catch this simple case. Most of the tools are concerned with just the general case of Python where anything can happen and dynamism is cool and you can override things at runtime and there's nothing wrong with that. So it's very difficult to write one of these tools when you accept that every feature of Python is great and it should be used all the time. But I don't think that's the case. I think we should write more restricted code just that, you know, in the same way that we should indent consistently by either two or four spaces depending on where you come from or where you work. And the thing is that Python 3 already has the hooks that we need to do very good annotations and we can use those annotations to tell the tools what we expect to happen. And there is a tool that works in precisely this way and I'll talk about that in a little bit. So here's what some other languages do with that example. Here's the airline version. So it's, you know, a little more verbose in some ways. And what does the airline compiler do? Well, if I try and compile this, it says warning, this expression will fail with a Batterith exception. And the interesting thing to note here is that airline is a totally dynamic language. It's not statically typed anywhere. It has optional type annotations just like Python 3 does. And airline also has even better tools. It has this tool called dialyzer which does static analysis and success typing and all this fancy stuff. And this gives me a more specific error about exactly why this is wrong. I can't add one to a string because it expects them to both be numbers given the first argument and the fact that plus doesn't work on lists. There's a separate operator for that in this language. And here's the Haskell example and you might be thinking, oh wait, where's the type signature? Well there it is. But this is the full Haskell program. You note that it's just as simple as the Python one if not simpler because there's no underscores to be seen anywhere, no equals or ifs or none of that. You just write main and what main should be and then that's that. And if I throw the Haskell compiler at it, it's going to give me an error. It says I can't add the number one to the string one. And to explain this a little bit, we can kind of gloss over this because it doesn't really matter. So it's saying this num chair thing because by default lists of chair are strings. So that's what the chair in square brackets is. And operations such as plus, minus, times, negate, etc. belong to the num type class. So it's saying that there is no instance of this num type class for lists of chair. And you could in theory implement such a num type class but you really shouldn't do that. Only truly numeric types such as double, rational, etc. should implement this num type class. The Haskell folks are, they like to write type classes only when there are algebraic laws that you can apply to them. And here it's the law for this particular category. And so why is refactoring in Python hard? Well it's hard to refactor without good tests and not everybody writes good tests. The types are very obvious tests and they're also documentation. So in one way or another you're writing the types here anyway. And refactoring is much easier in Haskell than it is in Python due to these types and also referential transparency. Can we do something like this in Python? Well the answer is yes. So first we have this pure Python, nothing fancy, breadth first traversal of a graph. So we have a starting node which is some number and then edges which is a dictionary of numbers to a list of outgoing edges. And we do the simplest possible bad algorithm. We have a list of all nodes that we visited, a list that is the queue of nodes to visit. And we simply go about our business traversing that queue and appending to it as needed. And so we're going to do one little thing here is we're going to add type annotations to it from this typing module. And so it's going to tell you all of the things that I just had to tell you in order to understand this algorithm. The starting node is an integer, the edges is a dictionary of integers to list of integers and it's returns an iterator over integers. And the only other thing that changed here is I had to annotate that visited is a list of integers because as an empty list this particular tool couldn't infer that. But nothing else had to pollute this code. It's not C or old C++ where I have to annotate visited and queue and node and tell the compiler exactly what I expect it to be. It can infer all the details. And then what I'm going to do is I'm going to make this algorithm a little bit more efficient. So I know that if I use a set for nodes that I visited and a double-ended queue or deck for the queue, then it's a more efficient algorithm because it's not a linear traversal every time I look through it. And so all I've done so far is I just changed the types. The only changes I've made so far are just these two lines. And obviously this isn't going to work because these data types don't implement the same methods. So I run this MyPy tool over it and it tells me exactly everything else I need to change to make this algorithm work. And the only thing I had to do was change these two little lines just the types. That's it. And then it's going to tell me everything that's wrong with my program. It says that on line 11 this deck has no attribute del item. So that's right here. And on line 14, set has no append because it uses a different method name. So I can simply look in the documentation and see what I need to change. And so here's the correct algorithm. It's very, very simple. I just had to change this to a pop left and this to an add and now it works. But MyPy was able to tell me exactly where to look in the code to make that change. And so is MyPy the solution to this problem? Well, you know, it's the most sensible approach that I've seen so far. But the author needs some help. There are many tasks that need to be done in MyPy that don't really require deep knowledge of MyPy itself or type systems such as annotating parts of the standard library or third party libraries. And although MyPy does great stuff, it doesn't yet catch the very simple integer plus string error yet. But it can catch many other mistakes such as the one that I just showed. And so why is PyPy or Nuitka or Scython or whatever not a solution to the problem? Well, these projects are mostly concerned with just performance. They don't really try and help you make your code more correct. They don't help with code quality. MyPy aims to do both. But I think right now the important part is helping us improve our code quality. And the nice thing is that this is just Python 3 annotations. That code runs exactly the same whether you're using MyPy or Python 3. And Python 3, it's not going to do any of this type checking, but the code works. So it's fully portable to any Python 3 runtime. So my modest MyPy proposal here is that we adopt this as a standard. We should start using this typing module or some standard derived from it, even in vanilla Python 3. Like all the code in the standard library should have these annotations. The documentation's tools should be able to read these annotations and automatically write out nicely formatted documentation with hyperlinks for all the types and all this nice stuff. And we need to stop using function annotations for anything else. As far as I understand, they haven't been widely adopted for any other purpose. So I think it's a good time to draw a line in the sand and say that function annotations are for type annotations. And just move forward with this proposal and help us improve Python's code quality. And the nice thing is we don't really have to rely on the quality of the MyPy interpreter, compiler, or any of that fancy stuff. We can just use it as a linting tool, as just a step and just a set of tests to run over our code. We can continue to use PyPy 3 or Python 3 or perhaps even the older Python VM once MyPy is back ported. And what you can do now is start contributing to MyPy and maybe write an official PEP for this proposal because I'm probably not going to do it. And so what? Well, the code quality tools in Python are really far behind other languages. I don't know what PyCharm does, but I suspect that it's not quite as good as Airlang Stylizer or Haskell. And MyPy is a huge step forward, and it can be used with our existing tool chain. The only thing we have to do is upgrade to Python 3 to make it work today. And that's something that we've all been trying to do for the past couple of years. And the only thing we'd have to give up is using function annotations for any other purpose. And I don't think that's a big deal because I haven't really seen too many elsewhere. And in a way, without giving any meaning to function annotations, it's hard to use them for anything at all except for some domain-specific library-specific purpose. They're only truly useful if you can use them in all of the modules that you write. And another thing that I have trouble with in Python these days is mutability is just everywhere. You can't turn it off. And I think it's the wrong default. It's a very, very common source of bugs. Even the beginner case where you're using default arguments and you have some keyword arguments set to the empty list or an empty dictionary or an empty set, and you get behavior that you don't expect because people expect it to always be an empty set. But if you add something to it, it won't be empty anymore. And it also prevents many optimizations. You can't do any multi-threaded stuff without locks if things are going to change all the time in unpredictable ways. And mutability should really be opt-in. And so why should it be opt-in? Well, it's hard to understand code when the underlying data might change. You can reason about it locally, but you really have no idea what else is going on, especially in a multi-threaded environment. The value of something could change from one line to the next. And this means that you either give up and just hope that nobody does anything bad, or you do all kinds of defensive programming. So anytime you return a value from your class, say you're returning self.value, you're going to make sure that that value is a deep copy or something like that. Every time you wrap it in some way, or if you want to use it a key in a dictionary, you have to just copy, copy, copy. And copying is slow, especially for large, deep nested objects. And sharing is prevented by copying, unless these already happen to be immutable types, like frozen sad, or frozen dicked, or integers, or strings, or what have you. And these days, we care a lot about concurrent access. And concurrent access requires synchronization if everything is mutable all the time. And so can we even fix this? Well, I don't know. Because to truly fix this, you're going to need some really large changes to the languages, to the language in the libraries, as we know. Because we've been trying to get rid of the gil for longer than I've been using Python, and it just hasn't worked so far. But if we're trying to fix this, we can look towards languages like Rust or Swift, for good examples. Because these languages have opt-in mutability. So in Swift, for example, if you use there, then you're declaring a mutable variable. But if you use let, then you're saying that that is a constant, even for a data structure, like a dictionary or a set. So maybe that's a bit more practical for Python to adopt. And another thing that really gets me about Python is that all of the abstractions are really expensive. So some things like PyPy's JIT can change some of the constant factors here and there. But ultimately, almost nothing is free. Function calls aren't free. Classes aren't free. Nothing gets optimized away. So you're encouraged to inline code all over the place and make local references to globals and all this gnarly stuff. If you want to see what this does to you, go look at the simple JSON code base. Because I hate doing this, all this inlining, all this stuff, because it's not fun. And you don't want to do it with decorators or AST manipulation or anything like that. You just do it. And it makes it more code that's harder to maintain. But you do it because you get a 20% speed bump here, a 20% speed bump there, and you just live with it. And I really don't like that. And the other thing is that classes in Python are open. You can always subclass them. You can do all sorts of naughty things in classes. And it makes it really hard to analyze them for correctness. Basically subclasses ruin everything. And so a solution that other languages, particularly the ML family of languages have come to, is having a syntax to easily declare algebraic data types. And so I'm not including Scala here. So other languages do this reasonably. And Python over the years has grown a lot of hacks to sort of give us some of this, like the new enums in Python 3.3, I think, named Tupel, et cetera. They all solve little pieces of this problem. And even the destructuring assignment in Python is sort of a subset of what you get with algebraic data types and other languages. And so here's an example of what a typical problem looks like for a Haskell developer, say. You're working with abstract syntax trees. So here I am in Python. In order to say something is an abstract syntax tree node, I have to define this class. All this class does is define an eval method. And then I have to define all of the different types of AST nodes. So there's a constant, which takes some integer. There's this minus thing, which is like a unary minus to negate the node. And then I have to define add and multiply. And you can see that it's quite a lot of code to do this, when ultimately it could be a lot simpler. And so here's that whole thing in Haskell. So in Haskell, I have the boilerplate to say, oh, hey, this is a module and this is what it exports. So in Python, I would have done that with under, under all, but I didn't really have room for it. And here I'm declaring all of the different types of AST nodes. There's a constant node. There's an add node, minus, and multiply. And all of that is very succinctly described. I can look at this and I can see, oh, these are all of the things an AST can be. If I look at the Python, I look, oh, maybe I should grep this code base to see if anything else subclasses AST anywhere. You don't have to do that in Haskell. It's closed. There are only possibilities here. There are ways to do extensibility, but you don't always need that. And it's harmful if you have that all the time, because you can't analyze this to say, oh, you didn't implement evaluation for minus or add. You can't do that statically. And so here's the whole evaluator in Haskell. You typically don't do this with separate functions for each type of node. You just do it in one function. And the compiler can tell me that I handled all these functions appropriately. But the cool thing is, in Haskell here, it can do a lot for me. So here I'm saying deriving show and eek. And so what this does is it automatically writes the code for me to make sure that these have a sensible wrapper and implements, like, under, under, eque in a reasonable way. So if I were to do that in Python, this is what it would look like for just that one specific node. So in Haskell here, I have this amount of code to solve the whole problem. But in Python, it's that much code to solve the problem for just one particular node. So it's very difficult for me to go back to Python and work on these types of problems without ripping my hair out, because Python just gets in my way. And none of the tools can tell me if I've done it right. And the other thing is that in Haskell, we often write a lot of abstractions. And we know that the compiler can unroll those abstractions for us. You can use something called NewType to just make a wrapper around a data type that totally evaporates at runtime. So if you say have a float in your library that really means time, and you don't want to be able to add time to pounds and have it succeed, you can wrap the float for time in a NewType that doesn't allow you to interface with other types without unwrapping it first. And this is also used for things like booleans and whatnot. So although there is a representation for true and false that are one and zero appropriately, you have to unwrap that with from enum. So there's no reason to have code like one plus true equals two in Haskell, because you can have this very efficient representation without paying all this cost all the time. And the other thing that languages like Haskell can do is in these abstract data types, if it sees that the field is strict or meets the appropriate criteria, it can unbox it. And this is something that is very hard to do in Python. You can get a little bit of it with PyPy, and you can erase some of the cost using slots and stuff, but with Haskell or Swift or whatever, you just get all this stuff for free. You don't have to think about it. And even function calls can be inlined. So you can write small functions that abstract little bits of code, and you know that you're not going to pay for it because the inlining actually works, even cross module, although you do get some of this with PyPy. And so on the performance topic, I'm not going to focus too much on that because everything I've talked about provides more ahead of time information. And this information could be used by tools like PyPy, Numba, Scython, MyPy, et cetera. And the important part is that these features save developer time by making it easier to write code. But also, this information can also be used for optimization, and it can lead to better performance. And the trick here is that once it's easier to write better code, it's easier to optimize it because you can refactor it and you can have these types guide you to correct implementations. And the other thing is we really need to write less code in C and C++ because this is what holds us back. This is why it's hard to remove the GIL because we all depend on NumPy or whatever. And these APIs are written in C and they need to work with the reference counting and acquire the GIL and release the GIL. And when we're held back by that, it's very difficult to change anything. But when we have implementations of all these things in pure Python, it's much, much easier to change the semantics. So thank you, PyPy, for spending all of this effort over the past decade or so making this even reasonable today. And so unfortunately for the same basic reasons, the Python C API is really holding us back from doing concurrency properly. It's not even something I can talk about solving until some of these other things are addressed like mutability and not depending so much on these C libraries. But once we do those things, then fixing the other deficiencies are going to be possible. But there is somewhat of a silver lining here. It's been shown that it's possible to have a mixed approach where you write code in a subset of Python, like Py Parallel, where that subset of Python can be compiled and work completely independently of the typical Python VM object system. And so in summary, I really think that we should look long and hard at incorporating all of the good ideas from Py and Python, possibly even just the implementation as is. And after that, we can add some more of the conveniences that we find from other modern languages. And to do that, some of us are going to have to learn languages like Haskell or Erlang or ML or Swift or F-sharp and actually come back to Python. But it is a worthy endeavor. Even if you don't go back to Python, I highly recommend learning other languages. I have learned so much by branching out a bit. And if we manage to do some of these things, then we can enjoy a safer, faster and much more capable Python in the future. And thank you. So thank you, Bob, for the very honest analysis. I think typically at Python conferences, you get a lot of hailing how great Python is and all this. And I think I enjoyed this very much to have a long-term Python user and also involved in other languages to get this honest analysis. So questions to Bob? Yes, Mike? Yeah. I got a question because I'm learning Haskell myself. Do you think it would be feasible to use Haskell as an extension language for Python and writing all those things, currency, recursiveness, trees? Yeah, Haskell is really good. And writing extensions and really make them nice Python objects. Do you think it's possible? I think it is possible. Certainly all of the FFI that you would need is exposed by Haskell to do that. I'm not aware of any library that makes that particularly easy. Most of the effort is kind of the other way around where you're writing code in Haskell and you want to interface with C or Objective C or something along those lines. So unfortunately, I think the upfront cost would be high to write all of the code to expose Haskell ADTs as nice Python objects. But if you were to do something that was a little more decoupled where maybe you're expecting primitive values in, primitive values out, that that would be a lot more straightforward to implement. But I think that as a learning exercise, that might be a bit tricky, like diving into the FFI and how to cross these barriers. I think it's much more reasonable to try and learn Haskell in isolation, maybe speaking over a network to Python rather than linking to it as a C extension. Yes? Just a small comment about the static analysis thing. Chedi is going to be able to find most of those bugs you presented. It's very new, so you can't know it, but still. I'm going to talk about it on Wednesday. Okay, great. I'll have to come to that talk. Thank you. Hi. Thank you for the talk. I just wanted to share some, I see some correlation between the dynamism of a language and the size of its community. If you look at JavaScript, Python, even PHP, they're all dynamic languages with huge communities. Even if you look at, let's say, Scala, Haskell, Erlang, they are very small, tight communities with very correct, very people focused on good programming practice, but also on correctness. Maybe there is some relation, something in the fact that they are dynamic that makes their communities grow so fast and so lively. So maybe by proposing more static approach, introducing that would actually hurt the community side, something to think about. I think that's certainly an interesting consideration, but there are some very easy counter examples such as C or Java or C++, which have presumably larger communities than many of the ones that you cited. And here what I'm proposing is not mandatory. It is opt-in. Full dynamism is still permitted. It's simply encouraged to add these annotations where they're possible and sensible. And anything else would be simply inferred. So it's not like C or Java where you have to write it everywhere. It's more like the ML family of languages where it just happens. And I think there are other reasons that have nothing to do with the type system, why those particular communities are smaller or larger than others. Thank you. I have a question myself. Also because I'm involved a lot in testing and functional testing of systems. To me it always felt that you have for any sufficiently large system, you anyway have to do some kind of testing. Right? Absolutely. So you want to make sure that you have some kind of coverage on your code. So actually your code lines are touched. And as soon as you have something like that, like a test suite where you test the behavior, not just the types, but much more than just the types, you get as a side effect the type checking. So your example of like the integer one plus string one would easily cause an error in this test suite, but the tests also provide much more. So basically my question is if you have a more powerful type system of which I can see the use of course, you still have to write tests. So you basically have to add more overhead and strictness there and you have to write your test suite. So are you actually gaining that much? I think that's an interesting point to bring up. Of course you would write tests, but you no longer have to write so many of the obvious tests. And in languages where you do have these annotations available, there are tools that can either exhaustively or like randomly generate input. Like basically it writes fuzzers for free. So in Haskell I can write a quick check property based only on the types that will generate you know small inputs, big inputs randomly to try and find errors. And those tests are much shorter to write because this information is available. And the advantage is that it tells you what tests you need to write additionally. Like say for example you have a library that accepts some input as JSON and you write the test for okay what if the input is a list, what if the input is a dictionary, what if the input is an integer, but you forget to test what if the input is a float. But the types because they're separate types for each of these things, you can look at you can try and compile it with something like Haskell and it can tell you that you don't have a case for floats. So you can very easily write a lot of tests and get a lot of coverage in Python but miss these cases that the type checker is going to catch. And these type annotations are very succinct. You don't have to write many of them basically just in the arguments to your functions and you end up writing that anyway in some less principled dock string format somewhere because the user of your system has to know what goes where anyway. So this is just moving that information into something that is actually verified either at compile time or run time or both. Thank you. Yeah, and if you allow me I would just like to expand on your answer and answer another thing of your question and it's not only the correctness and testing that whereas the extended typing helps but also the documentation of the problem, the program programs become much more maintainable when the developer immediately sees what type is returned and what type is expected of any arguments that go into the function that makes development much more well easier. And also it allows tools to understand the programs to, it allows the tools to navigate the program much more quickly like you can do in VisualSea or probably in PyCharm or Idea, et cetera in Eclipse. So it helps develop much better tools that allow you to program much more efficiently. It's not only the correctness part. That's just my sense. Yes, thank you. That is absolutely correct. Okay, then thank you again, Bob. We're just directly going to start. Yes, sorry. Thank you, Bob. Thank you very much, Bob.
Bob Ippolito - What can python learn from Haskell? What can we learn from Erlang or Haskell for building reliable high concurrency services? Bob was involved in many Python projects but argues that for some domains there may be better methods found elsewhere. He started looking for alternatives back in 2006 when building high concurrency services at Mochi Media (originally with Twisted), which led him to the land of Erlang and later Haskell. Bob is going to talk about what he learned along the way. In particular, he’ll cover some techniques that are used in functional programming languages and how they can be used to solve problems in more performant, robust and/or concise ways than the standard practices in Python. He is also going to discuss some potential ways that the Python language and its library ecosystem could evolve accordingly.
10.5446/19949 (DOI)
Next up is Benoist Shinnu. He's the correct pronunciation correctly. Okay. He's best known for being the author of G-UniCorn, but today he's going to talk about how he ported the Go concurrency model to Python. So please give a warm round of applause to Benoist. Thank you. Thank you, everybody. I'm pleased to be here today. I will present you my little journey in concurrent programming with Python and how I finished my experiment to port the Go concurrency model in Python and the library I wrote for that. So just to quickly introduce myself, I'm a G-UniCorn author, a WISGI web server in Python. I'm also a COSTP co-committer and member of the PMC, which is the project management group of the COSTP. I'm a Python foundation fellow member and I'm doing a process for a living. So first, what is concurrent programming? Basically, concurrent programming is a way to run functions simultaneously, but it doesn't mean formally in parallel. It doesn't have to be in parallel. It could be just running your function execute code simultaneously by sharing your process in multiple time slides on which you will run from time to time a part of the code you want to execute. Or you can run it on multiple CPUs or machines and then it can be run in parallel in that case. You have mostly two models of concurrency. The first one is the Charon memory, which is easier for the programmer. It doesn't have to care about the variable. It can use global variable, variable up path to functions, and virtual machines, the runtime is managing it for you. It can be problematic if it's not a more efficient way to run your program concurrently because the runtime has to care about logs. When you want to access, for example, to a global variable, the system will have to ask for the latest step of the variable and then you will have to log to runtime, check the variable and pass it to the function, etc. Again, back and forth. And Python is not really efficient for that. And the other way is message passing. So you have two models. You have the actual model and the ESC-SP model. I won't detail it. Today, this is mostly a way to say my function, my code is running independently in a part of my process, or different process on different machine, and I'm passing to them data via message passings so they can discuss between themselves and actions and data. Erlang and Scala are very well known to one of them. So nowadays in Python, you have different way to run all that. You have freeway in the standard library. The old way, for example, is using Asynco, which is basically just an improved SELECT. SELECT allows you to wait on read and write events on your circuits or find descriptors. Asynco allows you to do that, but you can register a function that will under some codes when an event happens. You have a more primitive way, which are threads in Python. I will come back later on that, but you have many problems with threads in Python that allows you to run concurrently, but doesn't run parallel and are running consecutively. You have multiprocessing that allows you to launch code on different OS processes and that have the same API threads. On top of them, you can use a shooter, which are now in Python 3, but are available as an extension in Python 2. And that allows you to execute code using a thread of pool or thread of process on top of multiprocessing on threads. You can execute your code on one thread or one process, and the results when you come back later in the future, you recover the result or the exceptions you had. And you can also put some code back on that, on the results. You have Asyncio, which is a modern way in Python 3, which allows you to do event in a sequence programming. It basically allows you to yell to or yell from a generator. And I'm not really like Asyncio, because it's like you are doing message-pacing because you can send to an iterator or getting back some results from an iterator, but this is not message-pacing and this is only running on one frame in your thread. So it just interrupts your code the time you get the data from an iterator or to an iterator, and then you come back on the code. So you can't really run with tips coding concurrently. You just interrupt from time to time. And it's also running on one frame only. You can also use external library. You have too many groups of external library. The ones that are implicitly yielding, running a sequence code, a blocking code in background, you don't have to care about how it's running a code. It's hidden. You are developing your pattern code like you usually do. Each function are blockings. You pass a function, get the results, et cetera, et cetera. And the code is run in an event loop. G event, eventlet, evergreen are good library for that and they are all based on greenlets. They just are using different event loops for G event. This is a lib event today. And evergreen is using pylybuv. The other group is event library twisted, like twisted, which is mostly working like asyncq, at least it inspired a lot of asyncq. And this is, for me, this is like having no G on Python using spaghetti code and waiting for callback, passing for callback. Event really differing some code for later. But this is not what I really wanted. And all this library asyncq, eventlet, evergreen, twisted, all are based on event loops. Obviously targeting IO input output. So files, events, and so gets events with some options to use the time where your event loop is yielding to under some other code or to under the timer. So I decided to write a new library for that to experiment some new code. And basically put in the go runtime library, the go runtime to Python. Offset means this is a small and virtual complex of plants so that is growing on another plant and sharing the same IDN. They are both sharing the same IDN. But the other plant has its own life. This is basically what is offset. Making the go scheduler on top of Python, top of Python VM. I have some goals, I want a simple blocking API like J event on eventlet. But that is not trying to patch in background my standard library. I prefer something explicit. I prefer to see, to know when my library is patched and I prefer to proxy standard library for that. So it used to be working on Python 27 and it is still working on Python 27 and 8. But I am mostly focusing today on Python 34 and PyPy because I don't have time to handle all the Python today. And you can find it on my repository. The code is mostly a memory model. It is based on go routine. Each go routine is running on one thread. It is basically a way to split your thread to pass function execution code in the stack of your threads in the free frame. When you want to switch from one code to the other, the system is using one frame in the thread to execute and go back in your code, et cetera. It is basically just adding a metadata to your threads. Each code is not from each other. They are running independently from other. You can't pass global variable. Obviously in go you have global variable but it is not advised to use them and this is the same in offset. You can use because you are in Python but I don't advise you to use them because you will have again concurrency issue. They don't share anything and channel pipes are the only way to communicate between them. Also our way to unblock your code because when you are waiting for a channel, the scheduler is able to run again to say someone will send to the channel or to execute another code, et cetera. You can wait on mutip channels. I decided to code that on top of Python because it was easier but it was some nightmare so really I didn't sleep some time to find the way. Because Python has drawbacks and the main drawback is well known. This is the skill and the main part of the skill. The skill is here to allow you to make easy code, to have global variable, to easily pass variable to your function. Like I said, to do that the system is the runtime is need to lock and it takes time. Also because of that one of the threads is executed at the time. You may have mutip threads running in parallel in your systems but you can only run one thread at a time to execute the code and then you need to wait until the thread is finished to execute to get the results. So during this time your system is locked. But it works well for things like accepting on socket, waiting for connections, reading an event on sockets or reading a file, writing to a file because all of that is under the background by your OS. So using threads for that and I will use for that is very fine. And yeah, Python has no implementation of the code and I don't want to try to do that on Yield. I don't think it will work anyway. So I decided to create some coroutines to create the coroutines systems. Coroutines will always be executed in thread, in event thread and broken code operations will be executed in their own thread, a Python thread. To implement coroutines I'm using Python fiber. Python fiber is basically a port of continuolets on C-Python from SAGUR, the author of IUV. And I contributed to Python fibers to also have the same API on top of PyPy so you can use Python fiber on top of PyPy to using the same API. And I created the modules to do atomic clocking so instead of using Mutex, etc. on the system and using atomic operations that you can find on GCC and other implementations and I've created a CFFI for that. Everything is abstracted in Prost class so if you want to use greenlets you can eventually write your own abstraction to the coroutines. So scheduling is the main part of the offset library. There are three entities in the scheduler. The other threads call F because they will run in future in thread pools. Scheduler context is called P because you have one scheduler context which will maintain the run queue in the main thread and this is called P because of process. This is a process in your Python VM. And go-routine which are called G. So how the scheduler works is pretty simple in fact. At the end you have a process context which is maintaining a run queue, a run queue of coroutines and these coroutines are stacked in a queue and the first one and third will be the first to be out to be executed. At the time you have only one coroutine that is running. The one that is put out of the run queue and when the coroutine has stopped to run it can be put back in the run queue or it can be another coroutine from the run queue will be executed. Of course you still have a system call to handle any blocking call like having a timer or waiting for connection or reading a file, any blocking operations, mostly I operations. So you are still in your run queue and when you go-routine is detected as blocking and this is done by propping the standard library in the C-scall models in offsets. I'm tagging any blocking calling from the standard library in the C-scall models and when a function is detected as blocking the scheduler will put the go-routine out of the run queue and will create a call in the thread pools that will handle the call. So the call accepting connection or reading a file will be under in the thread and when you come back the scheduler will create the go-routine and put it back in the run queue and it put it back on top of the run queue so it will be executed in priority and you will get the results in your code later. So by doing that all your C-scall are able to run in parallel and you are still able to handle the rest of the code in your run time. Some examples, here is a go-routine example. On the right you have the Python code and on the left you have the go-codes which are pretty similar. So what this code is doing is pretty simple, it's putting hello world five times and the first time the main function is executed so here you are seeing some kind of old code because the run function is about to be removed. I just need to commit the code. But right now it's how it works. You have a go-routine that is saying words and the main function that is saying hello and the safe function what it's doing is five times is printing the string that is passed to it and it's sleeping during 100 milliseconds. And when it's sleeping this is a C-scall function and when it's sleeping the go-routine is put back in the run queue and the next code will be executed. So the first time it will say hello and the main function will be put back in the run queue and the next go-routine which is a world go-routine, the first go-routine will print hello will be put in the run queue then the next go-routine will be executed will say hello, etc., etc., five times. And yeah, pretty similar to the go-code module of the syntax. Channels are fully implemented in the offsets. You have all the features you have in Go, Long-Grid, you have them in offsets. Channels are mostly pipes that connect concurrent go-routings. You can send value in a channel, into a channel from one go-routine to the other and we save those values in another go-routings. And by doing that, when you are sending a value, the go-routine is put back in the run queue to let the chance to another queue to let the chance to go-routine to send back the data to the go-routine. When the go-routine is sending, if we put back in the run queue and the next go-routine will be available, okay, and you will be able to read. So by doing that, we are mostly articulating the scheduler and unblocking your code by passing message from one go-routine to the other go-routine. Channels can be preferred. That means that you don't have to wait until someone is receiving the first value you are sending. You can send many values at a time before blocking your code. And you can select on YouTube channels. Here is a simple example. On the right, you have Python. On the right, on the left, you have Go again. And we are making a channel. Here, the goal is to sum a list and to sum the list more efficiently. We will split in two. And we are splitting the list in two. We're creating two go-routings that we sum this list. To this go-routine, we are passing a channel which is created by the makeChann function. And when the sum is done in the go-routine, it will send back the result in the channel. And the main go-routine, the main function is waiting for the result of these two go-routings, waiting the result of the sum on X and Y. And we sum the final result to print the final sum. And the code in Go is quite similar. This is an example of the buffering. And this is an example of the channel. So the channel is the select function which allows you to wait on multiple channels and you can wait that someone is able to resave the data you want to send to him to wait that someone is able to send you some data that you want to resave. Mostly like a select when you are waiting for read and write in your sockets. And this is done by the ifSend functions here. And you register some events in the select function. So you are, yeah, we are resaving a send and a resave. Sorry. And this is the few models you function. Not time to date. You have all the models implemented. You have sync function with the atomic locking that you can use in your library in plus of channels so you can do some atomic locking. And you have timer and net and IO modules to under IO connection to your file and your sockets in an unburking manner. What I want to do is to rewatch channel using a map. This is mostly done. Spend on different processes of machine which needs the first one to be done. Channel and make the runtime switchable like in Rust. So you can even really switch to a library in time if you want or to use multiprocessing runtime or any other runtime. Any app is appreciated and you can contribute to the repository. So that's it. Voila. If you have some questions. Yeah, if you have questions, please line up at the microphones. Or raise your hand. If you're. No. No questions. Yeah. No questions yet. Okay. Okay. Thanks again. Thanks again.
Benoit Chesneau - Concurrent programming with Python and my little experiment Concurrent programming in Python may be hard. A lot of solutions exists though. Most of them are based on an eventloop. This talk will present what I discovered and tested along the time and my little experiment in porting the Go concurrency model in Python. ----- Concurrent programming in Python may be hard. A lot of solutions exists though. Most of them are based on an eventloop. This talk will present what I discovered and tested along the time with code examples, from asyncore to asyncio, passing by gevent, eventlet, twisted and some new alternatives like evergreen or gruvi. It will also present my little experiment in porting the Go concurrency model in Python named [offset], how it progressed in 1 year and how it became a fully usable library . This presentation will be an update of the presentation I gave at the FOSDEM 2014. It will introduce to the concurrency concepts and how they are implemented in the different libraries.
10.5446/19947 (DOI)
Here, let's call this Das James Sance on. Austin is going to tell us about refactoring which is awesome and tricky in Python so please welcome Austin. Thank you. That's all right. Again, my name is Austin Bingham. And I'm going to talk to you about Python refactoring with rope and thrall. I'll explain what both of those are. They're two technologies that work together. I work for a company called Sixty North, part on it as well. So hi. Oh, this wrong button there. Right. A little bit about myself. I'm originally from Austin, Texas. And my name is Austin. So I'm Austin from Austin. When I like to show this slide to give a sense of the differences in places I've lived, Austin has statues of Steve Ray Vaughan downtown, a big guitar god. And I went to the University of Texas, so Hookham Horns. About five years ago, I moved to Norway. So Vanger, Norway, they're on the West Coast. Our statues there are different. We have three swords rammed into the ground. So there's like 30-foot-tall stone swords to commemorate the unification of the Norwegian kingdoms. And this is the most beautiful fjord in the world, I guarantee. Come visit Stavanger sometime. It's really wonderful. And this is something I added at the last minute. I was in the Hague the other day. And we tend to think of Python as very much being used for web stuff and being used for a lot of science and engineering. But I saw an art exhibit. This is one of the most famous Mondrian paintings here rendered in using Python. I saw this at the bottom of the display, and I had to get a picture, because you can't really read it. But it's import numpy, import tkinter, import random art parts. So they're using Python to generate really interesting art for, apparently, a very overpriced painting. But the Mondrian exhibit in the Hague is really, really worth seeing. And you get to see some Python. So a little side note. So what is Rope? Rope is a Python library for doing Python refactorings. It's that simple. That's why I kind of have the snake eating itself. It's a Python module. You can import. But then you can have it look at your source code, and it can do things like renames and pulling out of functions and all that kind of stuff. So at a very high level, that's all that Rope is. I didn't write Rope. Rope is something that exists independent of me. I've never met the people who do it. But they're very, very bright, because it does a really hard job refactoring Python, because Python is so dynamic. Rope has a lot of very powerful IDE-oriented features, like code completion, finding definitions and occurrences. These are things you'll note, by the way, which aren't actually refactoring. They're just things that Rope is also able to do. Organizing imports, a good refactoring, looking up doc strings, et cetera, et cetera. It's really designed to be used from IDEs, not used as a module, per se. It's not wise for you to import Rope and start trying to use it yourself, because there's a lot of ceremony involved in refactoring. So you want your IDE to take care of all that for you. And that's kind of what I'm getting to withdraw later on. So what are the elements of Rope? I'm going to take a pretty high level view of Rope, just to give you a sense of the parts of it, how a refactoring looks and things like that. I'm not going to get into too many details. The highest level concept is the project. The project is really just a directory with a bunch of stuff under it, a bunch of files and other directories containing even more files. And this is the tree of stuff that Rope is going to manipulate for you when you ask it to do a renaming or something along those lines. So there's a project class, and you instantiate that with a directory, and that's the base of all the things you do. You create a project just like this. I think that's fairly readable, but it's that simple. There, that's created a project, and it creates a little file for you, and it's parsed a bunch of stuff, and it's ready to go. The kind of things you can do with projects, you can walk all of the resources. Resources are files and directories. And you can get the children of resources and continue walking. So this is just not important that you understand this. This is to show the kind of the flavor of the API. It's very straightforward and really easy to understand, if a bit under documented. There is a Prefs object that you can get, and this thing is basically a dictionary of keys to values. And these values are all sorts of settings related to how much stuff should it keep in cache, or where I forget all the different Prefs. There's hundreds of them. And this is, if you look in your Rope project on disk, you'll see a.Rope project file. That is essentially reflected directly in this Prefs class. So this is something you can interrogate at runtime if you need to. If you end up doing IDE embedding of some sort with Rope. I just said all that. Resources, again, those are things like files and directories. And this is a lot of what you end up doing when you work with Rope, is walking these trees and finding specific things you want to work with, and then applying refactoring to specific resources. Again, not a lot of detail, just something so you have a sense of how it all is put together. What's more interesting, from my point of view, sort of aesthetically and technically, is how refactoring is done. So you have these concepts of projects and resources and so forth. But how do you actually, what does it look like to do a refactoring with Rope from the code point of view? The first thing you do is create a rename, or in this case, we're creating a rename refactoring. So I've imported the rename refactoring class, and I've constructed one. This can fail, of course, if Rope says that that's not a resource that exists, or you've gone off the end of the file, it can complain, and so it's possible for the construction of this to fail immediately. You can see this is only partially bound. And what I mean is that we've created a rename, and we've told it which project to work against, and we've told it the resource to work against, in this case, a file called state.py. And we've told it the offset, which I want to do the rename. But what's conspicuously missing from this, of course, is what you want to rename it to. So Trot has this notion of these partially bound, incomplete refactoring. It's figured out, if you then tell it to do the renaming, it's figured out all the places it has to touch. So interestingly, you can use the same refactoring multiple times, if you want to, for some reason, rename something to six different things. So that's the first step in refactoring with Rope. The next thing you do is calculate the actual refactoring, what you would actually do. In this case, I'm changing whatever was at 0.42 into the word, taco copter. If taco copter doesn't ring a bell, it should, because it's one of the greatest business models in the world. It's drones delivering tacos to you. It's brilliant. And hopefully, one of these days, it will be a reality. I think it was denied by the FAA in the United States. They couldn't do it. One of these days, the future will arrive. Once you've calculated the changes, you haven't actually done the changes. You've just figured out what you're going to do. You can print out things like the description of the change, the changed resources, which is an interesting bit of information if you have an IDE and you need to refresh frames or something like that. That's a good piece of information to get without actually having done the refactoring. So changes represents a fully balanced change that you can then execute. You just say project.do. Changes is the refactoring you calculated. And then this is when things actually get changed on disk. So that is the 10 cents tour of how to do a refactoring in rope. And this is sort of the full process here, from creating a project to creating or refactoring, calculating changes and doing the changes. So really pretty straightforward, conceptually pretty easy, technically very difficult. But that's rope's job to keep the technical part difficult and not have you worry about it too much. One important feature of Trot is this notion of history. This is the most historically accurate picture I could find on the internet. It's a blink and with a machine gun on a bear freeing the slaves. So it's a joke. History, it keeps track of things in this history class. Every project has a history list, I think is what it is, or a list like. I forgive the exact class. But it manages the changes that have been made and also the changes that have been undone. So if I've made a change and I want to undo it, I can do it. But it also remembers the things I've undone and I can redo them. And it's kind of fun sometimes to kind of shuffle back and forth between different refactorings to see which is the one that you like the best, which is the one that maybe is most aesthetically pleasing or what not. To undo changes, you can just say projectouthistory.undo, very straightforward. Or you can select specific points in the past that you want to undo. So you can go maybe four refactorings back and undo that one or redo it, as the case may be. This is transitive. Maybe transitive is the wrong word. But it will undo all dependent changes. So if I undo my most recent change, or if I undo my first change, it has to undo all the ones that have come afterwards. So it will undo all of your changes. And the same with redo. Because if it didn't do that, of course, it would just kind of spam your code in all likelihood. You wouldn't want that. Redoing changes is very similar. There's a thing called the redo list. You can look things up in that. And of course, you would never do this manually. You don't want to be writing code to do this. You want your IDE, again, to be asking the history object, what is there, and then displaying it in a nice window so you can check boxes and stuff and decide what to undo and redo. This is just the API at the rope level. Another really interesting and very powerful feature is multi-project refactoring. You may decide that you have separate projects in different directories and different places, but you know that they rely on each other. One depends on the other. And you want a refactoring that mostly applies to this project to also be performed in this project. And Rope can do that. At a very high level, it works like this. You create a multi-project refactoring, and you give it the refactoring type, in this case, rename, that you want to do. I've just used rename for all of my examples here. There's many other refactorings. You construct this multi-project refactoring and tell it the other projects, not your main project, but all the other projects you'd like this to operate on. And remember, these are just projects built on some other directory tree somewhere. And then you can use the MPR, the multi-project refactoring there to construct the unbound refactoring, just like we did earlier. Then you create the changes like we did earlier and change it. This is clearly somebody who likes Java, because it's the Enterprise Proxy Manager implementation factory factory. And then you would do multi-project perform on the changes. The multi-project API is a bit weird. And it took me basically a lot of experimentation to figure out how it worked. But it does work. I can say that with good confidence. It works as well as Rope works on single projects, which is not perfect all the time. We talked a lot about refactoring things that Rope does. It has a lot of obviously non-refactoring related things like finding doc strings and finding definition points and so forth. These are great IDE tools as well. Frankly, I use Jedi for a lot of that kind of stuff now. But I still use Rope and Troll for pure refactorings. I've said this many times, but Rope is not intended for manual operation. It's really tricky to get right and let your IDE do the heavy lifting for you. Let an integration tool do the heavy lifting for you. And that is where Troll comes in. Troll is, OK, there's the definition of Troll. This turns out a few. But it's Norwegian for thread. I thought it was kind of witty. Rope, thread. Little pro tip, if you need to find names for your projects, learn a foreign language. And just use the foreign languages word for that. I'm not Norwegian, obviously. So I just picked Troll. And nobody in the world that uses Troll for a project name. So it was wide open. So what is Troll? Troll is an HTTP JSON server wrapped around Rope. That's all it is. All it did is put an HTTP API on top of Rope so that you can call it easily. It also includes, I say, various clients for driving the server. Right now it contains one, and that's for Emacs. So I use Emacs. And so I needed this tool, basically, is why I wrote this. So the idea is that your IDE, VIM, Emacs, Visual Studio, whatever, can send HTTP JSON requests to Troll. And it will work on the file system and do the work for you. It's great. The embedding is really, really easy. The embedding of a refactoring tool in Emacs is really simple, because it's just so simple. So why Troll? Why did I go through the trouble of writing this? There are existing tools that rack Rope for Emacs. One is simpler integration with editors. Everything in the world now. My watch probably, this table, speaks HTTP JSON. So it's easy to send these messages back and forth. So I didn't have to worry about embedding the Python interpreter in Emacs or something along those lines, which is technically feasible. And I know how to do it, but it's more complicated than it needs to be. HTTP is way more than fast enough for this kind of work. People will say, oh, but you're sending messages over HTTP. What about response times? No, no. HTTP is way faster than we can blink. So of course, it's fast enough for this kind of work. The real time involved in refactoring is the refactoring themselves. And so I don't have to worry about latency. This is really a great way for me to support multiple versions of Python in one Emacs. If I was embedding the Python interpreter in Emacs, I'd basically have to pick the one I wanted or jump through incredible hoops to have Python 3 and Python 2 embedded in Emacs. As it is, that's all separate processes. It's really easy. And really, Emacs knows very little about the distinction now between 2 and 3. And it knows a little bit, because I have to tell it. But very, very little. And this really simplifies to three concurrent development, especially over multiple projects. It's an architectural win in many, many ways. It's the proper level of abstraction. The job of Trude is Python refactoring, not being embedded in an IDE. And so this is allowing me to pull them apart and really work at the proper level of abstraction. You can see I've solved the most heinous religious war in the world now. Emacs now loves VI, because they both use the same tools. If we all wrote our tools like this, we wouldn't have to complain. We'd all use the same tools really under the hood. We just had different key bindings. Right. So it's that simple, believe me. So a little bit about the architecture. We're good on time here. This is what I like to talk about, the Python goodness, for the most part. I use Bottle for the HTTP handling. And Bottle is wonderful. Anybody here involved with Bottle? Thank you. It's brilliant. It really is. I just copied Bottle.py, dropped it in my source directory. It's there. I don't have to worry about dependencies or anything like that. It just works. And it's awesomely, awesomely easy to use. Thank you very much. If you need to do HTTP handling, use Bottle. Or at least consider it. Another one, Pyka or Pyka. Who knows how to pronounce this? Pyka. OK. He should know because he wrote it, I believe. Yeah. OK. Thank you. Pyka is an actor model implementation in Python, which is hence the award here. This is an Oscar. It is awesome as well. I started the implementation of Troud without that. And I had to handle my own concurrency because you need concurrent asynchronous handling of requests because summary factorings can take a long time, especially on large code bases. Well, once I switched to Actors, basically I didn't have to think about it anymore. This is another huge architectural win. I knew that my state in this actor was distinction my state in this other actor. And I didn't have to worry about locks or anything. It just works. It just works. And the biggest win is not even concurrency, which I don't really get. It's the conceptual clarity of the program itself. So if you've never used Actors and you have concurrency nightmares or concurrency headaches, really make a branch for Pyka on your project and try it out. And I almost can guarantee that you're going to love it. It's even not picket any actor model. Staclas is essentially an actor model. Try that. Staclas is incredibly cool for many other reasons as well. So this is another big win. So thank you. Thank you for that. The architectural diagram, if architecture has to have boxes and lines. So I was required by EuroPython to do this. You have Bottle at the front receiving all of the inputs and two actors, the project, which is the thing that kind of handles all of the actually talking to rope. So it takes the requests for do a renaming, do an extraction of method, et cetera. And you can see that it works directly on the file system, which the editor is also looking at, by the way, which is a bit of a trick sometimes. The other actor is the state, which basically is a thing that keeps track of the request to the state of that request. And that can be queried through Bottle as well, hence the line, obviously. The task state, like I said, is just a mapping of integers, which are just increasing integers for every request, mapped to whatever the status of that thing happens to be failure, or pending, or success. It's sort of a free form thing. I don't use it much except to keep track of what's going on right now. It's simple. The state object, the task state object, is an actor and thus, I'm going to call it thread safe. That's a reasonable term to use for this. Really, it just means it's asynchronous safe. And multiple asynchronous tasks can be accessed at any time. And I don't have to, again, think about locks or anything. It just magically works because there's serialized messages at every port. I've got enough time to talk about this. The important part here is for the asynchronous operations intro. So some request becomes in for a rename. That's asynchronous because it might take a long time. The request just spits back immediately a task ID, and then that's done from the client's point of view. The client can then come in later and ask for task 23 and get the status back. But all the renaming actually happens asynchronously. Synchronous things happen in a much more simple way. Find definition. We want that to happen as fast as possible. There's no reason to continue without. There's no reason to come back to the ID until it's completed, so this is a synchronous operation. There you go, UML. There's a couple of asynchronous things, renames, extracts, organize imports, and there's a couple of synchronous things, things like find definition, get history, find the call tip, that kind of stuff. Those are all synchronous. I love Emacs, so I had to sneak this in. Emacs is the only editor or the only place where I use it, the only place that I know that it's used at all, actually. So the code for using emacs, or using trolled from Emacs is there's very simple, trolled open, and trolled rename. It's really that straightforward. Because Emacs knows where my cursor is, or VI for that matter, knows where your cursor is, trolled rename RagingRoyd, which is from an asteroid's clone that I wrote. It works because you don't have to tell it where to do it from. Emacs figures it all out, and this is letting your IDE do the heavy lifting of figuring out where to do the refactorings and stuff. That's why I keep hitting that point over and over. This is what I mean. And this is what the HTTP messages look like as they come through. Probably all knew that anyway. Right, so how am I on time? I have about, OK. I could do demos or we could take questions. The demos are just me using Emacs doing some refactorings. So if there are questions, let's me can start with that. And I can do demos later if people want to see. OK. I mean, you have the rope change and Emacs. So how do they interpret it? Yeah, I'll repeat the question. So the question fundamentally had to do with I have rope doing work on files. And I also have Emacs looking at these files, potentially doing things at the same time. Right now, that interaction is very dirty and crude. I just, let me pop the stack up a little bit here. I'm the only person who uses Troll as far as I know. So it works for me. That's what I know. I have my Emacs set up to once a second, refresh or revert any buffers that have changed on disk. So I know before I do a refactoring, I just save my file and do the refactoring. There are ways around this, of course, because one of the things I can ask Rope is, what are you about to change? Right, and he can tell me, here's what I'm about to change. And then after the refactoring is done, I can automatically revert all those buffers. I just haven't written the logic to do that. I'm accepting patches. So of course, if you want to do something like that, I'm more than happy to consider it or build it in. But you do have to be a little bit careful about that kind of stuff. And you can, of course, get into weird situations where you've made your own edits in Emacs, and then the file system is getting changed two or three times. And that's just a race condition. I'd say don't do it. Other questions? Yes? What a list for a while here is the format tool can take two expressions to a mechanistic format like to name a lot of things. Is there a non-line binding for the graph or the growth? I don't fully understand what it is you're asking about. A mechanistic renaming of arguments, I don't know what that means. OK. The answer is maybe. I don't know. The question was about something I don't know. But Rope has a lot of functionality that I don't expose right now in Thraud. So if you are missing some feature, we can explore whether or not it already exists in Rope or if it needs to be added or what the state is. Any other questions? OK. Well, we've got a little bit of time. So OK, you asked for it. All right, so this is Emacs. And I'm going to do a quick refactoring. So the first thing I need to do is start the Thraud server. So Thraud open and I tell it the directory. And you can see, of course, that Emacs is kind of managing this process, this Thraud server. It spits out some information. So that's Thraud running under Emacs's control. Now, let me make that a bit bigger. If I can, at my age, I should be able to do this. I don't know how to make the font bigger. I'm sorry. Well, you can kind of see that. The point is, this on the right is my unit tests for my collision detection. Increase. Hex scale. Text. Scale increase. Hey, look at that. All right, I'll do it over here. Can you make the Nyancat bigger? Probably. Yes. Yeah, in case you watch the Nyancat. Oh, isn't that great? That make you feel better? OK. This is how I spend my time. We've got this function, calculate collision vector, which is defined in collision.py, collision detection stuff for my Asteroids game. And over here is the unit test. And say I'm in my unit test and I, for some reason, decide, I don't like that name anymore. So I can say control XTR. Rename that to count, call back. And it'll think about it for a few seconds. And this is kind of what you were getting at earlier, you in the second row about the timing. But you can see, OK, now it's changed. I actually gave it the wrong name, but that's OK. It's changed it everywhere that you could find it. So it's changed it not only in the call here in the test, but also in the definition. One shortcoming, and I don't know if there's a great solution, is it does this. It leaves all these things incorrectly indented. That seems like a rope shortcoming that I would like to get fixed. So if I don't like those, I can display the history now. And I can see I've got this one thing that I can undo, which was renaming calculate collision vector to count call back. I do want to undo that, because that's actually not the name I wanted to give it. So I'm going to trot undo. And it will think about it for a few seconds. And then I promise it will. Yeah. Now the history doesn't automatically update, so let's just ignore that for now. That's another fixable thing. But that's sort of the main things that it do. Yeah? I got a question. Did the history get cived, or is that just in memory? It's just in memory. So if I kill off the trot server, it's gone. As far as I know, it might be serializable, but I've never tried. I've never looked into it. It's never been an issue for me, basically. One kind of cool thing that a lot of people might appreciate when they're starting to work with new code bases is it can clean up, rope can clean up your imports in certain ways. And so in trot, I've created the command, trot import super smackdown. And it just runs all of the organizing and cleaning up of imports. And I tell it which file. And it does it. And a second later, it will boom. OK, see? Isn't that much nicer than it? There's no leading import dot dot, all that kind of stuff. It's all done. And of course, I can undo that. So that's it for the demo. If there's no more questions. OK. I'll just do one. Is the power impactor in the gray system? Can you say that a bit louder? Does the power impactor in the gray system? And you're changing the class name or the name? Does the power change in the gray system also? You understand? I'm trying to get it right. It was about the gray. Can it have a great renaming decorators? A renaming decorators? That's a really good question. I don't know. Like I said, I'm the only one who uses this. So if I've never had to do it, I don't know if it works or not. I would think so. Because rope is pretty darn smart. Rope does incredible things well beyond what I would have imagined would be doable with refactoring tools and language as dynamic as Python. But we can try it out later. It shouldn't be hard. So yeah. Anything else? All right. The last slide, there's some links to all this stuff. The presentation is on GitHub, GitHub slash a Bing. You can find it. Links to everything else. And thank you very much. Thank you.
Austin Bingham - Python refactoring with Rope and Traad Rope is a powerful Python refactoring library. Traad (Norwegian for “thread”) is a tool which makes it simpler to integrate rope into IDEs via a simple HTTP API. In this session we’ll look at how traad and rope work together and how traad integrates with at least one popular editor. ----- Python is a modern, dynamic language which is growing in popularity, but tool support for it is sometime lacking or only available in specific environments. For refactoring and other common IDE functions, however, the powerful open-source rope library provides a set of tools which are designed to be integrated into almost any programming environment. Rope supports most common refactorings, such as renaming and method extraction, but also more Python-specific refactorings, such as import organization. Rope’s underlying code analysis engine also allows it to do things like locating method definitions and generating auto-completion suggestions. While rope is designed to be used from many environments, it’s not always easy or ideal to integrate rope directly into other programs. Traad (Norwegian for “thread”) is another open-source project that addresses this problem by wrapping rope into a simple client-server model so that client programs (IDEs, editors, etc.) can perform refactorings without needing to embed rope directly. This simplifies dependencies, makes clients more robust in the face of errors, eases traad client development, and even allows clients to do things like switch between Python 2 and 3 refactoring in the same session. In this session we’ll look at how rope operates, and we’ll see how traad wraps it to provide an easier integration interface. The audience will get enough information to start using rope themselves, either directly or via traad, and they’ll see how to use traad for integrating rope into their own environments. More generally, we’ll look at why client-server refactoring tools might be preferable to the more standard approach of direct embedding.
10.5446/19944 (DOI)
Y Menybur Hopefully nw enrolled payment Research Rock et tearych fudds ynhe שהadag fe allum i gellys y Fyllgor roedd gen nhw'r llw esp leisure pob l whiskardhopol C가요 gy nifer maen nhw'n edrych discussions sydd cbaitiaid o'rodus a i ddau sefydl i detwch eraill cy fresh I know, so, over for me. Thank you. So, I'm here to talk about PIPA STM, which is software transactional memory. And well, what it actually means is something that will become clear, I hope, during this talk. So, it is a bit of metadata. It is an ongoing research project. It's done mostly by two people, me and Rhymi Mayer, who is at ETH in Zurich. It is a project that has been helped a lot by crowdfunding. So, we got some almost $30,000 over the three years of the project. So, thank you for everybody who did contribute. And it's a project that started at the Europe Iphone 2011 lightning talk. So, maybe a few of you remember I was there and I presented in five minutes how it would work. So, yes, this is the result of three years later, basically. So, first question, why is there a global inter-potaloc when you run your PAPHIN code? Well, I mean, it came as a historical reason, but now it's really deeply into the language, basically, of the C-PAPHIN implementation. Well, C-PAPHIN started as a single-fredd program, and then, well, the easiest way to change a program to make it run on multiple threads is just put a lock around everything, right? You have one lock that is called the global inter-potaloc, and it needs to be acquired in order to run any piece of code. So, the result is that, yes, you can have multiple threads in Python code, but they are not being used for parallelism. You use them for concurrency, whereas, I mean, the difference between these two terms really means that you can use the fact that you have several threads that will run independent pieces of code or do some external code or things like that, but they are not actually running in parallel. So, this was really done because it was the easiest way to change the interpreter, and, well, it's also very easy for reference counting for all this kind of internal details where we don't have to care, basically. So, this has positive and negative consequences. Positive consequences, well, it's simple for the implementer, but it also has some consequences that are visible for you, for the user of Python. These consequences are some operations are atomic, for example, list.append or dictionary setting an item into a dictionary or doing these kind of things. You know that even if you are running a multi-thread program, another thread that would also try to do an update to the same dictionary, for example, it's not going to mess up the internal state of the dictionary, and that would lead to completely obscure crushers, et cetera. No, these are not occurring in Python. All variables are volatile, basically, is what I could say here. And if you don't know what volatile means, it's perfectly fine. But it has negative consequences, of course. The completely obvious one is that you don't have parallelism, actually. You cannot write a parallel program in Python. I mean, not one program in Python. There is another consequence that the global inter-petalock exists, and it's fundamental, basically, but it's not exposed to the application, which means that you get some of the benefits, like the atomicity of some basic operations, list or dictionary setting of this kind of stuff. But you don't get, well, you don't get larger scale atomicity, or you still basically need locks even in your Python program. So you need locks and then all the hard parts of locks, like dead locks and everything. So how do we remove the gil? Well, there are three approaches, I think. The first is called fine-grained locking. The second shared nothing. And the third one, which I'm going to present, is transactional memory. So a bit of contrast, what are these three approaches? Fine-grained locking is, well, we have this interpreter which has the gil, so let's kill the gil. And instead, we are going to put very fine-grained locks on each individual object, right? So this is a lot of work for the guy who is implementing Python. I mean, updating Python, basically. And also, if you are talking about sieve, and there are tons of nasty issues, like for example reference counting, et cetera, because now you can have several processes that will in parallel try to update the reference count of the same object, so what is the atomic updates and what are the atomic updates are slow and processes, et cetera, et cetera, well, there are tons and tons of issues. The point is that it's an approach that actually exists in Python and Python. They are doing it, basically, but they are benefiting, I mean, they, as in the Python maintainers and around Python maintainers, are benefiting a lot from the fact that the JVM and the.NET platform has really good support for exactly that. For example, the JVM hotspot will happily do lock removal on any object that it can somehow prove did not escape the current thread. And even in the case where it cannot prove things, they are doing kind of crazy things like they have five different cases, the first case I checked very quickly and then you go into slow and slow and cases, et cetera, well, basically they are doing crazy things and it's fine. But, well, you still need application level locking. It does not solve that, right? If you are writing a Python program and if you are running it on top of Python, let's say, well, you still need to carefully use threads and locks and everything in your Python program. So, this is why there is a completely different approach that has some traction nowadays, also because it can be used on C-Python, it's just shared nothing. It's basically the approach that if you want to run some piece of code in multiple cores in your machine, you just start several processes. And then the processes, well, you need to design your program in such a way that it's possible to exchange some amount of data that is not too much. Well, it is actually a model that some people think is a good idea and I cannot agree. There are usages for which it's a good idea. It gives a clean model on a multi-core program. You don't have the issue of locks. And then, well, the negative point is that, well, you have limitations on what kind of data you can exchange between processes. You have actually overhead for exchanging the data. Also, it's not compatible with an existing threaded application. Well, it's still a good model. That's not a 100% solution, basically. So this is now what I'm talking about. This is, well, transactional memory is a way, well, it's a way to run the interpreter as if it had a gil globally in the data lock. So the main difference is that instead of blocking, so when you have a lock that several threads acquire, it usually means that all threads will have to wait and only one thread can proceed. But here, the difference is that with this kind of locks, you can still run all threads. But you do so in a way. Well, you run all threads optimistically and then, well, you need some bookkeeping to check what each thread really reads and writes. And then, at some point, you need to check if they actually did something that conflicted or not. And the hope is that in the common case, you did not actually get a conflict. And in that case, everything works fine and you succeeded in running your multiple threads in parallel. And in the hopefully rarer case of a conflict, you need to cancel and restart one of the threads. So this is a very, very high-level view. I should mention that here I'm talking about STM, which is software transactional memory. There is actually HTM that exists as well. That's hardware transactional memory that's implemented on the Haswell CPUs, actually. So the latest generation of Intel processors has HTM. Well, you also have some hybrid that are some clever implementation of STM that use HTM internally for some things. Most of these three different solutions are still mostly research only because, well, STM so far has a huge overhead, like the cross-checking of memory conflicts. And so on has typically at least two times, but more like four or five or ten times slower on the, well, per core. Then you have HTM hardware transactional memory, which is in theory great, but in practice far too limited, at least so far. I mean, in the current generation, it's too limited to support. I mean, we tried to write a PIPI HTM, but it gives the result that if you run a transaction for one bytecode, then you have a bit of chance that sometimes it's not too long. OK, so that's why I'm still focusing mostly only on STM now, really the software part. So, yes, here in this slide, I wrote easy in quotes, right? So let me explain why it's easy and which part is actually easy. The easy part is to go inside PIPI and replace the gil because you just replace the place that called gil a quarry and gil release by, respectively, start a transaction, stop a transaction. Easy. Now, the hard part is to actually write it as a library. How do you write all this STM on STM handling code? So, I mean, the point I'm making here is that if you actually think about it, if gil, gil acquire and gil release, that's also actually something that's not completely trivial, acquiring a lock. Acoring a lock is done with a library, that is, for example, on Linux, the Pifred library, and the Pifred library itself is also a bit crazy. I mean, a lock is, yes, OK, how to do a lock naively, yes, just one word, and I put zero for not locked and one for locked, yes, OK, naive. Yes, it works, but actually it's not how it's done at all because it's possible to optimise it far more using clever techniques. So, here I'm trying to make the same argument. It's easy to add correct calls to start and end a transaction in PIPI, but the hard part is to write the library. OK, well, here I'm presenting PIPI STM, but just mentioning this library here, that is a hard part, could actually also be used in C-Vython, which would be great, then we get C-Vython with multiple calls, cool, but there is one catch that's, what do you do about reference counting? That's the main catch. Well, there are solutions that are involved, hard, messy, etc. OK, I have a nice diagram to show how it works. So, the basic idea is that in this diagram I have two threads and I want to run things that are blue box, horizontal blue box. And, well, if I was, if I were running this code with a normal Python with a build, then we would get the diagrams with the boxes that, well, they cannot run in parallel, right? So, they take more time in total. Here with STM, they actually run in parallel, but the point is that each thread is running a bit independently by being very careful about what it changes. Well, mostly all its changes are kept local. So, this is what is done on the first part of the box. And then at the end of each transaction, each box, we do it in a special phase that needs this time to be synchronised across all calls. We push all changes so that all calls will see it. So, the effect that we get from the programmer is as if, well, in this case, as if we had three independent pieces that were running and these pieces were running here. Here, here and here only. So, basically, the three pieces run after, well, serially. You have the first piece, the second piece, the third piece. It just happens that the piece, the preparation to the commit of the transaction occurred before, and maybe did maybe a lot of work before. So, it means that a model, when you think about how it works, it is still essentially a serialisation. So, you still have one thread, then another thread, then the first thread that can commit, so that means that can produce the results that you can see. So, in this sense, it's exactly the same as the GIL. So, a PIPI STM works, feels exactly like a regular PIPI with a GIL. You don't have any additional issue in any additional races, conflicts, etc. OK, a small demo. Here, I don't have a PIPI STM, so I will just go through the sources. This is an example of a demo that was posted in the comments of the latest blog post. So, it's not from me, basically. If you have this isPriam function, and you want to compute how many of the numbers up to 5 million are prime, well, you do it like this. And then, if you want to do the same thing on multiple processors, then, well, there are several ways. For example, you can use a multiprocessing module. Then it looked like this. Yes, I think we'll just switch to another tool. So, this is using the multiprocessing module. So, it's doing the same thing in ranges. So, it's really using several processors. So, this happens to work because this prime is simple enough. However, it's not actually doing the same thing because, well, if somewhere in the PIPRIME.py file, if somewhere there was some global state or something like that, then it would not work the same way anymore because now you have two different processors. OK, so, well, I cannot run, I cannot actually run them and show time, but it's on the order. You have to believe me. This one runs about six seconds. Typically, it's 6.2 maybe. This one runs something like five seconds. I mean, the reason of head, right? So, it's not twice as fast. Then you can write a version using multiple threads. This is just bare bone threads. It's starting here import thread at the bottom, starting two threads. Then every thread, well, you have a queue to communicate the ranges. Every thread reads from the same queue, so it gets the next range to do. If we run this on top of a regular PIPRIME, then it gives us something like eight seconds. So, it means like six seconds, but with a bit more because there is a bit of overhead. If you run it on top of PIPRIME STM, then we get 4.8 seconds, which is the fastest I described so far, which is cool. OK, now the... Well, here I'm cheating a bit basically because yes, this example runs faster with two cores already, which is great. However, the numbers, all numbers here have been carefully tweaked to show this, right? Like if you change the detail somewhere, then it's three times slower. But the point is that we are getting there. OK, now what I just showed is, yes, you can use multiple threads on its cool and on its faster. Good. However, the real point I'm trying to push forward in PIPRIME is not... Well, it's not just that, yes, you can use threads on below in your maze of locks and debug them forever. The real point is that you can use threads on very coarse locking. You can have two transactions that run optimistically in parallel. I mean, here I just thrown you this diagram. So here is another time the exact same diagram. However, now every block is no longer just from one... from GIL-quad to GIL release at the end. Now it requires some lock that you define in your application up to release these locks that you define in your application. So you see technically there is no difference, right? It's just one lock. It's just another lock. However, the difference here is that you can now start to think about your application as it's starting multiple threads. It's using just one lock, this time an explicit lock that you imported from the thread module, but just one. And everything it does in all threads, whenever it wants to do something, it acquires this lock. Right? It's something that makes no sense at all, a theory. It's something that you wouldn't do in normal Python because, well, why use threads then? But the point is that you can do it and then it can optimistically try to parallelize by STM. So it means that, well, the thing I'm pushing forward here, the kind of program that I could foresee could be done with Python STM is really... Yes, it's still using threads on locks, but you put them in some corner of your program with just one lock. And, well, you have completely caused grain locking, basically, extremely. So, I mean, an example, here is an application that is traditionally not... Ah, I don't have it here. I have to wave my hands, sorry. Wave more, my hands. So, yes, this demo is about a bottle web server. I mean, it could be twisted, it could be tornado, whatever. So it is a web server which is traditionally not using threads. It works like you get a request from an HTTP request, then you are processing it, and maybe you're doing some complicated computation, and then you're pushing the answer. So the point is that if you just take one of these frameworks like Bottle, you add a thread pool on top of it. So every incoming request, you ask the thread pool by pushing something in a queue, you ask the thread pool. Now please process this request. So in that thread, you will actually process the request and send the answer back to the main thread with an other queue, for example. Then if you do that, then it can actually run... Well, Pybystium can run this program on multiple cores in parallel. And the point is that each of these single piece that run in the thread pool are run by acquiring one look, one global look. So it means that the different pieces appear to run one after the other. So it works just like you did not have a thread pool at all. But in this example, this is an example where it will clearly, mostly be... I mean most pieces will be able to run independently from each other. So yes, this is in summary what I'm trying to say, is that the Pybystium programming model, yes, it gives threads on locks that are fully compatible with the global interpreter lock. But it's... Here I'm not saying... Now everybody should use threads on locks. Here I'm saying you should make or use a thread pool library and use only coarse grain locking because that's enough for the Pybystium. So yes, for... Well, you have three different kind of applications that are immediate. You can have a multiprocessing-like interface where you can use a pool of threads. I think there is actually in the multiprocessing thread option instead of a process option actually. But that's a bit pointless because that's not running things in parallel normally. But yes, the point is that here you could have a multiprocessing.thread that works as I said by acquiring one lock. You can extend twisted tornado bottle. Like I explained, you can also... Well, this is maybe a bit further down the road but it's always the same thing. Like if you have a stackless or green light or G event system. So it's a system where you have coroutines basically but coroutines tend to do something independent from each other. So you can again do the same thing. This time you acquire and release a lock around the execution of one atomic piece of the coroutine, which means from one switch to the next, for example. So yes, the end result would be again something that continues to work exactly the same way as in you take your existing stackless application and it continues to work. But on multiple goals. Yes, this is the current status. The basics work. The best case of 25 to 40% overhead, which is much better than originally planned. I mean, it's really good enough so that usually with just two threads it's already faster. So this is overhead of unrunning only one thread. Yes, well, everything I just said before about the application level locks working the same way as a global interpreter lock is actually wrong. But it should be true soon. Now we have a walk around with atomic things that I won't explain. It's temporary. Yes, well, there are tons and tons and tons of things to improve. So yes, as a summary, this approach has potential to enable parallelism of CPU bound multi-threaded programs. Or I mean, it can be used as a replacement of multiprocessing or etc. It can also be used in applications that are not explicitly written for that. Like if you have basically anything that could potentially be replaced by a code to multiprocessing.pool.map. Yes, so the benefit is you keep the locks coarse grained. However, the issue is that you keep the locks coarse grained. I mean, this is something that has actually other issues that we as in me and me and Michael Walker were not very clear about so far. Will this work very nicely, completely in any case? I don't think so actually because you have the issue of... If you are running things that should be running parallel, but are actually not because, for example, both pieces would increase some global counter. This is enough to make the pieces conflict and then if they conflict, they are again parallel and serialized. So this is an example of systematic conflict. It means that if you take your program and apply what I said and expect it to go just n times faster, then it may actually not go n times faster at all. The reason is probably because of systematic conflicts. So it's something that we need tools to debug. We need a way to find where the conflicts are and figure out, oh, but here I'm incrementing this global counter. Let's fix it in that way or this way. There are debugging tools and profiling tools, et cetera. All this is not done basically. All this will probably be very much needed. So here if you want to compare this approach with the standard multi-threading approach, in a standard multi-threading approach, everything is fast, cool, but then things crash if you don't look correctly. Here at first everything is slow, but works correctly. And then you can improve. You can improve by detecting the conflicts and et cetera, but everything still works correctly as in works the same way as if you had only one thread, which I think is a very good approach, basically, especially for languages like Python. Yes. Yes, the performance I mentioned. Yes. So it's not production already. It's still alpha getting there. You can download at this URL the first release. It works on your Linux 64 for now. And yes, it's crowd-turning. Thank you. Thank you, Armin. We've got time for a couple of questions before the next session. If you've got a question, will you go to one of the microphones? Thank you. When you say coars walking, how coars of fine grain can it be? For example, logging library has a global lock internally. Does that mean that logging something once a second would already hit this performance penalty, or is it still okay? What are the lengths of the atomic block that... Where's the threshold, basically? Can't hear it? The question is, what is the threshold for coars walking? How long is it in time, the extraction? How long can a coars lock transaction run? The point is that in the PIPI STM I try to enable arbitrary long. There is no limit. I'm saying how short is too short? Well, if you really do it too short, then you will have the gel. The gel will be applied for a longer time. The limit is not important for the programmer. The gel offers a lower bound, and the size in the gel is tweaked to get the best performance. It's tweaked to be long enough so that making it even shorter would introduce too much overhead. Can you hear this? No. I'll come and ask him if you can repeat them. The overhead is fixed or proportional. If you're running just in pure interpreter, is the overhead pretty much non-existent? The overhead is... I can't tell so far because it's in development. But how foresee it is that the overhead should be 25% everywhere. You're relying on the jits to remove some of the overheads? Yes, the jits will remove some of the overheads, but then the base line is also much shorter so it's harder to improve. It turns out to be somehow similar. The other question is, you said you need to remove rough counting from C5. Why do I need to remove rough counting from C5? I think I will take the question offline because this is asked for more complex answers. Do you understand correctly that these two transactions come back the second one that we tried? What do you do with the actions that transactions did outside the Python? The question is, how do you roll back transactions that had already side effects? The point is that a transaction should not have side effects. That fits very nicely in the model of C5 because if you're going to have side effects like writes to a file, you'll read the deal. Here it means you end the previous transaction and you do is actually writing outside the transactions. Can you hear me away? At the other microphone over here. In Haskell's STM there are a co-binator such as a retry where you can take this STM transaction and say, okay, I would like to do this from the beginning. Do you intend to expose something like that? No. Here the real goal is to have STM internally and not expose it at all to the language.
Armin Rigo - Using All These Cores: Transactional Memory in PyPy PyPy, the Python implementation written in Python, experimentally supports Transactional Memory (TM). The strength of TM is to enable a novel use of multithreading, inheritently safe, and not limited to special use cases like other approaches. This talk will focus on how it works under the hood. ----- PyPy is a fast alternative Python implementation. Software Transactional Memory (STM) is a current academic research topic. Put the two together --brew for a couple of years-- and we get a version of PyPy that runs on multiple cores, without the infamous Global Interpreter Lock (GIL). The current research is based on a recent new insight that promises to give really good performance. The speed of STM is generally measured by two factors: the ability to scale with the number of CPUs, and the amount of overhead when compared with other approaches in a single CPU (in this case, with the regular PyPy with the GIL). Scaling is not really a problem here, but single-CPU performance is --or used to be. This new approach gives a single-threaded overhead that should be very low, maybe 20%, which would definitely be news for STM systems. Right now (February 2014) we are still implementing it, so we cannot give final numbers yet, but early results on a small interpreter for a custom language are around 15%. This looks like a deal-changer for STM. In the talk, I will describe our progress, hopefully along with real numbers and demos. I will then dive under the hood of PyPy to give an idea about how it works. I will conclude with a picture of how the future of multi-threaded programming might looks like, for high-level languages like Python. I will also mention CPython: how hard (or not) it would be to change the CPython source code to use the same approach.
10.5446/19940 (DOI)
Hello, my name is Andreas Wusserman and I'm going to tell you a lot about brain waves and how we as Python programmers can use our skills and tools to explore our mind. First a little medical disclaimer, I'm not qualified to give medical advice on certain medical conditions or treatments thereof, so whatever I say about these treatments, take it with a grain or salt and consult a qualified medical doctor if you need advice. First of all, what are brain waves? Well as you probably know, your brain cells communicate via electrical signals among other things and the effect of this signaling is that they send out electromagnetic waves. And if you sum all these potentials from all the brain cells up, you get a sort of summation signal that you can measure on the scalp. But as I said, every brain cell counts a little. That means you can't really isolate single cells. You can't even often, you can't even resolve certain brain regions with medical devices, with medical EEGs that is sometimes possible but also quite restricted. The signals are extremely weak and noisy and virtually every facial muscle has a stronger signal than the brain itself. Relatively early on in the 60s, researchers asked the question if you can actually consciously control your brain waves. And they did some experiments on cats. They trained the cats to exhibit certain brain waves. They just rewarded them for certain patterns and they were able to control the patterns by just holding very still. Later these cats were used in experiments to test epileptic medication or rather the opposite medication that elicits epileptic seizures and it turned out that these cats were actually more tolerant for these medications than other animals. So they were more resistant to epileptic seizures. Over the decades it has turned out that several studies really showed an effect for neurofeedback as a therapy for epilepsy but it's not really all that common today. Agency also is a very severe condition and so it's not really amenable for us as amateur brain scientists. The more important application of neurofeedback is in the treatment of ADHD which is an attention deficit hyperactivity disorder which is characterized by a short attention span by high blood pressure and high impulsivity among other things. The consequences are for example higher risk for depression and other conditions, lower academic achievement, social skills and delinquent behavior, higher risk thereof rather. This is not a complete discussion of ADHD because I don't have the time for it and it's very complicated condition. It turns out that the research around ADHD is highly relevant to general mental training and general training of for example mental focus or skills training. There's one part of the brain which is especially relevant and responsible for the executive functions of the brain for impulse control and for all sorts of positive features and that is the prefrontal cortex which is right in the front as the name implies. And also this is one of the most human brain areas because other animals don't really have all that developed in prefrontal cortex and that makes us pretty human. If you ever saw a dog you can't really hold his attention really long except with very good training. It turns out that all sorts of activities have been shown to actually train the prefrontal cortex for example meditation as in the form of awareness meditation which was propagated by Buddhism mainly but in psychology it often is called mindfulness training or mindfulness based therapy and in the most basic sense you would for example concentrate on the sensations of your breathing and you would try to focus on them but after a few seconds especially when you're a beginner you will just drift away and think of something else or your mental voice will go on and your concentration is away. Then you bring it back again if you notice it which can be minutes later. So it's a very simple to describe training but very hard to do. Wouldn't it be nice if there was a signal hey you're going off track, hey you are not focusing anymore and that is basically the idea of neurofeedback training. So a computer could give you feedback on your focus state but it has to have some way of telling if you're focused or if you're not focused. So that is done with EEG sensors and a big problem with these devices often is they are very expensive and not very practical to use. The company called Neurosky has developed an ASIC module which is sort of a board with a chip and it does all the amplification and translates it into a digital signal also already with some preliminary analysis which is relatively simple but works quite nicely. It is used in several devices about a million or so the company claims. For example these board games if you ever saw them here you can control physical objects with your brain. They never really took off and several people also said that this is sort of bogus but the chip inside at least probably does exactly what it is supposed to do. Here that is a very nice device. It's a headset with cat ears and these cat ears are mounted on little motors and according to your focus state these motors move which is sort of popular in cosplay. This is a MindFake Mobile. Several versions of this exist. One is a USB dongle wireless thingy where you have a USB dongle and this communicates with the headset. Here I have a mobile version which has a Bluetooth connection which is actually more useful but they all talk the same protocol because they all have the same chip. The protocol tells us about the raw signal, attention and meditation values. These are values which are computed inside the chip. The chip newest guy doesn't really tell us how they are doing that but I think it's about frequency bands. I go into that later and these attention and meditation values are just between 0 and 100 and this protocol itself is designed to be extremely hackable and therefore it is very concise. For example, if you hook it up to an Arduino, the Arduino is able with just reading a few bytes to tell if the user is paying attention or not. frequency bands, I'm going into that later, what they mean but essentially they are values computed inside the chip itself so an Arduino wouldn't have to do foyer transformation. Then there is a detection for blink events. As I said earlier, facial muscles all have stronger signals than brain cells so it's nice to know if there's a blink going on, poor signal detection essentially when the device isn't on or if the device detects no signal connection, it's nice to know. Now we are moving on to the live demonstration if it works. The first thing is to make a connection via Bluetooth. And I have to excuse myself because before I went into this room, I had a connection and I hoped it would stay that way. Now I have a connection. So also my review, I-Python live review doesn't really work as well as expected. Here I have a code sample, this is a feedback loop sort of code routine which I'm going to use later to do some feedback. I have written a parser that writes a protocol, reads a protocol and then it's, well, the loop here reads something from the Bluetooth socket then feeds it to the parser and then it yields back to the function, to the other function. And this is the most simple way of, it's the most simple form of feedback in which I just print out the last attention value if there is one, isn't really that fault tolerant but I have to, so. Now I'm working. Now the value is between 0 and 100. And it's somewhat more difficult to do when you're standing up. The first time I gave this talk, I was wondering why I had such a bad signal but it turned out that really the whole time I was practicing for the talk, I was sitting down and then I, it's a presentation I stood up and wondered why I didn't got a significant signal but it's really so that the problem is when I'm standing up, my face muscles are a little bit more stressed and the brain is in a different state of mind. It has to stay upright and balance and stuff. So biology sometimes confuses stuff. And also we will just also, yes. Do you think I'm frightened? I'm not afraid of you. And if you have live code, you can also mess up the code. Now this is a live animated graph. The way I am controlling attention is by sort of mindfulness meditation. I concentrate on my breathing. I try to consciously put this focus level on or this button. And also I concentrate on the area below my eyes. That sort of, that seems to work reasonably well. Now they, the, the new sky module computes a meditation value. I won't comment on if it's really meditation for me, what works for meditation is I think of something cute or adorable, smiling, smiling baby or baby animal and that sometimes that mostly works. Now there is something called brain computer interfacing. Brain computer interfacing means you would use this EEG device to control something else. Essentially it's the most basic level you would want to have a button. But the problem with these, both of these values is you should not only have a way to consciously push the button but also avoid pushing the button. And that is much harder to do. Now I'm going to show you the raw data also in the same manner. Yeah, that, we had a few frames which were relatively good. I'm now going to show you what happens when I move my eyes. And as you can see every muscle is stronger. Now I'm going to clench my teeth. And I can abuse this signal to, to some sort of brain computer interfacing but it's not really brain, it's really a muscle. And EMG is normally electro myogram and you would use other sensors but this also works. And I do that by parsing. So I'm taking about a quarter of a second worth of data. I compute the first order difference, takes absolute and then I mean it. So in this case I'm having, what happens now? Now the Bluetooth is again down. That is a good sign actually. Because then usually it makes a connection. If you wanted to program a real consumer-friendly app, this kind of, to automate this kind of connection would be high on the list to make that work. So I have two demonstrations left and how much time is left? Okay then I will do one more time, one more try to get it back working. I essentially need to wait for the blue LED to turn, to not blink anymore. And now it works. So on the top is the computed value and I have a cutoff in this example. I have a cutoff of 30 and then I can more or less consciously, mostly consciously turn the switch on or off. In more sophisticated applications you would use machine learning especially if you really wanted to use EEG data, not EMG data. But also this is a one-channel device so it has only one channel of measurement and usually brain-computer interfacing requires more data. But you can do some of it with just one channel. I now have to go back to frequency bands in more sophisticated analysis of EEG data. I think I didn't explain EEG that was electroencephalography or gram. The idea between frequency bands is that the brain-based tell us something about what the brain is doing and how it's doing it. And different frequencies will tell different stories about the brain but it is a very, not the relationship between what the frequencies mean and how you measure them. It's very complicated so I'm just giving a very superficial overview of it. The boundaries here I have taken from Wikipedia. Below we have data waves associated with deep sleep. Then there is 4 to 7 hertz setter waves, drowsiness and hypnosis. Age to 15, alpha waves are associated with relaxation and closed eyes. 16 to 31 in this case is better. Attention is associated with attention and wakefulness. In ADHD therapy, new feedback you would try to up train better for attention and down train better. There are other modes, there are other ways of detecting attention but that is one of them. Here I have a code example. There is a library called pieeeg that can compute various stuff among other things. The power of certain frequency bins. Here I have different frequency boundaries. They were, this vector was noted in the documentation. Here I'm calculating these values from about one second of data and you can try different lengths of time. On the one hand you want the frequency computation to be accurate. On the other hand you want to give immediate feedback at not after five minutes of running. Here I'm distracting this vector again into different values. Then I'm displaying just the better with the setter. Now the Bluetooth is acting up again. I'm not going to turn it back up because this was the last demonstration. Maybe I can consciously manipulate this value but it's a bit more tricky than the attention and meditation values. Now onto one of my favorite topics which is data science. I designed a little experiment. Now not reacting again. At home I recorded two sessions. One is a baseline session. One is a training session. During the baseline session I tried to not pay a lot of attention which is really difficult because paying attention is a very physiological thing and happens all the time, especially unconsciously. I just took five minutes of that data and I counted on that I was more often distracted. Then I recorded 15 seconds of mindfulness. I wrote both of these data to files. I just took the Bluetooth data and dumped it into a file and later I can pass it again for data analysis which means it's a bit more reproducible. If I have a bug in the parser and I had a bug before and then I correct it later I can reproduce my data quite easily. So here's the data as a histogram. I've taken several values of our time and well, especially in the top graph there are two modes. I think that is a data quality problem. So if I wanted to be more sophisticated about it I would have to exclude eye blinks and situations where I am not entirely confident about the signal because if you move the device or if you move your head and stuff then this affects also the data. We have a general sense that the bottom graph is a bit more to the right but it's hard to tell. We could do a t-test but as always Bayesian know it better. There is a toolkit on GitHub which does that with PyMC as an Mckov chain Monte Carlo engine and if I do that I think I have the code here. This is the best import, best plot and then I just sample the model. I already did that and then I can show this graph. So I don't want to go into too much detail on this but essentially these two histograms show us the posterior belief about what the model believes where the mean values should be. The 95% high density intervals, Bayesian don't like it when you call these confidence intervals but here in this case they don't overlap which is a good thing but the bottom interval is certainly a bit broader and that is because I just had 15 seconds of recording. So on to further ideas. You could explore brain computer interfacing some more. As I said it's very difficult to really design workable switches that work between sessions and between people. Another thing you could try is watching MOOC videos and monitoring when you are getting out of focus. You could make actual games. There are game mechanics. You could make the game mechanics that character jumps when you concentrate or you could make a shooting game where the jiggle of the gun is controlled by the attention. So the more attention you are paying the steady your aim. And bioelectric identification is to make basically a password. You try to identify the person just by their brain waves. I can recommend several courses but as I'm already a bit over my time I don't explain this anymore and I'd like to thank you for your attention. You can do some questions. So first of all thanks very much Andreas especially for his courage which is actually worth an extra plus making live demos. Everybody having a question please line up. There are two microphones from each side. Please line up and ask your question. If I want to start doing this right now and doing what you are doing on stage is the nearest guy thing what I should get or what do I start? I think there are several devices out there but the nearest guy mind wave is probably the cheapest and from what I have seen I don't own these other devices but this is really one of the most useful devices. It has a dry sensor. You don't need gel or moisture here to make it work and just needs the AAA battery with good for safety and it's also wireless. I think the mind wave mobile is the way to go. They have a more comfortable headset which is about double the price and for example if you wanted to use it while making sport or even sleeping that would probably be a better idea. How much does that one cost? I don't know of the top of my head but it's at least double the price. So this costs about 110 euros and the other one about 200 or 300. I think the next question goes. So the question I have was as far as you were mentioning resolution or trying to get better detail is that something the fact that you could have, would a second sensor work or if you basically took what the nearest guy one and effectively had a separate sensor on a separate part of the head would that help or would that are you looking for is there needs to be more? Essentially to get more channels with these devices I think you can't really mount several of these devices on your head that would look kind of stupid but I think they offer these modules as developer kits so you could, if you are a hardware hacker you might be able to hook something up but that's complicated. So fundamentally when you say the different channels it would be different parts of the brain you are looking at. Yes you would get more spatial information but that is also a bit restricted. Okay, thank you. I've got two questions. First is how much data per second or minute in bytes does this device produce? Roughly. I don't know of the top of my head but five or ten kilobytes. So we are talking kilobytes. I think yes but that's mostly the raw values. You can really discard most of it if you don't want the raw values. And have you locked the brain waves while drinking beer? Not yet. I have a question. Would it be possible to trigger different switches with different feelings? That is certainly a machine learning question and I don't even know if you can develop a reliable switch with just one channel. That is certainly more, this requires more work. That's really something of a classification and not especially not over training on the conditions that you are actually using. And you have danger there that you overfit on your current thoughts. So you might try to distinguish between two different thoughts and then some other thoughts do the same thing. And you don't know it before and it's really tough I think. Thank you. Yes, so thanks again. Andreas Klosserman, first door.
Andreas Klostermann - Brain Waves for Hackers Using the Neurosky Mindwave headset we can read brain waves via bluetooth. In this talk I will present ways to interface with this device and to analyze their data, mostly from the perspective of a Python hacker, and not so much from the perspective of academic research or the development of production-ready software. I will convey the basic scientific and technical background, keeping in mind the non-medical audience, and touch on several practical applications, especially Neurofeedback and its use for personal mental training and potential therapeutic uses. The Audience can expect to walk away with a basic knowledge of EEG analysis, Neurofeedback and how to start experimenting with these devices on their own. ----- A new class of cheap consumer EEG devices allows ordinary hackers and even high school students a glimpse into the human brain. This talk will present how to use the "Neurosky Mindwave" headset with python software, and lay out the basic scientific and technical background. The Mindwave Mobile is a device that can be easily talked to using bluetooth, and it talks a binary protocol which is specifically designed to be useful without much computing power in the receiving device or advanced knowledge of signal processing. In fact, an Arduino with a few lines of code is perfectly capable of parsing some of the byte stream and reacting to the mental state of the user, while fully-featured python software can do advanced analysis using PyEEG and Pandas. The same hardware module and protocol is used in the Nekomimi headset (mind-controlled cat ears for cosplay) and some Boardgames (MindFlex). A python library for interfacing with the headset is presented and will be demonstrated on stage. Mostly kivy applications will be used. Also I will present some data analysis you can perform with pandas and scipy. Neurofeedback is a type of mental exercise where a computer uses the EEG data to direct the user towards certain mental states. In the easiest configuration a program would display a bar with the "concentration" level, and the user would learn how to tilt this bar upwards. In more complicated setups a game could react favorably towards states like relaxation or concentration. Using Gamification, Neurofeedback can provide a more engaging experience for children or adults, than other techniques with similar goals, like mindfulness meditation, and the more immediate feedback should enhance the effectiveness of mental training, though that has not been investigated scientifically yet. Neurofeedback has been shown to be effective (albeit not recommended as sole treatment) in Patients with Attention Deficit Hyperactivity Disorder (ADHD), Epilepsy and Dementia. Some background about these conditions and applications of Neurofeedback to them will be given. The first use of Neurofeedback was done in Cats, during early experiments with EEG electrodes in the 60ies. Cats where conditioned to exhibit certain wave patterns, and later, due to a coincidence, the researchers noticed that the conditioned cats where more resistant to epilepsy-inducing medications. The effect has since been reproduced in humans, in cases where medications did not work sufficiently. Ample hints on not to treat any of this information as medical advice will be provided. The goal of this talk is to promote Neurofeedback as a useful mental training and to encourage development of applications around Neurofeedback and the analysis of EEG data, from the perspective of a python hacker. I gave a similar talk at PyConDe 2013 in Cologne. The new talk will be in English, show some improvements on the software, and more advanced demonstrations.
10.5446/19938 (DOI)
Hi everybody. Good to see you here. Today I'm going to talk about Pony ORM. But before I get to that, I would like to tell you why we are developing yet another mapper in the first place. In my previous life, I was a technical lead with a New York financial company, New York-based financial company. My co-founder Alexander has been interested in object databases since we were students. Databases became his passion, the area of research and teaching at the University of St. Petersburg. At some point, he came up with an idea of creating an advanced object relational mapper, handy and efficient. He shared this idea with me and I just love the idea. After years developing products for such a dynamic field as finance, I saw the need for such a tool. If there was one, I would use it myself. This is how we started working on Pony ORM together. As you know, Pony is sturdy, smart and very friendly breed of horse. And so is our mapper. It is sturdy, smart and user-friendly. So what makes Pony different from other mappers? First of all, it uses generators for writing database queries. This is an example of a generator. We get the product names with a price over 100. And this is the same query expressed in SQL. As you can see, the generator looks similar to the SQL query. Let's highlight the common parts. The select section, it goes to the result list. The from section is similar to the iterator section. And finally goes to the condition. But this similarity is only in syntax. The behavior is completely different. A regular generator, it raises over data, starts in memory. While a SQL query selects data from the database. Imagine how cool it would be if we used generators for writing database queries. This is exactly what Pony does. Here's an example of query in Pony. The select function provided by Pony, it receives a generator as a parameter, but it doesn't execute it. Instead, Pony gets the generated byte code. It translates it into SQL. Then Pony sends this query to the database and creates objects in memory based on the query result. This function returns a list of objects. The product is a class which is declared earlier in the code. It represents the product entity. And it's mapped to a corresponding database table. So let's compare the Pony syntax with other mappers. Here's the query in Pony. We select products with multiple conditions. The product name starts with A. The product has no image. Or instead the previous two conditions, the product was added before 2014. In Pony we iterate over the product entity. See how can we use standard Python function for example. A name is a string so we can use starts with function. And edit is an attribute of daytime type. So we can use the attribute here. This is the same query in Django. The product class in Django has the objects attribute. It is a manager which is used for querying this object. In our example we have both and or conditions. We can express and condition just providing a list, a comma separated list. But in order to express or condition we have to use the special queue object. And then we combine those conditions with a bitwise or operator. In Django we have to use double underscores in order to apply specific conditions such as starts with is null and less than. In SQL Alchemy the same query we look this way. We get the session object and make the request to the product class. In Pony we would use the P variable in order to apply the conditions. But in SQL Alchemy we use the product class itself. In order to get the year from product edit attribute we need to use the extract function. Also we have to put a part of our condition into parenthesis in order to keep the precedence of the bitwise operators. If we compare these queries we look that they are pretty similar in terms of length. Some people like Django and some people like SQL Alchemy syntax. But we like the generator syntax because it's easier to remember. It is the native Python syntax. You work with objects which are stored in the database like they were stored in memory. It makes the development easier. Also using generators is more performant than query translation Django or SQL Alchemy. That's happened because in Pony the result of the translation is cached. The select function receives a generator as a parameter and the generator is a standard Python object. So we can use it as a key for getting the result of the translation of this query. In Django and SQL Alchemy there is not such a key because the filter function just receives a set of parameters. And that is why we necessary to translate this query every time in Django and SQL Alchemy when we execute it. Pony makes the translation of the byte code only once. With other mappers you can build query step by step. How is it possible using generators? Pony also allows query step by step. This is done with the help of the filter function. It receives a lambda expression as a parameter. This function turns a new query object which is applied condition. In this example we add a couple of conditions then order the result and slicing it. You can see the result of the last applied condition of the slicing. Now let's see how Pony translates generators into SQL queries. Some people may think that it is complex process and it's too much magic in it. I want to show you how it works so you can see that it's pretty fast and straightforward. The translation process consists of three steps. The first step is to get the generator and its code object. As you know Python doesn't provide abstract syntax tree for generators. So we have to restore it from the byte code. The second step Pony translates this AST into abstract SQL. It is intermediate representation of SQL. It is almost SQL but it's not a SQL query text yet. Because databases they have some peculiarities in terms of representation of SQL queries. And different dialects can vary. So that is why we don't want to over complicate the translation part. We just put it as another step. So the first step is the compilation of the byte code and restoring abstract syntax tree. For the compilation Pony uses an object which implements the visitor pattern. It has a set of methods and each method name corresponds to a byte code command. We go through the byte code from top to bottom and call the corresponding method. While executing the byte code we accumulate it on a stack. Let's say we have such an expression. And now we are going to translate it to SQL. We get the byte code from the generator object. And this is the stack where Pony will accumulate the AST parts. Now we process the first command load global. We call the method of the visitor object the same name. And this method pushes the name node to the stack. The next command load fast. The name of this command is different from the previous one. Because it loads a variable from a different namespace. But for the translator it does the same thing. Just load a variable. Pony pushes the corresponding AST node to the stack. The next command is load other. This command we apply to the top of the stack. We wrap the existing node with the new one. Get attribute. The binary add command pops two stack elements and then pushes the binary add command which wraps those two existing nodes. It combines the previous two. Then we load the X attribute, the X variable and get Y attribute of X. And finally we pop two stack elements and push the compare node which combines them. As you can see this process is very straightforward. It doesn't have too much magic. And usually generator code is not that long. Also we don't need to build the whole decompiler here because generator just has subset of Python by code operations. As a result of the first step we get such an AST. It is a tree representation of the same expression. The second step is translation to abstract SQL. But which SQL should we build? Can we tell that just looking at this expression? It depends on variable types. For example A and C can be strings or numbers. Why could be a string or a collection? If A and C are numbers and Y is a collection then we should generate an American addition and a sub query. If they are strings then we should generate the string concatenation. If Y attribute is a collection then we should use a sub query. If all of them are strings then we need to use concat and like operators. If we analyze all these variable types inside the translator we will have a lot of if then statements inside the translator and it will over complicate the translator itself. It will have to maintain and extend such code. So we should somehow structure the logic of our translator in order to keep the translator simple. And for this purpose we use monads. A monad is a container which includes translation logic. Each node type has its own translation logic. The translator walks through the tree and delegates the translation to different monads. Each monad accumulates data and generates a part of a SQL query as the result. Pony has different monads for different types for different attributes. Each monad defines a set of permitted operations and also how it will be combined with other monads. Each monad generates a particular part of the resulting SQL query. Here I show you different monad types. We have a lot of them but just some part of it. String monads know how to make operations with strings. For example, this string other monad can generate a join operation and string monad puts a string parameter into a query. Using monads keeps the process of translation simple. We walk the syntax tree and we process each node when we exit from the node. We walk the tree all the way down using the depth first strategy. When we enter the addition node, we don't have all the necessary information for generating SQL yet because we don't know types of nodes which lay lower. We continue walking the tree all the way down. When we leave the node, we create a monad. Let's say that A is an external string parameter. Then we create a string parameter monad here. Then we walk further. Before leaving the node, we create another monad. In our example, B is an iterator variable. So we create the object iter monad. This monad knows on which object we are iterating in our query. Then we walk further. Then the translator processes this node. It doesn't analyze the node at all. It just delegates the get attribute operation to the previously processed monad. It says to the object iter monad, get the attribute C from yourself and create a new monad which will be a result of this operation. It creates a string attribute because it knows the type. Then we walk further. Now the translator gets the left monad and says, add yourself to the right monad. By this time, we know all the types of operands. We create a string expert monad. This monad can generate the part of a sequel for this green nodes of our tree. This way, all the processing logic is encapsulated inside the monads. It helps to keep the translator simple and we can easily extend our translator by adding monads which can handle new types, for example. So we walk further. And at the end, we have the top level monad that has the generated sequel for the whole tree. Here the abstract sequel that we get as the result of the translation. It is stored by a list by now and it reminds list structure. So the first element of this list is a comment and then goes up around this comment. For example, this like comment, the first parameter is the column Y from the table T1. Then goes the function concat which is followed by four arguments that should be concatenated. By this moment, the process of the translation is almost done. The last step of the translation is to translate it to a specific sequel dialect. This is a very simple step. Pony has a set of database providers and those modules keep the knowledge of the database peculiarities when it comes to sequel syntax. We walk our list structure using the visitor pattern again and combine the resulting sequel into a query stream. Here you can see the result of the translation to my sequel and sequel dialect. What other features? This is it with the translation. So this is the last step and we got our sequel query which can be cached and sent to the database. By this time, my problem is what is needed. And now I would like to tell you about other Pony features. Pony keeps the objects in the identity map. It means that each object is loaded only once within the same database session. When we try to get the same object again, no query goes to the database. It will be returned from the map. Pony also has the N plus one query problem solution. This is when the marker generates a lot of unnecessary queries. I'll show you in a minute how it works with Pony. Pony can optimize queries. For example, it can substitute a sub query with a left join in order to improve performance. Also Pony can work with the database using pessimistic and optimistic concurrency control. The pessimistic approach is when we log a row in a database in order to prevent it's modification by another transaction. With optimistic approach, there is no luck. Before committing, Pony just verifies that no other transaction changed the value of the attributes which it read. And Pony also has online entity relationship diagram editor. You can build a diagram of your application online and get the code for your entities or SQL scripts for creating tables. Let's look at this example. Say we use Django and we want to select a couple of students from the database. Also we want to print out their names and their growth IDs. How many queries will be sent to the database and how many objects will be created after we execute this code? Let's see. After the first query will be executed, a student object will be created in memory. When we access the growth attribute, the second query will be sent to the database and the second object will be created in memory. Now we create another student object. Let's say that both students belong to the same group. When we try to access the group attribute, Django will create another group object. It is a copy of the existing one. This happens because Django doesn't implement the identity mark pattern. Each object exists independently and Django doesn't track if a similar object was already created. Let's see how it is implemented in Pony. The Pony syntax is a little bit different. As you can see, we use square brackets in order to get access by primary key. After we execute the first line, we have the following. A query went to the database and an instance of a student was created. Now Pony sees that there is a group object which is associated with this instance. It means that this group ID exists in the group row in the group table exists in the database. Pony didn't allow this object yet, but it knows that it exists for sure because it's consistent database. Pony creates a seed object. This is how we call the object which has only its primary key. The other attributes were not loaded to this object. It's just like a seed of an object. Using this concept of seeds allows us to make some optimizations. For example, if you don't need any other attributes, but just group ID, Pony will not send any other request to the database because the primary key of this group is already known. If we would like to get any other attribute of group, then the request will be sent to the database. But in our example, we don't need to send any request because the ID presents in the student table itself. Then we lower the second student and Pony sees that this object has the same group ID and it links it with the same seed. If we need to get an attribute of the group object for one or both students, Pony will send just one query to the database. But there is the probability that we don't need to send any other request. The concept of seeds allows us to solve N plus one query problem. Let's say we have an online store and we want to get customer orders which have the total price of the order greater than a thousand. In this example, we use the order by method. We sort the result in the descending order because we want to see the last customer orders first. Also, we are getting the first page of the result. The page method is just syntax, sugar. We can use slice, but it's more easier to use the page because usually we want to show the results at the web page. This is the SQL query which will be generated for the first two lines. When we start it rating over the order list, in this case, most mappers will run into the N plus one query problem. It is when a mapper will generate a separate SQL query in order to load each customer in order to show its name. N here is a number of items in the orders list. Pony will work this way. The first query allows orders to the memory and Pony creates seeds for all customer objects. We can see what customers might need if we iterate over the list. When we iterate over this list, we get the first customer attribute. Pony allows all the seeds objects with one SQL query instead of N queries. This query selects all customer objects with the ID belonging to the list. In terms of query cost, it's not a big difference if you load one row from a table or 10 rows. The performance degradation usually happens when we do a lot of database round trips. Of course, there is a probability that we don't need all the objects. But usually in the web application, we don't load thousands of objects. We just load some part of it in order to show it a web page. That is why if we load all the objects by one query, it increases the overall mapper performance. In Django, we can use select related or prefetch related. Other mappers also have a similar feature. The thing is a programmer needs to think about it himself. Sometimes new programmers, they put select related everywhere where it is needed and not. If you put it everywhere, it has performance. But if you don't put it where it is needed, it has performance too. Having this concept of seeds allows us to avoid N plus one query problem automatically. You don't need to think about where you need to put it. Actually, it's a smart way to do prefetch related. Also, if you use select related, it generates queries using join in order to join all the necessary attributes from other tables. If you do a lot of joins in a database, it can be less performant if you just select data from one table. When we select those customer ideas and customer objects in a separate query, we can join those records in Python and it can be more performant and more scalable. Another thing that we have in Pony is automatic query optimization. Here's an example. When we translate this generator to SQL, we get this query. This query has a subquery and it is called related subquery because it uses values from the outer query. The related queries should be evaluated for each row selected from the main query. It can be inefficient. There is a well-known technique of replacing related subqueries with left joins. Pony does this optimization automatically. Now let's talk about transactions. Let's say we need to write a function that transfers the specified amount from one account to another. If we use Django, we could start with something like this. Here we get the first account object by its primary key and check the available amount. If there is not enough funds, then we raise the exception. Otherwise, we get the second account, decrease the first account, save the object, increase the second account and save the object. Are there any problems with this function? The problem is that these two account operations are not performed in the single transaction. We have two separate transactions here. If we lost the database connection after the first save completed, we can leave the database in the inconsistent state. We can, of course, solve this problem and add the decorator transaction atomic. Did it solve the problem? Not necessarily, because this function can still override data if they were changed by a parallel transaction. When we do save, it doesn't take into account if this data were changed by another transaction. We can have the database in the inconsistent state again. In order to avoid this, we can use a special F function or lock the records in the database. For this purpose, we can use the select for update method. This way we lock the records in the database and no other transaction can change them until our transaction is finished. The inconvenience is that a programmer needs to specify the select for update method explicitly. Often an application consists of several tiers and in more complex applications, we can get data in one tier and then pass it to another. At that point, we can just miss this knowledge and we might overlook the point where it should be locked in the database. If we use select for update everywhere in order to avoid this problem, it again will hurt performance. In Pony, you can use the select for update method too, but besides this, Pony uses the concept of optimistic locking. Here's how we can write our function Pony. The DB session decorator is mandatory when we access the database. It wraps the database updates with a single transaction. We get the first account object and check the available amount. If there is no funds, we decrease our account and increase the other one. You can see that there is no need to call the save method because Pony tracks the objects which were changed due to using identity map. All that changes will be sent to the database automatically when we leave the scope of the DB session. What will happen if a parallel transaction changes the amount of any account? Pony tracks the attributes which were read and written during the transaction. When we read the attribute amount of the account object, Pony remembers the old value of this attribute. Now when we save the updated value to the database, Pony adds additional where condition with this check. The update query returns the number of rows which were updated during the operation. If the value was changed by a parallel transaction, then the update SQL operator will return zero. That means that other transaction changed the value. We have to roll back the current transaction in order to avoid the database inconsistency. This approach is called optimistic locking. We don't lock the object, but we keep the old value of each attribute which we read or wrote. When we commit this object to the database, we verify that this object holds the same state. This approach is more performed in scalable than locking the row in the database. It allows more parallel transaction to work simultaneously. Pony helps to avoid lost updates and keep database consistency automatically. Even if a programmer didn't take measures, when the DB session decorator will lose the scope, it will check if the database is in the same state. Another thing which we have in Pony is entity relationship editor. You can create ER diagrams for your applications online. This editor has several tabs. The first tab is where you can design your diagram. We represent entities with rectangles. Also, you have attributes, data attributes, and relationship attributes. In Pony, you specify relationship with both attributes at both sides. Here we follow the rule, explicit better than implicit. It is easier to see what attributes the entity has when you look at it. Here you can see that relationship, we use a line in order to depict the relationship. If it is a relationship too many, it has fork at the end. Also, you can switch the tab, get the second tab, Python code, and you will see the Python code of your entities. And there are several other tabs where you can see SQL scripts for creating tables in the database. So those are main features which I told you today. We have generators and lambdas for database queries. Pony implements the identity map. It has a solution for N plus one query problem. It has automatic optimization of query queries, optimistic transactions, entity relationship diagram editor. And here the roadmap of Pony RAM development. At the moment, we are working on adding Python 3 support because it is the most often asked feature. Then we add in Microsoft SQL server support because at this moment we support only four bases, SQLite, MySQL, Progress, and Oracle. And we were asked about adding support for Microsoft SQL server. And after this is done, we will add migrations and asynchronous queries support. This is it. Thank you very much. Do you have any questions? Hello. Can you return to the slide with DB session decorator? Oh, it's okay. With the DB session. This one? Yes, this one. How it is done? It is thread local, so something like that. Okay. I didn't quite understand that question. I hope you have a question. I think it's a good question. I think it's a good question. I think it's a good question. Yes. This one. How it is done? It is thread local, so something like that. thread local. Okay. I didn't quite understand that question. I hope I am not asking the same question again. If this now fails because the second, so the update is not done because there was some other thing, will it automatically retry to do the thing or will it just fail? You can specify the parameter to this DB session decorator or it can be used also as a context manager. You can specify retry for example 3 or 5 and it will retry. In the N plus 1 query solution, how does Pony know for which items in the second query to load the values? Well, when we execute a query. So you do the first query to load the orders? Yeah. And then you have the second query for the customers? Yeah, because order has a relationship to one. Each customer has a relationship to many. Let me show the diagram. So this is the diagram which I used for that example. See when we go to orders? Yeah, I understand that there is a relationship. But how do you know for which customers will be in the loop? Do you just? We don't know where we are going to loop over. We just create seeds for those objects which it has a relationship to one. And when we start iterating all these objects, we understand that it might be needed all other objects. So you show you load them if there is one customer don't name, you load the name for all the customers? Yeah, when we send this request to the database, it's not a big difference. We will load one row from this table or 10. It's not a big difference in terms of performance. So then you load for all the orders or customer seed objects that exist? Yes. We have all the seeds and then we load using this query you see the last line where CID in the list of IDs. And then you load for all the seeds that exist? Yes. It seems to me that after you have realized the seeds, so they have become objects, there's a lot more caching happening. And I can imagine that that can also be very dangerous to you. You're using weak references or I mean how do you know that after you have fetched all these customers that they can be and use somehow globally cache them so that other queries, okay. So for order one, you select the customer one and you realize it. And then for order three, you have some global reference to it so that you can fetch it again. Yeah, I think I got your question. But you know this identity map, this cache exists within one transaction. So when we start our transaction, we use dbSession and when this dbSession scope is over, we just free the cache. So and usually, you don't work with millions of objects when you build an application, right? You don't use millions. You can use bulk update if you want to update or work with millions of objects. Maybe you load say 10, 20, 100, maybe a thousand in order to show the web page. And in this case, it's not the big amount of objects we have. Hey, comparing MySQL and SQLite, for example, MySQL has strongly typed columns and SQLite allows you to insert any data type that you want. How do you handle these heterogeneous data types or do you just disallow them or what do you do? How do you hold one? In SQLite, you could considerably stick different data types into the same column. SQLite allows you to do that. How do you handle this in your mapping? Do you only allow insertion of specific data types or whether you filter them out? What happens really? When we specify the type of object, sorry, I didn't quite hear what the... Okay, let me restate that. In MySQL, your column specifies what data type will be contained within. In SQLite, the column type is just a suggestion. You can still have different data types with this integers of text or dates. Okay. How do you handle that? Well, in Pony, we have different DB API providers. In terms of Pony, all those types are exactly the same. This DB provider takes into account some peculiarities of the database. We use the Python notation of daytime. We represent it the same way in SQLite. Maybe you're talking about the difference in microseconds, for example, with this type in MySQL and SQLite. Pony takes into account using this layer over the DB API driver on this particular DB API provider. We handle that. Hi. Is it possible in Pony to iterate over results without having all the results in memory? Just pick up. I'm sorry. Is it possible in Pony to iterate over results without having all the results in memory? To iterate over... Like with a database cursor. So you mean don't load all the objects to memory, but iterate just in the database? Yes. We need that if we want to update a lot of records at once, right? Bulk update. For that purpose, we have one method. But recently we were asked about adding just a little bit more. We are going to add more functionality to that so you can update objects without loading them to the cache. So I guess we have time for a last question. Okay. You mentioned on one of your first slides that it was fast, this particular ORM. So what makes it fast and how does it compare to others? Do you have benchmark data? We ourselves didn't create a robust and good test yet. We definitely are going to do that. But other users, they tried to compare that and they said like three, four times faster. Why it is faster? First of all, it's because we can cache the result of the translation as I told. Because in Django and SQL Alchemy, there is no way to understand that we execute the same query. And when our program is being executed, we can see that this is the same generator. It has ID, right? So we can immediately understand that we don't need to translate it once again. We just can get the result from the cache. And also, when we develop Pony, we are very picky in terms of working with references, objects. We don't do deep copy a lot. We just pay attention to details when we just use low footprint in terms of resources when we need to, when we work with object with cache. We try to take into account the performance is one of the goals which we have in our mind. Thanks a lot for your talk. Thank you. Thank you.
Alexey Malashkevich - How Pony ORM translates Python generators to SQL queries Pony ORM is an Object-Relational Mapper implemented in Python. It uses an unusual approach for writing database queries using Python generators. Pony analyzes the abstract syntax tree of a generator and translates it to its SQL equivalent. The translation process consists of several non-trivial stages. In this talk one of Pony ORM authors will reveal the internal details of this process. ----- [Pony ORM] is an object-relational mapper implemented in Python. It allows writing advanced queries to a database using plain Python in the form of a generator expression. This way queries look very concise. The main feature of Pony is to provide a method to write declarative queries to databases in pure Python using generators. For this purpose Pony analyzes the abstract syntax tree of a generator and translates it to its SQL equivalent. Following is a sample of a query in Pony: select(p for p in Product if "iPad" in p.name and p.price >= 500) This query translates to SQL using a specific database dialect. Currently Pony works with SQLite, MySQL, PostgreSQL and Oracle databases. In this talk one of Pony ORM authors will go through the process of the query translation and dig into the implementation details. Attendees are going to walk away with the understanding of: 1. Principles of building a programming language translator 2. Python to SQL translator implementation details 3. Approaches for creating a pluggable translator architecture The presentation outline: - Why Python generators are good for representing SQL queries - Main stages of Python to SQL translation overview - Decompiling Python bytecode into Python AST - Translating Python AST to database-independent SQL representation - Generating SQL for specific database - Pluggable translator architecture - Performance concerns: is such way of building SQL slower or faster then Django's and SQLAlchemy's?
10.5446/19850 (DOI)
Nid o'r ailer 실제로 am g....ynd hold ond letter a naddwyd yn Based that various events field throughout the year and since 2015 she....N Walking Access Ave M ydi maland wedi'u igoedd gondol rhag CRSYL Young Dwi wnaeth amlaen fyddeusio, bob wnaedvious of..) Dwi ddarparu o'i rhai reb transactions a hebnodbwys Cexiserion to scientific articles published in journals which are published by us. Excuse me. Before I started, I just wanted to introduce you to Copernicus, because I don't know whether all of you know about it because it's a rather small publishing company. So basically it was founded in 1988 as a spin-off of the Max Planck Institute for Solar System Research. And since then has been involved in the organization of various scientific conferences and of different sizes. So this is one of our business parts. And in 1994 we started to be a scientific publisher. And in 2001, so very early, shortly after Biomed Central, who was the first commercial open access publisher, we started our first society open access journals. So we mainly worked together with the Learned Societies in publishing the journals. And we also with other scientific institutions, but we almost do not own any journals ourselves. So as I said in 2001, we started the first open access journal. And after that we moved all the other journals we were publishing to open access. And now also all new journals joining us are published as full open access journals. So now what I guess we publish 38 open access journals and we have 18 access review discussion forums because we have a special or these journals have a special way of conducting peer review where the public discussion and an open access discussion forum is part of the peer review process. As I said, most of the journals belong to Learned Societies or scientific institutions. We have 50 staff members in our offices here in Göttingen and we follow a straight in sourcing strategy, so typesetting, language copy editing, editorial support, programming of our software, everything is done and house, which is not so common in the publishing world. Copernicus is co-founder of the open access scholarly publisher associations, but we are also a member of STM, which is another publisher association, a member of ORCATE, and we also partner with OpenAir. Just to give you a small impression on how large we are, last year we published about 8400 articles. So basically scientific research output does not consist only of the article itself, but also of the underlying data, the model code which was used to evaluate this data or to come to a conclusion. Of course, also samples which were the basis for the research, but also video supplements or video abstracts. Might be, don't have to be, but it's possible. So we at Copernicus try to see the publishing of research outputs as, because we are an open access publisher, as open science, as a principle. What we mean by that is somehow we see the gold open access article as a trunk, but all the data sets, model code, video samples, and other, we call it assets, as branches of the research tree. So we think seeing all this different research output would work becomes a really publication cluster, but the important thing is that really all components are linked to each other. So, of course, the best practice we think is to deposit such assets in reliable repositories, which provided EOI and not just a web link, but also these non-textural resources should be added as a propocitation in the article and into the reference list. And what we do to provide better accessibility of all these assets is to include what we call an article asset tab. I know hopefully this is working because I just wanted to show you. Just a... Okay. Just an example. Okay. So you see here you can access the article here. You can access the peer review. As I said, all phases of the peer review here. We, of course, provide metrics and also provide related articles. But what I wanted to present to you today is these asset tabs. You see for this paper, for example, you have the supplement which is on our side, so maybe some tables that you did not want to include in the article, but they have it. But then they stored their data sets on a repository, in this case, Cenotro. And they also said, okay, we have different video supplements. And, yeah, they also stored them. And I'm coming to that later. But you see here you could also add other assets of this article. Okay. Okay. So, but today's topic is scientific videos, so I just want to concentrate on them. As we heard before, YouTube definitely is easy to use. But there are some things which really should prevent people from using it as a place for scientific videos. So there's no guarantee for long-term accessibility or preservation, no license management. It's difficult to cite because there's no guarantee that the link will stay the same, for example. And there's also no back-linking possible. And as I said before, we think it is really important that the article and assets are linked and vice versa. So YouTube is not an ideal solution for any scientific video. So we were lucky enough to have the opportunity to collaborate with the TIVAV portal. They offered us to host all videos related to articles which are published in Copernicus journals. This might be video abstracts or supplements. All of the videos get a DOI. Linking from the article to the video and back from the video to the article is guaranteed. There's a sort of creation because beside automatic analysis of speech, images and text, also the people working at the V portal make it like not a content peer review, but some kind of creation to guarantee that it's really scientific content and nothing. So that was just really nice. So what we experienced since we launched this collaboration was that it was mainly used to the opportunity to deposit supplement videos. For example, they have different model runs. So you see again, this is on our side, and if you click on the DOI, you are directed to the respective video in the AV portal. Here you see those of this paper use the opportunity of video to just make a visualisation or animation of a model run. For this paper, there are different model runs and they are resulting in different kinds of animations. But they also use it as a visual opportunity to clarify processes, for example. So we just have a paper here and the process which should be showed is like... It's really short but it somehow explains a bit on what the paper analyses. But we also experienced that for all also most videos are without text. Just to show you briefly another example. So here we have a soil science article. Here you see... we ended up on the peer review. The different version of the manuscript and the referee reports can be viewed here. But also it's connected to video supplement. Oh, they added a video abstract. I did not realise that that must be recent. What they are basically doing is just... They are the film of this kind of erosion to demonstrate or clarify what they are about. But as I said, no text. So a lot of the potential from the AV portal to make this automatic speech analysis, for example, is not yet used, I would say. I did not look at the video abstract because that must be new. I did not know that this paper is connected also to video abstract. So it's only one video abstract until now. But we found already 54 videos related to 17 articles which were published in 10 journals. So already some acceptance from the community. And I would like to conclude that reliable media presenters as the TIB AV portal are an ideal hosting solution because they provide everything which is needed from a scientific point of view, including the UI. However, there is still a lack of acceptance by the authors to cite and reference non-textual materials. And this not only affects videos, it is still to a certain extent also affects data. And data are already much more common in having data as a non-textual resource, but there are still authors so confused when we are asking to do so, when we are asking to include it in the reference list to cite it in the text, not linking to the supplement but saying, hey, this is a citation. So this is really something also hesitant about. And since we almost have no video abstract, which we think could provide a new gateway to the scientific work, especially in open access journals, because there you have really broad audience, because potentially the whole word could read the article. So videos might open up another gateway, but I think advertisement for this is needed. And I was asked to let you know that if you are interested in more examples of how the AV portal is working, there will be a station outside in front of the door of this room where you can get a demonstration. So this for now. Thank you. Thank you for this very practical and useful example, I have to say. I mean, that's inspiring to see that things are being picked up and implemented in a proper way. So do you have some questions to Senia straight away before coffee? I'm Bianca Beck from the European Petent Office. How do you deal with the copyright of these videos and the supplements? That's a good question, because luckily for the... So our articles are published under Creative Commons attribution license, obviously, open access. And in the TIB AV portal, users can choose a license. The CC by licenses is the one we just recommended, but also other CC licenses are available. And the users can choose that. But since it's mostly the case that this is like an own production of the user, nothing reuse, but really like I'm just filming my erosion part, which I was looking at. You normally, if they also said, okay, I agree to distribute it with CC by, which would be the easiest way. It's normally not a problem, but we just had one case where one of the authors wanted to reuse a series of television spots from some Dutch broadcasting station. And there was an agreement that we don't... So because you just have a collection, Copernicus publications appears as publisher of these videos, even though the author returned copyright with CC by. But for them, it was an agreement with this broadcasting station that they appear as a publisher and can define the license. And we basically, we just link it. Thank you. Any other question? You would like to have coffee now at the sea. I suggest that we divide the game delay in two so that we reconvene at 1535. So we add a little bit, but not the full delay. So thank you very much.
Besides data sets, model code, and other underlying material, authors may also produce scientific videos relating to their articles. Outlets such as YouTube do not seem to be appropriate locations to host such scientific video supplements or video abstracts due to a lack of reliable long-term preservation and licensing. Therefore, Copernicus Publications and the TIB|AV-Portal of the National Library of Science and Technology (TIB) partnered to provide authors who publish in Copernicus’ open-access journals with the opportunity to host their videos in the TIB|AV-Portal and link them to their articles and vice versa via DOIs. This paper presents first experiences and examples from this collaboration.
10.5446/19646 (DOI)
Good morning. Great that all of you made it out of your bed after the nice party last evening. Seems like some other people didn't do that. So today we're going to learn about how to make search work and in particular how to find out if your search box doesn't work. How can I tell you something about that? I happen to be working for Elasticsearch. Apart from that I'm a member of the Apache Software Foundation, co-founder of Apache Mood which does machine learning and co-founder of Berlin Buzzwords, a conference on search scale and store in Berlin. But apart from that I've spent the past couple of years in companies that do search. First four years in a consultancy doing search applications for German publishers and then two years at Nokia Maps. And now of course with Elasticsearch. And one repeating question always was how to find out whether the search box is actually working and how to convince both customers and your manager what the real problems are as opposed to what they think the problem is. Okay. So this is usually when I go around, take my microphone and ask people who they are and ask them to give a brief introduction because I have a background in doing meetups. I won't do that to entire crowds this morning but I still want to have a quick show hands. How many of you have ever cursed a search engine that they've used because it just didn't work out? Just was, sucks. Good. How many of you have integrated search into some website? Google search? Okay. Pretty much everyone. How many of you have built your own search application? If integrated, we'll see Elasticsearch, whatever. How many of you know about Apache Lousine? Good. Very good. So I don't need to. Anyone who knows Oracle and Deca? Just one of you. Okay. What about Apache Solar? Yeah. Nearly everyone. Elasticsearch. Yay. So I first briefly want to show you that search isn't just about searching webpages. It isn't just about searching text. It can be quite a bit more diverse. Quickly skim over the use cases because many of you were familiar with building search applications and what that involves. So the first non-text applications that comes to my mind is, of course, a mapping search, a POI search. The use case here is that given you have a user who has a mobile device, that user sends you latitude and longitude and maybe a category, say the user is searching for a restaurant or sending you the name of that restaurant and you want to return that particular POI that's interesting to the user. Or they are just sending you some complete address including street name, city name and house number or just a fraction of that address and you then have to return the correct location on the map. So this is something that can easily be implemented with a search engine. In Nokia's case, it's mostly been implemented with a combination of Lucene, Solar, so typical use case. Another not quite so obvious use case is you want to do market research. So you've got some brand names that you want to monitor. You take all the mentions of that brand name in social networks, be it Twitter or Facebook or what have you, put it in your search engine and then do trend analytics on it. In this case, I happen to have a baby and I happen to have a Twitter account where I got some of these temper snappies. Another use case which is not quite so obvious but which is particular, popular with elastic search is you have log files. They standard web server log files or standard application log files and you feed them into your search application and again to trend analysis on that. Elastic search comes with log stage to put these log files into the search engine and we skip on for visualization on top so you can easily monitor your applications with that and can easily scale out. Another slightly more typical use case, you've got a product database, in this case it's a database of apartments and you want to filter them not only by location and distance but you may also want to enter some kind of free form searches. You may want to filter down using particular attributes that you may not be aware of once you create the database. Usually these searches tend to be powered by usual search engines like we've seen as well. My focus today will be the end-up surfacing search applications, not so much the login use case but more the product database, mapping search or typical usual text search. Now the three dimensions that make up search engine quality tend to be user interface because if the user interface sucks and you don't find the search box it doesn't help you anything. Also if the query language isn't what your user expected to be it doesn't help you as well. The second dimension tends to be your responsiveness of the search. It's usually that if a user enters a search term and you get your response in way more than 100 milliseconds that web page is perceived to be very slow. So it's like a lag that can be noticed by the user and that's something that people turns away, turns people away. Third dimension is search result quality. What I mean with that is is the search results that the user is searching for actually in my index is the document that the user is looking for in that index. It's particularly important for the mapping use case. If the user is searching for it's not in the index you can't do anything with ranking. You just can't return it. Second one is if the query terms that the user is using in order to find the document are actually associated with the document. Think of synonyms for example. Some person may search for I don't know computer but it may really mean Apple MacBook or the other way around. And the third one which usually comes to mind is ranking quality like is the document that the user is looking for actually ranked on top or is it somewhere at the lower end of the ranking. Our presentation will focus only on the ranking quality and how to find out whether all documents actually are in the index. We won't focus on speed or on UI. If we think about how to determine whether search ranking quality is correct we first have to remind ourselves how search and search engines are typically integrated and what typical search problems are. Let's think of a mapping application and let's think our users searching for Toronto. Now the obvious answer for that query clearly is the city in Canada. That should be first without right. Now however what if this particular user is somewhere in the middle of Berlin has zoomed his viewport down to this particular area. If you're very familiar with Berlin and in particular this area you know that there's a tasty German restaurant called Toronto. Our search may not mean the city of Toronto in Canada but may mean this tasty little restaurant. So result ranking quality isn't actually that obvious and not as objective as it may seem. So a lot of our ranking depends on user context. Where am I, what am I really looking for? Anything else that's influencing my perceived quality is spell checking. Think of typical spelling errors that if you just use predefined queries that you think of when doing your unit tests you may not think of all the ways that people miss spell search terms but you do see it in your logs. Another thing is personal preference versus global popularity or general popularity just because your manager's favourite children's book is on top of your book search doesn't mean that this children's book is actually the one that everyone is looking for. So you may want to again have a look at what users really are looking for. Another aspect that you can think of is seasonality just because your search works in summer doesn't mean that it's great in winter. There may be destinations that are depending on the season. There's also a great difference when checking if your search works if you know how the system works as opposed to being a newbie user. Typical user doesn't know how even an index works. For them it's just magic. They throw you some query terms and they get back relevant documents or that's what they expect. They don't know how that index is built. So if you craft your test queries yourself you always know how the system works and you know how to craft your test queries. We had a problem of subjectivity. Another example for that would be take a random set of Berlin people from different areas and ask them for the best ice cream in town. You don't want to know how many different answers you get. Another place there's different meanings for the same term in different countries. Restaurant in Germany typically means nice place where you go to have dinner with your girlfriend. In the US it may be a place where you go to get food and where you can sit down. So once was its advertisement in Germany from McDonald's like see different restaurant. Americans do expect you to return McDonald's if you search for restaurant. In Germany it depends on who you ask whether that's embarrassing or not. Also there may be users who are including additional information in order to find their result which you don't have in the index. Think of a music search engine where you don't put the published data into the index if the published data is part of the search query then you can't use this information of course. The first step towards a better search engine are metrics that I typically call finding the elephant in the room. That's stuff that is very outstanding, very obvious once you take a closer look. What do I mean with that? You go to your log files where you log your searches and you search for zero response queries. So either on each search you note down how many responses you get or if you didn't do that at implementation time you at least take these queries, reruns them on your system say on a test instance it has all the data and look for queries that return no results. What you find out with that is stuff like spelling mistakes and you should in particular be looking for common spelling mistakes and include these different terms say as synonyms. You find searches for non-indexed information and again you should be looking for repeated occurrences of this. So if it's something that's very often that should point you towards a feature you should be implemented in your next sprint. Also it could point you towards information that's lost on pre-processing. There's a popular movie in Germany which is called 23. 23 is the three. If people just search for 23 and you normalize all numbers to a specific term number but don't keep the actual number you won't be able to return the movie for that particular search. So again if you look for zero response queries that already points you towards problems in your implementation. Next step would be you do not only log the query plus the response you also log which results a user clicked on. What you get for that is that you can at every first step search for searches where you don't have any interaction. So you explicitly looking for queries where you did get results but no one ever clicked on them. So obviously these results are crap. But again you can look for common query reformulations that is you take your query, you group these queries into sessions. Say given a certain time frame plus a returning user is one query session and then you look for common reformulations. Again this may point you towards an anonymous issue for gotten. All of these approaches are great for finding bugs in your ranking. They are great for finding bugs in your current implementation and they are great for prioritizing features because it doesn't pay very well if you just pick a random I want to add new synonyms to this such and such term if that's not targeted towards your users. However, it's still a very core assessment. So if you want to go a little bit deeper and more pine grained you will first take a look at search in a nutshell that is how the scene and elastic search are typically integrated. Again we have our search. So this is what you type. You type Toronto. Of course if you look at the search application that's not all you get. Get a little bit more information. You may get the user's location because that's maybe what the browser sends through a location API. It could also be simply the IPs that you use. So the search application knows approximately where you are. Also typically your browser will send a preferred user language. Typically if say you have a mapping application you will send some kind of viewport. You may have the default one but you may also have zoomed down to your interesting area already. You will send information about your operating system. So if you have Linux and you send a query to a text search engine that may mean something totally different than if you do have an Apple MacBook and you are searching for Apple. The search may have information on previous searches if you are a returning user and may target it that way. Also something very obvious that you do not need to send those time of day, day of week. Searches that are interesting on Monday to Friday may not be the same as searches done on Saturday and Sunday, same for working hours as opposed to free time. On the other hand for each result there is also attached some additional information. There is not only just a name Toronto attached to the city of Toronto, there is also something like city size. So if you have to decide whether to return the restaurant or the city it may be interesting to know if that city is particularly large, if it's far away from the user or if that is a popular vacation destination. You may have rating information on the restaurant. If it's a very popular restaurant it may be a good idea to return that restaurant as opposed to city. You probably have information if you do this kind of tracking on how often people click on a certain result. So in addition to just the query string you do have lots of additional information. If you query that's being sent through the browser, the browser adds metadata, set metadata plus the query arrives in your search application. Now something interesting happens because this search application has to formulate say in our case an elastic search query. So usually this query encodes information that's sent through the browser, that's sent through some kind of mobile device if that's a mobile application plus the user query. Plus maybe time and date. This query of course goes to your search backend and you get your documents back. The interesting part happens there because this is where you decide how to weight all the different ranking signals and how to combine them. So this is where you decide how to take these different boxes and probably many, many more of these and how to combine them in a query that works. Questions that you may want to answer is I found a query that works or I found a query of transformations that works but here I've got a different query transformation that's much, much faster on my backend because it still gives the same results. Another question that's obvious is how should each of these signals be weighted? Is it more important that my city is large or is it more important that my restaurant has a lot of positive ratings? And of course which function should I use in order to combine them? Which signals should emphasize the importance of a PY or of a search result? Which signals should decrease that importance? So the obvious solution, take a few queries, take several test configurations that look like they could make sense and test them. Typical solution for that that I often see in practice is you have your developer. Developer decides I'm going to test these five configurations, I'm going to fire a handful of queries and I'll see if it works. Awesome idea except that the developer clearly knows how the system works so they know which queries work perfectly well and which queries definitely do not work. So your resulting ranking function is targeted towards working for your developers. Maybe not so good. Another typical solution, you've got management making the decisions. You've got a product owner, you've got a customer, they sit next to the developer and they look at the ranking functions. Again, they choose a set of usually a handful of queries, maybe 10, maybe 20, but as management doesn't have a lot of time, it's definitely not 100 queries. They run these queries, they're usually targeted towards their interests. Typically it doesn't work as well. So selecting just a handful of queries and firing these manually, usually not a good idea. A better solution or a great solution actually would be sitting next to a user looking over their shoulder and using real queries. Now you can't go out in the wild, sit in a cafe and look over the shoulder of your users. However, what you can do is if you do have decent locking, you can indirectly look over the shoulder of your user. You can take your query lock, sample a decent number, say 100, and use these in order to do evaluation. What you get through that, so first of all, don't take queries only from 5 a.m. in the morning on Monday morning. Take it from all over the times that you want to cover. Second, don't take only five queries, but take multiple. No, don't take queries just for certain locations, but take it all over the space where you want to have your search perform very well, except when your target is to improve search for the search is coming out of the same. So that's what I mean if they use a diverse enough sample. Not just a small fraction, but really do a sample. Now see a solution is take a lot of queries, take a diverse enough sample. Yeah? So what do you think you want to optimize? You want to have a maximum storage for most of the queries? You know this, with a lot of time, you probably really need your search for what's the target function. The question was what was the target function when sampling that is something you have to define before taking the sample. If your business goal is to improve search for searches coming out of Germany, you should take queries coming out of Germany. If your goal is as a first step to improve, or either to improve search for all your queries, and for all your users, or if it's at least to evaluate how well your search works for all your users, then you take a sample from all incoming queries. So in particular at the mapping application, it does make sense to narrow it down from which set of queries you take your sample. You may have the objective to improve search in a certain country. You may have the objective to improve search for a certain city. You may have the objective to improve search for a certain continent. So you always define what your target user group is that you want to improve for. So if I see question was whether I improve the best average or worst experience, again, that's up to you to define what you want to do. What you typically do is to look at the average. So you typically look at the performance of say 100 queries and then you average it and then you know how you perform. If however, you say, okay, I do have, I want to see what my worst queries are, and I want to see if that's a specific type of query. And I want to improve that specific types and you would look at the worst performing queries, of course. But the typical starting point is to look at the average. And again, you could even say, okay, I do not want to sample by geography, but I do want to sample for certain types of queries. Say I only want to sample queries that have a certain device attached to it. I want to sample only queries that have something to do with either eating and drinking and going out. So that's again your business objective from all your queries that you have, which ones do you take, which ones do you want to improve. And typically the first step is to improve the overall experience. And at a certain point, you will realize that you can't easily improve the overall experience, but there's a few types of queries and a few types of users which are like low hanging fruit in order to improve them. So you take the sample just from that, compute the quality there, improve it there, and then only do it for that. You should again rerun your experiment on the whole set to make sure that you didn't decrease quality for the remaining users and queries. Make sense? So if you think about this translation of ranking signals towards an elastic search query, what this really means if you run these kinds of experiments is that you define sort of like a template to translate from your user supplied query data and metadata to a real elastic search query. That's where elastic search actually helps you, they provide template queries. You can define, okay, I want a elastic search query executed and in these spots I want to have variables filled with the actual data. And that data will be what comes out of your log files of being supplied by your users. So you can easily define multiple templates, one for each signal configuration combination that you want to test and can then run your experiment against the index without having to rewrite any code set out with the corresponding query. Now there's three ways of evaluating how good you are. There's a manual labeling and tagging efforts that you can do. There's one effort that kind of sort of works in an offline mode after having put your search online and having collected logs and there's one online metric. We will first look at the manual tagging work. The goal here is to still do a manual equality evaluation but to use real user queries and real returned results. And the goal is to decide whether those results for these queries are any good. So you take your query logs. If you're really good for each query you've also looked at results you've returned. If you didn't do that remember that you can always rerun these queries against the system which was live once these queries were run. So you reply them and you send them off to taggers. Could be mechanical Turk people, could be people you hire yourself. One thing to keep in mind is that you need to train these people. So you need to tell them what kind of result you expect or what kind of result is kind of like kind of an edge case. It typically involves going through a few iterations of queries that you tag together with these people. Second thing this entails is that typically you should have at least two to three people look at one query independently. What you get through that is that you can take a look at those queries where the opinions of people were largely different. If everyone agrees that's very obvious. If everyone disagrees there's a high disagreement rate and you should again take a closer look at these queries. Now there's two things that you can do. The one is like the Coca-Cola Pepsi experiment. You take a side-by-side comparison, you don't tell them which side is which, which is new and which is old, and you tell them tell me which one is better. From that you can deduce which ranking function works better. Usually works for whatever ranking functions you want to evaluate. It's slightly tricky because you have to evaluate complete ranking sets. So you have to evaluate, usually you do it for the top five, top ten results, typically for the first search result page because that's what people tend to look at. People don't tend not to page. What's also tricky with that is to evaluate after the fact, after you've got the result of which one is better, to say why it was, why it's better. If you do not track additional information, if you do not tell your people tell me why it's better, what went wrong on which side. The next step could be tell annotators to pick for each result set and tell me which of the results that I saw is a good one and which one is a bad one. What I get from that is for each query a set of annotations of this result is relevant, this one's not irrelevant, this one is relevant, etc. So you get multiple sets of Cs. What you can do from that is compute a precision. Precision means of all the results that are returned, how many were relevant, which portion was relevant. It's great as a first overview and typically if you hear precision and you do have a background in machine learning, you may tell me that hey, there's a second part missing and that is recall, recall meaning of all the relevant results that I should have returned, how many did I return. If you think of web search, tell me how to annotate all the internet in order to find out how many relevant results there were. So what you look at in search, especially in web search, even in a geo search, is only precision because even in geo search you can imagine that in order to find all relevant and restaurants in Berlin you have to be very knowledgeable about Berlin in order to give me some kind of recall. However precision does have a problem here even in the setting and that is that the two results that you see below are counted as equal. And clearly they are not equally good because in the right hand side you have irrelevant on top, in the left hand side you have a relevant one on top. So me personally I would prefer the left hand ranking. Also all documents are counted as either relevant or irrelevant. There's no edge cases. There's no if I don't have anything else, that's okay but if I do have a lot more better results I should better leave it out. So the first fix is to introduce relevant upgrades. Something like it's embarrassing to show that, it's kind of okayish, it's pretty good and this is essential to show. So you add these relevant upgrades over your ranking function and you get a better evaluation. Second fix is to discount the lower ranks. So if you have a very relevant result but it's ranked very low, it's contribution to the overall sum should be lower than if it would have been on top. So there's two ways to compute it depending on how much discounting you want. Last but not least you can normalize because imagine you have only one relevant result. You don't want to show five results just in order to push the number up. What you want to do is show this one result. So you can normalize for that query what is the maximally achievable discounted cumulative gain. You compute that by simply ordering all your results by relevancy grade and computing cities G for that and do the normalization afterwards. So there's still a few issues that you could fix. There's things like the observations that people do not tend to look at a result that's just below a relevant one. There's different metrics that fix this. Like ERR for instance, I'm not going to go into details here. There's publications outside so they explain it much better. Now if you do have manual taggers and if they go over your results anyway, there's two things that you can tell them that are cheap to accomplish but that may help you implementation a great deal. One thing is tell them to look for embarrassing stuff. Giving a little bit of time to look for the funny stuff here. It's okay if you look for a baseball club that it's okay to show a baseball ball but the lower right results may not be what people should be showing even if they do purchase it. So this is still working in Amazon but only in Amazon DE. Another thing that people, taggers can look for is given a query. Could I have answered this query with the current index? Tra la la happens to be a kindergarten in Berlin. It's not in the index so it can't be returned. If your taggers see some portion of an address or see something that looks like a restaurant or that looks like a kindergarten that they know of, they can easily tell you there's something missing. You shouldn't be just fixing these issues but you should be looking for patterns here. So is there a certain category of POI missing? Is there an issue in a certain country? Is there an issue in a certain city? So don't fix just this one instance but use it as like some kind of pointer towards a bigger problem that you should be looking for. So this kind of manual tagging is great for assessing your current ranking quality. It's great for comparing to ranking functions because you can always do the A-B testing. You can always compute the precision value for both ranking functions, doing it for the second ranking function. If that second ranking function is slightly similar to the first one, it's even cheaper because most likely you're not returning completely different results so you can reuse these annotations. However, it's still expensive because it's manual work. We can fix that by going to a slightly more automated approach. Looking for a slightly more automated approach usually means getting quite a bit more noise into your measurements as well. So these are not quite as precise as manual tagging but a lot cheaper. What you need for it in your log files is the queries. You need the results that you return and you need the exact results that the user clicked on. So in your search result page, you need some kind of feedback loop towards your application that tells you which link a user clicked on. It's something that's sometimes missing in applications. Okay, once I have these three input data sets, what should I do? What should my target function look like? Should I simply try to increase engagement with search results? That's what's typically done for e-commerce websites. Here's a Microsoft experiment come wrong. They had messed up the search function completely but that resulted in increased revenue from search result advertisement clicks and an increase in search result clicks. Why was that so? Because ranking was so completely broken, people had to do a lot more clicking in order to find the relevant result. So in the short term, that means an increase in revenue and an increase in clicks. In the long term, however, that means that people stay with their search. So this is not what you want to do. There's a publication out there already for nearly 10 years now where people did an eye-tracking experiment. How do people interact with search? People tend, which is obvious, to scan search results top to bottom. So that means I can use clicks as well as I see feedback. However, what I cannot do is to use a click on a search result as an absolute relevancy feedback point. What I can do, however, is to say, okay, somebody clicked on a search result but they skipped the first and the second one. So probably the first and the second one weren't quite as interesting. So you can take it as a relative feedback and incorporate that back into your ranking function. That is a little bit more noisy, but what you can also use in order to increase your data is to look at clicks being more important than whatever was clicked before. Because the reasoning behind that is probably the user came back because she wasn't happy with the first result. If you think about your search behaviors, that may be true for quite a few cases. In some cases, it may just mean, okay, I want a second opinion. I want to read more on the same topic. So that's where the noise is coming from. Another thing to look at could be you clicked on something, but it didn't click what was just below that because people tend to scan what's around whatever you do click. You cannot say that what you did click is more important than what was on position 10, get alone on position 100 because you cannot say that the user actually saw these results, but you can be reasonably certain that says so what was around clicked position. So there's quite some noise in this data, but it should be very cheap to get. So if you got just here, this is something called presentation bias. Users tend to be very trusting in your search results, so they tend to trust that the first result actually is a relevant one. Even if you turn the ranking completely around, there's still a preference for clicking on the first result. So you somehow have to account for that. Also users of course only scan a limited number of results. So what you cannot find out with that is if your ranking is completely broken for a certain use case. So if for a certain use case your interesting stuff is on page 100, you're not going to learn it through this kind of metric. And again it's only possible for life implementations. So this means if your ranking is completely broken and is going to scare away your users, this may not be the best way to find out because your users may have run away once you know that it's really broken. It's great for assessing current ranking functionality, it's great for comparing two ranking functions. It's slightly risky if you introduce a dramatic change and you're not absolutely certain that this dramatic change leads to an improvement or at least to comparable user experience because it's life only. So the last approach which is now really life only. If you are reasonably certain that your new ranking function works but you still want to have a comparison against your life system and you want to show that it works. It's a typical A-B testing setting. You again for evaluation needs queries, results shown clicks and that for both ranking functions. Now you can do two setups. One setup is you take a small portion of your users and choose them just the new ranking function and you take a larger portion where you are safe and show them the old ranking function. And then you just compare where your users click. Do they tend to click on the top results more or do they just randomly click or whatever? Another approach that tends to work very well is to take for subset of your users a kind of simple like approach. You take both ranking functions, the old one and the new one and you interleave them. With that you can say did my users click more on the old results or more on the new results? In order to account for presentation bias you switch the interleaving once the old one and once the new one is on top. And then from that you deduce which one is better. It's slightly less risky because you always have the old results in between and it's also easy to interpret because you know where results are coming from. So this is great for comparing two ranking functions. However, it's online only. So you don't want to scare away your users by putting something online which clearly messes the user experience completely up. So in a real life experience if you want to put the puzzle together you won't be using just one of these approaches. You will typically use a chain of filters in order to evaluate your ranking signals and in order to evaluate your combinations. So you will typically, your developers and your management or whatever comes to you with a new ranking idea. I want to introduce this new signal or I want to change ranking. So it typically comes with two to three queries where it really improves the experience. So you will go and first maybe first do an A V test that's offline. Show your annotators both versions and tell them which, tell me which one is better. Or you will rerun it against a pre-annotated set of such results and you will want to see is my ranking still kind of okay? Is it better or is it worse given on the annotations that I already have? Maybe re-annotating whatever came up new. If your new ranking function succeeds in these annotations, in these annotation experiments and is reasonably good, reasonably good I mean it does, it's good enough in order to reason to have that ranking function put online. You will then go and potentially run either a live A V test or you will put it online and track the click set up being done. So you will always have this filtering chain. You will first probably do the precision computation. You will then potentially do an A V test, like offline A V test that we had for like the side-by-side comparison and then you will potentially do an online A V test. So you will always have a multi-step process. And what you will see is that most, many of the great ideas that people come up with aren't actually that great or are great just for very, very small subset of queries. And then it's up to you to prioritize and to think whether it's worth the risk to put that online or whether to go with your current solution. If you want to read further information on those topics there's lots of information online. First reference that you should look at are the publications on the right-hand side. The first one is done by guys at Microsoft. They've done A V tests and they've compared, for instance, which kind of metrics influence how your ranking function changes. If you use the wrong target function, like for instance, improving user engagement with your search results, what happens? The other interesting publications is one by Joachim's on the query chain. That's the one which tells you how to do search result in the leaving. And that's the one that tells you how to interpret click data. The interesting books, there's a free S and free B book called Information Retrievals that you can read and learn lots about evaluation functions in there. They also talk about computing recall for a search. This works great if you have academic collections, document collections, like track for instance. There you know which documents are in that collection and you can compute the recall. Keep in mind that in your real life experience this may not be as easily computable as you think. There's one book I in particular like that search patterns. It's not about ranking evaluation. It's not about ranking quality. But it talks a lot about the features that a search engine should have in terms of user interface, in terms of user features that make the experience a lot better. Like for instance, the obvious phasor thing stuff. And there's some web pages online. There's a talk at Berlin Buzzwords that talked about ranking quality at Yandex. And there's publications by Google which talk about how they do search quality. Where again it boils down to a multiple filtering step process. Where first you go for the annotated documents that which you can easily use in order to compute your performance. Then going for A, B for side-by-side comparisons. And then going for A, B tests. And throwing out multiple filtering and signal ideas underway. So it's usually you come up with a signal. You make the change. You run it through annotators to see if the change is worth anything. You re-unit annotator only changed results. You use multiple metrics, potentially precision, potentially anti-seg, potentially ERR or whatever corresponds to your search. Also keep in mind that precision typically is used for the top end results. And you should target the size of n to your user interface if you are showing only five results on the first result page. It doesn't make a lot of sense to compute precision at 10. And then you only test those ranking changes on real users where you've seen before and said it does make a difference and it does make a positive difference. And with that I'm happy to take questions. And I have been given these tiny little alks to hand out to people who ask me questions. But as I've gotten one question already, no, someone looking in the back. I got one question during the talk. Not sorry. Thank you for the question. Any further questions? Anyone there for a person? But the question is fine. So the question was whether Elasticsearch comes with any features? That's a very great question because that's actually on our roadmap. So I've been tasked with implementing support for that. So the first step will be supporting users with log sampling. A second step will be supporting users with doing the A-B testing stuff. And way ahead of that, if you think about you do have annotations, you do have logs, you do have clicks, the next logical thing is to learn your ranking function and to not manually think about which signals I want to integrate and in particular how to weight them. You could easily learn that ranking, set weighting automatically. So doing this, learning to rank is like the ultimate goal. It's not like something that's going to be released next week, of course, unless you want to supply a patch. But it is on the roadmap. Because so the reasoning behind that is that what I have seen and what many other developers have seen is developers tend to know at least some of that, but usually in their company they don't get the time to implement the sampling. They don't get the time to implement, say, an annotation framework. They may get time and money to pay for mechanical type people, but there's still quite a lot of overhead in order to come up with a decent sampling approach, with a decent annotation approach, with feelings that back into your application, with running across your current index, there's lots of infrastructure code involved and that's something that Elasticsearch in the future will help you with. So the question was for your annotators, which information do you have to give them? First of all, it depends on your use case, which information you have to give them. It also depends on what you want to know through these annotations. If you have local people doing the annotations and you want to know their personal preference, you give them as little information as possible. Typically, however, you will give them a fixed set of rules. If you want a sample guideline, you can search Google for the Google search annotator guidelines. There should be a PDF online, like three to four pages, which explains which kinds of information Google annotators get in order to annotate web pages. In this room, everyone typically knows what a search engine spam page looks like, what all the links on it looks like, what a link farm looks like. Your typical mechanical Turk person probably doesn't have that knowledge, so you need to tell them what you expect. The question was if your site is very specific, say, where we technical site, how do I get that information into the people? Ideally you will get annotators who have some background. When I think back about the mapping use case that we had at Nokia, we always tried to find people from different geographies at least, so they understand at least language that's being spoken. It's evaluating a Russian restaurant if you don't know how to read. It works with Google Translate, so it can be done and developers have done it, but it's extremely hard. It also depends on how much noise you can deal with. If you can deal with noisy annotations, however you cannot afford the domain experts in order to do the annotations, it's probably better to get anything annotated back so you have nothing. But usually you are trying to find domain experts. Oops. Sorry. You got it? Good. One more? No more questions? Yeah? I was just wondering how would you go about setting up a search function for say 12 acres of signals and what would be the, or is there a better effect this way of starting to weigh the signals against each other and what would be the standard for, or is there a better effect? So the question was if you have multiple, if you have lots and lots of products and you have hundreds of signals that you have on your mind in order to ranking, what would be your standard approach? First of all I would go with whatever your search engine comes with and try that, like we'll see default configuration and see how that works and go from there. Also probably I would try to not use too many signals to begin with. Like in text search people usually start with tweaking which ranking functions they use. If they have standard text search what I tell them is just do whatever is shipped with the scene by default which is TFIDF and that's something that typically works extremely well and with product search it would probably start the same way. Isostar was an equal ranking or start whatever your gut feeling is. If you have no data just a little you can do. Depends. Sometimes you're controlled not only by your content and what you see and what you search for but sometimes, or maybe a kick off for this is like if you're controlled by your marketing. They have a new advertisement ongoing and they say okay we want people to search for product peaks and that at least and we want to bring the user to a new advertisement landing page or something like that. Maybe that's sometimes a start because it usually means they have a budget and you can start your work because they pay you. But that will infer into details because after a while I'm pretty sure you will get some news from customers saying okay everything I search I land on this page and very nice product I want to search for the rest. So usually first of all what I was talking about here was natural search. So there's a whole different topic about search placement, paid search placement. So there's a whole different topic about deciding which advertisement to show which depends on the budget which depends on how much your customer is paying in order to land on the top and which also depends on the relevancy. And apart from that you shouldn't be waiting for your users to send you an email. You should see it much, much earlier and you typically see it in your log files if you look close enough. And typically you shouldn't do this looking just on request. Like when your manager is standing behind you, like what are your users doing? Is it all okay but you should have some kind of dashboard which shows you the typical values that you should be looking at. Okay, further questions? Yeah. Shaka, and last question here Is your project짉engai or our website? Do you kind of feel by language, do you think that's naturally coming from the query or do you take into account what language the user first chose in order to access the site? In an ideal case, you should be able to trust whichever preferred user language, the browser of your user sent to you and target the search for that. Typically, you can't do that. So typically, you might even do something like, okay, in which location is the user plus which is the preferred language plus some other parameters that you use. When you do the sampling, it again depends on where do I want to improve search. Do I want to improve search for German users? So now, I may look for queries coming out of Germany. That's not only German users, but it's probably the majority. I know the problems that you cannot trust the language that's sent with the browser, but again, maybe application has a means of finding out what the preferred user language is. Maybe you can guess the user language from the query that these people sent. I can tell you, I guess you know the language that the user decided to watch the site in. Ah, okay. So in your case, you have like a button? Yeah, because it's mentioning all the sites. Okay. Some content is concentrated, some is not. Yeah. So it's not as easy as the other case. In that case, yeah. Yeah, in that case. So in that case, I would always default to the translated content if set as available in the user's language. And otherwise, try to find what is the best guess for what people speaking this primary language typically have as a second language. So you can't do any better. I can't think of a better way to do that because it always ends up being like a thing. Oops. Okay, I'm being told that I'm out of time. So if you have any further questions, come to our booth and get the remaining alchs.
Your search doesn’t work How to find out whether or not the search box you offer users is helpful at all This talk will walk you through the options of determining search quality - from purely offline metrics that work even before deploying version 1.0 to production to online A/B testing to check continuous improvement. I will highlight some Lucene and Elasticsearch features that can tremendously help you deploy your own search quality checks. Web sites without search functionality are unimaginable today - you search for comments and code on github, you look for books in your favourite webshop, you use the search box of your favourite blog to find articles. When offering your search for your own application - how do you know that your search actually provides a benefit to the user instead of causing lots of frustration over results not found? Only checking that the favourite book about witches of your child is ranked top of all children books clearly doesn’t help. This talk will walk you through the options of determining search quality - from purely offline metrics that work even before deploying version 1.0 to production to online A/B testing to check continuous improvement. I will highlight some Lucene and Elasticsearch features that can tremendously help you deploy your own search quality checks. Speaker: Isabel Drost-Fromm Event: FrOSCon 2014 by the Free and Open Source Software Conference (FrOSCon) e.V.
10.5446/19645 (DOI)
So, good morning everybody. I hope you all slept well. I wasn't here at the social event yesterday but I saw photos of the PHP table outside in the social area and I guess there were some hard stuff going on as far as the photos told me. Okay, what Symphony has to do with my garage, I'm going to tell you a little story of what I did in the last month. The big headline is home automation with PHP. A few words about me, my name is Jan Ummer. I'm a freelancer living in the Rhein-Main area near Frankfurt. I'm doing web applications mostly with PHP and JavaScript. PHP, since 14 years now, back in 2000 I was young and needed the money. Nowadays I'm old and still need the money. If you have any questions don't hesitate, just shout out. Try to answer them instantly. The object, what I'm going to talk about is this garage, my garage at home. It's a sectional door, electric drive is already in place. The view from inside is like this. You see up here we have a box with a motor in it and the metal beam, inside this metal beam there's a chain, quite similar to a bicycle chain you might know. Attached to this chain at the front is another metal beam and this metal beam that heads to the door and the motor drives this chain and thereby pulls the door back and forth. This was already in place and my intention was to get this thing accessible via anything like HTTP. There already was a radio remote control, this thingy here attached to my car key and this remote control was one of the main reasons why I started all this because I used to have this remote control in my pocket and from time to time without noticing I accidentally pushed the button, the door goes open and I didn't notice and the problem is as you see on the photo, this here is the door where you can go upstairs to our flat and there's a hole in the wall between the garage and the stairs and when the door is open you can go straight away up to the flat which is obviously not what I want. This was motivation number one, the other thing I had from time to time I drove away in the morning, deep in thoughts and two corners later I thought have I closed the fucking door? I don't remember. Yeah and this is the motivation for all. You have another thing in place, this is a button at the wall which you can just press, it's wired up to the motor, press the button and the motor goes up and yeah. The hardware, you might all know Raspberry Pi which is the base for my little thing, who knows Raspberry Pi? Okay for the others it's a micro computer, approximately the size of a bank card, it's a platform based on an ARM processor, quite similar to what you might have in your pocket as a smartphone. The big thing about this is it's quite cheap, about 30 euros and it's easy to expand. This here is the Raspberry and it has an expansion board GPIO, general purpose input output and five of these pins implement something that is called SPI, a serial peripheral interface bus, it's a de facto standard invented by Motorola for a synchronous serial in and out. And to make this GPIO port accessible for me, I'm not that deep in electronics, I used another thing, this expansion board, it's called PiFace, costs another 30 euros and it utilizes this SPI bus that comes out here and brings us eight input ports and eight output ports where you just can plug in two wires and if the wires are connected the electronics can tell okay the input port is connected, if they are apart the input port is open. The other way around is just the same, if you tell the software close this port then those two pins get connected, if you tell the software to open the port the two pins get apart. Okay, another nice thing which I didn't use but which makes it quite usable for home automation, you can stack up to four of these expansion boards onto one Raspberry Pi, so you have 32 inputs and 32 outputs with quite affordable amount of money. Software base is on the Raspberry, the operating system is called Raspbian, it's an ARM version of Debian Easy, so if you know Debian you're good to go, it's a fully operatable computer which you have, it has HDMI output, it has two USB ports, it has a network interface, audio in and outputs and the persistence is done by an SD card plugged to the port. And this is how it looks when it's assembled, this Pi phase is just stacked upon the Raspberry and it's quite as big as a cigarette box approximately. If you want to have a look on it, I have one with me, I have it here. If you're interested just come to me after the talk and take a look at it. Stealing it has no point, it's broken, I somehow managed to break it. Okay, the sensors, I want to tell if the door is open or closed or anything in between and to reach this I have two things that are called read contacts. Read contact is basically a small capsule, inside this capsule there are two metal plates and if they get in the range of a magnetic field they close to each other and provide an electrical contact. Which means we have a magnet which I'm going to attach to the door, this magnet is going to move back and forth with the door and somewhere we have those sensors and if the magnet approaches these sensors I get a contact at these two wires and just plug them into my Raspberry and so I can tell where the door actually is. Okay, so far. As I said, any questions just shout out. Okay, this is the installation, still looking a bit like a prototype which it is actually. The Raspberry mounted in some common installation box, we have an ebony uplink here and we have power voltage and we have some wires to the sensors and the actor. Oh, I forgot the actor is the thing mounted on the wall, you know, you remember the switch, I just attached to additional wires to the switch coming out of the relays here. Which means I can tell the software close the relay, it's as if I push the button and open the relay releasing the button. This is the situation in front at the door where the drive approaches the door and here is where I mounted this one read contact. You get a bit closer, it looks like this. This is the capture with this read contact. This is the magnet attached to this metal beam moving back and forth to the door. And on the other side, backwards, there's the same, this is the read contact and the magnet comes up here and stops right in front of this sensor. Another thing I have in place because I'm a control freak is a webcam which was in fact the first step in this little project where I could tell if the door is open or not. But the thing is the camera won't tell me, hey, the door is going up, have a look what's happening here. This is the view down from the camera and as you can see, we have a direct link here from the garage up to the stairway, stairway up to a flat. The software is a small single page application which can easily be accessed via a smartphone. It has a status indicator which tells me the door is closed, the door is open or the door is somewhere in between and is supposedly moving at the moment. We have a live photo from the garage and we have a button where we can tell the drive go. This is the basic structure of the application. The container is a symphony app, mostly overkill, but another intention which I had in mind was to tell if a Raspberry is suitable for running symphony applications. In fact, it is a bit slow but still usable as long as you don't have too many users at the same time and the only user and it's quite okay. We have four functional components. We have a door state indicator which we saw here which is able to tell whether the contacts are closed or open. We have a motor trigger which takes post requests from the single page app and tells the motor go ahead. We have the camera proxy delivering the photo from the webcam. Another thing in place is a watchdog which is a console command running endlessly which reads the contacts every second and if the state changes which means the door is up to move, it's going to send me an email. This was another point, another solution I would like to have to be informed when the door opens without me doing anything about it. The camera proxy was necessary because the camera itself has an HTTP interface but no SSL in place and sending credentials over the internet is probably not the best idea at least in plain HTTP and this is what this camera proxy is for. I pulse in photo and send it out via another channel. I didn't invent the wheel myself as you might guess. There were two main components in place which helped me to solve my problems. The first one is this component PHP SPI. It is a PHP module implemented in C. Some guy much smarter than me did this. It makes it possible to access the hardware via PHP and this is where the magic happens. It provides a PHP interface, a class called SPI which models this hardware access. The second thing that made it much easier to access the hardware is this project from a guy from Norway. It's an abstraction layer above this SPI module where you can simply access a method that reads and writes values to the single pins on the Raspberry. This is actually a PHP part of the original library from the window pyphase. It's that one here and this one is done in Python. You might say you could also have used the original Python library but this is not what I wanted to do. My point was to get to know if it works with PHP and it worked out quite well as we're going to see. Okay let's have a look at the code that we have here. First and foremost there is this driver class and as you can see there's many stuff going on here with hexadecimal addresses. I didn't dig in that deep I must admit. I just was happy that all of that works. If you like it's all on GitHub and you can read afterwards what's happening here. The thing is we have an API that allows us to read bits from the SPI bus and to write values to other bits at this SPI bus. And my hardware uses this. Just a second way have I. There it is. This is the topmost abstraction layer of the pyphase board which I've built. When it creates an instance it gets itself eight representations of the input pins and eight representations of the output pins. And all of what these pins do they know I'm attached to this board and to this pin number and they can tell the value of the actual pin and they can write the value in case of an output pin to the appropriate memory address. The application itself is rather simple. Do you all know symphony? At least at a basic level who knows symphony? Okay. The basic thing is you have a front controller. This patching request to specialized controllers in the application. And in my application we have four of these controllers. We have an index action, index controller which delivers the static HTML for the single page application. We have another controller in place for the door state action which gets a service from the service container and is able to tell whether the door is open, the door is closed or the door is moving. And it sends back a JSON response which the single page application is able to process. The next controller is this trigger action which gets a post request and tells the door, the motor, go ahead, move. The last controller we have in place is the snapshot action for the webcam which pulls an actual image from the camera and sends it out to the requesting application. And as you remember we had another thing in place, this watchdog. It's this one here. It's a console command. Symphony provides console commands which you can run on the server. And this one here is simply running a while loop endlessly where it executes a so-called watchdog component. The watchdog component reads the sensors, tells the state and if the state changes it sends out a mail. This mail is queued up. Symphony has a mail queue and after executing the watchdog this mail queue is flushed and the mail actually is sent out. And from time to time because PHP and long running process is not that good idea, this thing terminates itself every 24 hours and gets restarted by supervisor daemon which takes care of that this process is started if it terminates for whatever reason. Okay. I originally intended to do a live demonstration with this thing here but as you know it's broken and obviously I can't bring my garage here and I can't take you to my garage to show you how this works in real life and so I did a little video where you can see what happens. This is the garage. When I go downstairs in the garage I open my smartphone, push the button, the relay triggers, the motor starts moving. You see the magnet leaving the read sensor, the door opens. The read sensor on the other end, the magnet reaches the other end and the sensor at the other end, push in the button again, the relay triggers, the motor starts moving, the magnet reaches the sensor and my application tells me the door is closed. Everything is fine. Okay. This is the current state as it's currently running in my garage. I have some things in mind I want to try out with this. First of all some performance tuning. As I said before Raspberry is not the real performance hardware. Running full lamp stick on it with a symphony application is okay. It's not perfect. I'm going to try out a few alternatives. Throwing out the symphony stuff and using plain PHP, using Nginx and Light HTTP as a web server which might help a little. Let's see. I'm just trying out a few things. The other thing I have in mind is a feature, automatic closing, which allows me to go to the garage, open the door, drive the car out and don't care how the door closes, it would close by itself. I could do this just by telling okay. The door is open for 15 seconds now. The car should be out. Let's close the door. Might work. Might be too fast. Who knows. I already have some hardware in place to solve this. I have a photo sensor at the height approximately of the car bumper. If this photo sensor, if the light beam gets disconnected, we have two wires coming out of this. If the light beam is connected, the sensor is closed. If the light beam is disconnected, which means the car goes through, the sensor is disconnected. Thereby, I can tell, okay, the light beam has been disconnected for five seconds. It has been connected again. Okay. I think the car is out. We can close the door. It depends. I'm going to do a little research on that. How long it's disconnected when the car goes through compared to how long it's disconnected when the person walks through. I'm not quite sure about that. I haven't tried it out yet, but I'm going to. It's a point I had in mind, and I'm not sure if it works. Let's see. Another thing I have in mind is trying out web sockets. Currently, my single page application pulls every two seconds. This data is indicator. The image gets updated every 10 seconds, which causes quite a bit load on the respiration. By having web sockets, I would be, this problem would be solved. I would have an open connection to the server and the server would be able to push a notification as soon as something happens, which might be faster than the actual polling solution. Another thing I'm going to try out is an Android widget instead of the web application. I've never done Android development before. That might be a good point to start. Native application that talks to my door. Let's see how it works. Voice control is a point. I've seen a video of a guy in the US who has done quite a similar thing. The main difference is he hasn't built an application, but he talks to Siri. It tells Siri open the door. Magically, the garage door starts moving. I'm going to try this also. The last thing I'd like to try out is Ipeacon, which means having a Bluetooth first transponder in the range of the garage. If the smartphone comes in range of this Bluetooth transponder, the Android app might fire up and say, hey, we're in the garage. Shall I open the door? You see, it's a nice playground for big boys. Okay. I collected some links if you want to dig in deeper. First of all, this is my application, which I built. This garage door control is the Symphony application. It's on GitHub. There's also the library which abstracts the SPI bus. The PHP module for accessing the SPI bus and some materials for further reading. This is the documentation of the vendor of this PyFace board and some more stuff if you want to dig in deeper in Raspberry Pi and this GPIO port. I put up the slides. At slideshow, I'm going to tweet the link afterwards if you would like to read. Go ahead and grab it. There are quite some alternatives out there. Raspberry Pi is not the only thing to use. If you want to do a home automation, there is stuff called ZWAVE and a related project, Raspberry. I don't know how to pronounce it correctly. It's similar, but it's wireless, which means you have an expansion board on the Raspberry with some kind of wireless controller talking to hardware over the air. One wire, as far as I know, is something similar. Don't know much about that. ZWAVE, a friend of mine, played around with ZWAVE and he did a garage drive lately, which seems to work quite well. Another alternative might be Arduino. I don't know much about Arduino, but we have a talk today as far as I remember in the evening to Thomas Weynert. That was yesterday. Oh, it was yesterday, sorry. But you may be still around if you like to have some words about Arduino talk to him. Of course, we have a big variety of commercial products for home automation. I don't know much about them, but I would guess there might be more expensive than this DIY solution. Short recap. The electric door drive was already present, a common one, like you can buy it at the hardware store. Things I bought myself were these two read switches for about 12 Euro each. Some cables. The Raspberry, which is about 30 Euros. The expansion board, 30 Euros. With 90 Euros, I have my own home automation project, which I can play around with. Home automation can be easily done as a beauty self project, at least for me. This was proof enough. The Raspberry Pi works well as a platform for that. It's compact. It's inexpensive. It has a small energy footprint, and it's easy to extend. Okay. And now I'm happy to take your questions, if there are any left. Question was, if I considered to use an expansion camera for the Raspberry Pi, attached directly at the Raspberry Pi. In fact, yes, I did. But in my case, the camera was in place long before the Raspberry, because as a first quick solution to tell whether the door is open or not, I just wanted to have access to a photo. So I had this web camera already and just put it up there. And the Raspberry is mounted at the wall, but not at a place where it can look at the door. This is the point why I didn't consider, but this might be a point also, yes, using a camera attached to the Raspberry. Yes, please. I have a question with hardware configuration. If you could talk correctly, the standard of the Raspberry is open or closed, more or less vibrate. You can only say open or closed. Yes. Open or closed is impossible. Yes, question. So for other applications that in particular might, traditions, so the kids put something in the garage and they put it not far enough in the garage, then the door comes closed and then there's an internal mechanism which is stopping. And then it's half closed or big closed. Yes. So this is, from my perspective, a very critical situation. So you have to see the door closing down, but then there's a space in between and everybody has to be through. And maybe in winter with snow and ice, other situations, have you thought about something to solve this problem? I just repeat the question for the stream. The question was the sensors. If they are able to tell whether, if they currently put the answer right into it, currently the sensors are just able to tell whether the door is closed, completely closed, or completely opened. As we have a punctual sensor which can tell the magnet is in range or it is not. I cannot tell where the door is when it's moving in between. I might get into the same situation as you described it, that something is in the way of the door. The door crashes into some kind of, yeah, and it stops right. Because the electrical drive is to design to stop if it reaches something in its way. In my case, it's not that big problem as I get an email as soon as the door opens. And I get another email as soon as the door closes. And closing means closing completely. If it stops under ways, the state of the door is currently moving. The sensors can't tell if it's actually moving, but they know it's not completely opened and it's not completely closed. And that's enough for me in that case. About 15 centimeters, 10 centimeters. Yeah, it might be enough to leave some centimeters of the door open at the bottom in edge cases, yes. I haven't had that case yet, but would be not that much of a problem as those 5, 10 centimeters won't be enough for someone to break into my house. And this was my main point. And the, which we didn't see here, the kinematic of the door is so that the door reaches the bottom of the garage long before this metal beam arrives here. It's hard to describe. It's a sectional door and the top most section gets tilted. Yes, thank you. On the last, say, 20 centimeters of this way. On the last 20 centimeters of this way, the bottom most section is already on the ground of the garage. So all what could happen if it stopped here, say, that the top of this door stays open for, say, 10, 20 meters. Could be a problem if you have a neighborhood who is willing to throw something in, but in my case it's not the point. Okay, some more questions. Three, two, one. Thank you.
What Symfony Has To Do With My Garage - Home Automation With PHP Raspberry Pi is a perfect mini computer to experiment with, small, inexpensive, low energy consumption and easy to expand. This talk, using the example of a Symfony app as a remote control for a garage door drive, shows that it's possible to write hardware drivers in PHP and how to easily use the Raspberry Pi along with the PiFace Digital Expansion Board for home automation. ······························ Speaker: Jan Unger Event: FrOSCon 2014 by the Free and Open Source Software Conference (FrOSCon) e.V.
10.5446/19644 (DOI)
So good to see some faces that I saw in the previous talk. Can't have been that bad then. So coming from the same project, we're going to extend on security today. A little bit about myself. You don't know me yet. I'm born in London. I work for quite a few companies. Now I live in Berlin. I'm in the startup scene, probably everybody in Berlin is. Studied in England. I'm originally a C programmer that sort of moved up the ranks to do a lot of project management now. I tried to do some coding. I tried to do most of my coding actually. And so anyway, currently I'm working on a new project that's called D-Book, which is a document creation tool. And so the talk I held today in the morning or the early afternoon was about how we do data management. And another thing we did is security. And so security is if you get it wrong, it's very, very, very expensive. And a lot of things happen because people don't have a plan. So just the adobe hack was like $150 million. I mean, just for a stupid error. I mean, that's a scale that's unbelievable actually, right? So what we did is when we started the company, we didn't have a lot of money. But we've looked at the web stack and we sort of said, what rules can we sort of deduct? What rules can we sort of see that we can extract and act on them accordingly? Security is always a trade-off. I mean, you'll never have the perfect secure system. Never. I mean, in the worst case, people will come along and shoot you. And probably after they've shot your kneecaps, you'll tell them any password. So it's always a trade-off between how secure does it need to be and how secure can I make it? And of course, you've got the monetary aspect. I mean, if you're working in a company, you can't spend all your day working on not every company, but you can't spend all your day thinking about security, right? I mean, there are some companies, obviously, that do that. But most companies don't. Most companies let their programmers decide about security. And that is pretty much the worst case again. So I'm sort of quite convinced that a lot of the errors that come up in normal day-to-day life can be resolved through planning and the same with security. I think if you think about what threats are there towards my software, what do I have, which needs security, and what level of security does that data need, I think you can mitigate quite a lot of these threats. And what is valuable for your company? Is it the data? Is it the code? Maybe you're open source, so you don't have to protect the code, right? You can just say this is the code. Maybe it's false, so use uploads. So basically, you need a sort of roadmap. What's important for your company? And if this leaks, how threatening it is to your business model? And obviously, what to do if it happens. But in this talk, I want to sort of talk about some of the threats we identified at the beginning and how we challenged them and how we sort of tried to mitigate them, at least. So first of all, physical access is fail. If somebody has physical access to your machine, it is compromised. Basically they can do whatever they want with it. They can plug in USB devices. They can plug in keyboard sniffers. They can do whatever they want. It's very, very, if not near to impossible to secure a machine if intruders or attackers have physical access to the machine. There are some approaches and stuff, but in theory, you could change the main board and change the chip or whatever, right? So basically make sure that your servers aren't secure locations. Make sure you know where the servers are, maybe. Make sure who you trust. That's very important. Do you trust that hosting provider, that hosting provider? Maybe just pop by and say hello and see if you can get into the server room, which I actually, for an old job, I tried and actually got physical access to my server without identification without anything. And then we changed. So make sure where you have is secure. And then try to monitor your servers. So they're very easy things just to sort of see if somebody's tempered with your device. I mean, some hosting providers offer like video access that you can sort of see a video stream of your server. If you're handling bank data, that might be very sensitive data that might be something you want to think about. Maybe get the servers in your own location and think about. But then obviously the cleaning lady might have access, which was another hack, the cleaning lady actually hacked the machine. And so physical access in general is fail. So check out who has access to your machine. So the first real threat is somebody steals your hard drive. And this has happened quite a lot of times that somebody just went into a computer center and pulled out a hard drive. And it's astonishing to see how many people don't encrypt their hard drives. I'm astonished how many people don't encrypt their laptops. I mean, imagine all my company secrets are on my laptop. And it's in my bag. And it will be stolen. I know the laptop is going to be gone at some stage in my life. All my telephone, exactly, which I know these things are going to vanish. And they have vanished. And in my old office, they just opened the door and took out all laptops. So what would have happened if all our data would have been on, all our data was on there, but it was encrypted? But let's say somebody else would have come in there and looked at all our business data, looked at all our customer records, looked at all that. So I'm still really, really astonished if somebody doesn't encrypt a laptop. And I can only tell you Mac, it's super easy, Linux, it's super easy. Even OpenBSD, it's two clicks. So encrypt your hard drives. Even on your servers, basically performance hits are near to zero. So I did some benchmarking on this and we had a really, really small performance overhead. But looks on Linux is super easy. And sometimes you get some problems when you have to reboot, when you have to rebuild a RAID array or something. But it's a total trade-off that everybody should take, right? It's so easy to get going to a data center, pull out a hard drive out of RAID. The assist admin won't even know you've lost all your data. You've been compromised and you don't even know it. Yeah? So this is a typical trade-off, right? So on some servers, we just encrypt the database partition. So we just say, okay, if the machine reboots, if someone tampers with it, fair enough. Because we know so that the location is secure. But I would, I mean, on laptop, short out advice, encrypt everything. But on servers, it's a sort of trade-off thing. Because the problem is if you encrypt everything, even your boot partition and you want to reboot, it's very hard to add the password. You have to sort of remote V and C in. Which we do now. On the book, everything's encrypted. And if a machine reboots, I go through the whole horrible V and C thing, enter this stupid password. So we would try not to reboot. But yeah. So it's a trade-off again. You always have to see what data do I want to protect. So clearly, if you don't encrypt boot, anybody can come in and rewrite boot. But if somebody pulls out your hard drive, he won't be able to see your data. Whereas some people actually encrypt their database partition, but don't encrypt their swap partition or don't encrypt temp. And you've still got all the data. So the second threat, someone gets SSH onto your server. And this is like the mega super threat thing. Which happens a lot. I mean, if I look at all the SSH bots, I get that ping onto my servers trying all these different passwords. And I'm like, why are you still around? This is something that everybody should be able to really easily mitigate. And so don't have accounts on your servers is a simple thing. Don't have user accounts on your servers. Of course, if you're hosting, if you're your SSH provider, you should. But on a web server, database server, there's no reason why you should have user accounts on that server. Why should XYZ be able to go onto that server? Use configuration management to do that. There's fabric. There's so many configuration management scripts out there. No developer or admin actually really needs access to a server anymore, in my opinion. Use certificates is the easiest. Don't have passwords, basically. So a few years ago, we did a few thousand machines. I think we did 150,000 machines or something. And we had no passwords. Everything was done with certificates. A simple thing is use fail to ban, which I would also recommend. Then you can, so if somebody gets SSH as a low user permission sort of thing, you can gain some security for randomizing memory and encrypting swap and stuff like that. But this is sort of a last resort. I would always randomize memory anyway because your software, your web server might have some error. So you don't want a noob slide or something happening. Only allow SSH from certain IP addresses is probably the most easy thing to do. Just open the VPN tunnel to your network. And what was one of the most funny experiences in my life was having a honeypot that would open up once in a while to these SSH pings. And a friend copied this idea, but he did it on his production machine. And yeah, it went all quite wrong. So do a file or redirect or something to some honeypot machine. But really good. Try it. Just leave something open. A machine you don't need. Just put a password, one, two, three or something. And then just track what people do. It's hilarious. I can't agree. I'm trying to find out how to get to the end. And there's probably, they don't really know what they're doing. 80% of them are script kiddies. Just, sorry. I got a production machine. It was architected this way. Like a one hour after the installation and before it was up and down. Exactly. Before it was up and down to change everything. Exactly. And they'd score that like two weeks after. It's amazing. Because nobody could be here. They're very good at it. These scripts are extremely well-adapt. They try all different SSH versions. They try to figure out which SSH version you have if there's an error in it. So I don't have port 22 open publicly except if it's a honeypot. So if you try the machines, it's a honeypot. That's exactly what I did there. I had a different SSH port and everything that would come into 22, I had an IP table rule just redirect. Now we go in through VPN. We have a closed VPN. Especially with IP version 6, a lot of these problems go away. Because you can just say this is my private network thing and you don't have. Yes. Yes. Yes. Obviously. I mean, probably don't run it anywhere. That's important. The Amazon free instances are quite funny. You get a considerable amount of hacking out of those free instances. Amazon does shut you off at some stage there. So then we come to the next threat. Somebody uploads dangerous files. And I see a lot of open source Django projects go to PyPI and it's sickening how many people don't check stuff. They just do the standard Django upload field and they accept this as being the perfect security. Which is it not. I mean, it's Django upload. It's literally get a file and save it somewhere. It doesn't check what file it is. It doesn't check what type of file it is. It doesn't check for size. So obviously have a different process serving your media and static files to your actual files. Have an Apache or an NGX or something. Basically have it separated. Another thing which is really easy to do is verify uploaded files through Python magic or some other thing. Just do a fingerprint on the first few bytes and check is it really what I'm expecting. Sorry. So think of maximum file size. This is like a classic. Just upload a five gigabyte file and see if the server holds up. Very nice to fill up temp, for example, because what happens is it saves everything into temp, first of all. And you just open enough threads and then temp is full. Another thing, a lot of services offer you to upload files, right? So why not fill up their storage with uploading millions of files? Script it and that's it. Check file permissions and access. You can see. Yes. I'll show you the script that actually mitigates this in a minute. Check file permission and access. You'll see this a lot. And a lot of the code reviews I've done or I do, I see this done wrong. I mean, I see people CH modding 777 on their web route and because S-square light needs it. Yeah. So basically, you'll see this loads because every time I wrote this slide, I thought, I saw this being done wrong. And every time you'll see this, you'll know I've got a story to tell. Unicode was a problem, isn't so much anymore. There used to be horrible Unicode things happening that will crash Django and do horrible things. Now it's not so much. Check file names is always a good idea. Sort of see if the file already exists, steal this. This becomes very interesting when you have big production environments that are multi-threaded that start writing to different file systems and stuff. So here's just a really simple thing how to check that test.pdf is really a PDF. It's as simple as that. And like this, you can verify is the uploaded file really a PDF. Please keep in mind Django really just uploads the whole file and then does all the checks. So this is a threat you'll have to configure Apache or NGINX whatever server you're using to stop this. Then this is pretty much it, right? You see if a user, the count is over 1,000 you say F of because you know a file can only be five megabytes. You can calculate when you're going to have a problem and you'd send an email when it fills up so you can stop this. But it's as easy as that to stop end files being uploaded, which a lot of services actually allow you to do. I know a lot of Django projects where you can just upload as many files as you want and it will just crash the server. Maybe then somebody downloads files they shouldn't. This is probably one of the problems that comes from having your upload server being different from your file server, your static file server, your media file server. That not everything a user uploads might be public and just protecting it through a view saying is the user allowed to see this is not enough because obviously you're serving a file served by a different server that's not aware of what it's serving. So this URL can be served out to the whole world and everybody can see that file. Does that make sense? That was a little bit confusing but I hope it sort of came through. If you didn't understand it ask me. So there's this private media package which is awesome. It needs a lot of patching but it's still awesome. And what it basically does it says okay I'm going to do all the file serving for you but I'm going to use a patch to extend files to actually then serve the file which basically just says it says to actually serve this file for me but it does all the checking for you so you basically write the check routines and like this you can guarantee that the static files or the media files more that user uploaded actually only seen by the users that should be able to see it. You lose some performance because obviously the media file will first of all go to Django it will be checked and then Django will hand off to Apache and do it. But this is like a really thin layer and I did 10,000 requests and I didn't see any change in performance so I assume it's quite low overhead. Have a look at it it's a really cool tool. Ajax is your enemy as far as it goes with Django. A lot of things that Django brings out of the house that are really nice don't work with Ajax anymore. I've got quite a biased opinion about the Ajax but okay so if you use Ajax if you have to use it be really, really careful. A lot of things are just not done for you anymore. All this standard Django niceness that we'll come to at the end is sort of omitted like escaping doesn't work properly. You can really see it was an afterthought. It was really thought we've got this amazing model view thing and it's request and response are we need Ajax and then they sort of plonk it on top. Performance is not the best. That's probably the thing that annoys me the most. It seems to be quite slow. It's very difficult to get it right and secure. I've seen horrible code there and very unsecure code. So if you have to do Ajax maybe look in some other direction or be really careful. So a threat that I don't think is so big but we still got on our threat list is what happens if that's a security hole in Apache or NJinks. So what we do is we only include models we really, really need. So we're very careful what do we include when we start the service. We're really, really careful when we configure it. Then we only use configuration management to configure it. So nobody is allowed to just SSH into the production machine and change something because it's easy which is the classic. It has to go through the whole vetting process which we have when we do the configuration. And like this we try to avoid stupid configurations and keep your packages up to date. I mean that's probably the most, that's why probably you should not use Gen2 but use, I'm going to make a lot of enemies here. Use something that you pay for is basically what I've had the experience with. I've had very good experience with Red Hat and stuff. I know Ubuntu has very good packages and Devian too. They're very fast in fixing packages. I wouldn't know why you would have production servers that don't update their packages regularly. Especially SSH, Apache, hours count here, right? There's a zero day exploit. You're talking hours to minutes you want to fix this because you're going to be one of the targets. And if you haven't fixed it till then, you're a target. So if you rely on a small Linux distro that's compiled by two people that are sleeping at that time, you're compromised. So if you're really running production-grade stuff, dish out the money, get professional support, pay somebody for it, it's worth it. So we had this case, we were running Gen2, that's why. And they hacked us because of a zero day exploit. And since then we've been running Red Hat and CentOS and it's been amazing. Someone can read source files, which isn't that unlikely, which happens quite a lot, that people gain access and can read your source files. Probably your source code is probably not as big as a problem if you're open source and stuff. A lot of companies rely on their source code as being their business value. That's quite horrible if that leaks. But basically I've seen in settings files, I've seen passwords. I've seen passwords being one, two, three, four. Secret keys being one, two, three, four. It's not hard to get it into the OS environment and not make it visible right away. What I saw last week is Git and SSH keys. I saw the private Git or SSH key in the repo because he was too lazy to have it in his own home folder. So he could do Git pull. He had his private key in there. Yeah, don't do that. So, someone can write into my source files. That's of course really, really bad. But it can be sort of solved by using Tripwire, which is a really simple, easy tool. Works really nicely. We've never had a problem with it. Some stuff can be done with SC Linux and so forth. Git div is astonishingly easy. Just do a Git div on your directory and see what has changed. And probably you know the files that have changed anyway. But if someone can write to it, they normally won't check the Git repository. And again, check your permissions. Again, I've seen break-ins happen because there were bad permissions set. Someone can execute my code. This is probably another really bad case, which is a really easy case is once a user uploads a file and you've written it, just change the permission. So you can't modify it and you can't execute it. Just set it so you only read only every file that is uploaded by the user. You get rid of a lot of problems like that. And it's one line of Python code. So then you have to think about where am I saving my data. And so somebody is writing your code and that's really, really bad. But what else can you do? In theory, he can gain access to the database, right? So what we do is we disallowed a leak on the database. And we go even so far, we say that you're not allowed to update the database. So if somebody can go in, he can still read all the stuff in theory, but he can't modify our data. So he can't inject false data. Have buckups? Really, I'll come to that a little later, which I cannot stress enough. And obviously have source files read only. Someone can modify or read your backup. This is like, so actually what happened in this story is they had this huge server and they backed up on these tape drives. And that night somebody kicked in the door, took the server, and of course he took the tape drives. I mean, they're there. So they had all this encryption and everything on their machine, but the tape drivers weren't. So that company actually went bankrupt because of that. They actually had, they lost all their business because they had to notify all their customers that they were compromised and all the customers left. So yeah, as dark as that may sound, think about your backup. Use an extra process and a different user. Use write-only storage, which is really simple, just like a dropbox. You push it in there. If somebody compromises your machine, he can't compromise your backup. Obviously use encrypted storage on your backup and transmit it encrypted. When I was a student, we would just put a hub in the network and would sniff all the network of the whole network. And in my student house, 10 geeks, amazing stuff happened. So seeing what everybody was doing, it's so easy, right? I mean, just get a little hub and plug it in there. And instantly you see everything. Check the certs. So the typical thing is somebody brings up a machine in your network, starts a DNS server. You're using some DNS server that takes longer to respond and suddenly he's a backup machine, right? So because he answers faster than the DNS? Yeah. Yes, exactly. That basically goes with use encrypted storage and transmission. So yes, yes, that's very true. Very true. I forgot that. Yeah, that's a very good idea. So basically encrypt your backup and sign it. Check the cert. So have a certificate on your backup server and check that it's really the backup server. Don't just push it to any IP address that you hope is in the machine because you can't rely on DNS. DNS is really unsecure. Just start a DNS server in any network and you can take over pretty much anything. Never throw away backups. You never know when you were hacked. You never know when you might need it. The cost of keeping a backup is near to nothing nowadays. So why would you throw away something like this? The next threat, somebody can read your traffic and this is incredibly easy. Use HTTPS. It's known technology. Get a signed cert. I know it's snake all. I know it's useless actually. But people will expect it. And people don't trust your service if you don't have it. And I mean, it doesn't really help if you can't, I mean, enough certificate authorities have been hacked and new certificates have been issued. But I think it's worth it. But just use HTTPS. Sniffing the network here is quite astonishing how many people get their email unencrypted. Just doing pop. I'm just saying that's all unencrypted. Just encrypt. You don't know where your traffic is going over. You just, you don't. I mean, enough people here have got their laptops open, their browsing websites and anybody can see it, right? It's an open network. Or your email that you get over pop if it's not encrypted, everybody can read. So use these encryption technologies. They're standard. They work. The NSA can crack it, but the NSA will come in and shoot your kneecaps away, right? So we're not talking NSA-grade security here. We're talking the average guy with a laptop sitting in a conference room doing a network sniffing. Who's logged on to you? I can see it all here. In Django, there are two very easy configuration setting files or setting parameters to ensure this. Obviously, you don't want your cookies to leak over an unencrypted network, especially not your session cookie. So somebody can read your database. So there's a classical thing when somebody hacks the machine, he does a select star on the user database and saves that, right? And then he adds a new user that has admin rights. So he has admin on the whole system. Those are sort of the normal steps you'll see in any compromising situation. First of all, get all the data you can, all the password hashes. I deliberately didn't go into hash your passwords. If you don't know that, you shouldn't be doing programming. Sorry. If you don't hash your passwords, if you keep your passwords in plain text, leave, get a new job. I'm sorry, you've lost it. I have to be honest with you, if somebody saves clean text passwords, just, I don't know, build, no, just go. I have no advice for you. So what we do now is we do these really interesting Post-Escal stuff with Table Update and stuff. It's not very scalable and not very nice. So we do these other things that we override the delete method and stuff, so if somebody can execute stuff, we say you're not allowed to delete. And we override the base item manager, the models manager, to do like filter, we do some checks in there. But obviously, in a compromising situation, that doesn't really help because somebody can just uncomment those functions. I'm sort of relying if somebody can edit the code, you can't restart the server, so we've sort of got some security there. Yes, yes. So we did in the model now, which is probably the worst idea thinking about it. But anyway, we just don't allow in the database. So this is just sort of backup for security reasons. So I've been working on something which is not finished yet, which I hope I'll finish at some stage. And I'd love your input on this. This is one of the reasons. Yes. Post-Escal, that's what we do. That's what we do. So you have this, basically you have this process, well, permission. So this function is just, we add it to make the life harder and for bad programmers to get a bad response. Because actually somebody was coding and he's like, it doesn't work, it doesn't work. So we added this. Yeah. But exactly. So the problem you have there, if somebody's managed to get into your Python executable, he can override all that. Because what he can do, he can just put the super function here instead of that, because he can just take that method and overwrite it. So if somebody, so the threat scenario is somebody comes in, he manages to open the Python shell in your browser or in your web server somehow. And obviously all your code is in there. And then he can obviously overwrite everything. So the security in the app doesn't really help. Because the only real threat scenario is, A, you've got a bad programmer. Yes, this helps. But you sort of assume your code should be good. Or somebody has come into your web server and he's got access to your executable files and then he can just overwrite this, delete it, whatnot. So you really can have some people or some code to delete. Yes, yeah, of course. Exactly. Exactly. So this would be the right thing to write that into, into the delete. All you, all, what we do is we also overwrite the filter and the all and the get. Exactly. And then you'll sort of secure that everything that builds on top won't, won't destroy anything. But anyway, I didn't find anything I thought was secure. The process well permission stuff is really hard and really easy to get wrong. I didn't know anybody. I couldn't find anybody that really knew it. That was really weird. I hired people and we couldn't because nobody really knew. And we can't fix it in the code. So what can you do? You need to lay in between. And I'd love you to put on this because I've been coding this basically. And I don't know if it really, I hope it makes sense. But maybe you've got some ideas. So I'd love your feedback after in a few minutes. So basically what I've done is I've written a server that identifies himself as process well, that he verifies the login credentials with a real server. And then he takes some queries and he parses these queries and just so the queries Django creates for the OIM are really, really simple. I mean, most of them, you know. So what I do is I, I learn queries from my test cases because I've got tests that run and I know which test cases they run and I also have like some user behavior scripts that I extract from live data. So I see how does the user react? What does the user submit? And I use this to train my security model. And then for now, I have to tag variables manually. But hopefully in the future, the script will learn automatically what's available and what's not. And so I write a regex which says this is how this looks like. And then as soon as I, and then I train it, I've got this data set, I train it, then I've got a big regex tree at the end of the day basically. And as soon as something doesn't match this regex tree, I say, okay, I don't know this query, what am I going to do? And so when we deploy this, we'll get a few notifications, we'll have it running on a shell and the query will just stuck stuck there and I'll just do, yes, okay, this looks good. Well, this doesn't look good. And then it will learn this, hopefully, add this query to the training set and so forth. And so hopefully at some stage we'll have a complete regex with all the queries we will expect from the server. So then I want to, or what I do now is actually I assign a trust variable between zero and one to each query. This is really crude. But ideally you would say, okay, this is my logging database, queries that have a trust of 0.2, they can go on my logging because I don't really care about that. But on my user database, I only want queries that have a trust variable of one, which basically 100%, this is really trustworthy, specifically allowed in the regex. And it can also have handcrafted rules. So basically this is like the standard rule that's disallowed, select start from users. And I'm like, no, this is not happening. And I forgot the semicolon here, by the way. But select start from users where username equal x. That sounds like something a normal app would run. So I say, yeah, this is okay. What I want to add in the future is that I can then specify this is only allowed to return one record. Because I could say, look, if it returns two records, something's wrong here. Or you're not allowed, users is never, actually users is never allowed to return more than one record if you just do authentication on your app, right? And everything that returns more than one record, I'm like, no. But currently, I just pipe the result through. Don't tell me this already exists, please. If you know of something, send me an email tomorrow morning or when I'm asleep or tonight when I'm drunk. Yeah, so I'll get your feedback on that, what you think. I'd love to pick your brains on this. Then another threat, someone sees something you shouldn't, and Django is amazing in this respect. I really like Django. You just do decorators at logonrequired, and we actually wrote our own decorator, check permission that the user has to be owner, and we do edit authors, and that's it. And this does all the checking for you. And this is so easy, so nice. From the experience, throw errors. If prop don't get something, and then if it's empty, just propagate it through and throw a 500 somebody at the end. Throw the errors early as possible. Weird things happen with null values. The next threat, I have to hurry up. Someone can read your database. So let's say somebody hacks your machine, and as I said, the first thing he does is he does select star on users, right? So what you want to do is you want your database to be encrypted, right? You want the user to add some sort of key, the database encrypted. So there's this really nice encryption library, which I don't know how to pronounce, which is by Google. And what we did is we overwrote the dev to Python and get prep value, so basically all the communication Django has with the database, and as long as it's a text field and a char field. You don't encrypt integers, is encrypted by the key of the project. And like this, if somebody manages to do a select star on our databases, he'll at least just see garbage for the text fields or text data. In the future, we want to roll this out on images too. The problem with images is CPU power, that we don't have the CPU power to decrypt an image on the fly and serve it. We had it and we needed these huge servers we couldn't afford and it was just really, really hard to do properly and fast. But for the database, it works fairly, because the text is fairly small, fairly condensed, it's fairly fast. We've got some performance overhead, obviously, and you lose some queries, you shouldn't be doing anyway like queries and stuff like that. But normally these result in full table scans in most cases, so you shouldn't be doing them anyway, you should have an index. Of course you lose indexing. I started writing an encrypted index, but I haven't finished yet. So CPU power is needed for this, but I think it's worth it because the actual overhead, we have, CPU is not what's limiting us on the machines. And Django Extensions has something like this, and a lot of influence came from Django Extensions that we copied a lot. Yes, so this is on a field level. So what we write is models.encrypted text field, models.encrypted char field, and it takes exactly the same parameters, it inherits from those fields. But the only thing we do is when we serialize to the database, we encrypt it and when we basically get the result from the database, we decrypt it. So obviously you've still got your clean text in memory. I sort of looked at memory encryption and couldn't find anything good, and that was performant. OpenBSD has done a lot in that respect, but I sort of assume if somebody's hacked our memory then, yeah, we're f'd anyway. Then I think I'm hearing more and more now is the users don't trust the service anymore, especially with this whole NSA thing coming up, with this whole, yeah, the service is out to get us. And a lot of services I see are like, oh, yeah, we encrypt everything client-side, and we only upload encrypted stuff to the server. And then sort of, we had a very interesting discussion at the Berlin Django stumptish about this. And then so they trust the server and giving them the right JavaScript, but they don't trust the server in handing their data. So surely if the server is bad, we'll just inject some JavaScript, or we'll just inject a bad key, and then we could still decrypt it, right? So this is a discussion I find sort of followed up by quite the people that haven't followed it through yet, if that makes sense. If the user doesn't trust you, then you shouldn't trust the JavaScript, he's getting from you either, right, because it sort of defines the whole logic. So I agree, encryption client-side and JavaScript is really cool. If we would get this to everywhere, it would be amazing, especially the load on the servers would go down. This is why would the user not trust you, but trust your JavaScript. So a way we're investigating right now is that we will have a plug-in that comes from Mozilla or whatever, and that verifies the JavaScript that comes from us, and all the JavaScripts are open source. So even if we would inject some bad JavaScript, the plug-in would alert, and this adds to security if someone would hack our servers and inject bad JavaScript, also the plug-in would come up and say, look, this is not true. And like this, we sort of hope to have a transparent way of doing it. I don't know if we'll be doing this, yeah. Yes. So basically, encryption in JavaScript is really, really slow. So the first problem I ran into is true random numbers. I didn't find any good implementation in JavaScript of a random number generator. The thing I found was, yeah, yeah, it's time, which isn't random. So the first thing, the API will hopefully, they're talking about a true random number generator. And then the problem with JavaScript is that all the modern chips, they have these really good crypto chips. That's why hard disk encryption doesn't cost us anything. That's why all these encryption stuff is really, really fast because they've got a special chip on their chips. And what JavaScript does, if you have all these encryption libraries, it runs on the main CPU. And that's really slow because the CPU is not made for encryption. So I don't... You know, you're publishing your own source of the set. Exactly. Yes. So the problem still stays, yes, you can encrypt it, even through the new JavaScript API stuff, you can encrypt it really nicely on the client, but you're still pushing it to a service you don't trust. So there's a lot of...I think there's a lot of work to be done there. Maybe some offline JavaScript features, yeah. I was saying one possibility was to produce something that I see in the criticism of the DNS and... You know, basically what you're doing is you're operating... Yes. Yes. In the DNS, for example, the incident that happened, I was watching the whole process with DNS. I read about that too, but I don't know any browser that supports it. Yeah. Yeah, exactly. So we sort of... Yeah, but I read about that and that's a very good idea actually to do... One problem I see with that approach is that updates are going to be quite slow because, I mean, we roll out two, three times a day. So we'd have these very small and we're very fast. Knowing DNS is kind of your... Yeah, exactly. You need that. But... So we're just experimenting with this plugin. This is just sort of the direction we're going. Yes? No, you are... Not yet. Not yet. We're playing around with it. Yeah. Now I am... The plugin is okay, but I still need to... So ideally the plugin... Yeah. So basically what the plugin does it verifies the header. So what it does is it takes a whole head section and does a hash on it. But of course you can put scripts somewhere in the text, but we haven't done that yet. But yeah, so the idea is that if you have the JavaScript open source and everybody can sort of generate the hash in some way, he has a plugin where the hash is displayed, he can sort of trust it. There's no... I haven't found a really nice solution actually. Otherwise Django is amazing. It's all there, cross out scripting, use it, enable it, use it. It just does such a good job at it. Never use the safe decorator basically. You'll get in a whole world of pain. It's just so nice. I mean, coming from program web servers and C and just seeing our SQL injection is dealt with. And you're like, this is amazing. An email header injection, all this stuff is just done. Then again, a personal story. I've seen threat detection working perfectly, but nobody responding to the email. And actually this happened a month ago. Oh yeah, it was his job. It was his job and it was a circle. And so nobody did anything. And the server was hacked and it was standing there for days until somebody sort of looked at the server so he's still hacked. And he's like, yeah, it was him and him and him. So be sure that you notice when you're hacked at least. There are some papers, some research done on this by University of Oxford that say it's more important to notice when your server's been hacked and just destroy it than actually preventing hacking. I don't totally agree with that, but I sort of like the approach that you sort of monitor, really hardcore your server. And if you notice anything weird with that server, you just kill it. You just freeze it for analysis later, but it's not in the production server anymore. So I can't stress this enough. Have a central log. I've seen, let me finish and then have a central log. I know people that have 30, 40 servers, huge servers that don't have a central log. Emails are not enough. I get a few hundred emails every day. If that goes into spam, I will never read it. Have error follow-ups. So what we do now is all our error messages go to basically a bug tracking or support tracking system. And so if some monitoring service detects something, it creates a tracking cookie, our tracking task. And one of us has to follow it up because otherwise it's open. So one of us has to go there and say, okay, I've done this. I've solved it. And we have notification propagation. So if somebody hasn't acted on a task in 24 hours, we email his boss, which is incredibly effective. You had a question. Yeah. Yes. So the idea of the security is that we have to do a security check. Yes, so the idea is that you pull up new servers, obviously while you're doing it. But I read the paper two, three years ago, and I was like, I saw a lot of flaws in it too. And you've got like, you've got like, what happens if the notification is wrong, right? You just shoot off a user every time he tries to upload a picture of his family. And somehow it's a different color encoding. And you're like, no, I don't like this color encoding. And the session times out, which is not user experience you want, right? And I find it very hard. So what they did, they froze the virtual machine and they then analyzed it later. But I quite like that we get an email or ticket. And then we just go in and check right away what's happening. And we can sort of see if it's a real hack, which hasn't happened so far, or if it's something we didn't expect and can act on it and stop more notifications coming in. Yeah, so basically ask me stuff and check out Dbook. Yes. So we've got everything virtualized anyway, because we've got multi. I personally think Docker makes a lot worse because I know how programmers do Sys stuff. And I wouldn't trust, OK, there are some programmers that can do it without question. But I've seen some of the fabric scripts I've seen in my time when programmers try to do deployment. And it's probably this whole DevOps thing, right? It's always Sys admins against programmers. And I quite like just deploying from a Git tree and doing the whole staging old school approach. Docker is very, very good if you have lots of developers with different machines that deploy rapidly. Definitely. I wouldn't, I mean, how does it contain security threats in the respect? It might contain it in the Docker, but it also does it in a virtual machine, right? So yeah. But we do that in virtualization. Yeah, it's process isolation, which we do with virtualization. But we do it actually with physical machines nowadays. But yeah, I agree. Process isolation, I'm very astonished. I haven't come to the desktop yet, because a few years ago I had my Firefox in a virtual machine because I was so afraid of security holes in Firefox. But I don't know why, I mean, process isolation has been around for 30, 40 years. And it hasn't really happened yet. But I agree. Yeah, I haven't played around with Docker too much to do it. But yeah, we do it with virtualization. That's basically what I can say, which is just a bigger layer, right? Yeah? So we do it on the local machine. Basically we have a cron job that has a nifty Python script. And then we have Hadoop jobs that take all the log files in and do monitoring on that. But we do that two times a day. We have a big Hadoop job that kicks in with all the log files, because we have some historical analysis going on there. And for example, what we also do is we have user behaviors. So imagine a timeline, and you have clicks or actions on this timeline. And so what we do is user behavior changes over time. So a user will become more proficient as the longer he uses the software. But what you can do is you can sort of see how advanced the user is. And then if he does something really weird at some stage, you can sort of see, okay, this is sort of what he should be doing at the beginning. And so it says girlfriend using it mostly. That's the average case where we've got quite nervous and there was just this girlfriend kid or something using his account. But so we do that in Hadoop. We do classical map reduce. We're looking at stratosphere to do that was their stream processing, which isn't ready yet. I haven't found a really good real-time stream processor yet in big data. And we do really, really slim real-time logging on the machine. Basically, just log file analysis when we stream it off to the master. Yeah, that's an interesting question that I hope nobody would ask that. So the future is that we store the keys on the client and he gives us basically something to decrypt it. What we do now is we have a really locked-down database and that's all I'm going to say. So we still have all the keys in one central repository just because we haven't had the time yet to have a proper key distribution. No, so select or users doesn't work now anyway. But no, it's a total different system. So our key storage is something I don't want to talk too much in public, but I know it's not 100% secure because ideally what you would want to do is have the password generate some sort of key that does a decryption. But I haven't found a really nice way that if somebody loses his password, all we have the sharing feature that many people can access and edit a document. And it becomes incredibly complex if you want to do this key encryption like that. And maybe I'm not good enough at math or something, but I haven't figured this one out yet. So now for now, because time is limited, we just have a really secure key storage which is handwritten, which hopefully is secure than any data. It's a modified Kerberos LDAP thing, basically. So we have 16 shards, so roughly 20 machines, probably a little bit more, and we use SCP. And then we do analysis on it. Clearly, I haven't had the time yet. I know there are lots of solutions out there. I know there's a lot out there I just haven't had the time yet to do. So for now what we do is we do SCP, and then we just have Mooneen that reads those files, which works quite well because we just have an SCP tunnel that is open, and we stream to the file. So you get all the advantages of SSH, it being encrypted, it being fairly fast. We have the key authentication and all that stuff. And we just pipe. We just tree, basically. And SSH has been incredibly good. And it works. It was a hack, and it works. And we detect when the SSH tunnel comes down, so we know when a machine is sort of having a problem. He was first, sorry. No, I guess we're talking about finding lots of life. So we just need to have a compromise. We can do a post-mortem analysis. Exactly. Exactly. And it's the same thing you said, that there's compromise in just a minute of production, but then you should go post-mortem analysis on the post-mortem analysis. Exactly. And like you have a problem memory, over the binaries and the post-mortem, everything you can get, it was dense, out, and sort of, literally where it is, where it is, and there it is. So basically just freeze it, right? We have virtualization, just freeze the machine and put it somewhere where it's safe and then analyze it, not being live on the network. Yeah, yeah. The problem with the entity is, oh, he can't detect or edit with my data. Yes. Probably he can't edit it. No, he can't edit it. Why don't you do so? Probably he could modify the file pointer and, yeah, probably he could modify it. Now you all know, right? And the internet knows. We have to change this tonight. Yeah, of course, it's not perfect. I agree. Obviously, I just hadn't had the time yet to optimize it. I'm a very small team, and I'm luckily exponential growth, which is horrible right now. But, yeah. It will go to the honeypot. It's fine. Yeah. We've already known about production. Yes. I mean, obviously, you need one user to get in. We knew that, so that's good. And originally, we knew that we were running the configuration. Okay, so no user that, so what we have, we have a normal login user. Root is not allowed in by SSH. So we have the standard, I don't actually know the password, because on user creation, I just set a massively random password. But that user has sudo, and then can get root, and that's how we run the configuration management. But, yeah, you always need one user to get in. I wouldn't know a way. I mean, what I've been thinking about is using LDAP to basically have one central user that we sort of manage, but I don't see the big advantage yet. Yeah. Yeah. Yes. Yes. I mean, we have accounts. We have WW data. We have process squirrel. But obviously, those users don't have a shell. They don't have SSH access. They don't have, so we still have that one user that we can get into. But only a few people have the certificate to go into. And I hope that people don't do stupid things. Yeah. After you finished the conference, you know, it's like the other, our thing is the password. And you can say, hey, I've got my TPC S35 here. Based on all of our servers, and be sure that this one user is available on our fan site. It's a cylinder. How do they call that? They've got the secure storage thing, haven't they? A silo or something? Salt has this really cool secure storage container where you can put your ETC password in it and we'll distribute it in a secure way. But I... So if you're in a void, there's someone going to add something like that because it files a whole bunch of servers and takes my orders. So actually you can configure a salt that will actually phone out. So you could get rid of your user if you really wanted to by getting salt to get the salt master and get this configuration file from the salt master periodically. But I wouldn't, I haven't dared to do that yet. So again, physical access is fail, right? But just a few days ago, exactly that happened, I locked myself out of the machine. Not for this project, for another project. And I just went to the virtual machine, to the console. I rebooted the machine, put single at the end of Grubb and I was root. It was that easy, right? So that's probably something I should have added to. The dashboard of your virtual machines is probably the most important thing you've got. If that password isn't that long, because as soon as you can reboot the machine and you've got the dashboard, it's compromised, right? So yes, yes, that will come, definitely. I mean, we've got that with email and all that already. But I've got the app on my phone and I haven't gone that far to have the SSH stuff go that far. So in the future, we'll probably have that. So the PAM two-factor authentication rules have been around for years and it's well tested. Years back, I mean, this was 2007, we used LDAP with two-factor authentication, Kerberos, and it worked perfectly. I mean, you just have to buy these quite expensive RSI tokens and that were hacked by the NSA, by the way. We bought thousands of them and everybody had to carry it around and it was horrible to maintain. And then the news came, NSA had hacked them and we were like, ah. But yeah, so that worked really nice. So getting two-factor authentication in Linux is editing five lines, I think, of code. Just add the PAM rule in the PAM stack and it works. The biggest problem is the synchronization of the seed in all servers. There is a product here, a open-key, I don't know, that's basically a separate that's comprised of the seeds of the two-factor tokens, the inside of the seed. You have a range, if you want, of the range, the other server, the one-fringer, that's it. Exactly, yeah. We just did it with ranges. We didn't have a synchronized seed. If you want to fix that, you can use the antipyro-spoke code, you have much more space. Exactly. Yes, I agree. Probably the future, I think, is with phones. Everybody's going to have an app on their phone and it's going to phone in and phone out because my phone's online all the time. But I haven't seen anything useful there with Linux. Maybe there is. Questions? Or comments? Nobody commented on my genius idea of the self-learning SQL algorithm. This is hours of my life. That was the main point. Cool, so thank you very much for listening. I'll see you at the beer booth thing.
Web-App-Encryption Is your data secure by default? How Django can be used to make you sleep at night. This talk will detail the different threats a web application faces today and how different types of encryption can solve many of these problems. We will discuss the whole web-stack and show various technologies to deploy secure encryption. The main focus will be on using Django as a web-frontent in a highly distributed and load optimised environment. More than ever websites have to deploy encryption to protect their users. First it has to be defined what threats the data faces and how these can be mitigated. It is vital, that a lot of though is put into what is sensible for what use case. We will describe different strategies based on a little piece of software (written in Django) we use to showcase where encryption can happen (client-browser-server-cgi-database). We will back these steps up by real life examples, numbers and benchmarks we have collected from a productive environment. Finally we will discuss some problems that arise, when hosting is out of the house, your backups are encrypted, you have a fail-over distributed environment and you as a service provider can't see the data you are hosting. ······························ Speaker: Didi Hoffmann Event: FrOSCon 2014 by the Free and Open Source Software Conference (FrOSCon) e.V.
10.5446/19642 (DOI)
So basically I'm going to talk about solving your big data problem, which is quite a buzz word, I'm aware of that. But a lot of web apps actually are going to face this problem at some stage. So short story about me, I'm born in London, I've worked for a number of companies, now I live in Berlin. Yeah, I saw that on a C programmer from the base, I did a lot of kernel stuff way back. And now I've got this new project called Debook, and we ran into these problems, so I thought why not share it with the world. So what happens if your project actually does become a success? This is something nobody estimates, but it does happen once in a while. And while you're coding you don't anticipate for this, right? You use one database, you use, and suddenly your data explodes, and yeah, you've got a huge problem. So and then you're sort of thinking, I need to scale. I need to scale this out, we're getting users, all our users are slow. We've got an article on some big news site and the server's down. And you're like, oh my god, what's going to happen? So what do you need to scale? You need to scale your hardware, obviously. You need to, if you serve it out of your own rack, you need to buy more racks. You need to scale your servers. How are you going to have your engines, Apache, whatnot? How are you going to scale that? Analytics, something a lot of people forget most of the time. That doesn't scale in infinity. You need to scale your software, all the software stuff you have around. Your support, if you get more users, you'll get more support. You'll get more support requests. You need more people answering the phone, and so forth. And your network, which turns out to be one of the biggest problems actually. But I'm going to focus on data today, because that's the thing I'm most interested in to be totally honest. And big data. And that's enough buzzwords for today. So this is basically how your data curve looks like, right? At the beginning of your project, you're happy hacking away. You've got your 10, 20 users. Everything scales. Everything works fine. And you're happy. It works. Fast page loads. Everything is perfect. Some stage, you notice, OK, this is slowly picking up. And then maybe here, you're still in the point where, ah, easy. I'll just add another server. Everything will be fine. And here, you're going to shoot yourself. So accounting for the growth of your project is vital if it succeeds. If you're just hacking around on a small project next to your work, don't worry about this. If you actually want it to succeed, if you're actually working on a startup, if you're working in a company, you might have 1,000 users. In my old job, we had a small project, and suddenly it was company-wide, and everything went down. And then we shot ourselves here, basically. And so account for it early on. So there are a few known solutions for this data growth problem by a big single server. I know one big company in Berlin that was selling goods online, and they just bought the biggest server they could get. And they were housing it in this huge server room. And if somebody touched that server, he would be fired. And their whole database would just run on this one huge server. And at night, they had to turn it off, basically, because all the cashers had to rebuild everything. And then in the morning, they pulled it back up. And this was like, it's a stock-listed company now. This was their scaling solution for years, because nobody dared to touch this server. Then by bigger database servers, by even bigger database servers. And then somebody says, OK, we might separate the tables onto different servers. So we don't need all our analytics stuff maybe running on the same server. And user accounts might be on different server. And that's a fair approach. I mean, if all your tables are the same size, which they normally aren't, so you sort of come up to split data up. And this is the painful bit. And then when you're really big, you write your own solution. So Twitter, Google, Salesforce, they'll write their own solution. And that's totally valid, because they've got 200 engineers that do nothing else and maintain this code, write it. But pretty much nobody of us will have this resources to write your own database. It's really hard. I'm not going to leave out cloud services for now. Cloud services have one big problem. You don't know what's happening under the hood normally. If you use Amazon or Google or whatever cloud service there is, you run into a scaling issue. I've seen this many times. We just ran into a scaling issue. It didn't scale anymore. And we didn't know why. We called Google support and they really picked up. And we're like, why is this not scaling? So cloud services really be careful when you use this, because if you run into an issue, you're stuck with it. And you have to find a workaround. So I've sort of put this in brackets, because all the experiences I've had with these is it scales really nice for the few thousand users. And then at some stage, you hit a wall and you don't know why. And it takes you weeks to figure out how to come around or how to solve the problem. So obviously, the first thing is you've got your tables, simple web app, three tables. An easiest thing is you're growing, you're expanding, loads of people. So first of all, I put the database on a new server and it's still, I can grow and grow and grow by a bigger server, grow, grow, grow. And then at some stage, I figure out that was, OK, there's a missing slide. So basically, you split it up in three servers. But the problem is one table is always bigger than the rest. Your user database is probably going to be quite small, because it's just, I don't know, name, password, and whatnot. But probably your product database or your accounting history or whatever is going to be huge. And then you've got the problem again. You've got one huge server that you need to maintain. And you've got all the small tables on other machines, but you don't really gain a lot through this. So this is sort of a very short-term solution. It works for a month maybe. But in the long run, you'll run to the same issue, because you've just sort of taken out a little bit of data, but you've still got this one big. And most projects I've seen have one big table. It's really weird. So obviously, you want to sort of split up the tables into different servers. You want to shard your table, right? And ideally, you'd want three different servers or end different servers holding all your data. So you have 3.1 here, 3.2 here, 3.3 here, and so forth. Backups would be a nice thought. So ideally, you would also want redundancy in this. Again, if you have one big database, one big table, it's very hard to do backups, because you need the same machine again. If you want a hot swap backup, you need exactly the same massive machine that's costing you thousands and thousands of euros. You need the same machine again, exactly as a mirror. And you can't get all these funky features with different locations and so forth. So you shard like this. And this is sort of the ideal solution, right? The horizontal shard, you shard your data, your big data. You shard it horizontally. You cut it up into little pieces. And you get loads of little advantages. You have more and smaller databases. Through that, you get faster queries. Let's say a full table scan on one shard is going to be ridiculously fast because you're not scanning the whole table anymore. Locking is far easier because you've got different shardings. You gain caches. And obviously, you can use probably a lot more cheaper hardware. But if you sort of follow the backup strategy, if one dies, your business keeps running. And you can grow with your data, ideally. If you follow all the rules, you can, I'm going to come to some examples. So we grew to 16 shards really fast because we could just add new servers and it would just rebalance itself and scale. The other side is sharding is really, really hard. And it messes you up. Tell your girlfriend or your partner that you're not going to speak to them once you do this. It really messes up your life. I was shouting at people. It wasn't nice. It's really hard. Getting it right is really, really hard. So enough of the theory. So this is about Django in some respect. So the standard database setup in Django. So who knows Django? Who doesn't know Django here? This is maybe the better. Excellent. So I'll go into more details. So basically Django is a Python web framework which has a model view controller. As you basically, you can specify this is my database. These are my views. These are my controllers. And it takes care of all the nitty-gritty stuff, let's say. It does the object mapping for you so you don't really have to care about the database at the beginning of this whole project. You just say, okay, my data is saved there. And for example, here I've got an SQLite instance. So I say my databases. I have my default database which is SQLite and the path of the SQLite file is here. And then Django takes care of all the rest. It creates the database for you. If you have updates on the model, it will create the data. It will update the database for you. It does all that stuff for you. So it's really, really nice to hack up a small project like Rubon Rails, I suppose, is one of the other alternatives. But then Ojoi, obviously you've got multiple databases, right? So as soon as you start shouting out, this is like a really simple vertical shout, right? You've got your default database where all the stuff is kept and you've got your user database somewhere else. So let's say this would be appropriate if you have a huge user database you want to keep somewhere else. And maybe you even want a different database back end because for some operations you're doing mySQL is more appropriate and the other one, post-sql is more appropriate. So you even have this support with the databases that you can even choose the different types of databases you have. For example, we have a logging database that we have a total different database system there because logging has total different requirements in our transaction database, for example. So through this, you can really easily say, I have a default, I have a user database, save my appropriate models into the different things. For all the Django, Python-y people here, very easy you just say, database migrate and you give in the database, users, and it does it all for you. So this is fairly out of the box, fairly standard stuff. Then this is actually copied out of our config file. This can get ridiculous complex. So you see all our data shards here. Obviously, so we have these on different servers. Here you see that our logging database is on a different port because it's a total different setup of database and anybody who doesn't know the database URL package should have a look at it, who knows, because it's so much easier to express your databases like this and not have this huge dictionary, basically. So you see we have 16 shards, appropriately named by Hex, and we have our logging and we have the default and the debug database we have for migration purposes. So I'm talking too fast. If you've got questions, stop me, right, because I tend to talk quite fast. But obviously, how does Django know where to save what? So welcome to automatic database routing, which is a really, really nice feature. I've sort of picked out the two obvious things, read and write. We basically define a class where you say the database for reads should be and the database for writes should be. And here's a very simple example. Basically for reads, I want to read from my replica service and I want to write to my primary service. So let's say you have a simple Post-Ascale setup where you have two replicas replicating from the primary. Obviously, you want to write to the primary, which you basically ensure through this. You say database for writes is the primary server and the primary server you specified here, right, you named it primary. And the replicas are the same. You connect to the replicas and then randomly you choose which replica you want to read from. Is that sort of clear? Before we dig into the depth, routers can be chained, which is really, really nice. So if one of these functions returns none, so if I wouldn't know what to read, I'll just return none and it will sort of chain through the database routes. And like this, I can specifically say this does this, this does this, and I can have a default setting which just writes a default database and reads from a default database. And like this, you can quite easily add load balancing to the whole thing and so forth. So basically, the most important thing with sharding is the right shard key. So if you want to shard, you need some sort of key to decide where should that data record go, right? So you've got all these, you've got your table. How are you going to split up your table? Are you going to take your primary key, which would be a really stupid idea, I suppose. Because primarily, you just fill up the shards and you just fill them up, which doesn't really help. You'd want some sort of key that keeps everything together, right? You want some sort of what are people going to query out? And this is something that's vital. I mean, this is probably the most important thing when you're doing sharding is find the right shard key. Most data looks like this in your database. So you really need to find a shard key that separates this really nicely. If you don't find it, you're going to have one partition or one shard being totally overwhelmed with queries and all the others just idling around and you're actually going to lose performance. So you really have to figure out what is the best shard key, which connects most of the data points. So I can play around with it. Take two, three days of time, benchmark this, look at your queries, look at what data you're retrieving, look at your code, use Django shell and play around with it and really look at your data because if you get the shard key wrong, that's it, right? You've shot your foot off. So in our case, it was not as hard, luckily. So we have documents or POCs, as we call them, and POCs have millions of entries. These entries can be historical. So every time somebody edits something, we create a new one, but we have millions of these. But these are all logically connected, right, through the project. So basically, we said we're going to partition by project because all projects are sort of the same size. Obviously, we're going to have some projects that are bigger, some projects are going to be smaller, but if we take an evil hash, which we did then, we took a hashing function to do shard these, then we can assume that there will be equal amounts of size on every server. And that's totally logical, right? You add a new randomness to the whole thing, partition by that, because if you want equal distribution, randomness is the best you can get. So every project gets a project hash, we call it, and from this project hash, we shard. And a lot of blogs, for example, do the same. Google has buckets and so forth. So this is really nice because as soon as you access one project, you're always hitting the same database. And because your load is equally distributed, you're hitting all databases equally in load. Does that make sense? So basically, make it horizontal, which we decided the model, does everybody know what a Django model is? No, probably not. So in Django, you have models which define the way your data looks like. So you have your views, which render the HTML, basically, and you have your models which define how your data should look like. So a typical model for a blog post would be title being a char, string, you'd have content, being a text, and maybe author being a foreign key. And like this, you can define it more. This is then translated into SQL, run in the database. And so here, you have a very easy router, basically full reads. We said if we were using the statistics model, then we go to the logging database. Because everything that comes from statistics just goes to logging. And this is pretty much write-only optimized database. We just push into it. And then we do all the offline analytics from that. But this is not really time critical. We don't want to save or waste time, basically, writing through the log. Just push it, and it returns commit right away, and it's fine. Because we really want to get where's my data. But we said let the model decide where I'm going to stay. So if you see, if it's an instance, we call the get char method on the instance. And this is a get char method where we basically say get me the project, then return the char, which you saw in the database config. You saw char 1, 2, 3, and all that. And basically the first char of the hash tells us the char. And like this, we have the randomness of the hash. And we can automatically get the char. And it's a really easy operation to get which char to pull from. And so another problem with this is every time we hit the database router, we sort of were hitting the database to find out the project. So every time we were saving something, retrieving something, we were always hitting the database. And this was like a massive performance bottleneck. So we just added some caching, which basically says try to get the project ID. If we know it, we return it. If not, we save it into the cache, and we return it. And this is like vital for this whole cache sharding thing, that you're going to run into these horrible things. That really hard to debug, by the way. So and one of the most painful things is this. So how can I put this? So basically, if you've got different shards and you've got foreign keys, you cannot have foreign keys over different databases. So all your foreign keys are pretty much invalid, if they go over different models, especially as we're doing horizontal partitioning, you can't use a foreign key, because let's say this record points to this record. In the future, this record could be here. And in a different database, even on a different machine, right? We've got six in different machines. So a foreign key, a join on a foreign key suddenly becomes this whole network thing. And it doesn't work. I mean, people have tried, it just doesn't. And so what you have to do is you basically resolve your foreign key to a positive integer and then you start doing this in application code. And this is like a massive performance bottleneck that foreign keys just don't really work anymore. And you have to write all this wrapper code, you have to write all this stuff to make foreign keys work again. And so basically, here is a sort of solution that makes it hurt a little bit less, but it's still not ideal. So what we do is we save the country with country ID as a positive integer, and we set properties as setters and getters. And so basically, you have, if you want to get the country, you return the object. This will obviously then, because it goes through the router, get the right object. But this, of course, is a database. Look at one of the different machine. And if we set it, we do the same. We just set the primary key value. This assumes you have primary keys unique in your whole setup, which is something that's again another talk for itself. I'm just assumed for this, primary keys are unique for every machine. Something when people deploy this, they're like, ah, this is really easy. I actually had a programmer tell me, ah, this is a thing of two hours. And then we had this whole, it wasn't, it was weeks. Because it's really hard in a distributed environment to get a unique key. This is like another really, really complicated thing. And so obviously, when we get it in, we set it. And in theory, we can get out. But this is like hugely slow, because this is another database query. This is the same basically as we have here. That's what we deployed caching, is every time you touch anything in your model, you would trigger a database query, which you really don't want, which is basically dosing the one that holds project, right? Actually we had the case where project was sharded again and doing the same thing again. So actually we had this snowball thing. So this makes it suck a little bit less, but it's still not ideal. Yeah, so this makes it hurt, right? That you have another database. And these are the things you have to start thinking about as soon as you have sharding. That you're going to have all these problems you're going to run into. And you're going to spread the load out, but you're also going to increase the load quite a lot. So stuff to be careful of is hitting the database for every root decision. Yeah? Yes, we could have done that. But then we have foreign keys that we know are going to work in that thing. So in our case, we have this, right? We have the projects and we have these items. And we know that all items in the project are going to be on the same shard. So we have more foreign keys in a project with the items pointing to each other. Because for example, what we do is every time we create a new revision, we create a new item. But we also have a doubly linked list. So we can iterate through all the revisions really fast. So most of our foreign keys work with items in the same project. And we didn't have so many foreign keys between the projects. So we decided to just say, OK, we're going to expand the interproject communication. Because this has to be fast, right? This is what the user wants. This is what the user wants to see. The user doesn't want to wait hours for history to build up. The user wants the history to be there right away. So yeah, that's a conscious decision we made. We talked about this a lot actually. And we were lucky in the respect that we had these projects that had lots of items that are contained space. Social networks, for example, are really, really hard to distribute. So if you write a, you've got posts with users, but what do you shard by, right? Because users see other posts. You can't really shard by posts because you've got all the different users. You can't really shard by user because a user will have loads of posts that he needs to see. So there's a very good paper on how to shard, actually, social networks. And what Facebook ended up doing, because they couldn't solve it, is they would just copy every post onto every machine because they couldn't solve it. When they were growing so fast at the beginning, so every user got their machine. And if one of your friends posted something, you got a copy of that post in your timeline. It was a one-to-one copy. So if you had 1,000 friends and you would post something, it would go onto 1,000 computers. Because that was the simplest thing, because for them, retrieval time of posts is vital, right? They want to retrieve that post list really, really fast. And they want to sort it. They want to do all this funky stuff with it. So they said, data space isn't important. We can just buy new hard drives and plunge them in. But we can distribute this really easy, and then we contain the posts for this one user, and it becomes embarrassing easier again. So that's a totally valid solution if you're working in a social network. Data had huge problems paralyzing their stuff. They've written their own system now, but it was really, really hard. So we sort of got around doing it like this, which isn't the nicest way of doing it, but even a programmer that isn't too aware of stuff can use the country field now. And you can use it, and you can do stuff with it. If he does a select on it, we're basically fucked, right? Because this will be, every select will be a new database call, and it doesn't work. So be really careful of hitting the database for every root decision. Hitting all shards is probably your worst case. If you're doing an aggregate or something, and you somehow manage to hit all your shards, that's the worst case, because you lose, again, the whole distribution. Dot all for all the Django people will not or might not work. Probably will not work. I mean, I've never seen it work. People say it works. I've never seen it work. You shouldn't use dot all anyway. I mean, what you can do is you can use the dot using parameter and then say which database to use, and like that, you can do a dot all on that shard, but you're not seeing the whole database. You're only seeing that one shard. Foreign keys will not work. So you've got this whole new database setup, which is hard to monitor and debug. For somebody who hasn't been doing Django for a long time, this is incredibly hard to wrap his head around. Why is that database going, why is that data record going there and not there? Especially, sorry, when you've got an error somewhere, this is incredibly hard to debug because you end up having thousands of records, and one record is wrong, and you can't find it. You have to hit 16 different machines with their databases on it to find this one record. So it gets really, really hard, but I think it's worth it. I personally think that if your project is growing and you can see the curve going up and more and more people are using, think about sharding earlier than later because you're migrating your data might be a lot of work, right? Because you've got this huge database survey and at some stage you have to migrate this all around your shards. You're not allowed to lose anything. So think about it rather than later. Some links, probably the last one is the most important. You're going to fiddle around with this for ages. And it's going to be, again, very frustrating. And yeah, what do you want to know? And thank you. And I spoke too fast. Questions? Yeah? So the question is, exactly, so have we got a picture of, so basically the question was why not use the primary key as your sharding key? Yeah, yeah. No, it wouldn't because ideally in front of every database, so the question was in Django there's this UUID key which is a unique key generated by Django. And so ideally in this setup you wouldn't have one web server, right? Or even one web process. Every database server would be serving web servers, right? So you have to imagine in a network diagram you'd have probably three to four web servers sitting in front of every database server. Of course they're linked up, right? But there's no way in Django, except using RabbitMQ or using all the different ways, I mean there's all the caching framework stuff, Memcache, for example, is commit. So you can use Memcache to do it, to find a unique key because the web servers will have different threads and all these threads will not be available, the other servers threads being around. So what you can do, which lots of people do is they have one table that generates their unique keys and they just increment that, they use that to increment, or a lot of people use Memcache or other caching software to generate. I think it's more of a reference to the UUID version, Eric, but I don't know. So like a generator, UUID from right now needs to have a... Statistically unique. Yeah, statistically, but then you've got the problem what happens if random isn't really random and you get a second one and that's what we do. Yeah, exactly. But Eric, similar question. Why don't you use the shachi as the point so you would distribute the shachi to all the... Exactly, that's what we do too. So obviously this is massively simplified. What you can do is where can we see this, where's my foreign key stuff? What you can do is, for example, you can have this positive integer field. You can say the first n bits of this integer define my machine and the other n bits are my incrementing normal key. There are loads of different ways to solve this and probably it always depends on the load you have. If you're going to expect millions of database shards at some stage, you're going to have a different strategy than if you're just going to have 16 and, for example, our database config is not going to scale for a thousand machines. We're not going to start adding. Our unique key finding algorithm are not shards, a thousand shards. Just because we saw, figured out, we can grow machines and seeing the data growth we have, we can grow machines and we sort of know the sweet spot when we're going to hit problems and that's so far in the future that we decided not to bother about it. Yeah. At which point would you consider a problem to relate to the database or to find a piece anymore at some point where it was too much? I agree. I agree. I've done a lot with Mongo and Couch. These are very, very nice in this highly distributed environment. When we started this, this was a small project I did on a weekend. I just thought I'm going to hack up something really easy. Then I gave it to a friend and then the friend started using it and then it started growing. The problem is we had so many, when we ran, when we sort of discovered this was a product in the first place, we already had so many users that rewriting all the code that we'd written for like Couch, for example, which I was looking at at the time, would have been too much work. We're just growing at such a pace that we couldn't afford to basically rewrite all the database stuff. For the problems we have, relational databases are quite nice because you have these advanced index features and we have very structured data. I should have maybe put in some frames and slides about the problem set. We have quite structured data. It's basically a title and a text and these are ordered. We do gain a lot through having relational structures and indexes on that. For example, the whole backup we do, we just do with processquale and do replication with it, which is really easy to do. Basically what we decided is we're not going to do backup in Django. What we decided is we're going to do replication on the processquale level because processquale is really, really, really good at having this streaming replication. Obviously, you could do this with Couch or exactly the same. Actually looking back at it now, I would have probably used a non-relational database, but we're stuck with it now. I don't think we're going to ever rewrite it seeing the amount of work we've put into it. What we do is we do the replication. Table one is replicated actually on a really stupid thing on the same machine. Obviously table one should be replicated here. If this server goes down, we serve a replica. Then we've just got an IP switching in front of it. It will just switch the IP address if one server goes down. Processquale is really fast. We have three replicas of all the data that just replicates streaming replication. That seems to work quite nicely. There's nothing in this what we rely on acid. We could have used Couch or something. Yes, and I hate it. We had performance issues with it, which I found quite weird. It would just do weird things. The join pass would be weird in the database, which I didn't spend too much time on it actually. I tried it and it didn't perform well. It seemed like not being scalable to the level of machines we wanted to scale. At some stage, we can now add just a 17th or a 100th machine. At some stage, a problem with unique keys and stuff, but we can fairly easily calculate when we're going to hit this point. I couldn't see it with that. Yes? Yes? What is your development setup like? Obviously, you don't have all these different machines when you're developing, but you should have something that's close to it. Yes, we just... Actually, where's my config file? This is actually taken from our development machine. What we do is, shards are tables in one big process-quel server, and you can see from the ports, they all connect to localhost. They all connect exactly. Then we have the logging on this different server, but it's all on one machine. We run two process-quel servers to the logging and all the rest is tables or databases in one database server. Like this, we can really easily... Because we've got the same config in the development environment. Then we have in the settings file, we just have if production, basically, and we just replace localhost with the different shards servers. Obviously, we have authentication in front of it. Like this, we can really easily develop locally, and also, we can really easily get a sample set of the live production and put it on test, because we have exactly the same setup for test. Test is one big machine, again, with one date or two database servers running on different ports, one for logging and one for the data. Excellent. More questions? I've got one, just a problem, maybe, that would you decide to forge some shard key kind of data to your domain model as well? Exactly. So you can't data the data to your storage format. So what we can do... Yeah, I think... So our shard key is a hash we generate by random, and what we do is we take the first char from the shard key to decide which shard we can. What we could, of course, do is take the next char, take the next two char, and then we would basically multiply the servers. Does that make sense? I mean, to scale... Exactly. No, I mean, like, the constraints, what kind of interest you get from it? Yes. The way you would choose... Yeah, exactly. Exactly. For example, you can't do anything across multiple projects, but... No, exactly. Exactly. So... No, we... No. So the shard key is the most important thing you're looking at, because the shard key defines your whole performance, your whole scalability. If we would now say we want to work on two projects at the same time, it basically would be the most worst thing we could do, right? Because we'd be hitting two computers or two servers all the time. Exactly. But also by using this, we can rebalance quite easily, because we can just sort of do rerouting. So what we did at the beginning when we only had two machines, we just basically said we're going to split it here, and these are going to be one server, and these are going to be the next. And then we saw split it again, and so by growing, we could sort of horizontally scale quite easily by just copying the database over, which was really nice when we had, like, we got an article on, like, a big news site, and we just... It was just exploding, and I just had to change in the config file two lines, and we automatically had a new machine. Like, totally balanced everything, and right away, it all went down again, right? So doing it like this gives you a lot of advantages, but obviously if you get a wrong shard key, that's it. And we hope that's never going to happen. But, yeah, obviously, I mean, like I said, it was Facebook, right? It's really, really hard for some projects to find a right shard key, and that's why, I don't know where my slide was, really work on this. Really be aware, really figure out what are your next steps going to be, what are your next things you're going to implement, B, and try it. It still works with that shard key, and I spent a lot of time doing this, and as some said, as I said, we need a randomness here somewhere. We need a random char or some randomness so we can have an equal distribution on all the shards, and that's when we introduced this hash for every project. And of course, we can extend this to the length of the hash, right? So we could have a few thousand servers, I suppose. Yeah, we add you random. So the hash is a real random string. No, every project has a random hash, and we partition by the hash. So exactly. So the project always stays on one shard. Everything related to a project, pictures, all different types of items we have are all attached to the hash and are all sharded by the hash, and that's why we put the decision where to root to into the model. Because obviously in the model file we have pictures, texts, all different types of classes basically or models, and every model decides who am I attached to, right? So where was it? So here in the get shard, you basically get the project of the item you're assigned to, right? So this will be in an item, let's say a text item, right? And it's defined by the save function that every item needs a project, and so we get the project ID here and then save me or put me onto there. Which is a unique, globally unique. Exactly. That's why we've got the cache. So why don't you use the hash itself as the product would you be able to just reference the hash? Yeah, we thought about that and that's what we actually do in the back end now. But yeah, but okay, this is actually, so actually what we've done now is we've used the hash, so now we've got the projects, we have the problem that we had one project database where all projects were in. So what happened is the project database was just hammered because every lookup would just hammer it. And what we've done now is we've got a key value store that's distributed and we don't even use the project ID anymore. So what we do is we, on all the machines, we have a key value store that is balanced and we use the hash to point to the different projects. And so we've distributed that now. So now, again, we've still got network traffic. Ideally, it will be on the same machine, but we haven't done that yet. You still got one network traffic, but you don't hammer one machine anymore to find out all the project data. And that's why in this example, we introduced this cache because the memcache again is distributed and does it quite nicely. Yeah? So like self-migration and yes. So that's incredibly easy. Yes, you just add database shard one, shard two, shard three, shard four. So what I've done is I've written a full script and I've just got a list of all my shards and what I do is I do an SSH onto the machine and because our machines are sort of named, encoded the shard, name into the machine. So I do SSH into the machine, I call the migration and I call the database. When developing, this is very important. Only have your database routes properly set up because if you do migrate and your database routes are not properly set up, it will end up with data everywhere and it doesn't work. So always set the database. This is probably good habit anyway if you're working on multiple database. Never use this because this will always sort of fall through everything and ruin a lot of your life. Always use the database which you want to migrate and you can do all this stuff, right? The only thing you have to do obviously when you do a new migration, you detect a new migration, you have to do it on the model basically and not run it on all the shards. Be sure to run the migration on all the shards otherwise you're inconsistent. And be sure to do all the default values and everything the same because it will query you for a default value and you might have set something else and you start rebalancing or start copying records over into different shards, you'll get inconsistent data. A new product which you prefer now as well or still stable version of the database? Depends on the project. So the last project I was in, we did CouchDB because it just made sense. This project, I don't know. I think we gained a lot for relational databases because our lookups are really, really nice and fast but we had obviously we had all this pain. The choice using Django sort of said we had to use a renational database because the object map is for Django for Mongo are really, really bad. So probably if I would do it now, I wouldn't use Django anymore. I'd use the front end with Angular or some JavaScript framework and do the back end with Couch. That would sort of because that's interesting and hip right now and I want to learn it. This was really something I started on the weekend and I knew Django, I knew all this technology so I could just sort of kick it out really fast and actually the prototype, the first version that was used by loads of people was actually something I wrote up over weekend, Saturday night pretty much. And then we had so many users that at some stage I decided this might become a project and then the machine went down because we had too many people and then we started doing all this stuff. So we were sort of stuck with what we had. But I don't know if using Couch or something is really the solution for everything that is multi-server. My experience with Couch is that at some stage you hit a really big wall. So we had a project where we had four servers that were rebalancing and then we had mobile phones syncing up and using the revision ID stuff and at some stage we just hit this and it all crashed. And we never figured out why. We just got around with it through doing some intelligent compression stuff. But I don't think it's the ideal solution. You always look at your problem and then look at what you really want to achieve or where your bottlenecks are going to be. But I can guarantee you one table is going to be huge and all the others are going to be small. One thing is to use something like Postgres. I think the code is really well effective. It's been working for so long now. Exactly. But I have one question. How do you do the rebrand if you will be shy? Postgres is a tough company. No. You have to learn your education. We do that manually. So what we have is if we... We don't know the order of shy. Exactly. So what we... at the beginning we didn't use this and we really had to write migration scripts. So if you... Now we're sort of limited to 16 shards. If we wouldn't use the other two, we'd have to rebalance everything, obviously. And that's just a managed task. And we just go offline. We rebalance everything. There's no... No. No. And that's because actually it's quite easy to predict users, it turns out, or user sort of development. So we can quite easily... We've got this Excel file where we can quite easily plot how many users we can sort of stomach. Because assuming that users are random, which they normally are, we... From historical data, we can sort of know we're going to have so many power users. We're going to have so many people that just log in once, try it, or we're going to have so many people that are going to sort of use it. So we quite well... know quite well what the mix is going to be of these users, and we know quite well what the requirements are going to be. And because we use the random key, we know how fast the shards are going to fill up. So we can sort of quite... If... I don't know, maybe if the TechCrunch has this huge article or else we're going to all crash, I don't know. But... So we can quite... We know when our break-even point is going to be and when we need new shards, and when we need to shard further, and go to more machines. So as soon as you've sort of committed on your shard set in this example, you're fixed with it. Otherwise, you have to write a script to rebalance. And that works. I mean, it works. It's a lot of fiddly sort of... But at the end of the day, you just do a select on the database, give me everything that looks like this, and copy it over to the next database. So what you could actually do, you could emulate it through views or stuff like that, which we didn't do. And therefore, after that, we could have done views and just copied the view over, which apparently Perseusical can do now, which I haven't played around with. Other questions, ideas, feedback? Cool. Actually, I'm on tone, huh? Brilliant. Thank you ever so much. Cheers. Thank you. Thank you. Thank you. Thank you. Thank you. Thank you.
Solving your Big-Data problem before it arises, using Django How data sharding can make you perform better and faster More and more websites are collecting huge amounts of data and developers often don't think about this data wave when developing their apps or sites. In this talk I want to describe how thinking about sharing your data will not only make your app scalable, but also faster and the code will be better. This talk is structured in two parts. The first is, about sharding and different strategies that can be used in solving a typical big data problem for various projects. The second part will focus on a Django implementation on how to implement a sharding technology and create a fail over website without relying on any "cloud" providers. We will make the argument, that thinking about how your data will perform and testing these assumptions will make your code better and faster, even if you don't have too much data at the beginning. We will also show these assumptions on our real live data and describe how we shard our data and what motivated us. ······························ Speaker: Didi Hoffmann Event: FrOSCon 2014 by the Free and Open Source Software Conference (FrOSCon) e.V.
10.5446/19640 (DOI)
ƒ ƒ ƒ ƒ ƒ ƒ ƒ ƒ ƒ ƒ Lady alm helfen audience arman uh... wanta bill zasad cell mehr mechanism uh... it sort of repose like other photos in che air uh... Facebook, Twitter, whatever. By building this relations becomes quite hard on the relational database. That's a trick because relational databases make it sometimes hard to build relations. For this we want to probably use a graph database. What is a graph database?      The data is stored in the graph and the recurring nodes, which have properties.     �實 the nodes and we have relations and the relations can also have properties.          It is quite simple to organize data and build complex        , from the social network example, such a graph can look like Aujourd <|sv|><|transcribe|> noting.<|uk|><|transcribe|><|uk|><|transcribe|><|uk|><|transcribe|> Ті, що людей намагає easij У мене є не відкласти За token Ті вже As I already said, it's based on the graph model. It's fully reliable. It's scalable up to almost big data. Another core component of Neo4j is Cypher. This is a query language used to iterate over the graph, store data in it, and probably run select queries. It's also quite powerful, the rest interface. The common way to talk to Neo4j is probably the Java API, but using PHP, we'll use the rest interface as you'll see later. Let's first have a look at the web interface, which is quite powerful. It looks like this. Personally, I find it very clean. We have here an automatically highlighted input line for Cypher query. As you see, this is Cypher query language. More on this, we'll follow. Here in the example, an empty result set and a result set of two nodes. We also have node labels. In here, for example, a re-node has a label. We can use it like a type, but because Neo4j is a schema-less DB, we have no schema, but we can apply nodes. We can apply labels to nodes. Exactly. We also have different relationship types. I'll show this later. Questions so far? I have to use quite a bit of background information on my question. I'm here because I have to at the moment to evaluate so many different databases that I almost have no time to control. I mean, I have heard about Neo4j and heard about it as a graph database. Are there other graph databases that you have? I mean, you say it's a good database, but I think there are some other databases for graphs. Do you tell something about it? The question was if there are some other graph databases and what's the key point to take Neo4j, there are other graph databases. For example, Titan is becoming very popular. It's a graph database based on C, not on Java like Neo4j. There are some others, but I can not list them all. The main point that I took Neo4j is that it is very well documented. It has a large community and it has a very nice query language. As you see later, the Cyphor query language and the rest of the interface is quite powerful. It's the graph database in my opinion, my personal opinion. This is the graph database which best matches the needs we have when we are using a graph in PHP. Let's have a look on the Cyphor query language. Most of you know the standard query language in MySQL for example. It's quite different. As you see here on the first slide, the main feature is human readable, even if it gets complex. In the first slide, we have a simple create statement to create a node. Before I set something on the labels and here a person is the label of the node. I don't must give a label on a node, but I can be more than one label. So it's just for organization of nodes. The data which we want to store in the node is quite simple to read because it's JSON. Finally, on the fourth line, we return the node we just created. On the web interface, this is actually a screenshot that will look like this. We have created one single node and here are the properties. This is nothing special. Let's create some more nodes. Same example, we create three different nodes, all our person labeled nodes. For every node we have an identifier, A, B, C. This example can be every string, it can be longer than one char, but this is for convenience. We return here in the last line all three nodes. This will look like this. We have created three nodes here with the properties. Maybe you are asking yourself what is with relations because we do create nodes, but where are the relations? Why don't we have foreign keys and all that stuff from mySQL? Neo4j handles all relations as objects. These relations are quite autonomous because every relation object has a source, which is a pointer on the node and also a target, which points on the node, and a relation can have properties. That's one of the key features of a graph database. To make an example, nodeMee works for YMC, and I want to name since when I work for YMC. This property does not belong to me and it does not belong to YMC, it belongs to the relation. That's about relation properties. I will show an example in Cypher how to store relation properties a bit later. Let's see an example. We have here a match clause. This is a select in standard query language. We match a first person, me, Frank, and a second person named Memo. We created before those nodes. We match them and you see here the identifiers. I call them S and T for source and target, but this can be any string, as I already said, and we fire another create statement. That's exactly the case how I said it's human readable because this tiny ASCII art here shows the relation between these two nodes. The relation goes from the identifier S, which is the source. The relation itself has the type, the node's width, and the target is T, the other person. So I return those nodes and the relation itself. This will look like this. In this example, the relation itself has no properties, but it links those two nodes. We can even write more complex, more stuffed queries. Here on the first line, I match all person, and on the second line, I do a verb statement like known from the standard query language. This is only another flavor, which is how I can match nodes. How you want to do it, that's your choice. I only wanted to show this second example, how to match nodes. First of all, we create another node, with the label company. This is my employer, YMCE, with business IT, for example, to give two properties. We created the node YMCE, and directly afterwards, we create a relation between me and YMCE, and return those nodes and the relation. This will look like this. As you see, the Neo4j web interface will color the company. Oh, you don't see it. It's here, it's a bit cutty, but you see there is another color, because it's a different label on YMCE. It's a company and other person. That's the label thing. Yeah, over to relationship properties. I have here the example with the SINs property, exactly what I said before. I can here make a property inside the relation SINs timestamp created. The return will be those two objects as before, but the relation itself, the work at the relation, will have the SINs property now. This allows me to get even more into data and to find granular analyzes on my data set. We created a graph. That was all the magic behind graph databases and Neo4j, etc. You see, it's not complex, and it's not this Java thing as Neo4j might be like, you don't need to code Java to use a Java service. If we create some other nodes and relations, this example looks like this. Every person node works with the relation to each other and all have a relation to the company YMCE. Using this quite simple relation node model, I can build huge graphs with much data and do very nice things. Questions so far? Please. The question was, if the direction of the relations does matter, the answer is it can matter. You can fetch all the relations, ignoring the direction if you want, so if you have bidirectional relations, for example, which works will definitely is, but you can match the direction of the relation. I must say, Neo4j doesn't support bidirectional relations, so every relation will have one direction, but you can ignore it fetching nodes. I will see a problem there because we have redundant information because I will say if N-people work for one company, it's clear that everyone works for each other. So, I would say that it's a graph containing millions of nodes and relations between them. Redupting information could be a big problem concerning their troubleshooting software and so on. So, are there some possibilities to do something against it or to be prepared some functional properties or something like that? So, the question was the redundancy between those works with the relation to each other and the works for relation. This is quite redundant data. One point is, in this example, it is redundant, of course, but it can be. Second one, I wanted to say, there are ways to not have data redundant in the graph. There are some very powerful graph processing algorithms that are doing such things, but I cannot really go into it because the speaking slot is too small for it. But if you want to come in front after the talk, we can talk about it. Any other questions so far? Yeah, correct. There's a circle around it. This is an issue in my presentation. This is an example. In the output of the web interface, which makes those nice color graphs, you can click on the notes, this opens this window containing all the properties. There's a border around this node. This only means I click on manual and probably more right way there is such a property window. So it's only a flavor of the output. But this does not mean any data-related stuff. So probably long await the topic using the REST API because we want to use Neo4j with PHP. The REST API is quite powerful as the web interfaces. It covers almost all features. In the question before, we talked about graph processing algorithms. This is implemented, but cannot be used overall. In fact, all features are available, but you probably should not use them. It works out of the box. If you install Neo4j, you will have the REST API. As you will see, it is based on JSON. It is fast. You have a transactional HTTP endpoint. You can manage transactions over the REST API. What we want to do with PHP is call this transactional HTTP endpoint using curl. First of all, a little example. Just using plain HTTP without PHP. For example, to create a node, we send this JSON statement as a post request to the transactional HTTP endpoint. We write down our Cypher statement and the property used in it. This makes it quite simple because data and the statement itself is not in the same line. This makes it easy to generate JSON with PHP. The response we get will show us our data we entered. Just a little hint. This was a kind of direct insert. A transaction is opened, the node is committed, and the transaction is closed in one step. It is also possible to open a transaction, create five nodes with 30 relations, and then commit a transaction. Yeah, that was it. We also can execute Cypher queries, which is the key feature of this whole JSON thing. We have here a match query matching the name I and fetching relation and another node. We are fetching all nodes which are related to the node I. Response will look like this. We have here in the first line we have the columns showing what we got. We have here the nodes property name and node property age, and of course the type of the relation. We get two nodes in here. It is quite simple to create data and get it back without any big overhead. So that was it about Cypher, the query language itself. If you are interested and you want to know more, and it can do a lot more, go to docs.info.j or ask me. Let's get to the usage in PHP. We can use, of course we can write it by hand, but there are some libraries which make this easy. The first one is Neo4j PHP by Arriman. It's kind of a call wrapper to call the rest interface. It makes it quite simple to manage those statements. Example of an implementation, we do the whole outloading by composer or we can do a require orgy, whatever you want. And we instantiate a client, and it will, we can here pass an array of configuration. With no configuration it will connect to localhost 74.74. This is where Neo4j runs defaultly. So on the client, sorry, on the client, we can call the function makeNode and it will return node object. It can create properties easily like this and call the method save. So the properties are saved into node and the node is submitted to Neo4j. After we've done that, we can run the method save. After we've done that, we can, for example, get the ID out of top check, which is assigned by Neo4j. Yeah. Okay, maybe this is a bit too low level. So who of you knows the Doctrine library? So we can use the Neo4j database like we can use MySQL and Doctrine. It's, this library is called Hire Voice Neo4j PHP OGM, OGM for Object Graph Mapper. And yeah, this is a Doctrine 2 style entity for Neo4j Graph databases. So we can implement Doctrine common and you can use annotations to map the entities as you probably know it from Doctrine. So let's have a look on this. First, we want to map an entity using those annotations. For example, we create an entity object called user and we have to give it an ID and tag it with the annotation OGM auto. This means that there will be an auto-matic ID assigned by Neo4j. And we have a second property called full name, which we annotate as a property and we say it should be go to the index. So let's have a look at those annotations. First, we have the entity annotation. Using this, I have to use this on every class I want to define as an entity object. So optionally, I can specify a repository class as I can in Doctrine 2. And I can assign labels for Neo4j as we did before in the back-end. So I already said something about the auto annotation. So let's have a look at the property annotation. Maybe I have some properties in my object which I don't want to have in my graph, which I only use local, for example, a plain password. So every property, every class member I annotate with OGM property will be sent to the graph. Optionally, I can give it a format. If I give it no format, it will be a string. Then we have the index annotation. This is kind of special because it only works with the property annotation. I have to go back to Neo4j itself. Neo4j has a Lucene search index natively. So it supports fast searching. And if I want to have this property indexed in the search index, so if I want to match this name or search by it, I have to tag it as an index. Then last but not least, I have those many to one and many to many relations, which only means that in this column main actor is another entity object, which is being linked. Here I can specify a relation name here, act in or works forward to get the example from before. The many to many relation works exactly like this, excepting that the variable is an array instead of a single object. Questions to the annotations. Let's make an example. How to add properties to the relations? The question was how to add the relation properties. The answer is quite simple. The library doesn't support the relation properties yet. We are working on that to get it running, but the problem in fact is that it drifts away from the doctrine common specification. We have to know if we are wanting to go with doctrine or if we are wanting to go to Neo4j. There are people working on that. Let's store an entity in the graph database. First of all, we have to instantiate an entity manager like we have to do in doctrine. It is quite simple. We can say that $EM is a new class entity manager and provides all the settings we have to give, but in fact we are wanting to do this over a DIC container or something. So I switched the instantiation of the entity manager. We can say that we are interested in the second line. We have to get the repository object for our entity, in this case, an empty user. Now we can find, for example, a user called Pichando. We have those magic functions as a Dismdoctrine, so you can use every function, find one by and the property name and it will work. There was a question, I think. Okay, so we fetched the first node. Now we create the user chain here. So we instantiate the new user, set the full name and call the function addFollow, while follow is a many to one relation. Here we pass the object, chun. So if we persist this chainPerson object and call entityManagerFlush, both of those two nodes, entities nodes, will be sent to Neo4j and relation between those two will add it with the type follows. Next we want to fetch an entity from the graph. For doing this we can also do, like before, we get an entityManager and the repository for the user. We call findOneByFullName or we can call findByCountry, we have a field country in the entity. You may have seen that we can call findBy or findOneBy, so if we call findOneBy there will only be one object. If we call findBy it will be an area of objects, of all objects matching. As you see here we can call findBy directly providing an array with criteria, for example with status and email and we will also have returned a collection of objects. Questions? Like Doctrine and every other modern persistence API does it, we can use events. For an example we can write a simple class called pre-persistListener and implement a function named pre-persist. We have a pre-persist event and we can do our stuff here, for example call another API or doing something on the entity itself. That's all we need for our eventListener. What we need to do is we have to create the event manager and the pre-persistListener we created before and we have to inject it into the event manager and after we have to set the event manager into the entity manager. This looks quite complex but it's needed and in a modern framework we will do this using dependency injection because it doesn't make sense to do this manually. This is the list of available events all those events accepting, statement execute, a pre-statement execute and post statement execute are from our adept from DocTrain common. The whole event management is adept from DocTrain so you can go to the DocTrain documentation if you want to know anything about it. Let's go to the fun part building Cypher queries because this is what the graph database makes a graph database. We can take the setup we had before and directly on the entity manager we can call a function createCypher query. After we start with node for example the person node, John and we give an identifier to this node. After we can build a match query and this can be complex if it has to be complex and we can say OK, John follows any node and we tag similar interests on every other node which follows the followed by node and we can go further and take those similar interests from here and fire another match to all fellows and call a potential match. At the end we have a potential match and this is the result of a quite complex Cypher query and return it. We also have a limit and finally we call a getList which will be a returninary of objects. So... That's what we can do with the graph what is quite complex with a relational database because this is... Regarding production this is a quite simple query it can be much more complex but it remains readable. So... We are almost at the end some final thoughts of me personally there are some drawbacks as we already got from the questions on the OGM library I will not recommend it for very large data sets because this whole entity mapping is kind of overhead so if you have a billion nodes huge data sets you probably want to use... you probably don't want to use the entity mapping it also doesn't support streaming so if you fire calls to the REST API returning too much data you will get a memory exhaustion in PHP it's also not a feature complete yet not... as you heard before it does not support relationship properties neither it does support graph traversals because to do this we have to go to the Java API and probably the PHP and Neo4j people are a few so... regarding Neo4j and PHP it will be nice to do things with these two software stacks because Neo4j is the most common graph database and PHP is probably the most common scripting language for the web both is widely used both have a big community and also in PHP there are other great persistent libraries from which we can learn so using Neo4j and PHP together will be great but we... we have to join forces spread the word contribute if you want go to GitHub Neo Oxygen this is the organization which maintains the most PHP Neo4j stuff and bundles go to Neo4j, develop PHP check it out and play with it, contribute are there some questions left? please sorry? do you need to do a 3D... do you need to do a 3D... so the question was about the commercial Neo4j license that's a good question I personally work with the free license of Neo4j in the commercial license you have a cluster setup which allows you to have many Neo4j instances if you need it big, if you need it in production you probably want this you also have paid support what you don't have with the open source license yet that are exactly the facts maybe there are more differences but I have to consult the Neo4j documentation I don't know all the differences between those licenses other questions are there any libraries which are only focused on RETA and are there any other data to do with graphics? the question was if there are libraries to render the Neo4j data into graphs the answer is quite tricky Neo4j itself has a quite powerful rendering of the graphic rendering of the nodes and relationships as you saw in the web API screenshots there are also some JavaScript libraries doing this but I cannot name it but there are some... other questions no thank you visit me on the web drop me a line on Twitter the slides will be online soon on Speakaback thank you all
Playing with Neo4j ­-[:USING]­⇒ PHP Relations, relations everywhere. They can be difficult and maybe slow to represent in SQL. So why not to use a graph? Neo4j is a highly scalable and robust graph database, which fits your complex relation needs. In this talk, I will give an introduction into the graph concept, Neo4j, the Cypher Query Language and an integration in PHP. There are already some good PHP libraries for graph processing. I'll also show some examples and benchmarks using my favourite lib that is based on the Doctrine Common API. ······························ Speaker: Frank Neff Event: FrOSCon 2014 by the Free and Open Source Software Conference (FrOSCon) e.V.
10.5446/19639 (DOI)
to start in this B-Miles. Right. Thanks, Koehe. So the back story about this talk is I have a session, oh, maybe for an introduction, I'm Johannes Schlüter. Until last week, I was release manager for PHP 5.3, which now released its end of life, and it's dead, and it's gone, and I hope nobody of you is using PHP 5.3 or older anymore. And I hope you're all excited about PHP 5.6. Yeah, that's what I wanted to hear. And I do different talks. For some time, I did all the PHP 5.3 talks, and then the topic became boring, and new versions came out. And I had a talk about PHP under the hood, explaining some things about how PHP works, how reference counting works in PHP. And then there was some work done by a company called Zend to improve PHP's performance by massively changing the internals of PHP. So if I give this talk nowadays, it doesn't really apply for the future, and we know it won't apply what I'm going to talk about in that talk. Then for this year's Crosscon conference, they were looking for more technical talks, more experimental talks, not the default, oh, it's just web scripting talks, but in-depth talk. And Corin, I chatted shortly about it, whether something like that might work out, talking about PHP under the hood or PHP and G at this conference. But back in the times, I didn't really feel comfortable talking about PHP and G, since it was quite new, just announced by Zend that they are going to do it. It wasn't clear whether it will be merged into PHP and so on. And so that slowed down again. I kept it in the back of my head, but it didn't really prepare any talk about it yet. And then yesterday, I was noticed that the speaker was ill, and I said, well, yeah, let's try it. And therefore, I don't have any slides or anything. So in this PHP under the hood talk, what I'm talking about is what I'm trying to teach people is that references are bad. I assume everybody of you is knowing what PHP references are. So you have your variable and its $B. I hope you can roughly understand those dollar signs. My handwriting is bad and even worse on the whiteboard. And if you do this, this ampersand syntax, you get a full A here. So $A and $B directly refer to the same thing in memory. The thing in memory we are having is called a Zval, which is a send value derived from previous PHP three times. There it was called PHP value, but then proper or better engine sent. Engine came along, and the name was changed to Zval, to represent that. And a Zval is a quite complex structure. I won't write it in complete here. But it's a C structure. Let's take a shortcut. It's an angle bracket. And we have multiple fields in there. One is an integer about a ref count and an integer for is ref telling us how many of those variables are pointing to a specific variable. So after this line is executed, we have one of these data structures in memory. And we are having the ref count of two since $A and $B are showing on it. And as we have true alias, as we said, this is ref flag to the value of one, just tell us, OK, it's a value. We have more data in here. The important part is a union value. It should work on my handwriting next time, which has some different fields like integer for a long value, and another struct. Struct. I should go there. For string values, it's a char pointer and an int for the length, and some other things for other types around. It's not complete. It shouldn't be there. And so all different types we're having in PHP are represented in this data structure. And a union in C is a data type. We are basically the maximum value for the maximum type is allocated in memory. And depending on how you access it, it's interpreted in the according way. So the largest data type we're having in here is a char pointer and an integer for a string and a length. And so the size of the union will be the size of the char pointer, which is depending on your system, 32 bits, 64 bits, and the size of an integer. It's an integer. So yes, which might be 32 bits or something like that. And then we have these additional fields. And they are kept here in memory. And then we have an additional field called type. I'm not sure whether it's a correct name, but that's basically the set-world structure. So that we keep for every of our, you're taking a photo of my bad handwriting. You're all my fault. And there we keep all the data in memory. Now we're having an issue when doing it this way. That's the way how we reference to it. Since it's nice that we're having one container for those variables, but we need to point somewhere from these variables to this reference. And for that we have a data structure, which is a hash table. From memory perspective, we can simply follow our hash table and assume it's in C array. It's not exactly true, but it's the closest we can get to it. And if we look at a computer from Neumann architecture, what we are typically using these days, not exactly the form it is, or anybody here has seen a lecture about computer science 101 or Grundlagen informatik in German, a few studied people. Then that shouldn't be new to anybody. In a von Neumann architecture, you have your memory with slots of the same size. And they are all addressable with sequential numbers. So there's address 1, address 2, address 3, and so on. And we have somewhere on end with some other numbers. Yeah, it happens. Hems don't like me, and I don't like pens. So we have this memory layout where we can address the different areas. Now we're having an array for our values. So we place it in here, something like that. We have three pointers here. That's not exactly what it is, but we can assume it, pointing us to our structure, which are in some other memory address. So that's maybe here. And then we have a pointer pointing there. And we have a second pointer pointing there, too. So when accessing a variable, the PHP engine has to go first, or the system has to fetch that memory first. And then dereference the pointer and go here to fetch the actual data. So there's an in direction step. Now we have these things called CPUs. We're going deeper. If memory wasn't enough for you, we have our CPU, as you can clearly see. And the CPU, one key component is the Arithmetic Compulsion Unit, ACU, is that correct? ALU, Logic Unit. Or whatever. But that unit doing actually the math in the computer. Then you have your registers here, which are very small. Places of data basically can take the word size, so 32 bits or 64 bits or something like data, in one of those registers directly in the CPU. Then you have your L1 cache, your L2 cache, your L3 cache, the bit depending on your CPU. If you're looking at memory now, we know RAM sizes are in the gigabytes. I think I don't know what a typical server for you has, some quite few gigabytes. But if we're looking at here in the CPU level, we're talking about something like five megabytes or three megabytes or something like that, depending on your system's architecture, the specific CPU. And it becomes smaller and smaller and smaller. And here we are really at word size level. Now we have the second issue here, that it takes time to get from here to here, or data from there to there. Our limiting factor there is the absolute limiting factor. It's not the only one. It's called speed of light. Speed of light is, who knows it, how many kilometers per second? 300,000. 300,000, 299 or something like that. So then we have three gigahertz as a CPU frequency, which means in the time of one CPU cycle, the information can travel at most. Who can do the multiplication? It's 9 centimeters. Oh, depending on the 300,000 times the gigahertz, 8.9 is what I calculated yesterday. So the maximum distance our information can travel within one CPU cycle is, what did I say, 9 centimeters or something like that? And it has to go back and forth. And if you're looking at our main board, we see, we are a bit over that. So we are wasting CPU cycles while waiting for the memory. In real life numbers, just to give you an impression about what's happening here. Rough estimates, I found those numbers on the internet, so they must be true by definition. Accessing RAM, we can estimate about 100 nanoseconds. Accessing, I only have L2 cache, but it doesn't matter too much, it's 7 nanoseconds. And L1, 0.5 nanoseconds, and accessing registers more or less immediately. So by having to go to memory to access the data, we go from 7 nanoseconds. For data we have already cached here to 100 nanoseconds, which is a lot more. Of course, it's nothing if you look at it. But if you then think about, again, you have 3 gigahertz as frequency, and you're waiting for 100 nanoseconds for your data to process, it's quite some time you have to wait. And the CPU basically has nothing to do with it. So to improve this, the system, the CPU on one side and the compiler and everybody is trying to help by not reading the single data packet here, but trying to read more of it at once, and trying to put it in the caches. So we are not reading only this, but maybe if you're only accessing the LA, the CPU predicts that we're going to read this, and put at least an add of 3 cache, if there's enough space. That gives a huge improvement in the performance here. But we still, but the CPU can't predict that we're going to make this jump, and going to access that memory in most circumstances, depending on your CPU, depending on your compiler, that might look different. But in general, it's hard for the CPU to do. Now, we have to state a structure with this indirection here. And we want those references. And we have this issue. What can we do? We can change this behavior, and we can change these hash tables. When I thought about it, I thought about doing it next to each other, but I have to switch. So what the Sand guys came up with was redefining the hash table, inside the hash table. You're not actually storing the pointer, pointing there, but the actual value. So when we're drawing our memory again, we have to switch colors just to make that a bit more practical. We have our, that's now one entry for our hash table. So that's, all of that is $A. And inside there, directly, I don't have a value, but let's assume I have a value of 23 for that. We have some meta information, and we have the actual value of 23 right in that data structure. And if we are now having an array of data, the next element is directly next to it. Yeah, let's say $B, which already shows a small issue we're having. And that has some data. I'm not going into details right now. So what we're having here is, in the old version. Sorry, but there's two, it has some not really even now. Wait, wait. Coming exactly there. So in this old case here, we add inside this hash table with some meta data and so on, a reference to the actual data. And we could simply reuse this. In my old talk, I mentioned before, the main message was don't use references. Since doing this prevents an optimization inside the PHP engine, which tries to do copy and write. When we are not having a reference here but copies, and we don't change it, the picture here will be exactly the same. Only difference is that we are not marking it as references in the data structure here. But this stays the same. And if you have one reference and one copy, you can't reuse the container, but you need a second container to either hold the reference value or the copied value. And that's why references are bad, but that's another topic at talk. You can look at that with slides and everything on YouTube if you search for your hannish-luter PHP under the hood. There's a version from PHP UK conference about that. Now, as you directly saw, when we're needing a reference, and we are directly storing the value inside the actual data structure here, this doesn't work out that way. That's why there's more complication to it. What they already also did is I should have put it next to each other. I should have thought about it more. Changing the set world structure to a structure where you have type and you have a union and I think one more field, which I don't remember right now, but it doesn't really matter. And now the type here. Oh, let's take the other way around. The type flag in here directly represents the type you're seeing in PHP. If you're looking at the variable, it has a type of an integer or long, which is the same in PHP speak. It has the type of a string. It has the type of an array. It has the type of something like that. That's a numeric value. You have this is constant, I think, exported to PHP userland and the same ones are used here. In the new one, we have more types here. We have specific types saying it's long. We have specific types like here saying it's a string. And we have a specific type here saying it's a reference type. And if you say it's a reference type, then basically this happens again. But with more memory usage since the data structure is a bit, or that data structure is a bit bigger. And then we have this interaction again. But if we don't need an interaction for references, we can directly inline the data inside the hash table. Now, the next optimization this brings, or is that so for clear? The next optimization this brings by having those values next to each other in memory is, again, if you're looking at our different cache layers here, often operation we're doing is some form of iteration over in the data when searching for something, when looking in an array, when doing a for each on an array or something like that. By directly having the data next to each other, the CPU can take more of the memory at once closer to its core, to its calculation units. And without going back and forth all the time between different memory areas, then jumping somewhere else, and keeping in mind those are really small, it's quite nice to have this data really compact close to each other, everything. Now, there's another effect we're having here, which brings us back to our nice Mr. von Neumann architecture. Oh, just for more or less informational purpose. If you're reading data from an SSD drive, I just put some more numbers out just for giving a feeling what happens. We are at 150,000 nanoseconds, roughly for trusty SSD access. And then I have something about hard disk. So one megabyte reading from a spilling hard disk drive, one MB is 10 million nanoseconds. That's what I have brought here about numbers. So it's a huge gap if you're going to that kind of memory, just to give an impression of these numbers. So now, another thing is, if we're handling these variables in this old way, we have quite some common cases where we need temporal values. If you have in calculation, this is one working, 1 plus 2 plus 3, and equals $C. And as long as we don't optimize it, we need a temporal variable here. And then copy that, and then reference it again for that variable. And for all of that, we have to go to memory and find some space where we can put it. And basically, we have two choices when accessing memory from system perspective. One is putting it in heap memory, which basically means give me some memory area here, and reserve it for me so I can put data in and take data out. That takes quite some time on a system, speaking about in those many quads of time. The other approach is, again, looking at our von Neumann architecture. And our nice things we're having here is our stack. So we have one register, which is a stack pointer. And the stack, which is in Germany, nicely also called sometimes Kellerspeicher. So seller memory is at the bottom of our memory. So we have address one. And we have the maximum memory here. And when our program starts, the stack pointer points here. So this register has the address of that one. And each time, a function is called on a system level, so a C function from the PHP implementation. Somewhere annotated to that function is the information how much stack memory it's using. And it's simply changing this value accordingly, increasing by the needed space. And then the pointer shows here. And the function can use the space it needs. And that's a really fast way to access memory. Since all for allocation on a function call, you change that value. And when you leave the function, you change it at the other route. Unless you're using C++ with destructors or something like that, it's really, really a fast operation. I had some thought on my mind, but I forgot it. Anyways, I'm improvising, as you might have noticed. The data stored in here. And now, we don't have this overhead of putting it. My thought was, yeah, no typical issue about the PHP program, function foo calls function foo. And we all know what happens on PHP. We get a segmentation foo due to a stack overflow. What happens is we're calling function after function after function. So this one grows, grows, grows, moves up, moves up. And in some area, the operating system has a limit and says max stack space for this process is here, or for this thread, actually, not process. And if we reach that limit, the operating system, or actually the CPU, which knows this limit, will signal the operating system, which will signal the application. Sorry, no more stack space and goodbye process. And you get a segmentation fault. And detecting this in an incompatible way is something we don't do from PHP level. So you get a segmentation fault. So that's the reason for this one. Now, if we're having our temporary wayables and we are putting, taking this indirection out, we can directly put the temporary wayable here in our stack, put it there, keep it there. And if we need it, we copy it. If we need it somewhere else. So when the function exits, and we still need to value, we have to copy it out. Otherwise, we can forget about it. And it's gone from, well, it's still in memory. But in an area not accessible by anybody. And that's the second optimization we're having in PHP for the general purpose case. And these changes in data structures lead to numbers I don't know that anybody knows how much the factor is from you, well-informed people, something like one third of the performance improvement over PHP 5 for this PHP upcoming version, which nowadays has a version number 7. And mostly, you're really changing those data structures. While there's another change in the data structure, for instance, if you take Boolean values, currently in this implementation, we have a flag saying it's a Boolean variable, and then additional field for the value. They are now combined in one. So basically, true and the false are treated like they were types, not like values. So we need one lookup to access it's a true variable or it's a false variable, and not two lookups. And some more of those small improvements on there. Now, what can we ask you with this information? What's the time, by the way? So how much time? OK. Almost half time only. Oh, damn. It's the last talk, though. And party time is coming up. But what did I just say? All right. OK, so the initial issue which led to really changing these data structures was that Dimitri, who's the guy from Zendt, who's really in depth about doing all those optimization and thinking about those, wanted to do some just-in-time compilation of PHP code into native code to have even more performance impact. And when doing this, he figured out that this indirection kills every optimization since we can't really predict what will happen. With this model, there's a chance that we're not only seeing this improved data structures, which result in overall less memory usage and higher performance since access times become really slow. But that we can let the step towards just-in-time compilation, since with the values directly telling us the type, we can be sure about this and therefore give it to JIT engine to say, it's that type. Go with it. Optimize it. Make native code out of it. And? So almost work, I guess, like the optimization needs to be done, and then they have like experimental G to the engine of the app. Yeah. And then what do you do about it? Like, I think it will beat me, but the decision to simplify it's time. Well, the question is, this becomes way more complex if you look at it. If you really look at the code, it's more complex than what we had in the past. So it's not a simplification, but it makes it more complex. But for the user perspective, it's faster. It's more efficient. And you, if you're using PHP, you don't see anything of that. You see that. And but it's this first step towards JIT compilation. And there was a recent post by Dimitri starting a heated debate about one of everybody's favorite topic, static type hinting for scalar types. Since you really figured out, if we know in the declaration of our function we're having this type, we can do so much better JIT implementations. And after reading that statement, I thought, damn, he's quite close to having a JIT. I don't know any details about what he's really under. How close he is. But from that posting it sounded like there might be a chance that next week or something is coming up with a new idea for a JIT implementation, bringing again some huge performance improvements. The other thing in meantime Dimitri did, I never met him, but I really like what he does. Since he's really no big time about discussing, but delivering and improving things for quite some time in PHP. Even with that model, we have to allocate quite some memory on the heap or free memory or whatever you want to call that area, not the stack area, of the memory. And operating systems typically are optimized. But you start them at some time, allocate quite huge blocks of memory, keep them for, in computer speak, long time, and then free them again and do something else. What you're doing in the PHP script is you need these relatively small data blocks all the time. You need a new variable. You free it. You need a next variable. And new temporary table gives quite a lot of memory allocation operations. Memory allocating, finding good spot that you're not wasting too much memory and keeping it close to each other and keeping the total thing when multiple processes are running at the same time takes huge amount of time. And so we have an optimized memory manager already in PHP, which knows, OK, I'm having quite a lot of data with this size. And preallocates slots for that and reuses them and manages those. And what Dimitri, I haven't looked deeper into that implementation yet. And I think last week, or maybe the week before, it was a new memory manager. So he's not only working on changing the data structures, introducing a JIT engine, but also while writing a new memory manager. And again, improving performance of PHP quite a lot. So now there was quite some fuss in the PHP community related to this work. Now we're getting into politics. Or kindergarten. No, I won't read internal postings. So there's an operating system in a word which is called what's the name? Not doors, not gates, windows. That's it. And some people use that system. And there's a company in Redmond which really pushes that operating system and tries to sell it. I don't know why they are doing it, but they are doing it. Oh, this is recorded, isn't it? Damn. That's serious. I'm just. And what they are working on is they try to unify the experience, making it more portable that PHP scripts on different systems and different platforms behave the same way. And now we're having one thing in PHP, which actually is an error here. Now that I see it. This one is the long one. It's actually of type long. And the property of this type long is from the C standard, it's not clear what size long should be, which leads to different interpretations. In the Unix world, long is interpreted as if you're running on a 32-bit system, being of a size 32. If you're running on a 64-bit system, it's size 64-bit. On the Windows operating system, it's defined to be already 32-bit, just to make porting code easier on Windows from 32 to 64-bit. But I think that's also a change in the value when they would probably compile. I don't know about Windows, and I don't really. The point is there's this difference on the one side between Unix machines themselves, if you're running 32-bit and 64-bit, and with Windows machines, which then behave differently again. And what many people want from a scripting language is it behaves the same on all platforms. And those guys from Microsoft also figured out that we are using the int type here to represent the lengths of the string. If you look closer to C standard and recommend the programming guides, you see that int isn't the size one should take, but one should take the type called size t. And so they spent quite some time in an open process by early on telling everybody we're doing this and we want to do this to change those types. To make sure that on all platforms independently, whether it's Unix, 32-bit, and Unix, when saying Unix, I include Linux, which is a new Unix, other religious discussion, I'm working for a true Unix vendor, by the way. To always be 64-bit on all machines and all systems everywhere. And to have this type on a proper type, so size t. Long size t, S size t, just to be 64-bit all the time. So independently of your system, it behaves the same with high integers and so on. And long strings. I don't know if anybody needs strings longer than two gigabytes in memory, but if you do with PHP, it should behave the same on all platforms. That's the ideal. And it's a huge change in PHP to change that. And they announced that they were doing this. They were doing this publicly in PHP's Git repository in a specific additional branch, which was directly next to the main PHP branch. And suddenly, the send people came and said, well, we changed all the data structures. We worked hard on reducing memory usage. And we want to push that. And we didn't communicate with you beforehand, since it was an experiment, and we didn't know whether it would work out and or not. We don't want to send out all the ideas. We're having all the time, since that's too much, since they're really actually working continuously for years on different ideas, how to optimize PHP. And 90% of that are thrown away since it doesn't work out. That idea about changing the data type and so on, that seemed to have worked out. We don't have major bugs yet. Maybe you find them if you test what's now called PHP 7 from PHP repositories that has it with the applications. You might find bugs, but we don't know major bugs yet. Might want to push it. Now, this change here increases data usage. You need more memory if you're always having 64 bits here. You're using more memory if you're not using a small integer type here by a large integer type, which is kind of opposite. Now, you have the one company pushing it really hard to get their change in, since it's a huge improvement for PHP. And they are saying, that's what people are interested in. People want performance. And you have the other guy who's working for big Microsoft with other guys helping him, doing open source, open development from Microsoft, and doing this change. And they are more or less beaten down. I'm defending Pierre, by the way. New feeling, but heavens. And the same guy is saying, increasing memory usage and performance is the most important part. And they are saying, well, we need a consistent behavior, and we need better APIs internally, better types internally, and not ugly types, which that partly has internally. It's a more complex structure, needing more different operations and different types. And so there was a huge debate. In the end, they worked together silently and recently put this work on top of that work. And even in a way that in some cases, you even get more performance out of it. So out of the, oh, yes, so slow, they figured out if you're working, cooperating, we get something which is even better. We fulfill more or less both needs from both sides and putting stuff on top of it. And let me think, is there anything else on that level in the future of PHP? I don't think so. So if everything goes well, everything I talked about will be released as PHP 7. Now the debate is whether we will have a 5.7 release in between or not. From my personal opinion, I think we should focus on getting that one out. And if we figure out, oh, we can't do it. And we can do an immediate release. But if we say, oh, we can't do this. And we can't do it in a year, then we do some other stuff and implement other features which are piling up. People want to have big int support. So you can have integers higher than 64 bit, or that kind of stuff, and pushing for those changes. And then you get a 5.7. And then nobody has worked on that since the 5.7 got the priority. And then you figure out, oh, it will take so much more time until we have PHP 7 ready. So let's make a 5.8 and a 5.9 and a 5.10. And then we do the same what we did with PHP 6. And we kill PHP 7. And then we get to PHP 8. And so my opinion is we should try to push PHP 7. So we should demand, or you should demand, from the PHP developers, give us PHP 7 next year. And you should do your part in testing the Git repository snapshots of PHP 7. And try to bear breaks with your code base early. Since the earlier you report issues, you're seeing the earlier that can be fixed and the earlier it can be released. And that's mostly I can think of right now. And then the subject, if you have any questions related to that or any other questions, feel free to ask them. And maybe I'll answer them. And otherwise, if you don't have questions, there's beer and barbecue and stuff outside, I think. Or maybe inside. But sure, and not sure if it's from now. Oh, damn. So yeah, I need questions. So please ask questions. Yes? Does it break or extension? It's huge. I just had to make a joke first. So the question was about how much it affects extension developers, since there are people doing quite impressive work on top of the PHP API to make it usable with a proper programming language called C++, which really makes some things easier. And it's an issue since we have a migration guy telling you some of the things. But every place you're working was hash tables you have to change, basically. And some of the type usage you have to change. That's it for typical extension. You might, to some degree, automate it, basically when you have a set while star, star, take a star away. Keep the same macros. If you're using the isboolean macro, I think you have to change it. If you're using arrays, you have to slightly change those since there's a different type. Oh, and strings have been changed. They are now of type send string and not child pointer anymore. And then new string API. And then the string, and the string, and the string. But on the wiki PHP net, somewhere there's a migration guide. Just go to RFCs, then go to PHPNG. And on the bottom third of the RFC is linked to the migration guide for extension authors, which then also links by the way to the internals of PHPNG. So it's not on the RFC, but you have to go to the migration guide to get to the internals. And there you can find the information. But it's notable work to adopt to it. Other questions? Or if that's not enough, then? Well, the current set of extensions that I said, although there must be hundreds of extensions, they will all break. Yes. All extensions will break, and all extensions have to be adopted. And how much of the extensions are managed by PHP team? I don't know how much. So the question is how many extensions are managed by the PHP team, and as every extension basically has to be touched to be adopted to this new world. The number of extensions, I don't know, since there are many, many internal, only company specific extensions. Then there are tons of un-maintained and unused open-source extensions in PICL, in the PHP extension repository, PICL.PHP.NET. And then there's a number of used ones. And out of those used ones, there might be some which are worse maintained and some which are better maintained. So if you're looking at in common extension something like xDbug, which isn't part of the PHP distribution, but is very well maintained, that will be adopted quickly. If you're looking at some extension like the Memcache extension in the PICL repository of Memcache D, they are a bit less maintained. But I guess they are important enough that somebody will work on it. And if you're done going to even less used ones, it might take some time or your time. So the interesting point is if you have more or less simple PHP extensions, more or less wrapping only a C library, and not doing any object-oriented stuff, it's very little work to no work to get them from PHP 40 to PHP 5.6. The incompatibilities are quite small there. Less than an hour of work, pure work without all integration testing and what you could do. So there aren't many changes. And the changes there are kept in quite small areas. Now, this is a huge change. And this will really kill some really old extensions nobody should use. Anyway, since they are maintained, obviously, as they will hopefully be adopted. Since I think the performance improvements, the memory improvements, the springs are so much that the community will cry more than they will cry about some new syntactic sugar. I don't know what the latest syntactic sugar is, which is being introduced. I don't follow the syntactic sugar. I've come from an hosting company. We see sales very, very rarely. Like very exotic extensions. What we see is like between the community with the framework with the application, and they build all the certs. Mostly they are into core components. So some with that support SIP and HTTP and HTTP. Yeah, so HTTP extensions, a good example, that might probably become part of the core distribution. And the other extensions you mentioned are part of the core distribution. So either they are thrown out. I can imagine that some crappy stuff we're having in there, which nobody is using actually, might be thrown out in the process. I don't know. Some of the un-maintened PDO extensions. I won't comment on that since MySQL is the only database you should use anyways. I'm paid for saying that. So I won't comment on throwing out other databases. But yeah, in fact, that was an area I was thinking about. Some IBM DV2 PDO driver, which was broken anyways, and where nobody from the PHP developers can commit, since IBM lawyers don't like that. Such things might be thrown out. So most of that work is done by Zend, which is mostly dimetry, and they hired two guys more or less for that. I don't know if they hired them full time or just. No, not full time. Lawrence and PTC, are they working with that? Yeah, I don't know the contractual details. But so they sponsored at least work from two other guys. One is called himself LaRuins, which is a type of company from LaRuins, and he's a Chinese guy. He recently got into the PHP core community, and is also a great guy from technical perspective. He is a bit shy about communicating, since he feels his English isn't good enough. But that's the same for most of the contributors, which makes it a bit hard sometimes to discuss. But he's a great guy, and does lots of work. And Nikita is also quite into these things and send a sponsoring that. But I don't know how the relationship, who does what, and so on. And I don't care. I don't care who is paying whom for working on PHP for the most part of it, unless for stupid comments. So that was the question. I'm making sure that these two developers have a share of things together. So question is about our bus factor solution issue. So bus factor means having an important developer being run over by a bus. And what happens to the project? And well, you have Dimitri. I think he's still living somewhere in Russia. You have LaRuins in China, and Nikita somewhere in Europe. And I have a hard time imagining a situation where they travel from one location to the exact same location. They might probably go all due to maybe Send Consents, Send Past, and once their guy's there. And they might share a flight from Frankfurt or some other European hub. And I don't know if Send has any precautions of an accident happening there. I'm not so much into the disaster recovery stories from that. I know it from other companies, but barbecue has been opened. So if you're running out now, I get the impression that you don't like me. I prefer food and alcohol over me. Alternatively, I was so bad that you needed to become drunk. And anyway, thank you.
phpng - heap and stack allocation ······························ Speaker: Johannes Schlüter Event: FrOSCon 2014 by the Free and Open Source Software Conference (FrOSCon) e.V.
10.5446/19637 (DOI)
Hello, I would like to tell you some things about polyglot persistence and multimodal databases. So this talk will be about a short introduction into this NoSQL term. And then we'll point out what is this polyglot persistence and we'll move over to features of multimodal databases and how they really fit into this concept of polyglot persistence. So a bit about myself. My name is Michael Huckstein. I'm working on Rangody B. I'm part of the Rangody B core team, which is based in Cologne. And I'm responsible for the web front end, graph visualization, graph features. We have all that written in JavaScript and I'm a JavaScript developer. In my free time, I'm organizing Cologne.js. That is the JavaScript user group in Cologne. And we also have a track here at Frostcon, which is upstairs in the project rooms. And I think today there will be three more talks in that track. So if you're interested in JavaScript, you can come there. In my professional life, I hold a master's degree with a specialization in databases and information systems. And that is how I got in touch with Rangody B. But enough about myself. Let's start with my story. So sometime ago, there was this kind of dogma that you could either use a relational database or you did something wrong. So actually, you just created always a relational database, put everything into one ER format. And if you have an additional data, an additional class or object in your application, you just add another table, connect that somehow. And if you do that a long time, something like this in a quite large system really ends up and it's really hard to manage this and to get an overview of where is what. But the idea why you did that is that the normalized model is really space efficient, it's memory efficient, and it's quite fast on the database side. But the problem is you have to force your data format always into this relational normalized format and you have to do that yourself. So you have to do that in the application code and you cannot just store the native data object that you have in your application directly into the database. But with the rise of NoSQL, this actually changed. So to give you just an overview of the NoSQL database that are around, three major types, one, the first one is the document database. So a document database actually stores mostly JSON documents and you group them with logical similarity into collections. So to get the step from the relational world, a collection is basically quite equal to a table but you do not have to define the column names beforehand. So the NoSQL document store can live with different attribute names and different objects in the same collection. Then you can also add queries and indices on top of these documents. So it's not a problem if there is some attribute which is not filled, that's simply ignored by the indexer, but all the others can be really getting really fast by queries if you have an index on a certain attribute. Then we have graph databases. The idea of graph databases is that they are really focused on end-to-end relations between objects. So an object is again some kind of document but it typically cannot be that complex. So in a document store, it's also possible to store nested objects and objects in objects and so on as one entry in the database. And you can query on the internal attributes also. This is typically not possible in graph databases. The idea of graph databases is that you have simple documents, connect them to each other and query on paths lengths, on passes on arbitrary lengths. So on graph databases, it is easy to get from A to B with at most three steps in between, so one step, two steps, or three steps. If you want to do that in a SQL query, you would have to write three subcarries, one for one level join, two level joins, and three level joins to get the same result. So for these queries, graph databases are really, really good. And the last one, I would say the simplest one, key value store. The idea of a key value store is that you have one unique key that is unique in your complete database and to this key, you connect any arbitrary object. The database doesn't know anything about this object, so it can store binary files or JSON or strings or whatever, it doesn't care. And you can only get this object back using the key. But you don't get query operations on the object level. You can just query by key. You cannot say, I know that in my objects is always the attribute name, you cannot get that. You have to put the name if you want to query that into the key for efficient query. But because of this constraint, the database does not know anything of the content it is storing. It is really easy to implement scaling and partitioning. Because you just have this one key that is unique in your complete database, use hash function on that, and then put it on any server. You can just add millions of servers, and it's unique with your key which servers stores this data. For a document store, for example, it's quite hard to get charting. Because if you chart, you could still chart by any key for the document, that's not a problem. But if you want to query it, you want to query on attribute level. And maybe the attribute is not the one that you charted by. Then you have to collect the data from all the servers. That's why it's a bit harder to use charting on document stores. And on graph stores, it's even worse. You have to actually make sure that the vertices are on the same machine as the edge to get a fast query. And that in both directions. So it's quite hard to really chart the graph database. That's why most graph databases don't even support it. But now let's talk about polyglot modeling. The idea of polyglot modeling or polyglot persistence is to use the right tool for your job. So you take a look at your application, what data you want to store, and then you pick the database that can natively store your data from it. So if you have structured data like JSON object, then you should probably use the document store. Because you just fire your JSON object to the document store, it stores it, and no transformation has to be done. Neither on your side nor on the database side. And if you have relations between these objects or in simple objects, and you want to query them efficiently along the passes, then you should probably use the graph database. And if you say, OK, I don't care. I just want maximum performance. I don't want to query on attribute level, and I want to manage the structure myself, then you can use key value store for it. Because that is really fast on that point, and you can scale it endlessly. But if you have a mix of these, and I think most applications actually have that, then you could use a multi-model database. And what a multi-model database is, I will tell you in a few minutes. Let's go to a use case example, an e-commerce system. So I think an e-commerce system is, in theory, quite simple. You have somewhere a product catalog where you put all your products in. In the relational world, you would have to normalize it, because a t-shirt, a TV, these are two different entries, two different tables in a relational world. They have different attributes. In a document store, you can put that in the same collection, because it can handle that they are different formats in the same collection. Then you have your customers. You can also do that in a relational database, and they are quite similar. But also there are some problems. So if you are only in Germany, it's quite easy to make one customer table, and that's it. But if you support German addresses, and for example American addresses or whatever addresses, they are also quite differently. So they need different attributes. And you could store that in a relational format using different tables, or store some JSON inside it, but then you lose actually the benefit of a relational database, because you cannot query JSON or other stuff inside your table cells. Next thing you have is a sales history on the top left side, which just stores which user bought which items and at which price and all this stuff. Then you have the shopping cart. The shopping cart, you want to be really, really fast and accessible, because you need that on every page of your e-commerce system. But the storage of it is quite simple, I would say. And the last thing is the most important thing of a good e-commerce system is recommendations, because you want to recommend good products to your buyers, so they buy other products or also get more money for you. But recommendations are actually a graph problem, because you have users connected to products and other users buying the same product, and then you can suggest other products. And that's a graph query. So probably you would like to use a graph database for that. But anyway, you could do that in a relational database like this, but I think it's quite hard to manage, quite hard to handle, and quite hard to set up. And it's, well, quite hard to get an overview. If we are now moving to the no-SQL world, we have the same setup, the same e-commerce system, we still have the product catalog, which are simply documents in the same collection, and you actually don't care for all these different attributes, you just care for the same attributes that are shared between your products, like the price and stuff. And this is where you put the indices on. Then you have your customers, where the documents, again, could live with different addresses and different address types, and also Nessus documents. Then you have your sales history, which is quite much the same. Then you have a shopping cart, where you actually just need the session ID and then some entry. But if you want to query that, you will only query that by session ID. You will never search for shopping carts containing a computer. We just have one user ID and get his shopping cart, and that's it. And then for the recommendations, I already told you it's actually a graph problem, so you want to store the relations between product catalog and the customers in the graph database. And if we do that in nowadays most famous technologies, we would use the document store here, up there, and for the sales history, a QVagu store for the shopping cart, and a graph database for the recommendations. And with nowadays top leaders in these different categories, we could do this with MongoDB on the document store level, with Neo4j on the graph store level, and Redis, for example, is a shopping cart. So these are just examples of different NoSQL databases that support this format. So what are the benefits if you use this setup instead of one big relational setup? So the benefit is that you have a natural mapping of your data into your database. You store your graph in the graph database, you store your products in the document store, and your shopping cart in a QVagu store. And you don't have to write any code to transform that or to optimize that, because the database is really built for these kind of data. Then you also get the queries that are tailored for your data format. So you don't have to create like huge SQL statements to simulate the graph query. You get that out of the box. So most of the benefit is that you can really focus on writing your business logic. You don't have to write any transformation code from your locally used data structure into the relational structure, no normalization required anything. You can just simply use your data structure, store it, and that's it. Yes? That is actually one of the problems I'm coming to in a few minutes, because most document stores actually don't support it. Okay, so, but what is the overhead that we get with this setup? Because you don't get anything for free. So part of the overhead is that the data has to be stored redundantly and has to be kept at zinc. So for the recommendation example, we need the graph query capabilities of the graph database, but the actual content is stored in the document database. And we have to make sure that whatever is in the document store is referensible from the graph database, because we cannot connect those two together. Next thing is you have to set up three different databases just to get your e-commerce system running, and that's a lot. So the administration is really a huge effort for such a system, I would say, because that's a quite small system. It's a single thing of a large scale system with age, with age, or more database technologies involved. It's really hard to manage. And now I'm coming to your question, thinking requirements. So actually, you need relations between sales history, products, and customers. And many nos equal document stores, you can do some kind of foreign key constraint, I would say, but most of them don't offer joints. So you just have to do two queries and join that on your client's site. So that is, again, code that you have to write yourself, or hopefully there's a library for that. So just the library just hides the problem of the database. And the even worse syncing requirement is the recommendation. So I already told you, actually want references to the real object in your graph database. And if you want to query on certain attributes also, then you have to keep them redundantly in the graph database also. So if someone searches for TVs, and you would not want to offer a different TV if you just bought one, but you would, for example, offer him a different DVD player or something, and that should be part of your graph query. And you do not want to do one step in the graph database, go back to your document store, look, oh, is that a DVD player? And go back to the graph database to suggest this one. So it's quite a lot of effort that you have to put in your application to get that thing running. But the good news is there's an alternative to that. So-called multimodal databases. The idea for multimodal databases is that it can store different data formats natively. So it can store documents, it can store graphs, and it can store key values. And the idea of the graphs that it can store is that you simply use your documents from your document store and connect them in the graph. And the edges to the outside also appear as documents. So you can query the edges as documents, which gives you different opportunities. And you can query the documents as you're used to. But you can use the same documents in your graph query. And you don't have to write any application code to combine these ones. And to keep them redundantly, because it's in the same system, in the same database. And it offers you all the query mechanisms for all the data models. So you get query interface for graphs. You get query interface for documents. And you get query interface for key value pairs. Let's go back to the use case. So it's still the same setup. We still want to use document stores, graph store, and key value store. But we could just use a multimodal database for all of that. And this leads me to RangoDB. So my favorite features of RangoDB. The third thing is, it's a multimodal database. So we can store graphs, documents, and key values. Next thing is, there's a query language. It is called SQL. It is as powerful as SQL, I would say. And it is offering joints and traversals. That means that you can use this query, this language to query your graph database inside, and also get joints on the document level, which is not offered by many document stores, and also across multiple collections. And next thing is, RangoDB is completely asset, including multi-collection transactions. So you can actually store your documents in different collections, update them in one asset transaction. And for those of you who can count, I wrote four features, and just listed three. Last one is a feature that you don't expect from a database. Fox is our JavaScript framework. It is comparable to Node.js. It has some built-in libraries. It has a JavaScript runtime, which is Google's V8. And you can use it to put JavaScript code on your database level and to adapt the API of the database to what you actually need. If there is something missing, and you need that, you can just write your own API in JavaScript that is entered into the database and really acts on the raw data objects. So whenever you have something that you would put into your client, analyze it, and query again to the database from the result without user interaction or something, then you could put that into the database level, which is much faster. Because you don't have to transform it from A to B, you can just execute on the database and put the complete result outside. Yeah? Is this that question? I'm not sure. Okay. Yes, please. It is... the idea is actually that you make apps. So you can put apps into version control, and you can then install them from your version control system into a RangaDB. So it's not... It's quite comparable to stored procedure, but you can manage your versioning yourself. And you have it in your version control system. You can just install it. But I will have a slide on that later on. Okay. So how does that look like now? HUL, the query language. On top, we have a document query. So in this query, I will just get the users which are active, and then I iterate over the games, and they are performing a join, because I just get these games, the games where the player has the same idea as the user. And this is how I could do a join. And then I can return the user's name and, for example, the score. Second thing is I can also modify the documents. Again, I sort of iterate over all elements using this filter, but the filter is, of course, applied before you iterate over the documents because if it fits in the index, it will use the index, so it's fast. And in this query, I would, for example, do a migration. So I get wherever the status has the old format, not active, I will replace it with active false, which is the new status. And the last thing is a graph traversal, which is a function, where I just say I have a graph, which is called underground plan. And in underground plan, I have several document collections and edge collections. So the edge collections connect all these documents. And in this query, I want to start at the main station, just want to go in the outbound direction and check which is reachable within two or five stations, which is, for example, important if you are driving with the subway and you buy a ticket, which allows you to ride at most four stations, can check where you can go. Next thing is a transaction. So everything you do in HUL is transactional by default. But if you want to do a bit more, if you want to write your own code and do some logic that you cannot express in HUL, you can just write a JavaScript function, which is put in the action. You can get your logs on the collections that you need. So in this query, I would write on users and products and would only read on recommendations. So whenever I start this transaction, and this transaction, I get whatever is stored in that moment. Then I do everything that is stored in action as a JavaScript function. If that works through, everything will be stored and is acidly inside the database. And if there is, at some point, a throw for whatever reason, so the internal function fails, then it will automatically do a rollback. And I don't have to care for anything that is broken in my database. Yes, please. Do you set me in transactions as if I did batch operations for the table logs? Not really. We have multi-version concurrency control, so you just get the only thing that you really need in your query to get logged. But you don't see newer versions of these objects. Okay? And now let's talk about Fox, the JavaScript framework that we included. So the idea of Fox that you can encapsulate microservices inside your database, offer them via an API. What you can do, for example, is aggregate data and enforcing privacy or security constraints. So for example, you can cut out some data that you would not want to deliver to your user, or you can, for example, apply some decryption, encryption functionality, add some further information from other queries or whatever directly on the database level, and then just put out the complete result to the user. Then you could also use it to trigger logic on data modification. So whenever you want to store something, you just go over FoxRoute. It adds some further information to that, for example, encrypting the user password or whatever, and then stores it to the database. And the idea of these Fox apps is that you write them small, so you put them in your own version control, and you can require them from other Fox apps. So for example, if you have a user management tool, you write this one once and require it from different applications that you write. And you always get the features of this one user module. One of the things you can do with that is to improve your multi-device setup. So nowadays, you just have iPhones or whatever, tablets or PCs. And if you are, for example, in a mobile setup, then you typically do not want this whole load of data pushed to your client. If you're in an office setup, you maybe want that. So you can actually decide on this level already, do I have to crunch something down, write that one time in my application, and then just ship the short result. And I do not have to write the same thing on my iPhone, on my Android, and on my wherever device to just crunch this data down or trigger a different route. You can just use the same route and write it once and for all in your database. So you get the correct data format for your device. Then you can also secure your data in Fox, so you can just use further authentication algorithms or whatever authentication you need. So we have built in OOS 2 or HTTP basic OOS. Then one benefit you get is that you have low network traffic and direct data access. So you just push out the data piece that you actually need in your application. You do not push out any more and have to filter on application level. And that's why you can add your own customized and versioned REST API and JavaScript onto a WranglerDB, which is then the API that you would actually expect from your database or which you need from your database. Okay, so now let's go back to the benefits and overheads of the Polyglot persistence setup. So benefits, native mapping of data into your database, it's still given because you can store documents, you can store graphs, you can store key values natively. Database is still optimized for these formats and you get queries for all of them. But on the overhead side, we can have a closer look. So data has to be stored redundantly and has to be kept in Zinc. Actually we don't need that anymore because that will be done in the database level. So you don't have to enforce that it is in Zinc or something because you really use the same objects. You don't have to copy them yourselves. Several technologies involved, well, it's also not true. You use one multimodal database and that's it. And therefore, administration effort is huge. It's also not true anymore. So we could get, for this part of the view, into keeping the benefits but all these overheads I told you, it's not valid for multimodal database anymore. Yes, please. That depends on your setup. So we have replication algorithm if you want to replicate it for backup. Yes. So the idea is that a graph query can access documents and edges to the outside appear also as documents. So you actually have, in the out edge, have a pointer to the starting document and the target document. And you do not have additional documents stored in there. If you have a different graph database, you need to store these vertices in addition. But now we can use the documents that we already store and that's the benefit. So there's actually no redundancy you need for that. Okay? Yeah, then give me the chance to give you an overview of some more features that we offer with ArangoDB in particular. So the complete project is open source and free with Apache 2 license. You can just download it, check it out from GitHub, build it yourself and just try it. And we have one click install us for all the operating systems including Windows, Linux, Mac OS, and I think we also have a Raspberry Pi version if you like it. Then we have built in charting and replication. So replication for your backup strategy and charting if you have more data than it would fit on one server. Then we have drivers for wide range of languages including Java, Ruby, JavaScript, of course, Python, and PHP. Then we have a rep front end which is shipped with ArangoDB and you don't have to pay extra for that. Just get it for free. Then we have a documentation which is made with SkidBooks which I think is quite nice now and we offer you professional as well as community support for the database. And well, if you like it, you can be invited to join our growing community by using ArangoDB or contributing to it and if you have further questions, you can just contact me. And all these green fields is at least one contribution coming from all over the world into ArangoDB. So we are quite global now. Okay, thank you very much. If you have further questions, I will be around today in the JavaScript track which I'm organizing on the upper store, upper floor, and now I'm available here. So any questions? Yes, please. Could you say something about the performance characteristics of ArangoDB because you are ASID but you are shy and usually contrary goals? Yes. So the asset is you can enable it or disable it. You can do that on collection level and on query level. So if you want to say this one query has to be super false but I don't care if it's ASID or not, you can just disable it for that query and if you have financial data or something, just enable that and it's good. But then it takes, of course, a bit longer. But in typical use case, for ASID queries, you can actually wait because they are not time critical. And for time critical queries, you don't want to wait. So that is you can configure that on your needs. Yes, please. Yes. Yes. Yes. Yes, but you can... So if you're afraid of losing that, you could just use ArangoDB in all these states and set up a different database for each of them. Then you have the same setup as before, okay, which does not really help you but it's okay. You can do that. But the other thing is that we have this built-in charting and built-in replication. So if you use your setup, use one large database in some cloud environment or charted environment or something, then it appears like one large database. But you actually get this, again, the benefit that you have different servers storing your data and you could just throw away that one server and replace it by the other one. So... Yeah, I'm good. Yes. I'm not sure if I really got your point, but you can use the same... The idea of these microservices is that you could deploy them on all your machines. So if you throw away one of them, it will still be available on the other ones. And you just have to make a backup of your data and then still have the same microservice available on all your machines. And then it's actually transparent to which one of these machines you connect, but it would be faster if you connect to the right one because then you don't have the network traffic anymore. So our target is also all the servers in the same data center. So if you're in the same data center, you can use all the machines that are there. Basically the target we would suggest would be like four or eight machines, something in that region, but you could do more. So there's no hard limit in using like 200 machines. But if you're using different data centers across the world, then you always have this network latency that you have to take into account for queries that actually use more than one server in the setup. But you could do that, but you have to live with that or either chart your data such that everything that would be requested from Europe stays in Europe and all the things that are requested from the US are in the US. And then you could connect them in the global scale to have some more advanced features if you really have some queries that are across these countries, then you could do that. Yeah, for example, then he could still get the data from US in Europe or whatever. Yes, please. I think not yet, but that is definitely on our road list. I'm pretty sure we don't have that yet or Frank, we don't have it. Okay. Yes. Yeah, I am pretty sure you get. great data to make the microchips and something that you have done, so pretty much it's a different kind of data. Yeah, I'm pretty sure you get. Right now, there is nothing that we have published, but we are working on recipes, and we will publish them in the future, and that is one of the use cases that we will consider in these recipes. Then it's there. Yes, please. So my opinion is that I don't think it will get as fast as the NoSQL databases are, because they are built from scratch to support these features. For a relational database, you just build something on top that simulates the NoSQL database. I must admit, I never trust these benchmarks, because most of them are really. Yeah. Yes, yes, right. Yeah, but I think both parties really learn from each other and try to get to the one solution. That's it. So both of them are valid approaches. But I must say, if you really have no SQL data then you best use a NoSQL database and not something that simulates it. That's my opinion. Okay. Thank you very much. Thank you very much.
Multi-Model NoSQL Databases An introduction to Polyglot persistence and NoSQL In this talk i will introduce and discuss the term polyglot persistence in the NoSQL world. Afterwards i will present the multi-model approach of NoSQL database that try to overcome some drawbacks of polyglot persistence setups while keeping the benefits. The database i will use for this offers embedded Javascript for my examples. In many modern applications the database side is realized using polyglot persistence – store each data format (graphs, documents, etc.) in an appropriate separate database. This approach yields several benefits, databases are optimized for their specific duty, however there are also drawbacks: * keep all databases in sync * queries might require data from several databases * experts needed for all used systems A multi-model database is not restricted to one data format, but can cope with several of them. In this talk i will present how a multi-model database can be used in a polyglot persistence setup and how it will reduce the effort drastically. I will show with Javascript examples how to make use of such a multi-model database. ······························ Speaker: Michael Hackstein Event: FrOSCon 2014 by the Free and Open Source Software Conference (FrOSCon) e.V.
10.5446/19634 (DOI)
Hello, and welcome to Frostcon 2014, the ninth installment of this event. And my male client is complaining that he doesn't have internet. Ah, it's gone. Then first and foremost, very important, we have to get one thing out of the way. There have been numerous people who told us we should rename this talk from init to systemd. But we are old school. Okay, yeah. I'm Scotty. And this is Tobol. We are main organizers of this year's event of Frostcon. And we'd like to welcome you to this event. I hope you have a lot of fun and learn stuff in the next two days. We organized this event together with the Department of Computer Science of the University. And for the official part, I'd like to hand over the microphone to the dean of the department, Mr. Versaiden. Thank you. So, it is my pleasure to welcome you all to the Free and Open Software Conference 2014. Not only on behalf of the computer science department, but also representing the president of the university who informed me on short notice that he couldn't attend, which he originally intended. But he sends his greetings and his best wishes for the conference. The Frostcon started almost a decade ago as an initiative of some few students and one professor. But as the university and the department grew over the years, so did the Frostcon. And now it is with more than 1,000 participants, the third largest Linux conference in Germany. We take pride in being a part of that and having been a part of that from the beginning. And we like to host this conference and we see that the open software has always been an important part of solving real life problems. And as a university of applied sciences, we also are dedicated to solving real life problems. So I think the Frostcon is well situated here and we can work together on these issues of great importance. Open Software is growing in importance also in the field of business and economy. And many of the subjects and talks in this conference show that this also is part of the development here. And one of the major issues is security. Data security of course is always in public discussion and also at this conference it is an issue. And in fact, the choice for using Linux based operating systems and open software is not seldom, not rarely based on security issues, on security aspects. Well I don't want to spend too much time on introduction. Every one of you is probably eager to hear the talks. Just one more thing. Nearly two days ago we had another meeting here from an international project where the economic development is based on free and open software, the Oscon, which will also be presented during this conference in one of the lightning talks. And so from the timing it's almost perfect that we have these people still here and we can combine these two events. So now let me thank everybody and all the institutions who made this possible. And let me wish all of you and let's say all of us interesting encounters and fruitful discussions and enlightening talks at this Froscon 2014. Thank you. Next slide please. So we have a few console talks because speakers got ill and other changes. So we had an AngularJS talk and workshop which we have to cancel and as well as a knowing your garbage collector talk which sadly also cannot be held. So if you suddenly have like, I think we have still one or two slots open. We still have a workshop slot available at noon I believe and at 11.15 we still have a talk. So if someone has a presentation ready and is very eager to present to the crowd, talk to us. We are at the office right above the entrance. And now for some journal information. As usual the most important thing you need to know about an event is the hashtag. So if you want the usual hashtag is hashtag Frostcon and for this year it's Frostcon 9 as you can probably guess from, it should be a 9 by the way if you ask yourself what the logo this year means. Then as usual we have something to eat, something to drink and most importantly at this time of day for many of us is coffee. So I start with that. You find the coffee from Einbrand, local rostery, brewery. Coffee, coffee company. I don't drink coffee but I have heard very good things about them. They are at this end. Just follow the smell probably and I mean that in a good way. On the opposite side of there there's our, they can buy drinks, alcoholic and non-alcoholic whatever you prefer at this time of day. For food you go to the men's at the other end on the right where we have some breakfast and later on lunch. Of course we have a salty event tonight. Because the weather is not summer anymore we decided to go indoors this year but we will still put some meat on the barbecue and there's a beer fountain in the courtyard. So... Yep, it is. Yep, it is. I heard the presentation is beer fountain so if not correct me. I invite you all to come there after the talks finish and join us for a beer or non-alcoholic beverage of your choice and let's have some fun together. This year's keynote will be held by Chris Koehltop that probably many of you know and he's not here yet but he will talk about how big companies can handle open source projects. He has quite a lot of experience in that. I believe he started doing IT in the 90s. The dark ages of some would say. Early in the old days. True. When it's all over and everything is teared down again on Sunday we would like to invite you to our after show party where we all can relax and get drunk. It starts at 8.30, 9.30 in the Voyager, it's a new pub in Bonn. You will find information on Twitter and on the web page later on. And with that I'll hand it over again to Tovo for our... What are the features? Like coordination. We have a couple of bonus features this year. So I'm not quite sure what we have decided on how the bouncy castle and the ball pit are going to be situated. So we have them lying around here. I'm still not sure where they're going to be put up because of the weather issues. But they should be available at some point. We have a table soccer tournament because three sponsors or something brought kicker tables along so they organized an impromptu tournament about that. At 7 in the evening. Like just with the start of the social event you can start getting... I don't know, do we have prizes? I'm not sure. They probably have prizes. The whistleblower quiz will be on later today. I'm not sure what the exact time was. So look in the program, I think quarter past four, quarter past five. So it's like El Magizo is doing it. So if you're interested to participate, go to the info. They have some little slips where you can sign up and they will choose the ones who can join at the quiz. There will be prizes as well. You can't even buy in Germany, I was told. Yeah, especially very bonus features then. And we have a delegation of guests from Jordan and Lebanon here where I'm not quite sure what they are right now. They should be here in general? Any minute. Okay, so in general they should be arriving any minute? Middle eastern minute. Middle eastern minute. No, that's not him. So they should be around any moment and they have a quarter hour. So well, good time. And I guess that's about it for us. Very special. Oh yeah, we have lightning talks this year. They're in room B120, I believe. That's like downstairs there and up in the first floor, second floor in English. I'm not on the right and walk for like an hour. One hour, like two lecture halls right up next to the stairs more or less. But they're big. Yeah, that's that. There we stay. So it starts open. I think that's still too open for today and for five for tomorrow. They have these like talks and there's an other pad which we announced at some various locations where you can enter yourself. I'll also go on Twitter, call write to the uni. I'm not quite sure. The and uni as in unilateral. We organize the lighting talks. Last at least an event like that wouldn't be possible about without sponsors. Special thanks goes out to inno games who gave us some money to follow our speakers. So most of the speakers in the main track got their hotel room for free. So thank you very much for this. And that's it. And I frost on have a nice day. Drink some club matter and mention mention mention us on social networks and let's get frost on trending this weekend. Yeah, yeah, I'm this year. We signed a cooperation agreements with the university and as usual, there needs some pictures to be taken. So we're doing this now.
init Kicking off the conference The opening event of the conference. A few starting remarks and warm welcome from the conference organizers. ······························ Speaker: towo Andreas Kupfer Event: FrOSCon 2014 by the Free and Open Source Software Conference (FrOSCon) e.V.
10.5446/19628 (DOI)
Welcome everybody. Yeah. Today I will talk about data analysis and visualization with Python. I work at the German Aerospace Center in the Institute of Simulation and Software Technology. Before that I did my PhD in theoretical physics at the University of Bonn. And during that time I heard a lot of talks about Python and scientific computing with Python, but I never really got the chance in my work to do it. So I decided to do a little private project on my own to learn this stuff, because I think it's really beautiful and easy to use. Yeah, and this is what I'm going to tell you about here today. So first of all, I will give a short introduction to NumPy, which is the basic building block of all scientific Python libraries I know. And afterwards I will show you how to do publication quality plotting with Matplotlib. And then I will proceed to Pandas. Pandas is a library for data analysis, which was written by Wes McKinney in order to analyze financial data, but you can also do other stuff with it. And in the end I will show a Pandas use case, which was the goal of my project to analyze my personal expenses, so to find out how much money I spent on food, on clothes, or something like this. OK, so the main, everything I will tell you, here I got from this book. It's from the author of Pandas, Wes McKinney. It's a really great book, so I can only recommend it if you're interested. And the next thing I recommend to you, if you haven't already heard about it, is the iPython notebook. I will just briefly show you what it is. So as you see, my talk is web-based. So this is a browser here. And I actually did this talk, the slides for the talk in iPython. So iPython is just a really nice interface to Python where you can do nearly everything for example, slides for a talk. And you can type in Python commands here. Import, numpy, snp, and then I will show you later what this is. And you get out something. So this is just a brief stop here, and then I will proceed. So as I said, I will begin with numpy. So numpy is very good for fast vectorized arithmetic operations because under the hood it's written in C. And Pandas numpy also provides tools for integrating code which is written in C++ or Fortran. And as I already said, it's the basic building block of all the scientific libraries in Python. And as I said, since I will show you a lot of code in my talk, I import here the numpy library and snp, and in all the following slides, whenever you see np, this is numpy, of course, because this is really all the code you see is a sequence of commands which are given to the Python interpreter. So the main object in numpy is the array. So the array is a container for homogeneous data. As you can see here, you can create it with np for numpy array, and then you give it, in this example, a list of lists, and you give it a data type. So you have homogeneous data because under the hood it's a C array. This is the reason why it's fast. And you get a numpy array. So what you can do with a numpy array, for example, you can do vectorized arithmetic operations. So I want to multiply all the numbers in the array with 10, and instead of writing a for loop which runs over the rows and the columns, I just type data times 10, and then I have an array with the same size, and every number was multiplied by 10. You can also do more sophisticated operations, as you can see on the last command on this slide, where I applied the sine function to the data and something else, and yeah, this is vectorized operations. And they are really fast because, as I said already under the hood, this is written in C. Numpy also provides easy creation and reshaping of arrays. For example, if you want to create an array with two rows and three columns with ones, filled with ones, then you can use this command. You can also arrange. You can create just a range from zero to some number easily, and you can reshape. As you see here, I take this list from zero to five and reshape it into a two-dimensional object with two rows and three columns. Numpy also provides random number generation, as you can see here. And the good thing about Numpy is easy slicing and indexing. Here you have an array from zero to nine, and like in C, you can access the elements of this array with this command. So I have, I want the fourth element of this array, and I get it like this. Here you can see slicing. If I want the elements six, seven, and eight, I can do it like this. And you can also do more fancy slicing in the last command. With the last command, I get every second element of the array. You can also do this for multi-dimensional arrays. Here I have an array with three rows and four columns. And if I want, for example, to get a subset, the subset here of the array, then I can do it like this. So the first command here describes the subset of the rows and the second one of the columns. So I want row one and two and column one, two, and three, and I get it like this. And you can even do more fancy indexing and slicing. For example, if I want zero, the 10, and the 11, I can do something like this. So I get the index pair, not the zero, I want the one, which is the index zero, one. And I want the 10. This is the index two, two. And I want the 11, which is two, three. And I get it. So you can get every subset of the array. OK. Yeah, you can do Boolean indexing. For example, if I want all the data in this array, which is greater than four, I just type data, data greater four, and I get all the numbers, which are greater than four. And note that the shape of the array has changed because the data I cut out cannot be pressed into the same size and cannot be converted to a matrix-shaped data object like before. Yeah. I can also do more math-like stuff. For example, I want to cut out the zero, the three, the nine, and the six. And I can do it like this. So if I divide the data by three, and if I do model three, and if it's not zero, then gives something back. So you get an array where the zero, the three, the six, and the nine is cut out. I can also write the data like this. As you can see here, I replace the zero, the three, the six, and the nine by the value 100. OK. I will skip this. You can also do linear algebra with numpy. So now we'll come to matplotlib. As I said, it's a library for publication quality plots. And it's highly configurable, which means that because it's aimed for publications, for scientific publications, you want to configure every bit of your plot, your figure in your publications. This makes it somehow difficult to learn. But there is also, if you come from, I mean, the idea of matplotlib is that you have a matlab-like interface. And there is also matlab-like interface provided. So if you know matlab, then you can easily switch to matplotlib. Because I don't know matlab, I will not show you that here. I will show you the hard way in some way. OK. OK. And in the following, I will import matplotlib as PLT, or the part for matplotlib that I need, I will import as PLT. And the first thing I want to do in my Ipyth notebook is matplotlib magic. So if I type in matplotlib inline, then all the plots will show up inside of my notebook, so inside of the browser. Yeah. And yeah, plots in matplotlib, they all live inside a figure object. So you create it like this, PLT figure, then you get the figure object, and you have to put some plots into the figure with the add subplot command. And you have to give this command a grid of subplots. So you have to give the number of rows, the number of columns, and the position in the grid. In this example, I only want one subplot, so I give one row, one column, and position one. And I get back an access object, and this is the object where you plots things into. So if you have more subplots, then you have different access, and you can specify where you plot your stuff by using it like this. So you take the access objects and execute the subroutine plot. And you can see here, again, some numpy stuff, I created an array x, which runs from 0 to 3pi with 1,000 steps. This is this linspace command. And I want to calculate now the sine x squared of this. And again, I can apply the sine, the numpy sine function on top of this array and get a new array y, which now contains the values of the function. And if I then take the access and execute plot, I get such a thing. And you can see this looks really nice, I think. But there's something missing, which is labels. And the next cool thing about Matpotlib is that you can put Latich rendered labels in it. So forget about all the stuff above. This is the same as in the last slide. So first of all, I will label this plot with this string here. And if I include this dollar signs here, I can put in Latich code. And this will get rendered like this, as you can see here. I can also specify the ticks. So on the x-axis, I want to have 0pi, 2pi, and 3pi. And I do it like this. So I set the x-ticks by giving a list with 0pi, 2pi, and 3pi, as you can see here. And I want to label it with the appropriate labels. And this I do with x-ticks labels. And here I also use Latich commands, as you can see here, inside this list of strings. I can set a title, my plot, and I put a legend somewhere. So there's this option best. So there's an algorithm which finds the best location for the legend. And the last thing, I label the x-axis with Latich rendered x-character. And I think you can see this is with a few commands, you get a nice looking slide for your publication, a nice looking plot for your publication. You can do more. Here I have an example for three subplots. As you can see here, I again get the figure object and create three subplots with one column and with one row and three columns. And I plot now three different things in all the three subplots. The first one is the histogram. Here I give the histogram an array and this array is a normal distribution, 100 numbers of the normal distribution. I give it 20 bins. I can also specify the color easily and the transparency and the result is shown here. I can also do a scatter plot where I give it the numbers from 0 to 29 and the numbers from 0 to 29 and on top, Gaussian distribution. So I get a spread here and the scatter plot makes these little dots here. And the last thing here on the right side is again a random distribution and a cumulative sum which is also provided by NumPy. And I want to plot it in red with a dashed line and I can do this very conveniently with giving this string here r and minus minus. And you can also see that the plot command in this case only needs y values and the x values are just the numbers from the index of this array. So from 0 to 59. Yeah? You can export it in different formats. I'm not sure what's possible but I think you can do PDF, SVG, all the things you need for scientific publications. You have to configure my Python in the same way that I can configure my LATech and replicate all that configuration code. You mean if you would do publication in LATech or what do you mean? I'm running a paper in LATech. Yeah. I want a particular font. Okay, I see, yeah, I have, as I said, I have never done this. I'm not sure about this. Yes? You can set the font, you can set the font, set the font selection mechanism. You can write to like code and you can set the font. Oh yeah. You can replicate all of my code again in Python. But if you're going to do it, well, when I have a preamble in LATech, then I set the font and I go to the packages and use early flow. Yeah. That's a good question. I'm not sure about that. Yeah, but that's math mode. The question aims, can you include normal LATech text? What happens when you go to a real LATech, a store of dollars? Yeah. Does that work? I'm not sure. I didn't try it. Yeah, but not the plot, not the labels in the plot. I mean, if the question was in, for example, here, if I want this my plot title written in LATech, right? In LATech font, if I can render this. But I'm not sure if this is possible. We can try it out later, maybe if there is time. I can just switch to the notebook. Yeah. Okay. So now I will come to pandas. So as I said, pandas is a library for data analysis. And the first obvious thing that you will see is that the data structures are exactly like NumPy arrays, but there is also an index label and a column label. And you have supports integrated for time series, which is especially important for my problem, because I have expenses at different dates, and I want to analyze it. Pandas can also handle missing data, which NumPy can't, and it has functions for sophisticated data transformation. And the following I will import pandas as PD as shown here. So the main objects in pandas are serious in data frames. If I have one dimension of data, I use serious. You can see here, I create a pandas series by giving it a NumPy array of three random numbers and also provide an index, which is a list of strings in this case, but I can also use other types, not only strings, but also integers or floats. And if I plot it, you can see that there is this index and the data and the data type. So that's a serious. And the other thing is the data frame for multidimensional data. You can imagine this as a large, excellent spreadsheet. So you have two-dimensional data, and you have an index, and you have named columns. And you create it like this, your pandas data frame. You give it a NumPy array. So again, I create six random numbers, reshape them into two-dimensional objects with two rows and three columns. And then I give the column names Alice, Bob, and Charles, and I give the index names one and two. So this is the data frame object, which is the main data object in pandas. And what can I do with it? First of all, I can select columns in this spreadsheet. For example, by giving a label inside this bracket. So I want to go back for a moment. I want this column here, and I can do it like this. And you can see that this gives me back a serious. So if I want to know what is the type of this object, you can see that this is a series. It's a pandas series. Yeah. You can get all the subsets in this data frame with the Ix command. And the good thing about it is that you can not only use indices, but also labels. As you can see here, I will go back for a moment. I want to get this row here. I want to get row one. And I can give the Ix command in the first argument a label one. And in the second argument, I give it indices. If you know Python, this symbol indicates that you get all the indices in the array. Indeed, this gives me back this row, but now labels transfer the column names to index names. So now I have Alice, Bob, and Charles as index labels here. And the name of the, and there is also a name attribute in the series, which is then, of course, the former index label one. I can also do, as I said, I can also do index-based slicing. So here I get the zeroes row and the zeros and second elements in the column. So I get a series of two elements. What I can also do in Panlas is function application. So I want to apply some function on every element in the data frame. And I can do this with the apply function. So I define a function which adds 100 to all elements. And I just apply it onto the data frame and I get a data frame with all the numbers increased by 100. There are also included functions for statistics like sum or mean. And you can see the sum just sums up all the columns and gives you back. So it sums up all the columns and gives you back in a series with the index Alice, Bob, and Charles. And the data is now the sum of each column. The next thing you can do is merge data of different shapes. And this is a really cool thing about Panlas. So here you can see two different data frames with different dimensions, but they share a key. Here I have data one and keys A, A, B, A, C. And here I have data two also with keys. And if you want to merge them somehow, what would be the natural thing to do? So they share a key. Therefore, if I want to merge them, I get something like this. I have now three columns, data two, data one, and a key, which was shared between these two data frames. Sorry, I forgot something. The special thing about this data frame is that there's a one-to-one correspondence between the data and the key. So Panlas will recognize this. And we'll recognize this one-to-one correspondence. So it will set, and whenever there's a key A, then data two is three. And this is exactly what happens when you merge this. So whenever the key is A, then data two is three. So it's somehow intelligent merging. And there are a lot of stuff like this. So this is really powerful data-braining mechanisms included in Panlas. You can also concatenate data. Here you can see two data frames of different shape. Here you have four columns, and here you have three columns. And if I want to concatenate them, I will glue them together like this. And I get something like this. You can see here that despite the fact that they had different, these two source data frames had different dimensions. And the concatenation works, but because there was no data in the fourth column of the second data frame, it will include not a number. I still have 25 minutes, right? OK. Good. And here you can see one, another cool thing about Panlas, which is the handling of missing data. So it will just infer that this is the right thing to do. So I want to concatenate two things which are not compatible at the first site, but you can do it with Panlas, and it will just fill in missing values with NAAs. NAAs. If I do something like this, maybe I want to, I have now two rows with the same data, and I want to drop it. You can also do it very easily. You can just use the drop duplicate routine, and you give it the, as an argument, you give it the string of the column A. So in this case A. So it will search if A is equal in two columns, it will drop one of them. And this is exactly what happens here. And also you can see that it keeps the one with the number here in the fourth column. OK. For my problem, it was really important that I can analyze time series, and this is also completely included in Panlas. Here I create, I take the data frame from the slide before and rewrite the index. So what you, and the index is now from the datetime library. So import datetime and create a new index by giving a list of datetimes, as you can see here, and passing it to the index of the data frame object. I also give a name for the index, dates, and a name for the column class. And you can see that it now appears here, the name for the index and the name for the columns. And indeed, if I look at the zero entry of the index array, you can see that this is a timestamp of the type datetime. The next thing is when I want to plot this data in contrast to NumPy, Pandas provides more convenient plotting routines. So on top of matplotlib, Pandas provides more convenient routines. If you want to plot this data, you have already an index of dates. You have a name for this date, for this axis, and a name for this axis. And it would be nice if you can plot it and don't have to give the axis names and the labels. This is exactly what Pandas does. So if I take this data frame, df3 now, and type plot, then it automatically does all the labeling for me. As you can see here, I had four columns. I had even one column with anans in it, but it works. So you have a plot. You have the dates as labels. On the x-axis, you have the x-axis label. And you also have the label of the columns here, with just one command plot. This is really nice about Pandas. So you do not have to, if you are lazy, you can just hit plot and everything is there. Okay, and now I will come to the use case. So why I did all this stuff. So I wanted to analyze my personal expenses. And they look like this. If you get an account statement from your bank, you get a date, the amount of money which was transferred, and some description. And I anonymized my data here. So this is my data, but somehow anonymized. So the first thing you have to do is you have to categorize all this stuff, to know how much money I spent on different stuff. And this I have done with, I have written a small tool which is called PiAccount, which does this. So it reads in your account statements from your bank, and it asks you, it prints out the description, and asks you which category is it. And you can filter it. And then you can create filter lists. So every time there is ID in the string here, then it's food, for example. I will not show you how this works in detail, but the result is this. So on top of the data from the bank, which are these three columns, I get the fourth column, which is the category. So all the items in this data are now categorized. So, and the first thing I want to know is how much money did I spend on some category. And Pandas provides a very useful tool for this, and this is the group by object. So I have this data frame from the slide before, and I hit group by category, and calculate the sum, and I get exactly what I want in one step. So I have now in the row index, is now the category, is it's named correctly, and I get the sum of all these categories in the first column. And again, I can plot this really easily with Pandas. So, okay, first I want what I have to do now. I don't need this description anymore, so I have to get the subset, the serious subset, which is the first column, and I do this with the IX command, oh, sorry, with the IX command. So I have this data frame group sums from the slide before. I use this IX command and give it a list of categories in the first argument. So I only want to categorize car, cash, food, kids, media, restaurants, sports, and the second one is value because I only need the value column. So this pi data on the left hand side is just a series, which now contains the data I want, and I can plot it just with plots, and I want to make a pie chart, so I say kind, pie, and I give it a title, and it does everything for me. So I have a nice picture with one command, and I can see that I eat a lot, yeah? Yeah, as I said, this is anonymized. This is not really my data, and it changes every time I create the slides because it's random. Okay. Yeah, you can also, but the data here now shows the expenses on food on the whole time span, but of course I want to analyze how much did I pay on food in January or did it change over the month or something like this, and therefore I can restrict the data to a specific time span, and this is also a very cool feature about pandas. I can do it like this. I can give it just a string which gets recognized as a date, and I want to slice out from 1st February to 1st April and do the same group by category and some routine, and now I get the same kind of data, but now you can see the numbers are smaller because it's only for two months instead of six months. The data before was for six months. I can also look at the expenses over the time with the group by mechanism, the data frame, group by category, and get now only one group, the food group in this example, and I get a data frame which now only contains the category food. And again, I can plot it in a nice way. Here you can see again this convenient plotting style argument. I want to have dots and lines, and it's just O minus, and I get a nice plot with the right labels. Okay, this plot doesn't say that much, but you can do it for other stuff, and this can be interesting. Okay, so as I said, I want to get the monthly expenses of food or car or something like this, and therefore I have to sum up all the expenses in a given month and aggregate it, and this can be done in this way, so I go back here, and I have food in this case, and now I want, for example, this is both December, so I want to sum this up here. This can be done by this resample routine, so I say resample, this M stands for month, and how sum, you can also do mean or something else, but I want some, so I do it like this, and I get a series where now I always have the end of the month in the date row, and I have the sum for the monthly expenses on food in the first column. Since I don't want to have specific dates here, but I want to have time spans, so I don't want, the data corresponds not to this day 30 of November 2013, but it corresponds to November 2013, and therefore I can, in pandas, you can easily convert time stamps to periods, and this is just done with this single command, so you take the data frame and try to make two periods, and then you get the same data, but now here you have another data type, which is not a time stamp anymore, but a period, a time period. And now I have what I want, I have the monthly expenses of food over six months, I only show four here. Okay, and again I can plot it, so I just type plot, and I get a nice plot, and I can see that what I did. Yeah, you can do more fancy stuff, for example calculate the relative change in the monthly food expenses by taking the monthly food expenses and divide it by the data shifted one month earlier with this shift minus one, and then you subtract one to get a relative change, just with one command, and you can see that it gives you a series, and you can plot it, and you can do much more with pandas, of course. And the last thing, I don't want this for food, I want this for a lot of categories and see how they changed over the time, and so I want something like this. Here you can see that with these commands, I get what I want, so I loop, I create a new data frame, ME, and now I loop over all these categories that I'm interested in, then I use this group by mechanism to get the data for the specific group, and then I re-sample it in the same way with month and sum, and here I do this period, this transformation to periods in one step with this kind argument, and here I append each column to this whole data frame in the last command, and if I show now the data frame, I have exactly what I want, I have the expenses for car in November, December, January, February, and so on. And again, this can be plotted with a single command in a nice way. This time I type plot and kind, bar plot horizontal, I want it stacked, so on top of each other, and I give the transparency value, and I don't have to label anything, everything is there, and I now see where my money went in a really nice way. Okay, I hope I've shown you that this pandas is a really nice tool for data analysis, and it's really accessible and easy to use. Questions? Yes? The question was how the performance is for big data. I heard it's quite good, but I'm no expert in this field, because as I said, I did this as a private project for small data, but I heard that this is a topic on Pi data conference or something like this, so I think it's also useful for big data. Yes? So the performance is good. Yes? I don't know R, so I cannot answer the question. I just know Python, and I love Python. Yeah, I cannot answer it. It's just a matter of taste, I think. I mean, the good thing about Python and this iPython notebook is that you can do... It seems to be a tool for the whole scientific workflow, so that you can do everything. You can do programming, you can do scientific publications, you can write a paper in it. This is the goal of the iPython notebook. I think it is one of the goals, and it looks really good. So it's not there yet, but to my experience, it's just this... Maybe this is a reason to use Python for data analysis. Yeah? One of the things that occurred to me when you were giving me a talk is that you have to practice all of these different commands with the numPy library, you don't have to do it. Python doesn't really understand that all of these operations are vector operations. As an interpreter, it's unable to go ahead and do useful operations, like combining things or any of these typical, parallel operations like strain reduction, pulling things up and pushing them down in the hierarchy in order to optimize it. And so your argument that it's so fast, it's like C, doesn't seem to make sense to me, right? It's fast like C, as long as you're talking about very simple operations, but anything that is more complicated and re-factoring would make sense, Python should lose. Yeah, okay, but then there's... It does not... Pandas and numPy do not cover everything, of course, but I think then you can use Syson or something like this. Yeah, but it's still an extension to Python, right? Whereas we take R or Julia, these are our first-class operations in the language, so the interpreter needs to go ahead and re-factoring. Yeah, maybe. I'm going to respond to what you said. Yeah, yeah. Okay. Yes? I'm not sure. I'm really new to this stuff. Yeah. Yeah. Yeah. Yeah. Yeah. Yeah. Yeah. Yeah. Yeah. Yeah. Yeah. Yeah. Yeah. Okay. I think there are no more questions. Then thank you again. Thank you.
Data Analysis and Visualization with Python Usage of Numpy, Pandas and Matplotlib for a personal bookkeeping software We demonstrate the usage of python's scientific tools, Numpy, Pandas and Matplotlib for data analysis and Visualization. As a use case, we present a python tool for personal bookkeeping. The talk will include: ······························ Speaker: Tobias Stollenwerk Event: FrOSCon 2014 by the Free and Open Source Software Conference (FrOSCon) e.V.
10.5446/19627 (DOI)
Welcome once again for the second talk, slightly smaller audience this time. I have no mirroring on my laptop so there will be a challenge. Watch to this screen. This is a talk about an optimization to the SmartIn compiler that I have been working on. I will talk about SmartIn but talk about how to make things faster without much effort. About myself, I still work for Pernicomarketing software, I still study computer science and planning, and I'm the author of the PHP CPP library. One of the questions that people often ask me about the PHP CPP library, what is a good use case for this PHP CPP library? And I often respond, well, that's when you have an algorithm or a data structure that takes a lot of resources, takes a lot of CPU or a lot of memory, then you can port that to C++ using this PHP CPP library. And I noticed that people start writing their own simple scripts in C++ and that is often not a good use case. So I was thinking, what would a good use case be and I thought, well, smart it could be a good use case. I don't know if you're all familiar with SmartIn but this is an example of a very easy SmartIn template. You can use dollar signs and variables and if statements and this is how you make a SmartIn template. You can do more complicated stuff than this but that is not important for this talk. This is a SmartIn template. And how do you use this in a PHP script? You use like this, you create SmartIn object, you assign a couple of variables to it and you display a template. And the SmartIn object takes care of reading the template file and showing the output and replacing the variables and showing and processing the if statements. That's what SmartIn is. I think we're all familiar with that. How would you do this if you had to implement this yourself? That's the very first time that I used SmartIn. I thought, well, this is going to be crazy slow because SmartIn is going to evaluate the template every single time over and over again and it's going to use regular expressions and pattern matching and string replacements to do all these sort of stuff. So this must be crazy expensive and crazy slow if you look at the implementation. But it turns out that SmartIn has a smarter way of doing this. Under the hood, SmartIn transforms that TPL file into a PHP file. The very first time that SmartIn sees that TPL file, it reads it, it parses it, it analyzes it and it turns it into a PHP file and stores that PHP file on disk and it runs that PHP script. The second time you show the same template, it will no longer have to scan that template but can show the PHP file, can execute the PHP file right away. So that's much faster. And to get you to give you an idea, this is what the simple template that I showed before looks like after it has been compiled by SmartIn. So you can see that it has, it has turned into a messy PHP script but essentially it does the same. It has also that name that it is showing and it also has this if statement inside. The question that I now have, do we consider SmartIn to be a compiler? I never thought SmartIn to be a compiler. For me it was just a silly script language. But if you start thinking about it, what exactly is a compiler? If you go to look at Wikipedia, this is the definition that Wikipedia has of a compiler. It's a computer program that transforms source code written in one programming language, for example, the smart language, into another computer language, which is the type language. Well that's exactly what SmartIn does. It transforms that TPL file into a PHP file, which is in fact according to the definition. So SmartIn, you could call SmartIn a compiler. And would that be a use case for PHP? Imagine you find someone, you speak to someone on a conference and say, well, what are you doing? Well, I'm writing a compiler. It's so cool. I want to write a compiler myself too one day. Yes, good question. Is it more like transpilers than a compiler? That's a definition topic. I don't know. Transpiler? They used the term when it was a talk about JavaScript, where they used object-orientated version of JavaScript. It wouldn't run in the browser, but it would compile or transpile the one that I'm in, into real JavaScript, which is runable. This is the first time that I've heard that word transpiler. Yeah, like coffee script, but it wasn't the power script. I've never heard the word transpiler. But I guess you can give a definition. I said, compiling is only the process of turning something into machine code. It's called compile. If you change the definition, it's no longer a compiler. That's true. It matches this definition. It has a big pediatrics. What if you find someone, you speak to somebody, and you say, well, I'm writing a compiler or transpiles. That's cool. What language do you use for that thing? Well, I'm writing a compiler in PHP. That is lame. You don't use PHP as a language to write a compiler. Yet, smarty is a compiler written in PHP. This is a huge opportunity for PHP-CPP because PHP-CPU is a perfect use case, a CPU intensive algorithm, an algorithm that takes up a lot of memory, which exactly is what the compiler is. This would be a perfect use case for PHP-CPP. If you think of it, what exactly is smarty? Well, smarty is a PHP script, and it turns a template file into a PHP file. When you look at this in a single line, there are two very obvious improvements that are possible. One of them is you can implement smarty not as a PHP script, but in a native language. You can use C++ for the implementation of smarty. Would make it faster to turn that template file into a PHP file. The second improvement is while you're busy converting one representation into another, why would you convert it into PHP, which is a slow language, and not convert it right into machine code? Anyway, it would be faster. These are two obvious improvements. The end is that smarty-modem in native library that turns the template file into machine code, which is much faster and has the added benefit that you can use smarty templates suddenly also in other projects. Because we in our company are thinking of moving large parts of our code base to C++, and we have many customers with a lot of smarty templates. So we cannot move to another language than PHP because we have to support these templates. This is the idea that you get one day, and this is not something that you're going to do seriously because that's going to be a lot of work, of course. But you get the idea and every time you see smarty, that idea is triggered, and one day you decide to create an account on GitHub and just, let's try a little bit. Maybe we can do something. We're not going to be a smarty per project, but we can maybe only be a statement. Let's see what we can do, whether we can achieve it. But that's how it all starts. Some background information about compilers. I'm not an expert on compilers. I just Googled this. I just tried some things, and I wanted it to be small and simple. So I once gave this talk somewhere else, and there was some teacher from the university who was specializing compilers in the public, and he was tweeting while he was doing. Every bullet point was open for discussion. So this is just what I read on the internet. A compiler has two different steps. First it looks at the input file, and it picks out the tokens, the if statements, the keywords, et cetera. After that, it takes these tokens and turns it into a syntax tree or a parse tree. That parse tree can be optimized and checked for type compatibility and things like that, and after that, that tree is converted into a new representation of the machine code. Let's start with the first step of this compilation process, the tokenizer. If you, as a human, look at this, this template file, you immediately see the tokens. The HTML tags are tokens for us as well, but for the smart enough, it's just raw tags. So the raw tag HTML body, hello, then we see suddenly a token, which is a variable, and we see a token, which is an if statement, and a token, which is the age variable, and the bigger them that's a token. These are all tokens. They are picked up by the tokenizer. And the first thing when you write a program or write a compiler is to write this tokenizer. Yes? You had the ifslack of bracket slash if bracket, the second line to last one is the start token, but the closing bracket should not be there, right? Or should it? Or do I do it? Yeah, no, it's a very good question that you're asking. I don't know why this is called start token, because it doesn't start anything. These are tokens. They start new context. Yes? This is a start token because it starts a new context. This is a start token because it starts a new context. This is just a regular token. It was in the normal context, in the station, in the normal context. But I think the start words can better be removed here. These are tokens. And I also said smarty tokens, which are tokens inside smarty. Well, it's confused. It's confused. Okay. Well, we have tokenizer has state because, for example, inside curly braces when you see inside a string that you use a curly braces, it is not picked up as a token a while, it is picked up as a token if it is used in another context. Writing this tokenizer is the first step that you have to set when you're writing your own compiler. Luckily, we have a tool for that, which is called FLEX. What you do with this tool, you simply tell to FLEX, well, these are my tokens. These list of things, these are my tokens. FLEX, could you please for me write the rest of my software? FLEX has documentation online. This is a very simple web page describing FLEX. Let's see when documentation, because I wanted this project to be simple. I was not, I had not the intention to make something very complicated. So I wanted to use only simple software and no complicated. And this is just easy enough to use. It is, I don't like the syntax too much, but I read this website and it took me a day or so to learn this tool. And in the end, I managed to write a simple file describing all the tokens, which is this file. And you can define every token in this file on the left side and on the right side you can say what token it is. So you see inside the curly brace, we have a special state and if you see the word true, it means the true token is found. You see the false token is found. And some tokens like literal integer, middle of number, well, we return that this is an integer token, but we also have to remember what integer it was. So we store token object, which basically is a string. This is all the only programming that you have to do for the tokenizer. It is doable. It is not so difficult. You compile the tokenizer or transpile the tokenizer and with the flat command and this turn into a tokenizer.c file. A tokenizer.c file that looks like this. Well, this is automatically generated coded. This code was not written by me, but by the program and it looks ugly, but it works. It does the job. And it looks like the code from the same. No, this looks much better. There are comments in it and it does the job. It is quite complex. It has to create an array because it scans each byte. It has to create a new state. It is quite complicated software that is created. It is automatically created, so we don't have to worry about it. It is complicated, but not maintained by us, but by the program. Once you're ready, you can call the yylex function and it returns the token that it found. This is the core of your compiler. This is the core of finding the tokens. And the next step that you have to set is doing something with these tokens. The tokenizer says, well, I found nif statement. I found identifier. I found a number. You have to pick it up and analyze that. How is the tree true? There's no tree. Ah, there's no tree. At this point in time, there is no tree. The tokenizer only says, I found nif statement, I found yylex statement, I found nif number. Now you're going to write the next step and say, well, token, now you're going to build the tree. The tokenizer says, well, I see an entity. That's wrong because there was an opening statement. Up to now, there's no syntax check. We now do the next step and build the tree. Exactly. And report syntax error. And if you see expression like this, 2 plus 3 plus 4, you must know the process. This can be quite complicated to parse these trees. It's doable, but quite complicated. And we don't want to do complicated stuff. So this would be the tree if we parse the template, the example template that they gave with one h statement and one variable. It would be basically like this. And it would be nice if we had a program that does this for us, that we can just give a set of instructions and could you write our software, please, so that we don't have to write this complicated parser. And such software exists. And the famous ones are Jack and Bison. Jack is a very old one. It's, I believe, not even open source. And Bison is one that is based on it. That is open source. And that is when you look at compiler building on the internet, you find references to Bison everywhere. And also Bison has a website, essentially the same design as the flex documentation. No design at all. But it has a lot of documentation, a lot of examples and things. So I started working with this and suddenly I found on Stack Overflow a question about Bison and some guy answered that question, why don't you use lemon for this? I have never heard of it. I had heard of Bison because I've been using Linux and I see that being installed all the time thinking, well, I'm not going to use it. It's probably very complicated. But I saw this remark about lemon. So I did a Google for lemon and this was the documentation of lemon. And you see what it says. Lemon is similar to the much more famous programming, yeah, and Bison, but lemon is not compatible with them. There are several important differences. Lemon uses a different grammar syntax which is less prone to programming errors. Well, that's a good thing. The part that generated by lemon is both re-entered and thread safe. That sounds good too because we are going to write a smarty compiler and that could be running in a web server process that has multiple threads and we don't want to have crashes if one compiler process is running while the compiler program process is running as well. What is re-entered? Re-entered means that you can call the same function while another thread is already running in that function. That's a special case of thread safe. When it's thread safe, then it's always re-entered. If you have a function that uses a global variable or if you have a function that uses a static variable, then that function is not re-entered. Right. And then the whole program is not re-entered. Then it's that function not re-entered. And that is no problem if you're writing a single threaded program, but if you're writing a multi-threaded program, you want your functions to be re-entered. You don't want your functions to use global variables and static variables. And I think that the Beeson program was originally meant to be used in compilers and compilers only have a single thread compiling the program and after it is ready, it exits. And this lemon program is part of the SQL live suite. It's part of a database system that must run continuously, that must run for hours. So, they don't want memory leaks and they want to access it from multiple threads in the center. Because the other at the top of the level is that it doesn't leak memory, which we also want. So, we have this very famous Beeson project and somehow I ran into this lemon project with this part of a simple database engine and it seems to be better than Isser and better than Beeson. There's documentation online and this is only, well, a very small file explaining how it works. Some examples. This was really easy to learn. This was, in fact, easier than the initial part, the next part. And if you go back, you can go back. That's a good question. Yes, it is thread safe. Yes, I've read that on the documentation. They have a special option that you should use to have a thread safe. The default configuration is not thread safe. It uses global variables, but you can set a special option and then you have to pass in a state variable that it uses for all its globals and then it is thread. These parsers take a formal grammar and they turn that into a function to parse the output of the tonalize. What exactly is a formal grammar? Once again, until we can figure it out. And this is the definition that they gave in formal language theory. A grammar is a set of production rules for strings in formal language. Long story. Difficult, but they don't want a formal grammar. They want a more specific formal grammar. They want a context-free grammar, which is an even more complicated definition in formal language. A context-free grammar is a formal grammar in which every production rule is on the form VROW, where V is a single non-term or single, okay. That is also quite complicated. The problem with definitions I have is that the human brain doesn't work with definitions. If you want to teach to a three-year-old or four-year-old what a cat is, you're not going to give the definition of a cat. You'll give them a picture of a cat. You give them another picture of a cat and another picture of a cat. And by then, the human brain has formed the concept of a cat. You also show a picture of a cat. Yes, exactly, because you can't give a definition of a cat. You're going to give a cat, yeah, this is an animal and that's four legs. And then you show them, well, that's an animal with three legs. Well, okay, that's a three-legged cat. This cat is not alive. Yeah, this is a dead cat. But I thought the definition, it was supposed to live, wasn't it? Definitions are different. You saw that with the compiler before. We had the definition of a compiler. It turned out to be the wrong one. So what exactly is context-free? Well, this is an example. We show a picture of insert query. If you insert query in SQL, it looks like this. And it would be nice if you have the entire smarty language written out like things like this. What does smarty look like? This is allowed for an if stake and this is allowed for a variable, et cetera. You can do it in images. You can also do it in extended backers north form, which looks like this. You probably have seen these things on the web pages if you were working with languages and tools to show exactly what is allowed. This is for a very simple program syntax for a program that could, for example, look like this. And how cool would it be if we could write smarty in code like this if we could tell Lemon, OK, this is what my language looks like. Please generate the code to parse this language. Well, we can. And Lemon does not take images as input. Lemon takes files like this as input. And this is only a small subset of smarty. So I said, well, we have Boolean expressions and we have normal expressions and we have if statements. And I made a subset of the smarty features. The actual program has more features, but for the stock I have small subs. And you define what the elements of the language look like. And for every element you define an action that should be taken once such an element is encountered. And these are simple objects. So when you see an if statement, Lemon creates an if statement object. And when you see a Boolean expression, Lemon creates a Boolean expression object. This is the only program that we have to do. And we have, of course, to create these classes, but they are really simple classes. This, for example, is the class of an if statement. An if statement has three, three, uh, lemon variables. The expression that's evaluated, the statements that are going to be executed when it is true and the statements that are going to be executed when it is false. So this is straightforward programming. Because nothing, nothing difficult is going on. I have not done any optimizations or performance issues on the part. Well, let's try to see if it works and the optimization. It's nothing. Only the last function that's going to be used in the last step when we are going to turn this object into machine programming. This is the literal number. Only one member, the actual value. And this is the literal variable. Only one member, the name of the variable that is going to be out. Simple objects. Simple objects. Nothing complicated is going on. Once we have created that input file and we have created all this class, we can compile or transpile the grammar dot lemon file and it turns it into a grammar dot c, grammar dot h, and then grammar dot out file. This is the file created by lemon. This is once again a complicated C file. Not written by me, not written by any human being, but written, but ultimately generated by lemon. And it is also quite complicated. Also these long tables with states and supported things. You get the ID. It is complicated stuff. So writing a parser is not easy, but we don't have to do it ourselves. We just have to specify all these parser rules and the parser we get for free for the month. This creates a parser function. Believe it is set here. This is the actual parser function that you can call from your compiler program. It creates some other output files and had a file with the constants defining all the tokens and some grammar dot out file. I think this is some debugging file. So it is not used in any project, but it came out of lemon. Maybe you can do something with it. And now we are halfway through of building our own compiler. This is the only thing that we actually have to program. We have to create a partial object. We have to find all the tokens and every token we give to the partial object, to the large. This is the core of your compiler. In reality, it is a little more complex than that because we have to keep some stage variables, but essentially this is it. This is simple. So by this time, we have this tree that is fully balanced and that works completely. And now we have to further deal with that tree. The question is what do we want to create? The question is that we were writing a smarty verifier or validator, only to see if the smarty file was valid or true. Well then we are ready by now because the fact that we have that tree means that we have a valid smarty. If you want to write the smarty minifier or pitifier, we can say to every node in the tree, okay, output yourself, but then minify it or printify it. If we were writing a smart interpreter, we can run at an execute function of every node to say, okay, execute yourself, the F statement is going to execute the expression and run the true or the false branch. We however are going to generate machine codes. And that is going to be the hardest part. Once again, this was the tree and we can add every node in the tree function to turn itself into machine code. This is difficult. Writing machine code is no fun. I did it once during my study and I wanted to keep it that way. It's no fun. I don't like technical stuff. I like making beautiful software but doing technical stuff is not my thing. So an intermediate approach would be to generate C code. You could turn your smarty file into a C file and start a C compiler to do that. In fact, if you look at what the HHVM project did, they did exactly that. They were also writing their own PHP interpreter, their own PHP engine and their initial version was turning their PHP code into C++. Why? Probably because they thought that's the easiest solution. It is easier. It's easier than generating machine code. But it is much lower. Think of it. The C code is first written to this. You have to generate a C code. Then you have to start the C compiler and internally the C compiler is going to, once again, parse it and tokenize the C input. And the C compiler builds the same syntax tree and is going to turn that syntax tree into machine code. Stores that to this. Your program has to open that file, execute it and write it. Much slower, but still very fast. But much slower and it would be much faster if it could generate machine code right away. This would be a solution. But we are in a lovely situation because there are libraries that can help us. And a very famous one for that is the LLVM library. LLVM is a library that allows you to use C++ API to create machine code. And the machine code that you use LLVM for works on almost every compiler. And there are some others. Mozilla, the browser, also use JIT technology inside and the Behaven library. And I found somewhere on the Internet, somewhere deep not even in the first 20 or 40 matches on Google, a small library called libjits. You could use that. Let's look at LLVM. This one is famous. Everyone is speaking about this is a big one. And it's the back of the Clang compiler, which is a very fast compiler and probably better than the GCC compiler that most people use. And big companies like Intel are contributing to this. This project is cool. I heard. This is their website. And, well, we want to write to generate machine code. So we look at the documentation. And it is a big website. Get started is basically about how to download it and compile it. It takes some time to find the right documentation. This is an example. I spent too much time on this website. And I thought, well, I do a Google search on getting started with LLVM. And I found a guy writing his own blog about how to write your own compiler using LLVM. And I thought, that's so nice. And he wrote this blog. And it's exactly the things that I just mentioned, the steps that he is going to take is accepted first. And then the tokenizer using flex, then the parser using Bison, well, we use lemon, but he's using Bison. And then the final step is turning this tree, this absolute industry, that's the ASD, into LLVM machine instructions. That's going to be the cool part of writing this thing. So that's what we have to do. We say LLVM makes this all very easy for us. Oh, that's cool, because that's what you want. One of the downsides of LLVM is that it's really hard to find useful documentation. I found it out already. There are online tutorials and other set of documents are wildly out of date. And there's barely any information for the C plus API unless you really dig for it. I found it best to learn LLVM for example. There are some examples. And there is also an LLVM live demo website which you can omit C plus plus, C plus plus code or C program. That's cool. That's the problem. Well, maybe there's an alternative. So I googled, does someone have a copy of this page by accident and a guy wrote a blog about this that he always uses test demo sites and that he found out that someone has somewhere put a secret demo page online. This is a website you can give input the C program that you want to have. You want to create machine code that does the same as C program and what output you would get to do that with LLVM. And we are working with C plus plus. So we want to see the C plus plus code that is necessary to make this. This is very simple of course. Just an example, what simple C plus plus code we need to have this output. And to have this small simple program, the only thing that we have to write in our C plus plus code is this piece of code. This is really trivial code. Now this is no fun. This was a point, this was my giving up. If you have to write such complicated code for your compiler, this project is not going to be a fun project that we are going to do in the evening hours. So I decided to abandon this LLVM project. This is too complicated. So I went back to Google trying to find alternatives for using LLVM. And I already mentioned this project and in fact it is pretty cool. It is also open source. It is on glue.org and it is not very actively maintained. It is not even in the Ubuntu repository. I normally use Ubuntu so I try to update and install all my software. But I had to download it myself from some resource and it was not version. So you had to use the repository instead of downloading a specific version. But it worked. And there was documentation online and the documentation was very clear. And it was really fun working with this line. It is not as famous as LLVM but well documented and it simply works. So that is what I used. So the last step in the process of writing my own compiler was using this libjits to generate machine code. And this is one of the most complicated classes, the if statement. And that does a branch and if something is correct it branches to one direction and it is wrong it branches to the other direction. This is the way how you should generate machine code. It is not so complicated. It is not so complicated as you would expect. This was basically the most difficult part of writing the own compiler. And now we have written a compiler that we can use. This is a C++ library so we use it as a C++ library. We can pass it a template object. We can pass it some data and we can process it. That's it. But this is not yet PHP. This is only C++ smart. We can also do it as PHP extension and we can use it like that. I thought initially that I had this PHP extension on GitHub but I think I only made it on my own computer and threw it away or so because I didn't find it there. So this morning I rewrote that PHP extension. Now you might be writing a PHP extension. It was crazy difficult. It was a lot of time. Well, not with the PHP C++ library, of course. I only wrote a small wrapper around the smarttpl, one class with a constructor that takes the name of template, an assigned function that assigns some data to it and a fetch function that displays it. It's simple. And inside the getModule function I defined a class and the functions that are the methods that are on it and I added to the extension objects. That's all you need to write an extension. So by doing this we have this extension and the most scary thing that I did this morning was running it. That's really because there is no optimization in the code at all. I was doing only stupid things, making full string copies and working with smart points and all the things that you would normally not do if you wanted to write optimized code. So the most scary thing I did was writing, was testing it. And you don't want to be slow. Okay, this is done. Very simple. You know this one. I wrote a simple PHP script which you can see. The PHP script takes one command and arguments. If you want to run it natively or if you want to run it with the original smarttphp implementation, it creates a smart object which is called mySmartT. It assigns some variables and 100 times after each other it's going to display the template. And the PHP code does exactly the same thing. Put that in the native implementation but it uses the smart implementation. This PHP implementation. That's Horlicks. This is the original PHP set of 100,000 times template. 3.8 seconds. It's a very simple template. And this is the native implementation, 0.3. So by not even doing our best to optimize anything, we get 10 times better performance improvements. Yes? I guess, yes. And you were just recalculating the template again and again. And of course, this GCC compiler is pretty good at caching. What do you mean? Your extension. Yes. It does good caching stuff with memory and with CPU registers and stuff like this. Yes? The machine code because it's compiled by a compiler that has a development time of 20 or... Yes, but I'm quite sure that this is caching. Oh, okay. The PHP is also compiled by the bit of a GCC. Okay, yep, okay. Maybe you don't... If you would assign the variable h with the value of the counting variable i before each fetch all. But maybe we can connect. You're annoying. Yeah, I am. We can. I have the code here so we can easily change it. It would be nice to see. I don't think it would be much better. But I believe you let it break fast. This is the first time that I tried. I tried this in the first time I tried. Okay, remember the PHP CPU cases that I once mentioned? You should use PHP CPU if you want to speak. Well, we got to speak. Memory use we haven't seen but I have the idea that it uses less memory. The cool thing is we have used, indeed, external libraries. We have this flex, we have this lemon, we have used libjit which was not possible with just PHP. So we have used external libraries. And we have now a smart engine that can also be used from other projects instead of only from PHP. So we have scored all four reasons why you should use, what situation you should use, PHP, C++. So this is a very good example of a project where PHP CPP makes sense. Well, while I was busy doing this, I thought, well, it is a waste of time to compile your template every time over and over again. So why don't store this machine code to disk? So once you wrote the template, you can compile it using a smart TPL template for TPL instruction. This turns that TPL code into machine code and stores it to disk so that you can also load it to live that one shared object file which even saves the parsing and the code generation. And it's not, it's even parsing that perfection. So this is the end of the talk. Don't be afraid to use these tools that I mentioned. They are free for you to use. They are all open source. They are fun to use. They are not difficult. They are easy. And every time in your life you find yourself in a position that you're using, a big set of regular expressions to parse a style sheet or to parse an HTML file or to parse a database query or so. Be aware. There are tools for it. The tools are easy to use and with PHP, CPP, you don't have to limit yourself to just using PHP tools to parse that data. Okay. Thank you. Do we have questions? Sure.
Building a smarty-to-machine-code compiler The open source SmartTpl libraries greatly speeds up Smarty templates bij turning templates into native machine code. During a crash course 'how to write your own compiler' you will see how this alternative template engine works inside, and you will discover that writing a compiler is not even that difficult. The following topics will be covered: ······························ Speaker: Emiel Bruijntjes Event: FrOSCon 2014 by the Free and Open Source Software Conference (FrOSCon) e.V.
10.5446/19626 (DOI)
Good morning, everyone. Welcome to the first day at Frostgon and to the PHP subconference. We are holding here in this room number six. First, it's me talking about a contribution and point in PHP. Before I start with the talk, I want to say one thing. We have one talk at 1630, I think, which got cancelled due to sickness. We got it replaced already with two new talks because it was a two-slot talk. PHP and Arduino by Thomas Weynart and at 1745, I think, it's PHP, NG, keep and stack allocation by Johannes Schluter. If you didn't see that in the schedule yet, we got two replaced talks there. So, again, welcome to the PHP track and let me start with a contribution and point in PHP. So, this sounds kind of insane, I guess, to you too. Let me start why I would do something like this. So, we all got this smartphone, right? Who doesn't have a smartphone here? Oh, two. Okay. Almost everybody got a smartphone. The nice thing about the smartphone is that you have access to a number of apps which you can use for a lot of different things like Twitter, Facebook, and for example, there's a schedule app for the Frostgon schedule where you get even live updates of the schedule and stuff like this. Most of those apps, except for very few rare cases, depend on some kind of internet connection. They will access some kind of server. Twitter, for example, will, of course, fetch the tweets. Facebook app will, of course, access the Facebook servers to read new messages or whatever you're using Facebook for. And then, when we are using those apps, I experienced that quite often because I'm a consultant quite often on the road and even in foreign countries where I do not have data access. So, problems with the internet connection usually lead to some non-functional apps. So, I basically can't use my phone when I'm in some other country, for example. It got better and better with new European-wide data plans and stuff like that, but it still sucks to be in a different country. For example, I was in Switzerland in May, I think, which is not included in the European data plans. And again, my phone was basically a brick because, yeah, no internet connection. It sucks. So, most apps nowadays are still mostly unusable without an internet connection. Even the basic navigation sometimes does not really work. So, what can we do about that? There are some technologies which solve this problem really, really nicely. I will explain how this works in a bit. And if you're using CouchDB on the server and, for example, CouchDB on a client, you can have eventually consistent data storage. So, you can use the application on your phone like it would be online, but it is not. And so, the application will sync back with the server magically at some point in time. So, it will be eventually, it will be consistent again. So, it's a false friend in German. It will be schließlich konsistent, not eventually consistent. So, there's a false friend involved here. So, we will have a definite consistent state at some point in time. This already works and it's a nice thing which is nice to use and stuff like that. I won't talk about this. What I did was writing a PHP wrapper in front of CouchDB, which speaks the same API as CouchDB does to make it possible to synchronize the different kinds of phones which are already using one of those implementations of the CouchDB protocol with the PHP backend. The thing why I did that is, I get back to that in a second, and one thing which you can do with that is actually replacing the CouchDB in the backend and using any technology, any backend stack you have there and you do not need to rely on a CouchDB. So, it's a really nice database. I do not advocate against using CouchDB, but I wanted to be able to replace that for some reasons I will get back in a second. So, this is what the talk is about. And this is actually my use case. I have a front end which I want to be offline capable, offline first. I want to be able to use it in offline state. I want to synchronize it in the same eventual consistent state with some backend application. And this backend application, since I developed mostly in PHP, is of course written in PHP. And since this is PHP track, it makes sense to talk about that here. So, use cases. No. First client implementations and server implementations. The CouchDB replication protocol is already implemented by quite some server clients and even replicators. I will talk about a little more depth about all those. So, for example, there is this client PouchDB, I already mentioned by the logo, which is a full, almost full CouchDB implementation in the browser, which can work with indexed DB and local storage, I think. So, you have a CouchDB virtually in your browser where you can just store data, put data, get data out, run those macro use functions and stuff like that. And this CouchDB in your browser can synchronize back with a real CouchDB and can replicate back and forth with a real CouchDB. Houdy is a different thing where it does not really use the CouchDB replication protocol, but it almost uses that and it makes it really, really simple to develop offline first web applications. There will be a talk later today about Houdy. I have it on a later slide. So, if you want to learn more about that, you should go there. Then there is TouchDB, which implements, they implemented this natively for Android and for iOS. I am not sure about the current state. I think there is only an iOS implementation left, or there is also an implementation of the CouchDB protocol. You can synchronize some iOS application against the CouchDB server. There are some server implementations, of course. There is Apache CouchDB, then there is Cloud and PouchDB server, then there is a small Python server, and then there are a bunch of them like, Apache CouchDB itself can of course also replicate the stuff, and again, Replicpy and some other things too, which might or might not entirely work. So, we already have a bunch of different implementations, so we could use those implementations in the stack already. On the front end, on the back end. So, again, why do I want to do that? One idea could be, you have an existing PHP application, and want to put a front end on this PHP application to write a mobile app with PouchDB, TouchDB or something like that, and make that PHP application offline capable. So, you can replicate the data in your mobile app against, from and back to this PHP application. What we also could do is, replicate a MySQL database into a CouchDB or WiseWriter, replicate from a CouchDB into a MySQL database, and any other database you might be able to connect with PHP. The thing I want to use this for, or why I initially wrote this stuff, is I have a CouchDB backend, and I could just replicate against this CouchDB, but I want to adapt the data, which is in the CouchDB, based on some current circumstances, like some user scope and stuff like that. I want to modify the data and pass it only after that to the client. So, I need some modification stack. This is why I implemented this PHP CouchDB replication endpoint to load data from CouchDB, and then we modified and replicated back to the client, which will use something like CouchDB, or already is using CouchDB. So, this is the idea. We want some offline capable client, HTML5 something, to be able to replicate data from and back from our backend in an eventual consistent state. The interesting thing is, how does it work? At least this is interesting to me. So, I now will get a little bit more in depth in regarding protocols or distributed storages. I'll start with a very, very simple case, and to show how this kind of eventual consistent replication can work. It's very simple if you have a single master's case. So, we have one single source of truth where our data is primarily written, and we have a bunch of clients which just read data and do not write data on this client itself. So, no multi-master setup. Basically, you could consider this a master's slave setup using the common database terms. This is a simple case of eventual consistent replication. We are using this in quite some setups where we distribute data across several nodes. This is really failure resistant. So, if you have a distributed system like microservices, like a service oriented architecture, this kind of protocol is a very simple thing to use to distribute this data. So, what do we do in this case? I introduce that because it's a good base for understanding the couch-tube replication protocol. So, what we are doing here, we have some kind of replicator which has the job to ensure the data is replicated. We have this source of truth which is some kind of database, and we have the client who wants to display the most current data. The replicator starts with asking the client, what is the last revision of data you saw? So, what is the last data you saw? You will return null in case you did not see any data yet or some kind of revision hash. There's something we need to remember about those hashes, but I get back to that in a second. Afterwards, we just add the source of truth or master. Please give me all updates since this kind of revision hash. You can limit this number of updates if you like, but that's basically it. This will return a bunch of updates together with a revision of each update, and then we will pass on those updates to our client. This client will write those updates to the disk, but we need to remember two things to make this work in the same way. First, the revisions on our single source of truth or on our master must increment strictly monophonic to be able to have a defined sorting of those revisions. If you mix up the order of updates, depending on the data we are replicating, bad things can happen, like data loss and stuff like that. If I insert A after B, A must have a higher revision than B, and it must not be the same revision. Otherwise, it will not work in the same way. We implemented this mechanism in distributed systems with some of our customers, and at some point, the developers tend to omit some updates or try to merge updates, try to throw away old updates. This is really, really dangerous. You should be really careful with that. So do not try something like that, or be really, really smart about that. The other thing is, on our client, we must have some, or in the best case, we have some ACID compatible storage with small transactions or something like that, because if an update fails on the client, like, I cannot store this update, you must not write the revision as stored. Only, I should only store a revision, like, I received that update, if I really were able to store this current update. This is also really important. Otherwise, the client will report a later revision as stored, but it did not reach the update yet, so we have data loss. Those are the only two things which you need to remember if you are implementing something like this. If you do this, you already have an eventually consistent system which works in a really, really sane and stable way with network connection losses and stuff like that. CouchDB uses an advanced version of this, because we got the problem that we don't have a single master, but a multi-master setup. So let's take a look at that, but it's still fairly similar. CouchDB now acts as a source, as a target of the replication, and CouchDB also acts as a replicator. As mentioned before, we have different implementations for each of those nodes. So let's talk about that. Again, we start by asking our target database, what is your replication status regarding this concrete source? So it will contain the last update sequence, which is similar to the last revision I mentioned on the slide before. And if I'm replicating between, let's say, ten different nodes in each direction or whatever, each database will store this replication status for each of the other nodes. Then it's the same as before. We get the changes since this last update from our source. There are some interesting things about this CouchDB changes feed, which we are using for this. For example, this changes feed can be requested in a continuous way, like using long poles, for example, to receive all updates after and after and after, which is a really nice thing for a lot of different things, like just writing some backend service which processes all data, which is passed to CouchDB and stuff like that. This is already a really nice thing to use, but it's also used for this replication by the replicator. And now it gets a little bit more complicated. You see there's more space left here than in our single source of truth example. And we receive a revision diff from the target. What can happen here? I mentioned that we have a multi-master replication, and for example, you can have three different nodes which replicate each against each other. The target might already have received some revisions of some documents since the last revision. So the replicator asks, okay, I got this bunch of documents with this bunch of revisions. Which one didn't you see yet? And this is returned by the target. The target now reports, okay, I didn't see this, this, this, but I already got those three. This is what the target now reports. And then the replicator, the rest is fairly simple. Ask the source, please give me all the documents, which the target did not receive yet, and passes on those documents to the target. Which I omitted here in the diagram is that the replication status after the replication has been finished is stored on the source and on the target. This is a simplified version on how Couch2B replication works. And what's not with this is an invention consistent multi-master replication, and I did not mention that yet, over HTTP. So all this implementation we saw here is done via HTTP as a protocol. This is disturbing and a nice thing. It's disturbing because at least my first association is when I heard here a database replicates its data over HTTP, this sounds fairly inefficient. HTTP has a huge overhead and it seems just wrong. On the other hand, HTTP is a protocol which you can tunnel through every corporate network, and which of course our browsers understand. This is why Couch2B, Couch2B can just replicate a Couch2B. Every browser implements HTTP client, obviously. And so Couch2B can just say Couch2B, okay, please replicate, and those are just HTTP calls. The nice thing again about Couch2B using HTTP as a protocol is that we can reuse our full HTTP infrastructure stack, like reverse catching proxies, like load balancers, like SSL proxies, and stuff like that. So this is also a nice thing about Couch2B using HTTP as a protocol, and another nice thing about this is every language or every development environment of course speaks HTTP in some way. There's an HTTP client included everywhere, so every development environment you can easily connect to a Couch2B, and to this replication protocol, of course. So this is a protocol. Are there any questions regarding the protocol or stuff? Yes. What triggers the replication type? The question is what triggers the replication? You, basically. So we'll show a Couch2B replication comment later, and it's just a post to some URL replicate, and the replication will start. There are two types of replication in Couch2B, one-time replication, where just the current state of the database is replicated to another one, and there's continuous replication. You add the flag continuous to, and it will just replicate as long as it works. And when it does not work, it will hold and continue afterwards. So there's continuous replication, which is a common type of replication you would use with other database, but there's also one-time replication. If you implement it in a browser, for example, using Couch2B, you would try to replicate basically every 10 minutes or every 20 seconds, whatever you like, and sometimes it will work, sometimes it will not work. And every time it will work, you are guaranteed to receive a consistent state or to end up in a consistent state with a server again. Other questions? Otherwise, I will know you with implementation details. So you might want to add another question about the protocol, otherwise I will get even into code. Okay? Let's say you ask for it. I wanted to write this at PHP back-end for a Couch2B replication. The question now is, the protocol is not really documented. This is a bad thing about the protocol. It's not really documented yet. There are some documentation evolving regarding that, but not all algorithms are documented and stuff like that. So I could not implement this against some kind of specification. So my only idea was, let's record a real Couch2B replication and replay that against my PHP endpoint. So the tool I used was Man in the Middle Dump, which I can just start and say, okay, build up an HTTP proxy to that server and record everything and dump everything. And then I pointed Man in the Middle Dump to my Couch2B server and told Couch2B, please replicate to this proxy, and it recorded everything. Then I told Couch2B, please replicate from this proxy and it recorded this again. I built up a set of scenarios and recorded all those scenarios. And I had several examples of Couch2B replication implementations. The next step I obviously did was replaying those dumps against my own implementation, against my own PHP endpoint. Since Man in the Middle Dump uses TNET strings to dump those files, anybody heard of those? I didn't hear of those before. It tries to be a binary safe JSON thingy developed by DJB. And of course, there's some PHP library there which parses those things, so I could just read them with symphony responses, a request out of it, and put it into my endpoint. So this was fairly simple. There are some things you need to remember when doing such things. For example, there are a lot of random IDs like the revisions or some dates in the HTTP headers and stuff like that. You must replace those, of course, because the date of replication will not match the date when I replace those things. So I replace some headers, I remove some headers and stuff like that. Afterwards, I just fixed the failures. I made every replay work and win. The nice thing about that is I started with a really, really simple case. I created one document in the source database in one revision and said, replicate that. It's a really trivial case. I got that working and then I added another version. I added a conflict and resolved the conflict and stuff like that to make it more complex and more complex. And while doing that, I, of course, gained quite some understanding of the CouchDB replication protocol and was able to refactor my code I wrote for the first one and refactor it and refactor it in a better state. So I ended up with something which is fairly understandable code which solves all those problems. The thing I want to do and one thing why I did this stuff is to document the CouchDB replication protocol. I want to start, there are some other people who are doing the same with the Python backends who also tried to document all the algorithms which are included here. And I want to contribute to that and document how this replication protocol works. And this is one main thing I want to do with this because the CouchDB replication protocol is now implemented in multiple places. It's a very, very sane thing to do. We have a lot of implementations and thus we should document such a protocol, of course. Here are two links to, I mean the middle dump, for example, to record and replay HTTP traffic which is really nice, which is a fairly nice tool to do that. And I wrote this replaying of a mid-dump recordings and replacing dates and IDs and stuff like that in certain requests and responses. And I expected that into a small library which you can find in this address if you want to use this, for example, for testing your application or stuff like that. Pull requests are welcome as always and this is just a small library to make this replaying of stuff easier to do. Those are, of course, just integration tests. I put in an HTTP request and ensure that the outcome is what CouchDB expects. What I will need to write is, for example, unit tests for some of the more advanced algorithms. I mentioned in the protocol overview that I have to do some revision-diffing and this is a little bit more complex which you will not be able to test entirely using those integration tests by replaying HTTP traffic. So I will need to write unit tests for such things. And those are not written yet because it's all very much in development right now and it's not stable at all. The APIs are not stable but I will write unit tests for the more complex algorithms in there. If you have a question, don't hesitate to raise your hand. I will try to answer every question while I'm in the talk but we can also have like 50 minutes at the end of the talk where you can add other questions and discuss stuff I talked about and things like that. But don't hesitate to just raise your hand. The implementation I did uses Symphony 2 as an HTTP framework. For me it's the most, or not how to phrase that. It's not the worst HTTP framework in the PHP world right now. You might even say it's the best one, even if it has its flaws. So we can use that, I use that as a base because I did not want to write another HTTP framework. So I'm using the HTTP kernel from Symphony to pass the HTTP request and provide me with the correct request objects and create response objects and stuff like that. The actual logic of the replication is all implemented in absolute framework agnostic control. They do not know nothing about Symphony 2. So you can put in any HTTP framework you want in front of the actual replication logic because I do not want to have a couch to be replication endpoint, the logic of it, bound to some concrete PHP framework. So if you want to integrate that in your PHP stack, you should be fine. I did not test that yet, but you should be fine. Then there is some kind of a repository. The class is currently called storage, which has the job of actually storing all the stuff. So you could say it's a repository and the only repository I actively tested is an in-memory repository. As mentioned, I'm replaying in tests all the HTTP requests against one endpoint. And for my tests, the fastest thing to use, of course, is a very simple in-memory implementation. So all data is just stored in PHP arrays. This is, of course, unusable in any real application. For this demo I wrote on Thursday, Thursday, quickly, I hacked a MySQL endpoint. So I will demo that later, so where I can replicate a couch to be, simple couch to be yet, into a MySQL database. It was fairly easy to write, and it took me like one or two hours or something like that. So with that, you can add, in theory, basically any storage or any backend you want. I would not rely yet on the stability of the API of this class because, yeah, this is under development still. And everything I did there can also be found on GitHub, of course. It's KGNC couch db endpoint. Probably you'll find that if you Google for couch db endpoint or stuff like that. And so if you want to check it out, want to play with it, just go there and clone it and try it. So now I'm getting to the live demo part. If there aren't any questions left, if you have any questions about the live demo, don't hesitate to ask again. So let's see. I have a small problem with the beamer. You cannot see the stuff which is on the leftmost side, which is slightly annoying. But yeah, I hope it will still work. So first. Take a window a little bit smaller. Yeah, that's annoying because the presentation window is set to top most display and then, well, everything fucks itself or something like that. So first I start my couch db endpoint. I can quickly show it's a very, very simple script which we got here. No, it's just HD docs in XP. It's very simple, standard symphony stuff. I just create my endpoint and say endpoint run. It does some request browsing and stuff like that. It's really, really, really simple. So let me start that server. And I reset to the MyScale database, which is used to store documents. So we can recreate all this kind of stuff. So the next thing I do is using the couch db administration back end, which is delivered together with couch db to create a new database. Let's call it source. And now we are creating documents in this database. So for example, let's start with document test one. We had a field here. Hello world. Couch db documents are basically about any JSON structure. So I can put in whatever I want here. And so let's save this document. Yeah, I saved this document. So we can see this here. Again, there's a little bit missing there. We can add another document. Let's call it Frostcon. And adding a field year 2014, for example. So we have a very simple document which contains a year of the current Frostcon. So we now have a simple database which contains just two documents. And this database I now want to replicate into my couch db endpoint. Replication in couch db is absolutely trivial. The comment does not look that trivial yet, but I'm going to explain that. So what we have here, except for the missing part on the very left side, is a couch db replication I want to start. So if I just post to the URL, this is the address of my couch db. It runs on the port 5984. I post the document to the underscore replicate URL. And then I just say couch db. OK, the source is my test database. OK, I should change that to source because I called the database a just created source. And the target is my PHP server. And I called the virtual database master. This is everything I need to do to execute a couch db replication. I should pass the content type application JSON there to tell couch db, OK, this is a JSON request, a JSON body we are receiving here. So let me quickly change that to source. And yeah, the output I pipe into JSON pretty to make it look a little bit more beautiful. And now we should see a replication action. The nice thing is it worked. Otherwise, we would see some strange, long backtrace. This is the bad thing about couch db. If you happen to run into an error, you always get ugly, airline backtraces. It does not look nice. And it's hard to understand. What we can see here, or what you can't see here, is the most important thing. Let me try to move that a little bit. I hope we get this Bima stuff working for the other presenters later. So what we see here is OK, true. This is a nice thing. And we can see some details about the replication like docs written to start and end time and stuff like that. So we see the replication worked. And now let's look if this really the case. So I have this database called couch db. And you can again don't see everything. So is that left most? Can I move further to the left? Good. So let's try that. So I open my score. I access the database couch db directly. So I have a few tables in here, space missing there, which is document, document, update, and revision. The interesting table, of course, is a document table where all documents are stored. So just do a select, ask the risk from document. And what we can see here is I hacked this endpoint together. So it's not the most beautiful thing you can do. But we can see here the document ID, test one, Frostgun, those are the IDs I used. The document revision, it's both the first revision of those documents. Couch db by now uses a revision scheme where the first number is an incremental number. So one is for the first revision. And everything after the dash is a sh1 hash of the actual document. And then as a document, I just store a PHP serialized version of the object. So this is probably not what you want to do in the real implementation of a couch db endpoint, but for the demo, it just works. So this is a document. Document updates just store some update information about sequence numbers and stuff like that. And the revision stores, the revision database table stores the revision state status of each replication. So this is a simple case which already works. What I can show now is, for example, next year we might have an update to our Frostgun document, it's here 2015, I save that document and restart the replication, executing the same comment again, just say replicate again, and I hope hopefully it works again, looks like. So I can go into my SQL database, select again everything from our database, and what we see here is a second revision of the same document. Now it's in our database. We again have the ID Frostgun and we have the second revision here. What can also show now couch db has an HTTP interface. So my replication endpoint of course also has an HTTP interface. What I can do now is accessing my endpoint now. I call the virtual database master. And what couch db delivers by default is some kind of statistical information. Let's call it this way about the database. The most important thing is, we see the document count here. Most stuff which is in here is not really relevant for replication. So in my personal implemented endpoint, I just leave it empty like disk size, data size, I just don't care. And it doesn't really make sense for my MySQL database, so I leave everything at zero. The replication does not care about it, so I do not care about it yet. I might add that information later. What we can also do of course is requesting the Frostgun document. What is returned now is of course JSON because couch db returns JSON. My browser just nicely formats this kind of stuff. So what we can see here is the here information we added, the ID, the revision of the document and some additional information. This information, couch db would not return that information because it's only requested with a certain flag. But in my implementation, the only thing I need to do is this flag is always passed by the replicator. So I do not care about this flag yet and just return this information always. So the return from couch db itself for the same document should look fairly similar. So I just change the URL to the couch db port and the couch db database and the return should be similar except it does not send a proper header here, I see. This is why my JSON plugin does not detect this as JSON and just presents us a plain string. But it's the same content from couch db and from my replication endpoint. So this is the simple thing about the demo. What I can also show is replication of the other direction. So what I can do now is creating a new database, let's call it target and leave the database empty for now and now start the replication again to replicate out of my PHP endpoint into this new couch db database. So the source now is localhost 8080 slash master and the target now is my couch db database which runs on the following 8.5.9.8.5 and I call the database target and I replicate into the target database. What we see here is three replicated revisions and if I now go into the target database I should see two documents here in the versions we had here. So replication in both directions works for my couch db endpoint and what I always call was my PHP backend. What does not work yet is replicating attachments and there's some slight problem I have understanding the parent revisions in case of some kind of conflict which I'm supposed to return. I do not match the couch db algorithm entirely there yet. So it might not behave entirely like your couch db in some conflict states of your database. So conflicts might occur for example. I replicate one document like let's say some wiki text. I have it on one node replicated to another node. Those both nodes are offline for a second or for a while and I edit this concrete document on both nodes in a different way. When I start the replication next time of course the replicator will detect some kind of conflict because the document has been updated in different ways on both nodes. The replicator by default does not know how to handle that. Imagine somebody changed some paragraph in a wiki document. A computer, it's not possible for some computer to know how to merge those two paragraph changes. So what couch db does here is it puts both versions of the documents on each node, marks this document as conflict, and selects the exactly same version of this document on every node. So you have a consistent state again on every node. One version of those documents wins on every node. And you have a consistent state. The documents are flagged as conflict. So you can go as a user and look at all documents which are in a conflict state and resolve this conflict manually, programmatically, whatever suits you. With a wiki document for example where a paragraph is changed in two different ways, you probably want to resolve that manually. In a lot of other cases it's easy to resolve those conflicts in a programmatic way. So if you like, I can also jump into the code, but I will leave that to the quarter of an hour of question time that you left as you end or in about five minutes. So let me summarize what we saw here. I showed you, no, I think that offline first, eventually consistent HTML5 mobile apps are the future. Bingo. Sorry for the buzzword bingo, but I really think this is a case. So I do not believe in native apps. I think HTML5 apps are what you want to go. I think is that you should build every time your apps or your mobile websites, maybe even your real websites, with offline capability in mind and maybe even start with that. So I'm really pissed when I'm, for example, in a train, I'm using my app and it just drops with about everything. I cannot even use a navigation anymore or stuff like that because I'm currently offline because the train, I'm on the way to Hamburg, for example, and I'm always offline there in the train. So I'm really, really annoyed by that. I cannot continue to work in the second I'm offline. It's really important, for example, if you're using something like Google Docs, it did not work offline for a while. I think by now it works somehow. But you could, you just had to stop typing because you were offline for a second. This is really, really annoying. So please, if you build mobile apps, keep that in mind. I want to continue working with my app when it's offline. On the other hand, the synchronization of data between the state you modified while you are offline and the state of the server can be really, really complex. Apple introduced like three years ago something, some kind of, Jacob, you might remember the name of the Apple stuff to synchronize with the server, data with the server. Sorry? iCloud. iCloud, yeah, the iCloud stuff. Yeah, exactly. It does not really work because it does not know about this kind of revision of this kind of eventual consistency and you have to handle this entirely yourself if you want to use that. If you go there, writing an HTML5 offline app, use some kind of eventual consistent mechanism. And to make that easy, use the CouchBeam replication protocol. This is, for me, this is a key feature of CouchBeam. And the unique selling point for CouchBeam is this eventual consistent multi-master replication over HTTP. This is the nice thing about CouchBeam. Everything else is just bonus. So you might want to keep that in mind. To make that easier, try Hoody. Hoody is an approach to make it really, really simple to develop such offline apps. It uses CouchBeam in the backend. You do not need to care about that. But just if you want to prototype or write those offline first apps, just use Hoody. There's a talk, it's called, Coding Your Green, oh, there's an end missing there, by Team Hoody at quarter past three in C117. It's up back there. And you might want to listen to that talk if you care about writing offline first mobile apps. And yeah, take a look at that talk. Those custom implementation, like the PHP backend I just showed, I want to use that to add some additional source to the data and replicate out of CouchBeam. So with those implementations, you sort of are a bunch of implementations already available in Python, in JavaScript, and stuff like that. You might use those to do something additional with the data and do some fun things. But it already works with the plain CouchDB and stuff like Hoody or CouchDB. You can already write offline first mobile apps, which will just work as the data will be consistent over multiple mobile phones, over multiple notebooks, over multiple servers, and stuff like that. This is not only important, by the way, for the case where you have mobile phones and servers, but also important for if you have servers distributed across different continents, you cannot have, it's not saying to have transactions across multiple continents because the runtime of the request and response is just too long, it takes too long for same response time on the web. So you will need eventual consistency even there. You might have heard about the base model and stuff like that. So that's it, basically. What we now have time for about 15 minutes or less, if you want to leave earlier, is for questions, for discussions. I can even jump into the code if you care about that. Everything is online, as I mentioned. The slides will be online at some point. You'll find that I will Twitter the slides, and my Twitter nick is on here. You cannot read that, by the way. So I will link them on Twitter. All the links to the repositories are on there, so you can jump into the code yourself and look at it. But I can also show you something if you have questions. So any questions left? Yes? What is the setup for multi-user scenarios? So the question is, what would be the setup for a multi-user case where you have certain data just for certain users? The answer, let me answer with three points. First, CouchDB. In CouchDB, you usually use one database per user. A CouchDB server easily works with 10,000 of databases. So you can use one database for each user. The next question is then, I will have documents which will be synchronized between different users. Like, for example, the Facebook case, I post a message on the wall of another user. What you can use for that is, again, replication, and CouchDB supports filtered replication. So a replication between user database A and user database B, which just replicates the messages which are intended for user B. This just works with a replication filter and will also just work like this. The only thing you need to do is pass, okay, please use this filter. Second answer is Hoody. With Hoody, Hoody uses this aspect of CouchDB. In Hoody, you register first, and every user gets its own database. And then in Hoody, there is some very, very, very simple JavaScript API in the browser where you can, say, share this document, and Hoody will take care of this replication stuff in the backend. So with Hoody, it will just work. I'm not sure about the stability of this plugin yet for Hoody, because at least three months ago, it was still under development. It might already work. So I'm going to ask Olar and Lena later in the Hoody talk about this. But it's going to just work in Hoody. Point three, PHP, my PHP backend. You can basically use anything you want here. For example, you could parse an HTTP auth header with a username and select a database based on that, or add a pencil to the MySQL queries or whatever you want. With PHP backend, yeah, it works just like, it works in your PHP application. You can do whatever you want to. Does it answer the question? OK, so that's the one reason you want to work with this. It makes it easier, yes. Other questions? Yes, please. You used to implement basically the entire CouchDB protocol, right? You just have this one use case in mind. It's specialized for that, but it's the entire protocol. Yeah, the question is, did I implement the entire protocol? Even I just had this one through the use case. Yes, I'm just stupid. And so the point is, and it happens to me again and again and again, I have this open source project in mind I want to do. I did that for a different project I wanted to implement. And then I think, OK, I need that. I should do this in the right way. And then it starts to consume time. And because I needed this CouchDB protocol, I implemented this HTTP proxy replay stuff, which I also did in the right way. And for that, I had to implement something else. So this is project B in the ABCD stack. And I'm back to B right now because I want to complete the CouchDB endpoint. And then I want to continue start working on project A. And yeah, this is time consuming, but I try to do it the right way and try to contribute documentation and stuff like that. But again, this is even more time consuming than, of course. So yes, I implemented, I hopefully implemented most of it yet, but not everything. My endpoint doesn't support long polling, for example, yet, for offset changes feed. But I probably will even add that. Yes. And did you have to reverse engineer that too, or was that documented? The question is, if I had to reverse engineer that, if I had to reverse engineer most of it, there's some documentation. The documentation focus is different than what I needed. The documentation focus right now is on how to implement a replicator and on how to implement a client. And what I did was implementing something serverish, which is slightly different than something client-ish. I say client-ish and serverish because in CouchDB world, everything is a client as a server, as a master all the time. But so the documentation had a different focus. And some of the algorithms like the religion divvying and stuff like that, it's not documented yet. And I had to reverse, or I still have to reverse engineer parts of that. Yes, it's a lot of reverse engineering. The problem is, Elan code is, I think, the most unreadable code ever. I'm really, I'm similar with a bunch of functional languages. But Elan is a different kind of thing. Elan code is ugly as hell. So it's really hard to read, understand those algorithms from reading the CouchDB code, which is, of course, open source. It's an Apache project. But yes. So it's a little bit of soft code reading and stuff like that. Other questions? Three, two, one. Then thank you and see you next time in the PHP room. Thank you.
A CouchDB replication endpoint in PHP This talk shows how I implemented a replication endpoint for the CouchDB replication protocol in PHP. This makes it possible to use about any backend as a synchronization point for Offline-First HTML5 applications powered by tools like PouchDB or TouchDB. You will also be able to replicate a CouchDB database into a MySQL database or vice-versa. The growing amount of endpoints for this protocol in different languages and environments suggests that the CouchDB replication protocol might evolve as a standard for eventual consistent multi-master replication. ······························ Speaker: Kore Nordmann Event: FrOSCon 2014 by the Free and Open Source Software Conference (FrOSCon) e.V.
10.5446/19625 (DOI)
Okay, let's start with the talk about creating a crypto virus for Symphony 2 apps. My name is Rolf Reile, I come from Spain. A little bit of me, I am a software developer at CervoGo, a hosting company specialized in PHP hosting, I am a certified engineer, a Symphony certified developer, and I am now studying a master degree in research and computer technologies, and I am focusing on cryptography and data compression, so I thought that would be interesting to apply those things about cryptography to PHP, and especially with Symphony. This is something we will talk about during the talk, we will see the CDPHP, PAPIs, we will see a little bit about them. Even though you don't know Symphony, I will explain just a little bit, so you can follow the talk. It has functions, cryptography, Symphony kernel events, OpenSSL. First, we define what cryptobiology is. Cryptobiology is a computer science field that studies how to use cryptography to design malicious software. It is closely related to ransomware, you get some kind of information, you destroy something, and you ask for money or for information to get the information back, or to get what you deleted back. And also for private information retrieval, from the point of view of Fahaker, it is always important to retrieve some information, but they want to do it safely. So cryptography can help here. And it was a fundamental piece in cryptography. Before that cryptography was used to protect information, to hide what we don't want to share with the rest of the world. Here, applying cryptography to malicious software was a fundamental twist. We divide the talk into main blocks. There will be a quick demo at the end of the talk. First, we see what is public cryptography, which is very important. We see how and why. And then some Symphony internals. It's also important to know how Symphony works internally, so we can attack in some different ways. Some hiding strategies for our virus, and at the end, protection strategies. How can we protect from these kind of attacks? Okay, so we're going to see how we're going to create our own cryptorvirus, for fun, because only for fun. This is only for educational purposes. And I'm warning, this is not a real virus, it's just a proof of concept. Symphony is... I chose Symphony because it's what I know, but these same concepts could be applied to some framework, to PHP, whatever you want, even to plain PHP. And we assume that the virus is already in the target computer. We don't see how to inject that virus in the computer. I'm not a security expert, so this part probably would be done by a security expert. So, a cryptorvirus. How we are going to create it? So the first step is we're going to have the observer. We have Symphony here, an application written in Symphony, and we already have the virus. Then we have another server, which is the server of the hacker. So once the virus is here and it's executed, it connects automatically to the hacker server and asks for a public key. We'll see in a couple of minutes, public key cryptography. But the idea is that we get the public key. The hacker server generates a key pair with a public key, a private key. So it returns a public key and saves the private key. Then the virus already with the public key inside infects the Symphony's application. It could be done in many ways, but we are going to use Symphony kernel events and the Bustra PHP.Cache file. We'll see also how they work. Then once our code is here, we have access to database connection, user blog files, blogs, whatever. So we can use that public key to encrypt that information. Once that information is encrypted... Sorry. Once that information is encrypted using the public key, there's no way to decrypt it without the private key, which is in the hacker server. So we will need to get that private key. Obviously, paying some money. So once we have the private key, we can get back that information. Hacker can use services like Bitcoin to add an extra level of anonymity. That would be a ransomware attack. And we're going to see also the other kind of attack, the private retrieval information. Using the same code, we have here the infected application. Imagine we have a login and password page in Symphony. This is done in a kind of special way. So if we know that we are attacking a Symphony app, we know how to get that information. So once that information is submitted, we can take it here and save it encrypted in a file. So if anyone, the webmaster knows, sees these kind of files, he won't be able to know what is inside because it will be encrypted. Then we will create a backdoor so the hacker server can connect and get the list of users encrypted and using the private key that will be decrypted. We'll see everything in the demo. Now we're going to see the different parts, important parts to know how the virus works. First, public cryptography. Who knows how public cryptography works? Lots of people. Public key and it's also called asymmetric cryptography. Requires two different keys. A public key so we can share that key with anyone and a private key. We'll use, most of the time, we'll use the public key to encrypt information. There are two ways. We'll use the public key to encrypt information and the private key to decrypt it. Public key cryptography is based on one-way functions which are called also trunders. These mathematical functions are really easy to compute in one way and really difficult in the other way. We'll see an example now. This is important because it is believed to be difficult. What does that mean? It means that there is no way to do it fast. It doesn't mean that anyone or any organization can have already a method to do it fast. Some of these one-way functions would be integral factorization which is used by Erase. We're going to use it. This is the local and elliptic codes. If we have Alice and Bob and Alice want to send an image to Bob, Alice has her own private key and her own public key. I'm also Bob, a different private key and a different public key. Alice says to Bob, I want to send that image. Bob says, okay, I give you my public key. Using that public key, you will be able to encrypt it so only me will be able to decrypt it later. We can see this like a box with a padlock. Bob is sending an open box and an open padlock. Alice input enters that image in the box, closes and closes the padlock. So only Bob will be able to open the padlock with the private key. If anyone in the middle gets that information, they just bar-garb it. So this is the factorization problem. For example, if we have P and Q and we want to calculate N, N is a multiplication of P and Q. So even if we use some big numbers for a computer, it's really easy to do it, really fast. In the other way, if we want to know that multiplication, the result, we have the result and we want to know what two numbers were used for the multiplication, we will need to factorize. And factorize is really complex for a computer and for a human. So it is slow. And slow means that there is no known way to do it in polynomial time. We'll use OpenSSL for the sample, which is a general purpose pictorial library. And because we have an extension, PHP OpenSSL, so we can use it from PHP. We'll know what happened with OpenSSL a few months ago. So how can we use OpenSSL from PHP? Imagine we want to create a key pair, a pair of private and public key. We define an array. That is not important now. We say that this is going to be the length of the key and the type. This is RSA. RSA uses the factorization. With that function, we get a key pair. We get that SAP PHP resource. With other function, we extract that private key and then we extract the public key. It is not complex, but it requires a few steps. But if you use this in a function, you want to use a function and get the pair. This is how they look. If you already configure a patch, for example, with HTTPS support, we already know this kind of piece. And then to encrypt that information, we can use this function, which gets the data to the encrypted, the public key, and a reference parameter. So we will get the encrypted information here. Then to the encrypted, using another function, we pass the encrypted information. This will be the variable when we will get the encrypted information and the private key. For our purpose, always encrypt information with the public key and the encrypted data with the private key. Is everything clear with the public key cryptography? Any questions? Yes. So your virus will use the OpenSSL OpenSSL library, so it adds a dependency maybe to the application. The question is that the virus will use OpenSSL, so it is adding a requirement for the virus to run. Yes, it's a requirement. But we could do it from PHP manually, but it won't be safe at all. But for a virus, it will be a good way. So, Symphony, who have used Symphony before? Who haven't used Symphony before? Symphony is a framework for PHP applications. It's quite complex and quite flexible, so you can use the whole framework or you can use only some components. And inside, in every request, there are dispatch a few events. They are called kernel events. So every time a client sends a request, a new object of the request type is created. And then the kernel.request event is dispatched. There can be one listener or lots of listeners listening to this event, so you can use that information for something. Or you can, for example, send a response to that listener and then the execution. Then, when a response object is created, a kernel.response event is dispatched. So we can also use it for whatever. For example, we could use Google Analytics code in that event. It's not the best idea, but we could use it for that. Okay, once the response is sent to the browser, it emits an important event, which is kernel.terminate. We are going to use that event for encrypted information because we are going to encrypt user-uploaded files. So this may take time if there are too many files. So using that event, the client already has the web page. So we can do it later. This is especially useful for, for example, sending emails or post-processing information. Then, in the normal flow, it is kernel.controller event dispatched. And then, in case we don't return a proper response object in the controller, there is a last opportunity to convert that object, for example, a one string into a proper response object. And always, in case there is an exception, an event is dispatched, so we can transfer that exception into a proper response object with extra information, for example. So we will use this event for encrypted information and this event to get the user and password entered by a client. Okay, I will recap kernel request as soon as the request arrived. Kernel controller, once the controller is resolved, kernel view in case the controller doesn't return a response, kernel response, kernel exception and terminate, as I said, for expensive, poor response jobs. And the other part of symphony that you want to, that you need to know is the bootstrap PHP cached file. This is a file created by symphony, it is created by, it's a composer script, okay, but it is used to improve performance. This is just a huge file with lots of classes and interfaces, it's just a copy paste of those files. Why? Performance, okay, instead of loading those files separately, we already have here and we are going to use them for sure, so it's a good idea to have them there. If you download the standard edition of symphony, you will see these two commands. So when we do a composer install or composer update, these commands will be executed and create that bootstrap file. Yes. So bootstrap.cached file is generated by PHP or by the composer called to? Because you talked about the.cached file. Yes, it is generated here, okay, it's the command is configured in composer, but it is a bundle of symphony, so it is created there. So it was just a question which, if the web server has the right permissions to the.cached file, but if the server is probably configured, it's not necessary, right? You can use, okay, the question is if you can use the bootstrap file or not use it. So the question is, if the web server needs right permissions to this.cached file? Yes, it needs. But if they are using symphony, they are probably there, the right permissions. It's not necessary to use it, there are other ways. So we see the third part, hiding the virus. Usually, antivirus software works in two different ways. The first way is through virus definitions. So virus definitions, they are just patterns, so we can look for those patterns in files, okay? It is fast because it is just to compare a few patterns, but it is only useful for non-malware. If there is a new virus, we will have the virus definitions, so we won't be able to get it. So the other strategy is to use heuristic. Heuristic are also patterns, but you look for suspicious patterns. For example, suspicious TCPIP packets, suspicious kernel events. For example, a virus by definition replicates itself. So this is not common for normal software. So this could be a flag, so that could be a virus. Okay, I have to try this, but this works in PHP. So we can do a link of the file, so the current script will be deleted. So this could be a good way to infect the symphony app, and once infected, remove the file. We need to inject some code into Bustrak file, as I said. We can inject it as a normal PHP code, but we can try to make it difficult for a virtual antivirus to detect it. So for example, if we want to inject that code, PHP info, we can use this technique. There are other techniques. So for example, we encode with base 64 five times. Base 64 is lossless, so once decoded, we'll get the same information. So we encode it five times, and then we generate a PHP code able to decode it. So we'll use eval, which is nice for a virus, for real software. And we'll get the string, base 64 decode, five times. Then code the code, we go from here, and then the five parentheses. Then we can use this app to compress it. This app is also lossless. So then we will be able to generate the original information. So we'll get a compressed code. Then using this, we'll be able to execute the code. We'll see an example also with this later. That is nice, but it's just a couple of tricks. So a better idea is use polymorphic code. Polymorphic code uses a polymorphic engine to take code. So we pass some code, and we get different code, but that's exactly the same. So that makes it really difficult for antivirus software to recognize the code as changes every time. So most of the time, you're forcing to that antivirus software to use emulation to execute that code in a simple environment to see what it's doing. For example, if we have these five lines of code, all these lines print the same. In different ways, they print hello world, but they do it in different ways. For example, the first one is easy. This one also. The fourth one uses the CD out to print it, and the fifth one uses character by character. So all of them print hello world, but using different code. So using this, they're making life more difficult for antivirus. More important in PHP, it generates different upcodes. So if you take a look at the generative of codes, they are all different. So it makes it difficult. The goal for a virus would be to create a polymorphic enzyme able to generate different codes in each infection. As you know, this is also really difficult in a computer because it is impossible to generate real random numbers in a computer. If you use run or empty run to do cryptography, don't do it. You can see that there are patterns. Even in empty run, there are also patterns. It is better, but not good enough for cryptography. So it is always recommended to use physical methods for that. For example, random dot org uses atmospheric noise to generate random numbers. We also as humans are not good to generate random numbers. So we're going to do a quick test. During five seconds, we're going to think about one number between one and ten. Start. This is real time. Most of you probably have think of the number seven. Because when a brain tries to generate a good random number, it says one and ten out because it is the first and the last. Second is to come on. And then it looks for five in the middle out. And seven is what we consider the weirdest one. Because it's another number, it's prime number. But an ideal number generator is the frequency that should run. And the last part is about protecting us. So before the infection, we do what we have to do. The user security measures, restricted permissions, as you said, disabled PHP OpenSSL is not going to use it. And something that we can also do is virus and inoculation. So we have a virus always have a method to see if a given file is already infected or not. So if we know how to check how the virus checks if the file is infected, we can inject that information. For example, in a PHP comment or using the hard compiler function and inject that information there. So if we know the virus and we want to avoid that attack, it can be a good strategy, but only for a given virus. And once the app has been infected, we want to check the integrity to know if it's infected or not. So one way to check the integrity of some code or some information is using hash functions. Hash functions, we are used to use it in every day. We use SHA-1, for example, MD5 sometimes. And basically they create fixed-length digest, text-sum, from data or arbitrary length. They must be easy to compute and there must be really, really, really difficult to generate a message with a hash that we want. Really difficult to modify a message without modifying the hash. Really difficult to find two different messages with the same hash. This happens because the number of hash numbers is limited, but it must be really difficult. And the basic idea is this, tiny changes in the source generate big changes in the address. So for example, if we are hashing one gigabyte of information and we change just one bit, if the hash function is good enough, it should generate a new hash number with at least 50% of information change. If you like the hash theory, it's like this, like the butterfly effect. In initial conditions, little changes in initial conditions lead to big changes at the end. So the theory says that the flapping of the wings of a butterfly could cause a trishter in the other part of the world in many years. Like when you go to the past and they say, don't touch anything. The same idea. Why we don't use MD5 anymore? Because it's not collision resistant. The idea is in the build process, when we deploy the project, we can create a hash of the whole project and then check it regularly. For example, using the final component of symphony, we can get all PHP files, for example, and then create a hash of the whole project. So using that number, we can check it in production from time to time and check if anything changes or not. It could be a nice way, but we already have this in PHP, using the path extension. Anyone have used FAL before? Used. No composer? The basic idea is you encapsulate all the projects, even its dependencies, in a single file, in a FAL file. It's equivalent to JavaJal files. The nice thing for this talk is that FAL files can contain a signature, a text of the included files. So we are sorry. Okay, so it can contain a signature of the included files. So we can have what we did before manually, and we can have it automatically. FAL files are divided into four blocks. At first, there's a stack that usually contains some loaded functionality. Basically, some code to be able to map between the included files and that PHP code. It always ends with this function, hard compiler. Who knows what that function does? Two, three, four. That is a real PHP function, and what it says is to the PHP interpreter to stop. Anything that I put after that is not interpreted by PHP. So we can use it, for example, for install script, for example. Then we have a manifest. This is no longer a PHP valid code because we use this function. The manifest basically has the name of the included file names, some checking, the timestamp, size, some binary flags. Then the actual contents will have PHP code, our dependencies. And at the end, a signature. So we can have a signature in MD5, SHA1, 2M56, and 512. So I created a... This is only a missing line. I created a really simple file. So you can see here, we open PHP, we execute map path, so we can map between... We can access the included files and echo hello world. And then hard compiler. This is the stack. Then there's the manifest, which is all of this. This is basically some flags. This is also a manifest. This is the file I included. I included a file called 1.txt. Then the file contents. So the file has some random text inside. And then the signature. This is a SHA1 signature. The signature flag, which indicates the kind of signature we use. And a magic number indicating that there is a signature. So what happens if we are really smart and say, well, we're going to change hello world by hello there. So our virus, for example, would do something like that, change code. If we try to execute that file, we'll get an error. An error that has a broken signature. So automatically PHP is checking that for us. I hope what happens if we are even more smart and we change that little bit that says if there is a signature or not. If we try to execute it again, we can do it. It doesn't have a signature. Is it mandatory for file file to have a signature? No, it is not. But by default, in the PHP.ini file, we have this line. So file files are required to have a signature. So packaging a whole up into a file file could be a good idea to avoid these kind of attacks. And then, yes? If the attacker can write a file file, he also can reach out to lay out the signature and write it too. Yes, that could be even more, more, more smart. I tried to do it. I couldn't. But I need to spend more time on this. So let's see in action. Is there any question? I don't know. I downloaded a symphony project. There are a few demos. And I am using that demo. You have a simple page like this and a simple login for here. Can you see it? At the end? Yes? Okay. Okay. This is the Bustrak file. As you see, it's a huge file containing a copy paste of common symphony classes and interfaces. It uses the special way of using name spaces. And several name spaces in the same file. I'm using this notation. And what we're going to do is inject some code here. So as I said, there is a server, the Hacker server, which will provide the public key. So this is the script. As we do it before, this is the only thing that changes. It generates a shared one of the public key. This is only to have a kind of ID. So if that person pays the money, we can from that key get the private key. We will save the private key here. And try to put contents in. And the response would be an array with the username code containing the ID and the public key. So we are serving the public key and storing the private key. In case it pays, we return the private key. Okay. The symphony project has a known structure. We could use any other framework, but as we know already symphony. And we know that the upload file is here. So we have a Txt file containing Hello World and an image. Imagine that this were uploaded by final users. So we are going to encrypt it. And in case they don't have a backup, they lose that information if they don't pay that. And this is the code of the virus. Okay. No clean code here. Basically, this will be a super polymorphic engine. We are going to create a class because our virus is subject oriented. We are going to create a different class every time. So the name of the class would be V1, V1000, V5000. And we generate the code. Basically, we have an encrypt function. We have a decrypt function. Handle action, which depending on the request, will do anything. Okay. And now the important part will be here. We are getting the contents of the Bustra file. Once we get the contents, we want to inject some code to be in the middle of the file. And we are going to be in the middle of the symphony request. So what we are going to do is to look for this code. This is the code of the event dispatcher. And what we will do is to maintain that code, but in front of this code, inject a call to our virus. A call to the process method of our virus. Which is static. And we will pass the event. So then, depending on the event, for example, the request event, we will do the struct user and password in the response. Just for testing, we will modify the response, adding an extra header containing the symphony, the traffic path. And the kernel terminate will do the encryption. We will read the upload the file folder and encrypt all files. Okay. Let's see in action. This one is commented, so I don't want to lose the virus. Okay. So if we execute the virus, automatically connects to the hardware server, gets the public key. The public key is then injected inside the virus. So if we open the booster file again, we have this code now. This code is only one big line, so it's more difficult to detect. This code is doing all of this. This code contains this class. Class we were generating. And we also changed some function codes. Okay. We look for. We look for this. Okay. For example, here the kernel terminate event, the code, the normal code is here, but now it is injected this code. It's calling. It's calling to the virus, the process method with the type of event and event itself. So if it does it in every request because kernel terminate is executed in every request. So it will refresh this page. Okay. If we see the headers. Here is the extra header we have. And if we see the files, now that they are encrypted now. So if we find this and it's a project, we have a problem. I added this list tree at the beginning, so the file is not encrypted twice. And then to, in case we pay. We can execute. We see now. So what we are doing now is sending the private key to the private. Okay. It is encrypted now. And it is encrypted. We are using the backdoor to do this. So how the backdoor does works. If you see the code, the code is available online so you can take a look later. Here in every request, it gets some action. So in case the action is for that information. So it does the same, but in this case, we have to. Okay. And the last part, that would be the private information retrieval. We have this, a simple login and password. So we say user Frostcon, password 123465. It is not valid, but could be valid. And we can see. In the catch a file and there's a new folder called users. I am saving them there. And there's a file. Okay. We open the file. It's encrypted. So if anyone finds out this file, well, it could be deleted, but they have no way to accuse us for something. Okay. Because they don't know what it is. They know that they are probably using it because I named that way the folder, but I could use any name. Okay. We say Frostcon 2123. Okay. We have two different files. And using the backdoor, we can get the users. It is downloaded the list of users and using the private key to be encrypted. Okay. They are there. Frostcon 2123 and Frostcon 123465. Okay. And that's all. There's the code of the virus. You can take a look and play with it. And simple request to make it even more stronger. Okay. Thank you. Okay. Thank you. Okay. Okay. Yes. That's a way that you need that the client machine allows you to do that. It's a new thing and an extra dependency. And that machine must have appropriate server-random number generator. But yes. Yes. Yes. It's nice to think from the dark side sometimes. You learn a lot. Any other questions? Thank you. Thank you.
$kernel→infect(): Creating a cryptovirus for Symfony2 apps Cryptovirology studies how to use cryptography to design malicious software, given that public-key cryptography can be used to break the symmetry between what an antivirus analyst sees regarding a virus and what the virus writer sees. In this workshop we will create a simple cryptovirus in PHP - for educational purposes - able to infect a Symfony2 app and encrypt data such as database records or user uploaded files using public key cryptography with OpenSSL. To create the virus we will study how Symfony works internally, especially what kernel events are dispatched and how to use them to attach our virus. Several strategies to hide the virus will be discussed. Simple ones like using different encodings and more advanced strategies such as polymorphic code. Finally, we will see how we can defend ourselves from this kind of attacks. ······························ Speaker: Raul Fraile Event: FrOSCon 2014 by the Free and Open Source Software Conference (FrOSCon) e.V.
10.5446/19623 (DOI)
All right, it is quarter past three, so I'm going to start. Welcome. My name is Walter Heck, and I'm here to present today a session that was originally titled 600,000 queries per second on a MySQL Galeric cluster. But as I was preparing the slides this week, I realized that we are past a million queries per second, so I hacked my own presentation title. So in the next hour, I'll be telling you a bunch of stuff about a case study, a client of ours that we've built a Galeric cluster for. We'll look into how all of that is done. First of all, who am I? My name is Walter Heck. I'm a software engineer originally. I was once a Delphi programmer, but obviously that language died, so it was time to move on to something else. And my next challenge was MySQL. And then the system administration, and then I started running all the data, so I'm doing less technical stuff now and a little bit of MySQL still. So I'm the CTO and founder of all the data. We are an open source training and consulting company. We are a puppet labs partner for all of Asia and part of Europe. We do a bunch of other training, Node.js, some open stack. We do some MySQL consulting. So I'm standing here. And a whole bunch of other stuff. What we'll be talking about today, this is more or less the overview. So the MySQL cluster, the Galera cluster is run configured with Puppet. So we'll talk a little bit about what we do with Puppet. It's not so much the topic of focus here. So we'll just take a quick look at it. Galera cluster, for those of you who are not familiar with it, does anybody who here is running Galera cluster? It's getting more over the years slowly. Some terminology. We'll look at some statistics of what we're running and what kind of hardware we have and all of that. The HAProxy setup that's sitting in front of Galera. We'll look at stuff like monitoring. How do we do operations? Some backups. And obviously we'll end with what the next challenges are. Because in a growing infrastructure, challenges never really stop. So a million was fun. But now it needs to scale to 10x that in the next couple of years. So we have some more challenges coming our way. So first off, a little bit about Puppet. Who here is familiar with Puppet? So Puppet is a configuration management software, open source configuration management software. It's actually commercially supported open source. So you can choose, just like with MySQL, you can choose the open source version or you can choose the enterprise supported version. It's configuration management software. So what you do is, let's say I'll explain it to you as I explain it to my 73-year-old mother, and I should get everybody on the same line. In the old days, you would have 10 laptops. You would log into every laptop and install Microsoft Office on each one of them. And that would be horrible. With software like Puppet, there are many others like it, Salt, Chef, Ansible, you name it. With that kind of software, you take one of those laptops and you say, hey, if one of the other nine laptops comes in and asks what it needs to be running, tell it to go and install Microsoft Office. Now I only have to work on one laptop and all the other nine are managing themselves. Puppet is the same story. Only we're talking about servers and larger than 10 nodes. Puppet happens to scale quite nicely. I've run it on two servers the very first time we were using it just to play with it. But CERN in Switzerland are running it on somewhere between 200 and 400,000 nodes. So it scales quite well. Obviously, 200,000 is not going to be out of the box. You'll need to pull some stunts to get that working. But infrastructures of 10,000, 15,000 are not really an exception for Puppet infrastructures. One of the nice things is that Puppet is very multi-platform. I heard the founder of Puppet Labs once called it the Switzerland of IT. They want to try and not be specific to an operating system. So it runs on Windows. Many Unix flavors, MacOS, BSD, all of these things. Some of the newer network devices also run Puppet Agents, which makes it nice and very usable for infrastructures that are running every operating system under the sun. With Puppet, you write infrastructure as code. So you get all the benefits of having your whole infrastructure written down in code, which means that you get a whole bunch of benefits. I won't go too deep into that right now. This is a typical Puppet architecture. You assign one or more machines in your network to be a Puppet master. That is a machine that runs a demon called the Puppet master. There is a Git repository that has all your Puppet code in it. It doesn't have to be Git, by the way. It doesn't even have to be inversion control if you really don't want to. I couldn't imagine why, but most people are running with Git at the moment. So you have a Git repository that contains all your Puppet code that is checked out onto the Puppet master and all the servers in your network. Can you guys see the red dot? Is that clear? So all the servers in your network, I just created three random ones. Don't try to hack them. They don't actually exist, I think, I hope. So all the servers in your network are running a small little program called the Puppet agent, which you can also run as a demon or many people run it as a crown job that wakes up every 30 minutes and the agent connects to the Puppet master and says to the Puppet master, hey, I am web01.allendata.com. Tell me what my configuration needs to look like. The Puppet master looks into the Puppet code to see, OK, this is the configuration. It needs to be running my SQL and it's have this config file and it's have these users and these directory is created, compiles all of that in an adjacent file called the manifest and sends that right back to the Puppet agent that's still waiting here on that machine. The Puppet agent receives that configuration and compares it to the server itself and any differences are changed or at least attempted to be changed so that the server after the Puppet agent run looks exactly like the Puppet master told it to. That's in a nutshell how Puppet works. Galera cluster. So it's created by a company called Codership that has renamed itself to Galera cluster if I'm not mistaken because nobody knew Codership and everybody knew Galera cluster so then they decided to rename themselves which I think is probably a good move. Puppet Labs was also not called Puppet Labs before but then everybody knew Puppet and nobody knew Reductive Labs so they decided to change their name also. So Galera cluster is basically a library that is compiled on top of MySQL. It's also commercially supported open source. You can use the open source version or you can pay them for some excellent support if you want. It's also multi-platform. Distributions available so both Procona and MoriDB compile offer a version of their MySQL distribution that has Galera compiled into it so you don't have to get into that yourself. Just install it from their package repositories which makes life a lot easier. It provides a high availability in a way that is quite strange for people who are used to traditional MySQL replication. So traditional MySQL replication is asynchronous where you send a query to the master and the master executes it, writes it to a log, the slave downloads it and executes it as well. Whereas with Galera when you send a query to one of the nodes it won't return until all of the nodes have at least committed that they can execute the query. They don't all actually execute the query but they at least say, hey, I can do this. If they all do that then it comes back. It means that your failover situation will be very different with the traditional replication. If a slave failed, okay, then not the end of the world but if your master failed you had to make another slave the master and then have all the other slaves connect to the new master, figure out which position to be at was not really a fun exercise to be honest. With Galera in this case we have five nodes in a cluster, six nodes actually at the moment but it should be five. And if one drops out the other four just keep working and no big problem usually. I'll tell you some horror stories of things I've watched that were not really a lot of fun over the time. Split brain is the situation in which there is a network split and both sides cannot really figure out if they are the biggest part of the cluster. So Galera uses something called a quorum which means that if one or more nodes fall off of the cluster, if the remaining nodes are in a piece of the cluster that is more than half the cluster they'll keep working and otherwise they'll shut themselves down because they might be a smaller piece of the cluster. So split brain happens when you have for instance four nodes in a cluster and it gets split in the middle then both of them have no idea if they are the majority. So the recommendation is to always have an uneven number of nodes in a cluster. We are failing to commit to that idea with our cluster. We have six nodes in the cluster but realistically with six the chances that such a thing happens is so small that we haven't seen it so far. All the nodes are on the same physical network in the same data center so there is less of a chance than when there was going to be a replication over WAN. From IST, SST, so the way Galera works is that if a new node joins the cluster whether that node was previously down or not, Galera says hey, a new node. Do you already have data? Yes. What was the last transaction that you committed into your node? If that falls within a certain cache then I can send you an incremental state transfer only the differences that you missed out on. Great. In reality it doesn't happen so much. You can increase that buffer to a larger amount but it's not really in such a high-performance cluster it rarely happens that an IST happens, incremental state transfer. The other option is a SST which is called a state snapshot transfer. Is that correct? Does anybody know? I think that's what it is. Anyway, SST, you will become very familiar with the word SST and you will probably start hating it after a while as well and SST is a wipe all data from the server and copy it all from another node in the cluster which means that that other node, so you ask the cluster like hey, I need a copy of the data and the cluster says okay, this node will be the donor. It sets that node to a state that is the donor state and that node will start copying the data over the network to the other, to the node that is receiving. With a 300 gig database that becomes annoying at best. Oh, sorry, that was my caffeine, one of the best tools I want to make. So yeah, that becomes annoying at best. In the very beginning we were on 100 megabit network, that was really ridiculous. You would spend half a day waiting for a state transfer. Then we were on gigabit network that makes it 40 minutes to an hour, something like that, depending on the day of the week. Now there's a new cluster and that will be on 10 gigabit network and that should make it a lot nicer except that then other hardware becomes the bottleneck. So we're still in the works of figuring that out. How many times a week a day? Yeah, more often than you would like to. I would say a couple of times a month, it depends a bit. Sometimes it's like any operation, sometimes it's stable for forever and then all of a sudden it starts happening all over the place. What happens generally is that when something happens to this cluster, it doesn't just happen to one node. It happens to one node and then another falls over. With this kind of high performance clusters, it's really difficult to have proper failover. I don't think that the cluster has gone completely down more than a couple of times, but it has happened indeed simply because this Galera is very trigger happy. I'll get to that in a minute, but you'll see some of the downsides of the... It's coming in here, but don't add the issue more on that. It's going to have to be changed. The problem is that if you have, for instance, six nodes and one node goes down, then another node has to come down to donate to that node that is recovering, which means you have two nodes going down. If that happens to happen in a high peak traffic situation, all of a sudden you only have 60% of your capacity left and then it's very easy for more misery to happen. Galera is... I made two categories. I made a category called features and here I have a category called features. On the plus side, we have the features. Galera is a true multi-master, so you can read and write to any node at any time. In reality, it's not entirely true if you have hotspots in your data. Then rows that get written to really, really frequently, then writing to multiple nodes for those same rows at the same time is not going to be a pleasant experience because you'll get conflicts and that is translated into a deadlock. To cover that, most people either write everything to a single node or write specific parts of the application to a single node. You could write everything it has to do with users to one node and everything it has to do with logs to another node and everything it has to do with messages to yet another node. That kind of stuff makes that a little bit easier. Synchronous replication, which means that there is no slave lag, which for those of you who have run MySQL traditional replication, it's probably a yay. I don't miss that at all, actually. Lost data when a node crashes also doesn't happen. With a traditional replication, we would have these whole situations where a slave went down or a master went down and then the application started writing to another master, but it didn't really figure it out that it was another master. All kinds of mess would happen regularly. That's all gone. All the nodes are always the same, mostly. There are ways to mess that up as well, which I'll get to in a minute. Multi-threaded slave. So, Galera has this multi-threaded apply thing where you can have, we run 16 threads at the same time. I'll show you in a bit. Before this, we were running master slave with MMM, very old, not very old. I was here in 2009 preaching the MMM stories, so I'm curious to see what I'll be preaching in five years from now. But in MMM, you had this whole master slave failover and you had a virtual IP that you were writing to and that virtual IP should be moved to the new master, but it didn't always work that way. ARP caches that would get stuck, all of these things. It wasn't very pretty. You can have hot stand-bys because there is no real downtime during failover because there isn't failover in the first place. Just a node stops working, period. Automatic node provisioning. This is something that I've also put on the features list because it's also super annoying, but at the same time, with traditional replication of a slave really messed up, you had to copy the data from another slave and do the same thing manually that you should be able to do automatically. Galera does this for you, so you don't have to worry about copying the data over from a slave. It supports NADB. I put that also on the features list because it only supports NADB. There is some option to also replicate my some, but there is no guarantees about any stability or that kind of stuff, so just don't do that. One of the fun things is that it's transparent to applications. Before you had to figure out which node to read to and which node to write to, and that really is gone. You can write to any node. So no read and write splitting is technically needed. We came from a situation where we had that because we were on this whole master slave replication already, so then we decided to sort of stick with that. Galera features, it's sort of trigger happy. We've had situations where four nodes went down. We had a situation, so originally the class server was running. It's been upgraded from all the way from stock MySQL 5.0 to Maria AB 5.2 and 5.3 and 5.5 and then to Percona server 5.6, I believe, and then to Galera. Turns out there is some bug with the storage of date times that changed from 5.5 to 5.6 or something. Anyway, we had two nodes that were never an old MySQL version. They were always, they just came into the cluster as PXC nodes, and the other four came from this old move, move, move data set. So they had actually this problem, which was kind of a hidden problem. Until one day we hit a bug. All those four old nodes went down like nothing. One of the two that was left over went to donate to one of the other four. The other node went down because all of the traffic of the whole application was rammed onto a single server, which wasn't really anything suitable. So five of the six nodes were vanished in like, it was a bit more than a minute, but watching that happen is just like, but that one is also, and that would, what, what, not cool. So what Galera does is when a node comes back up and decides it needs to do a full state transfer and an SST, it will wipe everything from the data directory completely without asking you, hey, should I just wipe everything? Which is freaking scary. I would like there to be an option that says, before you wipe all my data from the server, just I don't know, stop and ask me or just stop and let me set a specific flag that says, okay, it's cool that you wipe everything from this server because it's scary. You lose all the data that's on there. It doesn't actually do an RM-RF, but it's essentially what it does. Galera is pretty hard to set up. There are lots and lots of options and they need to match exactly and there are lots of moving parts. To do an SST, it uses the, there's many methods, but the most useful one in most cases is extra backup, which is a Percona backup tool that does some smart stuff. But in order to have the state transfer happen correctly, you need to both have all the disk, the directory permissions have to be exactly accurate, both on the donating node as well as on the receiving node, but you never know which node is going to be your donor because it can be any node in the cluster that's up to the cluster to decide. You have to have the permission set correctly for the extra backup tool to run in the first place. All of this seems pretty trivial, but before you have the whole set of options figured out nicely, it usually takes a while. So we did this with the puppet module, which helped a lot. You can find it on github.com slash all in data. The Galera puppet module is there. That's the one that we used. Some operations are not supported. I don't know them from the top of my head and I neglected to look them up, but there are a few things that you shouldn't do on a Galera cluster that you can do somewhere else. And the last feature that I wrote down is NADB only. Technically, NADB is the only supported storage engine. We had last week or the week before that some developer create a table that was my ISAM. And it happened, he happened to create it on one of the nodes that was also the only one reading it back. But if you do that and you don't have the my ISAM support enabled, then it'll just create a my ISAM table on that one server and not on any of the other servers. And it just sits there and nobody will notice and nothing will log or say, hey, by the way, you have a table that is nowhere else and now you have technically a inconsistent cluster. So after God knows how many days, one of our guys was comparing just a routine check after we had some kind of incident. And he's like, we have this one table that exists on only this node and not on any other node and then it turned out to be a my ISAM table. So be careful with that. Right. Yeah. So we just turned off the whole my ISAM support and it just started to work. Right, yeah, so we just turned off the whole my ISAM support and I don't think you should be using it, but unfortunately with my SQL it's only in the create table, anyone can set the storage engine and it's not going to fail, it's just not going to replicate. So I would like that if somebody executed a statement that says create a table with the my ISAM table engine, a storage engine, fail, tell me that it's not allowed because I don't have any support for that. That would be much nicer. I think one of the things that I'm missing here is, oh, sorry, no, it's here. Logs are super hard to read. The Galera logs, a whole bunch of stuff that is all completely irrelevant to you and when it does log errors or problems, it logs it in such a way that you have to be able to read Egyptian upside down in order to be able to figure out what it does or what it means. And especially when things go wrong with these SSTs or the ISTs, it logs part of it on the one node that is donating and part of it on the node that is receiving the donation. But then if something goes wrong on the extra backup site, it's actually in the extra backup log file that is secretly hidden away in your data directory. So it's a fun adventure to figure out what gets logged where. So all of that was the introduction. Let me see. How far are we? Ah, halfway through. That's perfect. So now a little bit about this specific case. We have a client that runs a holiday property booking application where people who own a cottage can or multiple cottages can manage the bookings that come in for those cottages. They have integrations with things like booking.com and a whole bunch of other websites. So there is, especially when booking.com synchronization happens, the whole availability of these cottages needs to be updated and calculated and sent to booking.com and they're pretty trigger happy as well with their API. So that's pretty heavy. Complicated queries with the checking the availability of a property. So somebody says, I want to rent this property from August 20th to 27th and then you have to figure out if it's available and what the price is for that week and all that kind of stuff. So there's pretty complicated queries there. It's a single MySQL database. Actually it's 300 gigs by now, 500 plus tables. I think it's 600 by now. It keeps growing. They develop quite fast. The app servers are not under our control. So the client develops the application themselves and they run ASP Classic, which is fun because it doesn't support things like memcached. So they use the database for caching because that didn't exist back then. ASP Classic is still supported until 2023 or something like that. So we were ridiculous. Yeah, it's really, yeah. I keep being surprised every time I look it up. Did I look that up correctly or did I just dream that it gets supported that long? Oh, no. They're really standing behind it. As a special, they use a lot of stored functions to calculate things on the database servers instead of on the web servers, specifically those availability queries. They do some nice tricks to make that all work a bit faster. What does it look like? The database side of the whole story. It's fairly simple. We have a Galera node that takes mostly writes and some reads and then the other five Galera nodes. As I said before, you can write to any node with Galera, but what we came from was this traditional MySQL replication setup where we already had a split between read and write traffic. It just turned out to be the easiest to keep it that way. So what we did is we have an HAProxy instance in front of the Galera nodes. It happens to be running on what we designated as the primary writer. And that HAProxy listens on two different ports. And the application sends all of its writes traffic to 13306 and all of its read traffic to 13307. And the HAProxy instance pipes all of the traffic that comes in on this port straight to the primary writer unless that one is down. And all the read traffic goes straight to the other five nodes. We have a passive HAProxy sitting here as well in case this one, in case this whole machine fails because these two things run on the same physical machine. It's all physical machines, by the way. The reason they run on the same physical machine is to eliminate the network hop between the HAProxy and the primary writer. It just saves performance. So there is a passive HAProxy. We have never needed it, but it's there in case this machine goes down for whatever reason. We have had Galera go down, but we haven't had the machine go down. So HAProxy has also never gone down. It's super stable, and it's really impressed by what it can do. Very high throughput, no problems. Pretty happy. The whole thing is managed by an open source puppet master 3.7.5 and RTR10K, which is a fun deployment tool for puppet, and MCO means M Collective, which is a orchestration tool that comes with puppet. I'll keep those two to the side. It's not really the focus for today. So this is mostly the simple setup. What do we have for hardware? All six servers are exactly the same. It runs DB in 7.8 at the moment. We have some fairly average CPUs. Nothing too intense. 64 gigs of memory. This was taken at a low traffic time, somewhere last night, actually. So the load is not too high, and it's running quite nicely. The Galera-related configuration. So when you have a Galera MySQL with Galera built in, you get a bunch of new system variables. So we have the SST method set to extra backup V2, which is kind of the most used SST method. You can do things like R-sync and MySQL dump as well, but the MySQL dump style SST is blocking, so it means that your donor cannot do anything until it's done MySQL dumping, and then has to catch up. The slave threads, we have set it to 16. So there are 16 threads applying queries from the other nodes at all times. Gcash is the Galera cache. I mentioned that if a node comes back up after it has been down, it will do an incremental state transfer if the amount of writes that it's had, sorry, if the amount of writes that the rest of the cluster has had is less than its cache. We've set that cache to one gig at the moment. Then a bunch of the MySQL options that we've set. Binlog format has to be rolled for Galera. Query cache is not supported, so that is turned off as well. The provider options, this is where you set that Gcash. So we set that to one gig. We have the slave threads set to 16. I've already mentioned that. Auto increment control. So if you set this to one, then the auto increment, increment, and the auto increment offset settings will be managed by Galera itself, so you don't have to worry about it. This has to do with making sure that primary keys are far enough apart, so you don't have to worry about collisions in primary key assignments if you have auto primary keys set up. We have a Galera notify script. Not super happy about this, so Galera can, whenever something happens to the cluster, a change happens to the cluster, it can run this script, and automatically you can notify by whatever you want to notify, but there is about six or seven potential options that it can pass, and in most of the cases it passes only one of those options, so you don't really have much information. So it's mildly useful. I'll show you in a minute what we're using it for. SSD method is set to extra backup V2, as already mentioned that. The SSD authentication, so depending on what SSD method you are using, this requires some other values, but this is not our actual password, just in case. But anyway, that's how you mention the user and then the password of that user, and this is the username and password that are used by the SSD when extra backup needs to make its backup of the donating node so that it can send that off to the receiving node. Then some SSD specific options. We set the stream format to XB stream. You can read over here why you should use that one and not the other ones. And then some fun ones. We set progress to one, especially with a large database. It's good to be able to see how far along you are in your SSD. It logs a bit weirdly. So we've set it just to one, so it writes to the MySQL standard error, so you have to be tailing the MySQL error log, the tail-f, the MySQL error log, because otherwise it logs in a very strange way. But if you tail-f it, you can nicely see the SSD coming along. So that's quite useful. And time equals one. I don't know what it does if you don't have time equals one set. But anyway, we have it. I know. That sounds like I should probably look up what it does exactly, but I managed to not do that. I finished my slides 10 minutes before the presentation, so bear with me. I broke my finger last week, so that kind of destroyed a whole bunch of plans that I had. So I have a couple backslash s from one of the nodes. So as you can see, I had to figure out, but this says 2 trillion if I'm not mistaking. Please correct me if I'm wrong, but I think this says 2 trillion. So on 2 trillion queries, 80,000 of them were slow, which normally 80,000 is a reasonably high number, but on 2 trillion I'm prepared to let that slide. And queries per second on average, so that this is not the throughput at this moment. This is this number divided by 140 days, 19 hours, 30 minutes, and 22 seconds. So this is more like sustained throughput or the average throughput. 185,000. So if you multiply that by 6, you get to over a million. I noticed that yesterday when I was making these specific slides, I was actually quite happy that we made it through a million because I was wondering when that would happen. But yeah, that's what we have there. We're using the Percona X4DB cluster. We were using MaraidDB in the beginning, and then there was at some point a bug that was not solved in MaraidDB, and it was solved in Percona cluster. It had to do with the sort functions that they're using, so we had to switch to Percona. Really we haven't really noticed much difference, to be honest. The size of the data, it's 240,000 megabytes. On disk, we still have some NADB stuff there. So on disk, the whole data directory is about 300 gigs in total. But the database is 240,000. I changed the name of the database here, so also that is not the real name. Then so much for the hardware and mySQL. On the HAProxy side, I'm really impressed by stability and throughput. It pushes about 10 terabytes of mySQL traffic through its interfaces every month. I'll show you in a minute. We have one writer front end and one reader front end. The writer sends all of its node to the same back end with the other five nodes as the backups. So if the primary goes down, it sends it to the next one, and then to the next one, and the next one, et cetera, et cetera. And the reader front end just round robins through all machines and doesn't really care. No, no, just a simple app get install HAProxy. It's fairly straightforward. Then we run HAProxy. In order to run, HAProxy has two modes, TCPIP mode and HTTP mode. In order to run this easily, we run it in HTTP mode, which sounds a bit strange considering we're talking about mySQL traffic. But what we're doing is that the health of each node is checked by a simple Xenad script that just checks a bunch of different conditions. If they're all good, then it reports a fake HTTP status code, and if it's not OK, then it reports a 500 or something like that, or a five with three. And then HAProxy takes that node out of the replication. It's a bit hacky. You don't really have much control over status reporting inside the HAProxy front end. But it works, and it works really, really well. So, we'll talk about backups later as well, but one of the nodes backups every four hours, backs up every four hours. So every time it does that, it reports unhealthy to the HAProxy instance, and it just gets taken out of the load balancing easily. We don't have to worry about it. We have a failover standby HAProxy instance on one of the other machines so that if one goes down, the other one will take over. As I said, we've never needed it. Hey, that's strange. Why does this slide say, go on a live London? I copied it from another presentation. I'm guilty. So this is the screenshot of the HAProxy status interface. You can see here that they all have the status code 200. You can see that the whole thing has been up for 141 days. You can see here that this one has been up for 133 days. All the other ones have been down at some point or the other, but that hasn't affected the uptime of the cluster as a whole. Go away. You can see furthermore that we have here about 32 terabytes outgoing and incoming. So that's about 40 terabytes outgoing and incoming on the reader front end, and this is the writer front end. So you can see here that it only sends the traffic to the green node, and the other five are blue, and blue is the color for backup. So these are actually the same six nodes, and the writer is the backup in the reader interface, so it doesn't really send traffic there unless it really, really, really has to, because that single node cannot really deal with reader traffic and writer traffic at the same time, strangely enough. I think those are the most interesting parts about the front end here. The health check, the Galera health check comes from the puppet module. I put the URL here at the top so you can go and check it out. So we check a number of things. The state, the local state is not two or four, and I believe that two or four is online or donor, so when it's a donor, it's still in the cluster. Then it returns an error, and whenever we say return fail, that just returns an HTTP code of five or three, I believe it's five or four, not entirely sure. WSREP connected, so is it connected to the rest of the cluster? The cluster status, this says primary if it's healthy and donor or donating or desynced if it's not healthy, so only if it's primary, or actually if it's not primary, then we return a failure. WSREP ready, must be displaying on, and we check lastly if the cluster state UUID is equal to the local state UUID. This has to do with the configuration if I'm not mistaken, not actually 100% sure. So we check a bunch of things. It's kind of redundant, but we decided to check more than what was needed because it's relatively fast anyway, so better safe than sorry in this case. We also tracked the disk space, by the way. We found that that wasn't a, we had that happen once that a disk ran full and it didn't check anything, my SQL just went down, created all kinds of chaos, so that wasn't pretty, but that's not in this slide. Monitoring we use a self-hosted version of PRTG, not necessarily my favorite tool, but that's what the client uses also, it supports Windows and supports all kinds of other stuff, so it works. And here you can see that everything's healthy, just two servers are running a little bit low on disk. What we do with the Galera Notify script is that we send messages to our HipChat room, so within all the data we have rooms for each client and the Galera Notify script sends automatically a message to the HipChat room if something is wrong with the cluster, or if a change happens in the cluster, it doesn't necessarily mean that something is wrong. So we send a message to the HipChat room. We do the same thing for backups just to make sure that there is a message that says, hey, the backup is completed. HipChat is quite convenient, it's basically a fancy version of IRC with how to say that. When you log into HipChat you can see what happened before you were there instead of not being able to see that as it is in IRC, so that makes it very useful for this kind of things. You can see here that a node went down and then we fixed it. You can see that the SSD was initiated here at 6.15 and then it takes about an hour for the SSD to complete. For backups we used to have, so with Galera cluster it's quite nice because it works on a completely different part than the traditional replication, so you can set a whole Galera cluster as a slave of another MySQL server, or you can set a single MySQL server as a slave of a Galera cluster. All of that is possible. We used to have that for backups, but it didn't really work very nicely. It was an off-site slave. Either something went wrong with the traffic between the slave and the Galera cluster, or the Galera cluster was executing some query that the slave couldn't handle. It wasn't pretty and then it broke and then it had to be fixed and it's not something you want to be worried about. What we do now is we make backups on one of the Galera nodes. We do a full InnoBackupX daily and then five incremental backups. We do a daily MySQL dump and they just get synced off-site to the backup server with the added advantage that we leave the last backup on the node that is making the backups so that when something really goes wrong we already have a local backup. Once of the time, I must say that when backups are needed, it is some developer that accidentally did something that he shouldn't have done to the production database and it's just a, hey, can you get me a backup of table XYZ, which is why we make the MySQL dumps. We make MySQL dumps of every table individually because restoring a 300GB database to retrieve 10 rows from a table that has 20 rows is really quite annoying. This week somebody accidentally did an update without a where clause so we had all the records in the table overwritten with the same value. Not pretty, but at those moments you are very happy that you have made backups per table and you don't have to go and sit there and wait until 300GB of data is restored to then see if that backup even has the actual data that you are looking for or that you need to go back in time. Not pretty, so MySQL dumps. To make a backup, you set the desync to on which kind of takes the, it makes the node unhealthy in our HAProxy instance so it doesn't receive any direct traffic anymore. It does receive the traffic from the rest of the cluster, but at least it quiets it down enough for that node to make a backup. It makes the backup and then the script sets desync to off. So that works quite well actually, much nicer than this old situation. Eight minutes, that's perfect because this is my last slide. The current issues and what's next? So because the application keeps growing, more users keep signing up which is all great but it means more headache for us. We have known for quite a while that this database needs to be split but it happens to have built as a monolithic application that isn't so easy to split. So that has been postponed and postponed and postponed a little bit more until now we are actually, sorry? Yeah, pretty much. So now we are reaching the max capacity of a six node Galera cluster and the data is getting quite big and there is a bunch of reasons, so many reasons to make an actual effort to split off and to shard the data that were actually in the process of doing that or actually they are in the process of doing that for the operation side of the MySQL database is not really that much. We just need to set up a second Galera cluster and then a third and a fourth and whatever. So we have decided to do that on a 10 gig network but new issues. That's really a this week kind of thing so we are kind of figuring out what the problem is exactly. And one of the big problems is backups take lots of space. Even if you take a backup a day, you want to keep the last seven days of backups, you take the incremental backups, you have the MySQL dumps, you want to keep the backups from the last seven days, from two weeks ago, from a month ago, from two months ago, and from three months ago, you end up with a ton of needed space. So for now it still all fits. It's a giant storage server but it's not as exactly fun because also when the one node that sits in the cluster that's making the backups, it has to backup the whole thing both in a backup and in MySQL dump. So that takes a bunch of space. For now I think we are okay but if that keeps growing then we will have some new challenges on our hands. I think that was most of what I wanted to talk about and considering I have five minutes left, that's perfect. Obviously I wouldn't be cool if I didn't have a sign that says we are hiring so we are hiring. If you like open source software and you love traveling and a small team of skilled people, at least I think they are skilled, then send an email to jobs. I am on twitter at Walter hack. Find us. That's all. We are ready for questions. I have here a fancy question, Mike. Hello. Hello. Yes, I saw you have set WS slave threats to 16. Yes. Why so? It seems high to me. We had it set to lower and this provided better throughput so that's what we did. We played around with it in the very beginning and never touched it again. So I must honestly say that it's been there for quite a while. Back then this provided the best performance. That's why it's set that way. Can you pass that on? Thank you. My name is Edwin. I would like to ask you whether your customer requires multi data center set up in the future. In the future, yes, but in the current time space continuum we have managed to convince them that multi data center failover is more pain than it's worth. At least it's my belief. There is the chance, the off chance that the whole data center goes down. It has happened once or twice. It's a holiday cottage booking application. They have received actual death threats during downtime. Yes. It wasn't me. Okay. There are only five big players in the scene. So they all get those threats. You know, yes, downtime is a big problem and yes, it should not happen. But the amount of problems we've had from data center downtime is so limited that it's simply currently not worth going through the trouble of adding the complexity of multi data center failover. Thank you. Anyone else? I saw a hand up there somewhere. Was that just me dreaming? No? All right. Then if nobody has any questions, thank you very much. If you have any questions later on, come and find me here or online. Thank you very much. Thank you.
The world of high availability mysql has seen several solutions over the last decade or so. All of them were flawed in some way, none were perfect. One of the new kids on the block is Galera cluster for MySQL. It's fully open source and scales surprisingly well. In this talk we'll look at a case study of how we deployed a 600k QPS cluster sucessfully
10.5446/19622 (DOI)
Mein Talk ist about free Software and free Culture. Making Music with GNU-Lenux. Mein Name ist Tobias Platten. I am a Fellow of the Fellowship of the Free Software Foundation Europe. First I explain what free Software is. Free Software is software that comes with four freedoms. The first freedom is the freedom to use the software for any purpose. The second freedom is the freedom to study the work and make changes. The third freedom is the freedom to distribute the work to others. The fourth freedom is the freedom to distribute modified works. If one of those freedoms is missing, the software is non-free. Freedom requires that you have access to the source code of the software. But that's not enough. There are sweds like Tivo Session. This is the contrast to open source. And there is already the phenomenon of free culture and open source culture. And there is a difference. If something is open source, it is not really free. In Alex Leavitz' book about open source culture, he discusses the mass multimedia sharing phenomenon, that has built around her Tsunemiko. She is a Japanese popstar, actually a singing synthesis instrument. It is used as a new musical instrument, but the software itself is not free. But those media sharing appears in a way that is similar to free. And with free culture you have several freedoms. And media companies try to restrict what you can. For example Vocaloid restricts, that you cannot use the sound samples with your own synthesizer. And with free culture you have the freedom. You can change the sound samples. Now I go to how do you make music with GNU-Linux. There are special audio distributions for GNU-Linux. Some of them are fully free. Then you need recording hardware that works with your Alsa-Körnel. And not every kind of hardware is supported on GNU-Linux, but many glass compliant devices are. This recording hardware can be a microphone or a MIDI keyboard. And if you have the hardware you need to understand how to use the software. And GNU-Linux, there is a sound system called Jack, which allows you to interconnect multiple applications und control them with a single transport. To make actual sound, if you don't use physical instruments, you need synthesizers or samplers. And there are many free synthesizers and samplers available. So, once you have that, you can produce your music. I'll explain later how this is done. And once the music is composed, you can post-process the music using different plugins such as LV2, where one can add effects such as reverb or equalizing voices. And in the last step, one can export the song as a wave file or as an obwarpus and upload to the Internet. Digital Music has source code like software and there are several ways how software can be distributed. For example, music in source code can be distributed. Lillipont is a notation program, which allows you to enter text and get musical notations. MIDI is a format that is used by hardware music synthesizers, as well as by software, and Lillipont can export MIDI. There is also MusicXML, which is a new XML format, which maps all features that can be used in graphical musical notation. There is also File, which also has software support. And then there is the classical printed sheet music, which also acts as human readable source code. It can be transcribed in many other formats. For singing syntheses, there are special formats, like the VSQ format from Vocaloid, which is an XML format, which is a proprietary music source code format, the UST from Uthau, which is similar. Implementing a JSON-based format for monophonic music syntheses. And these formats can be used to create waveforms, which are actually not source code, except when you record directly from a physical instrument. There is source audio, which can be processed using different plugins. When you start making music, the first step is that you compose the music using MIDI, because MIDI is that most programs do understand. MIDI is the common source code for digital music, which was invented about 30 years ago. And it can be used to modify musical pieces. If you have only an mp3, you cannot do modifications as easily as you can with a MIDI. The MIDI format is an open standard by digital instrument makers. For example, Yamaha-Keyboards have a floppy disk drive, or had a floppy disk drive 10 years ago. Modern keyboards have USB-Sticks support. And these keyboards can actually save performances on a floppy disk and then replay the performance. The sheet music can be typed with Lillipont. In Rowskarten, you can also do graphical note input, either using Piano Roll or the classical musical score. You can use keyboards as an input, but then you have to quantize the notes. There are also plugins that can manipulate MIDI data with Alpha2, so you can build an arpeggiator or some other MIDI effects. You can create background chords on your detected melody. And those MIDI files are small, they fit on a floppy disk and can be easily shared on the Internet. This is an example of such a MIDI-based audio workstation, where you can compose songs. In this case, it does not detect the correct scale. In MIDI, you cannot specify this in a good way. There is one problem of MIDI-Music-Format, but you can manually select a scale for a segment, and then you get these gray lines, which are used for the chord of the first tone of your scale. In Rowskarten, you can create audio data or while composing. This is actually played live, if you run the plugin. There are different ways to do this. With the MIDI-Format, the MIDI-Format controls hardware and software sound generators. In Rowskarten, there are two examples of these sound generators that I often use. The sound font is an industry standard for instrument sounds. With Sinead FX, you have more synthetic sounds. It has an FM synthesizer, it can create organ sounds. The pad synth is a special algorithm for creating pad sounds. This is event-based control. When you press a key on the keyboard, an event is sent to the synthesizer and the sound is created. Most important MIDI-Messages are note-on, note-off and modulation. You can change the pitch with the wheel. There are special controller events, such as sustain, pedal and portamento time, which you can specify. There are special MIDI-Instruments, such as laptop-Keyboards, which can be configured with SysX-Messages. You can also use SysX-Messages to transfer new sound fonts to hardware instruments. Hier sind zwei Exzellen. Der erste ist die Q-Synth. Es hat einen Bild-In-Effekt-Track, wo man den Rivaub und Corvus-Synthesizer verabschieden kann, aber nur global nicht per Channel. Der zweite ist der Netsup FX, der ist ein mehr komplexer Synthesizer, der kann man mit verschiedenen Stärkern konfiguren. Man kann sich mit verschiedenen Stärkern konfiguren, wie man das mit den Stärkern konfiguren kann, und man kann sich mit verschiedenen Stärkern konfiguren, wie man das mit den Stärkern konfiguren kann, mit speziellen Effekten, wie ein Kompressor, wenn man ein Instrument nicht sehr laut ist und man nicht globaler Möbel macht, dann kann man ein Kompressor nutzen. Man sollte immer ein Rivaub zu Stärkern konfiguren. Es hat ein Bild-In-Mixer. Es supportzt beide Medien- und Audio-Tracks. Für die Medien-Tracks braucht man immer ein Synthesizer zu instanzen. Das ist AdWords. Das lässt man mit den Check-Transporten nutzen. Wenn man den Kompressor klickt, werden auch andere Sequencer-Applikationen auch gespielt. Und eine dieser anderen Applikationen ist Hydrogen. Hydrogen ist ein Tram-Computer. Und diese Programme sind synchronisiert. Sie haben einen kommunen Timewagen. Und mit diesen zwei Programmen, die Sie mit den Möbeln zu komposen, können Sie eigentlich komposen. Was ich auch mache, ist mit den Synthesis-Synkern. Das ist sehr populär in Japan. Und die meisten Programme, die Sie mit den Synthesis-Synkern nicht erlauben, sind non-freie. Ich beginne einen Freireplacement in 2011. Und im Moment habe ich einen Tech-Demo, auch ein Internet-Page, wo man die Medi-File und die Singingsynthesis-Synkern erlauben kann. Die Programme supportzt both drum and English singing. It is derived from the Free Software Speech Synthesizer eSpeak. And once you have that, you can master your music and mix all together. Therefore you should use an integrated DAW support plugins. I already mentioned it. For each singer you usually use a chorus and a reverb, but also for many other instruments. A feedback delay line produces an echo effect. This is often used for guitars. You can use tube amplifier emulation. Compressors can be used to change the dynamics. And there are also already those CAF plugins. Those provide graphical equalizers and much more. And if you want to have a Kraftwerk sound like you should use vocoders. So you can mix an instrument signal with a voice. And in the last step I will explain how one can publish the music. Soundcloud is very popular, but I don't use it because it uses non-free JavaScript. I have my own media goblin instance. There are also public media goblin instances, where one can make songs available to the public. You can sell self-burned CDs to your fanbase. For example, many Vocaloid Producers sell their CDs at Anime conventions. This is a least restrictive way compared to such iTunes, which only works in non-free operating systems and requires non-free Oilers. Und additionally, you can use Flag or Octvobbis if you distribute music online for a different channel and not iTunes. Flag ist, für example, supported by CD Baby. And you can also allow remixes by publishing source codes, for example, MIDI and USTJ. UTAW produces studies already. And currently there is a new payment system in development called Knutala, which could be also used by a music store that allows anonymous payments. And you get a Flag file for download. And last but not least, there is already a Verwertungsgesellschaft under German law called C3S, which tries to make fun free culture. And this is because of GEMA is doing censorship on the Internet. And we actually don't want censorship and we want ways that people who create free culture can be also supported financially. This is now the end of my talk. And you can now ask. Yes? Yes, I have many songs on my hard disk. So, this character here is Hatsune Miku, which I showed again. She was created by Cripton Future Media. And I can demonstrate some songs. Yes. Okay. This is a song that was created by a found at the site of the Frisoster Fondation. This is a synthesizer that was written by a person from Germany. And I am currently working on improving the synthesizer. This was a speak, yes. And there is already V-Connect, that is a Japanese synthesizer, that is less known here in Germany. This is a mid uncle's murderer. Damit ändert sich's, dass die und es wurde unter GNU General Public License Version 3 eröffnet. Es stammt nur auf Windows. Ich habe das Programm gemacht und es portiert zu GNU Linux. Jetzt werde ich die Package auf Mentors.debian.net und das Programm kann sich jeder auf dem Programm installieren. Die Programm-Internatöne benutzt die Vorbildformat um die residuelle Art des Soundes zu kompressieren. Sie benutzt die Spritzenanalysis-Framen-Framen, die die Fundamentale Frequenz betrachten. Es betrachtet den spektralen Endenlop und ein dritter Komponent, der die residuelle Art ist. Diese Art kann nur mit Vorbildformat kompressieren, weil andere Kompressionen für Sound, die die genügend genügend genügend verwendet sind, nicht der Fass des Soundes und das kann auch mit Vorbildformat genügend verwendet werden. In der neuen Version ist die Art-Periodasise stattgewendet und man braucht keine Vorbildformat, die eigentlich nicht für Spezialen-Synthesien für sich verwendet wurde. Einmal habe ich mit der neuen Version der Software experimentiert und ich habe herausgefunden, dass diese Art auch kompressiert wird, von der PCM zu einer halben Art der Art, aber man bekommt nicht die gleichen Spezialformat, sondern es klingt sehr ähnlich wie die originalen Art. Ich habe hier ein paar Medi-File und dann habe ich sie wieder mitgebracht. Ja, du kreierst eine Medi-File mit Rausgarten. Ich kann es demonstrieren. Ich habe hier eine Medi-File mit Rausgarten. Ich habe hier eine Medi-File mit Rausgarten. Ich habe hier eine Medi-File mit Rausgarten. Ich habe hier eine Medi-File mit Rausgarten. Dann kannst du die Medi-File mit Rausgarten ablaufen. Hier ist ein Lürröckes-Editor. Hier ist ein Lürröckes-Editor. Hier ist ein Lürröckes-Editor. Du exportst eine Medi-File. Dann kannst du die Medi-File mit Rausgarten ablaufen. Dann sendest du die Medi-File zu der Page. Das kann eine Zeit dauern. Wenn es sündig ist, dann wird die Medi-File zurück. Dann wird die Medi-File mit Rausgarten ablaufen. Dann kann man auch die Medi-File mit Rausgarten ablaufen. Man kann auch die Medi-File mit Rausgarten ablaufen. Ich kann das Problem nicht fixieren. Es waren nicht� Ann Turner. Das ist Publikum auf der Web. Und wenn es nicht funktioniert, kann man die Webmaster auf der Webmasse verbrechen. Ich werde einen E-Mail-Link verfahren, wenn etwas nicht funktioniert. Und die andere Sache, wie wir die Webmaster verbinden, ist auch publiziert, aber die Dokumentation ist nur in Japanisch. Es gibt viel mehr Arbeit, um die Software zu machen, die eigentlich verwendet ist. Das ist eigentlich Eikantarik.moe. Moe ist ein japanischer Termin, das ist ein neues Domain, das vorhin zu dem Namesystem verwendet ist. Und man kann solche Domains registrieren. Ich habe schon ein Simmerer mit dem Workbench 1.3 auf der Wiga. Es ist ein plug任 78 Schmidtino in einer USB-Worstuchtbook, das klingt gut. Ich kann es nur montieren, aber local mit dem знаю der von Bildfreer Replacement, das auch als Bildungs-Voyz-Bank. Das ist der Matrador-Part, den Bildungs-Synthesis-Software erlangen. Vor Singingsynthesis, yes, vor Beispiel vor Erz wheel She is called by�kemronton-Future Media. Das ist bei Hatsune Miku. Es ist ein We-Connect Version, der auf YouTube wurde, aber die Free Software war für Singling-Synteses geäußert. Es ist wirklich ähnlich wie ein Vocaloid. Aber diese Free Software nur für die Japanen unterstützt. Es ist nicht mehr aktiv, und es ist viel mehr Arbeit, um andere Langgages zu unterstützen. As Japanese ist es ziemlich leicht, in einem Singling-Syntese zu unterstützen. Für europäische Langgages muss man jetzt auch die ESPEC-Frontend benutzen, die für einen anderen Singling-Syntes ist. Es gibt auch mehr Menschen, die auf Vocaloid-Replassungen arbeiten, die es als Free Software erlisten haben. Aber die meisten sind nur für die Japanen und die Chinese. Es gibt auch auch sehr viele Englische, die auf Vocaloid-Replassungen arbeiten. Mein Name ist Kyo Tao, der Grafische Editor. Ich kann Demonstraten mit Editor. Sie sind dann immer auf alter Ich weiß nicht, ob es startet, wenn der Check Sound System noch nicht funktioniert. Jetzt muss ich erst mal starten. Hier kannst du die Knoten holen, und du bekommst eine Phonetik Transkription. Das ist schon gemacht. Hier für convenience easily arrivesabel. Sie weiß aber auch mal, was man von allen Vier sheer hat. Ich habe noch nicht diese Version veröffentlicht, da sind noch zu viele Bucks, die ich fixen möchte. Wenn ich sie fixe, dann vielleicht will ich die Programme erlesen. Es ist nicht mediativ, es benutzt das ownDrazen-Format, aber es kann import und export. Es benutzt das ownDrazen-Squenzen-Text-File. Es ist auch wirklich der Otausformat, aber der Format ist nicht extensiv, nicht sehr dokumentiert. Ich habe einen neuen Drazen-Format, der easy zu verstehen ist und der Otausformat ist kürz. Das Otausformat ist ein Text-Basenformat, der eigentlich keine Modifikationen gibt, das nicht funktioniert. Es scheint, dass Qtausformat schon verbunden ist. Es sollte auch ein Portiosensound sein, wenn ich den Klick auflebe. Das ist ein Versають von fastnersound, der auf começa. Aber wenn ein Notfall dran ist, Enter Ich habe ein Mist gemacht, aber es war perfekt, ein paar Wochen oder Monate vorher, bevor ich zu Anime Marathon ging. Nachdem ich die Format zu Jason geändert habe, scheint es jetzt für die jungen Medifinals zu verwendet zu sein. E-Speak hat eine spezielle Format für ihre Format. Ich will nicht das Programm verwendet werden, bis die meisten Bugs aufgeführt werden. Es wurde testiert. Es waren viele Bugs, die ich verwendet habe.
This talk will be about Free Culture and Free Software in the context of computer music production. GNU/Linux is often used by musicians who want to share their music. Tobias Platen
10.5446/19615 (DOI)
Hi everybody, welcome and thank you for coming. I'm a software engineer at Etsy.com and Etsy is a global online marketplace where you can buy and sell handmade and vintage goods. I think we have 1.5 million active sellers right now and we value craftsmanship and human connection. I write software to help sellers at Etsy. The title of my talk is a culture of courage and I wouldn't say that I'm an overly courageous person. In fact, I'm a bit shy but I'm giving a talk right now so that requires a bit of courage. I'm mainly here because of my community of encouraging people. These are my colleagues from the Etsy Spirit Squad and I'm very grateful for these encouraging people. It hasn't always been this way for me, especially in internet related cultures among nerds and hackers of all kinds and people like me and all of us here. We see a lot of the opposite behavior. One upmanship outsmarting each other or just bad communication. We've all done it. I've done it for sure. And I think it has to do with technology shaping our brains and behaviors. Wait, what did I just say? Technology makes us evil. Now that's a bit far fetched. Let me explain what I meant by this. I'm speaking from the perspective of a software engineer but I think we can deduce general patterns for communities from what I'm describing. So every day I work with a computer. I love that because the computer is a great teaching instrument. I love computers. From the nature of the construction as a machine, I know that the computer is always right. We could say it never lies. A faulty behavior has been programmed into the computer by a human at some point. So if I'm trying something new and it doesn't work, I can be pretty sure that the mistake is on my side and I have to poke around a bit to find out more what I did wrong. So in comparison to a human, a computer is very deterministic, predictable, following the same rules. Also that means it's kind of inflexible. In programming, small mistakes like a forgotten new line in the program codes can make the computer unhappy. You all know this. Over time, my brain learned that it's very important to pay attention to teeny, tiny details. Learning this can feel like banging your head against a very rigid wall at times. It's a very humbling process. It is also a very intimidating process. I have friends who can never remember their passwords and they say it happens because they fear their computer because it's complex but rigid at the same time and they fear doing something wrong when they touch it. So my job is building computer programs. That means I work on parts of the system that are under development and they are not quite working yet. So working with broken code is the main part of my job. Imagine the code was working already, then my job would be done. How boring. I'm sure this can be translated to other professions like editing or creating art and media. We are knee-deep in broken things all the time and it's not our fault. The weird thing is nobody talks about this part of the process. I don't know about you but it used to make me slightly grumpy and stress me out. All these not working yet things. Before I heard this thought from my co-worker Bethany and I thought about this in depth. It gets even more difficult when we add constraints of the real world like time. We want our code to be ready fast because we have lots of things to do. That means there's also the trade-off of how to approach our job. Ideally we write some perfect code, super clean, easy to understand for the next person. In reality we have to make it work and then move on to another thing. If we are seasoned and smart about it we try to strike a balance between idealistic goals and a realistic outcome. If we just take shortcuts we incur technical debt in the project, meaning our shortcuts introduce unclear parts that other people have to tidy up after us. Then we even land it on a project where the code is already messy and we are scared to touch certain parts of it. Another constraint is the connection of our work to the rest of the world. How does my code work together with the rest of the code base or my co-worker's code? Maybe we have different styles of writing. Sean likes spaces and I like tabs. My friend Nina said a good code base should look like a single person wrote it no matter how many people contributed. So there's some communication and decision-making to do to accomplish this. It can be an area of frustration when people insist on having their personal styles met and they're not willing to collaborate on that matter. This happens surprisingly often and I suspect it's because computers train us over the years to follow a very rigid style because that's how they work. Most of the collaboration in terms of style should be easy to understand when a new person is joining the project and that's another reason to focus on a clear decision and communication about it. We could say those are a bunch of different and completely non-technical pitfalls or evils when working with computers, no matter if we are coders, researchers or other digital workers. I've seen people, friends and colleagues become desperate, cynical, sad, mean or lonely for these reasons because the computer always wins. It's a rigged game, right? So there seems to be some fuzzy emotional headspace element to working with computers even though or because they are unemotional machines. I started realizing this when I transitioned between different communities working with computers. So let's talk about technical culture. When I grew up, my dad was a programmer and even though he sat down at some point and he coded with me for a bit, he was too impatient to really explain the details and he gave me a book that he had written instead. The C programming language? I don't blame him. I was in primary school and this was the C programming language. I was just too young. When he installed a new Linux version on our home computer, he went to his room alone for a day or two. It was very mysterious but not very collaborative process. I learned to read the manual before daring to ask, before I was even in high school. And then I still remember my first time installing Linux on my own computer, doing it all alone with just the help of the fine manual. And then having a friend over, helping me set up my dial-up modem after moving to my own place, which he did by grabbing my keyboard and typing things without giving any explanations of what he did, must be wizardry. In the university, I studied computer science and I started going to the local hacker space. So this was actually before hacker spaces took off. This was the local airfare crisis, as we say in CCC. This was many years ago. They're dawned on me that doing things with a computer has a political dimension. I learned a lot of details, tuning my computer at night, patching and building the kernel of my operating system in order to learn some wizardry myself, mostly or by myself. The meetings with fellow geeks were reserved for both things, about new tricks, versions, arguing about over-heeled opinions on software, not learning or sharing. Trying to fight my way into a competitive culture, which wasn't very welcoming to female folks, in part because people seemed to be afraid we might find out about the poor nature. These were the awkward years of undergrad study. Here I learned competing and outsmarting people, not asking questions in fear of looking foolish, even though everybody in the room had the same question. I learned that people seemed to like doing the coding, but not the documentation and writing it was looked down upon and other toxic tricks of engineering culture. I suppose back in the day when engineers were designing mostly trains or bridges, it made sense to have people prove themselves and fight their way into the ranks of esteemed engineers in order to make sure they really know their shit, how to build stable bridges. But this one sensible idea overshot its target and created a culture that can be an obstacle to learning and development now. During my following years as a PhD and postdoc in which the university became my professional work environment, I saw more and more of these behavior patterns from growing up in engineering culture take over the internet. People were outsmarting each other on professional sites like hacker news and Stack Overflow, just as we had done it in our undergrad years in our geeky meetups. I saw people derailing a conversation by adding a non-relevant tangential detail with a phrase, well, actually, just like in school. I saw the same questions being asked at professional conference talks that were in fact just thinly weighed statements of opinions or facts to put the speaker into place or directing the conversation to the person asking the question instead of having a real desire to learn via having a burning question answered. Also, there was this really beautiful sounding but soft and squishy concept of meritocracy or as the German geeks call it, wer macht hat recht? Whoever does it is right, which essentially says that fame and our culture is based on what you do and nothing else. So you are what you do, why you can hack and what you code it. Sounds excellent to me, not being judged by what I do. Being judged by what I do means stripping away other factors such as money, class, race, age, gender or other things that can be used to judge a person. No prejudices, sounds great, except for it doesn't work like that. And the meritocracy is a theory. In reality, people from different backgrounds are dealt very different hands in life and the amount of money, spare time and education influences what they can hack on our code, what they can do and will be judged for. It sounds like this romantic but unrealistic dream of capitalism where everybody can be a millionaire when they just work hard enough. What's also really dangerous about the meritocracy idea is that the people in this culture will always be judged based on productivity. So even in our spare time we are supposed to write blog posts, contribute to open source software, of course we do, and do cool stuff. So we are optimizing ourselves to be productive even in our spare time. Don't get me wrong, I love tinkering and technical discussions in my spare time and I don't want to say that we should never do such things in our spare time but basing our value on it is almost like a logical fallacy that creates a lot of pressure. And it makes it hard to really take a break from things or do useful things that don't fall into the school tech category like spending time with my grandma. Not taking a break makes most people depressed and burn out after a while. Also I noticed there was a pecking order of geekier than though established in most work groups I was in. So people introduced themselves as old sea gurus, network technology specialists, grumpy citizens with root privileges and keys to the data center. And many people introduced themselves with the history of how long they had been programming to make themselves more credible in the group. While I understand that every person has a history and some people here had a great history, I really love the talk we saw today. While I understand this and even though I did write my first program as a kid and I compiled my own operating system before, I'm not sure why I should tell this to the people I work with now. It's of no relevance for them except for trying to impress. It establishes a hierarchy and it excludes people who are new to the craft. Still I catch myself doing it all the time. So looking closer at this pattern, there seems to be a war of generations going on. I'm 33. I'm somewhere in the middle of this war. The older dinosaurs of the Internet are somewhat shaped by this geekier than though attitude. For them the Internet was a playground of geeks which was a safe space from the rest of the world. It's hostile in its own way because you had to fight your way into it and prove that you know something or at least you were able to set up your dial-up connection and read a news group. But once you are in, you could be pretty sure to be safe from the jocks and mainstream people that bullied you in school if you were a geeky. In times have changed though. Now everybody's on the Internet and my 88-year-old grandma skips me from her iPad. That's awesome. And with different communities, there are different interaction patterns again. So the Internet is a part of everyday life now. If I put on my dinosaur geek hat, it's about time to grow up and reflect on my behaviour patterns. The question is, does my inner-old style geek get angry about new people invading my safe space? Is it my space at all? Or do I manage to be inclusive and extend the space and make it bigger and even nicer? How do we welcome new people? Focusing back on the professional sphere, I think we have problems with passing on knowledge about technology. Historically, people have been kind of exclusive about it. Maybe because in history, technology was an underground niche. Maybe it's because technical people are more versed to focus on technology than on teaching. Or maybe it's because of outdated safety concerns. Who knows? Maybe it has to do with the fact that it's really hard to teach programming and other tech topics. You can't really learn it from book. First of all, the book is most likely outdated and secondly, the big leaps of learning come from doing the thing itself. So it's more like a craft. Yet there's no such thing as an apprenticeship or a master apprentice relation when learning about programming because it's still a fairly new craft and it has no links to traditional crafts. A lot of the learning for me happened in informal ways. On the internet, after class, in this parallel universe. A weird cause of the problem of passing on knowledge is also that fellow engineers love to point people to the documentation instead of explaining things. Reading the fucking manual. Like I experienced it as a kid. Interestingly, nobody seems to want to write these manuals. My hard-boiled dinosaur geek me would pride myself on just writing code and documentation was almost as evil as bureaucracy to me. Even though we might not like these behavior patterns or we might not have fully identified all of them or we like in different parts of this journey, they are known to the entire internet generation of which I see myself and all of you as a part. It's the toxic undercurrents in the culture we all love. We have friends who are as geeky and who we really like. There are fun moments where the empowerment through technology makes up for occasional bad behavior. It can't be that bad, right? So for me, I didn't fully realize the extent to which it was dragging me down and how much of this behavior was ingrained in me myself before I moved across the ocean and back where I encountered different tech communities with a different interaction style. I work now in what I would describe as a culture of courage and encouragement. Before that, I went to a free school in New York City. It's called Hacker School. It's now called the Recurse Center. The school was like a writer's retreat for programmers. So there are no teachers, just facilitators that help you when you get stuck. Essentially, you pick your own project and then you pair program and teach each other for three months. Hacker School was one of the first safe spaces I encountered for programmers and it was an eye-opening experience for me. Hacker School created the space by giving us some simple social rules. I hope you can read this. So first of all, know well, actually, if you're trying to explain something and another person corrects you with well, actually, what they usually do is they throw in some facts nobody asked for just to sound smart and divert the conversation to themselves. The second one is no feigning surprise. So if somebody asks in fake surprise, what, you really don't know what a frame buffer is? They don't accomplish anything except for making you feel bad. No backseat driving. If you listen to a conversation where two people are trying to learn something and then you hijack that conversation with the answer, you make two people feel really bad and make them lose their chance of learning how to figure things out. And last one, no subtle isms. This makes it possible to call out behavior that makes the space uncomfortable for marginalized people and make it welcoming for everyone. And this culture makes for a great learning environment, a place where people feel encouraged to try new things out, ask questions and give answers in a straightforward way without posting or ridicule or shaming. This is one of my first encounters of a geeky culture that felt safe for asking any kind of question, felt great. When I started working at Etsy, I had to write code and bring it live to the website on my first day. It felt like a giant wave of forward trust that everybody had in me. Of course, somebody was reviewing my code and explaining me the steps to put it on the site to make sure it all worked. But it still felt like an empowering accomplishment to do this on day one. We called this the first push project because it's the first time an engineer pushes code to the site. A few months later, my colleague Dan and I organized a first push project in the Berlin office where I worked from. So my colleagues from the international community, design team and office management pushed code to our website. They felt the same sense of empowerment as I did in my first push project. This was a great exercise of unity, breaking down the somewhat artificial barrier between engineers and non-engineers that I always found silly. In the end, it's not magic, even if people like to say that out loud. Everybody could do it. Also, a few months later, I pushed code which contained a bug for the first time. Uh-oh. I was pushing a bit late all alone in Berlin while my fellow engineers were in Brooklyn. The internet was flaky and I noticed I pushed the wrong thing and caused a bunch of alerts on the test server. I freaked out a little bit, but people patiently offered their help and in the end, we fixed my bug before it made it out to the real website. Yay. I was actually surprised about how relaxed and friendly my colleagues were in this situation. This was great. Nobody was angry at me. Everyone gave me time and trust to fix the mistake. After I fixed the mistake, I found some super nice reassuring messages from my fellow engineers who said, don't worry about breaking stuff. Everybody has done it and they told me their faulty push stories. Even though they were all the way across the ocean, it felt like a giant wave of support. So from this anecdote, we can speak a bit about the process for pushing code to the site that we have. We always do it together. We have a queue so that people don't push changes at the same time and write all over each other's changes. We communicate a lot while being in the queue together. The push queue has opening hours to make sure that people are around watching and people don't drive by push late at night when they're tired, what I did due to my time zone thing. And during the opening hours and also off hours in case of emergency, every engineer has the full autonomy to push code to any part of the site. So we push continuously to the site, driving its change up to 60 times per day. And when something breaks, we can push a fix in the same quick fashion, which is often times faster than reverting a change and we keep rolling forward all the time. There's also a customer which is very surprising for me at first, a price for breaking the site in the most spectacular way. So this is really related to what Leslie said earlier with the fail cake in the previous talk if you've been there. So we have the three-armed sweater for this. And EtsyCela made a three-armed sweater as a reference to our famous error page, which looks like this. Can you see it? And this sweater is awarded as a yearly prize. A colleague from our team once got the three-armed sweater because he accidentally banned all Etsy admins from the site, wearing us off from doing our work. Shit happens. The prize is giving away a bit jokingly as a reminder that failure happens, even though people usually have good intentions. Good intentions. So good intentions and trust are a very important point to this philosophy. Overall, this strategy sounds counterintuitive, right? Like we discussed before, everybody can push code to the site and there's no blame when people break something and they even get a prize. Thinking a bit more about it, it makes sense, right? If we come from a place of trust. And we can assume that the person who introduced the mistake did it by true accident because they were changing something and their best intentions. The system is just so complex that they didn't know its full behavior at that point in time. They didn't know that their behavior would have a different outcome from what they expected. By blaming them or even firing them, we would let this opportunity of this great moment of learning pass and the same mistake might happen again in the future. And of course, it's a calculated risk. We do have code reviews, we have tests, we have the collaborative deploy process and a test server which is called the Princess that saved us many times. Still, the full autonomy of deploying code for everybody at all times is important because it allows us to move fast and if things eventually do break despite all our precautions, we can fix them. Another topic that's still a bit hard for me is asking questions. Asking questions the right way. Looking back at my time in university, I feel a bit sad about all the questions I didn't ask and the pressure I found back then around asking questions. After all, this should have been the place of learning in my life. So why was I so reluctant to ask questions? Because asking a question makes you vulnerable and it exposes an area of not knowing and it describes a need or a dependency on another person. And there was no explicit culture around creating a space for asking in class. Even though professors occasionally said phrases like, there are no dumb questions, do they really mean it? Why were they sometimes annoyed if somebody did ask a question then? So I asked other people, I asked the professors after class or I went to the library instead. All fair. What I only realized later is that so many people had the same questions they didn't dare to ask. So I would have made it easier for everyone if I must had the courage to ask more. And of course, there's a trade-off. I don't want to be selfish and waste the classes or the professors' time and have them cater to my smallest needs, I understand that concern. But understanding each other requires asking questions sometimes and this is surprisingly hard to do without an encouraging community, without good examples and without practice. It got a bit easier with practice and gaining more knowledge in general, but even as a grad student I found it hard. I still find it hard sometimes. So this is answering questions. At the same time, how can I help people to ask questions? How can I answer a question without making the person who asks feel uncomfortable? As I briefly mentioned, some questions are indeed difficult. I call them unreal questions. They are no real questions. There are more demands of attention. Sometimes they're negative. This I've seen when another person gave a really good explanation or when people speak in bigger groups. Maybe they are misguided attempts over thank you. I'm still figuring them out. But back to answering a real question. The rules of hacker school helped me a lot here because they cut out a great deal of subtle or maybe even subconscious ridicule and boasting such as fame, surprise and well actually and they encourage people to reflect on their communication patterns. They allow us to address negative mechanisms. We have names for them, right? A good first step is welcoming the question. So I have this colleague Lara and she's really great. So if you ask her a question, she will go, that's a great question with a lot of enthusiasm. So it's really fun to ask her a question and then she takes the time to answer it. It never feels bad to ask her a question. It's great. Another good step is to admit not knowing something as a positive example and make it the normal and non-scary thing that you don't know stuff sometimes. This can be used super constructively. So when you say things like I've understood the first step of the problem but then I don't know why the second step is happening instead of this other thing that I assume to happen. So you can debug the problem in this way, right? And this is an area where I try to watch myself continuously as hard. Thinking about this change of perspective that my encouraging colleagues kicked off of me, I noticed a few takeaways. So we could say this is the courage and fail also fee part maybe. First of all, there are a bunch of myths in engineering culture that were does. There's the myth that there are such a thing as technical perfection and that it scales to bigger systems. We all know that in a sufficiently complex system, it's impossible to oversee every detail. It's not possible for one human. There will be bugs. And there's the myth of the 10 times engineers, some magical people who do 10 times the work of others. This myth has to die because it's introducing more pressure when most people don't have a problem with not working enough. They have a problem with taking breaks. Also doesn't moving 10 times as fast come at the cost of technical depth and an untidy code base for other people maybe? That doesn't feel like it would work well with others. And then there's this artificial boundary between engineers and users or we could say writers and readers or artists and consumers of art, whatever. You can see the pattern. And doing our first push program with non-engineers or however we want to call this, people not in engineering roles, in our office was one of the most empowering moments in a long time. In the end, we're all humans and we can all do awesome things and everybody could do it. And then there's this big element of ego and pride and programming and among nerds. So this is really interesting to me. Perfectionism is a big problem. It's leading to not finishing a project or maybe not even starting it yet and fear of it not being perfect. And I think the narcissism of the modern internet where everybody takes pictures and posts about their stuff, this makes it even worse because you can see all the people around you presenting their awesome projects. And there are many overachievers or people with really great ideas or people that are just really smart, which can be intimidating. Everybody wants to be awesome, right? And thanks to meritocracy, we also have the problem of strongly identifying with our code. So for some people, it's really hard to get a code review with criticism in it because they learn that they are their code, which is obviously not true when you're breathing human being with a heart and not a machine. But it seems easy to forget when people tell you this all the time. Maybe it's a thought coming with the immense power that you can change things in the programming arm. I don't know. Some people I know practice meditation in order to improve their skills of letting go of the ego and these overly controlling elements that come with programming. And then there's a big part of society who still sees failure as a shameful process. And step down instead of fixing things when they fuck up. Why? Our parents might have been angry when we got bad grades. Our inner voice might criticize us for every tiny mistake, wanting us to cover them up and hide them from others. Opportunities for learning are lost in this frame of mind. And I think these three problems are disproportionately huge when working with our brains, ideas or computers. I saw them among scientists, writers, artists and geeks, because oftentimes we cannot see the result of our work. They seem virtual. We cannot touch them. It feels different than building a house from real wood with our real hands, at least for me. I think it's easy to get alienated from digital work for this very reason and also because of the lot of the work is done alone. The work doesn't feel real on some days. Did I do any work at all today? Maybe I'm just an imposter. Speak to your fellow nerds about this and find out when and why it is happening to you. Another big field of action is the field of collaboration versus competition. So what's competition? Usually we compete when a resource is limited, right? That's why countries fight over natural resources. In capitalism we're supposed to fight for resources that are not limited, like grades in school or money to buy digital goods, to establish a healthy competition. Usually this is done to establish some artificial power dynamics. Many goods in the digital world are shareable, like education and information. And even if they are limited, like for example, attention or one-on-one time of a person, collaborating and giving it freely and helping each other will empower everybody around you in the long run so that even more people can help each other and you in the future. In Montreal I was part of a group that practiced do it together, where we exchanged computer skills in our spare time. Julia from Montreal is giving away self-made zines about her favorite tool S-rays. I think sharing and doing stuff together makes it less scary and more fun. My favorite trick that I noticed and all of the above points is to go from this situation of failure to a situation of learning as quickly as possible. Removing blame helps a lot. When there's no blame and shame, failure becomes a learning opportunity right away. Also, I want to mention that it's still a privilege to fail and learn from it. Depending on your standing and your community, you might get a pat on the back or a kick in the butt. So I'm very grateful I'm in this place and I can talk about this here. I think it's important that we create an inclusive and safe space in which everybody can ask questions, try wrong things and improve because that's the way we learn. Always being right means I'm doing or thinking only things that I know already. Being wrong and having to change my view is actually awesome because I just learned something and I evolved an idea. I want to close with a suggestion that you are someone's spirit squad. I had a transformation via other people. I don't have it all figured out. I'm still learning all of this. It's an ongoing process for me. I still encounter grumpy dinosaur geek parts in my personality every day. But I'm also starting more and more ways to build and expand this culture of courage. And I want to share it with you. I want to be your spirit squad and I want to encourage you to encourage others. And I want to hear the story about your community. Thank you. So do you want to ask questions here or do you want to maybe discuss at the side? It might feel more comfortable. Do you have questions? Okay. Can you explain some more about the spirit squad at Etsy? How does it work? So I'm supposed to explain what the spirit squad at Etsy is. So this picture is from the Etsy talent show. And there was actually a cheerleading squad, which is the Etsy spirit squad. So this was from a performance, this picture. But this is like, I use this as a metaphor. I know that these colleagues have my back. And if I do something wrong, they're going to help me out. I can trust them 100%. No, that would be awesome. Great idea. Yeah, so that's a very good question. That's a bit what I'm trying to... So how can you teach children nowadays programming and have a better experience? That was the question. So I made this talk with the focus of what did I experience and what would I like to be different? So I think these rules that I got from Hacker School are creating these spaces. This would be what I would like to encounter. So I can have just my pure curiosity flowing out and exploring the world and answering all my questions without these steps that I have to prove myself and so on and so on. But the question is, how can you explain these skills packageable in motion. So I think the question was when you get an objective number from your system, how can you communicate when this number is negative? How can you communicate this in a good way? So I think I'm not really touching this here, but I think maybe the topic of nonviolent communication that we heard in the previous talk could be helpful here. So you have to think of this emotional side too when you're discussing purely facts, because we talk about computer science, it's never purely facts. There's humans communicating and we tend to forget this part of it. And especially dealing with negative things, there are some interesting reactions in the brain. So if you tell a person, for example, negative feedback, their reptile brain takes over and their reptile brain will say, no, no, this is not true. And then you cannot discuss it. So I would say for these things, if it gets emotional or if it's like some negative things you have to talk about, come back to the discussion later after this brain reaction has passed, because you can wait it out, because it's happening in everybody. And it's like a proven scientific thing. More questions? Otherwise we can just talk and have a little discussion at the side, maybe. Yeah? So I wanted to talk about the first concept in the equity working class on gaming, like exclusive knowledge and then occupying these exclusive knowledge and occupying their typing system. So how can you work with a system in which people are hoarding knowledge and they don't want to share it? What can you do about this? That was the question. I think that's also a cultural problem. So you have to create a culture of sharing. You have to create a culture where people teach each other, where learning comes first, where curiosity comes first. And it's more important than having this single point of failure person, and that you bow down to them because they have the knowledge. But that takes time. Yeah? So this is a question about hacker school and social roots. I would encourage you to try hacker school because everybody can go there. I came here from here. They're international. Everybody can apply there. It takes three months, knowing which you can pick your own project. So you can go to hacker school.com. Now it's called the request center. So now you have to find the new website. because in my times it was called differently. So now they are recurse center, recurse.com I think. I'm asking, and I'd like to ask you with this, you've been the class from our MC to our school. Is that significant part of getting to do with, which from the very latest organization to learning? So Edwin wants to know if flipping the glass from high of empty to high full, like optimism versus pessimism, is it plays a big role in this change, like learning from failure and seeing it positively. I think that's definitely true when we have such an attitude towards it, but I think there's even more effects that speak for it. So it's even, even if you just want to optimize the learning within your organization, it's a smart path to follow. Because otherwise the moments where you can learn something because something goes wrong, they would just pass by. No more questions? Then feel free to continue the discussion at the coffee stand or find me later.
At my new job, I was surprised about my colleagues reactions to my mistakes. No blame! People trust me to own my mistakes and fix them! Complex systems are brittle. Developers work in a constant state of new things-not-quite-working-yet. Programming in pairs and code reviews help us. But what about the quality of human interaction? How can we build a culture of blamelessness and why is it crucial for learning and for brave decision making? Stefanie Schirmer
10.5446/19605 (DOI)
Thank you. I was looking through my slides. I was looking through my slides and I've been speaking all over the world. I was looking at when I was last here and it was in 2008, I can't see that far. I was looking for St. Augustine but for some reason I just called it some small town in Germany. Yeah, August 24th. Some small town in Germany. That was my last talk, simple as hard. Many years ago when I started talking about stuff like that. But we're not going to talk about that. We're talking about PHP 7 this time. My slides are online, talks.php.net. You can go look at the last 20 years of my talks on there. The older ones are kind of badly formatted now but grab them from Git if you want. So yeah, really, 20 years of PHP. It was fun listening to Mad Dog earlier talking about how Linux got started and things. And I remember sitting with floppy disks in late 93. I think it was 25 of them and you get to the 23rd and it doesn't read. There's a read there on the disk and you have to start all over. Terrible. But I eventually got through it and that's when I started PHP basically. Once I got my, I was running SEO Linux or SEO Linux beforehand but it wasn't until Linux hit with all the tool chains and all the gear to actually start building things, have debuggers, compilers. All that was too hard before Linux. Linux really drove this whole industry for us. So by June 8th I had played with enough floppies and gotten a system up and running to announce it. And the announcement is here. It was posted to use net which was this thing that previous generation used instead of Facebook and whatever else the kids used these days. But we actually discussed things on use net news groups and I posted this to the Comp info systems, www.authoring.cgi. And as you can see, I didn't really describe PHP as you know it today. I described it as a bunch of things you could solve using this tool. And it's a nice snapshot of what were the issues people had on the web in 1995. And it's hidden in here. PHP is kind of here. It's usually creating display forms. And the ability to use information in the following documents. So you put up a form, you post the information to the next page and you can use that information somehow. I don't go into the fact that there are variables and you can do things, you can stuff it into a database. It's kind of implied but people weren't used to that back then. People were used to static web pages. There was no such thing as the dynamic web in 1994. The web was like a newspaper. You go to the website each morning and see, hey, is there any new content here? And once you've read it, that's it. There's nothing else. It's not like you could log in, you couldn't do anything. It was just basically a digital newspaper at that point. So you didn't need anything, you didn't need a scripting language for the web back then. It was starting to come but the mass majority of people didn't really connect with the idea of a dynamic web. So people were mostly interested in just logging who came to their pages. So that's why there's a lot of stuff about logging in here. So tracking who acts as the page and putting all the information in the database, create reports, things like that. But what I was actually trying to do in a very sneaky way which completely failed was to introduce the C API for the web. So all these various logging tools and all these things that I built were built on top of this very simple, or I thought it was simple, C API that then could be used to create or extend the templating system that I was providing. So the templating system basically just had a set of tags that I had provided as default implementations. They were essentially just examples. So here are a bunch of tags. They happen to talk about logging and put stuff into a database related to logs. But those tags could easily be changed or duplicated and change slightly to do other things. I figured people would be writing business logic in a strongly typed language, compiled language, debuggers and all these things. I really didn't foresee that people would write large complex applications in PHP itself. To me, it was just a display part. And all the business logic would be written like this basically. Hold on. So here, if you wanted to implement a cosine tag, for some reason you put in one of the cosines into your template, this is all you had to do. It was stack based. So you'd pop the argument off the stack, check it, make sure there was something there, then perform the cosine operation and you push the result back onto the stack and you tell it that it's a double, D number stood for double. And that's all you had to do. Then you would have this cosine function available in the templating system that you could then use. So you didn't have to worry about how do we compile it into Apache, how do we, well there was no Apache back then, but how do we interface with the web server, how do we spit stuff out, how do we parse a post document, how do we get this stuff in. You just had to write just the core of your business logic in C. And everything else was handed to you on a platter. But my platter wasn't big enough. People just did not want to write C at all. No matter how simple I made the C API, people refused because C is too hard. And the web was moving so fast that it was non-programmers that were tasked with solving the web problem. It tended to be the tech guys, the tech writers in companies that ended up becoming the web team. And the tech writers, they became the web team because they were asked, hey, this web thing that's new and exciting, let's get something up there. Let's put our documentation. Release notes, upgrade guides, anything like that. And the tech writers who wrote that stuff said, sure, whatever, Microsoft Word, save as HTML, we done. But when they then came back and said, let's put our inventory up, let's put our support database up, our CRM system, let's make that available, all these things that are way more complex. And they told the web team, go do that. And the web team are sitting there with Microsoft Word, save as, there's no save as, big dynamic website. And those were the people that ended up using PHP. Much to my annoyance for the first couple of years, I was fighting with the user base essentially. What the hell? I mean, they would, I would show them, this is so easy. Here's an example. And they would say, well, I see you have, it wasn't cosigned. I say, I see you have cosigned. Why don't you have signed? Come on, it's like a search and replace. It takes you two seconds and I do it for them. They say, thank you. Now, how about, and I just kept going and going and going like that. I felt like I was the remote programmer for about 100 different companies at the time. And I got a bit burned out. And I essentially stopped. I said, this sucks. Nobody's buying into my idea. Everyone's just expecting me to solve their problems for them. And so I was, for about three weeks, I was at the point which was ready to toss it. There's too many people emailing me complaining. They're not using my tool the way I want them to. Everyone's just suck eggs and go away. But I didn't. Instead, the smartest of the folks that had been bugging me and complaining, I just said, okay, screw it. Yes, I know my Oracle extension sucks because I didn't actually have Oracle. I just got the header files from Oracle and compiled it against just the.h file and relied on the user base to tell me if it worked or not. And a guy named Steve in Norway, Steve Bucking, was complaining because he used Oracle and because I had never used Oracle, I didn't even have Oracle, it didn't work quite right. And he sent me all these bug reports. I said, fine, Steve, it's yours. I don't know anything about Oracle. Take it. It's all yours. And I did that for most of the PHP. I just sort of handed off all the PHP to other people to the point where I had nothing left. And this was late 96 or so. Zevan Andy came and said, hey, we looked at your core parser. We've just finished taking a course in this realm, Tel Aviv, on exactly this, on building compilers. It doesn't look like you've ever taken a course on this stuff. And that's very true. Like Mad Dog said earlier today, it wasn't computer science folks that were building things in the early days. It was people who were solving problems. And I'd honestly never taken a computer science course in my life. I have an electrical engineering degree and we had an engineering computer science course, but it was completely crap. It was there, but it was terrible. It was really, really bad. It was dumbed down for the engineers to the point where it was useless. Anyway, that's sort of the story of the early days of PHP. I did eventually grab a few things back after giving everything away to the point where I was comfortable with the workload. But if I hadn't done that, if I hadn't given up control and so they let it just take its own path and basically let users dictate what PHP should become, then it would have died right then and there. I stopped being stubborn. I stopped rewriting everybody's patches that they sent me. That was demotivating for the contributors. And I just let everything in. And yeah, some of it has come back to bite me and bite us later on. Some of the early contributions weren't necessarily the best. But it kept the project alive. All right. So we're at PHP 7. There are some massive improvements in PHP 7. The biggest one is 100% plus performance gains on actual real-world applications, which is pretty much miraculous. I mean, it is really, really hard to take something that has been around for as long as PHP and make it more than twice as fast on real-world loads. You can game benchmarks all you want. Microbenchmarks, all kinds of things like that easily. You can double-triple 10x microbenchmarks, no problem, by focusing on them. But taking millions and millions of lines of code that PHP out there in the wild and making all of it twice as fast is quite an achievement, actually. And the guys that worked on that did a really, really good job. Plus doing it in less memory at the same time. We've also added what we call persistent secondary file-based cache for opcache, which means it's an on-disk version of the opcodes that we store in shared memory during opcode caching. The biggest gain here for high-traffic sites when they have to restart their servers, you take a bit of a hit because you have to recompile and repopulate the shared memory cache. If you have a copy of those compiled opcodes, operates on disk, then you can repopulate from disk quite a bit faster than having to recompile. It's obviously not as fast as having it in shared memory because in shared memory we actually don't need to copy too much down into local memory. We can point the executor directly at shared memory and just execute out of shared memory. We cannot execute right off disk like that. It doesn't work that way. So in a couple of simple tests, if it's one x time to read an uncompiled index.php, this was, I think it was the WordPress front page I tested this on, then it's 10x faster to get it from shared memory and it's 4x faster to get it from disk. So you get a 4x increase on the restart. And yes, it's only for half a second as you're restarting, but for really busy sites that take thousands and thousands of requests a second, that half a second is thousands of requests. That makes a difference there. Plus, there's sort of a secondary benefit. And the secondary benefit is that from the CLI, because the way CLI works, it starts up and then tears everything down, you can turn on opcache today on CLI, but it doesn't help you because that shared memory cache is destroyed as soon as that CLI script ends, it's gone. So the next time you run the same command from the CLI, there's no caching. If you turn on the file-based cache, all your CLI programs end up being about four times quicker. Not necessarily, depends what they do. Two to four times quicker, I would say, just based on the caching. Never mind the actual increase in speed of PHP 7 itself. So I tested this with Composer. Composer is a big CLI-based script, right? It's a far-based thing. And turning on opcache CLI, the first time when I have to populate the disk cache, it took 0.04 seconds, right? So 40 milliseconds. Now, the second time I ran it, 19 milliseconds, so a bit more than twice as fast the second time I ran it. And without disk-based caching, turning off opcache altogether because opcache doesn't actually help you, right? It's 33. So you take a slight hit on the first time you run it, but then from then on, it's going to be 33 versus 19 milliseconds. And this wasn't to run the complicated Composer thing. This was just Composer help or whatever, the status screen thing. So for more complex operations, it might help more. And the actual files on disk, you saw in my config here, I set my file cache directory to var temp. And in var temp, it actually, you can see the whole structure of opcache inside var temp, right? Inside the far file. So inside the far file, opcache is caching individually all the different pieces of it. I bet most of you haven't actually seen how complex Composer is inside, but it has all this stuff inside it. Because it comes as sort of a nice standalone program right now. It's just Composer. It's a simple little one-program script, right? One file script. It's not a one-file script. There's a ton of crap inside. A lot of it may not actually need actually. All right. Abstract syntax tree. Personally, this is my favorite feature in PHP 7. I've been playing with it quite a bit. And what this means is that internally, we're now generating an AST. And we use that AST as an intermediate stage for building the operators that we then cache and share it memory. But this means that you can go in there and you can ask PHP, hey, give me this AST so I can have a look at it. So I can play with it. I can change it, maybe insert other nodes into the tree. For me, I'm excited about it because of static analysis. And I wrote a little test implementation just to see if I could do it. I have no idea how to write a static analyzer. Zero. But I also had no idea how to write a scripting language. Right? I mean, you have to start somewhere. So yes, I have no idea how to write a static analyzer. It's completely crap. But it works pretty damn well for a completely crap static analyzer. And I've taken a lot of flack over there already. People looking at my code going, oh man, what are you doing? It kind of works. So please write a better one. I would really, really love to have a great static analyzer for PHP. We need one. So please write one. If you're one of the folks who looks at my code and go, oh, I could write that way better, do it. I don't want to be the guy who writes the static analyzer for PHP. You should have learned by now after 20 years in PHP. You don't want me writing this stuff, right? I'm really good at coming up with the ideas and test implementations and so they're pushing people in the right direction. But the actual production code you run probably shouldn't be mine. I take too many shortcuts. Because I mean, I wrote most of this in the weekend and it's completely impossible to write a static analyzer in the weekend. It just can't be done. And when you look at my code, you'll see. Anyway, take this line of PHP, echo, substring, ABC, 1, 2, 3, or 1, 2 as an array argument. Obviously, this is not how you call substring. It makes absolutely no sense to have an array argument as the second argument to substring. So my static analyzer is called fan, not very creative, a PHP analyzer. And minus a dumps the AST. And this is the AST that gets dumped. So there's a statement list that says echo, which is the echo here, obviously. What are we echoing? We're echoing a function call. So we have an AST call node. This at 2 means just line 2 in my code because I had the starting tag on line 1. So this is line 2. And what are we calling? Well, there's a name node that gives us the name of the function that we're called. And this flag, this is name not FQ. FQ stands fully qualified, which just means I don't have a backslash in front of it. So I don't have a fully qualified namespace for this particular call. And we don't have a fully qualified namespace. PHP falls back to the global namespace. So in this case, it's going to look for substring. Well, it's going to look for it in the current namespace. If it doesn't see there, it's going to find it in the global namespace. If I had put backslash substring, this would say name FQ, not name not FQ. So I know I'm calling the substring function here. Then I get an argument list. So this is the list of arguments that I'm sending to substring. And the first one is a very simple argument. It's just string ABC. And that just shows up as the literal string ABC because that's what I have here. My second argument is more complicated because it's an array. So it says it's an array, and it has elements, and then each element has values. So the first one has value 1. The second one has value 2. That's it. That fully describes my little program here. And my static analyzer then goes through and looks at this. And it knows it has a big include file that has all the built-in functions in PHP. And it knows that substring should take a string and an int. And it looks at that and going, uh-uh. Type error on argument number 2 because I walked the tree and I got to here and I said, whoa, I was expecting an integer. And I got to here and I was expecting an integer and I got an AST array node. That's wrong. And my static analyzer can just spit out and say, that's not what I expected. And it's a little smarter than that. It actually does a little bit of generics because it looks at these elements and sees both of them are integers. So it says I saw an integer array and an array of integers. It arbitrarily just checks the first five. So if your first five are integers and your sixth is a string, it will still think it's an integer array. Because we don't have generic support in PHP, there's no, by the way, I mean, you can tweak that number in the analyzer if you really want. You can set it to 100, but it's going to be very, very slow for large arrays. But anyway, so this is my very, very pragmatic approach at building a static analyzer. And it catches tons of things, not just argument things. It just walks the tree and looks at stuff that it didn't expect. Try it. I like it. And Lorna had already gone through a lot of this stuff earlier. I'll skip quickly through this. Return types. This is the syntax colon, the type that you're returning from the function. If you get it wrong, you can get an error, which you can catch if you like. We have coercive scalar typing and strict scalar types. So basically, you can now say on the scalar types, this is a string and it in the float. And PHP will try to course it to those. And if you can do it, even if you send it the wrong types, like you've sent one, then a string and three, as long as you can, PHP is able to course the types without any data loss, then it'll do it and it won't complain. If you do want it to complain, you can turn on in the caller, you can say I want strict types. And then it will complain and give you a fatal error. Even though there's really nothing wrong with passing a string one to something that takes a one, you can have PHP complain and be really pedantic with you. This will probably only work for new code. If you try to turn this on for existing code, your world is going to suck. It's just not going to work very well. For that, I prefer my static analyzer approach. Run the static analyzer against something and start cleaning up. And once the static analyzer runs clean, then you can start thinking about maybe turning on strict typing here and there. Anonymous classes, just like anonymous functions, means you don't have to declare the class. You can just create the class on the fly and use it. So null coalesce operator returns the first true element in the list, right? First PHP truish element or non-MT element. So A and B, right? A is null, B is one. It's going to return one. C or B. Both C and B are set, so it's going to return the first one, which is C in this case. A, B or C. A is null, B is one. So B is going to return A, X or C. And here's where the coolness, where it really solves the problem. It does not complain if the variable is not defined. So you don't have to do a bunch of is set, is not empty checks on this stuff. You can turn this stuff directly into the coalesce operator. Also means if you have a typo here, you're not going to see it. It's not going to warn you. It's just going to be false. So be aware that this is like an if-empty or if-not-empty call in here. Space ship operator. Lots of discussion about which actual spaceship it is. My son tells me it's the Thai advanced X1. Because obviously this would be a Thai fighter if we had chosen that. Thai interceptor, Thai bomber has two circles in the middle. People are saying it's a Thai bomber. It's not. It's a Thai advanced X1. This is all from my son. So if you want to complain, you can complain to him. He's 13. So be nice. You use it in comparison functions mostly. We've had lots of trouble with people not knowing how to write a stable comparison function for things like U-sort. If A is greater than B, then later on B has to be less than A. And some people's comparison functions were not stable like that. A was greater than B and B was greater than A at the same time, apparently, according to the comparison functions because the logic was all messed up. And I mean, you can get it messed up because you basically had to write something like this before. Now you can just toss in the spaceship operator and you will not make that mistake again. Exception on fadals. It's just what it sounds like. Most fatal errors now have been turned into exceptions. So if it does fatal on you, you can catch it and continue or try to continue. You can't really continue, but you can at least catch it and maybe print out better error messages. It also means because it's an exception, now you get a nice, you can do a nice stack trace of where the fatal happened by default. So that part is nice about it. And it's especially nice for chain stuff. I don't have a nice example of that. But if you have a whole bunch of chain method calls and something in the middle of your chain ends up returning null, which is what happens a lot, then you're trying to call a method on null and things blow up. And because you don't realize that something in the chain could potentially return null, then you have to split it all up and call them each individually and then put it together. Now you can just put a try catch around the whole thing and bail out that way. Closure call. Basically, you can force a call on a closure and pass it in the class that you want that call to apply to dynamically. It just turns this type of code into a much cleaner version of the code. Not a big deal. And we've removed a whole bunch of PHP4 features. Stuff that we have been hinting and signaling for over 10 years that we would get rid of. We have finally yanked it. So the old extEreg functions is now completely gone. So if you still have ereg stuff, that library has an update since 1946. So you really shouldn't be using it. And a lot of this stuff is driven by external changes to us. Where libraries we have been relying on for generations simply aren't up to speed anymore. So yes, I get a lot of people complaining about the fact that ereg is gone. But look, the library is gone. Tough. You have to modernize your code a little bit. And it's not that hard to convert ereg to preg. It really isn't. We also got rid of the eval modifier on preg. This one might hit a few more folks because it is a bit annoying to convert this over. It's not that hard. And I'll show you an example of using preg replace callback instead of using an eval. But there are just too many security issues with calling a direct eval usually on data that comes directly from the user. And there are just too many ways that you could get it wrong. So it was a big, big gun that was aimed at your foot. Right? And all you had to do was just touch the trigger and your foot was gone. So that's all gone. And a whole bunch of other things in there. You can read through the list yourself. Most of it is not a big deal. If you have a class named string in your code, you're going to have to change it. Sorry. A few others. Hopefully you don't have a class named string looking at you, Drupal 8. They have fixed that now in Drupal. And those are the ones as well. We now own those words. Sorry. 64-bit integers for the windows. It's very nice for the windows, folks. Because even before, even on a 64-bit windows machine, you still didn't get 64-bit integers with PHP. It took quite a bit of work to get to that on Windows. A whole bunch of integer edge cases, overflows, underflows, have been cleaned up now. Plus, we have also made it possible to have string lengths greater than 2 to the 31st. So greater than 2 terabyte strings. Not quite sure why you would need strings that big, but now you can do it. There's no real reason we should have the limit. We just never really, well, at least I never imagined that you'd be playing with data inside a PHP script that was that big. But people do. I mean, you can do file uploads, you can manipulate it with image functions and things like that directly in memory. And PHP is binary safe, so you can load an entire movie file into PHP and do stuff on it. And people do. If you can do it, people do it. All right. So parser on invalid octals. This one caught, at least in the Etsy code base, it caught probably five or six places in the code where we were doing that. Where silently before, something like 0, 8, 5, 5 would end up just being zero. And you wouldn't necessarily catch them. Actually, it had really good unit testing. Now it's a fatal error. It's a parser when it hits that because 0, 8 is not a valid octal number. Any number that starts with 0 is octal. And you only have 1, 0 through 7 is valid octal numbers, right? It makes no sense to have something 0, 8. It mostly happens in date type stuff, like make time and things like that. We're putting in month and days, literally, and you end up with a 0. Uniform variable syntax. This one, this was to enable the AST. There was just no way to build a clean AST with some of the weird exceptions that we had to the parsing order in PHP before. And the big one that hits you is this first one. That when you have this and then you have an array dereference. So you have an element on an array and you're referencing that inside this. In PHP 5, this would dereference the contents of the belongs to array and find the column element and then use that as the property. And it would access that property, right? Which is kind of weird. Why isn't it left to right? And in PHP 7, everything is now left to right. So in PHP 7, this will now look for the $belongsTo property and then find, so the list, the property in the class called belongsTo and then it will take the element column off of that. You can still get the PHP 5 behavior, but you have to toss in some queries to say, do this part first. Then my static channel is for you and tells you that you might want to look at this. This is PHP 5 code. This is going to behave differently in PHP 7. Now if you wanted it to work that way in PHP 7, that static line is a check is kind of bad, but there's a switch on it that says don't assume PHP 5 code so we can turn it off. This hit me in my presentation system actually because I was going through and very quickly changing my preg replace slash e because I had a bunch of those. I have these weird markups. I have these weird markups so I can toss in the title of my presentation or anything like that into a slide because I reuse my presentations all the time. So I don't have to rewrite my presentation just because I went to a different town or something. I can just put colon minus colon city, colon minus colon and my current city will end up in my slide. So I'm cheating badly there. The way I did that was to just do a slash e and then put in this variable called press and then whatever I found in here. So if it was city, you would look for the city property in my press class. But we don't have slash e anymore so I had to fix it. So this was my very quick hack. So to preg replace callback, my callback function goes and finds the first match and then looks for that first match in the press class. But I made the PHP 7 mistake, right? Because I wanted matches one as one unit. I didn't want press matches and then one on the whole thing. And my static analyzer came up and told me that, hey, this expression may not be PHP 7 compatible. So my tool actually caught my mistake on there and the easy fix is just to toss in Curly's. Other feature, Unicode, code point escapes syntax slash u and then Curly's and you can put in the code point. So there's a right to left and a funny smiley. There's a new Intel char class as well. It's been added to the Intel extension. And we're looking to release in October 2015, hopefully. We released the first beta two days ago, Thursday, whatever that is. I'm in weird time zones. And hopefully if the beta releases go well, we're still on track for an October release. There's some grumbling about some exception handling or things that might delay it, but we'll see. Sorry, sorry, sorry. Release candidate one. That's what I meant. If our release stages go well, we're still on track. We're done with the beta stage when release candidate one and we'll see. So a little bit more on the performance. We had mostly Dmitri, Chen Chen and Nikita working hard on this stuff for about a year and a half. Dmitri for even longer. And the way they did it was they took WordPress and they just hacked away at WordPress. Not touching the WordPress code itself, but hacked away at PHP continuously. So if we just look at the time, this is 100 requests against the WordPress 3.6 front page. And it started off in January 2014 at 26.7 seconds to load this. It was on a slow machine. And then over the course of the year, you can see that they just kept improving the time that it took to load that 100 times. Just going through and figuring out what can we make faster? What can we yank without breaking WordPress? And then if we look at the instructions, the same thing. So this is the machine instructions and it started off at about 9.4 billion trillion. I don't even remember the units here. 9.4 billion instructions to do those 100 WordPress pages. And we ended up at 2.9 billion instructions. So cut the number of instructions by a factor of three. And if you think about it, I mean, we have this big, big complex program. We now say, hey, you only get a third of the instructions to do exactly the same thing and don't break anything. It's not that easy. Imagine your own code saying, look, delete two out of three lines in your code. Throughout your entire code, you only allow a third of the code to do exactly the same thing. For very new code, sure. But for code that has been around for 20 years that people have been iterating on for 20 years, basically, calling them now, you have to do the same thing in a third of the code. That takes some serious hacking. And a lot of things changed internally. So the Zval size was shrunk from 24 to 16. The hash table size reduced from 72 to 56. Each bucket shrank a lot, 72 to 32. So now something like this, where you're continuously appending to a string, another array to an array. In PHP 5, that takes 43 makes of memory. In PHP 7, that takes 6 makes of memory. And when you're moving less memory around, you can do things faster. Much more CPU cache friendly, new memory allocator, similar to J e malloc, much faster hash table iteration API, array duplication. So when you're copying arrays back and forth, it's a lot faster now. There's a fast CPP. So certain functions internally function that are called a lot now has a faster way of parsing parameters. A whole bunch of other things, too. We haven't done the JIT yet. There was a test JIT, but it didn't really help. So the way I like to think about it is we haven't played our JIT card yet. We still can. And when we do look out, if we can write a decent one, of course. So to finish with some benchmarks, don't trust them. Do your own. I have all my test box specs, everything I could think of that you might want to know to replicate my benchmarks. It's in here. All my configurations. Everything is there. Drupal 8. You can see the difference here. PHP 4, 5455, 5656. We got better. Each otheration. We're quite proud of our performance improvements, right? Which looks a little silly now because that's PHP 7 and this is HVM 3.7. This is for 20 requests per second. If we look at the latency at 20 requests per second, we can see that the latency dropped as well. Droped in half. And it doesn't really matter if we go up to more. This is 40 requests per second. We see the same trends, same down at 5 requests per second. So I have it in here for completeness, but basically it matches across the range of scalability. WordPress 4.1, HHVM is still faster. WordPress is an interesting case because both the PHP team and the HHVM team uses WordPress as sort of its benchmark. If we can make WordPress faster, awesome. Anything should be faster. Which isn't quite true. The real reason we use WordPress is that the code is quite simple. Other projects are way more complicated. When you're starting off, you start with WordPress because it's easy to get WordPress running. It's harder to get something like Drupal running because it uses way more features of PHP than WordPress does. WordPress is very thin on the number of features it uses. But anyway, so you can see it's way more than twice as fast on WordPress. But HHVM is even faster. Which annoyed me a little bit. Like, what the hell? All this work and we're still not as fast? So there's a solution to that. Now, the solution is a little bit of a hack. But GCC has this thing called feedback directed optimization. It's basically like a little jit in GCC itself. So what you can do is that we now have support in PHP 7's make file to generate a profile. So you can build a new PHP 7 and type make profgen. So now it sets up PHP to read profiling data. Then run it against the code that you're going to use. So in this case, I run it. If you use PHP-CGI, you can give it a minus T argument that says run this a thousand times. And I'm running the front page of WordPress. Because the front page of WordPress loads in most of WordPress. It includes everything. So as long as it loads the front page faster, it'll load. It'll run most of WordPress faster as well. So I do that a thousand times. Then I go back and I say, hey, prof clean and prof use. That tells GCC, use the profiling data that I generated. So this is now a WordPress specific build of PHP 7. It's probably going to run Drupal 8 much slower. But it's going to run WordPress really, really fast. And you might laugh. But if you're a WordPress shop and all you do is WordPress, why wouldn't you build a WordPress optimized PHP? You should be building your own PHP anyway. You shouldn't rely on some Debian build guy somewhere or some Red Hat build guy to build a generic thing that works everywhere. Because you have a very specific system that runs very specific code. So I don't think it's as silly. And people always laugh at me when I talk about FDO. But I think it's cool. I think it's cool that you can. And at Etsy, I'm going to build a PHP 7 and I'm going to profile against the Etsy ORM because all of our code goes through the ORM. If I can make the ORM just 5% faster, awesome. And I build PHP at Etsy anyway. So why wouldn't I build an Etsy specific or tuned version of PHP 7? Anyway, with that hack, it's now a statistical tie. It's still, I mean, 664 versus 666. But that's within the margin of error of my benchmarking here. So I went from 627 up to 664. And HHVM is at 666 on this one. So it worked. All right. A few others. PHP BB. Again, PHP 7 is way, way faster than PHP 5.6. Media Wiki. This one has been optimized for HHVM. So here we're lagging behind a little bit. I didn't try FDO on Media Wiki. I think we're too far behind to catch up with FDO on this one. We'll see if we can do something on that later. But for now, if you're a Media Wiki shop, you probably should be using HHVM. It's faster. Open cart. We kind of just throw hands in the air and go, well, whatever. You can see, yeah, it's faster on PHP 7, but not by much. HHVM is struggling as well. And the reason we're struggling is that it spends 98% of its time in the database. And nothing we do in PHP is going to make your mice call run faster. Sorry. And if all you're doing is just full table scans continuously on every single request, well, whatever, right? It's not us you need to talk about performance. You need to talk to your database or maybe fix your queries. Wardrobe CMS. This was mostly to try a generic Laravel application. This was just the first one I found on GitHub that used Laravel. And you can see PHP 7 runs Laravel apps quite well. Just about twice as fast as PHP 5.6. Geek log. Another simple app I found. Again, faster. Magento. This one, Magento is tough. You can see the numbers. Another is we're talking about 500 or even 1,000 requests per second. This is the same machine, right? Magento, we're in double digits. Not four digit numbers in here. But yeah, not quite as fast as HHVM yet on Magento. Although there's been some tweaks lately. These numbers are two and a half months old. So we've been improving a little bit. But so is HHVM. Do your own test. Track. Take a tracking app. Again, faster. This was the only one that broke, actually. So I've been going through all these large applications that I just installed and ran. This was the only one I had to fix to make it work on PHP 7. And the thing that broke was again that stupid order thing where they had this, right? And I had to toss in Curly's on it to make it work. So if you see this weird unexplained thing that's suddenly a variable or a property in a class that works fine in PHP 5 and is suddenly empty in PHP 7, track it down and look for big chains like this where you see a property and an array reference on a property inside a class. Chances are you just need to toss a few Curly's in there and it will fix it for you. Cache, it's this downtime app. That's quite nice, actually. Again, twice as fast. Moodle. I couldn't get Moodle working on HHVM. But there are a whole ton of Moodle installations all over the world. My son's school uses it, for example. If you have kids, I bet your kid's school uses Moodle as well. And it is quite a slow application. I think a lot of school systems, system administrators, are going to be happy with PHP 7 for their Moodle. Cenkart, another one that's quite slow because it spends a lot of time in the database. And you can see we didn't get any improvement from 5.3 to 5.6 even though we actually made a bunch of improvements but it just didn't help Cenkart. But PHP 7 does get a bit more. And that's mostly from the memory savings. CPU-wise, it's still doing all the full table scans but because we can now store things, arrays. So it's probably reading a whole ton of crap back from the database and storing it. And by the fact that we're storing less in memory means that we can go a little bit faster. So that's probably where the increase is. Help us test. It's easy. Really easy. There are many different ways of doing it. I packaged up my Dev environment just because I've been doing this for a long time and I have a nice workflow of doing it and switching PHP versions. So I figured, well, let's give everyone that same workflow. So I just packaged it up as a vagrant box. You can install it. Get clone this URL. All right. CD into the directory. Type vagrant up. Takes a little while, especially from the conference Wi-Fi here. Has to download. It says 1.5. I think it's up to 1.7 gigs now, or 1.6 maybe. So do it on the fast connection and then vagrant SSH into it. And it's a standard vagrant box. You can configure it and you can mount shares and all the same stuff. It has a default IP of 7.7. You can change it, of course. But now you should be able to point your browser and you'll have the PHP 7 info box should come up. You can switch versions inside. Just type new PHP in the version you want. So new PHP 5.6. We'll give you PHP 5.6. Dev. If you want the debug version, you can type new PHP 5.6 debug. So it has 20 pre-compiled versions. So 5.3 debug, non-debug, thread safe, non-thread safe from 5.3 all the way up to 7. That way it's easier to test if something that broke in your application. You can quickly switch back to 5.6 and make sure that it's not also broken in 5.6 and has something to do with the environment as opposed to the language itself. I also like it for extension development. That's really fast. Go into the vagrant box and then compile your extension for every version of PHP very, very quickly just by typing new PHP and switching back and forth. You can build any version. To build the latest version of PHP, just type make PHP 7 and it's going to go and fetch it and build it. Same for 5.6 or any of the other versions. There's also a make PHP world. They'll just do everything. Rebuild every version. But 5.3 doesn't change. So there's no real reason for rebuilding those. You can do it manually. PHP sources, directory, everything lives in. You can go in and play around in there. If you want to do your FDO build, which you should. You can use the box to build yourself an FDO. That's where you get it. I think I have about six minutes for questions. Yes, Lon? Is 7 going to improve the traditional long tail of adoption for PHP? I certainly hope so. I think there is more reasons for people to upgrade now. I think there's more competition at the ISP and cloud provider level as well. There are already cloud providers that have PHP 7 support. It's not that hard to do. I don't see any real blockers. In the past, ISPs have just dragged their feet. There wasn't any real demand. The fact that your app will run twice as fast on the competition's cloud or the competition's ISP, I think that's going to be a big draw for someone to spend an afternoon making PHP 7 one of the options that people can choose when they're choosing their PHP version. I think availability of PHP 7 is going to be pretty good. Whether users are going to go after some will, hopefully many will. We've gone to great lengths to make sure that we haven't broken too many things. The things we've broken, we've been trying to shout from the rooftops, hey, this is why we broke it. This is how it's broken. This is how you fix it. The upgrading guide is pretty good. You should read it. I hope we can get folks on to PHP 5 off of 5.5.5.4. There's a lot of people still running 5.3. Remember, the delta from 5.3 to 7 is even bigger. You may not think twice as fast. It's that interesting, especially if you're just like one or two servers running a code. For big companies that can cut their number of servers in half, if they're going from 500 to 250 servers, they can just look at the money involved and say, yes, this is obvious. Of course, they're not going to actually pull out 250 servers. It just means they can use those servers or they can load so many new things into their application that weren't viable before. Anyway, it's easy for a large company to justify this. But for the small folks on one server, if you try it, your app just feels more responsive. Every click just snaps up. Whereas in PHP 5, it gets there. In PHP 7, it just goes, and it just makes the whole thing feel more professional, feel nicer. Even the single server instances out there, I think once you try it and once you see other people's apps, why is his WordPress so fast? Mine kind of drags. It's PHP 7. I should do that too. It's a lot of people who make this kind of get rid of all the versions. Like one app is one and one. For the video, just discussing human nature. Humans are just... It's human nature not to want to change things. My stuff is working. I never want to touch it again because that's effort. I don't want to make any effort. I understand it. Then you do go to a provider, one-to-one. You say if they're still running PHP 4 and your code runs fine on PHP 4 and you're happy with that, maybe you should go to that provider. Of course, you're probably going to get hacked. There's some cost in not wanting to upgrade, not wanting to actually maintain your code over the course of 12, 14, 15 years or however many years ago PHP 4 was. If you can live with that cost, it doesn't bother me too much. I think on the security front, all these recent hacks are actually helping us a little bit because people are getting more paranoid and the non-techies are starting to ask questions, whoa, could this happen to us? The programmers will come back and say, yeah, because we're running on 10-plus-year-old code and you haven't given us the time, the money, the people to actually make this upgrade. Want to fix it? Give us the resources. We'll fix it. I think it will help. We'll see. I don't know. Yeah, so the question is about the file-based opcode cache. Yeah, it'll recognize the fact that it's changed. It keeps track of that for even the shared memory version. It keeps track of that. If it's changed, then it'll go and it'll invalidate the disk version and it'll redo that one. So the question is, we're going to turn PHP into a compiled language. No, we're not going to do that. You could theoretically distribute the file-based version. I showed you the whole bar attempt structure. You could theoretically package that up and send to people. I don't really see why you would want to. We already have FAR, which kind of does collect all this stuff in. And the very first time you hit it, it'll build the compiled version. So shipping the compiled version, yeah, you could do it if you wanted to. But it's not going to hide anything. It's not going to help you make sure people don't steal your code. And that's usually the direction that this question leads to, is how do I hide my code? The answer is you don't. Yes. Yes. So what's our plan for porting current extensions to PHP 7? They are well underway and most extensions, all the core extensions have been ported already. Now, and most of the peckled extensions have been ported. There are a few stragglers still. Now we're tracking down GitHub things that are way outside the scope of the PHP team. And we're poking those folks and asking them, hey, what can we do to help you get this up? And there's a tracking page. There's a Go PHP 7, EXT. If you look for that, you'll find big document, big table of all the different extensions we know about and what their status is. There's an RSC channel on FreeNode, Go PHP 7-next. EXT, right. Go PHP 7-EXT. And you can ask about that in there. Don't talk to Laura. She's championing that stuff. Yes. So currently, so the question is, can you by default get EXT, AST out of PHP? No, you have to add an extension. We're currently not distributing that extension with PHP, only because it's not really quite ready yet. Nikita wrote it. It's on GitHub. It's called PHP-AST. It's very small. It's easy to compile. We probably will include it in PHP 7-1. It just wasn't ready by the time we froze. We had the code freeze. He wasn't ready for it yet, but it will be in there because it should be part of PHP. Not enabled by default, but it should be easily available. And these days, it really is easily available. It's not hard to. People who are at the AST level can very, very easily build PHP-AST. Yes. It's called fan. GitHub.com slash our leader of PHP. What can you do if PHP 7 segfaults when you run your stuff on PHP 7? Well, your first thing is get a back trace. We have some instructions on how to generate a back trace. If you get a core file, it's easy. If you don't get a core file, if you can narrow down the piece of code that doesn't do it from CLI, then it's easy because you just type GDB PHP and run. If you know how to do a back trace, that's the answer. File a bug, include the back trace. And if you can narrow it down to the snippet of PHP code, Chen Chen will fix it within like 20 minutes of you filing that bug. Time zone dependent. He's in China. If he's sleeping, it will take him a little longer. But a really specific bug report that says this piece of PHP code generates this back trace on this segfault, which generates this back trace, he's all over those. He's so fast at fixing it. Now, if you send a report that says, well, I have this huge application, it's proprietary, I can't tell you what it does. I can't show you the code, but it's segfaults somewhere and I have no back trace, then it's going to take a little longer. Something else? Yeah, I'm filing a bug and put the link in, sure. Okay. Are we out of the questions? Really? Are we out of time? Okay. We're out of the test. Questions to end time. Thank you very much.
2015 marks the 20th anniversary of PHP and it also marks the release of PHP 7. PHP 7 brings drastic performance improvements along with a number of new features including optional scalar typing, anonymous classes, and a couple of new operators. Rasmus Lerdorf
10.5446/19603 (DOI)
And now it's time for the introduction by our Vice President Professor Geisler. And I give the word to her now. Thank you very much. Good morning everybody, dear ladies and gentlemen, dear conference participants, here Professor Tannenbaum. A very warm welcome to the Bonn-Reinzig University of Applied Sciences here on our campus in St. Augustine. I welcome you to your anniversary conference actually, the TENS Frostconn. And we are happy to host this conference here and that we can welcome again such a large number of you here in St. Augustine and also some renowned experts in the field. Not only from Germany, but from many other countries around the world. I'm a chemist myself, so obviously my understanding of what you are actually doing and what your topics of research are is very limited. What I understand however is that your work makes a difference. Your work has an impact on society and that I understand on a global scale. Your work enables users around the globe to use a free and secure tool for their education, research and work. So that is really a difference. You work for the benefit of the society and this is also as a university of applied sciences the goal of the Bonn-Reinzig University. We are educating young people and preparing them for the challenges of the globalized world. We just celebrated here also an anniversary. Our 20th anniversary we celebrated and we developed from a university which was planned for 2500 students to more than 7600 students now in 2015. So we call that a success story and it's not over yet. We have a lot of plans for the next years. So I know that all of you are waiting and looking forward to the lecture of Professor Tannenbaum. I will end this small speech to you now and once again you are very welcome here on campus and I hope you enjoy your stay here. You have a very successful conference with a lot of interesting discussions and I thank you for your attention. Thank you very much. Thank you.
A welcome by the vice president for research and young academics of the University of Applied Sciences Bonn-Rhein-Sieg. Prof. Dr. Margit Geißler
10.5446/19593 (DOI)
Thank you very much for inviting me here. I was invited because I was told I gave a talk at the first Froscon ten years ago. And then some people have mentioned I've been to Froscon since, but I don't really remember because I go to a lot of conferences and when you get to be 65 you tend to forget some things. However, with this talk I try to remember everything, but sometimes I don't remember everything. So some people may object to some of the things I say, but I try to be objective about things. So if you see something that you disagree with me you can talk afterwards, but not during the talk because they have a lot of slides to go over. And that's the second warning. This is a very long slide, it's about 105 slides, and I'm going to be talking very fast, but they're going to be recording the whole thing so you can go back and look at it later. I often also do not talk about the things which are on the slides at all, and so that curious the problem. You have to read the slides and listen to me at the same time, and often it's not your native language. There's little symbols throughout this, little square symbols, and this particular one is a square beer mug, which has beer mug number zero in it, and that means it is more to the story. So if you catch me afterwards with a beer or something like that, I'll go into whatever you're interested in. Then the more mugs of beer there, the longer the story, and the more interesting. And there aren't any more symbols in this particular talk. For those of you who don't know me, I've been in the industry since 1969, I started programming back then. My undergraduate degree was half electrical engineering and half business, with a minor in these computer things. And I'll go into more about that later on. Then I got my MS in computer science in 1977 from Wetzel-Lear Polytechnic Institute. I've been a wide variety of different jobs. I've been a programmer, an educator, systems administrator. But one of the things I like to think about and proudest about is the fact that I'm pragmatic about things. I try and get the job done, and I think that's what free software is all about. So we're going to go way back in time. So here is 1642. Blaise Pascal was a young man. His father is an accountant. He's trying to help him do calculations to be more accurately, faster, and things like that. So he events and automated adding machines. Now, programmable machines didn't happen until a little bit later. And most people think of music boxes and clocks as programmable. They were, but typically only like one to two to three songs. But then in 1801, they came along a loom, a Jacquard loom, which could weave the pattern into the cloth. Now, up until this time, they did have power looms, but the looms all wove the cloth the same, and you printed the pattern on them. But the Jacquard loom had holes and cards that went across the top of it like that. And so the warp threads could go up and down and you could actually program into it the pattern. And Napoleon was so fascinated by this, he called it the marvel of the day. Now, about 1860 to 1929, player pianos, Nickelodeons of Things, came into being. I actually collect player pianos and Nickelodeons, so ones just like this work off of paper rolls. It's a very, very fascinating type of thing, but it is programmable instrument. Now, about the 1860s, over the 1860s, Wooder wheels and textile mills and things were there, but there were water powers. And you had to have your mills very close to your river in order to have the power come in. There was no electricity to drive them. And then James Watt came along and invented something called the steam engine. And this allowed you to build your factories any place you wanted to because the steam engine would provide the power that Wooder had provided before. Now, there's a little bullet there that says that the water wheels and textile industries led to intellectual property laws. Well, actually, intellectual property laws were around a long time before that. The written patent came about in Florence, Italy in the year 1300. We know that for sure. But the British took this to its extreme. And if you were caught with a pencil and paper, if you were an American caught with a pencil and paper inside of a British textile mill, you could be executed because they thought you were trying to steal their intellectual property and take it back to the colonies. The colonies at that time were the people who grew the flags, grew the wool, grew all that stuff. And then Great Britain would bring it over to Great Britain and make it into cloth and then sell that back to the colonies. So if the colonies could do this, Great Britain would lose a lot of money. And because of all of this, in Great Britain, there was this feeling that machines were going to solve the problems of the world. And this led a person by the name of Charles Babbage, who was a, believe me, a civil engineer or mechanical engineer at the time. But he was sitting there in his engineering office working with a set of tables and books and a slide rule to do calculations on building something. And at that time, what you typically did was you had another engineer sitting side of you doing the same calculations just to make sure you came up with the same answers because you were likely to make a mistake. And they were going through doing their calculations, doing it, and they came to one part and they just could not agree. They went over it and over it and over it and they couldn't agree. Finally, they realized that the two different books they were using with the tables of science, coscience, tanchists and everything had a different number in them. Somebody had made a mistake making the book. And it was either the person who did the calculation had made the mistake or the printer had made the mistake. But in either case, this horrified Charles Babbage because this meant buildings could crash, bridges could be destroyed. This is a terrible thing. So he decided he was going to create a machine that could do these calculations and print the book at the same time. Or print the printing page that you could then use at the printer. So there would be no issue of transcription errors. And he started building what he called an analytical engine which was very extremely complex. It really strained the capabilities at a time of creating gears and things like that. He got about one-third of the way through that. And then a brain storm says, oh no, I don't have to create something that complex. I can create something called a difference engine. So he started all over again. Of course, he had to throw away everything he'd done with the analytical engine which pissed off his investors. But in the meantime, he ran this very nice young lady who was the daughter of Lord Byron and she was a mathematician. And that was very strange back in those days because if you were a lady, you didn't do anything with math. Oh my God. You know, all you do is play the piano or the organ in the parlor or something, you know. But she was a mathematician and she was fascinated by this machine and she said, I'm going to write some programs for it. I'm going to set up how you set up the gears and everything to do these different things. And she did. And so this is one of the reasons why we think that Countess Adelovelez was actually the first programmer. Now, out of this, Charles Babbage never finished either his analytical engine or his differential engine. And he actually died in poverty. But there were two other people who looked at what he had done and actually built a couple of the difference engines. There were two machines produced. They actually did create some books, but they were very not, they were not financially successful. So that kind of like died away. Now, in 1884, there was a problem in the United States. Every 10 years, the United States takes a census and they count up the people in the United States and they try and ask questions about them to figure out where we should be putting our money and investing stuff. The problem was that every time we took the census, it took longer and longer to do all the calculations and stuff. So we'd be doing the census in 1990 while we were still working on the numbers from, obviously, 1890 while we were still working on the numbers from like 1870. And this was going to be a problem. So the government went to this person named Hollerith and said, can you make a way of doing this faster? And he said, sure, I think we can create these tabulating machines so we can get the answers and punch them under these cards, put them through the tabulating machines and come up with the answers in a much shorter period of time. Out of that came a whole series of tabulating machines and some of them were programmed by plug boards like the plug board you see up there. And, you know, I've actually programmed one of these things. That plug board, in effect, represents a program. And as you move the wires around, you move them according to the time sequence that the machine is supposed to be working and what the machine is supposed to be doing across. And if you leave out a step, you have to move all your wires down, which is a pain, you know, and stick in the step as you're going along. And after a while, this created what we call the original spaghetti code. Now, in 1935, there was a young man in Cambridge, England named Alan Turing. You're probably all familiar with him by now. And he was actually interested in trying to create a machine which could duplicate the human mind. He knew that the mind was made up of some relatively simple thing, neurons, synapses, but a lot of them. And he said, gee, you know, maybe I could duplicate this. And so he started to think of a series of different ways of doing that. And of course, there's two types of problems in the world. There's solvable problems and unsolvable problems. And the unsolvable problems are things like what's the last number of pi? What's the last number of E? All that type of stuff. There is no answer to that. But the solvable problems should be able to be solved by a digital computer if you give enough time and memory. And that's basically where he thought and he came up with this machine concept, which is called the Turing machine. Now, the Turing machine was hypothetical, but people started looking at this and say, yeah, this is kind of an interesting concept. And we think that we could do every mathematical calculation that can be solved using one of these machines. Now, as a person in Germany by the name of Konrad Zuse, who was watching all this type of stuff, and he decided that he was going to build a programmable computer. Now, back in those days, this was built mechanically or maybe with relays and stuff like that. They had that and he built the first freely programmable computer, but it was a little bit unreliable because of the mechanics made. In 1937, there's a guy named Claude Shannon who wrote a paper about symbolic arrays of using relays and switching circuits to do this. And basically invented the concept of using logic gates with Boolean logic and electronic relays to build these types of computers. And then after that, George Stibbitt's at Bell Labs really built one using this relay-based computer called the Model K. Now, during the war, as you're again, you're probably aware of, do some movies and stuff that have come out, there was a place very close to London called Bletchley Park, and they were trying to break the German enigma code, which everybody considered to be pretty much unbreakable. Alan Turing was brought in to work on this. He's built his bomba on the basis of some work done by some Polish mathematicians who managed to escape from Poland with an enigma machine and with the work they had done and bring it to England for them to go. Now, where Turing really did the improvement on this was that he made his machine parallel, so he could do things in parallel, and the second thing was he made his machine figure out when it was going down a wrong path and stop. So it would never go down a path any further than it would, you know, it didn't go all the way down every time. It would stop when it recognized it was going down the wrong path, and this sped up the whole process of solving the code. And he used math to create these shortcuts, and it was so successful after a while that Britain had to fake some of the results because they were reading all of the German enigma messages from the Word Department, and they could have intercepted everything, but they said, no, no, we can't let the Germans know that we've done this, so they kept faking messages. In the meantime, Konrad Zuz is continuing away on building computers, and he actually built one that could do floating point arithmetic. Now, some of you may remember the 386 computer system, when it first came out, it didn't have floating point. You had to buy a separate little processor to fit in there to give you floating point, because most of the stuff, most of the work being done back in that day was digital work, but it was integer style of work and very, very little floating point. Well, Konrad Zuz actually built a floating point unit, but it was electromechanical relays with cams and things like that. It was the first Turing complete machine, the one that could do everything that our Turing said you could do in a Turing machine. However, that of course was in Germany, kind of behind the wall, and in the meantime, over in England, they were still working with non-Turing complete machines, trying to build one that could actually hold its own program in its own memory. Back at Bletchley Park, where it was still very, very top secret, the bomb was falling behind, because the Germans war machine had come out with a better enigma machine called the Lorenz. It went from three rotors to five, and that made it much more difficult to solve it, so they needed something that would be thousands of times faster than the bomb in order to be able to solve these messages. And so they were looking around, they needed some components that would not attract the attention of the Axis powers, that they were doing something. And so they used components that were used in telephony, relays, tubes, and things like that. And they were in an area that was very strong with telephony. There was a lot of telephone lines coming in, so it didn't raise anybody's attention that they were ordering all these tubes and relays and things to build this first machine called the Colossus. But it was still not a machine that was Turing complete. It couldn't hold its own program in its own memory. It had to be programmed on a paper tape. In the meanwhile, back in the United States at Cambridge in MIT, there was a person by the name of Howard Aiken, who was a commander in the U.S. Navy, and he was going to build a machine that could do ballistics. Now, ballistics, for those of you who are not familiar with it, is the thing of being able to shoot a gun, have a bolt go a long distance, and actually hit the target. So if you've ever watched movies of World War II, and especially people in the front, you see these very big guns, and then there's two people right next to them, a person with binoculars and a person with a thing that looks like a telephone. But what is a telephone? It's a field telephone. And actually, that circuit goes all the way back to a place called Princeton, New Jersey. Because before you fire that gun, you have to say, I'm going to fire this shell, maybe two miles. The shell weighs 65 pounds. I have stacks of gunpowder of various measured-out quantities. I'm going to shove that into the back of the gun. Now, I have a choice. I can fire my gun parallel to the ground. Well, that doesn't work very well. Gravity says that the bullet is going to fall at 32 feet per second, no matter how fast you're shooting in that direction. 32 feet a second, boom, it's going to blow up right there. You guys have wiped out. Or I can shoot it straight up. Yeah. Or I can shoot it at an angle. But what angle? I don't know. That's ballistics. Now, I'm shooting it. It's going to the air. The wind is blowing. Well, it's going to be in the air a long time. It's a big shell. The wind is going to blow it off target. So I have to account for windage. I have to shoot it back in the opposite direction so the wind blows it across. Maybe it's raining. Maybe the air has a certain density. All these things go into, of course, it's where you are, where the enemy is. All these things go into ballistics. Now, the people firing the guns don't know how to do this. They are typically 17 year old males who were lucky to have gotten to high school. And so they're going back to Princeton, New Jersey, where there's a whole bunch of women sitting in a room, or mathematicians sitting in a room, and they've got books of ballistics, and they have hand calculating machines, and they are calculating away with all these ballistics. And they pull back with all this information for the gun. Now, you're there, you do all this stuff, elevation all this stuff, you fire the gun, you sit there watching with the binoculars to see where the boat hits, and if it hits the target, hey, we're done, it's great, it's fantastic, if it misses the target, then you have trouble. Because the enemy also has a gun, they also have binoculars, they also have a field telephone, and now they know where you are. And they are motivated to fire their gun and take you out. So if you're smart, you start to move your gun, okay, and they're moving their gun. And the wind is changing, and birds are flying overhead and crapping on the bullet and stuff like this. And in the meantime, you're calling back all this information, and this woman back at Princeton, she's really under pressure to come up with that next thing, because now you've told her how far she was. She's going to make the corrections so you can hit that gun. Fast. So this is the thing that inspired Mr. Aiken to make a machine that would do this calculation extremely fast and extremely accurately to replace this woman in Princeton. Not replace him, how can you replace a woman? But the problem was he made the machine, they made the machine, but then the Navy says, okay, program her for ballistics, and I can't. I'm an electrical engineer. I don't know anything about ballistics. Nothing, nada. Oh, well, we'll bring this woman up from Princeton, New Jersey. She said, Navy Wave, I'm not going to have a woman on my team. I'm in the Navy. We don't have women on our teams. Now, I don't want her. Well, unfortunately for Howard, he got pulled away to Washington, D.C. for a couple weeks, and up came this woman from Princeton, New Jersey, a lieutenant in the Navy Wave, by the name of Grace Murray Hopper. And she taught herself how that computer worked, and she taught herself how to program it, and in two weeks that Howard Aiken was gone, she programmed that thing, and not only that, but she whipped his crew into shape. So when Howard Aiken came back, he finally had to admit that Grace Murray Hopper was more of a man than he was. And they actually got together. They formed a very good team. She actually wrote one of the first programming manuals ever, and they went on to food due to Mark II, and then she went on to do the ENIAC afterwards, and out of this came some pretty interesting terms. First of all, that group, up until this point, you may have noticed all these names, these things were electromechanical, calculating device, you know, really long names. Well, they needed a shorter name. And so just so happened that the Navy term for these women in Princeton, New Jersey, who were doing the calculations of ballistics, their official term was computer. And so they became computers. The second thing was when these machines were going, these machines had a drive shaft that went up through the center. The drive shaft turned three times every second, so the cycle time was 333 milliseconds, and the drive shaft kept everything coordinated. You had relays, you had cams. This whole thing sounded like a cable car going along. But then when it made a mistake, the whole thing came to a halt, and it sounded like the cable car. It crashed. Crash. Computer crashed. Today when computers crash, you don't hear anything like that, do you? They're quiet. They don't do anything. Crash. Okay. Finally, on the Mark II, it was late night in August, very hot, no air conditioning in the buildings as before air conditioning. The windows are all up. Mark II was having some problems. Grace Murray Hopper came along. She was looking inside the computer. Oh, by the way, I should tell you, this computer is about 70 feet long and about 8 foot tall and about 4 foot deep. So she's looking inside the computer, and she sees a moth stuck in the relays, and she takes a pair of tweezers, and she pulls the moth out, and she goes over to the logbook, and she says, I found the problem with the Mark II. There was a bug in it. And although the word bug had been applied to other things in the future, this is the first recorded time the bug was applied to a computer. Meanwhile, back in Germany, Conrad is working on the next group of machines. That was binary and floating point. But unfortunately, after the war, he didn't get the credit. He should have gotten for that. Now, when I was going to school in 1969, I was taught that the ENIAC done at the University of Pennsylvania was the first electronic digital computer, and it was done in 1946. But the reason I was told that was because Blakley Park, Bursley Park, was still under classification, was still classified. Nobody knew about the work that those people were done. And after the war, all of it was completely destroyed because Churchill was afraid that the war might start back up again, and they didn't want the German military to know that they had broken the enigma code. So all of the work that those people had done was not really disclosed until 1970. And so if you're looking at textbooks about computers written before 1970, you'll see the ENIAC prominent as the first electronic digital computer. After that, it gives credit to the Colossus. Back in Cambridge in 1948, they have a small little computer called the Baby Computer, and they stored the program in a cathode ray tube where you could draw the values on the actual cathode ray tube. But when you wanted to erase it, you had to erase the entire cathode ray tube at one time, so it was kind of inconvenient to use it. In 1948, Turing wrote a book called Intelligent Machinery. This is, again, willing him to go on still thinking about modeling the human mind with these computers. And he wanted to be able to program a computer just by rewarding it and punishing it when it got this bad code. So he was kind of way ahead of time. The ENIAC in 1949 was the really the first practical stored program computer where it could store its program in memory. It was actually using tubes filled with mercury to store the memory. So there would be a transducer at the bottom that would create a vibration in the mercury if it was a 1 or lack of a vibration if it was a 0. That vibration would move up through the memory at the speed of sound through mercury. And then when you get to the top, there was another transducer to test whether there was a 0 or 1 at that point. If it was a destructive read, it wouldn't bother to reproduce that at the bottom. If it was a non-destructive read, it would. So eight tubes of mercury is a bite going across. By the way, back in those days, they didn't have a concept for a bite. There was an argument for a long time as whether a bite was six bits or bite was eight bits or whatever. Half a bite was a nibble. We won't go into that. But Maurice Wilkes was the head of the ENIAC project. You'll notice there's a little beer mug next to him. I got to meet him many years later when he was the person leading me through the Museum of Computers at Digital Equipment Corporation. And all you can say is, thank you, Dr. Wilkes. Meanwhile, 1950, Turing comes back with his paper about artificial intelligence. We described how can you test if a machine is artificially intelligent or not? And I think most of you are familiar with that test. After this, companies started to get up and say, hey, maybe we can start to build these computer things. And a variety of these companies are still in existence and some of them are gone. All this time, machines are being programmed in ones and zeros or binary code or maybe assembly language. And Grace Marie Hopper said, you know, I think that we can actually program these machines in a higher level language. And I think that's something much closer to English or a native language. And people laughed at her. So she created a couple of simpler languages like Flomatic and she did a couple rounds of that. But then in 1959, she headed up a team to create the language Koball. And about the same time, there's John Backer said IBM who created a language called Portran. And that was those are languages of first-largeing people along the line that you don't have to program the machines in ones and zeros all the time. Now I lied. There is another symbol. And I'm going to introduce this as I go along. This is called the urban legend. And I'm going to debunk some urban legends for you. So when you hear them the next time, you can say that's not the way it happened because Mad Dog told me it wasn't. Yes, that is me in my monks robes in front of the blue screen of death. So the first thing I want to debunk is this concept of lock in from vendors. I mentioned all the vendors there. People say all these vendors were trying to lock in their customers with all of these different operating systems and architectures and stuff like that. They were just trying to get their customers that they couldn't go to some other company. I was there. We never talked about that. I've just demonstrated to you a whole bunch of machines who had extremely small memories if they had memories at all. They ran at extremely slow speeds. We were just trying to help people use those incredibly expensive computers. And to think about trying to put a multi-purpose operating system into that that could do all sorts of different job loads was pretty hard, if not impossible. Now, Digital Equipment Corporation, in the period of about 1960 to 1970, had a little computer called the PDP-11. We had 11 different operating systems for that. If we were trying to lock in customers, we only would have needed one. But we had an operating system for real-time work, an operating system for batch, an operating system for time sharing, an operating system for educational use, an operating system for health use, all these different operating systems to try and make this thing, this computer, easier for our customers to use. Another little myth I'd like to get over with, and you can use this a lot, I hope, is that free and open source software is some type of new thing, some type of hippie new age thing that came about in the 1990s or even the 1980s. Back in those days, there were few professional programmers. Programmers were people who had problems, and they were writing programs to help them solve those problems. They were electrical engineers, mechanical engineers, civics, business people, educators, stuff like that. That's why they were programming. And then when they got finished with their program to solve their problem, they said, what am I going to do with this? Now, I've also showed you one other thing. All these computers were different. There was no common architecture, no common instructions set or anything like that. In fact, even from the same company, oftentimes the next computer was completely different than the line before. Well, the operating system, if it had one, was completely different than the one before. And so a lot of these people were writing their problem, their code for a very specific computer for solving a very specific problem. And there really wasn't a market for them to try and promote this program to a whole bunch of users. Because not only that, there were very few users. These machines were incredibly expensive. Very few people could afford them. So they said, now I've finished this program, what am I going to do with it? And this is why there were virtually no computer science degrees back at that time, because you would be in the curriculum of the university. You would be studying physics. You'd be studying electrical engineering. You'd be studying this. And you'd be doing this computer thing. Now, I was a university student in 1969. And it cost the software if you could buy it, and it wasn't shrink-wrapped at your local computer store. That's because there were no computer stores. If there was a computer store, you would have needed a 20-wheel tractor-trailer truck to haul your computer home. You'd need three-phase power to plug it in. You'd need a 20-ton air conditioner to cool it. No computer stores. But there was software you could buy. And the software was pretty freaking expensive. $100,000 for a compiler. And I was a university student. I didn't have $100,000 in my pocket. But I did belong to this organization called DECUS, the Digital Equipment Corporation User Society. And they had a whole bunch of users who also were programmers who wrote programs to solve their own problem and would contribute it to the library. And then I, as a student, could take $15 out of my pocket, send it to DECUS. They'd give me a paper catalog of these programs, which I would look through and go, Oh, man, a text editor. An assembler. You know? And this is going to go when this little computer right there, that's a PDPA computer. It had 4K 12-bit words of memory. And it ran maybe 50,000 instructions a second. And it cost only $80,000. And we had two of them in our lab. And next to it is the ASR33 teletype, which could read or write paper tape at the blazing speed of five characters a second. Now, if you think about that, your 3,000 character program is only going to take five minutes to read or write in, you know? So that's a concern. This is why in the early days we did write comments on our code. It wasn't because the comments took up that. It was because it took up more paper tape. And more time reading and writing on the ASR33 teletype, okay? Now, like I said, I could find these things and I had to send away money. $5 for the text editor, $15 for the assembler. Why the difference in price? Longer paper tape for the assembler, okay? But that was still a lot of money because back in those days a pitcher of beer was 50 cents. So I had a choice. Text editor or 10 pitchers of beer. I think you can see what direction. No. But then I would get the paper tape. And because this was free software, they weren't charging me for the software itself. They were charging me for storing the software, for replicating the software, for mailing the software. This was free software. I could make copies of it. And so I went to the school store and I bought some new paper tape. I stuck it through my ASR33 teletype. I duplicated it and I sold it to my roommates for a dollar or a copy. And so by the time I made 10 copies, I not only had paid for the original program, I now have paid for all the new paper tape, but I have another 10 pitchers of beer. Now is that time I had a person, a professor who was teaching me some of the aspects of computers who said, Mendog, you'll never be able to make a living as a professional programmer. Now what he meant was a programmer who was writing programs for somebody else. They're not writing the program for themselves. They're not writing the program to solve their own problem. They're writing a program for somebody else. And back in those days, it's not what you did. Yeah, there was a few people that did that. If they worked for IBM, they were to compile it, but they used to compile it themselves in a lot of ways. But you didn't write programs for other people. You wrote programs for yourself. Now I've been writing programs for other people for a long time. I'm still trying to figure out if he was right. We'll see. I still have a few years left to go. We'll give him one to that later. So it's another thing that happened in 1969, besides me being a student. UNIX came about 1969. Two people, Ken Thompson and Dennis Richie, started this thing in New Jersey called UNIX. Ken Thompson had been working on a project called Multix. He was taking off that project because the telephone company is a monopoly. Okay. The telephone company can't have anything to do with computers. Okay. This is Congress saying this, by the way. But Ken Thompson comes back, finds a PDP7, not in the hallway, kind of cast off, gets a group of people together to start working on this. Now you notice there's a beer mug right next to Douglas McElroy's name. I want you to remember that for a little bit because we hear all the time about Ken and Dennis, and rightly so. But Douglas McElroy got, I think, short shifted. They'll get into that in a moment. They wrote the first UNIX system in assembly language. Now, and it was across assembly language because they wrote it on one computer. They had it assembled, created the binary tape, took it over to PDP7, booted it. It wouldn't work. Then they would play with the switches on the front to look at what was happening through the registers and stuff like that. And they would go back and change it and continue going. And finally got it going. And why was Ken doing all this? Because he wanted to play space travel. Space travel, when an ASR33 teletype, it was fun. Okay. And after a while, the PDP7 kind of ran out of steam. So they went and they got fined a deck PDP11. Now this, I should have had another beer mug next to that because they couldn't get anybody to buy them the PDP11 at Bell Labs. Because this was not exactly what the telephone company was paying them for, although it was for pure research, they couldn't get anybody. They finally found one department that had all the money in the world and they really didn't care what result came out of it. And that was the one who financed the PDP11. It was the legal department. And that's one of the reasons why UNIX has so much textual-oriented type of stuff, because Ken and Dennis convinced the legal department that they would be able to write their legal briefs on this and print it off and be a lot easier. I wanted you to picture in your mind a lawyer sitting down and using ED, not EX, not VI, not EMACS, but ED to type in their briefs and then format it with T-Rough. But that's what they did. Now, in pointing all this stuff back and forth with the PDP7 to the PDP11, of course, machine language and PDP7 would not run on the PDP11. So they had to rewrite the entire kernel in PDP11 assembler and then they got all done with that and they said, oh, thank God we've got it over there. But then somebody went on an Interdator 832 and Dennis said, that's it. I'm going to write C. We're going to make this thing portable. So actually he wrote C for the PDP11 and they compiled, they rewrote the kernel again and made it so that they had most of it written in C. But the problem was when they went to the Interdator 832, they realized there's more to portability in an operating system than just the instructions said. You have things like buses and stuff like that, memory management systems. And so they started to break the operating system apart into different parts that was to make it more portable over time. And at the same time, they started to invent little commands to go with this and a command interpreter. Of course, a command interpreter turned into a shell. The commands themselves use a strange construct called pipes and filters. And this is where Douglas McElroy came in. Douglas McElroy was the person who conceived the pipes and filters. And a lot of us, when we think of UNIX, we think of pipes and filters and the shell and stuff like that. It was Doug McElroy who did that. Doug McElroy was the head of the department. He hired Ken Thompson and Dennis Ritchie in Debell Labs. He recently retired after 50 years in computer science. And he's now teaching at Dartmouth University in New Hampshire. And he often does not even mention to his students what he did. Also in 1969, the Arpanet was started. It was the last time I ever shaved. And little recognized, except in Helsinki, Finland, to two people who happened to have him lead his tour of Valls to Sport. We'll hear a little bit more about him later. Now, about that time, UNIX escaped. And escaped to universities and large government labs. And some commercial companies like DECK and SUN started to give support to it. They liked the time sharing. They liked the fact that they could have security between the different people in the system. They liked the multiprocessing, all the different things. And the most important part was not only was the software portable across hardware, but the users were portable across hardware too. Now, about this time, various different systems started to come out for these weak, miserable Intel chips. Things like the Atari, Kim One, Commodore-Pad, they used various chips from various pieces. We had the Cosmic Elf that hooked up to an analog TV screen. A lot of them did that, you know. And recently I came across this little meme on the net. I grew up in the era where you had to go to channel three to play video games. And believe me, so many people loved that. And I put it on, I put it as, Mad Dog, what's a channel? Is that like a URL? I don't know. CPM, the MIPS Altair machine, the Osborne One, K-Pro, all of these were computer systems that came out. A lot of them were using CPM. CPM was an operating system that was delivered in binary only form for these different machines. But about 1976, the Apple started up in a garage, Apple One, Apple Two. Apple One sold for $666.66. Evangelical Christians didn't like that. And about the same time, IBM said, hey, these computer things are getting really neat. The price is coming really down. It's only $20,000 for a decent-sized system using your five-and-quarter-inch floppy disks. But they were mostly for professional work, because very few people could afford to bring these home into the home unless they were going to be using them to extend their work hours at home. So most of these were ending up on the desks of businesses. Now, about this time was when the hardware was dropping like a rock, but the software was still really expensive. And remember, I said it paid $100,000, or I would have paid $100,000 for a compiler except for Deacus, because the software was being written by contract. You, the programmer, would come together with the customer, and you would do things the customers say, I have this criteria for my hardware. These are the things that need my software to do. This is how much, you know, and you would say, well, this is how long it's going to take me to do it, and this is how much I'm going to charge you for doing it, and you would really negotiate all this type of stuff. You come up with a contract, and then you write the software. If the software didn't work, well, then you weren't paid for it. If the software was late, you were paid less for it. If the software didn't have good documentation, you might not be paid for it. That was the way we did software. But what this is being replaced by software as a product. Somebody someplace said, this is what I think people need. I'm going to get a whole bunch of engineers together to do it. I'll create the one image of it, and then I will start stamping that out like cookie cutters and selling it. A friend of mine came back from Redmond, Washington after visiting Microsoft in the early days. His face was white as a sheet. He said, John, they're printing money up in Microsoft. It's actually going on to black plastic disks, but they're printing money, and that's what they were doing. And this is the point where computer stores started to come in. I still remember my first computer store. I walked in there. There was an IBM. There was an Apple II, and there were three boxes of software on the shelf. One of them was MS-DOS. One of them was a modem program to allow me to attach my modem and dial up a bulletin board. And another one was SuperCalc. That was it. And that's where computer stores started to come in. Now, the problem with production software is this. I write my piece of software. If I'm trying to meet 100% of any customer's needs, that's really hard. If I'm trying to reach 100% of all the customers in the world, that's also very hard. So typically what I aim for is 70% of the needs of 70% of the world, and therefore I come up with 49% of the world's needs. You see a problem. And this is why when we have 2.5 billion computers in the world, we have this really huge gap between the functionality that we really need and the functionality that they're willing to deliver to us. The other thing about this is there's 7 billion people in the world, and I don't know what operating systems the other 4.5 billion people are going to need. Now, another little fable that people have is, Unix was free. Never was free. Ken Thompson would take around his tape and show it to everybody. Everybody even made copies of it, but back at AT&T, the lawyers were dripping blood out of their mouths. And when they finally started to sell this as a commercial product, it was $160,000 per CPU for you to put that code on there. And you had to tell them what the serial number of your CPU was. If that CPU went down, you had to tell them what the serial number of the replacement CPU was before you could move the code. And maybe if you notice, the serial number of your laptop right off the top of your head doesn't even have one. I don't know. So a binary license came out of this. Sun Microsystems beat up AT&T really bad so that Sun said $350 license and unlimited users, and then more and more companies started to go with this binary license only. And that's what happened in 1981 that these companies started to put out this Unix systems as binary licenses. And there were two main flavors of that. AT&T System 5, which had a dial-up store and forward type of networking called UUCP. It was a swapping system, not the man-page virtual memory. Two main compilers to it, C and Fortran 77 versus BSD Unix, written by a bunch of freaky college students, which had TCPIP, great networking, demand-page virtual memory, and three main languages, C, Fortran, and Pascal. And of course, most of the vendors went with that. SunOS was BSD-based. Altrix from Digital was BSD-based. Let's see what some of the others. Most of them, IBM went with kind of a System 5 and AIX. The only one that went really System 5 was SCO, the real SCO, the true SCO, not the SCO that caused all the problems later on. About 1984, there was a sky-divergent stallman, and he liked seeing the source code for Unix systems. He didn't want to see these binary systems. He was having problems getting his printer running. And so he decided he was going to start a complete project to write a complete Unix operating system in source code. You all know about this so I can go on. And computer stores were coming into more and more prevalence. And about this time, copyright and patents were applied to software. Now, think about this. This is the period of time that copyright and patents were applied. People had applied for patents and applied for copyright, but they hadn't been granted. It was at this time because companies were beginning to put out these floppy disks that could be copied, and people wanted to have protection against that. And at first it was just case law on this, but then it started to be built in. And people say we need to have copyright and we need to have patent in order to stimulate research and development and stuff like that. Now, I've been up here talking for 53 minutes and I've covered a whole bunch of stuff that has happened without copyright and patent. And since this time, since 1970s and 1990s, what have we really gotten? Because I was using virtual machines back in 1973. Mice and things like that all developed before copyright and patent. And I think it really came after copyright and patent is this paper clip called Clippy. And I think we're all glad that that went away. When we're talking about technology and balance, we have to think about the cost of the technology versus the capability of the technology. And that's all based on things of balance, like how fast is the CPU versus your speeds versus the memory size versus bus speeds and things like that. And that's the reason why things happen. And it has to do more actually with business and what people can afford than the actual state of the technology at the moment. So we take a look at something like Sony Betamax versus VHS. Sony Betamax definitely the better technology, but what one? VHS, right? Why? Because VHS was easily licensable out so other companies could produce it and sell it. Sony held on to Betamax so tight that nobody else could make any money off of it. That's why they lost. Sony went in with the Sony Walkman. It was a fantastic thing. For the first time, you could take your music and walk around with it. You didn't have to wait for the radio to play it and stuff like that. You could make up your own little party tape and walk around. And it was great. And actually that they actually licensed out, but then they came to the Sony Discman and they screwed it up again. So just because you're large, that doesn't mean you can't fail. And all of the companies on the top row are companies at one time or another with the second largest computer companies in the face of the earth. The other ones down below were also very large and also failed magnificently. By 1991, the desktop was owned by Microsoft about 90%. Apple had 7% of it. Service systems were made up of a wide variety of different systems. The GNU products were all coming out. BSD Unix was still struggling with the lawsuit. And that's when Lina's tour evolved as a college student started the Linux kernel project. And he gathered a team. He started the project. By 1994, version dot 1.0 of the kernel was ready and people started to take the pieces of GNU and BSD and MIT code and everything put together into some distribution. Soft landing systems, IGDRACIL no longer exists a little bit before their times, but Slackware, Red Hat, all those flourished. I met Lina's tour evolves in 1994. I took a man on that river boat, the Natchez. We were going up and down the river and I said to him, hey, how would you like to take this Linux thing you're doing and put it on a risk computer to make it portable and 64 bit to give it a larger address size. Because what I saw was something that we could do research in very large address spaces and therefore move forward computer science. Later on, I realized, G, there's a commercial aspect to this too, that maybe we could help to revive the dyeing computer system industry by utilizing these things called Beowulf systems. And then today, the 500 fastest computers in the world, 485 of them run GNU Linux, 12 run Unix, one is mixed, and two run Microsoft because Microsoft pays them too. Of course, when Linux came out, it had this problem, it didn't have any applications for it, but gee, there was this wonderful thing happening at about the same time called the World Wide Web. Linux was perfect for that. What was being done before with Solaris and Spark could be done way cheaper with Intel and Linux, and that started to get people in the way. In better systems in the year 2000, we're typically only proprietary systems, but this thing came along which caused everybody to do a reset. It's called a network stack. Network stacks are very hard to get right, to keep right. There was this operating system that had a network stack and it worked on all these different processors and it was secure and it was free and it was called Linux. So after 2000, Linux became almost overnight the most used operating system in new designs. And so today, the market looks a little bit the same except Linux is starting to creep out onto the desktop and it is outselling Apple on the desktop. Linux, in the disguise of Android, is starting to sell many more systems and also on the phones. Now, it takes time to change. People are becoming used to different things. I remember when my father was using some systems in the beginning, he would write down every single word he had to type in and would come back with. And people have gotten past that now. They know what a scroll bar looks like. They know about how a lot of data works and so they can handle different things. And so it's not the best technology that often wins, but the technology which is marketed the best, the technology where most people can make money off of it, the technology that people have control over their software. That's why I stopped talking about free software a lot. I stopped talking about software freedom. Instead, I talk about software slavery. And I also talk about to business people, I talk about control because that's what they want. They want control. In the near future, we have a whole bunch of different things that are happening. The Internet of Things, resistive memory on a project that HP is doing with what they call the machine, photonics instead of electronics to be able to connect things, nanotechnology where we can actually create an analog computer that do calculations hundreds of times faster than a digital step-by-step computer, quantum computing and artificial intelligence. And I'm glad I'm retiring in about five years. Because the whole view of computers is changing too. It started with high performance, it went to embedded, but then the Arduino came about. And the Raspberry Pi, because this is the way that a lot of high school students see computers today and this is how they really work. And we really need to get the incoming freshmen to be much more ready to go for the types of systems that we have that are coming out. If you haven't seen it, the BBC is promoting something called the BIT, MicroBIT. They want to give it away free to every seventh grader coming into the school system this fall. They're actually changing some of their programs, like Dr. Who is going to be talking about things to do with the MicroBIT and stuff like that. And why do I show you a lot of this stuff? Because you too can build something like this. This is a supercomputer that fits in a briefcase. And not only can I demonstrate high performance computing on this, but I can also do high availability computing, heterogeneous computing, heterogeneous systems administration. And I can take it out and put it back in in a short period of time. In a couple of weeks, I'm going to redo this to do cost reduction on it. I hope to get the whole price down way below $400. I'll be publishing how to make it. I'll bear with me just a couple more minutes. I actually did this part of the talk back in 2010. So it's been five years since I did this. I want to show you what I predicted then. 2015, Nokia gives up the Windows OS and uses Android. This is when Microsoft, yeah, Microsoft, Microsoft, Microsoft, Microsoft. It only cost them $10 billion. Project COA, a project I'm working on to produce jobs in Latin America, creates a one millionth systems administrator entrepreneur. We're a little far away from that, but it's moving forward. And Baltimore admits to using Canoe Linux at home. Now, remember when I wrote this, he was still the CEO of Microsoft. Now he's a, what's the basketball team? 2020, the newest Canoe Linux supercomputer has one trillion processors. And Lena says, I'm glad I got rid of the big kernel lock. If we use Windows NT for this, it would have cost another $35 trillion USD for the royalties. That's almost enough to fund a small war in Iraq. 2020, Steve Jobs says OSX was not being used because they were holding their supercomputer wrong. 2030, software patents are ruled invalid worldwide. They are really stupid. The US Justice Department admits. Microsoft, Apple Wars, and because both companies are out of business. Free culture wins. And finally, Lina's Torvalds retires. It's still fun, but I want to do more scuba diving. He passes his position to his protege who's been working with him in Brazil, but he will still act as the advisor and Lina's joins, mmm, mmm, is my retirement project. Mad Dogs Mansion and Marina of math, music, micro computing, micro brewery, micro winery, micro distillery, and big time. And if in the year 2031, you happen to be in Floridopolis, Brazil, please stop it and see me. Finally, 2060 free culture brings world peace. I've been a very lucky person in the 46 years I've been a computer science. It's not been a single day I've ever been bored that I consider to be the worst crime. And so people come up to me and say, thank you, mad dog. I heard you speak 20 years ago or 30 years ago or something like that. And what you said changed my life. I went in a different direction. That's really, really great. I please me a lot. But I want you to remember something. If you would like to see the person who's the most important person in free software. And when you get up in the morning, look in the mirror because that person is you. Thank you very much. Thank you.
On August 7th maddog turned 65 years old. He started programming in 1969 after almost being electrocuted by 13,600 volts and 800 Amps (he figured software was safer). In celebration of 46 years in the computer in the computer field and five more years before he can afford to retire, come hear maddog explain the computer field in ways few people have thought of it. maddog
10.5446/19592 (DOI)
Hi, good morning. My name is, I'm getting away from the audience. I love you already. Hi, there aren't very many of you, but it's all about the quality. So, hi, I'm Lorna. I'm wearing both my hats today. So, I am an open source maintainer. I'm also an open source contributor. So, I sort of see that from both sides. And, hi. And, I'm also a team lead. So, like, commercially, I'm also a team lead. So, I run a team and I am responsible for maintaining code quality with them as well. So, I'm going to talk about how to get your patch accepted. This is predominantly aimed at people offering contributions or, you know, trying to do good work at work. I have been completely unable to write this talk in a way that doesn't cause me to sort of trip over and start giving advice for the reviewers as well at some point during the talk. So, we'll be looking at it from both sides of that relationship because I think ensuring that your patch is awesome is the same as ensuring that someone else's patch is awesome. There's just an awful lot of crossover in there. So, this talk is full of advice you never knew you wanted and you didn't ask me for. I've got some stories to tell. But it all boils down to three main ingredients that you need to get your patch accepted. The first one is the code because if your code is rubbish, I don't want it in my project and that's easy. Everybody pretty much does this. The second are the words that describe what this patch is or does or fixes. Maybe it tells me why I care, which can sometimes be a missing link. And that brings me on to the third ingredient is understanding it from the maintainer's perspective or your team leads perspective. What's the big picture? Where is this project going and how does your change fit into that? Does it fit into that? So, three things that it's very important that you cover. Before you submit your patch, bear in mind that the first thing I will do when I see it is wonder what does this do? Like, I didn't write the code. I'm not already on the inside of this process. It just arrives and I go, oh, what's that? And I kind of poke it and smell it and kind of try and understand what it is. So, it's really important that that information comes in and it's something that you think about as you prepare the patch. You write the code and then I'd like you to hesitate before you actually submit that patch and cover a few more things. Give me some information. Are you building a feature? Are you fixing a bug? What is this? Does it relate to a ticket? Now, some projects will require that you open a ticket and they like to have patches which come in through tickets. A lot of the examples in this talk relate to Git and GitHub because that is the way that I mostly work. I think everything is transferable. It's not a coincidence that the GitHub issues and the GitHub pull requests are basically the same feature. They're kind of really connected. In my projects, I don't require that you open a ticket. If you see something that you want to fix or enhance and there isn't a ticket for it, I don't think you should have to do the paperwork to open the ticket before you can send me your awesome fix. It's just one more hurdle and especially in open source. That's just annoying and we might have to do a lot of different things. However, if you think of a code review process as a horse race, so there's a series of fences and your horse may fall at any one of these fences, the whole load of criteria which can cause your patch to be rejected, then you can think of it like that, maybe it is a problem. I like to think of a code review more like a scoring system. If your patch is not related to a ticket, that's not really a problem but you don't get any points for that. If your patch is related to a ticket, perhaps you get plus ten points. If it's related to more than one ticket, you get minus three for each ticket it's related to. If there's two related tickets, they're kind of the same then fine. But if you've got two different things or four completely unrelated things, I do not want this patch. If you need some help preparing your branch correctly, then let me know and we'll turn that into four patches. The nice thing about coming from a ticket is that the ticket probably describes the original feature desired by somebody or the original bug as it was reported. So if it does relate to a ticket, you, the contributor and me, the reviewer, we all have more information. There might be some acceptance criteria, something which says I saw that the system did that and instead it should do this. If there are no acceptance criteria, you need to invent some. Think about how this feature will be used, whether it's an API endpoint or actual user interface. Think about how it will be used. Think about what's acceptable and now try and apply those criteria to your patch because I'm going to. Just save time if you've done that already. Make sure you've got everything that you need, all of the code and nothing that shouldn't be here. So check that everything looks like it should. It's really important to understand what's included and if you're not terribly familiar with your source control system or you're not familiar with the workflow, you might need some assistance or you might need to make sure that you know what you're doing. Talk to the projects for help. Everybody who is responsible for reviewing patches has an interest in helping you make more awesome patches. Never be afraid to ask. Try and check you haven't included anything that shouldn't be there. So you can check what's different between your code and master, but remember this will include anything that's coming on the master or your main branch adapt as appropriate since you started your branch. So instead try this. Get diff master with three dots and head shows you everything since the last common commit, i.e. just the commits on your current feature branch. Get to know your diff tool. Get diff by itself will just show you that inline ASCII art diff that we're all accustomed to seeing. But get to know your tools. Get diff everywhere you have a command that is get diff, if you can replace it with get diff tool or one word. And that allows you to start to use cleverer tools than just the inline red, green line diff that gives you by default. You can configure your config, configure your config, wow, with diff dot tool and say which tool you'd like to use. I'm a vim user, so most of the time I use vim diff as my diff dot tool setting and that's awesome. It gives me a nice view of my side and I can push changes from one to the other. If things get really sticky, sometimes I'll use meld, which is cross platform and has a nice configuration setting so you can get it to open, rather than just pairs of files, you can get it to open the whole thing. So you can see the tree and look at where in the tree things changed and what the old and new versions are. It is worth getting to know your tools so that you can be certain about what you're submitting and as a reviewer. So it's very easy to review other people's branches and understand what is coming in. Sometimes a patch can be too big. There is such a thing as too much awesome incoming code. Trust me, especially if I wasn't expecting it, this is really, really hard to review. I had a dilemma recently where I run an open source project which has made them a few different open source PHP projects and there's a web front end and API back end. The API back end uses a different coding standard than the front end and somebody offered me a patch which kind of mostly fixed it to use a different coding standard than the one it does. 37,000 lines of change, which I wasn't expecting and it arrived on a day where I was on the road speaking at a conference. My co-maintaining was with me at the same conference. There were eight open pool requests, all of which would have had to have been rebased. Was it a bad patch? Not really. I mean, it wasn't complete but we could have worked on it. Did I merge it? No, I didn't. It was too much change. Giving the advice that a small patch is way more likely to be accepted is a little bit like giving the advice that how to avoid conflicts in source control systems commit before the other person. This is the same thing. There's nothing to say that you can't build a big feature but you need to build it in such a way that it's digestible by whoever has to retrieve it and at work we have pretty regular release cycles as in we merge it and then we just deploy it. It's not quite continuous but it's potentially continuous. We just click the next button. So by building a small change and then a small change and then a small change and then a small change, the feature still gets shit and usually faster than it would have if we have one big step coming in and we try to launch that. There are some common code mistakes that I see all the time. I have two hates relating to comments. I have two hate comments. Let's talk about the two mainstream ones that I see all the time. Really exotic code with no explanation. If I have to go and look up the operator precedence rules in order to understand what your code does, I probably don't want my code base. So we need to write code in the way that we want to read it at some future point. The opposite is also true. So missing comments, commented code. Right. Source control has been around for a while. I don't know if you've heard of it but it has been invented and it means that we do not need to leave commented code in code bases. It litters the place, it's hard to read and in the straight diff view it's not marked as a comment. If you comment at the beginning of the line, I basically can't see it when it's invented and I rejected a pull request because I thought it was nonsense recently and it was because there was commented code and it just wasn't clear to me that it was commented. Don't leave things lying around in your code. If we need it later, we'll just get it back. That's how this works. I'm not sure this really belongs here but it genuinely happened to me last week. Pull request came in, I'm part time in my day job as principal developer. So things kind of queue up and wait for me to come back into work and then try and mop up what a number of full time people do when I'm not there. So I popped in and there was a pull request waiting, client very urgent, we contacted the client so we're just waiting for law and she'll be in in the morning. My colleague had added a single variable called X, I'm a PHP developer, so $X. Single variable, undocumented as an optional final parameter to a method. We specialize in legacy systems. It's not like he's messing up an otherwise beautiful code base but really we can do better. There's no need to think to the lowest common denominator around you. And we were under pressure and I took a deep breath and it wasn't the right thing. And I rejected the pull request. A bit later he came back and I also mentioned one other thing that seemed a bit weird but I hadn't really understood. When the pull request came back in later on in the day, it looked completely different. There was no single character variable, $X. In fact that was completely refactored away. It was to do with the type of file that he was sending with an email. He had just refactored it in a much, much better way. And so my code smell and my doubt was the right thing to do there. Our second attempt, as is so often the case, was really so much better than the first attempt. And that is bravery on the part of the reviewer to call it and say that is not how we do things. On GitHub you will find a file called contributing.md. Helpfully GitHub doesn't show you this until you try to open a pull request. At which point it seems too late because you probably need to know what your branch should have been called and things. So have a look in the projects that you are contributing to because this will tell you do you need a ticket, must the branch be called something completely? Should it be rebased or squashed or any of those other things? It is also worth checking in directly with the project maintainers. Most of them have chat channels or mailing lists or there will be conversation going on the issues if you are out of time zone or they are just not real time people. And it is worth talking to them, just taking their time to let them know what you are working on. It helps the projects to keep moving. Something that is omitted too many times. Can you break your code? Try. Because I can. I can break your code. One contributor laughing at me from half way back in the room. Hi. I can always break your code. I think my developers at work, the people that I work with think I have some kind of magical, mystical power that causes their code to just malfunction spontaneously as soon as I get my hands on it. And the truth of the matter is this is not magic and it is not even rocket science. It is not hard. I do things like is the data missing or is it overlapping or is it a little bit ambiguous because you have allowed me to edit it in too many different ways and I have deliberately tried to confuse the system or omit something. I will sometimes log in as a different user. That seems to throw everybody, too many developers building things logged in as the admin user and strangely or not logged in as the admin user or those things are easy to try. The truth of it is the user is an idiot and I have extensive experience of writing code that was broken by idiot users and so now I do a really good impression of an idiot user. The reason that I can break your code is because my code has been broken so many times before. So try. See if you can beat me to it because the poor request that I can't break so impresses me. I remember being on site with a media company in London doing some work and quite an angry QA person showed up at my desk. It is never a good thing. Quite an angry QA person. And she said I am very angry. I cannot break your code. She is a QA person. It is her job to ferret about and pull apart code and find the bugs and in my code she couldn't find the bugs and she said but I will and off she went. And maybe it is a threat. I think that is a compliment because I have always tried to think about what could go wrong and that is something which will enormously help. Both to get your patch accepted if you are contributing to a project but just to keep things moving at work to get features shipped if you are thinking about these things. If there are automated ways to break your code maybe there are tests that you can run. Coding standards checks which if failed will cause your patch to be rejected. Joindyn has a syntax check ever since the time that a co-maintainer and I both were running development platforms on a different version of PHP to the live platform. Guess what? He committed a change and I reviewed and merged the change and between us we broke the live platform. Well done. Now I have a syntax check that runs on build. GitHub has this commit API, commit status API. You open a pull request and it will run the builds for you. It integrates with Travis. Really helpful. This is fabulous because it means bad news like your code might be fine but you are in contravention of our coding standards therefore we won't accept your patch. That is why we are doing this. This gets delivered nice and early. Like the syntax check. That is worth having and then you know. Half the time it is conflict marker that somehow made it into a file. One thing to really look out for and it is something that I think as developers we occasionally underestimate the importance of. And that is your commit messages. The commit messages that you write on your journey to hack around to end up with the world's most perfect patch do matter. I do see those. I do read the logs of my project. I call it archaeology. I work on legacy systems so things like that. I dig about to try and understand how on earth we ended up where we are today. This matters. This does matter. If you get to the end of your branch and it is a bit of a mess and you don't know what to do, figure it out. This I use a lot. All it does is takes everything in your branch since you branched off master and makes it an un-staged change. Now you can make me some new commits from all that change that you just put in on the branch. It was a single commit and I complained or it was a bit of a long journey of commits that went a bit round the house. Sometimes we can't tell at the start of a feature quite how that is going to look when we are finished. If it was all very straightforward and we knew exactly what we would do, none of us would be doing it because we would be bored. We all need the challenge and the entertainment. Sometimes can be a very scenic journey to eventually arrive at the working solution. So clean it up. While I am on the topic of commit messages, I need more information than I get in the Diff. Please don't write me a one-liner that describes what the Diff says. I work with a lively and soon-to-be-talented junior developer who, at work, I use a Slack channel with Git, yeah. Yeah. Sorry. That's fine. You don't need the slides for the story. I'll tell you the story. You can grab this. I will also use my slides. I work with a soon-to-be-talented junior developer and he put through a commit message. We commit to GitLab. GitLab calls the Hubot. The Hubot talks to us in Slack and the commit message said shuffling the JavaScript files around, which caused me to simultaneously say, do you call that a commit message? And also pop open the Diff to see what he had done. He had not shuffled the JavaScript files around. But I need, in the commit message, I need more information than I get from just the Diff. So tell me something about, I never really did find out why we had shuffled the JavaScript files around. And if we ever have a problem with the day that we renamed all the JavaScript files in one commit, I will still have no idea why that happened. And that's why this matters. Don't tell me what's in the Diff. I'm going to read the Diff anyway. Every commit has the apparent, the Diff, who did it, when they did it. The commit message is the missing magic. It tells you potentially why something was done, the context of this change. And if you just write, fix all the things, I'm going to hate you. Worse than that, commit messages read by other people. But sometimes you are the stranger. You come back to your code in three months and you've slapped. You are the stranger reading your own commit messages and hating yourself. Do yourself a favor. Do yourself a favor and write yourself a really helpful note that says this seems like a really strange change, but there's a logic. And then explain the logic. Please write me an accurate commit message. I see too many which are described the most recent commit and kind of forget what they did in the branch before. Again, a lot happens in open source and people can be kind of chipping away, doing a bit more work, a bit more work on a feature. I need all of it. Please try and use some kind of sane format. I have a favorite list of things you do for a sane format and it's here. This article is so good that you've just have 20 minutes of rant. You can all just read the article. To summarize, a headline that isn't very long, which is going to fit on Git log with one line, it's going to fit in the chat ops notifications, right, headline. If you need to write more words, blank line, more words. And write as many words as you like. Give examples of command use, give bullet points, give links, give anything you want to. I am either famous or infamous, depending on your perspective, for writing commit messages which are longer than the diff they relate to. I don't think that's always a bad thing. Sometimes the change can be very elegant, but the reason and the journey to get there can be a bit longer than that. Don't be afraid to write it all down. Please keep your commit messages safe for work. It doesn't matter how hipster or hobbyist or cool or out there you think your library is. Hello. I am the consumer of your open source library. I build things on what you've made and sometimes I want to do that in a commercial setting. I don't want to read your gender biased, homophobic, racist comments. It's unnecessary. I don't even need just words, although sometimes that's justified. So please, safe for work. There's one thing you can do in a commit message which will automatically get your patch rejected. If I see an apology, right, I don't need it. I'm not taking it. And the reason is if it's good enough, there's no need to apologize. And if it's not good enough, well, then it's not good enough. And maybe we can get together and try again. But if you apologize, not just commit messages, I see this in code as well. No. Not ready to go in. Yeah. I'm so sorry about the state of this patch. I'm so sorry. This is the best I could do. Any kind of sorry makes me go, I probably don't want this commit in my code. So this is a real, what's the equivalent of a code smell? Commit message smell. Like, it's not really good enough. But just know. When you're working on a patch, it's worth checking if it will merge. If it won't, somebody will probably ask you to do something about that. GitHub has like a no green button scenario, web page. I don't have a good relationship with the green button. But anyway, there isn't one because it's going to conflict. So it's worth checking if it will merge. Now, you can check by just opening the pull request. But you can also check by seeing how that merge will look. So you can switch over to the master branch and do this with no commit and no FF. So it won't complete the commit, it won't complete the merge, but you can see if there's going to be any conflicts, it will tell you. And if not, there aren't any. So you can use this or something like this to do a dry run on whether your branch will merge into whatever the target branch is. If it doesn't merge, and then do get merge, get your repo out of the merging status and back to being normal, it's as if nothing happened at this point. If it doesn't merge, then fix it. And that might be, there's a couple of ways you can do that. Some projects are happy if you just merge the master branch into your branch and deal with the conflicts. The more textbook and occasionally required way is to rebase your feature. So if you've worked on a feature on a branch, things have happened on master which have caused conflicts. They'll say, oh, you should rebase this. So take your branch and reapply it on the tip of master or developer, whatever your main branch is. If you're rebasing, because there are conflicts when you merge, there will be conflicts when you rebase. Like, there is still a conflict between these two branches, and you're going to see it somewhere along your rebasing journey. I've seen some situations where there's actually a lot of conflicts along the rebase journey because you're applying, you can be applying a lot of commits. So sometimes the merge is easier because it avoids all the crossing over that might have happened in the middle of the branch. So rebasing. Opening a pull request on GitHub is not just the action of throwing code over the hedge. Done. Here you go. It's the beginning of getting your patch accepted. When you're opening a pull request, check the source and the target are correct. This is surprisingly easy to get wrong, and I still do it sometimes. The source will be your branch. If you're working as an open source contributor, that's probably on your fork. If you're sharing a repository in a commercial project, that's very likely on the shared repository. And the target branch will be either master or develop or whatever. GitHub has a setting for what the mainline development branch is. So usually it will default correctly, but it's worth a check. And then scroll down and have a look at what diff that's generated. This will tell you if you're vaguely on the right lines. If the diff looks like nothing you've ever seen before, something is terribly wrong. And you should just close this web browser window and try again, check you pushed the branch, check it's called the right thing. I don't know. Something is terribly, terribly wrong. This is usually the moment at which you'll realize that you branched from completely the wrong place or something else terrible has happened. And pull request needs a title. Most people will view a list of pull requests, and so I will only see the title. Pull requests have to be opened quite a long time on the list before I get to know them by their ticket number. So if you could possibly include any extra information, maybe some words to go with that ticket number, that would be awesome because I'll know what thing is on the list. I want you to remember why I care enough to, you know, I have 45 minutes before my next phone call. I'm looking at a list of pull requests and the one that says copy change on the navigation will make me go, oh, I've probably got time to merge that. And the one that says ticket 42, you're unlikely to get that merged. And it's right up there with submitting small patches. It's about perspective. It's about remembering the maintainers. And for years, I've been saying, be sympathetic to your open source maintainers. They're busy people. They're volunteers. But actually, it's not much better at work because I'm very busy there, too. I'm sure that's true for everybody. It's not special, really. Always try and lower that acceptance barrier. And that's how you'll get your patch over it. Description, I need some words. I really need some words. I had one pull request opened and I think it had a single commit and the title was the same as the commit message, which was implements the get cash function. This is a bit like implements the dancing bear feature. Wasn't really on my roadmap. Dancing bear. Got to maintain it. This is the get cash function. I'm thinking about that. And then thinking, well, it's come from a co-maintenor, actually. It's not even a trusted contributor. This came from someone who definitely should have known better. So in the diff, there's a new get cash function and inside the get cash function, there's code that looks like cash code and nothing else. It's not called from anywhere. I have literally got a commit that implements a get cash function. I really could. This does not help. Write me some words. What had actually happened was we had somehow eliminated the get cash function from the code base. I don't know how and therefore that was the reason that the search function was broken across all platforms and all we needed to do was implement the get cash function, which is what he had done. But later night in a huge hurry and then it opened me a pull request, which did not did not allow me to understand the urgency of the situation because I had no idea what I was fixing. So tell me what it does. Tell me not necessarily exactly how to test it, but what are we changing about this? I'm working with a client at the moment that likes paperwork there. I said 27,000 one compatible and they like lots and lots and lots of paperwork. And it's really interesting because it means every feature we build or every bug that we fix or every system change that we make, we have to write how to test that it isn't there and then how to test that it is there. And actually that really makes me think about the big picture and what the users will see and how that will look different. And that's quite good information that that would be really helpful to be included when you're submitting a patch. Tell me why I care. I work. It's my job to care. I'll probably measure change eventually like the client will shout loud enough we'll get there. In open source. That's not true. There's a lot of abandoned. I'm sure all of you have opened contributions or offered contributions and some of them haven't been accepted. Sometimes you don't even get response. All the questions lies there in limbo for ever. Tell me why I care. You want to get my attention if you want me to invest my time in bringing your code into my project so that I can be responsible for it forever. Please tell me why I care. Please write me some words. Code review is. It's a process and there's it changes a bit depending on what exactly you're reviewing and what the context is, but not a lot. I've been an open source maintainer now for a number of years and I was contributed before that and still a contributor to a bunch of other projects that we always follow my own rules. Probably not. But I think there are some things that we can do. To prepare for code review to make sure that our changes are ready. And as reviewers, this is the point at which I couldn't avoid tripping over and becoming code reviewer because sometimes that's my perspective to and I'm sure that all of you will and perhaps should review as much code as you can. To be a good writer. You need to read. You need to be really well read, but I think that's true of development to you need to read other people's code and to actively participate in code review and in evaluating code. I think is a really smart way to do that. When you're looking at a patch for the first time with a title and description and think about. What shape you would expect that patch to be. So I had one come in for a specific ticket and the ticket said the client requested a copy change. Okay, so viewed the diff and the diff had quite a complicated SQL statement in it. I went what. I didn't know the system very well. I haven't been in my job very long. I didn't know the system very well and it turns out they have a CMS. So in order to make this copy change across all the platforms, we need to do that by editing the records that we've got stored for them in their CMS system and we were just doing is. I did mention that I deal with legacy systems. Yeah, we're just doing that by entering a line into a database because it's dynamically generated. Because I had always nothing wrong with the SQL statement. I mean, if you just read the code, the code looks fine as a code reviewer, you need to do more than that. You'd think about is this the right perfectly correct piece of code or is this just a perfectly correct piece of code that does not bear any resemblance to solving the problem in front of us. That's a tiny grammatical point. Please don't merge someone's poor request. Please review it. I want you to keep that attitude of skepticism right until you can't prove that it shouldn't be it shouldn't be accepted. This is really important. I come to work and people say I need to merge this thing. And half the time I don't merge it because it's not ready or it's not done or I can break it or all of those. I had a good one recently where the same junior developer is a really small company. The same junior developer said I'm not even sure this this merits a merger quest. But we made these rules for a reason. So I will as I was like good man. So I opened this measure question. It took him five attempts to get me to merge this thing. Because first of all, the database patch didn't have the right numbering in it and then he forgot something else. Like this piece and then there was a typo and then oh my goodness he spent all day going around on this thing. All of these things he could have picked off before I got it. And hopefully that will happen next time. I feel like he learned something. But just keep that cynicism a little bit longer and review it be open to it. But don't try to merge it when I try to merge code. I accept things and then it probably gets to the test platform and I realize it's not complete. I think anyone can be a code reviewer. I don't think this is the responsibility of the team lead or the maintainers exclusively. At work I operate a system of peer review. So I don't mind who writes the code and I don't mind who merges the code as long as those are not one and the same person. Which means that the most junior person in the company also reviews everybody else's code. And I review his and we all kind of share ideas. So he sees my changes and often picks up bugs in them and that's really important too. He sees how I would approach a problem. In open source the merging can't be done by just anybody because we tend not to just open up right access to our repositories. But having input from other people on an open pull request makes me way more likely or way more confident. That this is actually correct. I mostly work on joined in which is an open source event feedback site. So if I've got conference organizer running a local Dev copy pulling a feature and saying this looks great or I'm not sure this would work for us. That really influences whether or not I merge and accept that. We had a bug last year. Unfortunately I had flown to San Francisco. Even more unfortunately with my co-maintenance. This is a mistake. One piece of advice do not travel with your co-maintenance. I once had the other co-maintenance and the only other person with server access all on the same transatlantic flight to Oscar with me. I just logged into channel and says if anything breaks you need to wait 24 hours and we're on this flight. I go sorry. Look out for the flight number of anything terrible happens. I mean anyway so I go to San Francisco with Rob and I woke up at 5 am local to emails Twitter stream everything about some users being unable to log in on joined in. So Robin I was sharing an apartment and I very optimistically logged into ISE and he was not obviously awake because he was not logged in. I was like okay so now I know who is fixing this thing. However due to the time zone difference one of our contributors in Europe had written a patch. And so I logged in a channel and I was like I see a problem I see a poor request where we are with this. I have the ability to put anybody's branch onto the test system so I did that. Some people tested that and someone else pulled it under his dev platform and tried it there. Because people were able to make it work on someone else's dev platform and on the test platform I pressed the big green button in GitHub which never happens because I can't. I don't believe that code review can be done other than like on a read me. Without pulling the code looking at the code running the code poking the code right I don't have a good relationship with this. Button on a web interface because I don't think that's how this works. On this occasion I click the green button and then I click the go button on Jenkins and then we're back to bed. Because somebody else had done that code review. And if you want a feature. Accepted tested come back and say hey I really liked it worked for me on this platform yada yada. I am slowly learning. I need to check the pull request queue. Before I open them a pull request because half the time the thing I'm going to fix has already been fixed but sometimes it's still sitting in there for a question. If that happens pull that branch by all means but test it and feed back on that pull request said hey I tried it really looks awesome to me. On this version on my platform etc. There's no reason that says you can't get involved. The merging will actually be done. In different ways for different kinds of projects. I like the peer review I enjoy getting the whole project involved by its very nature on an open source project. We have the gatekeepers we have people who take that responsibility and at work if something breaks I will say who merged this. My developers have stopped saying to me I wasn't my code. I think that's a responsibility thing we take it quite seriously. As a code reviewer there are some key skills that you need and in particular the ability to see what you are not looking at. Is absolutely key. It's very easy to eyeball the death and maybe the death looks good. But it is the things that are not in the death which cause you all the problems. And this is what makes you both an awesome reviewer but what will really get your patch accepted what will really enable you to get a complete patch and make that work. Does this need documentation this is my number one reason for closing work pull requests we've changed something fundamental and there's no documentation to go with it. Close. I'll add you the wiki later. No it's part of the patch if it's not in close. Maybe that's harsh but it is improving our quality and on those legacy projects that really matters. Tests do you require tests do you think this feature could have needed a test I will sometimes not close but delay. A pull request be like this will be acceptable when it also has. Documentation tests are they missing database patches does somebody make a local database change that we need to make this code work and it's not in the patch maybe because it's a new file maybe they forgot to add it that happens. Deploy ability I'm not sure if this is a word but it's a really important issue. The ability to run this code somewhere other than on your on your platform okay works for me. Is not how we ship software. Well works for me is really good starting point but works for me doesn't do the rest of it has to run on your death platform but then on my death platform and on the test platform and on the live platform. And you have to be able to see that I did recently which came in which change the conflict and it's like you just change the path with no respect for what platform you're on this code we've just inherited only runs on one platform. The live platform so now only runs on one platform the dev platform that's going to be a problem when I deploy this. Looking out for those things that are hard to see because they're not there. The forgotten changes to templates the follow on changes to emails when you remember to change the templates reporting systems I have a client who I think we must have broken their reports three times in the last. Six months because neither they nor we can remember that we have reports and so we do these like beautiful and amazing refactors and then we update their emails and all their templates the website looks great and then they're reporting breaks at the end of the month. You've got to be able to see that this change is not in your death. Monitoring changes this is sometimes invisible to developers. I'm in the middle of doing a big refactor of game and workers because we're running like 20 different ones and. I'm going to group them up so that can do more than one thing so I'll have like five different ones but we'll have 20 of one of them. This is going to break the monitoring system completely which checks that certain game and jobs are running at all times. So more things to bear in mind cron jobs can be really hard to remember especially the conflict for that or for anything is not in your repo. These can be really difficult things to remember. As a reviewer this is really difficult to identify and then can be controversial to deal with if there's something missing reject. And this can upset people particularly if you are the junior developer. Reviewing for the senior developer she doesn't want her patches rejected but if they're not good enough then it's the right thing. So don't be afraid to reject it or at least to push it back and say I also want this. I think this would make it complete. We should also include the following push it back and if a change comes in like my big coding standards thing that you don't want. You know you're never going to merge dancing bear feature because you don't want it. Close it reject it early. It's kinder to everybody just just do it and we can iterate or not but we have to be up front and we have to be able to communicate about this. Sometimes the rejection will come automatically because you're running those automated builds and it failed on coding standards. If you're not accepting a patch really important to include constructive feedback. I had one situation where a new employee had had you know he was really new so is poor request never got accepted first time in fact or third time or fifth time right. So he had quite a long quite a long go of just everything being hard work. I have to work with this guy right so this is fabulous because he's now much better at all these things. But one day I think I merged it but I commented he sent me a perfectly good request and I merged it and I was on my comment back to him was like it was cool but I really didn't like the comment syntax that you use the C comment syntax is valid in PHP what we typically use to slash. Came straight back to me and channel and said so my patch was awesome yeah because all you can say is what's wrong with my comment syntax. Yeah he was right I didn't say that I did not say well done your pull request is otherwise perfect and you have worked hard at this. I said a bit of a problem there. That's not very constructive and it didn't recognize the work that he had done. The feedback that I give does depend a little bit on who it is for an open source contribution people have taken the time we probably don't know them. They're volunteers and the lag between iterations can be quite long. I am more likely to add one more commit onto the branch to fix whatever is missing or whatever small thing I don't like and then merge it myself. With colleagues. I have to work with these people and I don't want to be picking up after them all the time. They are very much more like it also paid to be at work when I'm at work so they're very much more likely to get the no do this. Whereas in open source unless I know so joined in has a lot of new contributors is a lot of first time open source contributors. If I know those people involved because they want some experience and they want some feedback then we'll do it like that and they can improve otherwise I'll comment what I did. And fix it myself and merge it so my approach is quite pragmatic and I'll do often some combination of those things. There is such a thing as too much feedback. Please. I would never ever have mentioned the thing about I don't quite like your commenting syntax. If there had been anything else wrong with that patch. If there had been anything where I actually couldn't accept it I'd have mentioned all of those things but nothing else. For something which is pretty good one thing to change and in general and not a fan of ternary operators because I think they're hard to read. I probably would say one thing and offer that extra. Feedback otherwise I'll just fix it as it comes past. So it's about finding the appropriate feedback that gets the patch accepted but that also gives that contributor or that colleague what they need to work with you. I spend a lot of time at toast masters which is a public speaking organization helps you to improve your skills. So you give a talk and then you get some feedback from the evaluator and they use an approach called sandwich technique. Where you start with something positive. The filling of the sandwich is something that you can improve and you go on to end with more bread on a high note. And I think this is something that we could do in open source because we don't do very well at saying thank you. And we could start with thanks for offering me this for request thanks for taking the time for this. Quite like it if it actually worked and looking forward to seeing more code I don't know. There's also something called the modified sandwich which again starts really positive mentions what isn't working. And then gives constructive advice on how to change that your commit messages are awful. Please read that link that I mentioned earlier. So thinking about the feedback that we give sometimes you'll have to deal with harsh feedback. This will happen more likely a lot of people don't offer patches because they think they're going to get flamed. It's actually massively more likely that you will get nothing at all. There's an awful lot of abandoned pull requests on the Internet. If you get harsh feedback it isn't personal. It's about your code. It's not about you. But also take your efforts somewhere else. Open source has a place where you are wanted has a place where you are appreciated. It has a place where you belong and if you haven't found it then your open source journey will continue until you find a project or an organization or a group or anything that you can contribute to which don't make you feel victimized. Harsh feedback. The official advice is always grow a thicker skin and I don't think that's fair. Find a place where you feel comfortable offering your changes and interacting with that community. Pull requests are not the throwing of code over the hedge. It's done. Here you go. It's the beginning of a conversation. They have a life cycle. You may need to iterate. Other people may contribute before this feature is finished. But by starting the conversation you become a contributor to get your patch accepted. You only need to remember the three main ingredients. Get your code correct complete test it make sure it's ready. Write me some words to go with it. Explain to me why I care. Remember my perspective as a maintainer or as development lead. My colleagues are very much getting to know the things that I am going to reject without even really looking at them. Get to know that look at the road map of the project think of it fits. And with these three things you will get your patch accepted. Thank you. Thank you. I appreciate your feedback about rejecting patches if there is an apology in the commit message. I wonder how you balance that out with first time contributors who may have imposter syndrome who are going to apologize for breathing let alone for the quality of their patch. And what advice would you give people in that situation? That's a really good question. I do see a lot of first time contributors. Sometimes I don't actually close it I just mock them in a really friendly way. I try and let them know that they don't need to apologize. Sometimes I let it that message and just try and make it a bit more factual around what's actually happening because there isn't a problem. But yeah, I still try and take it on its merits. My colleagues, however, yes, will get their patch rejected with a commit message that apologizes. I think you forgot something. Most important in the code is checking licenses that you don't use license that will violate other licenses and so on. So that the developer has to check license before you use libraries that are allowed. Okay, yeah, that's a really good point. Do you hold it? You said documentation is a must have, but you also said that you don't want comments in the code. So where do you want to have the documentation? I do want commenting code. I don't want commented code. So I don't want code that isn't operational that's commented out. I do want do always want comments in code and I normally like to have additional documentation. There might be API documentation, for example, or user documentation that would also need updating. So that needs to be considered if you're changing a feature. Any more questions? I saw two more points. What you see in outside US is lots of code where comments and variable names are in different languages. So OpenOffice spend years in changing all German and Russian comments into English. I think that's very important. Use just one language. And he's laughing. He knows it. I forgot to say. And it's very important for the project itself that they have very strict coding guideline, coding style guideline. I'm from PostgreSQL. You get a patch rejected when the layout of the code is not okay. So I think it's very important that you really reject code where the tab not has four spaces, eight spaces. That's why I mentioned the GitHub status API. So we have that automated that you submit the pull request, the builds run. If it's not compliant with the style guide, it just rejects it. And that's one less piece of bad news that I don't need to deliver myself. I have on my slide, because if it's not on my slide, my brain is so empty right now, I would never remember. I'm speaking in the PHP room tomorrow about PHP 7. So feel free to pop in and see me. It is really early, though. Sorry. Anybody else? Well, we have some mails here in this room just to mention. It's quite funny that only women are speaking at the moment. Anyway, I like it. And I think it's a good thing to have a talk like this, because a lot of people don't know why their stuff is rejected and how to get it improved. So thank you for this talk, Loreen. Please give her a nice applause.
Open source is built on volunteer hours. Using best practice in creating and reviewing patches means we're making the most of those volunteer hours - both from contributors but also from those overworked maintainers. Lorna Mitchell
10.5446/19570 (DOI)
Good afternoon and welcome to this talk. I'm Enrico Zini, the developer. I'm the one that realized the WN contributor site, which is about making sure that all Debian contributions are acknowledged no matter what they are. And Debian contributor came as a way to fix the old situation we had in Debian, where the only... I begin, is that okay? Good. To fix the old situation we have in Debian, where the only kind of visible type of contribution was mostly being a package maintainer. And this is the kind of page that you would have for your contributions in Debian in the past. A list of packages, bugs that are open, versions in several distributions and so on. It's pretty nice, you see, the work people are doing, but you only see package maintenance. And all the people doing other things like translations, Debian has a vast group of translators, for example, reporting bugs, porting to different architectures, were just not visible. And some of them still are not visible. And the people doing those were unsung heroes, nobody saw their names, occasionally on mailing lists, but that's it. And the people including Debian people, including the people that were not maintaining packages, they thought that Debian was only about package maintenance. And the process to join Debian was called the new maintainer process, even. So it was all around package maintenance, but that was not reflecting the reality of the project. So at some point, we approved the diversity statement, which was a first step in acknowledging diversity in Debian. So the Debian project welcomes and encourages participation by everyone. No matter how you identify yourself or how others perceive you, we welcome you. We welcome contributions from everyone as long as they interact constructively with our community. And while much of the work for our project is technically in nature, we value and encourage contributions from those with expertise in other areas and welcome them in our community. So this was voted as something we all agree with, or mostly all agree with, like an important document in Debian that we agree to follow in principle. But the visible situation, this documented the effective situation, but actually seeing non-package maintenance contributions still did not happen. There was a blog post in my blog where we kind of decided that we have the need to make other kind of contributions visible. We tried to make a little list of what other kind of contributions are and where some of those information could be found, but still there was no actual technical central way of showing these things. All of that because Debian is complex. This is a simple infographic about Debian, which in a corner is get involved, which you could blah, blah, blah, and then blah, blah, blah, and so on. That kind of gives a bit of a visual idea, a very simplified visual idea of contributing, but different parts of the project track contributions in different ways, some by email, some by by login names, on by GPG key. It is not really feasible to map all of Debian because it keeps changing and people set up new systems. And we have Debian maintainers, people that commit on Alio, people that report bug, people that edit the wiki, translators, people that participate in this discussions. We have people maintaining packages, people reviewing somebody else's packages, people who organize conferences, people that go to conferences, people that run Debian booth, that events, people that do press releases, system administrator, people that develop web applications for Debian. So, yeah, all of those should somehow get credited. I missed the slide. So, it is a social problem of self perception, therefore we needed a technical solution. And this is what I'm going to present today. The idea is to, we started, well, the main idea I had was to introduce a new title in Debian, which was the title of Debian contributor. And there is no process to become a Debian contributor. When you contribute to Debian, you automatically are a Debian contributor. And when you are a Debian contributor, you can have your name on a list. I'll now get the list. There's a list of Debian contributors, at least of all the 1,750 people, as much as we can tell, that contributed in 2015. Actually, that should be changed in the last one year, maybe. So, we have credit for anyone that does things that actually contributes to Debian. You can also choose not to have your name on a list, there is some privacy management in this. So, you can opt in and out of the list by default. All contributions done with the Debian org email address, or all of Debian org email address are public. And things done with the private email address, email address are sort of mostly opt in. And there's a way to manage to get out of the list if somebody doesn't like it. And now, we finally have a place where we can thank and acknowledge the contributions. So, I feel a bit better in Debian, because it was unacceptable that in the past people would contribute to Debian and not even get a thank you. So, one of the important things is that it kind of automatically expires. So, the list that's presented in the main page is of people that did things this year. And you can still get credited for the past years. You can go back in time. And so, when you do things in Debian, you get thanked even though you stopped. So, you can say, well, I did things back then. That was nice. You can then, you have a page with lists, everything one has contributed to. So, I have uploaded packages since 2007. Actually, 2006. I should do some merging of these kind of things, messy at the moment. But I've also been an application manager to help people get into Debian. I commit to repositories in Git Debian org. I talk to people on the backtracking system. I've done some editing in the wiki. I developed the nm.debian.org website. I send patches to the Debian system administrator. And so on. People can have a bit of a more, people can be thanked for way more than developing packages. And so, this actually starts to change the image that we have of contributions in Debian. And then, I, where's the login button? In order to get this done, there was the need to do identity management. So, say that... I am also this email address. I am also this GPG key. And... And I'm not exactly sure what is that key. I'll need to look into that. I haven't... Oh, well. I'll just bug in the site that I fixed yesterday. There's an audit log of all the changes that happens because there's a robot that tries to be smart and do some auto-association. Oh, yeah, that's my other key. And you can change your full name to whatever you want. And then, because people have all sort of things in full names that have different full names in different parts of Debian, and one here can choose how to be credited. And then, I can manage visibility of contributions from all other identity files that I have. So, if I don't want to be credited with my work address and I only want to be credited with my private address, I can have some control on that. Yeah. And so, in order to get this implemented, we had to also introduce identity management that did not exist in Debian. In the past, in Debian, there was really no way to say that email is actually me. And this opens a lot of things that can be done in Debian in the future where new services can interface with this and deal with people instead of email address, GPG keys, and so on. Identity management has been quite tricky because have you read this before? Falsehood programmers believe about names? Basically, all of these things are not actually true. So, for example, people's name change. We have several people in Debian that have legally changed name and even non-legally changed name or are in the process of changing names. And, yeah. Back to the slides. And then, we need to collect data. And the main design principle on collecting data is don't expect me to do it because Debian is fast and it's impossible to go and find everything. So, I designed the site in a way that allows every team to submit contribution data to the site. So, every Debian developer can go here. Well, every person can go here and see the list of data sources that are currently sending data to Debian contributors. And every Debian developer can create a new one. It has a name, a description, a URL, an authentication token and some other things. And basically, you configure the authentication token and you include it in the post request when you send the data and you're done. So, everyone can send data. Every team has a possibility of sending data. The general design principle for this was, when in doubt, relax the technical requirements. So, the system does not support gaps in contribution. There's only first scene and last scene. It is okay to have a granularity of a month even. It is okay to have some lag and send contributions in a cron job run like once a week. It's okay if some contributions are missing as long as when a person keeps contributing, eventually they will show up. So, I try to make it easy for all teams in Debian to actually participate in this. Because harvesting cannot really be centralized, so teams need to do it. And then there's some auto matching so that all your user names are mapped to Debian user names and things like that. The technical details in the system is that there are users, there are people. There are many identifiers related to a user. So, a person has two email addresses, three GPZ keys, one or two login names and so on. And data sources, it's data source has several contribution types. So, for example, in package maintenance, one can maintain a package or one can sponsor the package of somebody else. And there are contributions, which link identifiers and contribution type. So, that email address has done this contribution time from that date to that date. That's a data model. It's reasonably simple. And data submission is documented here. It's basically posting a JSON that looks like this to the site. So, you have an identifier, which is a login name with the value Enrico, that in... Let's have this. And identifier, login and Enrico, that for the data source that we are submitting, has done talking from 1st of January 2010 to 16th of November 2013. And that's a URL that can identify those kind of contributions in more detail. That's all that is required. Actually, that's more than what is required because you can even post without dates. And the system remembers the first date it has seen and uses the submission post as the last date. So, you can have a data source that just has a list of people who are currently doing things. And you just post the list of people, and that is enough. So, the idea is that it should really be as simple as possible. So, now it's not about Debian maintainers, it's about Debian contributors. Actually, an official Debian developer is not necessarily a Debian contributor in case they actually stop doing things. And this as... Debian contributor is actually a serious thing in Debian now. People talk about Debian contributors rather than talking about Debian developers unless they want to refer to people who have voting rights. What was called the new maintainer process for getting into Debian. Now, it's called the new member process. It was a change, that was a clever hack that allowed to maintain the same acronym so that documentation didn't need to be changed very much. And DebConf, when somebody wants to go to the DebConf Debian conference and asks for sponsorships, the DebConf organizer asks for explanation of what one has done in Debian or a URL to contributorsDebian.org. So, it starts to be like a curriculum of people in Debian. And a really nice way to start contributing to Debian is to contribute to Debian contributors and make it nicer. Then one is contributed for contributing to Debian contributors. Future development in the site after the Debian conference. So, now we see that there are people that start and end contributing to Debian and so we can tell them welcome and goodbye. So, recent development is having a list of people that just started contributing to Debian. Ideally, there's a group of people in Debian that are considering starting to start sending e-mail to people who show up doing things and saying welcome. If you need anything, get in touch, I'm a real person. Just so that people, we make sure that people are not left alone doing things and they can ask, they have a point where they can ask for help. And we are starting to consider using this to track people who stopped contributing to Debian. So, here's another list of people who are listed as official Debian developers but who don't seem to have been Debian contributors since 2010. And then there's the Debian Mission in Action team can send an e-mail to these people and saying are you still around? If you're not, would you mind closing the account in a nice way so that we don't keep possible attack vectors of password guests into Debian and we can still compute the quorum when we run elections? So, after changing the way Debian perceives itself with the Debian contributors site has started to be actually a resource and a resource to work with membership. And a bit in advance because there's few of us so I guess question time could make more sense that lengthy talking. I would say question time. Well, many more comments on the question. I found it really nice that the deathmatch organizers were also thinking of making or starting to make data source for this. So, it's a kind of contribution that people often, I guess, haven't thought in Debian where people actually use this normal in order to make a commitment to have a, so that was very nice. Yeah, it's not all about the goal. Yeah. There's work on going to have people who spoke at Debian, people who volunteered for the Debian video team or organization team and potentially even Debian fatalities show up in the list. For Debian fatalities we need to check because some people need to really opt in and not show up by default in that list. So, we'll see a bit if the system is good enough to make that happen. But yeah, there's been talking also like people running Debian boots conferences like this to show. It is possible. Yeah, you can have multiple Alioth accounts and manage them as like different identities and login in different ways to the site. What we miss is a bit of a guide on how to do it. For example, if you want to keep things separate, do not put, I mean, you can make one email for work and one email for other stuff. But then if you have a GPG key with both emails, things will automatically be associated with one of the two or the contributions done with that GPG key can only show up in one of these two accounts. So, it could be a good idea to have two GPG keys also. And that sort of thing should also the tips when signing the change log of a package. You can set this environment variable to choose which of the two identities you are using. Yeah, we miss a bit of a guide like that, which would be a nice thing to have. At this depth conf I even dropped the idea of we could have people having two Debian developers, I mean, being twice Debian developers with different identities and I would have nothing against it. And people reasoned, oh, yeah, yeah, that makes total sense. I was afraid that people would go like, ah, that's nonsense. Instead they were like, oh, yeah, yeah, sure. So, yeah, that would require two GPG keys and a bit of reasonably careful data management if one doesn't want contributions to mix up. The problem is that once an action has been done, there's really no way to revert it. I mean, when you sign an upload, an upload, that's it. That will show up in a thousand places. There's an email sent to a public clear card mailing list about that GPG key, that email address, signing that upload. So you do it once it will get credited and it will be pretty hard to change. So that requires a little bit of precision and attention. How did you get all the things to do? I mean, I think all the things around doing this are a very good thing and how did you get all the things to do that? I mean, I'm not something that I'm socially in and I guess all the things are not related to each other. So how do you convince them that it's good to do that? Partly, I've said that if one doesn't show up, they're not Debian contributors. And dear teams, do you really want that people do work in your team and not show up as Debian contributors? That would be really bad. So in a way, having this list is a motivation factor. For some of the important things, like the backtracking system, I actually went and wrote the data mining script myself and then I tried to tell, now you maintain it. I don't want to know about it. And it still runs as a consorb as my user in some machine and I'm upset by that and that should change. And sometimes, another one thing that works really well is sometimes I get an email saying, oh, I do lots of work in that team and I don't show up in your site. And I'm like, yeah, of course, because there's no data source for that team. Right one. That's the documentation. And they're like, oh, okay, I'll do that. And after a while, they're like, oh, now I show up, I'm so happy. So that also works. But there's not as many teams as I would like actually showing up. There is a wish list of the source code and the information for contributing are listed at the bottom of every page in the site. Wink, wink. And here is a list of data sources that we know we would like to have and some information on how one could help making it happen. So currently, we still do not track the localization teams because it's really hard to go and find who did some change because of the way things are done in those teams. But I don't know those teams, so it's hard for me to figure it out. But yeah. Oh, and we need the Debian Project Secretary to send information about when people vote. Because that's also counted as a contribution. And that's easy. This should be really easy. So hopefully. Yeah. What? No, no, the list is public. So actually, there is something. The list is not just public. There is a crypto thing for, so the list is, there's a list published together with some crypto token that you can use to verify that your vote has been counted or something like that, or at least received. I don't remember how it's this thing. Yeah. Well, the big missing thing is localization at the moment. This needs to be updated. The backtracking system now works really well. I'm very proud of the work I've done. Spent like two days on it. And now it's good. Yeah. So, I think that's a good question. People usually ask me about badges and achievements. And I don't want to add any to this site. I would like this to stay objective and not tell people, I'll give you a badge if you do this. Because I would really like this to be only about tracking and not about the security of the data. And I would like to certainly contribute to Debian and not start saying that person contributes to Debian more than that other person or that sort of things. If somebody wanted to build a badge system in Debian that they could build on top of this, because this is the first place in Debian that actually thinks about people and not about email addresses. So, I think that's what this site gets the user, the list of persons and ways of tracking them and then build badges if they feel like. But yeah, this I would like to just stay as a list of Debian contributors. At which point someone can be in the continued process? There are... Oh, sorry. The question was at which point one person shows up in the site. And this is up to the various teams in Debian that send data. They can decide what is a contribution. But I'll list the teams that we have and what it takes. So, to be credited by Debian System Administration is one single commit in their gate repository. Debian Security Tracker, I have no idea. Deスト Tracker, I also have no idea. Perle Packaging Group, one patch committed in their version control system. Backtracking System, at least five meals in the backtracking system. This is just one commit, just one commit. One blog post published in the official blog of Debian. Having participated to the Debian Conference once, although they haven't sent data yet. My question was... I thought contribution was a very good idea. Yes. When is the point that you take... She said she can contribute... Well, for Debian contributors, everyone that... For example, I find it back in the package. But you never thought I'd make... Okay, so the question is... At which point, what practical actual action you need to do to show up here? No, that was not bad. Are you asking what's the threshold so that your contribution will be affected? Yes. I'm very proud to submit it. If it works, I don't know any other... So thank you, pretty much no threshold at all. If you do a week-page edit of Debian. You will show up there. So thank you. At least for me, I spent years and years trying to figure out which package everyone's bagging and maintained and they were having the right package for me. And this changed the whole... So I opened my eyes and yes, you don't need to tell people who's doing what you're doing. So for example, about people that we can consider new contributors, we can have a look to give an example of entry. And this person has... has sent one package to be evaluated by Debian mentors. I can package maintainer. Maintained and did one edit the wiki for one day. It could have been just once. Lots of these people have maintained packages. Has been sending mails to the bug tracking system from July to August. So I guess opened the bug in July and kept the mailing on it. After five mails, one shows up in the system. And the limit of five mails is because there is spam that sends mail there. So we want to automatically filter out spam mails. Can I get an example of people doing anything that is not package maintenance? I guess there's still a huge amount of packages in Debian that people take. I guess. Oh well. Package maintenance. And package maintenance. Wiki editing. Yeah. I edited the wiki for a couple of days. Not continuously. Like maybe even just twice. The idea of this is that there's no official process. You do things in Debian. And for most of the things that one can do in Debian, there is no need of getting some official membership first. The only thing one needs to become official Debian developer is to vote and have an email address at Debian.org. But for pretty much anything else, it's just do it. And so as soon as somebody just does anything, one tends to show up here. As long as things are done in a team that has set up a script to send the data to the site. And if you don't know what to do in Debian, after since last week, we have the welcome team. And there is an IRC channel. Any questions can be asked. Questions will not be replied in detail, but at least one can get the pointer of what to do next. So that's another new thing in Debian. So that if somebody would like to get on that list, but doesn't know exactly how, then first step is going on that IRC channel and then asking. And somebody may ask, so what would you like to do? What would you like to learn and try to give some direction? Does that answer your question? I guess if there's no more questions, we can end it here. Thank you very much for...
A description of contributors.debian.org, the site that Debian uses to collect and acknowledge every contribution to the project. Its aims, its implementation, and where it got two years after its initial deployment. Enrico Zini
10.5446/19568 (DOI)
Welcome you to my talk, Drive by SSL Certificate Creation with Nginx. During this talk you will see what I mean by this, what I have in mind about an IDE, what Nginx is capable of. First of all about me, I'm Dominic, working for a hosting company back in Switzerland. We are compared to German market, quite small, but we are in the top five of Switzerland, top four. Everything is factor 10 smaller in Switzerland. I'm mostly developer there doing a lot of backend security, that's why I sell them, have to pick something on the website, that's part of my team, but not mine. You find me on Twitter, it's also my nickname. If you have questions, please ask right away and don't hesitate to wait at the end of the talk. I came across a capability of Nginx when Cloudflare in 2004 or 2014 announced that they give away free SSL certificate for all. They explain what they are doing and I followed along the Nginx community. We used the Nginx and the scriptable capabilities and I thought it would be nice having such a feature. Recently there was a patch contributed by Cloudflare and this talk is about this patch and the possibility. This year is 2015 and if Frostconn has a SSL certificate that is only for this specific domain, it has no SAN or Y-Cast certificate, they have reissue certificate every year. The same goes for if you are a pass provider, good example, Slack. Maybe some of you know Slack as a chat program. Each company has its own subdomain and I guess what they provide is a Y-Cast certificate. What would be really nice is having a certificate on the fly generation per subdomain. That is the whole idea behind it and I will introduce you to steps to build such a system. If it is reasonable, I don't know. It is more a technical challenge than a real use case but it could be. In the example of Cloudflare, it is a good example. About Nginx, written and spelled, it is a different thing. Nginx itself, if you are familiar, is more on the developer side. Who is responsible for server stuff and deploying? It is like the majority. I will skip this quickly. You know the second most used web server. His properties are high performance, low memory, footprint. He is a web server, he is also proxy, load balancer, you can do caching. Since the new version 1.9, you can also do TCP proxy. That is a new feature that they introduced. They came along with H8 proxy. The whole system is event driven and has a sort of business design. It started in 2002, went public in 2004 and now in 2014, Nginx.com, the company was built to have a professional support. The open source domain is Nginx.org, the commercial one is Nginx.com. Think of Nginx. It is like Batman, he can do a lot of things and he is great and he is established. He has all the good benefits and features. What makes Batman really, really a superhero is that he has a lot of accessories that he can use. The same applies to Nginx. Nginx has quite a small core. Nginx is capable of doing HTTP stuff, SSL stuff, but not much with a little bit of logging and a little bit of load balancing. In the ecosystem around Nginx are the accessories. People build in modules written in C to extend the capabilities or the belt of Nginx. A few examples, it is really wild west. If you look at the third-party modules, you see abandoned stuff, you see stuff like video thumbnail extractor or upload process. That is actually quite often used or a circle gift that is generating gifts on demand and resizing them. Drizzle is also a thing that is often used. It is a myoscal possibility to talk to myoscal within the Nginx scope and talk to Rettis as well. Another thing that I can... Here is a little example. That is actually two different third-party modules. This one is the echo module. It is not in the core and returns the value. The other one is the Rettis extension. The first one was shitty, they built another one. With this example, you can set different values directly to Rettis or read it and then do some dynamic low-balancing or configuration stuff. Another thing is Nginx because it is event-driven. It has different phases or different stages during the start of an HTTP request and handling and finishing it off. There are some steps in between, I left them out because they are mostly pre-imposed stuff, configuration, read and write. The important one are the rewrite phase. In this phase, you could apply different rewrites, how Nginx is behaving. The access phase is normal, what you know about HTTP authentication, try files, it is looking at the file system content, it is delivering content out of different file system database, different backend. Log is after the process is done, it is locked. Then you can apply filters, if the request is at the stage where you can push back to the client, you can do filtering of the header and the body. An example you can see here is the echo example. It is in the content phase. The set is actually in the rewrite phase. If you write a C extension, you have to decide in which event you hook into the Nginx core and what are the changes you are applying. Because there are different modules, you can sometimes mess up stuff from other people. Then there would be nothing without Robin. In my talk, it is Lua. Lua is a programming language. Lua is fast by design, not by design, because it has a very, very lightweight design. A good example is learn Lua in 15 minutes. There is a web page. If you are familiar with programming, within 15 minutes, I can assure you are capable. The syntax is so easy. Invitable is one of the features that Lua is famous for. For example, Far Cry and a lot of game engines have the possibility to write modifications in Lua. They expose different modifications possibilities. You see embeddability also in the automotive industry, where you have simulations and then you hook in. Lua is used in network switches as well to packet filtering and on-the-fly giving the scriptable language possibility to hardware boxes. That is actually from the 15 minutes. It is not the whole part, but you see the syntax is quite easy. You have no types. Numbers are always doubled. You have double and single quotes. You have multi-line. If you need something, it goes to garbage collection. You have loops and if-else, and there are some other constructs. What do you know from different programming language hashes or arrays? They have tables. They have no class support, like object-orientated. You can do stuff, but no rich functionality. It is mostly procedural programming. In the UND, Lua has a lot of accessories. Lua comes with a rich variety of different modules that can be written in Lua or in C itself. What I mean by this is a good example for this is an MVC. It is a web framework that is entirely written in Lua that you can use. In the Lua file system, it has some C extension to hook into the file system itself. It is like a C-json implementation exposed to Lua. What you also have in the Lua space is LuaRocks. LuaRocks is a different package manager in every language. It is quite limited compared to other tools that I have seen. Most of the time it works because people are not depending much on each other's modules. The JavaScript community has two lines of code, and everybody inherits these two lines. Then you need circle dependency resolutions and conflict resolutions. Lua is capable of compiling C-based code. If someone ships C-embedded Lua functionality with LuaRocks, if you have the right dependencies on your OS operating system, then you can install this module. As always, there is an awesome language GitHub account where they have a lot of summaries about different tools and stuff about this ecosystem. Then there is LuaChit because LuaChit was started as a project because the core or the language itself is so small. A guy, I can't remember his name, started the LuaChit project. Now you have the possibility to either use Lua or LuaChit as the name for testing time compilers. If you run this code in a continuous way, it optimizes on the fly a lot of code. This is very useful in a web server where you would like to apply web application firewalls. These rules have to be run over and over and over again. They get hot and they are optimized and compiled to machine code. They say 10 to 100 times faster than the normal Lua implementation itself. One of the main drivers behind it is Cloudflare as well because now they ship around 10% of the traffic worldwide. If they could optimize LuaChit by 5 or 10%, they gain a lot of capacity. Think of LuaChit as robbing on steroids. The nice part about LuaChit is that it compiles on nearly all systems and all process architectures. It is binary compatible. It means that you can switch from Lua to LuaChit. It has the same syntax and it works. It works on a PS3 or PS4 which is quite nice. One thing to remember or take away is that Robbin and Batman are two heroes. They are both hands with a community and tools behind it. That is not enough. You have NGINX and Lua. Now we are at NGINX Lua or HTTP Lua module. That is the package name on the documentation and the GitHub name. It is confusing if you are searching for the thing. It means embedding the power of Lua into NGINX. Here is a small example. You would like to get the content. Content by Lua means within these brackets you write normal Lua code. It gets interpreted and it is printing out HALO work. That is the integration. You have a lot of these. You have init by Lua, init worker. In it it runs once when the server starts when a new master comes up. In init worker is when the master process forks a new worker process. You have set by Lua. In the previous example you have seen set as a directive of NGINX. Now you can dynamically set things in the scope of NGINX. Rewrite access content, log header filter and body filter. These are the phases where you can hook into NGINX and modify it by yourself. It gains some attraction because you saw this wild west of C modules. People started migrating their code into Lua because the burden of maintaining a C extension in an ever-changing NGINX code was too difficult or too time-consuming compared to Lua. That is always the same or more or less the same. That is the reason why nowadays a lot of modules and stuff are moving to the Lua world. All stuff are ripped out or is dying off. Another thing that is possible is Lua file. That means in the difference here you write this directly in your NGINX configuration. Here you can specify a specific Lua file. I always would recommend this way because you can see the burden that you have with double and single quotes within the NGINX configuration. There is a fix on the way but it needs some time. There is also another benefit. The Lua code normally if it is embedded by Lua file then it is compiled. Meaning the Lua cheat compiles it into an optimized way. Then it is always interpreted from this optimized way. During development every single character that you change in the Lua file you have to reload NGINX to get updates into your NGINX. That is one of the tricks that you can do. It is that you during development disable the cache and then you can edit right away. You always see the new updates if a new request hits this Lua specific directory. Another thing is these are the parts where the Lua NGINX Lua API comes in. Within the scope of Lua you have to talk somehow to the web server. Meaning that you need some API to talk to the outside world of NGINX. The first thing is NGINX ARC. It is something like you have on the console, on the bash script or in every other language. It is like parameters passed in. There is some situation where it is happening. For example set by Lua. You can pass in parameters or in the filters. But that is rarely the case that you work with. Most of the time you work with NGINX VARs. A good example is outside. VARs always has to be declared outside of the Lua scope. Meaning that during the lifecycle of a request you could change the values. This is very handy if you have, for example, at this point, going to a proxy or to a proxy upstream and define the variable of the proxy. In the Lua code you could do health checks or you could do load balancing or intelligently load balancing algorithm. If you set the variable in the right phase, then NGINX is performing proxy stuff with this modified variable. Another thing is NGINX header. It is used to read and modify headers depending on the stage. If you are passed the lock phase, you are not able to modify them anymore. NGINX status is the HTTP status that is sent back to the client. NGINX context is also a handy thing if you have to pass information between phases. Meaning you have a rewrite phase that writes some information, extracted some information. You need this on a content phase. You can do context. If you are familiar with Android, it is like on an Android system, if you switch the view, you have to assign all the information on a context and then switch the view. Otherwise, these information are lost. That is quite handy if you are passing states or information along with different phases. Is that clear? Other things in the Lua API, NGINX Lua API are the output stuff. We saw NGINX say send headers and so on and so forth. You could do redirects, exit, subrequest. I will come to this later. And co-sockets. I have some examples about these two. NGINX capture. It is a nice thing. What you could do is you could do advanced cookie checking or spam checking. In this example, what we are doing is we are capturing during a process. We do a subrequest within NGINX and waiting for the response. And then we interpret. This is like an HTTP request within an HTTP request. And you can do multiple captures. There is a capability of doing parallel capturing and aggregating the information and sending them back. Another example for this would be if you have a central login server, you could always use NGINX as a proxy. And he is checking against this login server. Are these credentials sent by these clients are valid? For this reason, I let him pass. Otherwise, I deny the access. An example that I used to implement was like MailChimp newsletter. I wanted to have a custom newsletter subscription form. And normally what I have done is like posting on my own website, capturing the stuff with NGINX. Send it to MailChimp server with the API credentials attached. They are actually within NGINX. And then I modify the response that I can differentiate between different errors on the front and side. These are the possibilities that you could do with capture. Another thing is the code socket IP. A thing about NGINX within these phases, everything has to be non-blocking. And in the Lua sphere, normally you have these Lua modules. For example, simple HTTP or Redis implementation, and they use a blocking socket underneath. Meaning if you use this library within NGINX, it's not going to work because if a request comes in and you're blocking while waiting for Redis to give you an answer, every other request has to wait until Redis gives you an answer. And for that reason NGINX request soccer was introduced, meaning giving the user the possibility to do non-blocking socket connection, TCP connection. There are UDP connection as well, but not much space on the slide. But what you have to do is implement a protocol on top of the socket. A nice feature about this is you can use keep alive, meaning that if you're not closing the connection, if a new request comes in, it reuses the keep alive connection. That's a handy thing to get more performance out of it. A good example are the Redis memcache, MySQL, Postgre integration. DNS is actually a UDP implementation. What they look like, it's like you include the Lua Redis clients that's crafted for NGINX, or work within NGINX, and then you do your normal manipulation, reading, writing. Then there are lots of more stuff that you could do with NGINX and Lua. For example, you have LightFret, you can run some work offloads. I've seen people doing a job queue within NGINX. That's a funny thing because you have in it by worker, you could do things with this part. It's a strange thing in LightFret. It actually worked, but it's somehow scary. Shared memory access, meaning that because you have one master process and you have a lot of for worker processes, you could share a caching layer over all these worker processes, meaning that, yeah, and that's a reason why there are some basic caching algorithms within there to help with the cache. Also, Ragex is directly in the core for modifications and stuff. That's basically it, and there's some, yeah, some tiny little things that I never counted, and yeah, they are there, but it's not cluttered. It's quite small, but you have with this capture and co-socket thing, you could do a lot. Meaning that if you combine these two, you get a Batmobile. It's kind of cool. It's like you have NGINX and then you have Lua. You could do a lot of programming, but the problem is you have to build it. It's an own module. You have some people wrote on GitHub, Redis integration. Some people wrote the MySQL integration, and that's where OpenResty kicks in. OpenResty, it's actually a combination of NGINX, Lua. They could also use Lua as well. NGINX Lua, integration Resty, Lua, modules, and C-Lips, meaning aggregating a lot of stuff from the community and packing in the right space that you have a rich environment that you can start with and a normal Makefile. That's very handy. You download OpenResty, Make, Make, Install. What it's doing in the background, it's more or less, first of all, it downloads Lua.chit, compiles it and bets it in NGINX, compiles it with NGINX and NGINX with all the different C-modules, NGINX C-modules and Lua modules, and then place it on the correct system. I think that's not happening at the moment. There's no distro packages. What I normally do, I build distro packages myself, they're not that complicated, and I'm in touch with the creator of the OpenResty project, but he's so busy at Cloudflare. I guess I have to contribute stuff. There's also Docker image existing, but about Resty modules, the Resty modules, as you saw, you have modules coming from NGINX extending the NGINX score, you have modules coming from Lua extending the Lua modules with Lua or Lua C, and the Resty modules, it's always a mix between, I don't know, it's also a little bit Wild World West. The OpenResty project tried to only include modules that are well maintained, that work, that are tested. Actually, the testing of OpenResty is quite impressive. If you ever go on the OpenResty webpage, go to qa.openresty.org. They have heavy testing. That's the reason I never had any issues with OpenResty in our infrastructure. Another thing is, if you have to install things that are not bundled with OpenResty, please use Lua ROX and install it on one specific path. Within NGINX, you then can include this specific path of ROX into your current environment, and then use the installed... It's not very easy, you have to get used to it, but once you use it, you get it going. If you need a BMW, take Kong. Kong is actually an open source project from Mashable Ape. They do a lot of API, localizing, authentication and stuff, and what they build, they call it microservice and API management layer. What they actually took is... because OpenResty has the things that you can build your application on top of it, what they actually done is going a step further. For example, what they included is a central login layer, or JVT, decryption layer, and so on, the central login server, meaning that in an ever-changing environment, you have an API where you can manage your NGINX configuration. That's kind of a neat thing. You can add SSL hosts, you can add hosts, you can add authentication information, you can localize and shut things down. They use a Cassandra cluster on each node, and the information is shared in this. If you need something, and they have a plugable system, meaning that every one or two months, they bring out a new plugin that you can enable or disable a little bit of configuration, and then you have a new API endpoint where you can manage XYZ. That's kind of a cool and neat thing, and gains some attraction in the microservice docker community, because that's a big deal to dynamically low-balance things without changing NGINX configuration. One thing to take away is use ready-built test solutions, looking at OpenResty, if you'd like to be more on the basic side, or Kong, if you'd like more or less production-ready stuff. Take the fast lane in association with Batman and dropping, take the fast lane of crime prevention. Now, to the thing of my talk. What I was thinking, or I often, I'm active in the OpenResty community. We've been in our company for different services, and recently there was a patch about SSL by Lua, meaning that you could secure your SSL connection controlled by Lua. Batman and Robin, they have the same problem. Recently they were tapped, and now they have to introduce new mechanisms to make them safe again on their phone. This is actually a patch. It's not right now in OpenResty. It will be, as I mentioned, the creator of OpenResty is quite busy at Cloudflare. What they newly introduced is SSL certificate by Lua, and SSL certificate by Lua file. What it's actually doing is it's a step before the process even happens, that you could do SSL generation, SSL delivery, OSTP checking, stamp-ling. There's a heavy discussion on issue 331 on the OpenResty project. At the moment there's a branch. You can compile it. What I've done is I took the branch, and I took the OpenResty project. I was doing all the compilation and stuff, and swapped out the OpenResty... Because OpenResty is downloading Lua Engine X module, I swapped out this download with the download of this branch. At the moment you have to patch the engine core as well, because OpenResty downloads the Engine X core, and also the Lua Engine X module. What I had to apply was changing the branch in the download and patching the Engine X core before it's built. That's the thing I had to do. It's not that tricky. The thing is powered by Cloudflare, meaning that they run this since 2013 or 2014. That's definitely battle-testing. That's the thing that's driving their SSL-free for their customer. What they're actually doing is they partner with a CA, I'm not sure if it's a global sign. What they are doing is combining a lot of domains, generating sound certificates, and what they have to do internally if a domain or an SNI only supports SNI. If a SNI request comes in, they look up in which certificate belongs to this list of sounds, and they have to fetch their certificate from the backend. Because they have around 30 to 40 data centers, they have to do this on a distributed way. They do it on the fly, otherwise they have to send a lot of SSL certificates across the globe. Meaning if I hit now here a Cloudflare instance, that's not having my SSL certificate, it gets fetched on the fly. It's kind of a neat thing. I was inspired by this, and I can show you a demo about what I've done. I'll switch to the other screen. My setup is the following. I have a vagrant box running. I have a vagrant box running with NGINX and my Lua code. What I can do is if I request... Wait a second. Now, what I'm actually doing is the following. If the scroll is working, I open an SSL client connection to localhost, giving a server name, meaning a SNI connection, test.driveby.tld, giving a CA file, meaning that certificate authority file for validation, meaning that checking the certificate that I get back, if this CA signed this certificate. What we see here, it's verified, verification chain. What I add dynamically generated by Lua at Saturday 8.40, because of time zones on my machine and in the vagrant box, that's actually the two hours difference. If I hit it again, meaning I could get the same, but a little bit later, now it's 44, and the CN, the common name. If I change it, I take the short, then the information are here. If I pass in another subdomain, subdomain, Glyph 2015, for example, then I get a new SNName, meaning the certificate is valid, but the NGINX core generated on the fly SSL certificate, and then in this returning. The same, I can show you with a fresh Firefox, if you work with Firefox and install a lot of demo drive by TLD. Not working. Ah, now it's okay. The thing is that I, ah, the stupid, if I connected to the Internet, then the thing is I have a DNS mask entry within the DNS mask set up within the network manager. If I'm not connected to the Internet, then DNS mask within network manager, it's not responding, that kind of a bummer. But what I wanted to show is what you could do on the fresh installation of Firefox, you could add the certificate authority, adding a new certificate, and then I can go to every subdomain and I get a valid browser certificate or no warning. Um, is that example clear what I wanted to show? Yeah. Yeah, never mind. The actual code. No. Sorry about that. Not starting at the point. The code in Lua or in NGINX, it looks like this. You, first of all, I include the module REST-SSL. That's an extension coming from this SSL patch. Then I need open SSL for the whole certificate generation, key generation. P-key means like there's a public key cryptography. Then I require a CSR, certificate sign request. Afterwards, I load in the CA, meaning the certificate authority certificate. Load the thing from the file into an object that's actually the certificate. Then I could do manipulation on the thing. The same happens to the key of the authority because with the key of the authority, I have to sign the newly generated key certificate. What I then do, if it's not a SSL server name, meaning if it's not an SNI, if someone connects not with an SNI name, we drop out because of this limitation. Then I start with a new certificate request, meaning the subject. That means the region generated by it. You see here that's actually the date. It's always included. From the SNI name, the SNI name will be the so-called common name. What I then do is generate a new public and private key pair for the new certificate. Afterwards, I assign the key to the certificate and generate a certificate request. The certificate request then from the certificate request, a new certificate is issued. Actually, I had to change this because Firefox is blocking. This is the serial number, meaning that the certificate authority have to increase the number of the serial for each certificate they issue. Firefox is actually checking this. I had to do this morning a little bit of hacking to overcome this issue. Now it works. It's not actually the code on the server. It's not the same. A little bit modified, but it's more or less in the same thing. Then I set the validation time. What I then do is taking this, the naming is wrong, meaning that the client certificate or the certificate is signed with the key and the certificate of the authority. Here, that's actually where the magic happens. I guess in Cloudflare, it looks like this. The thing on the top is the generation and signing is somewhere offloaded. Meaning that the only thing that they do on the fly is capturing the response and certificate on the fly and setting it and caching it on the local server. What we then do is clear the certificate that we had in the engine configuration, set the certificate in the format of the DER, meaning a binary string, converting the binary string to the certificate into a binary, the same goes for the private key of the new generated certificate. That's all the thing that you need to do. At the moment, it's a little bit of tricky to get everything right, but I think in the future you see a lot of application. The first idea was at the moment, if you heard about Let's Encrypt, that's an initiative from Mozilla, Akamai, Cisco, they build an automated system to get you free SSL certificate. My initial idea was going to an upstream server to the Mozilla server, so I was writing a valid public certificate reissuing on the fly, meaning that every time someone hits the server, I get an instantly valid certificate. I never have to think about reissuing or stuff. Everything I can write down in Lua. If someone hits the first time, he has to wait, I don't know, two seconds off or something, or I don't know, a minute, then the request responds, but the request afterwards, it's okay. Or I can do a cron job that is doing that every night. That was the basic idea. At the moment, we are implementing this for our web hosting customers, and during this work, we saw that the API and the specification is changing too radically that I could adopt these changes all the time before the talk. I started with the adoption and I ran into the problem that actually the OpenSSL project had a lot of issues. First of all, I had to fix a lot of C code issues within this project before I could go on, and that's why we have only a simplified version of that. Nina's say, securing in an ever-changing system is hard, but it's also possible that you can introduce security layers or dynamic stuff on the web server. At least you can try, but don't produce snakegoys. One of the pitfalls that I learned during my years and also preparing for this presentation, if you do a lot of engineering configuration modification, please always run service engineering conflict test. I had sometimes the issue that I thought I had changed something, made a reload, but actually if you do a reload and you have conflict issues, engineering is doing nothing and says nothing about it. That's the reason why I always do service engineering conflict test and then a reload. The same happens if you do a lot of conflict changes. I have a when change, which is a little small Python script. If the file changes, I access H into the server and do a conflict test and reload the server. I also fell into this trap, like the escape characters in Lua. It's not very intuitive, but better than Ruby. As I mentioned, always use Lua by file. It's easier to handle with and no escaping. If you'd like to read post-words in an access phase, meaning like one of the rewrite or access phase, then you have to do an additional request head body, meaning that in the face of rewrite and access, NGINX has not yet loaded the body or the post information. Tips and trick debugging in an NGINX environment, especially in a dynamic NGINX environment with Lua. It's not easy or actually hard. I was burned many times, like little pieces that, yeah. One of the things that I often do is like adding debug information to the header information, meaning aggregating information. You could log all the information, but the thing is on the log sometimes on a business, it happens so much thing. What you could do, I have special tags and if I specify this hidden tag, it gets me like debug output on a live server. So now that's just kind of cool neat trick. What you actually also could do is like generating a tracer, tracing ID, and then piping, you know, or giving this tracer ID as a header parameter parameter to the web server and then going through your logs. That's also a possibility. But I found the NGINX header dump the easier. And if you're looking for code or useful example, actually the OpenRESI project has very good tests. And for this SSL talk, I had to look many times in the code because it's at the moment is not yet documented. And there are some conditions where the documentation lag. Yeah. And I'm at the end of my talk. Thank you for listening. Are there any questions, regards, or concern about the stupidity about this project? Yeah. What was the future ratio on the server that you have in terms of the problem? No, what I do now, it's kind of a silly example. I generate for each request a new certificate. It's kind of stupid. It's not, it's not. But what you normally could do is offloading money. As I mentioned, people doing worker demons within NGINX, you could do the same. It's like if the first request hits the server, you could offload this to worker. Then it's in its own worker and it's not blocking the other requests. Yeah. But you could do, or... Okay. No, they run under the NGINX user. Meaning that I had to give well permission or at least for the CEA, for the CEA certificate I had to give permission to the NGINX user. Yeah. But normally you do this in a secure backend and then you get, yeah. So I'm thinking that in principle, we also for other users, just for the sake of the NGINX user, we don't see a certificate of other clients. Yeah. Where the case is attached or back into the client, how much the NGINX certificate. Yeah. So, for the reason I need the private key to sign, otherwise... No, no, no. My use, yes, this use case, yes. But the use case of LatinGrip, for example, I go into an HGT backend and they give me an SSS certificate. I could also program that I log into the complicated website and do web scraping of global sign or something else that's not limited to this because we flew out of the capabilities. Yeah. But for this purpose, because I'm not a CEA, I have to trick the browser to accept me as a CEA. Yeah. The initial idea was going to an official CEA where they have a REST API where I can issue. Yeah. Okay. So far, Bova Jaskity. And thanks to agent CH, that's the guy behind all the RESTy stuff and CloudFare for the contribution. And hopefully we'll see some of you in the OpenRESTy and GNX Lua community playing around. Thank you so much. Thank you.
When working with webservers it's sometimes necessary to introduce some dynamic parts in the life cycle of an HTTP process. nginx provides this possibilities with an integration of Lua. On the example of dynamic SSL certificate creation we explore the capabilities of Lua within the core of nginx.
10.5446/19565 (DOI)
So, hello everybody. Nice to be here. I hope everybody can hear me. So if not, just tell me something and we can do the mic. All right. I'm David. I'm a computer scientist from Bonn. So actually pretty close by this conference I come from. And in real life, I work at IVU on topics like release engineering and machine learning. And data science. But this presentation is about something completely different. You know when you visit IT security lighted presentations, afterwards there's always some kinds of devices you don't really like to use anymore. So a little disclaimer. If somebody has a special relationship with this copy machine, so this presentation is not really for you. In this presentation, we will do three things. First, we will look at one of the most common and most dangerous bugs in the last years. Second, we will try to make it plausible for techies and for non-techies. And third, and I believe that such a story might happen to just everyone here. So we'll look at how a single person can deal with going against a big company. So we will be talking about how this developed and which mistakes I made. And we'll derive take home messages for you to rely upon in case you face such a situation. Hey, how are you doing? The presentation is a little bit like a novel. So and as such, it starts with a prologue for the conspiracy theorists among you. The year is 2008. In 2008, there's no joke, but the people are laughing already. The primaries took place in the USA with Barack Obama against Hillary Clinton. And as everywhere else, politics in the US are a comedy of intrigue. So there was anonymous mails that should be useful to Hillary. It was held that Obama was born in Kenya as a Kenyan citizen and thus not fit for being a president because he needs to be a natural born citizen of the United States. And the term natural born citizen is actually not properly defined. The Americans are not really sure for themselves. But there is a consensus. You need to be American and you need to have been American at birth. And you can imagine that Barack Obama's second name Hussain was also not that optimal in that context. So then to have it done, Obama published his short form birth certificate depicted on the left. And if you're a good conspiracy theorist, you're not going to be dispelled by facts. And like immediately, there were claims that the certificate was false. And like a stamp was not on the right place and stuff like that was held. Now, on the right, you see some bumper stickers. The lower ones explicitly asking for the birth certificate. So even though Obama won the primaries and the presidential election 2008 that followed, the controversy did not really stop. The theory Obama isn't fit to be president is surprisingly popular in the United States. This is named the Bertha movement. And they want to prove Obama is not a real American. So this is actually true. So two and a half years later, when Obama was already president, the discussion still wasn't over. So Obama was really pissed off, you can imagine. Obama published the long form birth certificate shown on the right now. So as you can see, there's more information in it. So you could say now it would be quiet. But again, there were claims that the birth certificate would be false. So let's look at it a bit in more detail. The left image now is a strong magnification of the placemarked red in the right image. And as you can see, between the different letters, between the 1 and the 4, for example, you can see it, there is a clear differences in gradient and sharpness. The 6 and the 4 are perfectly pixel at sharp and uniformly colored, while the 1 is slightly unsharp and its color has some noise, like you would expect from a scan naturally. So how is that there is such a difference in one and the same line? In this additional example, you also see similar differences between the two boxes marked. So again, one is like you would expect it from the scan and the other one is sharp on the pixel level, like somebody drew it with Microsoft Paint. Oh, look at this, this pure gold. This part of the image is taken from the stamp. And it looks like there was a typo in the stamp. Yeah, sure, right. How likely is that? So of course, people believe the birth certificate is forged when they see things like this. And additionally, one believes the White House in turn is to stupid to use Photoshop. So of course, for Obama, that was a major PR, fuck up. And just get to see this thing is huge. In an CNN poll of 2010, at least 11% of the US public believed Obama wasn't born in the USA. And an additional 16% that he probably wasn't born in the USA. So this is a quarter of the US general public. And even today, the White House gets requests for comments. And now we jump to 2013. At the 24th of July, 2013, a company called me, they have two big Xerox Work Centers. Xerox Work Centers, those are huge business copying machines that like every company has now. They have network, they can scan, print, and fax, and email, and everything, and they cost as much as a little car. And that's not your grandmother's printer, but they may have hundreds of users per machine. And on the slide, you can see a blueprint. And the black places are not original. I blacked them out because I couldn't have used this blueprint otherwise. And there are now three yellow places. The yellow places are standardized blocks, which show the area of the room in square meters. We talk about those now. The company said, hey, David, if we scan the blueprint to a PDF, then there are different numbers on them. Can you take a look at that? So on the left, that's me, you know. I have to say that I always had good atmosphere with them, and I've been doing a T-service for the company a long time. And obviously, I thought they were pulling my like, sure, right, yeah, a copy of changing numbers, sure. You hear that every day, of course, yeah, that's what I thought. And they said, no, really, no, really, come, look at it, look at it. We need this machine. It has to work properly. OK, so I went there and took a look, still thinking, mm-hmm, yeah, that's just a prank. And they have Xerox WorkCenter 7535. And here are the three original image segments before the scan. So we can read that at the top, there is 14.13 square meters, and then there's 21.11 square meters. And at the lower one, there's 17.42, right? So I put the blueprint into the WorkCenter, and I scanned it. And here's the same place after the scan. So apparently, that's quite funny, right? So all the rooms now have 14.13 square meters. No way, that's impossible, this isn't happening. I still thought that was a prank, yeah. So just to say, I had to say this a lot of times, there's no OCR involved. The replacement of the numbers happens at the pixel level. The company had another WorkCenter, the 7556. That's larger, and it's a bit faster. And there are many, many more like this. It's a huge family of machines. On the small WorkCenter, there were always the same numbers that came out, like you see, and on the big one, every scan, there were different numbers. It's bigger, so there's more CPU power, I guess. And look at those numbers. For example, place two, this is the row in the middle. First we have 14.13 square meters, and next scan we have 21.11, and the letter would have been the correct value. So after all, there is a chance you get correct numbers. So if anyone needs an SACQ, random number generator, you can ask the Xerox company and they have one. So also, this is not very funny, but I'm laughing too. Also, the numbers look absolutely perfect in the layout, and they only noticed it because a room that's obviously bigger has a smaller area than the smaller one next to it. I know that the font is very small, but it is not some strange corner case. We have some more examples, but this is the original example where we found it, and I wanted to show that to you. So here's the next example. This is the cost register. You see that a six turned into an eight. And the joke is really that later I put this image on my website, and I was like, look here, a six turned into an eight. And next, some reader emailed me, oh, look here's another one. So again, it looks perfectly clean in the layout. It looks perfect. You can't really see it. This time, we noticed the errors because the numbers were sorted in ascending order. Consequently, if the numbers make no obvious sense to you, you can't see they are wrong. You always have to have some semantic criteria that make the text implausible, otherwise you don't find out. So as you can see, my neck gets longer and longer. So I tried reproducing it. Like a good computer scientist, I did so at night. I made columns of numbers in different sizes and different fonts and scanned them. Are you done? And scanned them. And lo and behold, I could reproduce the error. The eight that are yellow should be sixes and should not be the eight that we see there. So we stop for a moment here. I promised that I'm going to show you the entire interaction with Xerox. And I'll tell you what I felt at different points in time. And every time I stress those things that are very important, if you have to find against a big company, I will also show you a proof about this. But I will tell you one thing up front. In my eyes, what does not help is becoming offensive and hating publicly in particular by Twitter. This is not helpful. I have no problem with Twitter at all. But if you want to do something, if you want to achieve something, you just make yourself a target and an idiot. And nobody is going to take you seriously. And they will tell you that you don't really want to have a discussion because that won't fit in 140 characters. They can always say that you only want the show. So I don't want you to do these things. What do I want you to do? The best thing is to not make it publicly initially. So write emails, I call them. So we call Xerox support several times. Very often, we call every single support level up to top level in Dublin. And nobody knew a single thing. We wanted personal contact as well. So Xerox people who were at the site, they didn't know anything either. So they were not real Xerox people. They were just working in commissions, some distributor. So they tried to reproduce the aros. And they did. We are laughing about this. But they were standing there with their pants down. You know, imagine somebody is coming along and it looks like he's crushing your existence. So Xerox, et cetera, not the support company, but the very Xerox company. They were a bit surprised, yes. But they didn't really try to help us or the support film. So sort of they say they respected the problem. So well, that's all. And there were no signs of bigger interest or any advice how we could get rid of it. And somebody came from Xerox and gave us new firmware. It didn't help. But I was like, oh great. Now we know that the problem existed three years ago as well. After there hadn't been a sign of progress on the site of Xerox after more than one week, I thought, right, that would be enough. So I wrote a blog post in German and English about what I just told you now. And I offered some test documents the readers could download to print, scan, and see if they were affected. That's how the story started to spread. I have to say my blog isn't huge, not at all. Maybe 500 to 1,000 readers a day. That's not a lot, but it's not nothing either. Most of them are IT people. That's what I know from the emails that I get. On the button of my slide, you can now see a line. It's a plot of the page views. It's going to get wider and wider as I continue to speak. It's a sign of how much attention I'm getting at the time. So let's test that. You see the small bump there? That's a peak of 3,000 hits per hour. The numbers come from Google Analytics. I have been told you're supposed to multiply them by two or three, but never mind you get the idea. On the second and third of August, the story spread on some tech blocks. The peak you see is from FIFA's block. The German people in the audience probably know him. So the story spreads and I get more and more email from people who are affected. The funny thing is I also get loads of confirmation for Xerox work centers I've never heard of. So I told you it's a whole product for me, a family, and so I'm starting to think this might be something huge. So lesson learned, it was good to provide the test documents right away. If I hadn't, people wouldn't have been able to reproduce it for themselves and the story wouldn't have spread that much. On the fourth of August, the story spreads worldwide in tech portals. In the picture is Hacker News, you probably know it, and I'm getting hundreds of emails from people with technical knowledge. I start spending a lot of time to channel the email I'm getting, and only that allows me to continue the story and to follow the rabbit hole down to the bottom. I'm not allowed to sleep anymore either because I start to get lots of calls from US reporters who apparently don't know that time zones actually exist. Lesson learned, write in multiple languages. Important of course is English for the international readers, but also the home language of whatever company you're targeting. You may know that Xerox is so widespread in the US that there's actually a verb for it. It's to Xerox. And whenever something goes that big in the tech world, what comes next? Mass media. So that's where it starts to get huge. This is Der Spiegel. It's the largest German news portal, and I'll click through a few now. It's not an exhaustive list, not at all. There were thousands of articles worldwide, and I'm just going through it, however it suits my talk. There's no statement about the published states of the articles. And as a side note in before, a German journalist told me that he wanted to bring it into Targass Schau, one of the biggest German journals. And they told him, yeah, yeah, this is really cool, but we want it to happen when you photocopy, not just when you're scanning. So maybe someone should tell them that if you print a scan, you do have a photocopy. Never mind. When learned, don't make it bigger than it is just because you want the attention. The economist, now it gets really serious and also expensive in terms of PR for the company, and you also can see where I stole my lecture title from. ABC News, even more expensive. BBC, CNBC, suddenly it was everywhere. And believe me, this feels completely surreal. And if you do shit a few big ricks in such a situation, I won't blame you. I found myself getting up several nights just to prove, read my own articles and make sure I described everything correctly. That's what I did. I wanted to make sure not to get sued on millions of fairholder value right at the start of my own professional life. At least that's what I thought. We'll get to that later. So this is Business Week. It's a popular business magazine. And until now, there was no reaction from Xerox. And if you react that slow, it's getting pretty uncomfortable. Here comes a citation. On the scale of things, too horrible to contemplate, document altering scanner is right up there with flesh-eating bacteria. Yeah, that's an original citation from Business Week. That's Peter Koy. Editor there, and we will get to him a few more times in this presentation. Now my blog post went up to 100,000 readers a day. And still no reaction from Xerox. And in the meantime, I managed with the help of my readers to show what actually happened. And in a minute, I'll tell you about that in a small slide in about image compression. But before that, a small remark. As this thing exploded. I first used some non-standard technical terms in my descriptions. For example, I used pattern instead of symbol. So and after that, I got some emails which criticized and corrected me, which I am thankful for. However, if this happens to you, don't feel discouraged by mistakes you make in the details. At the time, I had to deal with Xerox. I had to write my articles in German and English. I had to storm-proof my internet servers. You'll get, you'll bet. But I had to deal with the press. And additionally, I had to understand what was happening at image compression level. And just let you know, at the time, I had no academic interest in image compression because I'm more the machine learning and data science kind of guy. So that's a lot. And normal management means to not let anything catch fire, but crisis handling is completely different. There's a lot of fires already burning. And what you're doing is running back and forth between them to just make sure none of them gets out of control. So stay at one of the fires too long and you're done for. So lesson learned, make sure you understand what's going on, but don't lose yourself in details. Now for the image compression. This is a test image I photographed. Both the photo and the text are part of the image. So we have different kinds of test image data. And you know that data transmission is time, money, and storage intensive. So you don't want to transfer images uncompressed. That's why there are lots of compression algorithms for images. Now there's two parts of the test image. One of the photo, one of the text. They are very much enlarged. So we can look on pixel level what can go wrong with different compression algorithms. So there are lots less compression methods where no information is lost or if you want to get the file even smaller then there are lossy codecs. This is the popular give format. And give is lossless, but does only support 265 colors. So the visible loss of information comes from the color reduction. And give is good for graphics with few colors and sharp edges are preserved well. So as you can see, it's less suited for photos. Now we have JPEG which is lossy. And this slices the original picture and 8 by 8 pixel blocks and they're approximated with cosine wave how exactly this is mathematically done. I won't bother you with. This is really good for photos, but bad for text and sharp edges as you can see. So different compression algorithms are good for different kinds of images. And the more advanced compression strategy involves slicing the original image into several sub-images we call symbols. If you know the kind of image in every symbol you can use suited confessions algorithms for each of these symbols to get very nice images. The spaces that don't belong to a symbol don't even need to be saved. You probably agree this is quite an improvement compression, but you can use the slice to symbols approach in another even more advanced way. You can see every letter as a symbol. This is actually done, I didn't make this up. Usually that's what is done when an image is compressed to JPEG-2 format. JPEG-2 is an image storage codec that's especially suited for images from scanned text. Next the encoder looks what symbols are really similar to each other. Like the symbols I marked here. That's all small ease. That's why they're similar. And they have only very few pixels that are different. The step is called pattern matching. So you get groups of all the similar symbols. And for every group we save only one representative symbol and that is used all over the image instead of the other group members. Only one of those ease is actually saved and consumes storage space. And all other ease are replaced by the save one. You can save lots of data and don't have to fear about image quality. And here you get the result. So there's some quite nice quality and use much less data. Use looks good, right? Did you see it? Pattern matching thinks that the small EI is similar to the L. That's what's happening when pattern matching is not exactly accurate. Having simplified, JBLIC 2 has two usual modes of operation. It can be encoded lossy. In this case it works exactly like this. Or it can be encoded lossless. In this case in an additional step, errors like these are corrected before saving the image. It seems like Xerox used a pattern matching approach and accidentally left out the correction step. So did you see those at well? So that's dangerous mistakes. Normal compression artifacts are not that problematic. They produce unreadable text and you can see something is wrong. But here you have perfectly looking and layouted letters that are actually incorrect. You really have to read them to notice errors. And even then you don't usually notice them because if they don't make the whole document implausible on first glance you just don't get them like in the blueprint. Also I don't know what you do but I don't usually prove read my scans after I produce them. So a politician who has to put this in a positive light would say use such Xerox machine to scan the medicine doses of a retirement home. And there's a good chance that you will relieve the pension office from paying rent mask monthly income. So is here somebody from Berlin? No? So otherwise we could have asked which machine they used to multiply the blueprints of the airport. So airport medicine elections as big as those are. That's all small stuff. If such scans were actually used as evidence in court that's where it gets really interesting. So now if you assume me on which with such a Xerox scan I would just say you know that's false. And you can't prove me wrong. So you can't even prove anymore that a place in the scan comes from the corresponding place in the original paper document. The legal value is zero and that's business appliances. There are hundreds of thousands of such machines. Each of them has maybe hundreds of users and even more people getting handed over documents by the machine. So for example I was called by a big business. They scan every incoming mail automatically and from this point on use the scan. So if they use such machines good luck. So we'll get back to the implications later but let's go on with the story. It's now the 5th of August three days after the first impact and then got created a life sign of Xerox. The PR of Xerox Germany calls me and it was obvious they can't really do anything without the Americans. They thought it was just a prank and I said no it's no joke. And we agreed to stay in touch. And the day after that the 6th of August it was the first one where really things started going. In the morning I got this screenshot from a reader from his Xerox machine set up. It talks about character substitution. So there are three PDF compression modes. There are normal, higher and high. Very PR compatible names. Normal is the mode that compresses the strongest. The reader says in normal the error is there and in the two other stages it's not. As far as I could tell at that point in time that was correct. More on that later. And I promised I will tell you how I felt during that. And to be honest I was a bit afraid. I thought I was being portrayed as the idiot who didn't read the manual. So till now there was no official statement from Xerox and I was tipped off that Xerox was about to write something like that. So lesson learned that the internal view and the outside view is so what's the deal David? Such a problem must never happen not even if you know about it. So but from the inside the world looks different in such a situation. So once such a story happens to you guys you're prepared now. But if you remained calm from the beginning on and didn't hate you can just ask colony in the public why didn't support tell me that two weeks ago. So I started some forward defense. I presented the screenshot on my blog as a possible work around and I recommended to set compression to high. And I was curious why support couldn't tell me that. And I also criticized the setting was called normal. And all the consequences remain of course. And I wanted to give the story a spin because Xerox was about to get on my back. And now it gets crispy. The same afternoon there's a conference call with Rick Destin, corporate vice president of Xerox and Francis C which is one of the chief engineers. And guys that's really something. You see at Xerox the boss is doing support himself. So Rick Destin is the first one to whom I talk who actually does work at Xerox who confirms that character substitution was indeed known at Xerox. So if you have a problem and call support and talk to them for like two weeks and they can't tell you anything then you ask may I please talk to Mr. Destin. And they confirm it was correct that the pattern matching is responsible and they also confirm it is only done in normal mode. So we agree that first support fucked up. And second normal was probably not an optimal name for the setting. Yeah I recommend that experimental. Yeah right now it's a lot of fun here but at the same time I was quite a bit scared believe me. And then Xerox gave me a fairly crystal clear RTFM which is abbreviated for read the fine manual. And first the normal mode isn't the factory default. Yeah they told me. Dear customers you are all stupid. Why do you set it to a different setting? And second the manual also says that letter replacement can occur. So you are all doubly stupid. So well that's only half the truth. For the customer of course factory settings is the setup in which they get the machine and they don't usually get it from Xerox themselves. There are third party companies from which you get the machines and they do consulting for you and they set them up to whatever settings. As for the manual actually there is a mentioning in one of the manuals on page 107 of 228 and we are all old enough to know how many people always read manuals 300 pages thick before they use a copier. I also was of the opinion that copiers must not be designed in a way that such errors can happen on whatever setting. No one's expecting that. And the answer was oh yes that may happen. And the market demands the small document sizes. Additionally I was right and they confirmed that you can't prove that a particular document has no errors. So if I claim it's false you can't prove me wrong. Overall there was quite a nice atmosphere and they didn't threaten me legally and they listened to me and it was a long talk and then I really let myself be caught in a trap. However I never did anything of that scale and at Xerox of course they had professionals and after a while I was wondering why we could talk so long and in that relaxed atmosphere despite Dustin is corporate vice president of a huge company and he probably had other things to do. So it turned out that during I was on the phone with them. They released the press statement. Not stupid because that's the time at which I cannot react. So always listening to our customers was the title. Indeed so. And they say who wants data integrity needs to use a compression setting of high or higher and furthermore they say the manual had the info RT FM. Lesson learned always have someone else watch the website of the adversary when you cannot react. So I also wrote an article on my blog and told about the telephone conference and reported about what I just told you and I also wrote that I don't think there are off the hook and now what? That could have been the end. If a single guy fights a huge company either the company shoots back and the guy caves in or the public can side with the big company or the public just loses interest. And nothing of that happened. You can see the huge spike in traffic. My blog article was on the page of slash dot. Unfortunately the press got on my side. Here is Heise the most popular German IT portal and they stated that I presented the work around even before Xerox did. Which is nice. And here Derspiegel stated so Xerox knew about the problem for years. Now that's something. If you work for the PR of a company and something like that happens that's really nice. You can screw your holidays for the rest of the year. And it gets funnier and funnier. If you have ever been to the US, when it really starts getting ugly they say shit hits the fan. The next day my blog article was on Reddit and you can see the next spike in the plot and what you see at Reddit is the nicest, most eloquent version of shit hits the fan that I have always seen. Fecal meta will indeed hit the rotary error impeller. So however what the guy writes is true. If a company relies on digitization of documents and nowadays honestly who doesn't. They all have a problem. They can close the shop if it's really bad. So to give an example a state run archive called me and they created their entire archive with Xerox machines and what did they do next? Well they threw away the originals. In theory they now would have to look at the documents and check them for plausibility and even if they did they couldn't be sure. So if you ever see some keeper of an archive staring out of the window gazing at nothing you see why. You know why. Also internet jokes are very nice. This is Niengeck. Oh oh you know we are in lecture hall 8. Maybe it was supposed to be hall 6 but then they scanned their blueprints and sometimes the really funny jokes come from the protagonists themselves. So if you are corporate vice president Xerox and have to give interviews on the same topic all day something that just will slip through. You don't need to read. I'll just read it for you. Speaking to the BBC. Destin wanted to relativise the issue and said hey well this is it's not really that bad. Yes the normal compression mode can create errors but nobody really uses it. For example the military and oil rigs and such. So what's the worst that can happen right. Yes you probably know problems on oil rigs are not looked upon very kindly in the US nowadays. So perhaps this is the right moment to say again a bit of a laugh is okay but imagine yourselves in Destin's shoes. Imagine you really have to talk about this in interviews on the phone for like 14 hours. It's more than human that you let slip something. Also he told me afterwards he had been quoted out of context and I have no reason not to believe him but still I thought it was funny. Here's a tech portal that is happy that cat images seem to be not affected. So as you can see they're not sure reportedly. And here's also a new press release from Xerox. Under the public pressure they say oh maybe yes perhaps we're going to make a patch in which we disable the pattern matching stuff. So they never admitted a mistake or problem though understandably they have to cover theirs. So what if you wait that long then even announcing a patch doesn't help you. Here's a newspaper that put Xerox like error in the title on purpose. But now let's go back to the Xerox statement. There is an important and crystal clear message in it. You will not see a character replacement if you set compression to at least higher with at least 200 dpi. They also published glossy documents saying that pattern matching is only done in the normal compression mode and not in the higher ones. And now I was quite sure I had seen the problem in higher modes and users told me that too. Unfortunately I didn't manage to reproduce it on my own devices that I had access to. So I'm just not putting out any rumor because if it did happen in other modes then everyone would be affected. And Xerox communications had been misleading and they had a much bigger global problem. It would be a disaster. But a friend of mine in Bonn where I was living at the time he had a work center 7545 in his office. And we went there and scanned my test numbers and used the mode higher and even 300 dpi. So we actually were quite generous. And now look at this. The yellow numbers have errors. I just marked some of them. I don't know if I got all of them. But still you can see how frequent it can occur. So I repeat that it was in mode higher with 300 dpi. So lesson learned. When you find a bug it's unlikely you see the full breadth of the issue at the beginning. So we now take the blue rectangle and have a closer look. Here you see some groups of digits that are marked red. The digits within the red rectangles look absolutely identical on pixel level. That's very unlikely. It's always going to look a bit different if you scan it naturally. And lots of digits that look exactly the same. Pixel by pixel that's a clear sign of pattern matching. So despite what Xerox told us pattern matching was done here. One of my readers built a nice visualization that marks equal digits in red. They are marked when I hover them with the mouse. I can see if I can get it to run. Yeah, there it is. And now I can hover. And you see the red runs those are the very same. This is the usual frequency of the two. And you see there are several versions of the two. So that's how it works. And you can see how many there are. So now in this point it is clear that hundreds of thousands of large business devices worldwide are affected in factory defaults. And by publishing something like that you can really damage a big company. So I did not want to publish that without at least trying to talk it to them in before. I'm sorry? Yeah, yeah. I come to earning money with that later. This is really an interesting point. I don't underestimate that. To tell you again how I feel at this time there was lots of pressure. So I wanted to make sure that I did not make any mistake and could be sued on loss of millions on shareholder value. And so I recorded the whole process of producing wrong digits on video and uploaded it unpublic on YouTube. And I sent a link to Francis, the principal engineer mentioned before. And they were a bit shocked, you know. And Francis told me on the phone that I did everything right in my video. And Xerox was cooperative, but they wanted me to wait until they could reproduce it the error by themselves. However, I remember I felt a little bit fucked over after the last conference call with them. So I said, guys, you know what? This time let's do that differently. So please be informed. I have a blog article written on this ready. And as you can see, I already uploaded the video too. So don't take this the wrong way. But this time I want you to keep me in the loop. And that's how we agreed. And there's a lot of falling back and forth. And because of the time zones are literally spent the night in the office and only had some biscuits. And finally Francis calls me and tells me, yep, we have reproduced it. Factory replacements, factory defaults, everyone was a bit shocked. And you know what they told me later? The code for the compression kernel was eight years old at the time. This bug has been in the wild since 2006. And with that being the case, we were all a bit muffled. So next I said, hey, have a look at my article and make sure that I've got legal safety so I can push it out. This bug is really dangerous. And I don't want to wait longer. And they did. They did it. And they even allowed me to publish it before they published something too. And that's why we shouldn't hate on them. Lesson learned, negotiate at the right moment. Right afterwards Xerox bought their own statement, they take back their previous communications and even said thank you and wrote they now will have to investigate how big this issue is. And that's where they started to be really nice in the press statements and the whole climate was very constructive. In the press because of all the flip-flopping, the whole thing becomes more and more surreal. This is slashed out again. Look at the title. Apparently to them it doesn't matter what Xerox says, but only what they confirm to me. Here again is Peter Koy from Business Week. And I've got one more for you. One more for you. I mean one compression mode. Never mind now, but at the 11th of August I can actually prove that it happens on highest mode as well. So even people willing to create massively beautiful PDFs couldn't escape it. And to be honest, as far as I know, it doesn't happen if you scan to TIFFs. On the 12th of August Xerox confirms it's a software bug and announces the patch another time. And in the middle of the night, my time destined and C called me on my mobile to be the first to tell me that they found the bug and they'd be rolling out new software to all devices. From this we can see how nice the atmosphere had become. That's the patch download site from Xerox. And here we can see for the first time how many devices are affected by this. And look at all the access. Those are device families. And it took until the 22nd of August until the first patches were released. If you think that's long, I think different. I do the release engineering at my employer, IVU. And I can tell you that rolling out and testing a new software release for such a large and long existing device family is really, really challenging. So they work quite fast. In the next days, the press is reporting again. And for example, the German computer magazine CT has a report and calls the whole thing scanner gate. And here Peter Koy puts the boot in. This may sound sarcastic, but Peter is completely right. Eight yearly productions of scanned documents across tens of thousands of enterprises worldwide can contain these errors and damage things forever. And to understand the full monstrosity of this reflect on the time we are living in. We are living in a society that right now, as we speak, is doing a transition from paper to digital. And the translators between the words are devices like Xerox WorkCenters. We'll have to put up with this a long time. And computer science slowly grows out of its infancy. And as you can see, computer scientists have social responsibility in their own way and in particular way more than they think they have. And here comes the most important thing of the talk. I told you Xerox sold most of its devices to third parties. They told me they don't even can collect a complete list of their customers to notify them. So we can't know if that's right. But in any case, there's no reason to believe the patches have reached too many devices at all. So please sped the word. For example, a few weeks ago, I visited Boston and I know some folks working at MIT. And I was told that the MIT hasn't patched the device. So now that I gave this talk in English, finally, I hope it gets viral enough that the MIT can get the message too. Perhaps you can all help. And besides all the lessons learned, there's one lesson I haven't told you yet. I always get unbelieving looks when I tell people I hadn't earned a single cent from Xerox. A manager even told me I wasn't an idiot. So I now give you the information and you can decide for yourself how much of an idiot I am. And two things. Firstly, it's really hard to earn money with something like this. An enterprise of Xerox size gets threatened by some crackpot every single day. And without proof, people are not going to take you seriously. And if you provide proof, it mostly directly leads to the buck. So no money again. And secondly, corporations don't know friends. If I had asked for money, this would have come to light and it would have looked sleazy regardless I earned the money or not. I would have been shot down with it. And maybe most important, if I had been paid by Xerox, I would never have had a negotiation position that allowed me to actually demand a solution or asked for getting my articles proof read. So last but not least, lots and lots of people all across the world helped me and they didn't ask for compensation either. And I would do it again like this. But at the end of the day, everybody has to decide for themselves. If you want to do it differently, that's perfectly fine, but now you've been here and you know in before you might weaken your negotiation position. And these are all the lessons learned. I'm not going to go through them again, but if you download the slides, here they are. And in our novel, we now jump to the present more precisely to March this year. And again, you don't need to read that. I'll explain it. This is the website of the German Federal Office for Security and Information Technology. They are in charge of managing IT security stuff for the German government as the BSE. As a consequence of the Xerox Saga, this March, they declared all scents using pattern matching and related technology as not legally safe. This includes all Jb2 scents. They even bend the lossless version of Jb2 encoded images. The bend is effective independent from the manufacturer of the scanner. In other words, this affects all manufacturers. So this is even bigger than it sounds. As far as I know, all authorities in Germany have to follow the scanning guidelines of this Federal Office, as well as lots of enterprises that have to do with e-government stuff. And it sounds like they have to reskin. So in a sense, we are creating jobs here. There is a similar Swiss institution that made a likewise decision. The Germans are not the only ones. So what remains? Barack Obama's birth certificate. Here it is again. Shortly after, the Xerox thing, journalists from Reality Check in the US, you see the link, asked me if the Xerox buck might have been the cause for the phenomena observed in the birth certificate. And they had done detective work already. For instance, the Obamas had published the text work right before the birth certificate. It had been scanned with Xerox Work Center 7655. I wonder if I get the numbers right every time. And they asked me if I could ask Xerox because I now had connections. And understandably, Xerox said, no, we really got different things in our minds right now. So at the end of 2014, I looked back at the birth certificate PDF. And have a look at this. The PDF contains exact duplicates of characters that were assigned for uncorrected pattern matching in the Xerox saga. And when you look on the internet pages of the conspiracy theory, they also say something like duplicate characters. And there they thought they were copied on purpose in order to forge that certificate. And here, for example, there are two boxes that look exactly the same. I mean, make up your own mind. But I think this Twin-Fort head theory might hereby be shut down. And all I have to say now is thank you for spending this hour with me. And here, find a link to the Xerox saga. Please read the words. And later, I'll publish my slides on my web page as well. And last but not least, congratulations, Frostcon. It's amazing what you did the 10 years. Thank you all. Any questions? Yeah. When you first showed the first certificate, you said, for example, it is one that looks like it was blurred. Yeah. I can go back and... Kind of different than from characters of... I'm getting to the slide. You mean the image with the one with the four. Yeah. Yeah. So it was blurred. Yeah. It's because they try to get the characters out of the background. And the ones they isolated from the background are perfectly sharp in a separate layer, which then is compressed by Jabyk 2. So the one, they didn't get it out of the background. The one is still background. That's why it's blurred. This is the technique. And that's why it is actually a correct. Another question, maybe? No. Then, thanks again. Thank you. Thank you.
On the scale of things too horrible to contemplate, "document-altering scanner" is right up there with "flesh-eating bacteria". Since 2006, Xerox scancopiers literally are making stuff up. They, for example, replace digits with others in scans. The replacement digits are layouted perfectly into the page, so the errors are hard to see. Sounds unbelievably insidious, but it's true. Drug prescriptions, construction plans, just anything can be affected. David Kriesel
10.5446/19554 (DOI)
All right, so like a number of the speakers, I am back here again for the second time. I was here first four or five years ago, and so in a sense as someone who's grown up in this community and the free software communities more broadly, it's an honor to be invited back here again and to give the opportunity to talk today. What I wanted to do today is really talk about, you know, they have a provocative title access without empowerment, and what I want to do is really walk through, think of this as sort of like an ideological progress report for the free software movement more broadly. And I'm going to sort of talk about how I see free software as mission, like a huge number of other free culture and sort of broader movements for free information to fall down into a sort of two-part mission. The first being access, sort of promoting access and the dissemination of knowledge in software in particular, and the second is in terms of empowerment, really sort of encouraging people to sort of take control of the software that they're using. What I want to do is suggest in, you know, this sort of, in this progress report part, suggest that we're, that in terms of the first mission, in terms of promoting access, we're doing well, very well, and in fact getting better over time, but that in terms of the second mission, in terms of sort of promoting empowerment, we're doing much less well and that in many ways we're not improving, or at least not improving nearly as well as we are in terms of promoting access. I want to walk through why I think it is we've had these mixed results, sort of to talk through a series of systematic reasons that I've identified in the context of our movements and our advocacy and the way in which we structure and engage more broadly, that we have privileged access and sort of, as a result, led to victories in terms of access that have not been followed by similar victories in terms of empowerment, and then I want to sort of end by pointing to three sets of strategies that we might be able to adopt to do better in terms of this in the future. All right. So when I give talks like this, and when I'm sort of talking about free software mission, it's worth going back to the beginning, which is to say the free software definition, and we start out, this is one of these things I've sort of been repeated to me so many times and repeated to other people so many times I can do it in my sleep, but of course the four freedoms that most of you are going to be familiar with, we start counting at zero because that's really funny if you're a programmer, but of course the freedom zero is the freedom to use software for any purpose. The second freedom is the freedom to study software, to see the source code, to understand how it works. The second freedom is the freedom to sort of share and redistribute copies more broadly, and then the freedom three, the fourth freedom is the freedom to collaborate, to share our changes with others and to benefit as a community more broadly. But as I've suggested, I think that these four freedoms actually come down to two fundamental types of freedom, right, two categories of freedom more broadly. The first is really about access, and this is a quote from the GNU Manifesto that suggests this is a Stahlman writing, I consider the golden rule requires that if I like a program, I'm going to share it with other people who like it, software sellers want to divide the users and conquer them, making each user agree not to share it with others, I refuse to break solidarity with other users in this way. This idea here that if I have something that I like, that it's sort of the golden rule, it's something we learned in kindergarten, that if someone asks me for a copy, I should be able to say, sure, yeah, I want to share that with you, right? But this form right here in some ways is actually kind of like the weak form of the argument. Kevin Moglin, who some of you may have run into or had the privilege of here speak, gives a much stronger form of this argument that's based on the idea that software, like other information goods, has what he calls, you know, what economists call zero marginal cost, which is to say that as an information good, if I may take a lot of effort or energy to produce it, but that once I've produced that piece of software, the cost of giving a copy of that software to another person is zero, effectively zero. And so Moglin draws a comparison to a machine that could make food, right? If I could make a machine that could produce and distribute food to a hungry person by pressing a button, Moglin suggests there would be no ethical justification for hunger in a world in which that machine exists, right? It may cost a trillion dollars to make that machine, but once that machine exists, starvation is no longer ethically justifiable, right? Now, for information goods like software, right, that is the context in which we're in. Once, you know, we may take a huge amount of energy and effort that goes into producing software, but once that software exists, everyone anywhere can have it, right? And like all information goods, anyone everywhere can have a piece of software for the same cost that it takes to produce it for one person. And so Moglin suggests that in this sense it is ethical imperative that we be able to share software more broadly. That's the argument that he makes. That's a very strong version of the argument, but there's a weaker form that just suggests that sharing is good, and either one of these leads to this same kind of argument, if not in the same degree, all right? So the second type of freedom really comes down to empowerment, right? And empowerment really means not only that people should have access to this stuff, that it should be able to be disseminated widely, but that people should be able to change the software to do what they want. I mean, this is really where I think a lot of the rhetoric around free software kind of gets it wrong, because there's a sense in which software freedom doesn't matter at all. The software doesn't need freedom. The software, information doesn't want anything, what matters is the users, the freedom of the users. And it's the people, the people who are using software who matter in this sense. I'm talking about this in terms of empowerment, but lots of other terms that people have used to talk about this include things like autonomy or power. And when I try to talk about this, I often give an example using my phone. So if I pick up my phone, if I want to send a message to another person using my phone, I'm going to be constrained in terms of the kind of message that I can send by the technology of my phone, right? If I want to, if I'm limited to being able to send text messages, I mean, I can write a pretty good text message in not so much space, but I'm limited in terms of the nature of the message. If I can call someone to tell them how great this conference is, I can sing a song, I can send a different kind of message. If my phone can take a picture and I can send that picture and you can receive it, then I can send a different kind of message. The point is that all of these things are technological decisions that someone made, either in terms of hardware or very frequently in terms of software. And the nature of those decisions constrains very explicitly the kind of message that I can send with this device, right? And to the extent that this device mediates my experience of the world, the question of who controls that device and what it can and can't do is the, is a question of who controls my experience of the world and other people, right? And so insofar as our lives are increasingly mediated by devices like this or like this, the question of who controls those devices, devices, or who controls what they can and can't do becomes an increasingly important political question, right? And free software in this sense, freedoms zero, two and three or one, three and four, depending on how geeky we want to be as we're accounting them, suggests an answer, right? The answer is you or users, right? The users of software insofar as our experience of the world is mediated by these technologies. It is important that users be able to control that technology and determine what it can and can't do. If we look at other movements, if we look at the Wikimedia movement, if we look at creative commons, if we look at, you know, the open source definition, all of these things, they have lots of different ways in which they describe essential freedoms or core parts of their mission, but all of them come down to these two core types of freedom, freedom to disseminate and sort of spread access and also, and then a freedom or an ability to change and take control, not just be a consumer of sort of information or information goods or software, but also a producer as well, all right? Now, as I suggested, I want to do a little bit of a little progress report in terms of the movement, in terms of these two broad missions or these two broad types of freedoms. Now, in terms of the first, which is to say access, I want to suggest that we're doing quite well, that we've done a fantastic job in our movement of disseminating the stuff that we're writing, the software that we're writing, and that we've been doing good for a long time and that as time goes on, we're doing better. Now, this is sort of the classic people who have seen these net craft market share surveys or sort of automatic surveys. These have been published for almost as long as I've been involved in the pre-software community and they, for example, show a number of things. The most famous one was the proportion of web servers running different pieces of software and of course as long as these statistics have been kept, free software has been dominating. In terms of server-side scripting languages, you see something very similar. We are now, it's not only the case that Apache is the most widely serving the vast majority of pages over time, it is now the case that number two is also free software. Nginx has surpassed the proprietary alternatives as the second most widely used web servers. Free software is completely dominant in this particular space. If we look, browsers are also largely free, of course, although Internet Explorer once held over 95% of market share after it squeezed Netscape navigator out illegally, of course, according to antitrust adjudicators in both Europe and the United States. The free software browsers including Chrome and Firefox and I-Sweezle, my favorite, now hold nearly half of the market. Recent industry surveys suggest that over 40% of firms engaged in free software development, sorry, engaged in software development at all contribute to free or open source software projects as part of their work. Free software in this space has been dominant for a long time and is continuing to do and is in many cases doing even better. If you look at usage shares in terms of operating system, you can look down the list. We are still, as it turns out, waiting for the year of new Linux on the desktop any day now, but then in lots of other spaces including smartphones, including servers, and supercomputers, and embedded systems. Linux-based operating systems in particular, but free software operating systems more generally, occupy enormous proportions of market share. Lots and lots of people are in lots of different places using free software. If you look at the growth curve, one of the first places that free software was adopted in huge amounts was in supercomputing. You can see that there is exponential growth starting in the late 1990s until, of course, we have to slow it down because all of it is running free software. It's hard to grow past 100% or very close to it. Basically all supercomputers today use some version of Linux and you see similar growth in terms of servers. If you look at smartphone share, you can see that Android-based operating systems go from almost nothing in 2009 and today make up a majority of all smartphones that are being used. You look at embedded systems including televisions, your television, if it's a relatively recent one, probably runs some version of the Linux kernel and an operating system based on free software bits and pieces. Of course, because free software has been so dominant in this very quickly growing space, you can say we are moving very quickly towards a period of time when there will be more than two billion Linux devices in the world, the vast majority of them mobile phones running Android. If you think about this in terms of the computers that people actually have, that we are close to or have recently surpassed a period of time where 50% of all computers in the world are actually running Linux kernels and operating systems which use the software that we as a movement have built. Bits of free software here. Now one problem with measuring the usage of free software broadly is that it's actually very hard to see when people are using free software in many cases. When I worked at Canonical early on, one thing part of my job was to grow our install base, our base of users and also developers. But in terms of measuring users, people would ask how many users do we have. I have no idea. Lots as far as we can tell. I was personally coordinated the mailing of millions of different Ubuntu CDs. The CD company that was producing our CDs was so happy with how many CDs we were buying that they made me this framed platinum CD. I gave it to my parents. I'm like, here. We don't really know what you do, but seems to be going great. Our best measures were often based on things like NTP check-ins so we could see how many computers were coming online and connecting to us. Even within the first few years of Ubuntu being launched, there were in the orders of tens of millions of users who buy our best measures. We certainly made millions of CDs which were distributed as well. There are lots and lots of people using free software. Here is just a graph from SourceForge. 2009 was the last period of time where I could get good data. What we can see is that in terms of downloads, what you can see is that the important thing to keep in mind is that there are in the order of 50 million downloads a month during this period people moved away from SourceForge in large part, but consumption of free software has not abated in other places. There are huge millions, many tens of millions of people who are even outside of the stuff that comes installed in their devices going out of their way to get and download and use free software of various different kinds. We are doing really well in terms of access. There are other places where we can, other similar movements where we can look at access to knowledge in places where measures are a little bit better because everybody who reads Wikipedia has to go to the Wikipedia website. We have much better data, although still not perfect data on consumption of pages there. I will show you this because I am going to compare it to more measures of empowerment later, but if we look at growth of Wikipedia, readers over time, we can see that there are now, now if you include mobile, this does not include mobile devices, which is part of why you see it, it goes down there at the end or mobile views. There are moving towards a billion people who are using Wikipedia each month. In the broader free culture movement, we are doing very good at producing information, which we are able to disseminate very widely. In terms of access, we have been doing excellent for quite a long time. We have been building stuff that lots of people are using and consuming in various ways, and we are, along many metrics, doing better as we move forward in time. But control and ability to change and reuse is far less universal in the free culture and free software universe by a lot. Here is over the same period of time data from on developer, on the number of developers in terms of source forage. This is a really like, whatever the opposite of a conservative estimate is. This is the number of people who are sort of developers on a project and it is double counting everybody. This is assuming that no one on source forage has ever joined more than one project, which is not true. I am participating in many. This is assuming that nobody is inactive on source forage, which of course, if you participated in any free software community is also not true. This is like an incredibly generous estimate. What we see is that the number of active users using this very generous, sorry, the number of contributors is in the order of hundreds of thousands. That is to say a couple hundred downloads per developer every single month. GitHub has somewhere over nine million users as of the last time that I checked. Of course, this includes lots of proprietary software developers. One challenge with GitHub, which is why I don't have data from them, is getting a sense of the GitHub projects users based because it is very hard because many projects on GitHub are not distributed from GitHub. So for example, if I write an Android app and I post the source code in GitHub, almost no one will download my Android app from GitHub because you can't run an Android app in its source form. You get it through a store, probably the Google Play store. As a result, it is hard to measure that. That said, the rapid growth of free software, as we have seen before, suggests that a majority of these phones are running Android and are installing apps which are available online. To the extent that the vast majority of people who are running these things like apps on Android are consuming them on Android, we don't really have to speculate about the exact proportion of free software users who are engaged in modifying their software because a majority of users, which is to say the large majority of users whose only computers are Android devices, can't modify the software that is running on their devices even if they have access to all of the source code. Because of course, an Android phone can't modify its own software in and of itself. They're not designed to, for one, in the sense that they don't have affordances or the development tools installed by default, but they're also locked down so that even if you wanted to, you wouldn't be able to do it. You walk into a Google or a company of people writing Android apps and you see a bunch of people sitting around and using computers. Now, of course, if you were to walk into an office of people writing software to run on laptops, they would also be a bunch of people sitting around using laptop computers. But this situation in the past where the systems we use to develop software were also the systems we use to write software meant that people could transcend that role in a way that users of devices that are locked down so that they can't run software and so that are designed so that they can't change software anyway means that the vast majority of people simply can't, which brings us to the last point here, which is that this is the measure of contributors that ship to Wikipedia again since 2007, which is the period of time that there is good viewership information. It shows just the number of editors over here and you can see that since 2007 Wikipedia has an editor base, which is decreasing slightly, but is more or less holding constant. The key point is the graph over here, which is the percentage of readers who engage in editing the site. This is basically that previous graph, the number of readers. This graph right here divided by that graph of the number of readers. What you can see, of course, is that although the number of contributors to Wikipedia has more or less held constant since 2007 or gone down a little bit, that the proportion of readers has gone, has been halved. We're now looking at that there used to be one in about one in a thousand, let's say, or one in a couple thousand users of Wikipedia would engage in editing your contribution. Today it's half that, maybe one in five or one in six thousand people ever change anything. That a smaller portion of people, proportion of people who are accessing free knowledge, are engaging in the freedom they have to change that stuff, to build, to become not just consumers but producers. The second thing, that's the update, good in terms of access, in terms of promoting access, less good in terms of promoting empowerment, at least in terms of the way in which our movement has defined it. I want to talk about why I think this has been this way, to talk about why empowerment is so much harder than access. I've come up with five different descriptions or explanations. The first is that access is always sort of step one, that in order to promote, sort of, if our goal is to promote, even if our goal is only to promote empowerment, that we first need to get people access to stuff so that they can then change it. As a result, our advocacy, as a broader movement, has focused on promoting access first. Lots of, this is a picture of an install party. You're here first installed at an install party. Who is running an install party? You're bent on a few people. I've definitely been to install parties as well. I can't remember if I first installed it that way. Here's a picture of one in Stabropole. I've participated in organizing in various ways. In a number of these, my local Linux user group in Seattle organizes one every month or two and people show up to install it that way. In terms of the work of our advocacy organizations, it's something that we've made a very important part of the way in which we reach out to people. We have not, for the most part, run similar types of hack on your operating system parties. Not because you couldn't, but I've never not seen that as often. It's certainly going to be pointed to addressing a smaller group of people. It certainly requires more specialized skills, but it's not something that, generally speaking, we have. I will talk about some examples of people who have done that a little bit later on. In terms of our outreach and advocacy, this is stuff from Software Freedom Day. A picture from Software Freedom Day. Last time I gave some version of this talk, the person who was in that picture was like, that's me. Was in the audience. I've stood in local squares in my cities and handed out CDs to people. CDs running, either open CDs running, lots of pieces of free software that could be installed on proprietary operating systems or installed CDs with free operating systems. As I've suggested, I have helped send millions of CDs to people that were interested in passing those out to people and engaging in promoting the adoption of the dissemination of free software very explicitly. These are valuable forms of outreach because, of course, using free software is a first step, right? But for the most part, that's where our advocacy has not taken gone steps beyond just the dissemination of software more broadly in that way. I have participated, as I'm sure a number of you have, in spreading the word or documenting at Firefox.com. This is get IceWeasel.com. IceWeasel is the Debian version of Firefox and it has a very cute logo. It's a very funny website because the only way to install IceWeasel is to just apt-get install it on your system. It's just like a website that tells you to do that. All of these get Firefox is about spreading the word about a free software browser that you can install. It's been enormously effective in terms of spreading the word and increasing access to this free browser in this way. But hackfirefox.com, if it exists or some version with that, something that is conceptually similar to hackfirefox.com is, if it exists at all, far, far less possible. All three of these, I think, these install parties and outreach events and things like get Firefox are valuable forms of outreach because using free software is a necessary first step. But we shouldn't stop there and in each of these cases that's exactly where I, to the extent that I have engaged in this work, have stopped. We need to focus on advocacy within our community to ensure that users can take advantage of all of the freedoms, right? The both of these two types of freedoms, all of the four freedoms, and we very rarely do. The second reason why I think that we've really privileged access over empowerment in terms of our advocacy is that there are very often subtle social compromises, sometimes a little bit less subtle. I'm going to sort of retreat a little bit into my sort of day job as an academic studying free software and free culture communities. I want to touch a little bit on a piece of work that I've done which uses the Scratch online community. People here use Scratch. Scratch is a programming language which is self-written in small talk. It's designed for kids and it's a sort of graphical block-based programming language. So you sort of can't make a syntactical error. Your program probably doesn't do what you want the first time, but it will always run. Scratch is also an online community where kids can share the programs that they've used and then every piece of software released on the Scratch website is released under a free license, under the Creative Commons Attribution Share Like license, so that everyone in Scratch can take someone else's program and sort of build off it. If they can sort of change it, they can use it in different ways. Now, one thing we've looked at in Scratch is when is the sort of the criteria that cause the criteria associated with projects being more generative or popular? And so the trade-off here that I want to talk about is one that I've sort of explored in my research which is a trade-off between generativity which is to say the qualities of Scratch projects that make them more likely to be sort of hacked on or sort of remixed. And that's the first column here and there's a series of different things that we measured. One is for example how sort of popular or high status the author is within the community. One is how cumulative the project is which is to say is it like a remix of a remix of a remix and then the third will have to do with how complex the project is. But the important thing here is that along all three of these dimensions we find that the qualities associated with increased generativity in the sense of the qualities associated with increased engagement and reuse, the kind of empowerment that we're trying to provide, that we're trying to sort of facilitate in the broader free software community but also in Scratch, are all associated with less original forms of remixing. Which is to say that the project we found that projects are more likely to be remixed if they are moderately complicated, sort of created by prominent users of cumulative, but that each of those things are associated with less original forms of remixing. The story here is that the kinds of things that a designer could do, right, if you're designing a community or if you're sort of creating a project, that the kinds of things that you can do which will invite engagement are associated, are all associated with sort of, they work by attracting people who are maybe less interested in changing things a lot or less able to change things a lot. And very often there are compromises that we as designers have to engage in that mean that the cost of attracting more people to engagement or empowerment mean that the nature of that engagement is weakened, right? It's a real compromise which is something which I've been able to show in some of this research. The third kind of compromise is in terms of technological compromises and these come in a bunch of different ways and we're very familiar with them already. The most extreme version of this is just in terms of Tivoization which is to say that freedom is simply compromised in the sense that it is violated completely and users are simply made unfree, people are familiar with the concept of Tivoization. Tivo released a device which came with free software running on it but was locked down using essentially DRM so that users of the Tivo, although they had access to all the code they needed necessary to change the software on their device, couldn't. They didn't have the keys, like literally the keys necessary to install the software on their device so that they could make it do something else. You have access to all the code that you need to change it and yet you can't. This, you know, Tivoization is the example of when users have the rights under a license but no ability in a practical sense to exercise those rights in practice. And that this business model, right, this technique of Tivoization has been very popular more broadly. There's a pile of devices, all of which run or nearly all of which run Linux in some form and various other pieces of free software and almost all of which are locked down in a way that make them unmodifiable at least without having to sort of attack and compromise your own device. We are succeeding in terms of spreading our stuff by spreading it in devices not like this or like your television that make realizing that freedom technologically impossible or at least extremely difficult. Here's another technological compromise which is a little bit more subtle. People familiar with Wikipedia Zero. Wikipedia Zero is a project launched by the Wikimedia Foundation which makes access to Wikipedia free for users in large parts of the developing world. They essentially make agreements with telecommunication providers in the developing world to say that people want to access Wikipedia from their mobile devices that they won't be charged for that access, that it's free for them. No cost. This is great in the sense that this means that the world's knowledge is accessible to, as reflected in Wikipedia, is accessible to huge numbers of people around the world. Yet the nature of that access is compromised because when Wikimedia Zero first launched it initially there was no way to edit Wikipedia from a mobile device. This is a very clear technological compromise. It is now the case that you can edit Wikipedia from a mobile device but it is much harder and that some of the many of the features that many of the most active editors on Wikipedia use take advantage of to edit Wikipedia effectively are simply not available to users of mobile devices. We have in our desire to spread access more widely in the case of we, I'm also very involved in the Wikimedia community, we have decided to trade off users' ability to engage in production as well. A fourth answer to why comes down to what I call second-order digital divides. There's a great piece of work by Esther Hargitay and Aaron Shaw, both at Northwestern University, that again looks at the gender gap within Wikipedia. This is a gender gap in Wikipedia you may have heard that the vast majority of people who contribute to Wikipedia are male. This has been seen within that community as a problem. There's a very similar conversation that's been happening in the free software community for a very long time, I can look around the room and get a sense that there's still work to be done in many ways. There Hargitay and Shaw's work has actually suggested that a big portion of the gender gap at least in the context of Wikipedia actually comes down to a skills gap. If you take into an important variable that we haven't looked at is the fact that there are many people who have access to a particular information good, don't have the skills necessary to do it. Wikipedia is a nice example because contributing to Wikipedia is supposedly much easier than contributing to free open source software and the sense that you don't need to know a programming language. You just have to know how to press the yet button and make a change. Yet, the technical skill gap means that large numbers of users of Wikipedia, including many of the other kinds of demographic gaps that the community cares about, are actually keeping these people from being able to participate. Many people don't, until we address this inequality in terms of skills, not just having the stuff but also having the skills necessary to take advantage of it, which is to say, and we can talk about those skills would be in the context of free software, but they would certainly involve some level of programming. These broader forms of inequality are going to continue in terms of contribution and empowerment. The fifth and final reason why I think that we've struggled to address empowerment while succeeding in terms of action has to do with project life cycles. Here is a graph that shows the number of people who are members of the Debian private email list. This is not exactly the number of Debian developers or people that are sort of empowered members of the projects over time, but it does capture, but it correlates very strongly to this. What you can see, of course, is that like many projects, Debian had some kind of exponential growth for a period of time, lots and lots of people joining the project, and then over for a lot of reasons, that growth slowed down. I mean, actually during a period of time, Debian developers felt that they were growing too fast and just cut off new contributor, like joining altogether. These sorts of life cycles are very common. You see growth of projects up to a certain point, and then you often see that they change in the sense that the projects sort of solidify over time. There's a group of people who are able to work together. We have sets of norms that we know. There are things like groups that I've shown in some of my other research that lots of free software and free culture projects actually become oligarchic in the sense that there's a small group of people present at the beginning whose interests begin to diverge from those of many of the membership. I've shown this in wikis, but there's reasons to believe that this exists in free software projects as well. Getting a patch in can be harder. Some of these are good, sometimes for good reasons. The project has become more stable. The project has become more widely used. It's more important that we maintain sort of stability in the project, and some of these are less good in the sense that people want to sort of preserve their own power. But in either cases, we have projects that there are life cycles that mean that it becomes more difficult to contribute to projects as they grow older and larger and more established. And to the extent that free software has grown in this way, this may mean that it is harder along many dimensions to contribute to many particular free software projects and maybe to establish free software projects in general than it was at some period in the past. So that sort of leaves us with the sort of final question of what is it that we should do about that, and I have four answers. The first thing we could do is nothing, of course. And you can probably guess that that's not the position I'm going to argue for. And if you guessed that, you would be right. But I think it's not so obviously wrong that it's not worth addressing. Because I realize, like I really do, that empowerment doesn't mean that everyone has to become a programmer, right? And if you really believe that not everyone, you know, one answer is, well, not everyone needs to be a programmer. Why should we care about engagement in this sense? Why should we care about empowerment, right? If everyone has it, and all the people, the vast majority of people that have this stuff don't want to, you know, they don't want to be empowered in the way that you're talking about, why do you want to go out and enforce them, right? And because after all, right, freedom of the press, right, is another freedom that many people believe in. It doesn't mean that we all need to go start newspapers, right? And if we say that not everyone's running a newspaper, that like, that doesn't mean that the place is not free. The Can You Manifesto frequently suggests that even if you can't program, you might be able to hire someone to program for you. And I think that that's absolutely right. The important thing after all is not that everyone needs to be hacking on free software, but that everyone has the freedom to do it, right? It's the freedom to do it as opposed to the realization of that. That said, I think it's hard to believe that you lived in a country with a free press if there were no independent, if there were no independent newspapers or very, very few or only certain kinds of people, let's say, sort of rich people, male people, people in the developed world who ran newspapers. It would be hard to believe that that was free as well. And I think that, but I sort of think of, and I sort of think of empowerment in this sense about learning, about programming as kind of in terms of writing or literacy, right? Many users of free software, because many users of free software have never considered changing their software to do something different. Now, so in terms of the comparison with literacy is sort of like this. Although it's important that the, imagine a world in which everyone knew how to read, but only a very small number of people knew how to write. That seems like that would be a sort of less than ideal world, that it wouldn't be democratic in some sense, right? But that kind of, to the extent that we think that software or technology is an important kind of literacy, that is kind of the world that we live in now, right? So but that said, the end result is not a world in which everyone is a professional programmer any more than we teach everyone to write, because we think that it's important that everyone become a journalist or a novelist, right? The important part is that that process be demystified enough, that people feel that writing is something that they could do. And the, it's important, and so for the reason that I think it's important to teach people to read and write, I think it's important to teach people who use software to at least understand how they would transcend their roles as consumers. The reality is that learning to program really is empowering. Being able to change how your world works yourself is empowering. That empowerment is the promise of pre-softening that we should not be willing to treat it only as a potential freedom. All right. Now the second sense in which I think we can address this gap, the gap between our success in terms of access and our success in terms of empowerment is by compromising, right? Sometimes we may simply have to choose. We may have to sacrifice efficiency in various ways by, for example, dealing with newcomers. I sometimes joke that GNU Linux is the least efficient operating system ever sort of imagined. We have to spend like all of this time arguing with these people who are obviously wrong, right? I think they're, I think they're obviously, I think the people who disagree with me are obviously wrong, right? And that we have to go through this process of, you know, of negotiation, which is not as easy as it could be, right? And that by facilitating engagement of lots of new users, it means that we have to spend time dealing with sort of challenges or convincing people of things that we wouldn't have to do if we were to not be as open or as sort of allow, you know, encourageable to be as empowered in the sense of engaging in our projects. The, that, that may in various ways mean that we have to, that we should compromise quality, for example, in order to promote engagement. There are tough choices that we will have to make if we want to promote, if we want to make empowerment of users a first order goal on the same level of access. And the figuring out how to negotiate that is something which is tricky, but it's something that I think we need to, we need to be willing to make, compromise, I think we should be willing to make. The third thing we can do is remove systematic barriers to participation. We can, we can work in, in, do this in various ways. We need to work to make our projects systematically more accessible to newcomers. And we can reject unacceptable tradeoffs between access and empowerment if they're in, in, in various ways. So for example, lots of organizations have, or free software organizations have adopted, adopted codes of conducts explicitly designed to make their projects more welcoming to large numbers of people, including people who are not participating before. Lots of conferences and organizations have adopted anti-harassment policies which systematically are trying to make, make it clear that there, that, that, that systematic barriers to participation that have existed in the past should be, should, should be removed to allow more people to engage. There are also lots of ways in which we have promoted outreach more broadly. So people are familiar with outreach, which is a nonprofit, which essentially funds people to participate in free and open source software development from groups of people. Historically, this was originally the, the outreach program for women, promoted sort of women's engagement as developers and contributors in the GNOME project and now in a variety of different free software projects. There are a series of ways and because of course economic inequality is one way, is, is one way in which lots of people are prevented from engaging. There's a sense in which I grew up very privileged. I had a computer at home. I was able to, you know, I never took a computer science class. For me, development, software development was something that I engaged in recreationally because I didn't have to have, for example, a job after, after school and high school. I had space to explore this and ways in which to engage and existing and there are now a series of projects which are making, which are in various ways making it possible for people who have historically not been able to contribute to free software for lots of systematic and economic reasons to be able to do so and outreach is a one example of a project which is doing that very effectively. All right. The fourth and what I think is probably the single most important thing we can do to address this gap between access and empowerment is basically around education and technology education and there's a whole bunch of ways in which this happens. I have over the last two years been running a series of projects called the computer, the, this is computing, should be the community data science workshops, a series of efforts to basically teach absolute newcomers with no background at all, how to program in Python, how to pull data sets from web APIs, how to ask and answer questions that they have about online communities that they are participating in, free culture and free software communities in particular, but really anything more broadly. We have, we have taught 250 people how to program using curriculum which is available online, you can check it out on the community data science workshops and have explicitly decided not just to teach people to engage in, in sort of to have software which they can use but really to sort of take advantage of that software and change it in various ways. And if you make it a goal to, to spread, to give people the tools, right, there are, we've been oversubscribed by a factor of almost 100 percent every time that we've tried to do this. We're now teaching 100 people at a time, twice a year. The curriculum has been picked up and people are teaching similar sort of learning Python and programming workshops more broadly in various places. Open Hatch is another project which is very active in this in a way that I think is actually really smart there. Open Hatch has a series of events which they have, which they are running in which you can run the curriculum is online which are designed to teach people who are already participants in, sorry, already users of free and open source software how to contribute. They for example teach people how to use Git. They teach them about the social processes in projects. They teach people about submitting patches or engaging in mailing lists. There are, this is the hack on free software party, right, that should come after our install free software party. But that historically we have really not usually gotten to. I think that the most important thing to realize is that I think that, is that although that, you know, those are a series of ideas I think that we can do, but I think the important thing to realize is that if we take this really seriously, if we make engagement with, you know, sort of promoting empowerment, a first order goal in the same way that we have made using free software or access to free software, a first order goal in the past, we can do much better. When I first was talking about the idea for this talk to Walter Bender who is very involved with Sugar Labs which is a project connected to the one laptop for child project, sort of comes from that. And it's an interface for kids to use a free software tool to use as their sort of operating system. He sort of, I don't know, had a very inspiring sort of approach to this. This is a program called TurtleArt. It's one of these block based languages a lot like scratch where kids can use to program, make their own programs, which itself is kind of cool because now we have a piece of educational software that is not just a software that you can use to, you know, use your computer but you can actually use to program it. But the coolest thing about it is that this lives up to an old OLPC goal which is that for every, in this program there's a view source button. It's right up in the corner and if you press on it, you will see the source code to the program that you are actually running. So not only can you write your own programs here but you can actually press the view source button and you can see the Python code that implements this TurtleArt and you can change that code to make it work in a different way, right? They have, at least in the context of TurtleArt and to some extent in Sugar more broadly, made engagement and empowerment something which is a first order goal. That it's not enough that every, it's not just that everyone will have access to this source code and can change it. There is a button right in that interface which allows you to see and to begin changing the software that you are using. But of course the inspiring part is not just that this exists but that people are taking advantage of it. Walter told me that during the last release of Sugar, a majority of the patches that went into Sugar, the last release of Sugar, actually came from kids. Many of them in Uruguay where the largest number of users are who are using this software and who are changing this software to fix bugs to make it work in different ways. That if we do this, if we start and design our stuff with a goal of empowerment that it's as important in our actions and our principles as important in our actions as it is in our principles, we can make real progress. And it falls on us, right? People like us in this room, the advocates of free software to address this. We, you know, you run and contribute to and influence many of the most successful and influential free software projects. And what's at stake here is more than our particular projects but the broader movement. Because when people realize that they can change their technological world and when they are willing and able to do it, they are able to take control of their experience in a way that is profoundly powerful. The potential is there and can be realized in ways that I've suggested and there are lots of other ways that I haven't if we try. You know, your work here is very important and thanks for letting me be a small part of it. All right. Cool. So, I mean, I guess there's time for a question or two. Yeah, sure. I'll repeat the question. All right. So the question is about sort of like how much should one have to learn to be empowered, right? Is it, you know, in terms of system programming or simple scripting, something like this? I think for me, so the analogy that I keep coming back to is this idea of writing versus like writing versus writing and programming, right? We don't insist that like, I don't think it would be reasonable to insist that everyone should be a professional journalist or writer. Nor do I think that it's important that everyone be able to, you know, be a system programmer or be able to design the chips that run in their computers. I think that the question is at which point do you, I think that the goal should be to demystify programming and to put people in a position where they believe that they can, they understand how they could change their computer to make it work more difficult in various ways. In my own work, I teach, I like teaching Python in part because I think that you can, it's very easy to show that you could use Python to do anything from building like working graphical applications to, I can point to real websites that people use all the time, you know, Instagram, written in Python, that kind of thing. And people can begin to be, feel like they're changing things right at first. So I don't know, I think it's an open question and I think it's something that we'll sort of figure out, but that's how I sort of engage with it myself. Yeah? Yeah. Yeah. So the question is should empowerment also involve documentation and I think the answer is absolutely yes. I think that, I mean, for me, I think of the, you know, I'm also very active in the Wikimedia community and Wikipedia and I see work in that space as basically falling short in exactly the same way. I have like a, you know, I can give the version of this talk which is like informed but unempowered, which is exactly about, you know, Wikimedia and which comes down to issues of documentation. I think that insofar as the documentation is an important part of the way in which we experience the software or experience the world or understand the software in the world, that sort of the ability to engage in that also becomes important. There are lots of ways to become engaged and lots of ways to sort of transcend one role as just a consumer of software or information goods and I think the documentation is one way to do that. So I think that's a great point. Yeah? Yeah. I'm not going to try to repeat that whole thing, but the point was that the designing systems and encouraging people to be willing to take risks is a type of compromise that we should be willing to make in order to promote engagement with an empowerment in terms of software, free software more broadly, and other things as well. That's a great point. I just want to be aware that people are moving in. So maybe we'll, is that okay? Okay, great. All right. So we'll switch over to the next speaker, but I will talk to you right now.
The free software movement has twin goals: promoting access to software through users' freedom to share, and empowering users by giving them control over their technology. For all our movement's success, we have been much more successful at the former. I will use data from free software and from several related movements to explain why promoting empowerment is systematically more difficult than promoting access and I will explore how our movement might address the second challenge in the future. Benjamin Mako Hill
10.5446/19553 (DOI)
Okay, I'm going to talk a bit about Asstops today, which is a project that, well, basically it is about optical micro recognition mostly. We may have seen the pieces of paper in the back that you had, which is a small survey that they are doing here, and they are using a software which is non-free, which is actually used by a lot of universities throughout Germany. What we had, why we started Asstops, is that we needed to read out exactly these forms at the university. So, SDAPS, which is an acronym, I'm not going to spill it out, but it probably doesn't make much sense. It's really just an optical micro recognition. It's only about recognizing which checkboxes are marked by the user and then figuring that out and getting all the data out from the scans that you have done. However, to a large extent, the problem there is to the questionnaire design. You want to design the questionnaire in a way that is easy for the user. You want to quickly create something like this. You don't want to, I don't know, I've seen tools where you create the questionnaire somewhere else and then you import it, then you mark the regions that need to be recognized. And in my opinion, that's very, not very useful. So what SDAPS does is that you create the questionnaire in Lattech and all the metadata that is required is exported into a file, which is then picked up later on and can be analyzed by the program. In general, it's a Python program with just about 10K lines, so it's relatively small overall. And it's designed in a way that is extensible so that you could create own plugins and commands that build on top of the internal data model that it has. And yeah, mostly it's a command line utility. The only point where the user interface comes into play is for doing manual error prediction because that's where you need a user interface and the rest of this is very much designed to be scriptable. So we started the project back in 2008 actually when in Cod3 at the university, it was still the university of Cod3 at the time, today is the Cod3 Institute of Technology, it was decided that the evaluation would go into the centralized and we weren't quite happy with the bylaws that were in place at the time. So what we decided at the faculty of electrical engineering is that we would boycott the evaluation at the university. Now we had an issue because at the same time there was the change to the Bachelor of Master System here in Germany going on and we really didn't want to lose the data that was coming in especially for the lower, for semester's bachelor's if there were any changes. So we had to actually use the, do the data analysis ourselves. What we ended up doing is that we created a tool which read out these forms in a pretty quick hack like over the Christmas holidays and then ended up actually evaluating most of the, let's remove the cell phone, should help, most of the lectures at the faculty were using our tool and actually in cooperation with the faculty itself. So that worked very well and after that we realized that we could create such a tool but obviously we were using these original forms that time so we needed a way of also creating the format not only reading it in and we first decided to use OpenOffice for that and later LibreOffice and then even later created the Latin support which is now basically the main part of doing it. So since then people have tried, oh sorry, probably should have, let's do this first. Since then people have used it for a lot of different things or even tried to use it for different things. So this is a survey that is being used in the UK by a company called GPTools and they offer some services there for doctors who need to do a yearly evaluation of their office for the NHS and what they offer is a very simple form so the doctor or 20 patients or something the day and send it in and they will create a nice report for it. There is even an example report online. They basically take the normal output that SDAPS generates at somewhere statistics data themselves and that's then it, what they are offering and they are selling the service there. Another thing is examinations so both every TH often the physics department there, they are looking into using that and they have, sorry? Okay, sure, no worries. All right, that is a good point. That should be it. Okay, thanks for the, so yeah, examination is a point which is actually quite interesting. I'll come back to that a bit later. So they have designed a completely new way of asking, formulating the questions for the examination. This is an example for the tutorials that they were using but they have used it for the real examination too and this is an example from Princeton where they have tried to get it to work and you can actually, if you look closely you can see that SDAPS is not really designed to handle these cases. So what they did here is that there is a large box which is just taking out as an image and then they have placed something else inside to be able to get the data out from after the scan and then have a look at the image there. But I've seen, I think that they have also issues that students write outside the field and stuff like that which makes it a lot harder to handle the data later on. So yeah, this is different layouts, layout issues that they are having. They, the general me there, he did a pretty good job trying to hack out the class in a way, the Latif class, that you could get the layouts to work like this. I'm working on improving this. This is another example from Nation Builder. This is a sheet that was used during the 2014 elections in the US. This was for the, well, door to door, you go, walk from door to door, you ask questions and then you just check out the answers there. And they sold the service also to some people, to some organization and lecture parties I think that walked around there. In theory voting, I have had someone doing this ballot at some point. I'm not sure if they ever used it. I think that the pirates in Berlin have tried to use SDAPS for a relatively complicated voting system because it's a lot, it's a pain to count manually. But I've not, I don't know whether they're actually using it other than trying it out once. Just month ago I got the request for someone who wanted to do Autocross, German Autosladung or something. And there you need to count the cones that are hit by the cars. And for that you wanted a sheet like this. They are currently using some Excel and then manual things. So I actually played around trying to do this. And this is using some new code that is not in production yet. So as you can see there are a lot of different use cases there with SDAPS and you need to think about how to make it easier to use for the user. You need to think about the different requirements that you have. In some cases you want, let's say you're doing a survey, you want anonymous versus nonanonymous surveys. You might do a patient survey where a patient gets the same questionnaire every month and then it's not anonymous. You also need to know from which month it was later on. There are some technical aspects. You need to think about logistics. If you have only one piece of paper like this one, it's very simple. But consider an examination, for example, with a huge amount of papers, four pages, 10 pages, then if you staple it, it's hard to scan in again because you need to cut off edge or something which might destroy the edge markers that SDAPS is using. There's a lot of things to think about at that point so that everything runs smoothly. This is most to a large extent not even a software issue but an issue of getting all the integration on thinking about how to do it. For example, another thing is error handling, especially in examinations. You need to make sure that the students, if they mark some piece of paper that they can correctly correct their results and then you can go back and you know exactly what happened and you can correct it manually instead of just running it through the computer and then you end up with wrong data and the student will complain that the mark is wrong or you might not even get complained and then you're in trouble. So that's not too easy to solve in general. There's some consideration that you should think about before doing an examination or even a survey on paper. But at the same time, it's nice to... Paper surveys can make a lot of sense in some contexts. So here is the thing, some parts of it are solved by S-Tubs. So what S-Tubs does is for multi-page handling, we have a barcode at the bottom corner and if you look closely it says 0002 which is the second page. So on the first page there's no barcode but on the second page there's a barcode saying which page number is and there is a large random number identifying the survey which is reproducible. So if you use the same Latch-Input file, compile it again, it will result in the same number. But if you do some minor modifications you will get a new number because the software or the areas moved around. So that means that you are reproducible. We have to do it. Then you get user-defined barcodes. So with the example that... For example I'm sending a survey out to a patient every month or so, you need to know which month the piece of paper was from so you can just add this information to there or another example might be lectures where you have 10 lectures and you want to know which lecture is. You can print on the piece of paper directly to ensure that even if you mix up the papers in any way you want you know afterwards which lecture it was from. But for non-unanimous servers you want to be able to mark the paper with a custom barcode that identifies the specific user that you hand it out to. So that is what SSTEPPS provides internally while the center one, it's basically not even used by a SSTEPPS itself because it's not useful for it. It's just there for the user to be used later on. In general the process is that you have to create the questionnaire, you have to then pass it over to the main program which expects all the metadata out of it. Then you are able to create the printable document afterwards after some processing. Then you hand that out, you scan it back in, then obviously you want to hand it over to the main program again to do the optical recognition. The manual error correction depends on what your needs are and obviously data export afterwards. So these steps are different commands here. So we have SSTEPPS, we have a stamp command which does the printable document, we have an add command which simply adds the scan, we have the recognize command which does the recognition step, user interface, CVS export command. And because they change the aspect ratio of the slides is the report command which creates a PDF document. So the setup command that simply compiles the lattice document or takes the oddity file, parses it, reads in the PDF file, extracts all the metadata from there and after it has all the metadata it can recompile the document with the correct information or overlay the corner marks and stuff. So that is what happens and after that, yeah. So considering the metadata and stuff what you want is to create a nice looking document and for that we have the lattice class. This is just a simple example and when you compile the lattice class, the lattice class, this is the example document actually. So what we can see here is that it's relatively simple document. What we do is we create begin questionnaire and questionnaire. This is just a wrapper environment to be able to repeat it so that we can generate like a hundred unique questionnaires with different barcodes from lattice directly. And then it's a simple section and then single mark is just mark question with lower bound upper bound as you can see here. Then you can add a choice question with different choices and it's a metric. It's layouted as a table. The four there means that it is four columns and then we have two choices and another choice for text input. And text boxes are out of skating. So if you look at the page here, this is the bottom of the page and you can see the end of the text box because it scales over the whole page. And that's it. What it comes out is one, the PDF file which is kind of printed but on the other hand all the metadata with the exact position on page of all the check boxes and the questions that you were using so that we can create a report which contains the question text, which contains the information. And also the program has all the data required to analyze the paper. So the next step sometimes depends if you're doing a non-unknown survey is that you still don't have a printable document because you still need to add more barcodes which identify the user, which identify the single piece of paper. So you re-render, you pass that over to S-Tubs and then you can create, reproduce, use the stamp command to create the actual printable file. After that all the processing has to be done, obviously. You have the papers, you add, you scan them. The scan is right now you need to provide a monochromative file, multi-page tiff file, or there are some, I've got some work which means that you can import basically any photo. So it actually works, I've tried it, that you use the cell phone camera, just take a snapshot with your cell phone, the mobile device and pass it over to the import feature which converts it internally to the multi-page tiff, does the 3D transformation and everything. And then you could also use that. But if you're scanning and you don't want to use all this overhead, then you need to have a scanner which outputs a tiff file, monochrome tiff file. And basically the ad command just checks that it's a monochrome tiff file and that the page count is seen and then copies the data over into the project. And the next step is the actual data processing where you run the recognition and it loads the image, it calculates the correction matrix. So what we do here, it extracts the meter data, the barcodes are read, the rotation is done and optical macro recognition happens. So if you consider an image, this is a photo now, it's a black and white image otherwise, obviously. But what happens is that the corner marks are detected, then you can do the desqueuing of the page because actually it's surprising how bad scanners are in printers. The human eye doesn't see it, but it's not quite accurate. So even over the page, you don't only get rotation, you get ensqueues and stuff. We also get that the piece of paper didn't quite move in the same speed while you're scanning or printing. So that means that the checkboxes are actually not quite at the correct position. So what SSTAPS does is that there is an extra correlation there that analyzes the checkbox area just looking for the bounding box of the checkbox or if it's circular for the circle. And then goes back after that to analyze just the center of the checkboxes. There are a couple of characteristics that I've implemented. It's probably not the best. I'm not a computer science guy. I don't know that much about memory data processing. I guess that you could do a lot better. What SSTAPS does is a simple black level check. So it just comes with a number of black pixels in the area, center area. So you can see only the red areas analyzed. The white is just padding to make sure that we don't see the surrounding box. Then another thing is that what I've implemented is a half transformation. So it tries to detect lines and then removes these lines. And the idea is that if a user fills in the box, it's supposed to be considered not marked again. So if I remove the lines from the scan and pretty much nothing is left, then it's probably not filled out completely, which is, let's say, the other way around. If quite a lot is left, then it is filled in. And so it's just a big pin mark. And another thing is that I try to detect continuous white areas to be able to find whether it's filled in just sloppily and you get lots of small white areas. So the coverage is pretty low, but still it's not really a single mark or something. This kind of works. It's not great, but it works mostly so. In my experience, it's fine enough for most use cases in examination. I probably want to think about how exactly you're doing because there you can't really accept much errors. And then we have user interface. It's for menu. It's written in GTK. And it simply shows the document, the scan, and you can hit the checkbox to toggle it and to move it around. And that's all there is to it, really. And obviously, we have that export to CSV and the report. But the thing is with the report, I don't consider SSTUPS to be a statistics tool. However, it's nice to have a PDF report for quick service where you don't really need to be due to complex statistical stuff. So there is some support for statistics. There is some support for report generation. But I don't see a point in adding much more features to SSTUPS with regard to statistics because if someone is actually doing more complicated stuff, they probably want to export the data anyways and then process it further using R or whatever is their preferred way of doing statistics. But you can, for example, export just a subset of data using filters. So you can do some statistics. It works some analysis on the data. So there's a filtering support. It's just a neat feature, but it's also quite hard to explain actually to people. And then we have got some debugging commands, but that's not separate. So I was thinking of that might be actually quite complicated right now. So if we consider, this is just the example document that I have online for the field. So it's just a large PDF document with lots of questions and we chose all the different features. You have mark groups, you have mark line, which is just condensed version of marks. You have a choice questions that we already had, which is the number of choices. And the resulting document. What does it do now? That was correct. Oops. This is the result. So we can do like questions for range questions like this one. We can measure them up into different so that they're more condensed, ask multiple questions at the same time. The choice questions are just multiple choice questions with the possibility of having free form fields which are on the one hand a check box because if something is written it's checked, on the other hand you can get the image data later on if you want to. Then the same thing for choice questions. So this is basically all that I stopped support, but it is enough for most use cases. So it's fine usually. So this would be the... So this is the example document and I can now... What? No. Okay. I thought it's just... So what I can now do is that I'm running the S-Tubs from the development version now, but that doesn't really make much of a difference. So we create the test directory. This is the project directory S-Tubs keeps all the data in. We run the setup test command, which means that we want to test file as an input command and it will compile them. So what happens now is that S-Tubs compiles the document a couple of times, then reads the metadata in, it shows the metadata here, which is what it found, calculates the ID, the unique ID status, are required and then reruns the whole process again so that the printable document is produced in this case. Actually, I'm not quite sure. I think I've modified it in a way that I don't have the printable document now. Let me see. Questionary test? PDF. No, it's printable. It's fine. So what you can see now is that there's no draft. You might have seen before that there was a large draft text on the background so that you wouldn't print it by default. So right now, because it's not a minima survey, we don't identify the user. There's no barcode here. We could simply print this. I have an example scan here. All right. I need to go back here. Let's go. Example. If you have any questions for you to ask at any point, just, if this is an example scan that I have. Okay, right, it's on this screen here. Or actually mixed between the both screens. So I'm just going to use that as an example. So here you can see that it doesn't matter if it's on upside down the scan because as steps find the barcode, that just simply rotates the page. Rather simple to fix the issue. So if I hand this over to S-Taps, it will simply, okay, let's do this. We want the test project which is there. Then we want the example.tiff file. And I forgot the add command, obviously. That's it. It's very quick because it simply does pretty much only copies the file. And now we do the recognize. This takes a little bit. Now we have the data is analyzed and we can have a look at it. So this is it. You can see it. If I simply, I know, make sure that I can see the whole page. I can quickly check whether everything is correct. Oh yeah, that's good. Here it detected the area that the writing is in because the border is both thick. It means that there is text there. That's it. And I'm done. You have reached the first page. Okay, I just went backward, but whatever. And so basically now all I want that is left is a nice looking report, right? That's pretty boring. Oh, there we go. We got a little bit of statistics here. Pretty simple, but it does the job. The text, the free form text fields are simply included as images here so that you can read them later on. And that is all there is to it really. And this uses, this actually creates a lot of document again in this case, but there are different ways of doing it in S steps. So all right, we could also, let's try that. Export. This is actually pretty ugly right now. I think it's data. So it's just a large list of ones and zeros and the ones that, so at the top is the checkbooks. It's the question number encoded there. So one, one is question one, checkbooks one or something. I'm not quite sure I would have expected it to have more. I know the first question is a mark question so it has the integer in there which of the checkbox is checked. So one, one is the first question in the first section and its value is one, three, four depending on what was checked there. Okay, that's it. Right. Any questions or I guess? Probably not. Okay. So all right. So I was thinking of just a little bit about what they did in Aachen. So in examinations you have their different issues. What they decided on doing is making sure that they don't get, they don't have to staple the paper or anything by using a three-folded sheet. So they were limited to four pages. They designed the whole thing in a way that this would be possible and then created some scripts around the whole thing to slice up the images correctly after the scan and combine the four pages into printable document and stuff like that. And then we all, and they also thought quite a bit about the error handling and selection for manual inspection. So this is what their first design looked like which was used for a tutorial. I don't have a design of the later ones. And you can see that basically each question is just the checkboxes. They ask for the formula. They ask for the value that is the result and then they ask for the unit. So basically they just put quite a lot of thought into how to do the questions, how to change the design of the examination so that it would work properly. And they have used it at the beginning of this year and apparently were trying for them. The first, then, but error connection, what they first were trying is that they would go back, they would, sorry, what they first tried to do is that if a student corrected something they were supposed to raise their hand, then if someone would go in and would circle the point where the correction was made here and do the cross and then note it down which piece of paper had to be manually checked later on. They changed that around a bit and then came up with this, with a scheme where the students themselves just go ahead and do the correction. But are supposed to note it down on the first page just so that you know that there is something weird there and then you can explicitly go in. You can filter to just have a look at all the ones that were, this was filled in, the box in the user interface and then you just go through all the pages and look carefully but you can skip all of the ones that are fine right from the beginning so you don't even need to look at those and only look at those if the student seems things that there was a mistake done. And apparently they had two errors with the whole process, two check boxes that were not identified correctly overall where students complained. But then the other thing which was most apparent with the people and with the guy in Princeton, they tried to do very specific layouts and at some point I decided this is, there's no way of going forward with the current lattice code. So what I'm working on right now and I've been working on this off and on for quite a while is a completely rewrite of the lattice class and because the current code is really designed only for very, very simple surveys and only has pretty few layout options. You have basically two question types only. I don't care about single choice, multiple choice which also, which already makes a difference in question design because people do expect that a single choice question is a toggle around checkbox and multiple choice is a square checkbox and things like that because that is what people are learning from the computers. So you really want to mirror these kind of things and it's not designed to do that well. And there are some other aspects like you saw this ESB export. I had the 1.1.1.2 and I didn't know what it was about, right? So what I want is that you can actually change this around later on and you specify in the lattice file what it's called in the export so that you can better do that. So the new code, I've been experimenting a lot with lattice 3 which is really nice. To some extent, probably most of you won't care about that because it's all the background machinery where it's only relevant but I have separated out different support packages. I have a base package which implements a lot of infrastructure. I'm actually afraid that I've over-engineered a little bit but so that you can design the questionnaire properly, you can have sections which are designed slightly differently. You could overwrite some options locally. You could also for examinations if you want the standard answers. You might want to check some boxes and then print it out. And you can do things like that, you can overlay data on top of the checkbox. You can create a text box around normal lattice code. So I've done a lot of work there. So what the support package does is that I edit the context management thing. So what you could, for example, do here is you create a context, context begin, context end and then you enable PDF form creation and you get in this section, in this inside, in between those context commands you get a PDF form elements overlay and you can actually use it correctly in Acrobat Reader to mark things. What would still be needed to be able to post this data somehow to server or something, I guess. It's a variable name, I've tried to find a scheme where you hierarchically can name variables. So if you have a section, you could give the section a variable name then append underscore and then get the question and so forth. Or you could change the checkbox design a bit. And then you have ways of creating your objects, QObjectBegin, QObjectEnd, which is the more important internal name and then this is a choice question. This is going to be written into the metadata so that you have the metadata output and this also means that I separate the metadata output from the actual design, which is a problem when you get really special things like, let's say, graphics as a question. So if you think it wasn't in the examination, they had a graph, a plot, a diagram as the question basically and then different answers. And it doesn't make sense. You can't have a diagram in a metadata in a report. It doesn't make sense to export. So you really want to be able to overwrite the, by default, use the string that the user used, but also have a way of specifying a normal human readable string instead of a graphics, a PDF or whatever. And this is the, I've called it overwrites where you can actually pre-mark checkboxes that have a specific variable name so that, yeah, you could pre-mark them or you could do standard examination results with a feature like that. This is an example document that, well, a test document that I used. So this, as you can see, the blue ones have PDF form elements can be changed. Different ways of overlaying data. There's form data here and this box is simply around the box. And all of this basically works. So actually, S-Tubs can extract the metadata there and can work with the data. Another feature is that it was requested from people. I've talked to a number of people and those were, I think, was Nando. They suggested it. That if you create a matrix of questions, you want a more profile layout options. So what I've tried here, and this is, Henry Menker helped me a lot with this, is that you can actually, by simply changing this one flag in the code, change the layout entirely. And by that, you're very flexible with the questionnaire design because you can focus on what the questionnaire is about and don't have to focus on the layout right away at this point. I still have to do a lot of work with this because I'm not quite sure. This is a matrix layout, right? The table layout. But I'm thinking of optimizing things a lot so that the tables, if you have two tables above each other, for example, that the columns aren't differently sized, I'm not quite sure what kind of features I want to support there. And it's a lot of work to do, unfortunately. But I think it's worth the effort at this point because you want to, yeah, I want to have a nice looking questionnaire, obviously. Yeah, that's basically it for now. I'm done. So if you are interested, there's a homepage, there's a website, there is a mailing list if you can join or IRC. Well, talk to me. Yeah, that's basically it. Thank you. Any questions? Maybe. None? Okay. Oh, I was going to ask about knowledge and explaining what the rules are, or the patterns So the question, I'm not sure if I understood it quite correctly. The question is, could you import data? Or? It's a complex code. If you have an ABC, answer it with how many of the people are answering A? So the question is whether I could ask, ASTEPPS gives me a way of knowing that how many people answered A? If a user answered question A with a certain answer, what else did these people answer there? This is actually something that is possible with the filters because you can create a report where only the answers are included that are, which are, so only the sheets are included with it, which the questionnaires are included where the answer was done. So let's say, let's try this out actually. It should be simple, right? I hope. What do we want? I want projects installed and then this direct show. Let's do the user interface. So let's say we use question one, question one and see whether the question checkbox is checked. So we get this report with everything is good there. And okay, I'm just zooming right now. And this one won't be included. And probably the other ones neither. So I could actually use this. I can use the filter in different programs, right? I could use the filter here. So I could say here, one, one equals, equals one. There you go. We only have two pages and everything else is hidden away. And now if I create a report with that, I get a new file, which is just numbered through here by default, which just includes one in a questionnaire. And that's it. It's a very, very simple way. If you want anything more advanced, you'll need to do the statistics yourself imported somehow. But yeah, it works. Okay, you're welcome. Thank you. Thank you.
This talk will give an introduction into SDAPS how it works and how it can be used automate surveys or even examinations on paper. In the core SDAPS is an optical mark recognition software that is integrated with LaTeX and LibreOffice. It provides all the utilities to automate simple surveys, including questionnaire creation, manual error correction, and a simple report generation module. Also important is its flexibility to be used for data acquisition by either exporting the data or even interfacing with SDAPS python API directly for specialized applications. Benjamin Berg
10.5446/19544 (DOI)
Pretty easy for a theorist to calculate. They can calculate the energy of an isolated K plus ion in a vacuum, an isolated Cl minus ion in a vacuum. And if you tell them the crystal structure and that there are so many distances, then this is the kind of problem a theorist loves. Wow, how am I going to sum up all those positive repulsions out to infinity? And then all the attractions and figure the total energy of attraction of that crystal. And then compare it with the isolated ions. And our solution then was to try to come up with some reactions using Hess's law, to come up with some reactions that we can measure quite easily, and that total up to the one that we want to get. So we just play a game of figuring out what we can measure for this reaction that we can't easily carry out in the lab. And what we're going to do is we're going to do it by stages. We're going to first take the atoms, and then we're going to move an electron off one and onto the other. And we're going to keep track of all the energy in all these processes. And then we're going to total it up and see what we can get. Now the problem here is that some of these energies are rather large. And so although we can get a number, the number may not be as good as we would like. Because when you have to add and subtract large numbers, you lose precision. I get on the scale. I get a pretty good number. I put a submarine on a scale, and then the submarine plus me and subtract. And I can be plus or minus 1,000 pounds, depending whether the tide was going in or out and a bunch of other stuff. And so we have to worry about that here, because some of these numbers are going to be big. The first thing we're going to do is we're going to decompose the salt into its element. Because that's the heat of formation. That's the enthalpy of formation of potassium chloride we can certainly measure that. That's in tables. The delta H of formation is in all kinds of tables for all kinds of simple compounds. So we can get a good number for that. And because we're going backwards, it's minus the heat of formation. So we make potassium metal in the standard state and a half a mole of chlorine, molecular chlorine gas, again in the standard state. And then we have to take the potassium in the standard state, and we have to turn it into potassium vapor. And I've mislabeled this, but I'll fix it. This should be delta H of sublimation, not vaporization, because I didn't start with a liquid, to pass in solid at the standard state. And then we have to make a single chlorine atom out of molecular chlorine. So we take half a mole of Cl2 and make a whole mole of Cl dot. Chlorine atoms, far, far more reactive than just molecular chlorine. In fact, the Air Force had a program on ultra high energy fuels. You may know that in the space shuttle, they use various kinds of propellants. For example, hydrogen and oxygen can be used, and you get a lot of thrust out of that. But in theory, if you could have, instead of a tank of hydrogen and instead of a tank of oxygen as the diatomics, if you had a tank of H dot and a tank of O dot, it would weigh the same, and you would get much, much, much more thrust. The problem is how do you stop them recombining and going back to the more stable form while you're waiting on the launch pad? And if that's a very energetic process, then your rocket just catches fire sitting there. So it's easier said than done. But anyway, there has been some work on that. Then we take the potassium metal in the gas phase, and we ping an electron off it. And that's the ionization energy of potassium. And that can be measured quite well. It's a fairly big number, because as you can imagine, to take an electron off the atom is not quite so easy. But anyway, that's called the ionization energy, and it can be measured quite well. And then we have to take chlorine, and we have to add an electron to the atomic chlorine. And it loves that. Boy, it loves to get an electron and complete that octet. That's quite energetic, and that can also be measured. That's the electron affinity of the chlorine atom. And now, if we just take all these delta H's that we've got, we know that if we add the chemical equations, we just add the delta H's, because delta H is a state function, and it doesn't matter how we get to the final state, including by an imaginary path like this one. So we cancel out everything that appears on both sides, and we end up with the reaction that we want. kCl as a solid going to k plus in the gas phase, and Cl minus in the gas phase. And then we just add up delta H1 plus 2 plus 3 plus 4 plus 5, and we get a number. And then we can compare the number with the theorists, and then argue about who's right or who's wrong. The experimentalist says to the theorist, hey, you better make your calculation more accurate. You made some approximations there. You better go back and do it right. And the theorist says to the experimentalist, you better do that experiment more carefully. I don't really believe that number you're getting there. And until they come into registration, somebody's wrong. Or something's not taken into account. Sometimes there's something not taken into account, and you make a discovery. So science, when everything agrees, is quite boring. When it's exciting is when you have two sides, then both think they're right, and then something doesn't agree. And the question is, what's out of whack? And that means that you're going to make a new discovery, probably, once you figure out what's going on. The lattice enthalpy, I figured, should have something to do with the melting point of these salts. They all melt at very high temperature. But potassium chloride, if you heat it up enough, will melt into a liquid, like ice melts into water. Be a nice, clear liquid has essentially no vapor pressure because it boils at thousands of degrees Celsius. And it can be a dandy way to move heat around. Molten salts are being explored as ways of storing heat, moving heat, and so forth, because they have very high heat capacities, because moving these ions apart takes a lot of energy. The problem is you have to keep them quite hot, or they solidify. And if they solidify in your piping system, then you're in trouble suddenly. So there's a trade-off. You usually don't want too high a melting point molten salt. And I plotted some that I found here as a scatterplot. And I plotted the lattice enthalpy on one axis, and then the melting point. So we had things like sodium fluoride and so forth. I didn't label them all. But it looks like there's more. There's kind of a trend. The correlation is weak. If these results were in biology and not chemistry, this would be proof positive of something or other, that eating sugar gives you diabetes. These plots tend to look like this. But for a chemist, we'd love to see things better. We'd like to take something else into account. Maybe these have different crystal structures. And maybe if we took the crystal structure into account some way, which has to do with the melting point, then maybe these would start lining up better. And then we'd have a better idea of what the true forces and energies in play actually were. But you can see we've got a range here. And there's some correlation, but it's definitely not something to write home about. OK. There are also tables of trying to keep track of the energy it would take to break each kind of common bond that occurs in chemicals. And the way that's been done is that we get a library of representative compounds. And we try to measure how much energy it takes to break each bond. And they're slightly different. Because if we have something else there, it may depend. If we have a carbon and there's a hydrogen hook to it, that carbon-hydrogen bond, it takes a certain amount of energy to bust it apart into H dot and the carbon with a free electron on it. And the energy it actually takes depends on what else is hooked to the carbon. Is there an oxygen on it? Is there nitrogen on it? Is there a fluorine on it? So on. But we can get a representative idea by just taking a bunch of compounds and then averaging. And so here's what we might do for methane. We can do these kinds of reactions. Usually this is done with a laser in a molecular beam or something like that. But in any case, we can do it. And we can get an estimate of the energy. And we have a certain amount of energy to break one CH bond in methane and make the methyl radical, free radical, and then H atom, not molecular hydrogen. And then if we take this guy, we can knock another H off and make this guy. He's like an angry B CH2. You can't let these hit anything or touch anything because they react like that. Bingo. So you do this in a vacuum with a beam coming through and you shoot a laser and you see how much energy it takes to get the products, which you measure separately, usually in a mass spectrometer. And then you take the methylene CH2 and you make a methane CH and another hydrogen. And then you finally pluck off the hydrogen of the methane and you get carbon in the gas phase and hydrogen in the gas phase. And you total up these four, which are not the same. But they're fairly close. They aren't totally different. The first one and the last one may be different. The others may be quite similar. And then the average that we get is for this, the average, what we'd call the average strength of a CH bond in methane would be atom all up and divide by 4. And so these are extremely useful because if you have a table of mean bond enthalpies, as long as you've got the kind of bond you're looking for, then you can just add up the energy to bust all the bonds and then add up the energy to make all the bonds and you can get an estimate for the enthalpy of any chemical reaction you like. You don't need to know the heat of formation or anything, but it's only an estimate because these are approximate. These numbers move around. And this has been done. You take a bunch of them. You don't just take methane, but you take ethane and propane and some other ones. And it requires a little bit of, yes? No, that's the average for one CH bond, averaged over methane. But when they give you a quote in a table for a CH bond, they haven't just done methane. They've done a whole bunch of things. And what I was about to say is it requires some judgment when you're making the table what compounds you measure to put in the average. Just like anything. What do you count or what do you not count? For the census, do you count people who are homeless or not? Things like that. And if you know you're going to miss people, do you try to estimate as well as you can who you've missed? Because they're sleeping under a bridge. Or do you just say, no? Sleeping under a bridge, you don't count. You don't get any services. Same thing here. And I don't know exactly what they've included in the library because they usually fail to say. But the current mean value that they get, just to break one CH bond, is 412 kilojoules per mole for a carbon hydrogen bond. That's a currently accepted value, I think. And lots of bonds are listed. So lots of them are there. They have mean bond enthalpies. But you have to pay attention to the kind of bond. A carbon oxygen single bond requires a lot less energy to break it than a carbon oxygen double bond. And so they will, in the table, try to tell you what kind of bond they're talking about. And you have to make sure, when you look at your compounds, that you're breaking and making the right bonds, or you get the wrong estimate. And as I said, if we know these bond enthalpies, these estimates, then we can estimate delta H for any reaction. And we don't have to do anything. And that's quite powerful. Because we may want to get an estimate about whether something is even worth considering. If the estimate's so far off that it's not going to work, the way we want it to, then we'll try to look for something else. And so we've saved a ton of time. Because rather than combusting the thing and measuring it and then saying, gee, that's no good, I'm going to need a tank as big as a freighter on that car if I use that fuel. We can do that just sitting at our desks. And conceptually, all we're doing is we start with reactants. We convert them all into atoms. We bust every bond. And then we take the atoms and we reassemble them into the new guys. Obviously, atoms are conserved in a chemical reaction. That's why we balance the chemical reactions. And then if we got more energy out than what we used to break it apart, the reaction is exothermic. If these are more stable, then we can get heat out. When it makes a strong bond, it shakes everything else out as heat. That's what happens. And then, as I said, we just recombine these. We make the new bonds and then we tally it up. And we see if the reaction is going to be exothermic or endothermic. And let's try this. Let's take a simple combustion reaction and try this. My example will be ethanol, the ill-fated ethanol push, which was great for farmers who were growing corn and terrible for everybody else. One lesson from that debacle is that you should not burn food. Burning food is a bad idea. If you're going to make a campfire, you don't throw all the chili con carne and spaghetti and stuff into the fire, even though it'll burn. You throw wood into the fire, which you can't eat. And then you cook the other stuff. But what we are effectively doing by converting a lot of corn into ethanol to use as fuel is we were diverting corn from food, and there was civil unrest in Mexico right away because the price of corn tortillas surged. And if you want people to get angry, make them hungry. That works. Remember the French Revolution? It's what happens. We have to watch out for stuff like that. OK, so let's estimate. Well, the first thing you have to do is balance it. And complete combustion always means CO2 and H2O. And if the fuel has nitrogen in it, you have to be careful. You're going to get NOx of some type, NO2. And you have to kind of know what conditions you're operating under in that case. We take ethanol, CH3, CH2, OH. And we need to have two moles of CO2 because we've got two carbons, so we have to have a two there. And we have to have, let's see, three, that's six. So we have three moles of H2O. And then we just figure out the O2 after the fact to make it work. The O2 doesn't matter for the enthalpy of formation because the enthalpy of formation of O2 is zero. But for this thing, we need to look up the strength of an O2 bond because we have to break three O2 bonds. And then we have to reassemble them into CO2 and H2O. And therefore, in this case, it counts, and we have to look it up. If you don't know the structure of something that has a name, ethanol or toluene, then you have to look it up. And you have to get not just the molecular formula like this, but you have to get it in a way that you can see how many of each kind of bond you've got. And therefore, you have to know the structure of what it is that you're reacting. You can't just know the name or the formula. You need to know really the structure of it. This one is pretty much the way I've written it. There's three hydrogens on this carbon. The two carbons are then hooked together. There's two hydrogens on this carbon. And then this carbon is hooked to an oxygen. And then finally, the oxygen is hooked to one hydrogen in ethanol. And therefore, if we total it up, we've got 1, 2, 3, 4, 5 CH bonds, 1 CC bond, 1 CO single bond, and 1 OH, which has to be a single bond. And then the oxygen gives 3 OO double bonds, which we have to look up. That takes energy to break them apart. And then the products have four CO double bonds. But carbon dioxide is kind of a special case. So if you look in the table, carbon dioxide will be set aside separately because the CO bonds and carbon dioxide are especially strong. It's going to be a little bit more than other CO things in formaldehyde, for example. We have four of those. And then here, we've got two OH single bonds for each of those. And so we've got. And if you're doing this on an exam, any bonds that are the same that you're making and breaking, if I have six OH single bonds here and five here, then I can cancel five of them because I'm going to count them the same when I look them up. So I don't need to, you know, whatever I can cancel out before I actually start adding and subtracting numbers makes it faster. The more stuff that cancels, the luckier I am. And if you do that, then you'll figure out what you get. And the easiest way to see what's going on is to draw an energy level diagram. I start with the reactants here, ethanol and molecular oxygen. And it takes energy to atomize them all into atoms because I'm breaking bonds, and that always takes energy. And then I get a ton of energy back when I make these guys. And therefore, this is going down. This is exothermic like crazy using these atoms to make these stable molecules. And then the difference between this one going up and this one going down is what I want, which is my estimate for delta H for this combustion reaction. And that's just how I do it. It turns out then that in this case, it's the reactants minus the products because these are all positive numbers, breaking bonds. They're all listed as positive numbers in the table. And you have to be careful about that because usually you take the final state minus the initial state. And this looks like it's backwards. But I usually draw this. I draw an energy level diagram, and I see which is which. And then I figure out what I'm going to get for the entire thing. That's the easiest way to do it. OK. Some comments. These are only estimates. They can be maybe plus or minus 10% in some cases. So you can't trust them too closely, but they'll give you an idea. And they may not ever predict subtle things. For example, remember we had those two cis and trans dichloroethylene. And we decided that the transform would be more stable because there would be steric repulsion between the big balloon-like chlorine atoms. But if I do it this way, then because both of them have exactly the same number of bonds, then they're predicted to be equally stable. It takes exactly the same amount of energy to break apart cis-dichloroethylene as it does to take apart trans-dichloroethylene because I just count the number of bonds. I got one Cc double bond, two CCl single bonds, two CH single bonds. And they're both the same, so they're predicted to be exactly the same. And that shows you that this approach is never going to tell you some subtle thing about structural isomers based on this because it's not accurate enough to ever possibly do that. The reference state for these reactions is always the isolated atoms. Whatever you have as reactants, whatever you have as products, you're going up to a common denominator up here of isolated atoms. That's how you're figuring out what's going on. With enthalpy of formation, the common denominator is the elements in their standard states. And because those things have actually been measured by somebody, those numbers are way better. Therefore, if you have a choice, if you have all the enthalpy of formation of every chemical in a reaction, you always do it that way because that's going to be far more accurate. But you may not, in some cases, you may not have the numbers you need. This thing we invented, the internal energy, U plus PV, is really of central importance in chemistry because we usually carry out reactions of constant pressure, not constant volume. Therefore, we're interested in the heat evolved at constant pressure, not the heat absorbed or released at constant volume. Therefore, there's hardly any mention of delta U except to introduce the idea of internal energy being the sum of heat plus work. And then after that, chemists rapidly move all the way over to delta H. And that's it. That's all they talk about after that. OK. Let's talk now about heat flow. If we add heat, let's say with a blow torch, to a block of copper at constant pressure, we will raise the temperature of the block of copper. And if we pick another material, for example, aluminum, then aluminum, starting at the same temperature and receiving the same number of joules of heat, will rise in temperature but not as much on a per gram basis. If I take 10 grams of copper and I put in so many joules of heat, the temperature goes up so many degrees. If I take 10 grams of aluminum and do the same thing, the temperature goes up but not quite as much. And you'll notice that if you buy expensive cookware, the bottom of the pot is copper often. And then the sides of the pot are aluminum or something else. And if you want a place in hell where the coals are warming, hang all those pots up so that everybody who walks into your house can see them all the time. And then you spend all your time polishing the copper, which always tarnishes so that it looks beautiful and you can see your face in it. If you want an even worse chore, go over to Newport Beach where a guy has a solid copper garage. Of course, what you're supposed to do with copper, if you have a copper roof, is you're supposed to let it turn green, like the Statue of Liberty. You're supposed to let it get a patina. So you get copper sulfate, copper oxide, and then it just sits there. And that's what you're supposed to do. But if you're stubborn and you say, no, I like the look of shiny copper, then what you have to do is every week, you have to get out there and polish it with polish because oxygen will react. Or you have to coat it with plastic or some varnish, but then it's not quite as appealing as just the bare metal. And I run by that house every other week or so. And I'm absolutely amazed. He must have an army of people polishing that garage, because it's always very, very impressive. A little green around the edges, but nothing worse than that. That's a very bad idea to set up a lifestyle like that, unless you can afford to have someone else do the work. OK, so if we measure the temperature rise per gram, we get something called the specific heat. The specific heat has units of joules per gram per centigrade. And the specific heat of aluminum is larger than that of copper. Therefore, the bottom of the pan will rise in temperature more quickly if it's aluminum. I won't be wasting my gas flame heating up the whole pot. I'll heat up the bottom and then start cooking whatever's in there right away more rapidly. Also, copper conducts heat extremely well. That's another issue. If I take these two blocks, and they're at different temperatures, and I want them to come to the same temperature, all I have to do is bring them into thermal contact. Usually that means you bring them so they touch, or they're very near each other, so they're both heating up air. But in any case, eventually, if you bring them close and in thermal contact, they will come to a joint temperature. And it'll be in between where the two started. If you sit down on a metal chair in a stadium, let's say, that's been baking in the sun, sometimes the first thing you do is sit down and you get up again because it's so hot, it's actually burning your butt off. But if you sit in a plastic chair that's been out in the sun, it doesn't seem so hot. The question is, what's going on? And I think I mentioned this last time, but if you toast raisin bread and then eat it while it's hot, the raisins always seem a lot hotter to your tongue than the bread. The question is, what's going on since these are presumably at the same temperature? And the answer is that your heat receptors don't respond to temperature, they respond to heat, the molecules that are detecting if it's hot or cold, and sending signals to your brain saying, get your hand off there now, or run if they're flames, are responding to heat. And so it depends how much heat gets transferred to you. And it also depends how quickly it gets transferred to you because you have blood flow going through various parts. And if the heat is transferred slowly, your blood goes through and takes some of the heat, new blood goes through, and the temperature locally doesn't go up that much. And so you say, well, it's hot, but I can eat it. But if it's too much, so it's starting to cook you, it's that hot, you either spit it out or you get up off the chair. So there are two issues as to what goes on. The first is you're responding to the total amount of heat, not the temperature. Something that has tiny heat capacity that's extremely hot, like a little spark from a sparkler that lands on your arm, although it's extremely hot, it doesn't have much heat content because it's a very tiny mass. And therefore, it tends to bounce off and not burn you, even though it's extremely hot. And the other thing is it depends on the rate at which the heat is transferred as well. And metals transfer heat extremely effectively. So when you sit down, you get a lot of heat coming in quickly, and then you're off that thing. And they have a high heat capacity, so they can store a lot of heat. When they go up a few degrees, a lot of heat's gone into that chair, more than the plastic chair. And then when you sit down and you're colder, all that heat goes into you. And then you get off. A few proteins start coming undone, unwound, and you're off. You know what temperature it takes water to be at? What temperature before you say no, no? Anybody got any idea? Because if you do, you can stick a temperature in something before you get in. That's sometimes a good idea if you're in a hotel and you draw a bath, and that's in Europe. Sometimes the water is boiling. And if your way of testing it is you put your foot in, then when you struggle to get your foot out, you can actually flip and fall and get hurt. Because it's burning your foot to that extent that you kind of panic and lose your balance. I think Princess Margaret did get scalded in the palace in England because the water was drawn that was too hot, not enough cold in, and she just got in and then slipped and fell in the tub. And then you have to get out. And by then, you're red, and it was just way, way too hot. It turns out it's only 120 degrees. At 120 degrees, you can put, for example, your foot if you've got an injury from playing tennis, because I've done this, you can put your foot in. Your leg up to your knee, 50 Celsius, that's it. Not even close to 100 Celsius. 50 Celsius in water, that's it. If it's going to get any hotter, you can't stand it. You take it out. If it's that temperature, you can leave it. They usually don't have it quite that hot. If they like to heat up joints that have problems, then work the joint to get the flexibility back and then ice it right away to bring down the inflammation. And if you do that regularly, if you're an athlete, you'll heal much more rapidly than if you just sit around and say, ouch, my elbow hurts. So they do do that. OK. Let's use the first law then to predict the joint temperature that two or more masses will reach at equilibrium. This is problem 39 then. Let's take aluminum and copper. Let's take 10 grams of aluminum initially at scalding temperature, 50 degrees Celsius, and 15 grams of copper initially at 20 degrees, nice and cool. And let's just bring them into thermal contact. Let's have them touch. And let's assume that none of the other heat is lost. That's a big assumption because if you have hot things and you have air, obviously the air going over it can cool things down. And therefore, you have to be extremely careful when you're measuring heat that you don't lose any heat. If you lose any heat to the air or some other place, it's not accounted for and you get the wrong number. If we do this in an insulated container and no heat's lost to the surroundings, the question is, what joint temperature will they reach? The specific heat of aluminum metal is 0.9 joules per gram per degree Celsius. And the specific heat of copper is only 0.385 joules per gram per degree Celsius. Well, this is what's going to happen. We have the hot guy and the cold guy. They're initially at different temperatures. And we bring them into thermal contact. Heat will flow from the hot guy to the cold guy. Heat always flows from hot to cold. And then finally, they will come to some joint temperature. While they're at a joint temperature like this, they're dead. We can't use them to do anything. When they're initially like this, if instead of just bringing them into thermal contact, we do something else like we use this guy to boil some water and make some steam and run a turbine. And we use this guy to cool off the steam so that we get a pressure difference across the turbine so we can spin it. Then we can do some work. We can actually produce energy. Once we have things at different temperature, it's like water behind a dam. Rather than just opening the dam and just letting it go out, we can let the water go through and generate energy. And it goes out. And we bleed off something to do something we want to do. But in this case, we're just going to waste the potential here to do work. And we're just going to turn it into this average temperature. The question is, what is the average temperature? Now, the key thing is that heat has an algebraic sign. It can be plus or minus. And therefore, you don't want to try to second guess who's heating up and who's cooling off. You can always do that if you're given two masses. Because you can assume the cold guy's heating up. And you can assume the hot guy's cooling off. And you're going to be 100% correct. But if you're given three masses, like you might be given on the next exam, then if you try to do it that way, you may get into a muddle. Because you won't know if the third guy's going to heat up or cool off. And then you're trying to guess the sign before you do it. Therefore, you don't guess the sign. You just follow the rote procedure. The temperature's going to come out somewhere in between. But the heat that's going to either flow from or to, I'm not going to try to guess, the aluminum depends on the specific heat times the mass of aluminum. And then it's always the final temperature minus the initial temperature. That's all you have to remember. It's always final minus initial in thermodynamics anyway. But that's all you have to remember. And I don't care whether this q sub al is plus or minus so many joules. I do not care. I'll figure that out later when I figure out whether t star is higher or lower than t aluminum, what I started with. Likewise, for the copper, I write exactly the same thing. The only thing that's different is, well, everything could be different. The heat capacity is different than I have, however many grams of copper I have. And then the starting temperature is different, but the ending temperature is the same. I've got numbers for this, this, and this, this, this, and this. I've got numbers for everything here except t star. But I need an equation. I have one unknown t star. And I need one equation. And the equation is that because no heat is lost to the environment, and I didn't run a chemical reaction to make any heat, the sum of the heats is zero. Because energy is conserved, and I didn't add or subtract any energy, therefore my equation is q aluminum plus, plus the sum is conserved, plus q copper is zero. That'll mean that one of them turns out to be negative. But I never write minus. And I never try to say, oh, the heat's going here, and this is heating up, and this is cooling down. If I try to do that, half the time I get it wrong. OK, so let's do it. Here's our first law equation. q aluminum plus q copper is zero. Then I substitute in what I've got here. And that should be equal to zero. And then I just insert the numbers. And in this case, I don't bother converting to Kelvin. I could, but it doesn't matter because a degree Kelvin and a degree Celsius are the same size. And therefore, it's only the difference I'm measuring, and that's going to be the same. And if I want the answer in Celsius, why convert to Kelvin, get the answer, and then convert back to Celsius? That's just taking time and adding extra steps that can do nothing except make you more error prone. I have then 0.9 times 10 grams times t star minus 50 plus 0.385 times 15 grams times t star minus 20 equals zero. I put in the numbers. So I have 9 joules times t star over degree c. I write it this way. This may be unfamiliar to you, but I write it this way to indicate that t star's got to be in degree c. Because only then will the units work out for me. That's the term here. This one's 450, 9 times 50. And then this one's this term here. And then this 115 is this last term. There, I add it all up, and I get 14.775 joules times t, which has to be in degree c, minus 565.5 joules equals zero. And I can divide both sides by joules to get rid of the joules. And I will find out that t star in degree c should be 38.274, which I'll just round to 38.3. And that's the answer. And now that I know t star, if I were asked, OK, how much heat did the aluminum lose? How much heat did the copper gain? I could go back and figure it out, because I have a formula up here for how much. And I can figure out if the algebraic sign was plus or minus in each case. And that's how I would do it. Final minus initial, if it's more blocks, it's a whole bunch of blocks. But I've got to know the starting temperature of each block. I've got to know the heat capacity of each block. I've got to know the mass of each block. And then I just have another term here with t star and some other numbers, and it's all the same. It looks intimidating, but it's all the same. No matter how many blocks you've got, it's always the same. There's a lot of them. You're going to use a computer, obviously, to do it, because it takes too long. Yeah? You know, most of the same things, kind of, between the round and I give this the final temperature, so they can ensure that. Is here the first, the song for the, I mean, the initial? I called the final temperature t star, in this case, just because it was the common temperature. The special temperature at equilibrium. But I could have called it the final. I could have called it t final. But I mean, you can give us the final excitement. That's just a bit of a typical issue, right? Oh, yes. I could say, after the blocks were put together, they came to this temperature. What temperature were the blocks initially? But the answer is, I have to give you the temperature of at least one of the blocks, because there's an infinite number of combinations of hotter and hotter and hotter and colder and colder and colder that will all come to the same final temperature. So I have to give you the temperature of one block and the final temperature, otherwise you couldn't get it. You need to know two out of three of them. Otherwise you can't figure it. Because if you have a really cold one and a really hot one, they make the same temperature as, well, what if they just started at that temperature and went nowhere? That could be a solution, too. They were always at t star. So I'd have to know the temperature of one of the blocks. OK. Calorimetry is the business of measuring calories. It's interesting to me that they list calorie content on food, and then you ask the man in the street or the woman in the street, and they have no idea what a calorie is. Here's the scary thing. A calorie in chemistry is the amount that it takes to raise one gram of water, one degree Celsius. But a calorie in food is a kilocalorie in chemistry. They just call it a big C for calorie, for food. But it's actually kilocalorie. And so if you eat 2,500 kilocalories a day, you're up around 10 megajoules, 10 million joules. That is a lot of running. If you think of a machine that's going to do that, and that's why no matter how much you exercise, if you eat poorly or unwisely, you're going to end up as big as a house. Because there's no way. If you run a marathon flat out, you'll lose less than a pound of fat. And therefore, if you run slowly, it's going to be 35 miles. So if you're one pound too heavy, that's 35 miles you've got to do. And then not eat. And usually, if you do 35 miles, last time I checked, the second people hit the tape, they eat much more than they did, because now they're not only hungry, but if you're tired and hungry, then your defenses are really pretty low. And then if there's Snickers bars around, you go wild. So you have to be careful. Well, the calorie values on food are also a little bit suspect, because if we just burn food in a calorimeter, we'll get a delta H. But it won't be the same as if we eat it. Won't be exactly the same, because for example, if the food has fiber, the cellulose in a bomb calorimeter will burn and produce heat. But because our body can't metabolize cellulose, for us, it's zero calorie. If you just eat cellulose, you die. You feel pretty full, but there's no calorie content. And if you keep eating cellulose and nothing else, you just drop dead. And therefore, they have to try to buck out how much fiber is in there, how much stuff is undigestible. The other thing is that if you eat certain kinds of molecules, your body may elect not to burn them at all. If you're short of a certain amino acid and you eat that amino acid, your body doesn't burn that up and say, yeah, let's just throw that in the furnace. It instead elects to use it to synthesize new protein. Therefore, it gets much more complicated than you think, sometimes, to figure out what's going to happen. Well, even if you measure in a calorimeter, it's really tricky because heat can always leak in. Heat can get in from anywhere. You have to be ever so careful if you're accounting for heat. And big mistakes have been made by measuring reactions and not being careful enough to ensure that no heat got away or got in. The calorimeter itself usually has a carefully calibrated heat capacity. And then if you measure a temperature change, delta T, then that can be converted into joules of heat that you produced by running the reaction. Let's have a look. Let's burn some magnesium. Don't ever burn magnesium because you cannot put it out. Once it gets going, it's extremely difficult. Burns extremely hot and quite heat, and it's extremely difficult to put out. But suppose we put a small amount, a tenth of a gram about, of solid magnesium. And we burn it in oxygen in a constant volume bomb calorimeter. And the calorimeter has a heat capacity of 3,024 joules per degree C. If we measure the temperature rise, and I don't know how they got four digits, but let's go with it, if the temperature rises 1.126 degrees Celsius, then calculate the heat given off in the reaction in kilojoules per mole. You can already see one problem when you're doing this. Where do you measure the temperature? What if you have three temperature gauges in there, and they all measure slightly different temperatures? Which one do you take? Or do you average them, and so forth? It gets tricky because you have to be able to mix things fast and get the heat to equilibrate everywhere so you don't have any hot or cold spots. OK, the constant volume heat, we'll just call it Q sub V, is given by the heat capacity of the bomb calorimeter, and then the change in temperature. Therefore, I know the heat that was produced. It's 3,405.024 joules. I don't believe all those digits, of course, but that's an intermediate result. I work out that the molar mass, by looking it up of magnesium, is 24.31 grams per mole. And therefore, I have 3,405 joules per 0.1375 grams. Convert it to kilojoules. Convert it to moles. And I end up with 602 kilojoules per mole. Well, I had a look, and I looked up the enthalpy of formation of magnesium oxide, and it's minus 601.24 kilojoules per mole, which is pretty close. Of course, the enthalpy refers to constant pressure. And this bomb calorimeter was done at constant volume, which is slightly different. We might get a more accurate answer by using a bit more magnesium and getting a slightly larger temperature change, but we should never let the calorimeter change temperature a lot, because the heat capacity of the calorimeter will be temperature dependent. And if I let it change too much, I may not know what it is anymore, unless I have an equation for how the heat capacity varies with temperature. When you have gases involved, the constant pressure molar heat capacity is larger than the constant volume heat capacity, because if I heat something up at constant pressure and it's a gas, it's a constant pressure. It always expands. And therefore, it doesn't heat up as much. So its heat capacity looks higher, because instead of just sitting there and going up in temperature like crazy, it expands a little bit, and it has to do work to do that. That energy comes from somewhere, and so it's not quite as hot. And therefore, in more advanced courses, you'll see that the constant pressure molar heat capacity of a gas is equal to the constant volume molar heat capacity plus just the gas constant, which comes from PV equals nRT, basically. OK, here's a case study. These guys are going to lift grease out of the economic mire that it's in. And they are raising money for this project that is going to revolutionize power supplies. Here's their scheme. They're proposing to sell thermal power supplies, and you can use them for whatever you want. You can heat, you can boil water, you can generate electricity. And they tell you what they're using. The ingredients they use are high pressure hydrogen and powdered nickel. The first thing I would do is look up whether the formation of nickel hydride is exothermic, because that might explain the heat that they're seeing. But the other thing you've got to be very careful about is that if you've got powdered nickel, metal, and hydrogen, if you have a tiny leak and you let in oxygen, you'll get an exothermic reaction like crazy. And you'll be measuring all kinds of excess heat, and you'll get really excited. And you'll say, I've got this incredible power supply. It's way more than, right? And here's what they think they've done. They claim to have rediscovered low-energy nuclear fusion. This is the kind of nuclear fusion that occurs only in the center of the sun or in an H-bomb. And they, in their literature, say that that's what they think is going on. And that's why these power supplies are so great. And because they've patented all the intellectual property, they're going to sell them worldwide, and they're going to make a killing. And what they would like you to do is give them money so that they can get off the ground, because they're a startup. And my question to you is whether or not you should invest, because, of course, a lot of startups don't pan out, and then you lose your money. The guys working there got paid. And sometimes, right before they go bankrupt, they pay themselves a lot, like they did at Lehman Brothers. So my question is, could it be possible? Because we mustn't just dismiss it out of hand because it seems outlandish. But we have to ask, could it be possible that they are seeing nuclear fusion in this device? Well, let's look at their literature. Here's their description. This is freely available on the web, so I don't think I'm doing anything too wrong. But anyway, they show you this little picture. This is their pre-industrial prototype. And they comprise single and multiple reactor so they use the R word, configurations using nickel and hydrogen, in an exothermic reaction to produce thermal energy in the kilowatt range, providing safe and stable products. Now my question is, how does it work? They have the answer, maybe this is hard to read down here, type of equipment according to Greek class, electric appliance, boiler, thermal source, chemically assisted low energy nuclear reaction. They just slipped that in there. Now it's easier to see it. So there it is, chemically assisted low energy nuclear reaction. The first thing you say is, do you have any nuclear physicists on your scientific advisory board? No. Have you measured any gamma rays coming out of this thing? Because usually when you have nuclear reactions, that's one of the sites. No. Why do you think it's doing this? Because we looked at it after we ran it, and the surface was really rugged, and there were all these defects, and it looked like it had been blown up. And so here's my conclusion on that investment. Unless they prove that that's what they're doing, this is just a way to lose a ton of money. So this is just like the power enhancer thing, but it's more sophisticated. Because it will produce thermal energy, because nickel and hydrogen will react. And if I leak oxygen in on the slide, I'll get a big thing. And then they come back, and they put another tank of hydrogen, and they recharge it with powdered nickel. But the question is, how much energy does it take to make the powdered nickel and the tank of hydrogen? And what you'll probably find out is it takes a lot more than what you're getting out. And they're just charging you an arm and a leg to recharge it once you buy the thing, and then it probably won't work. But we'll see. They might be able to prove that it does. Good luck. So here's my warning. Many, many schemes sound plausible. Remember Alexander Pope, a little learning is a dangerous thing. Drink deep or touch not the period in spring. There, shallow drafts intoxicate the brain while drinking largely sobers us again. If you're an engineer and you understand their jargon and you don't understand that this is probably impossible, you might think it's a good venture. You might put some money in. Sometimes these things turn out to be correct, but only if you let somebody independently verify it. And sometimes very surprising things do turn out to be true. And other things that seem self-evident to most people turn out to be false. That's why we've got science, is to separate the wheat from the shaft. And in every case, we've got to do three things. We've got to repeat the experiment. Not the same guy, a different lab. They repeat the experiment. They get the same result. It's repeatable. Second, we look for clues as to what's happening. If I'm getting a nuclear reaction, I look for neutrons, I look for gamma rays. If I don't see any of those, I don't believe it. And third, we never let anything except whatever the evidence is sway us. If we don't have any evidence for something, our default is to be skeptical always. We don't believe things without evidence because that way madness lies. Once you believe anything without evidence, then I can just attach whatever else I want to that belief. And I can extract money from you or do whatever I like. And so the default is, if you're unsure, you don't believe in it. All right. What we're going to do next Tuesday is work on some practice problems for the final and a little bit of chapter 18. And then the Tuesday after that, we're going to have the exam. So next week, we're going to review practice, practice, practice, we're ahead slightly, so we're OK.
UCI Chem 1B General Chemistry (Spring 2012) Lec 11. General Chemistry Intermolecular Forces -- Born-Haber Cycle, Mean Bond Enthalpies and Calorimetry -- Instructor: A.J. Shaka. Ph.D. Description: UCI Chem 1B is the second quarter of General Chemistry and covers the following topics: properties of gases, liquids, solids; changes of state; properties of solutions; stoichiometry; thermochemistry; and thermodynamics.
10.5446/19495 (DOI)
I just saw a reference to a news article in Google about some new kind of compound or actually a polymer that could be used to remove toxic chemicals, not as a source of environmental cleanup but from the air that you breathe. The article refers to something called POPs, that's clearly an acronym. So I wanted to find out more about what is this POPs business and what does it have to do with cleaning up the air that you breathe. This is work that was developed by Son Bin Nguyen at Northwestern University. The basis for this idea POPs, it's based on a cool reaction that you've never seen before. It's a cobalt catalyzed cyclotrimerization. So you've never learned about any cool ways to make benzene rings. What we've spent our time in this chapter doing is talking about ways to substitute benzene rings. In fact, benzene is very cheap. You typically buy benzene and then add substituents to it. But here's a reaction where you take alkynes and you can ignore these green dash lines for the moment here. And when you throw in a cobalt catalyst and you heat this, if you've chosen the right cobalt catalyst, the cobalt atoms will grab the alkynes and start forming carbon-carbon bonds. So a cobalt atom will grab two alkynes and make a carbon-carbon bond here. And then it will maneuver over and make a new carbon-carbon bond here. And then it will grab another alkyne and make a new carbon-carbon bond there. And if you've designed your alkynes very cleverly, and this is what the shtick here, if you've designed them very cleverly, if you have an extra alkyne on the other end, now that one can engage in this cyclotrimerization reaction. And if there's another alkyn on this end of this other substrate, that can now engage in cyclotrimerization reactions. And if over on this piece here you've got three more alkynes dangling off, that can engage in three more alkynes in a cyclotrimerization reaction. So you end up with these benzene rings that serve as rigid spacers. And at the ends of those you have sites for polymerization. You get this massive polymeric network composed of these rigid benzene rings, and it has lots of space inside. It can't possibly pack very closely. So if you take these kinds of monomers, here's a monomer with two alkynes, and just ignore that functional group for now. And here's a monomer that has four alkynes. It's shaped like a tetrahedron. It's sort of because it's based on this sp3 hybridized center. And if you apply this cobalt catalyzed polymerization reaction making benzene rings, all the benzene rings are highlighted in red. And what this group did is that they incorporated these two alcohol moieties in a protected form and they hydrolyzed off this group. That's chemistry you'll see in Chem 51c. And it left behind two oxygens ready to grip onto metal atoms, and in particular copper and zinc metal atoms. So what that means is this very porous polymer now has metal atoms, and copper is exceptional at binding to amines. So if you're breathing in some sort of toxic vapor that has bad stuff, this will help absorb those vapors, and the copper atoms specifically will latch onto amines and suck them out of the air very quickly. So for example, Vx nerve gas has amine groups on there, and wouldn't it be nice to have some polymer that selectively binds to those kinds of amines? OK, so this is a very cool way to make benzene rings using transition metal catalysis. And it really gets closer to the kinds of reactions that are being developed now in the field of organic synthesis. So let's switch back to chapter 18 stuff in the Gorginski-Smith textbook, and we'll talk about electrophilic aromatic substitution. We left off with one of the ideas that I introduced to you during our last lecture was that if you do electrophilic aromatic substitution on a benzene ring that already has a substrate there like this R group up here, that R group will now control where the second addition of a functional group will go. Groups that are very activating and speed up electrophilic aromatic substitution tend to be ortho-pair directors. They tend to cause the next substituent to add to the ortho-in-pair positions, and usually that's a resonance effect with lone pairs, but alkyl groups can also do that. And then if you look at the groups that are deactivating, which tend not to have lone pairs but have electronegative atoms, those tend to slow down electrophilic aromatic substitution and also lead, they slow down, in particular they slow down addition to ortho-in-pair positions, and so it leaves you with meta-substitution. Those are meta-directors. So I showed you this chart, and I expect you to know this chart, and you'll see in just a little while why you really need to memorize this chart. There's some things in here like this, the position of halogens. That's a deactivator, but it's still ortho-pair, and you just need to memorize that. There's no simple principles you could use to have guessed that. Now when we left off, I showed you these special rules for Friedel-Kraftz reactions. I said Friedel-Kraftz reactions have all these exceptions you have to memorize, and so it is cool to form carbon-carbon bonds. It's undeniably cool, but the problem with Friedel-Kraftz reactions is that acyliam ions are nowhere near as reactive as nitronium ions or those other electrophiles we showed you. Carbocations are nowhere near as reactive as these other kinds of electrophiles that I showed you. So anything below this line here, and let me draw that line, anything below this line, any functional group below this line deactivates the benzene ring so much that you can no longer do Friedel-Kraftz reactions with acyliam ions and carbocations. And that line there just happens to correspond to this line between meta-directors and ortho-pair directors. It's just a happenstance. So we've got this simple rule that any benzene ring that has a meta-director on it is simply too deactivated to work with Friedel-Kraftz acylations or alkylations. Anything above the line you can do it on, but then there's this additional problem, and I don't want to go into the details of this, but that is that if you have amino groups on benzene rings with two alkyl groups or Hs on the amine, that's too activated. It's too activated to work in Friedel-Kraftz reactions, acylations and alkylations. So you can do other types of electrophilic aromatic substitution, but not CC bond formation. So those are all those exceptions or some of the exceptions with Friedel-Kraftz alkylations and acylations. All those horrible exceptions. Okay, so let's continue to talk about exceptions. What are some more of the exceptions that we have to remember that's going to make it difficult? And let's focus again on this over-activated end of that chart, the top end of the chart where things are just too active and get too hard to control. And let's talk about anilines and phenols, and I'll start off by talking about phenols. Boy, that lone pair on oxygen, if you have a hydroxy group on a benzene ring, that really donates into this benzene ring and activates that benzene ring to the point where once you add a single chlorine atom, and it is true that a chlorine atom is slightly deactivating, but this ring is still so activated that you cannot stop a second chlorination. So it adds again. And you still cannot stop another chlorination, so it adds again. Even if you add only one equivalent of Cl2, chlorine, you'll still get trisubstituted products coming out of this. You just can't stop this. You'll get this ugly mixture. So you can't stop over chlorination when you're using this super active recipe with chlorine and ferric chloride. But there's a simple thing that you can do that will allow you to get monosubstituted products, and that is to leave out the ferric halide catalyst, to leave out the ferric bromide, FEBR3, or to leave out the ferric chloride, FeCl3. If you have a phenol and you want to add just one halogen, and invariably you only want to add, nobody wants to add three halogens. If you just want to add one halogen, leave out the FEBR3. It's that simple. That's how you stop. Now you're still going to get a mixture of ortho and para. That's okay if we get a mixture of ortho and para. At least we didn't add all those extra halogens on here. So those hydroxy groups activate benzene rings so much that we get over halogenation unless we leave out that ferric chloride or ferric bromide catalyst. So hydroxy groups are very, very activating. Amino groups are more activating than hydroxy groups. And it turns out there is nothing you can do if you've got a dialkyl amino group or just an NH2 group sticking off of a benzene ring. There's nothing you can do. You're going to get overbromination in these cases. So in this case, if it's, I'll do the case where it's two methyl groups there. If you've got a dialkyl amino group, you're going to get every single ortho and para substitution brominated. And it doesn't matter whether you include the ferric bromide, you may think, oh, well, I'll just leave the ferric, no, that's not going to help. It'll still overbrominate. Remember, these anilines are at the very top of our activated benzene rings list and you just can't stop overactivation. So that makes, so again, there's all these exceptions and you have to memorize these exceptions. I expect you to know those exceptions for electrophilic aromatic substitution. I expect you to know that if you want to brominate phenol that you have to leave out that ferric catalyst and just go with straight bromine. That's how activating that hydroxy group is. Yes? Is that all about the monobrominates? With amids, you can mono-brominate and we used to do that in the 51L labs and I don't know if we do that anymore. So in other words, if you had an amide and you're, we're going to cover amids in amazing and infinite detail next quarter. So if you have a carbonyl group on there, you can mono-brominate that. And again, they used to do that, I'm not sure if they still do that in the 51L labs in 51LC but you may do that. So here you could mono-brominate and what's particular about that is that the carbonyl group is electron withdrawing and these lone pairs spend a lot of time donating into the carbonyl instead of into the benzene ring. But you don't know how to make amids yet. You don't know how to hydrolyze those back off. Wait till Chem 51C and we'll show you that and they will be asking you about this amid case in Chem 51C. They're going to check to see if you remembered this over halogenation of amids. Okay, so that's more exceptions and more exceptions. Let's stop talking about the exceptions and let's start talking about some powerful tools to help you further figure out how to selectively add substituents to benzene rings. Now I talked about this case. What happens if you have a substituent on a benzene ring? You need to know which groups are ortho-paradirectors. You need to know which groups are metadirectors so that you can make a prediction where the second substituent is going to go. But what happens if you have two substituents on a benzene ring? How do you predict where the third substituent is going to go? Which of these groups do we pay attention to when we look at a ring? And we have a very, very simple and powerful rule to help us predict which groups will control the regiochemistry. And our rule says the strongest activating group on the benzene ring controls the regiochemistry, controls this issue of ortho-para versus meta. So if I take this top example here, I think this is called cresol, this para-methylphenol here. I've got two groups there. How do I know whether the brominate, and here's one of these examples where I'm going to brominate and I see the hydroxy group. So I'm smart enough not to add that ferric chloride catalyst because I don't want to over brominate it. I just want to brominate it once. And so which of these two groups controls the regiochemistry? According to the rule I gave you, I go to the highest group on this list and it's over here. It's a hydroxy group. So in other words, the hydroxy group controls the regiochemistry, not the methyl group, and hydroxy groups are ortho-para directors. Let me just write that here. They direct ortho-para. They're alkyl, that's not as high as hydroxy in our list here. So the product of this is going to have a halogen wherever the hydroxy group makes the halogen go. And so I'm going to put that, I can't put it here at the para position, there's already a methyl group there. So really the only product you'll get out of this in high yield is going to be that monobromination product ortho to the hydroxy group. It's the hydroxy group that controls the regiochemistry. Okay, let's go down to this next example. Here I've got a carboxylic acid substituent and again I have a methyl substituent on there. And so when I think about where that third substitution is going to occur, I have to decide whether it's the carboxylic acid or the methyl group that's going to control the regiochemistry. And so when I come over here and I look at my list, well carbonyl groups are down here, solphonic acids, ketones, aldehyamides, any carbonyl compound. But higher than that are alkyl groups like methyl. And that is once again, that's an ortho para director. And you need to know that. So when I look at the two groups, the methyl group is controlling the regiochemistry and the para group, the group para to methyl is already substituted. And so in this case the new substituent, the solphonic acid substituent is going to occur ortho or para, but para is blocked ortho to the methyl group. So that's how you use that rule. It's a pretty simple rule but it requires that you have memorized this list. And you just straight up have to memorize that list of activating, deactivating and ortho-paradirecting. So know that list and know how to use it. So that's the simple idea there. So let me just circle again the groups that are controlling the regiochemistry. This is the group that controls the regiochemistry here. It's ortho-paradirecting. And down here it's the methyl group which is controlling the regiochemistry. And that's ortho-paradirecting. If you have two meta-directing substituents, it's the most activating or maybe least deactivating meta-substituent. You just find the highest group on the list. Okay so and there are problems and many, many problems in the back of the chapter that you should work that will give you practice with that. There are problems on the online sapling homework that will give you practice with that. So practice that. Work all those problems and keep working. Okay, here's an observation that's based, you know, sterics is really overblown as a source of control in organic chemistry. Usually resonance effects are much more important in organic chemistry. What's symbolously referred to as electronic effects that involve molecular orbitals, explanations. But here's a very simple steric effect and the idea is simple. If you have two groups that are meta to each other, like this, if you have a choice, for example here, this group is an ortho-paradirector, so both of these are equally activating. So if this group is an ortho-paradirector, it's going to direct the new substituents to go ortho or para. And this methyl group just so happens because of its positioning will direct to the same positions. So now I have three positions and really these positions here, this position here is different from these two here. Position two and two are both identical. There's a symmetry element in this molecule. You couldn't tell if I substituted at the top position two or the bottom position two. And so how do you decide? And our simple rule is that if there's a choice, you don't substitute between meta-substituents, right here in between it's too sterically hindered. It will be faster to substitute not between those two methyl groups. So here, even though there's all these positions where you could substitute, you only get one product as the major product and in good yield. You'll get very little of the product where you substitute between these two methyl groups, even though our ortho-paradoles predict that this middle position is activated. So one product would have the carbonyl group down here and the other product would have the carbonyl group over here at this other position two, but that's the same. That's the same product as I just drew. So simple rule, it's based on sterics and I hope, maybe that's kind of obvious that it's a little more hindered between the methyl groups, but you wouldn't have known that that would be useful enough to actually really dissuade groups to go in between. Okay, so again, if there's a choice, don't add between the two meta substituents and that's another thing that you have to look out for and it will help you to do synthesis and to answer questions in the back of the chapter and in the sapling problem sets. Okay let me show you a useful reaction. We covered all this radical chemistry back in Chapter 15. It was all kinds of radical substitution stuff. I'm glad you guys are seeing this too. I thought this was just me. Let me see if I can stop this. That's driving me insane. Let me go back to PC here. Okay, let me, let's see what we can do here. This looks like it's on the PC end of the, let me try turning this thing off. Just give me a minute here. We'll sort this out. Okay. This is going to kill us. Okay, this seems to be a doc cam problem. So let me just check out what we've got here. I may not have this lecture on my, I don't know how to fix this doc cam so we may have to make a choice here between chalk or, okay chalk, let's do it. Okay people in the back. Yeah well, I'd like to be able to do that. I apologize for the doc cam here. I don't know how to fix that. Maybe I can give it one more shot here just to see if we can make this work out. Yeah, the last time I taught Chem 51B it was chalk and people in the back complained that they, even, and I write with the big chalk, they complained they couldn't see my writing and I thought I wrote big. So okay, let's see if we have any chance here of not spazzing out. If it spazzes out again I'm going to go right to the chalk and I'll write big to help you. So far so good? Okay, let's cross our fingers here. Okay, so all of that radical stuff and you're never going to see radicals again? Yeah. Okay. I'm considering getting it a couple times. Okay, let's go to chalk. I'm sorry for the, you guys in back I'll try to make an attempt to make sure that we can see what's going on. Okay, I want to remind you of chapter 15 stuff. You learned all of this stuff in section 15.10 about allillic bromination and in cases like this when we treated allillamines with NBS and heat or peroxides you don't use BR2 on here because that will add bromine across the double bonds. We use this N-bromosexinimate compound. The problem with this is you get a radical where the, an allill radical where the BR group can substitute on both ends of that allill radical and so you almost always got these hideous mixtures when you do allillic bromination. And who wants a mixture? And there's also on top of that this issue that you generate new stereogenic centers. That's not such a big deal. But nobody likes to get mixtures of compounds as products in organic chemistry. And so what I'll show you now is if we do the same reaction and instead of doing it on this kind of an allill substrate we simply switch to a benzylic substrate it does the same stuff. So let me redraw that same substrate here and all I'm going to do is make this part of a benzene ring. And I do the same conditions N-bromosexinimate and light. But this time I don't get mixtures of products. You'll get selective bromination of one of the two H's that are at these benzylic positions. And that makes this way useful whereas allillic bromination is not way useful. I would say way useless would be a better description of allillic bromination. You have to have super symmetrical substrates for allillic bromination to give you clean product mixtures. So look at this. I can replace one of the two H's with this same reaction that you learned in chapter 15. And why is that important? Because that's a leaving group. We can go from something that has no functional groups here really to something that has a leaving group at that position. And now you can do SN2 reactions, elimination reactions. So that's very powerful. This idea that we can add leaving groups wherever you want to have those. Because there's no easily bromonatable double bonds in a benzene ring, you don't have to worry about using N-bromosexinimate. So in other words, we can take this same kind and you can have other substituent on the benzene ring. They don't get affected in that reaction. I don't know if this is a distraction that we erased this. And because we don't have bromonatable double bonds where you add Br2 across, you can use Br2 in this reaction if you want. In fact, that's more typical. And the book shows you other types of ways to do this. Or you could simply heat the reaction so hot that you generate small amounts of radicals. So you can't do allillic bromination with Br2, but you can do benzylic bromination with molecular bromine. But it works just fine. And look how powerful that is that we can add a leaving group anywhere that we want to have a leaving group. So you should know that reaction and be ready to use that reaction. Because again, that's very powerful to add a leaving group. OK, I'm going to show you two more useful transformations of side chains. So really what we're talking about now is what are the useful things you can do once you've added a side chain to a benzene ring? How do we turn that into a useful functional group? And let me show you two powerful reductions of carbonyl groups. When there's an arrow group on one side, these tend to be very efficient reduction reactions. So I'll show you a way to take a carbonyl group attached to a benzene ring and burn that down to a CH2 group. And so here's one version of that reaction. This is called a Wolf-Kieschner reduction. And you don't need to know the name of this reaction. It's not important. This is a reagent called hydrazine. There's an NN bond, H2NNH2. And you have to do this under strongly basic conditions, sodium hydroxide. And there's a third thing for you to remember, and that is you have to heat these reactions. These are not mild reaction conditions. So I'm going to write a big delta under here. So hydrazine, H2NNH2, sodium hydroxide, and you boil it. And when you do that, the product of this reaction is now missing that carbonyl. But it's not so much that it's missing the carbonyl. It's that you've now replaced that carbonyl with a CH2 group. And I'll draw that CH2 group for you so you can see. It's not that there's nothing there. There's H's there. And you don't need to know anything about the mechanism for this Wolf-Kieschner reaction. But I think you can see that's useful. And the reason why this is useful is because you can't make that product through a Friedel-Krafts alkylation. So I want you to recall that Friedel-Krafts alkylations on primary alkohalides suffer from this problem of migration. So I want you to recall this problem here. Well, actually let me cover that in just a second. Let me first talk about an alternative set of conditions. Suppose you can't remember hydrazine for some reason, and it's just completely escaping you. There's an alternative set of conditions we can do. This is a reaction called a Cleminson reduction. And it involves taking, you buy this stuff called zinc-mercury amalgam. Here's the way we represent zinc-mercury amalgam. We write it like this. You take zinc powder and you mix it with mercury, and the mercury absorbs onto the surface. So you put the mercury in parentheses. That's called zinc-mercury amalgam. And in this case, it's not strongly basic conditions. It's strongly acidic conditions. And again, these conditions are not mild. You have to boil your ketone with zinc-mercury amalgam and hydrochloric acid. So I'll draw a delta symbol here. That means you're boiling the heck out of this to get it to work. And this will do the same thing as that Wolf-Kieschner reduction with hydrazine. Boy, as soon as I see the CH2 group, I want to brominate it within Bromo6-Inimate. You can see why it's cool to introduce a CH2 group. OK, so this is a way to take carbonyl groups and reduce them down to CH2 groups. You're not going to see anything like that in other chapters. It's a, well, maybe there's a different type of reaction with lithium-aluminum hydrochloric acid. Never mind. In this chapter, that's the only kind of reaction that will take a carbonyl group and reduce it down. So let me make one important point to you, because you're going to tend to get this confused in chapter 20, that you cannot burn down the groups of esters or amids. There's a different side reaction I'm not going to show you. It has to do with hydrolysis. And so you're not going to be able to ever take something like a methyl ester or an ethyl ester and convert those into CH2 groups using this Wolf-Kieschner reduction. We may have some other chemistry to do something like that. But there's, but not exactly like that. So don't do this with esters, not with amids, only for ketones and aldehydes. That's the only place where this is useful. And you'll have a tendency to want to do that. Now, you might ask, which of these two should I memorize? Which of these two is more useful? Typically, the base version is more useful. The hydrazine and sodium hydroxide, because there are so many functional groups that are acid-sensitive, you're going to find that boiling things with acid is usually going to screw up some other part of your molecule. So I usually prefer this Wolf-Kieschner version, this hydrazine and sodium hydroxide. If you want to have, you know, if there's one thing you want to really commit to memory the most, that would be the one that would be most useful to you this quarter. Okay, so let me remind you of why this is useful. It's because of this limitation in the Friedel-Kraftz reaction. Remember this problem with primary alkohalides is that they will rearrange. And so it really limits when you do Friedel-Kraftz reactions. So this is just a continuation. Why would you want to do this Clemensen reduction or a Wolf-Kieschner reduction? If you wanted to take this benzene ring and do a Friedel-Kraftz reaction with this primary alkohalide, if you wanted to make that kind of product, look at this CH2 group here. You might see that and try to write this out as a reaction. But there's a problem with this. You wouldn't get any of the product I drew over there. What you would get would be a T-butyl group substituted on there. And the reason is when you draw out the primary carbocation like this, is that that will do anything so that it's not a primary carbocation. And it will do it quickly. The primary carbocation intermediate that you generate, and I'll draw the, let me draw that H2C group here, will very quickly rearrange to give you a tertiary carbocation. And that's what's going to attack the benzene ring. It's going to be the tertiary carbocation that attacks the benzene ring and does this Friedel-Kraftz alkylation reaction. So if you want to add a substituent like this over here, you have to do it in two steps. First you do a Friedel-Kraftz acylation. And then you use one of these reductions to reduce the carbonyl down to a CH2 group. So that's the way to do things. Now there is an exception to this. I said don't try to do primary alkohalides. But you can do, there are two alkohalides that you can do that kind of look like they're primary. And the book seems to love these and the online homework seems to love these. And I don't want you to worry about the mechanism. You can do it with this because methyl is not susceptible to any kind of a hydride migration. There's no 1, 2 migration possible for a methyl because there's not even a second carbon. The other type of starting material that you'll see used in Friedel-Kraftz alkylations, mainly in the book, not in real life, is ethyl chloride. And why is that not a problem with hydride migrations or alkyl migrations? It's because if you migrate a hydride from one side of an ethyl cation to the other, you get back an ethyl cation. So those are the only two instances of things that look primary where you don't suffer from this problem. In general, if you see a CH2 group attached to a benzene ring, you should make that through Friedel-Kraftz's isolation and then reduce the carbonyl group down to a CH2 group. That's the general way to attach CH2 groups to benzene rings. And that's the way I would recommend to you. So lots of stuff you can do with these carbon substituents. You can brominate them. You can reduce down carbonyls to CH2 groups. That's powerful stuff. And let's talk about carbon nitrogen bonds or nitrogen substituents on benzene rings. And I apologize for those of you in back. The problem is these erasers don't do the best job of erasing usually. And so you're trying to see my writing through this haze of chalk on the board. So let's talk about converting nitro groups, which are pretty useful. You can't make medicines that have nitro groups on them. Those cause problems with toxicity when they're metabolized. So if you want to make useful drugs that have nitrogen on benzene rings, typically invariably you're reducing those nitro groups down and doing something else with those. So here's an example of ortho-nitrotoluene to nitrotoluene. And it's very, very simple to reduce these down to give you something to give you something that's useful to work with. And it's the same conditions that you use for hydrogenation. And that's H2 and palladium on carbon. I usually write only solvents underneath the arrow. That's why I was hesitating there. So palladium on carbon is a catalyst. It's the same thing that you were doing with hydrogenation of double bonds. Typically we don't show the stoichiometry. In fact, it takes three equivalents of hydrogen. Generally I want you to write the stoichiometry. But for hydrogenations, you don't chemically do not draw out the stoichiometry for hydrogen. So I think you can see you're going to lose two H2O's at a minimum here. And then another set of H2's go on to the nitrogen atom. So we don't show stoichiometry for hydrogenation type reactions. Look how easy this. These are the best reactions ever. If ever you want to have a feel good reaction in the lab where you get 100% yield and no byproducts and all you do is filter your reaction, this is the way to go. Now the book gives you two other recipes for reducing nitro groups to amino groups. And this only works when they're attached to benzene rings by the way. You can't do this on alkyl nitro groups. Let's take a look at another set of conditions. Sorry, I don't know how to push this past so you've got some light here to see. So here's the other set of conditions that the book shows. The book shows tin and HCl. And then some books, I can't remember whether it's this one, shows SNCl2 and HCl. And that's actually more typical conditions, stanis chloride. But the book shows tin and HCl or iron powder and HCl. So tin powder, tin is SN, and hydrochloric acid. And the product of this reaction that they show in the book is the same thing that you get with hydrogenation. And so why does the book give you all of these different recipes? Why don't they just? I don't know. But why does the book show you in Chem 51, see all these recipes? Here's why any chemist would want to do this. It turns out that if you have a halogen up above here, those hydrogenation conditions will cleave the carbon halogen bond. Whereas the tin HCl conditions do not cleave the carbon halogen bond. And you're never going to run across that in the Chem 51 series. I'm not going to ask you that. The book is careful not to ask you that. So that's why people might not want to use the hydrogenation is because maybe they don't want to lose that bromine atom. There's a second little trick that I expect you to add that they didn't add here in this book. And that is, if you're stirring around an amine in hydrochloric acid, it's not the amine anymore. The product of this reaction is actually an ammonium salt. And I want you, even if the book doesn't, I want you and expect you to draw out that if you want the free amine NH2, that you have to treat this with sodium hydroxide to deprotonate that. And that's free-basing. Like when you free-base coke this weekend, this is what you're doing. You're deprotonating an amine. And I want you to show that free-basing step. If you do Stannous chloride, that's NH2 I'm drawing here. So don't just draw this one step tin in hydrochloric acid. I want you to do a second step with sodium hydroxide. And usually we just enumerate those. Step one, tin hydrochloric acid, step two, sodium hydroxide. So generally I would use hydrogenation if I didn't have some other reaction I was trying to avoid. Yeah? No, the byproducts here, you get 2H2O's as a byproduct. So you see two of the molecules of hydrogen combined with the oxygens give you two waters. The third equivalent of hydrogen ends up, don't worry about the mechanism. You don't need to know that. You just need to know that that's a fantastic reaction that works every time. Okay, last, let's talk about multi-step synthesis. You've learned a lot of reactions in Chapter 18, actually not that many. Five electrophilic aromatic substitution reactions. And then I just now showed you some fancy ways to dress up those side chains that you put on through reduction, et cetera. So for multi-step synthesis, when you do that involves electrophilic aromatic substitution, the main admonition that I can give you is to strategize regio control. If you want to put three groups onto a benzene ring with a super particular arrangement, you have to know which group you add first because each group is either an ortho-pera director or a meta director. And so you need to strategize regio control. So let's take an example where we want to do some sort of a synthesis. Suppose that you're asked by somebody to take benzene. And then through some number of steps show reagents and steps that would allow you to put on these kinds of groups here. And so you have to think about what do I add first and what do I add second? And what are all those exceptions that I have that I have to worry about? So let's go ahead and talk about this. How would we, typically when you're given a synthesis that you have to do, you have a choice to either work forward or work backwards? I usually start by working backwards. I usually start by saying, what are all the different ways that I could make this? And so what are some of the ways that you know for how to make that? Well, maybe one possibility is we could start off with nitro-benzene and then do some sort of an alkylation reaction. But you already know that doesn't work. Nitro groups are meta directors. Nitro-benzene is too deactivated for you to do any kind of Friedel-Krafts alkylations or acylations. So just forget that. That's out. Really your only choice is to somehow have some kind of a group here. But there is an alternative here. And that is maybe my last step in my synthesis was reduction of one of these carbonyl groups using that Wolf-Kieschner reduction or the Clemenson reduction. Maybe the last step in my synthesis was reduction of a carbonyl. This has to do with me being so clever that I could see that CH2 group. And I remembered those carbonyl reduction reactions that I just taught you. Maybe that was the last step. Or maybe the other possibility that we have here is that the last step involved in nitration. Now that actually looks pretty promising. And that looks promising because alkyl groups are ortho-paradirectors. So we could have made this by first putting some sort of an alkyl group here on the benzene ring and then doing a nitration reaction. Let's remind ourselves of what those conditions are for nitration. It's nitric acid and sulfuric acid. So of these choices, to me what's looking pretty promising here is this nitration. So maybe the last step in this synthesis is involved in nitration. But I think we can probably figure out how to put a propyl group on a benzene ring. And so how would we do that? How would we add a propyl group to a benzene ring? Well, this comes back to another exception that you can't directly add propyl groups to benzene rings. Let me just write that problem out for you here. What was the problem that we just finished talking about with trying to do this in one step? The problem that we talked about is that if you take chloropropane and you try to do a freol-crafts alkylation, that you'll end up with all these hydride migrations. That primary carbocation would be unstable. And if you made something that looked anything like a primary carbocation, I'm not saying that that's what would happen here, but if you started to generate something that looked like a primary carbocation, these hydrides would migrate over. And so before it does freol-crafts. And so in that case, you wouldn't have n-propyl groups attached to your benzene ring. You'd have isopropyl groups attached to your benzene ring. Right? So you can't do just straight freol-crafts to make this. How do we make this? Well, this is where those carbonyl reductions come into play. The best way to put that CH2 group directly attached to a benzene ring is to do one of these reductions. And I'm going to choose the Wolf-Kieschner reduction, that hydrazine one. There's an NN bond there. You don't have to draw that NN bond. And there's two other parts to this recipe. Sodium hydroxide and heat. And if you wanted to do that zinc-mercury thing with HCl and heat, that's perfectly fine, too. So now it's starting to look like we've got a root here. We could start here with benzene and do freol-crafts, acylation, and aluminum trichloride. And then for step two, we could use some sort of a reduction, hydrazine and sodium hydroxide. And then that's the molecule we have over here. And then our third step, we could nitrate. Now there's one little stickly point here that I'm leaving out. And this is the last thing that I'll tell you in this chapter. And that is in cases when you're doing synthesis problems, in cases where I ask you to efficiently make some product, I'm going to allow you to claim that separation of ortho- and para-isomers constitutes an efficient chemical step. And I want to add that in here. Ortho- in other words, if you take something that looks like this and you brominate this, you will get a mixture of ortho- and para-isomers out of this. And there's no way that you can get around that. So as one of your chemical steps in any synthesis, I will allow you to do this. And separate ortho-para. And then just draw whichever one that you want. I admit, yeah, you only got a 50% yield of each one. And that's not really that efficient. But we're just going to pretend that this overall process of making both ortho- and para, and separating out the one you want. Let me just draw one of those. Suppose I want the ortho here. We'll just pretend that that's an efficient combination of steps. So what I need to do here is acknowledge the fact that nitration is going to give me a mixture of ortho- and para. And I need to add an additional step here. So what we need to do here is write step. And I don't know how to raise this board here. So step one is going to be nitrate. And let me go back a little bit here. Let me do it like this. I'll start back over here with my propyl benzene. And I'll write step one, nitric acid and sulfuric acid. And then step two, just like I just told you, separate ortho- and para. And that's the way you deal with that. When you generate ortho-para mixtures, but you only want one of those. I would like you to do that. Okay, that's it. That's the end of what we've got to cover. And I have one last thing to tell you. Our final exam is on Monday morning at 8 a.m. Seating charts are posted and I'd like you to be in your seats at 10 before so we can start passing out the exams. And this weekend, drive thy business. And when you finish this class and you are going on into 51C, drive your business and invest in your career by learning organic chemistry. And so thank you. Have a great time with you this morning.
This is the second quarter of the organic chemistry series. Topics covered include: Fundamental concepts relating to carbon compounds with emphasis on structural theory and the nature of chemical bonding, stereochemistry, reaction mechanisms, and spectroscopic, physical, and chemical properties of the principal classes of carbon compounds. This video is part of a 26-lecture undergraduate-level course titled "Organic Chemistry" taught at UC Irvine by Professor David Van Vranken. Index of Topics: 00:10- Removing Toxic Chemicals with POPs 00:43- Molecular Structures of POPs 04:02- Summary of EAS Substituent Effects: Know This Summary 07:41- 18.9: Over-Activated Anilines and Phenols 11:56- 18.11: EAS on Disubstituted Benzene Rings 15:58- 18.11: EAS on Disubsituted Benzene Rings-no substitution between meta-substituents 18:26- 18.13: Benzylic Bromination 21:48- 18.13: Benzylic Bromination- chalk board 25:11- 18.14B: Reduction of Acyl Side Chains 30:40- 18.14B: Reduction of Acyl Side Chains, example 2 33:52- 18.14C: Reduction of NO2 to NH2 39:28- 18.15: Mulit-step Synthesis
10.5446/19492 (DOI)
I saw this rather horrific story on the news last night. Dad was watching his kid in the garage and suddenly this rattlesnake jumped out of nowhere and bit the child on the finger. And I can't imagine how scared they both were. I can't imagine how scared that little child was going to be of snakes far into the future. Fortunately, this child was doing all right. They took him to a specialist at Loma Linda University and they were able to inject 22 vials of anti-venom in order to stop the action of the snake venom. And so let's go ahead and talk about this anti-venom business here. What's going on with anti-venom that they're giving to people in the hospital? So if you go for a walk in the woods and get bit by a snake, what's your prognosis? So this is a Southern Pacific rattlesnake. That's the most common rattlesnake that you find in the Lake Elsinore region. And if they take you in with a rattlesnake bite, they're probably going to give you this commercial anti-venom. It's produced commercially. They don't make it there in the hospital. And so let's talk about this particular venom called CroFab. If you look at the prescribing information or just the title in the box, it says, Crotolidiae Polyvalent Immune Fab, Ovine. And what that tells you is that it's an antigen binding fragment that is produced from monoclonal antibodies that come from sheep. That's what Ovine means. It means it comes from sheep blood. So what they do is they typically collect venom from many snakes and then they use that venom to immunize sheep. So you immunize sheep, you combine it with something called Croin's Adjuvant, typically, to get the immune system going. And then a couple of weeks later, you give it another boost and the immune system freaks out and is totally ready and starts cranking out tons and tons of antibodies to all the different things that you find in snake venom, in this particular snake venom. And there are lots of nasty things in snake venom. Snake venoms are designed to mess with the cardiovascular system, at least these types of snakes. So they contain enzymes and proteins that degrade tissue, that break down proteins, that lyse blood cells, and that prevent clotting. So you can imagine what a bad mix of toxins this is. So when you inject this into a sheep, the sheep's immune system produces all these different antibodies to all these different bad things that you find inside of the snake venom. And so then you come along and you collect blood from the sheep, doesn't kill the sheep, right? You can go give blood and it doesn't kill you. And then they isolate the antibodies, they use affinity chromatography to isolate all the antibodies and leave all the blood junk behind. And so what do they do with all these antibodies? The last thing in the world you want to do is take a sheep antibody and inject it into your human being. See these parts right here on the antibody called the antigen binding pheromones bind specifically to all those snake toxins. But this part right here doesn't help you. It's just a little bullseye that helps your immune system home in on this and say, hey, that's not human, I'm going to attack it. So what they have to do to prepare this for a human being is to chop off this constant fragment down here and they use an enzyme to do that. And they use an enzyme that's derived from papayas called papain. And that papain comes along and cleaves a single amide bond on each arm here. It's just a single carbon nitrogen bond, but it's extremely specific. And so the enzyme papain cleaves off these little arms, they throw away the bottom part, don't need that. And these top parts look a lot like the antigen binding fragments from your antibodies. Your immune system can't tell the difference for all intents and purposes. So what they're doing is they're collecting these antigen binding fragments that bind to all these different snake venom components. They put it into a vial and those things sit in the refrigerator waiting for somebody to get bitten by a snake. So it's a simple use of an enzyme to cleave very specifically amide bonds here on the arms of immunoglobulins of antibodies. Say again. How effective is that? Is this venom? I'm not an expert. How effective is the anti-venom? I'm not an expert on anti-venoms, but after reading a couple of these stories, it's very effective. If you can get to the hospital very quickly, you're in good shape. If you're stuck out on the woods on a six-day hike, that's a problem. And this is one of the nastiest toxins. You notice they had to use a lot of ant, whatever they said, 22 vials of anti-venom and the kid's doing fine. So you're a lot larger than a kid, so it would be a lot harder to hurt you. But I had a mistake on one of my slides during the last lecture on the Diels-Alder reaction. And I was pointing out this nomenclature for XO versus endo. And what I said was the substituent down here that's on the same side as the alkene bridge is referred to as endo. But then I had a typographical, I mean just a mistake. I said over here substituents on the same side and I again said alkene. I should have said alkane. That should be alkane bridge there, not alkene bridge. They can't both be on the same side as the alkene bridge. So this is the alkane bridge here and that's XO. I'll just write alkane. So please replace the letter E there with the letter A on the bottom. And if you're not exactly sure, look at the book because I just had the same word twice and that's because I was copying and pasting too much. Okay so we moved on from chapter 16. Chapter 16 was a lot of dienes and conjugation and we moved on to chapter 17 to talk about aromaticity. And one of the main points about aromaticity is that you learned all these different reactions of double bonds. Lots and lots of different reactions of double bonds and what's going on there. In chapter 10 you learn more reactions of pi bonds in alkynes in chapter 11. But for some reason the double bonds of benzene are resistant to the typical reagents that you know. Bromine doesn't add across the double bonds of benzene rings. HBR doesn't add across the double bonds of benzene rings. You can't hydroborate the double bonds of benzene rings. And so it seems like it's pretty important for us to be able to recognize when double bonds have this property of aromaticity. When is a double bond part of an aromatic ring system? We need to know that so we know which double bonds have low reactivity towards typical electrophilic reagents. So I'm going to give you just one moment here. I'm going to give you, if I can get my act together here. Yes, sir. It is amazing how quickly I have now mixed up all of my little sheets that I had here. So you will have to just pardon me. You can stare at the chalkboard behind me while I'm sitting here trying to sort through this. I want to note that we have extra office hours next week. Next week is the last week of lectures in this class. So of course what that means to you is you've got one week left to study for the final exam which is on Monday of final exams week. So please make this last week count as we are going through that kind of material. So I want to talk about aromaticity and how to recognize aromatic ring systems when they're there in front of you. So I'll just do the best to sort through my disarray of notes here. I want to introduce you to some, oh that's not the, here sorry about that. That's not what I wanted to give you. Here's what I wanted to show you. It's to try to give you the ability to recognize aromatic and anti-aromatic compounds. So probably you have your notes in front of you and know where they go. Okay, so let's talk about this. How do you recognize an aromatic compound? This property of aromaticity that causes double bonds to be unreactive. That causes protons in your NMR spectrum to be shifted way downfield to 7 to 8 parts per million. That's super particular to benzene rings in the proton NMR. So it's important for us to recognize aromaticity and we're going to use a set of three rules in order to decide whether something is aromatic or not. Here are those three rules. And the first of those rules is kind of a mathematical rule but I'll have to explain how we do this accounting for this mathematical rule. It's called Huckel's Rule. And it's very simple math. It's 4N plus 2 where N is a whole number that allows you to calculate how many electrons should you be counting up when you try to add up the electrons in a potentially aromatic ring system. And because N is always a whole number like 1, well 0, 1, 2, 3 or 4, when you do the math that means it's telling us that all aromatic ring systems have either 2 electrons, 6 electrons, 10 electrons, etc. And in practice you typically don't get things with more than about 14 electrons. It takes a lot of synthetic work to try to design systems that have more than that many electrons but we still give you the mathematical formula in case you want to calculate it out to infinity. So let's take the canonical aromatic compound and that's benzene. When I think of aromaticity, benzene is always the first thing that I think of. And if I count the electrons here in these pi bonds, it's 2, 4, 6 electrons. And there's a special requirement for those electrons that I'm adding up. First of all, they must be in a planar cyclic array. So if I look at these pi bonds in benzene, they are in a planar cyclic array. Benzene is planar, benzene is cyclic and they're all connected to each other and conjugated. If I come over here and I look at this 6-carbon chain that is not connected here, there's no bond here. This is not aromatic because it's not cyclic. So it does have the 6 electrons. It satisfies that Huckel's 4n plus 2 rule but it's not cyclic. So obviously that can't be an aromatic ring. In fact, this is just a really reactive trying. And then the final point here is that the pi bonds and or p orbitals, you can have 2 electrons in a p orbital, they have to all overlap with each other. And so when I come over here and I look at this compound, cycloheptotriene, this CH2 group prevents this end of this double bond here from interacting with this end of this double bond over here. So those two ends are not in conjugation. They are not part of a continuous conjugated cyclic array. And I'll show you this business about p orbitals. None of these actually have an example of electrons in a p orbital. Okay, so that would be an example of an aromatic ring system. And so let's go ahead and extend that idea. So I'm going to compliment that by telling you about something that would be the opposite of aromaticity. And that would be anti-aromaticity. So what would be an example of something that is anti-aromatic? And I think I'm messing this up again. So let me show you, just give me the ability to write on here. Okay, so anti-aromaticity is the opposite of aromaticity. Aromatic compounds are stable. There's a thermodynamic driving force for organic compounds to want to form aromatic ring systems. Those confer stability. And conversely, it is thermodynamically unfavorable for systems to form anti-aromatic compounds. So what makes a compound anti-aromatic? And again, there's going to be three sets of rules that I'm going to apply, and they're almost identical to the rules for deciding aromaticity. And the only difference is, instead of 4n plus 2 electrons, it's 4n electrons. So whenever I see 4 electrons, like 2 pi bonds in a cyclic array, or 8 electrons in a cyclic array, or 12 electrons, etc., that tells me that that's probably going to be a very difficult compound to isolate. Probably that compound is going to be filled with self-loathing and try to self-destruct or react in some way. So everything else is the same, if I see 4 electrons or 8 electrons in a planar cyclic array, all conjugated together, and they're all in overlapping pi bonds and p orbitals, so they're all conjugated, then that tells me there's going to be problems. So let me take an example, and whenever I think of anti-aromatic, here's the prototype. Let me go ahead and use a black pen for this so I can draw this more clearly. Cyclobutadiene is the canonical anti-aromatic compound. You cannot just make cyclobutadiene and put it in a flask. It's not stable. Yes, question? You listed 14 electrons before, and the dot was all before. Yeah, thank you. 16 electrons. Thanks for asking that. I guess I'm not so good at math here with 4n. Once you get to those larger numbers, it's very atypical. I'm sorry about that math mistake there. Okay, so of course the problem here is I've got 2 double bonds, pi bonds in a cyclic array, and I add up the electrons here, and this is definitely anti-aromatic. And that's why nobody has ever made this on its own. Chemists have managed to trap cyclobutadiene in little cage-like molecules so it can't escape. That's one way to stabilize it. The problem is that when you try to make cyclobutadiene, it's not like we don't have reactions or elimination reactions that can make that. Is that it starts to react like this resonance structure. It hates being anti-aromatic so much. You can imagine if I take the electrons in this bond here and I give one electron to each carbon, I'll draw a resonance structure that's a diradical. And that's a better picture for cyclobutadiene. It's like each electron is saying, forget that other thing away from me. I do not want to acknowledge the existence of that other electron. I don't want to have a pi bond. I don't want to have conjugation. So it acts like this. This is how much cyclobutadiene hates being an anti-aromatic molecule. Now there are other apparent anti-aromatic molecules that have been synthesized that somehow manage to avoid being anti-aromatic. So for example, chemists have made cyclo-octatetraene, a cyclo-octane ring with four double bonds and it looks kind of aromatic. It looks kind of like a benzene ring. The problem is that it's got eight electrons. So there's two electrons in each pi bond, two electrons here, two electrons here, two electrons here and two electrons on top here. That's eight electrons. And the way that this avoids being anti-aromatic is it bends into this boat-like shape that prevents the double bonds from being in conjugation. How clever of that molecule that it figured out that it can bend into this kind of shape so that the pi bonds are literally orthogonal to each other. So in fact, cyclo-octatetraene with four double bonds is not anti-aromatic simply because it's not planar. If you tried to somehow flatten it to make it planar, it would freak out and probably start to act like a diradical or do Diels-Alder reactions. It would find some way to not be to react and turn into a stable molecule. Okay, so try to recognize aromatic compounds because they don't do addition of the reagents that you're familiar with, bromine, HBR, hydroboration, hydration. They have special properties in the NMR spectrum. And don't expect that you'll be able to make anti-aromatic compounds because you won't be able to synthesize those. They'll find some way to finagle themselves out of being aromatic. They won't be aromatic. Okay, so let's talk about this issue of planarity. How do you know if an atom is planar? Now I'll show you why this is important in a moment. Not every aromatic compound has only carbon atoms in there. Sometimes you have to count lone pairs as part of your 4n plus 2 calculation or your 4n calculation. And we have to decide how we're going to calculate that. We have to decide which pairs of electrons we're going to count. And I want to start off by addressing this issue of how do you know whether a pair of electrons is in a p orbital or not in a p orbital? I'm going to start off by looking at ammonia and I think all of you know. Did we? Let me, does somebody have a set of notes that I can look at so I can try to get back on track? Plainer aromatic ions. Okay, perfect, thank you. And I'll get to this, I'll come back to this issue in a second. Okay, how do you know if something is planar? Before we look at this issue of lone pairs, how do you know whether an ion is planar? So let me start off by taking a look at a series of ions. So for most of these compounds here, there's very little opportunity for these to bend out of planarity. These are pretty much forced to be planar because they are so small, the ring size is so small. There's no opportunity for these to bend out of planarity like that cycloactotetraene. Kind of the largest ring size I'll talk about here is a seven-membered ring. And so let's talk about what are our options here? I obviously can't have a double bond here on this last carbon atom, the top carbon atom of this three-membered ring. And so what I'm going to do is I'm going to put a positive charge here. If I add up how many electrons are in this empty p orbital, and I'm going to struggle to draw that empty p orbital there, there's zero electrons. So when I add up all the electrons in this array, this array of conjugated double bonds, then what I'll find is that there's two electrons. And because there's two electrons here, that's aromatic. That's 4n plus 2 where n equals 0. So this would be a much more stabilized carbocation than you would expect. And if it truly is aromatic, then we ought to be able to draw a bunch of resonance structures where we delocalize the pi electrons all over that ring. And let's just practice that just to make sure that it has this property of delocalization like benzene. I'm trying to draw an arrow here where I shift that double bond. Let's start to draw some of these resonance structures where I shift, and I'll have to draw this a little bigger here, where I shift that double bond around. If I take the electrons away from this carbon and move them here, now my cation is over here, and I can draw another resonance structure where I move those electrons to here and take the electrons away from this other bottom carbon. And so this has this property of delocalization just like a benzene ring. It has 4n plus 2 electrons. It's planar. In fact, I don't think that could be anything but planar again. So this very strange looking, even with all that strain, cyclopropenium ions are stable and have been made in the laboratory. It's not like you can put it in a flask, but they have been made, and you can get spectra of those kinds of species. Okay, so what do we need to do to a 5-membered ring in order to make that aromatic? If I put a carbocation here like I did with this cyclopropenium ion, if I put a carbocation there, I'll only have 4 electrons, and I definitely do not want to do that. What I'd really like to have here is electrons 5 and 6. So what I really want to have for this to have this property of aromaticity is I want that to be a carbanion at that center. And so I'd really like for these electrons to be in a p-like orbital. And I'll address that. I was just getting to that. Is that p or sp3? So now if I add up my electrons, I've got a planar array, and I have 2, 4, 6 electrons. So let's just add that up 2, 2, and 2. That's 6 electrons. That is an aromatic anion. That carbanion is amazingly easy to make. It's very hard to make carbanions. It's hard to pluck protons off of carbon atoms. But in this system, because this gets to be aromatic, it's very easy to make that by deprotonating carbon. Okay, so now let's come back to the last. The 7-membered ring kind of takes practice to learn how to draw 7-membered rings. That will come with experience. So now if I want to have 6 or 4n plus 2 electrons in this system, do I want to have a carbocation here or a carbanion there? Yeah, we want 0 electrons. We've already got 6 electrons. We don't want to add any more. So we don't want to have a carbanion here, we want to have a carbocation. That would be a stable aromatic ion. So if I add up all my electrons, there's 0 in this p orbital. Let me try to draw that p orbital here. And I'm not going to draw all the different resonance structures. There's lots. But if I add up my electrons, there's 2 in this pi bond, 2 in this pi bond, 2 in this pi bond. There's 0 electrons in that empty p orbital. That's a 6-electron system. That cation would be aromatic and exceptionally stable. So what are the implications here? Implications for you with respect to these aromatic ions is that if you're ever confronted with cyclopentadiene, it is so easy to pull this proton off that you can use regular bases like alkoxide bases. And no other simple alkane allows you to do that. You can just take that and pull that proton off because the product here, I should have used a red arrow there, because the product here is aromatic. The product here is aromatic and heavily stabilized relative to other types of organic molecules. OK. So you can't use alkoxide to pull protons off of hexane or cyclopentane. Or even if you had just one double bond in this ring instead of two, you couldn't use alkoxide to deprotonate that. So those CHs are exceptionally acidic. Somewhere on the order of 34 orders of magnitude more acidic than a regular alkane. Let's come back over here and look at this 7-membered ring. And now it's different. I'm not talking about deprotonating this, but what I've done is I've put an alcohol on here that's been protonated. If you just touch a proton onto that alcohol to put a potential leaving group, this leaving group will fly off. And again, the reason why this is so fast, the reason why that is so exceptionally fast is because it generates an aromatic ion. So reactions that generate aromatic ions, whether it's deprotonation or ionization, those reactions are amazingly fast. And the situation would be totally different now if I did this, just to be clear here. If I only had one double bond in this ring, that's no longer fast. There's no base or simple base that you know of or will have heard of in the Chem 51 series that could ever pull this proton off. So I'm just going to put a dashed line here because this is insane. There's no way you could pull that proton off. That's not going to be aromatic. So you have to look for systems that have the potential to be aromatic. Those reactions will be exceptionally fast if they generate an aromatic ion, either a carb anion or anion. And let me just sort of remind you here that this is fast and this is fast. And this other one is just, there's no way, inconceivable. So gee, isn't it great to become aromatic? You get to enjoy all of that stability. Okay so I drew empty p orbitals with carbocation ions. And then I drew this sort of carb anion where the lone pair was in a p-like orbital. And how do you decide the hybridization of an atom? How do you decide whether electrons are in a p-like orbital? Because only if the electrons are in a p-like orbital do you add them up as part of your 4n plus 2 calculation. So let me just remind you that we'll use nitrogen, not carbon as our example here. I think all of you know that simple amines are pyramidal. Ammonia adopts a pyramidal geometry. That's the lowest energy hybridization for this nitrogen atom. So in this sort of a scheme here, these lone pairs exist in this sp3-like orbital. And that has differential sizes on each end of the orbital. So one end of the orbital is big, the other end of the orbital is small. So that would be an sp3 form of hybridization. If you were to shrink yourself down to the molecular scale and grab these R groups and bend them to the lower planar, you could force this nitrogen atom to adopt an sp2 hybridized geometry. That means each of these bonds have sp2 hybridization, but the electrons in the lone pair, they're in a p-like orbital. And a p-like orbital has the same size on the top and the bottom. And that would be a requirement for us to add this into our 4n plus 2 rule. So let's see how that comes into play. How do you decide in this 5-membered ring system here? What I'm doing is I'm drawing edge on, this is really just the molecule parole. And it's got substituents on all these. I drew substituents on all these. And so the question is, is parole aromatic? Does this 5-membered ring with that nitrogen atom and its lone pair, is that aromatic? Do I count that lone pair in my 4n plus 2 rule? If that lone pair can contribute to aromaticity, it will contribute to aromaticity. So there's two possible hybridizations for this. Most amines don't exist in a planar form, but when I give this lone pair the opportunity to participate in an aromatic ring system, in this 4n plus 2 ring system, it will rehybridize. So flat in this case is more stable because it gets to be aromatic. And that's not normal for amines. Amines don't do that. By being flat, these electrons get to participate in a p orbital. So there's my p orbital there. And when those electrons are in our p orbital, we have equal hybridization there on the top and the bottom face. Or equal, I guess the p orbital has equal size on the top and bottom face. And that allows it to effectively overlap with the pi bonds, which have electron density on the top and the bottom face. So you'll count lone pairs in this 4n plus 2 rule if they can exist in p-like orbitals. And I'm making a big deal about this because there will be cases where lone pairs cannot exist in these p-like orbitals. So you would expect those to have less aromatic resonance energy. Okay, so let's take a look at some systems that have nitrogen in them. Some rings that have nitrogen or oxygen. And try to decide should we count the lone pairs. And I'm going to give you a simple rule to help, I say simple. Maybe it's very wordy, but once you use it a few times, it becomes very user friendly. So I'm sorry, maybe the rule is not, doesn't sound simple. So here's a whole set of heterocycles. Heterocycle means there's a heteroatom in the ring. Usually oxygen or nitrogen, but you can have lower row heteroatoms like sulfur in the ring. So for heteroatoms, how do I decide which of these pairs of electrons to add in to my 4n plus 2 rule to decide whether these are aromatic or anti-aromatic? And here's our simple rule. And I'll read this out to you. If the heteroatom is not part of a double bond, if it's not part of a double bond, then you can count one lone pair towards the 4n plus 2 rule. Now that's a whole string of logic there, so let's practice using that. So if a heteroatom is not part of a double bond, okay, well that nitrogen is part of a double bond. That means I shouldn't count that lone pair. I only count lone pairs if they're attached to atoms that are not part of a double bond. So I'm going to go ahead and cross this out. No, I don't count that. The nitrogen's part of a double bond. So now how many electrons do I have to count? I've got just the double bonds left over. That has six electrons and that's aromatic. So I think you'll be as good as I am at figuring out which of these heteroatoms are part of a double bond. Okay, so let's take this next heterocycle. This is called furan. Okay, if the heteroatom is not part of a double bond, well that oxygen is not part of a double bond. There's only single bonds to that oxygen. Okay, if the heteroatom is not part of a double bond, you count one lone pair towards the 4n plus 2 rule. So I've got two lone pairs here. I'm going to cross one of them out and I'm only going to count one of them. So how many electrons in this system? Six, two, four, six. There's two in this lone pair and then two in each of the pi bonds. That's a total of six electrons. That's aromatic. Okay, let's try to apply it to this heterocycle here that has the two nitrogens next to each other. So if I look at this, again my rule is if the heteroatom is not part of a double bond, well neither of those nitrogens is part of a double bond, then I get to count one lone pair towards the 4n plus 2 rule. So I count both of those lone pairs. Both of those nitrogens are not part of a double bond. So when I count up these electrons here, that would be eight electrons and that would be anti-aromatic. If you could somehow synthesize a molecule with that pattern of bonding, that molecule would be very reactive. It would try to find some way to distort out of planarity or it would try to find some way to react and so it wouldn't have double bonds in that arrangement. That molecule would be extremely unhappy. Okay, so here's a five-membered ring. This is the side chain of the amino acid histidine. It's called a mitazole. And so let's use our little accounting system here. If a heteroatom is not part of a double bond, well this nitrogen atom on top here is part of a double bond. So I don't count that lone pair. The nitrogen's part of a double bond. Okay, let's look at the bottom nitrogen. And our rule says if the heteroatom is not part of a double bond, you count one lone pair towards 4n plus 2. Oh, well we count that. So now we can count up our electrons. There's two in this pi bond, two in this pi bond, and two in that lone pair. That's six electrons. The side chain of histidine, a mitazole, is aromatic. It's an aromatic ring. So every protein in your body is filled, histidine is a common amino acid. It's filled with aromatic rings on the surface of your proteins and the inside. Okay, here's one of the bases of DNA and RNA. This is adenine. And so now there's two sets of rings here. And I can draw different resonance structures. Whenever you've got a double bond between two different rings that are fused together, you double count that double bond. You can look at each ring independently and count that double bond towards each ring. So let's take each of these rings independently. I think you can see that the ring over here on the left hand side is a mitazole. We already did that one. Right? Let's apply our rule. If the lone pair is not part of a double bond, well this lone pair is part of a double bond. I'm not going to count that. And I come over here and this nitrogen atom, well that's part of a double bond. That means I'm not going to count that. And what about this nitrogen atom over here? Well that's part of a double bond. I can't count that. So the only lone pair I count is on the nitrogen that's not part of a double bond. So now when I start off and first count up this five-membered ring here and I add up those electrons. There's two in the lone pair, two in the pi bond, two in the pi bond. This ring here has six electrons and that's aromatic. Now I come over here to the six-membered ring. I don't count any of those lone pairs. And there's a lone pair on the nitrogen but that's not the amino substituent. That's not inside the ring. That's not part of this ring. So don't even worry about the substituents. So I have two, four, six electrons. This ring is aromatic. Both the rings of the DNA base adenine or aromatic. And you would draw the same conclusions about guanine, cytosine, depending on which resonance structure you draw for those. You could consider the other DNA bases to have either partial or full aromaticity. Okay. So let's just come back to why does this rule work? The reason why this rule works. I mean it's very empirical. You don't gain any insight about the geometry of the molecule simply by deciding whether an atom is part of a double bond. All those electrons that we were counting as part of that rule will exist in p-like orbitals. So when we were counting lone pairs in our 4n plus 2 rule, that's because they were able to adopt geometries that were flat so that the lone pair could be in a p-like orbital. So it could interact effectively both and I'm not sure I want to try to draw this in here but with pi bonds that have electron density top and bottom. What about the electron lone pairs that we crossed out? In every case where we crossed out a lone pair, when a heteroatom was part of a double bond like here in pyridine, what that means is that lone pair existed in an sp2-like orbital sticking out of the side of the aromatic ring. So when you didn't count the electrons, they're not sticking up and down in a p-orbital, they're sticking off to the side of the aromatic ring or of the benzene ring or pyridine ring. The implications are these lone pairs that are involved in aromaticity, they're busy. Don't try to mess with those because you'll disrupt aromaticity. So what you would find is that lone pairs like this are simply not reactive. It's very difficult to protonate them. You couldn't protonate that. In fact, if you try to protonate, if you struggle to protonate pyridine by throwing in a powerful acid, it protonates on carbon even. So don't try to mess with that lone pair because it's doing something. It's trying to make the system aromatic. In contrast, the lone pairs here that are sticking out to the side of an aromatic ring, no problem reacting with those. And you know that already. Pyridine is a base. You've already done reactions where you used pyridine as a base. So you can do all kinds of reactions with these lone pairs that are not part of the aromatic 4n plus 2 rule. So no problem reacting with the lone pair on pyridine or this crossed out lone pair on histidine. If you look inside the active sites of enzymes, one of the most common lone pairs used in catalysis is this lone pair that's sticking off to the side of a histidine side chain. If you look at every single amide bond that is produced in every single protein in your body, every single amide bond is created because this lone pair on the bottom of this adenine ring, a single adenine, a single lone pair inside the ribosome is responsible for the synthesis of every single protein, every single amide bond in the human body. So lone pairs that stick off to the side are completely reactive whereas lone pairs that are part of aromatic systems are not reactive at all. Okay. So I think you can see from adenine that you confuse benzene rings together and have much larger aromatic ring systems. So I'm going to give you an example of some fused systems here. So you can see that there's more than one way to account for this 4n plus 2 rule. There's more than one way to do the addition there. So this is a molecule called naphthalene. If you go to the hardware store and buy moth balls, it turns out that crystalline naphthalene just by solid balls of crystalline naphthalene and for whatever reasons moths seem to find that repulsive and will tend to stay out of your closets. So there's multiple resonance structures that I can draw for this. If I count around, if I just ignored this ring, this bond in the middle of those two rings, that sigma bond, just pretend that it's not there, I can count around the outside edges of this flat molecule. And if I count around the outside edges of that flat molecule, what I would find is that there's 2, 4, 6, 8, 10 electrons. That satisfies our 4n plus 2 rule and that's aromatic. There's another way I could have done the accounting for this, that's slightly different, another way to describe this is I could have drawn a resonance structure for naphthalene in which I put a double bond in the middle. There's a different way I can shift around those electrons. And so remember what I said is if there's a double bond at the ring fusion, you can count that double bond for both rings. So in other words, the other way I could have accounted this is I could have said in this ring over here on the left hand side, there's 2, 4, 6 electrons and that's aromatic. And then I look over here at this ring on the other side and there's 2, 4, 6, I double count, I get to count that double bond again and that's aromatic. So I can count that middle, that double bond in the center twice and I reach the same conclusions either way and that is that all of the carbons in this ring system are part of an aromatic ring. I won't reach a different conclusion. So you can fuse these things in all kinds of different ways. Let me give you another example of another aromatic ring that's very common that's fused and this time it's a parole ring fused onto a benzene ring. This is the side chain of the amino acid tryptophan so I'll just write trip here and there's a lone pair and there's nitrogen. So again in this ring system both rings, both of these rings in this heterocyclic, this is called an indole, this bicyclic ring system, both of these rings are aromatic. This ring over here which obviously is benzene, that's aromatic, it has 6 electrons. If I look at this 5-membered ring over here there's 2 electrons in the nitrogen, 2 electrons on this side bond and then 2 electrons over here that's also aromatic. So the side chain of tryptophan is fully aromatic as is the side chain of tyrosine and phenylalinane. You guys are probably learning about those in Bio98 right now. Okay so you can, it can go endlessly. You can fuse benzene ring after benzene ring after benzene ring onto each other. You may have heard of carbon nanotubes or graphene, that's basically what those molecules are. They're just infinite tubes made out of benzene rings all fused together. Okay so the last parts of this chapter are interesting but they're not going to be useful to you for anything else in this quarter. They have to do with molecular orbital base of aromaticity and I think you ought to read that. I would never discourage you from reading anything but it's not the kind of thing that I can test on. People learn about those powerful concepts if you take upper division classes and I would love to teach those to you there but we just can't fit those in with the time that we've got. So be able to recognize aromatic rings, be able to recognize anti-aromatic rings. You need to be able to know when ionization reactions will generate aromatic anions or aromatic cations. Those ionizations or deprotonations will be fast and be able to recognize when heterocycles with nitrogen and oxygen are aromatic. So be ready when we come back on Monday we're going to do chemical reactions of benzene rings and we're going to do a lot of them.
This is the second quarter of the organic chemistry series. Topics covered include: Fundamental concepts relating to carbon compounds with emphasis on structural theory and the nature of chemical bonding, stereochemistry, reaction mechanisms, and spectroscopic, physical, and chemical properties of the principal classes of carbon compounds. This video is part of a 26-lecture undergraduate-level course titled "Organic Chemistry" taught at UC Irvine by Professor David Van Vranken. Index of Topics: 00:11- Lake Elsinore toddler bitten by rattlesnake 00:54- Antivenom 05:00- 16.13: Drawing Bridged Bicyclic Products of Diels-Alder Reactions (corrected slide) 06:25- 17.7: Huckel's Rule-Recognizing Anti-aromatic Compounds 12:43- 17.7: Recognizing Anti-aromatic Compounds 18:13- 17.8C: How Do I Know if an atom is planar? 19:05- 17.8C: Aromatic Ions 26:29- 17.8C: How Do I Know if an atom is planar, revisited 29:56- 17.8D: Aromatic Heterocycles-Which lone pairs do I count? 38:45- 17.8B: Other Aromatic Compounds
10.5446/19489 (DOI)
I stopped by the local Trader Joe's supermarket yesterday morning to pick up some water and turned around and I saw on the shelf behind the checkout stand there were some bottles of something labeled picnogeneol which I've never heard of but that to me sounds like a chemical name. If it ends in all it's some sort of an alcohol and so I immediately got interested in what is picnogeneol that they're selling to people. It says here may support healthy circulation exclamation point so what is this stuff? Turns out the picnogeneol is an extract of the bark of these pine trees called the maritime pine and the Trader Joe version of this picnogeneol is isolated from the French version of the maritime pine pine as pine aster. So I got very excited about the idea that gee maybe they're taking pine bark and extracting some useful thing out of that maybe I could make tea out of my own pine bark at home and it'll have some therapeutic benefit to that. To my disappointment it turns out that picnogeneol is not actually one chemical compound that has an IUCAC like name to it. It's actually the extract is actually a lot of different compounds dozens of different compounds. In order to label anything picnogeneol so picnogeneol is this crude extract the US pharmacopeia has laid down the law saying it has to contain these four natural products that you'll find in lots of different plants and extracts. You'll notice that two of these are very similar catechin and taxifolin. These two are not quite so similar, catechic acid and ferulic acid and the common feature of all of these is they are phenolic. They have hydroxy groups attached to benzene rings. Anytime you have a hydroxy group directly attached to a benzene ring you can expect that to have antioxidant activity. The kinds of preservatives that they put in potato chips have hydroxy groups attached to benzene rings. It's not that spectacular. There are a lot of companies that now sell picnogeneol these extracts that come from this French maritime bark. The question is does picnogeneol this bark extract really support healthy circulation? I don't know. There's actually clinical trials that have gone on many different clinical trials nothing beyond phase two which would be the gold standard of approval. Maybe it does looks like it probably does. Of course so does aspirin. So does steroids. There are lots of compounds that can improve circulation and would be related to things like heart disease, Alzheimer's disease, anything involving the brain, headaches, inflammation, menopause. It may be active towards that but there's lots of things that are active for circulation. Is this going to be the next big hit like the statin drugs that have gone a long way to cure heart disease in the United States? I'm not going to bet money on that. But very cool. The name is very cool. Okay so we have an exam coming up on Friday. So remember to be here in your seat at 7.55 so we can start at 8 a.m. because we have a very limited amount of time. You know there's a class that comes in here after us. And bring your ID for that. I've already posted your seat assignments on EEGradebook and so be ready to sit in your assigned seat. The problem set for NMR is due this evening and I've got one last little snippet to cover about or a couple last little snippets here to cover about NMR before we start on this next chapter which is radicals that I didn't quite have time to finish. So here's one important feature that I was leading up to and let me just succinctly state here that this splitting really complicates NMR and it can make NMRs of even simple, seductively simple looking compounds will have complex looking NMRs if you have multiple different types of coupling going on. So let's take an example of this dichloro-styrol compound. Don't worry about the name. It has three protons on here and what happens if they're coupling to each other with different magnitudes of coupling constants? This will create huge headaches in the NMR and we refer to these types of effects as higher order splitting. And basically I'm not going to have this on my exams. Higher order splitting. If you're taking the Chem 52 lab then you need to know about higher order splitting. If you made cyclohexanone or some sort of t-butyl cyclohexanone in the Chem 51 lab, well you weren't able to interpret all of that NMR because of this type of higher order splitting. So just to give you a sense for what's going on here, imagine taking one peak, one proton NMR peak and then having it split by some neighboring proton to give two peaks. And so if I split that peak into two peaks now it will look like this. And there's going to be some coupling constant associated with that. So I'll just measure that coupling constant. J equals 7 hertz. As it doesn't matter what the coupling constant is, I'm just trying to help you imagine what happens when a peak gets split into two peaks by some magnitude. And now let's imagine there's a second proton that is splitting this. And so now this peak could get further split. So now there's more splitting. And so now this can further be split again by an even larger magnitude. So imagine taking this pair of peaks, I don't know if I can do this with my fingers here, and splitting that pair of peaks even further to make four peaks. And so what you'll end up with is a pattern of four peaks. Here it is and now here it's split again. And I'm really exaggerating this so that you can see. So now I can go from one peak but with two different types of splitting I can create four peaks out of that. So you can still see there's that original coupling in here. But in addition to that there's a bigger coupling which I have grossly exaggerated. So that new bigger coupling there, it's more than twice as big I can tell by my eye. But just imagine it's only twice as big, 15 hertz. So this is what happens when you have two different types of coupling that aren't of the same magnitude. You can go from a singlet to a set of four peaks and what is important is that those four peaks are not a quartet. That is not a quartet. We call that a doublet of doublets. Here's a doublet of doublets down in my spectrum. Here's a doublet of doublets. And the reason I know that that's not a quartet is because a quartet has peak ratios of 1 to 3 to 3 to 1. And I don't need to see any exact integration there to tell that it's not 1 to 3 to 3 to 1. Those sets of four peaks here look closer to 1 to 1 to 1 to 1. So that's not a quartet. So every time you see four peaks even if they look like they're equally spaced it has to have that 1 to 3 to 3 to 1 ratio for you to call it a quartet Q. These are doublet of doublets. Okay, so splitting can become very complex when there's more than one type of proton. And I'm not going to put examples like that on the exam. It's important stuff for interpreting proton NMRs, the more complex structures. And enough said about that. And again, it makes proton very complex. But once you learn proton NMR it makes it very powerful to help you deduce the structure of organic molecules. Okay, so an important feature that I already mentioned of NMRs has to do with the equivalence of protons that is created by bond rotation. So one of the most common situations where you encounter that is a methyl group. So in other words all of these protons on a methyl group and on every methyl group are indistinguishable by an NMR. The H is on a methyl group are indistinguishable because I can rotate about that bond and once I rotate you can't tell which proton was which before I rotated. And so that causes all the protons on any methyl group to be indistinguishable. But remember you cannot rotate about a double bond. On the NMR time scale, on the laboratory time scale, on the time scale of your four year degree here at UCI that double bond will not rotate. That means the H that is next to cis to the bromide or sin to the bromine is never going to experience the same environment as the H that's anti to the bromine. So you have to look for double bonds. There's a potential for H's attached to double bonds to be distinguishable and to give, unless there's just some weird symmetry they'll be different if there are the two protons on one carbon of a CC double bond. So bond rotation can make things identical. Not all processes on the molecular scale are fast relative to the NMR experiment. And so this is the last thing that we'll say about NMR. So bond rotation makes things equivalent, makes the H's of methyl groups equivalent on the NMR time scale. Let me give you an example of another process that's not bond rotation that makes things equivalent. And it's kind of not important here so much for this chapter. But coming up in chapter 25 at the end of Chem 51C, this is going to be sprung on you as though, oh you knew this, but you will have forgotten it by then. And so I'm just going to tell you now and I'm telling you you're going to forget it so that when you were told you're supposed to remember it, it'll jog some neurons in there. Okay, so when you take amines like ammonia, ethylamine, that's the whole chapter 25 is all about amines. There's a lone pair that makes that pyramidal. And so when you look at that, you might think that these protons could be diastereotopic if there was some chiral center nearby or some other chiral center in the molecule. But the important thing about amines is that they rapidly invert. And again, you'll cover this in chapter 25, the idea that amines rapidly invert. And this inversion process, kind of like an umbrella flipping inside out, is so fast that those two protons will be able to effectively switch their environments. So that fast, rapid process there of having, of that flipping through amines makes protons on most amino groups indistinguishable. If you have an NH2 group, the H is on an NH2 group are indistinguishable, even if they look like their diastereotopic. So I'll just write never diastereotopic, no matter how many other stereocenters or other features are in the molecule, diastereotopic. And it's because of that fast flipping. Let's take a look at another type of process that is not bond rotation that can allow protons to switch places very rapidly. So you need to imagine this picture where we take a molecule and I'm going to do my best job here to draw a chair. And I've had years of practice, but I hope you've been practicing drawing chairs. So here's my example of a chair. And when I draw the two protons here on the right hand side, the right hand carbon of this molecule, they're not identical. One of those protons is axial and the other proton is equatorial and that's not the same. So I have an axial proton and an equatorial proton that are distinctive. These different environments, they'll couple with each other, with other protons in a different way, axial and equatorial, with different coupling constants. But because chairs flip very rapidly on the NMR timescale, in the NMR experiment what happens is you pulse this with energy and the molecule sits there and while it's sitting there waiting to emit its energy back, it will flip many hundreds of times. So I'm drawing a chair-flipped version here. So I don't know if you're good at drawing two different types of chairs, chair-flipped, but you need to flip that chair. I'm good at that because I've had lots of experience, but you should get good at that. I remember when I was an undergraduate, I used to just sit and draw a chair after chair after chair, practicing to see how good I could draw chairs. And you'd be like, what a dork. I was into that. And what I noticed is that most of my colleagues who ended up going into organic chemistry were into that kind of stuff. It turns out that well-drawn chairs help you see anti-paraplanar relationships. That's a really important skill. So now the top proton that was axial is now equatorial. And this proton that was going down that was equatorial is now axial. So that fast ring flipping causes axial and equatorial protons to rapidly exchange. So unless you have some big bulky group on here that prevents ring flipping like a t-butyl group, you can expect cyclohexanes to rapidly flip and cause the CH2, the Hs, the CH2s to exchange positions. So in other words, when I go take the spectrum of cyclohexane, I don't see the difference between axial and equatorial protons. They all look identical. Okay, the last issue of things that might prevent splitting is something I already talked about before, and that is hydrogen bonding. So as we mentioned before, you can't see any typically in most cases. So in 95% of cases, you won't see any splitting between OH protons and the protons that are on adjacent carbons. And that is simply because hydrogen bonding starts, there's so many zillions of different ways that this can hydrogen bond back and forth between acceptor atoms. So I'll just put a water molecule here. There's so many different ways that that proton can bounce back and forth with water molecules on the NMR timescale that you don't see any coupling between protons and the neighboring protons. So those are things that are fast on the NMR timescale. This proton transfer of this bond vibration of a hydrogen bond is fast on the NMR timescale. So you don't see splitting. Okay, so that's it for NMR. Again, we're not going to have high order splitting on my exams, but you should know what that is. And when you run across that, for example, when you run across a doublet of doublet, you should know, gee, that's not a quartet. There's something else going on there. Okay, so let's move on to chapter 15. It's actually, there's not a lot of, it looks like there's a lot of stuff in that chapter, but I'll show you why there's not a lot of stuff in that chapter. So we're going to talk about radicals. I mean, you can have people that are radicals that are radically different, but we're going to talk about radicals in the context of organic chemistry. And what I'm going to do is I'm going to give you a series of neutral radicals that will be common when we discuss radicals in organic chemistry so we can talk about stability. And I'm going to show you that when, if you want to have an unstable radical, let me start off by drawing this radical. This is what I would consider to be a reactive radical. It's an oxygen atom. And it's an oxygen atom that has only seven electrons. Right? It's not an alkoxide minus. There's no H on that oxygen or no R group. It's missing something. And what it's missing is the eighth electron. And oxygen is electronegative. You know that. So you can imagine how angry that oxygen atom is. That it only has seven electrons. Here's an electronegative oxygen atom. And I promise you that thing is going to pluck some sort of an atom from somewhere in order to make itself happy. Very selfish, very angry. It's going to pluck an H off of something. And we'll see some stuff like that. Okay, let's take a less electronegative atom, something that's not, what I'm going to do is I'm going to draw some radicals in terms of increasing stability. And at the high end here, this is the most reactive and least stable. So an alkoxy radical is the least stable in this series. But it is the most reactive and the most unhappy. So let's compare this to a halogen. I control chloride. It's the same idea. But I'm going to draw bromide, which is more common. It does more useful chemistry. Bromine is not as electronegative as oxygen. So you can guess it's not happy, but it's not going to be as reactive as an oxygen-based radical. And so, you know, if I compare these, oxygen-based radicals are more reactive than Cl dot. And then once again, there's only seven valence electrons with bromine. I don't want to use the term octet rule, because bromine is not in the second row. The octet rule is only for second row atoms. So you can have more than eight electrons on a bromine atom, but in this case, it wants eight valence electrons. I guess that's the important idea here. Okay, so a bromine radical is more reactive than a radical that's centered on carbon. So if I come over here and I draw a series of carbon-based radicals, let me try to draw these in black so I can be consistent here. I'm going to start by drawing three different types of carbon-based radicals. And the difference here will be whether they're primary, secondary, or tertiary. A primary radical is less stable than a secondary radical. And that's less stable than a tertiary radical. So as I go through this series of primary to secondary to tertiary, they get more and more stable. Again, the carbon doesn't have an octet. It's only got seven electrons. That can't possibly be happy, but the more alkyl groups you have, the happier that that carbon radical is going to be, the more alkyl substituents you have. And that's just like carbocation. I don't think that's that weird. Carbocation aren't happy because they only have six electrons. Attaching alkyl groups makes them happier. So it's the same idea with radicals. Tertiary radicals, there's this change in stability as we walk through this series that primary radicals are more reactive and less stable. Secondary radicals are in between. And tertiary radicals tend to look rather stable to me. Not stable enough for you to isolate. That would require some weird structure. But of those three types, tertiary radicals are the most stable. And primary radicals are actually very hard to form. Okay, the last structure I'm going to draw in this series is a rather special type of radical. It's a radical that's primary, but it's a special type of primary radical. And that would be one that has a carbon-carbon double bond next door. In other words, not where the carbon is part of a C-C double bond. That would be just insane and crazy unstable. But if this CH2 group is attached to a double bond, that is going to have extraordinary stability and we'll talk about that. So I would consider that to be a really stable radical. And we call that an allyl radical. Okay, so there's this trend. Electronegative atoms, they want eight electrons, not seven. Oxygen radicals are angry and reactive. Carbon based radicals are more stable, but it depends on how many alcohol groups are attached. And if you're going to form a carbon-based radical, then you really want to form a tertiary carbon based radical or one that's a lily. Okay, so we're going to introduce a very different type of arrow pushing for talking about radical reactions. I hate this because it's so hard to get regular arrow pushing down. The idea that just for one chapter, I'm going to introduce a single type of arrow pushing that we only use in this chapter and we never see again. That kind of kills me because I feel like pedagogically that's not a good idea. So let's take our angry oxygen radical. It really wants to have eight electrons. And let's just imagine that it bounces into a piece of your DNA. And look at that proton, not proton, that hydrogen atom there. That hydrogen atom has an electron. When oxygen-based radicals collide with your DNA, they will pluck hydrogen atoms off the DNA backbone. This is why everybody talks about free radicals and, oh, you should take antioxidants. And it's not oxygens they're worried about, it's free radicals on oxygen that they're worried about. What will happen is that this oxygen will pluck off this hydrogen atom and it will leave behind a carbon-based radical that's more stable than the original oxygen radical. The oxygen-based radical was not stable. Now that oxygen is happy. And we need some way to depict this process where the H moves from carbon to oxygen and brings with it a single electron. And we can't use the regular arrow pushing that we've been using throughout the book and will continue to use throughout the book. We need a new type of arrow pushing. And the types of arrows that we use are called fish hook arrows. So here's the way we use fish hook arrows. I'm going to take this bond here. We know that the H-C bond has to break. One of the electrons in the H-C bond goes back to carbon. And so I'll depict that with a half-headed arrow. And there it is. Notice that little half-head. It looks kind of like a fish hook upside down. So we call these fish hook arrows or half-headed arrows. You may not have noticed this, but when you do the sapling problem sets and you draw arrows for arrow pushing mechanisms, if you click on the arrow, it toggles back and forth between double-headed and single-headed. And you'll work some sapling problems where you use that feature where you click on the arrow, you just tap whatever, mouse click on the arrow, and suddenly it toggles back and forth between double-headed and single-headed. So okay, so there's a second electron in this bond. When I break that bond, I have to do something with it. What I'm going to do is I'm going to depict using a second arrow that the second electron in that bond recombines with this single electron, this unpaired electron on oxygen in order to make a new bond. So notice what happens. I don't show some arrow going from electrons and attacking proton. None of these arrows ended on a proton. This is totally different from the regular arrow pushing that I've been using before. It's an accounting device. It just is an accounting device to help me see where do the electrons go. This O dot electron and one of the electrons from this bond combined to make a new OH bond. There it is. I'll just darken it in blue here so I don't know if that's darkened it in blue so you can see. There's two electrons and here's the third electron. It's still sitting here on carbon. Okay, so that's fissure arrow pushing. And we won't use this ever again after this chapter. So I'm not a big fan of forcing you to stop and learn this new type of arrow pushing, but we're going to have to do that. And you may end up on some standardized exam at some point staring at this stuff and you'll need to know how it works. Okay, so new type of arrow pushing just for this chapter and not beyond this chapter. Yes? No, there's nothing in this chapter 15 will be on the exam. This is all for the final exam. It will be wrapped into the final exam somehow. Yeah, the exam on Friday will just cover through chapter 14, the NMR chapter. So what's that? 11, 12, 13 and 14. But that's not to say you still have to invest in our lecture today. Okay, so how can you use this reaction? Reactions of radicals turn out to be sometimes not obvious that they're occurring, but when you see mechanisms you don't understand many times those involve radicals. So let's take an example of a reaction that involves radicals. And it looks like it involves reagents that you've seen before. We're going to take bromine. You've seen that reagent before. Simple alkanes. I don't think you've seen reagents like simple alkanes before. Those generally don't react. But if we choose our conditions carefully, look at that. I just added a leaving group. Think of all the things that you can do with that now. You can do E2 eliminations, SN1 reactions, E1 elimination reactions. When we get to chapter 20 we'll show you how to make a super powerful nucleophile called a green yard reagent out of that. I can start with something that has no functional groups on it and using this simple reaction. And there's one secret key that I need to remember here. And that is we need something to make this work. Basically we need something to generate radicals. And that is energy. Here's one type of energy that you'll use. Light. You need some sort of photon source in order to get some radicals going in this reaction. And the book gives you another way to do that although this is less common and that is heat. And I'm less of a fan of showing you heat as a way to generate radicals because it looks so much like the non-radical heating stuff we've been doing in other chapters. So I'll generally choose, you know, the book says, oh use either one. I'm not sure why they tell you two different things. Why not just tell you light? Okay, so yeah, if you heated it hot enough you could get some radical stuff going on here. Okay, so it doesn't notice nowhere above the arrow does it say radical. You can't just look at the reagents and well, as soon as I see light I'm thinking radical. Okay, there's another byproduct here. You may see that I formed a new carbon-brome bond because I'm trying so hard to make a big deal out of this but I want you to notice that something else happened here and that is that I broke this carbon hydrogen bond. And in some ways that's as important as seeing the fact that I formed a new carbon-brome bond. So where did that H go? It's over here. It's in the byproduct for the reaction. The byproduct of the reaction that we generally don't care about is HBr. So there were two bromines in Br2. One went to the alkane, one went to HBr. Now hypothetically you could do the same thing with chlorine. The problem is that chlorine ends up everywhere. Right? If you take chlorine and apply the same conditions you'll end up chlorine all over the place. In this case above what I showed you is the reaction is selective for tertiary. And there's a phenomenal degree of selectivity here. And it goes like this. When you do this reaction tertiary Rh's alkyl carbon hydrogen bonds are much, much faster to react than secondary alkyl hydrogen bonds. And that's much, much faster. In fact I've never seen a case where this reaction can apply to a primary alkyl hydrogen bond. It's very selective. And in general in almost all cases you'll only use this for tertiary carbon hydrogen bonds. So you notice of all the different types of CH's in the substrate it only went after the tertiary CH. The problem with chlorine when you try to do chlorine in this reaction it reacts with every type of CH pond. Right? And since that's useless I'm not going to put it on my exams. I'm not going to discuss that. I'm not going to ask you questions about chlorination. There's no use to that because it gives you horrible mixtures of stuff. Right? Why should we spend our time? What's ironic to me is the book loves that. I don't see why it's good to ask you questions about stuff that's not useful. Okay. So bromination is useful because it's so selective for tertiary CH's. And it's going to be useful to you. Now that I've taught you how to add functional groups where there was no functional group before, you can think of all the synthesis questions I'm now going to ask you where you start with simple alkanes and then add leaving groups to them out of nowhere. Okay. Let's talk about the mechanism for that reaction. What's going on there when you add bromine and light or heat? So I'm going to draw three steps here. The three steps involved in that bromination reaction. And I'm going to start off by drawing out bromine. And the key thing is that whenever I see two electronegative atoms, oxygen, oxygen, chlorine, chlorine, bromine, bromine, with two electronegative atoms tugging on each other, those bonds are weak. And they'll have a tendency to pop apart to give two radicals. Not to give a carbocation or a cation and an anion, but to give two radicals. And let's use fish hook arrow pushing to depict that bond cleavage. And we have a certain name for this. We call this homolysis. The bond is cleaving homolytically in an even way so that each bromine gets a single electron. And that's how we depict it with that fish hook arrow pushing. And so that the products that we get out of that are two bromine radicals. Now, I call the bromine-bromine bond weak. It's not like every bromine-bromine bond is falling apart. It's only a few. You only get a tiny amount of these things in solution. So I'll just write small amounts. You only get tiny, tiny amounts of bromine radicals floating around in your reaction mixture. Okay, so what's the energy? Let me just remind you of the energy that we're using in order to create that. Light is one, and we always symbolize that with H nu. So Planck's constant times the frequency symbol nu at E equals H nu. Or the book puts or heat. I favor the light. So you'll find that when I write questions, I always write the light version because that's distinctive from anything you've seen in any other chapter. Okay, so what are these tiny amounts of Br dot doing as they float around in your reaction mixture? You've got Br dot floating around, and it's not happy. Let me just draw the seven electrons. That's not happy. Br minus is happy, but Br dot with just that unpaired electron isn't happy. And so when it comes along and it collides with an alkane-CH bond, it's going to abstract a hydrogen atom. It is going to pluck off a hydrogen atom from that carbon. And as I've drawn it, it's a tertiary CH. Those are particularly easy to pluck off. And I need to use this arrow pushing to depict that, and I already showed you how that works. I need to show how this carbon-hydrogen bond breaks. So I'm going to form a new BrH bond. I'll do that by taking one electron from here, and I'll take one electron from here that's going to form a BrH bond, and it's going to leave behind one electron on that carbon atom. And again, it's this very weird fish hook arrow pushing that you have to get used to for this chapter. There's my BrH bond. That's happy now. That's happy. Oh no. Now the carbon is unhappy. Maybe it's not quite as angry as the bromine radical was, but now we're in this situation where the carbon is not so happy. You know carbon wants to have eight electrons, and so let's take a look at the fate of this carbon-based radical. I'll redraw it again down here. And now I'll watch what happens. Now hypothetically it could bounce into another tertiary carbon H, but that would be a very slow hydrogen atom transfer. And notice how I'm avoiding calling this a proton. A proton has no electrons with it. When Br dot pulls off the H, it's bringing an electron with it, and that's a hydrogen atom. H with an electron is a hydrogen atom. Okay, so when this carbon radical runs into a Br2 molecule, not all of the Br2 homilies, only small amounts of it homilies, the rest of the bromine is just floating around as Br2. And as soon as that carbon radical bounces into a bromine, it abstracts, it pulls off a bromine atom. And I'm going to use arrow pushing, this fish hook arrow pushing, once again to depict that. So in the first reaction we abstracted a hydrogen atom, and in the second reaction this carbon radical abstracts a bromine from Br2. Most of the bromine is just floating around as Br2 and never got homilized. And the end result of this process is that it makes a carbon bromine bond. And now the carbon is happy. And what's the leftovers here? Now we're back to the Br dot. So you can see what's going to happen. The Br dot is going to come back and find another alkane. So you start with Br dot, and after two reactions you've regenerated another Br dot. And this process will continue in a chain. It's called a chain reaction over and over and over and over again. And the end result is that you're converting CH bonds into carbon bromine bonds. That's the end result of this process. And at any point in time there's only small amounts of radicals floating around in your reaction. So notice the language that I'm using. And so I'm not going to test you on this, but the language that I'm using is I call this homolysis, where I cleave a bond, where a bond just simply flops apart. That's only weak bonds that do that. Oxygen, oxygen, bromine, bromine. These two steps down here I'm using a different term that we haven't used before, and that's abstract. I abstract an atom. I abstract a hydrogen atom up above here. Here I'm abstracting another atom. The carbon radical is abstracting a bromine atom. In other words, it's taking the atom and one of the electrons from the bond. So those are very classical radical reaction verbs that we use, or lingo or descriptions that we use. Okay, these radicals that we generate. There's some stereochemical consequences that arise when we talk about making carbon based radicals. So when I, let's just imagine I'm going to take a substrate here. I'm going to try to draw this out in a way that gives me a little bit of room. What I'm going to do is I'm going to draw a chiral center. And here's my proton. There's only one tertiary proton here in this substrate. So I have this carbon atom in the center, and on it I have a methyl group going back. I have an ethyl group coming forward, and I have a propyl group, so methyl, ethyl, and propyl. So there's only one tertiary CH bond in this substrate. If I take that and I apply it to my conditions, I put in some bromine. That's a reagent. You've used lots before. And then I shine a light on that. And in our lab we have, you know, it's not a fancy light. It's a light you buy from Home Depot. So you don't have to use super fancy light with most of the common reagents. And the product of this reaction is that we replace the CH. And here's my new carbon bromine bond. And immediately I'm thinking, gosh, I really want to do some SN1 reactions with that, or an E2 elimination. All the things you can do with a tertiary carbon bromine bond. Okay, let's take a look at what's going on in this reaction. I'm not going to show how you homilize the bromine-bromine bond to generate Br dot. And I'm not going to draw, I guess I could draw, why don't I draw out this hydrogen atom abstraction just to give us even more practice with this fish hook error pushing. Here's our Br dot. It's floating around. It's looking for some choice easy proton or hydrogen atom that it can pluck off. Here's the bond. So I'll take this electron, use a fish hook arrow. I'll take one of the electrons from the CH bond. And there I go. I've depicted how I'm going to form a new BrH bond. So what do I do with the other electron that was in this carbon hydrogen bond? Well, I have to do something with that. So why don't I take that remaining electron from that CH bond and I'll deposit it on the carbon. So once again, that's the use of fish hook arrows. The point is that we make a radical here that is essentially planar. It's not perfectly planar, but it's essentially planar. So I'm going to do my best to draw this resulting radical as a planar species edge on. And so here's my radical. And here's my orbital, my empty, not empty, it's half filled. Here's this half filled orbital. And it's very P-like. It's almost like there's no significant difference between the top and the bottom face for this radical. And let me draw that one unpaired electron. I can draw it in either the top lobe or the bottom lobe. It spends 50% of its time in each lobe. I'm not going to even phase the lobe there. So the important point here is that this is essentially planar. What that means is, as I showed you before, this carbon radical isn't happy. It's going to react with BR2. So when BR2 comes along, the BR2 can collide with either the top face or the bottom face of this molecule. 50% of the time it will collide with the top face. The other 50% of the time the bromine will collide with the bottom face. And so in the end what you end up with is a mixture of products where 50% of the time the carbon bromine bond is on the top and the other 50% of the time the carbon bromine is on the bottom. And so I'll draw my fissure-carrow pushing here. So you get an equal mixture. You'll lose the, even if you started off with 100% of chirality, one stereogenic center there, you'll end up with a mixture. So here's the way, again, I'm going to show my fissure-carrow pushing. I'll take one electron from this carbon radical and I'll recombine it with one of the electrons from this bromine-bromine bond. That will make a carbon bromine bond. Notice I never showed anything attacking bromine. That's not the way fissure-carrows work. And then I'll take the second electron from that bromine-bromine bond and I'll give it to the other bromine. And that simply takes experience and practice drawing these fissure-carrows to get a feel for how they work. Okay, so because these carbon bromine radicals are essentially planar, you get this effect where it adds top or bottom with equal facility. So top or bottom of that carbon radical that's nearly planar. Now there are other reactions that involve radicals. And in particular, the book has an entire section about fluorocarbons. In fact, this is the basis of the ozone layer being very sensitive to fluorocarbons that they used to use when I was a kid in all kinds of aerosol spray cans. Our former colleague, Sherry Rowland, won the Nobel Prize for showing that this type of radical abstraction process is a problem and destroys the ozone layer. And we just don't have time to put that on my exam. Read about it. It's cool. It puts you in touch with the history of our department, but I won't test you on that. It's more stuff that's cool reading. Okay, so replacing tertiary CH bonds with bromine, super useful. You can start with no functional groups whatsoever and introduce functional groups. That's one of three important reactions in this chapter. Let me show you important reaction, well semi-important reaction number two. So you can replace tertiary CH bonds with bromine. Wow, that's powerful. Okay, here's a reaction that's not quite as powerful. And I don't know why, but the book loves this reaction. What I'm going to do is I'm going to take an alkene. Well, you've seen, you've had an entire chapter on alkenes. And I'm going to show you a reagent that we mentioned sometime in the past, but we didn't go into in much detail. It's called n-bromosuccinimid. Let me remind you of what n-bromosuccinimid is, and you don't need to remember it. I'm not going to draw the mechanisms for you. And I don't want you to try to draw the mechanism for this because you won't be able to. There's n-bromosuccinimid. Usually the n is in italics. IUPAC rules say that the n is in italics if you have to write that out. So here's our recipe. We take n-bromosuccinimid and we take light that's supposed to be h-new. I'm not doing good. It's not h-v. It's h-new. It's the Greek letter, new, equals Greek new. And we can replace, we can convert alkenes into alyl bromides. Effectively what you're doing is you're replacing one of the CHs that's next to the double bond with a carbon bromine. And so let me show you that this reaction is amazingly complex. What is this nbs for? The only reason they're using n-bromosuccinimid in this reaction is that under these conditions, under the conditions of this reaction, nbs generates very small amounts of bromine at low concentrations. So really this is a reaction of Br2, just plucking off a hydrogen atom, just like the tertiary CH substitution reaction. So why don't you just draw Br2 here? Because you know what high concentrations of Br2 do. You already know what happens if you dump Br2 in high concentrations into alkenes. They add bromine across double bonds. It would not work if you simply wrote Br2 above the arrow because you would get the dibromide. So nbs is a super secret reagent that under these conditions generates very small amounts of bromine at any point in time in the reaction mixture. And I'm not going to talk about how that happens. It's not important. The one thing I will show you is that there's all kinds of allilic carbon-hydrogen bonds here, and I'm just going to draw one of them. Well, I'll draw two of them here. And so you can imagine what would happen if a Br dot abstracted a hydrogen atom from one of these two positions here. What you would generate is a carbon-based radical that is stabilized by resonance. And so here I'm going to draw this carbon-based radical. There it is. If I pluck off one of those two hydrogen atoms, and I'll draw the other hydrogen atom there just so we can see that one of them is still there. And that radical is stabilized by resonance. Let me draw a resonance structure. And I will use arrow pushing, fish hook arrows, to depict how I get from one resonance structure to the other. So I'll take this electron and one of the electrons from this pi bond, and I'll create a new pi bond. There it is. And then with the remaining electron that was in this pi bond, I'll deposit that electron back on this carbon atom on the end. So you can see the resonance structure I'm going to create is still another allil radical. So that's why allil radicals are more stable than tertiary. And there's one H over on this side, so I'll draw it. Now this is a very carefully chosen substrate. It's carefully chosen because on the starting material when you look, there was another set of CHs on the other side that are indistinguishable from, right, those, because the substrate is so symmetrical, the CH2s on each side of the double bond are indistinguishable. And more over, it generates a radical that is also bisymmetry symmetrical. So what happens is this carbon radical will abstract a bromine from Br2 that's floating around in small concentrations in the reaction. And it doesn't matter which end you abstract a bromine atom on because bisymmetry, if I attach a bromine here, it's the same as if I attach it to bromine on the other side. You just flip the molecule over and they will look the same. This reaction, unless you use it on super symmetrical substrates, will give you lots and lots of products. And the book is not totally clear about that. It only gives you useful product mixtures if you use it on super symmetrical substrates. So I'm not a big fan of reactions that require super special substrates. So I consider this to be less useful than just replacing tertiary CHs with bromine. So that's not a very, so not quite as useful as replacing tertiary CHs. Okay, so that's the second reaction, allylic bromination. And here's the last reaction that's important in this chapter. There's three reactions that are important. Replacing tertiary CHs, second reaction is replacing allylic CHs using n-bromosic-cinimate n-bs. And here's the last reaction. So the last reaction is adding HBr across double bonds. And that may surprise you because you've done that before. Let's take an alkene. And let's take HBr. Well, you've seen that before. And the key here that should clue you in that something is different is that they write this. This is a peroxide. It has an oxygen-oxygen bond. You can see it has an oxygen-oxygen bond in there. So ROOR is the symbol for peroxide. As soon as you see ROOR, you know this is not going to be a regular HBr addition across a double bond. So you can recall from chapter 10, we did this over and over and over again. You took alkene, you added HBr, and the bromine ended up substituted at the more or ended up attached to the more substituted carbon of that double bond. What's going to happen up above when we add peroxides in this reaction is the bromine ends up at the less substituted double bond. And there's an H that gets attached here. I'll draw it for you. But just to make sure you're clear where that H went, the H ends up at the least substituted. So in the framework of Markovnikov versus Antimarkov-Selectivity, we refer to this as Antimarkov-Selectivity, Regio-Selectivity. And it all has to do with this addition of peroxides. And I think the book mentions or tries to tell you that you can just use heat or, sorry, just light for this, but really you need a peroxide initiator. So let me demystify this peroxide business for you. This is the same peroxide that they put in acne creams. It's Benzo-Wheel peroxide, oxy-10. You could take a smidgen of this paste and put it into your reaction and you would reverse the selectivity and get Antimarkovnikov. That's very powerful. It's very powerful. You know how to hydroborate and put oxygen at that least substituted double bond. But just by including peroxides in your mix here, you can reverse the selectivity of an HBr addition. Okay, so let me summarize what we did in this chapter. Again, we didn't do a whole lot, but it's this whole fish hook arrow pushing that underlies everything. I just showed you three reactions. Here they are. The first reaction I showed you is that you can replace CHs that are tertiary with bromine. It's powerful. It adds a leaving group, where there wasn't a leaving group before. I showed you that you could replace allylic CHs using N-bromosexcinimide. That's a secret reagent that generates small concentrations of bromine. Then last, I showed you if you add peroxides to your HBr additions, the bromine will add to the least substituted carbon. Those are your three reactions you need to know for this chapter. That's pretty much it. The rest of it, you can just skim through.
This is the second quarter of the organic chemistry series. Topics covered include: Fundamental concepts relating to carbon compounds with emphasis on structural theory and the nature of chemical bonding, stereochemistry, reaction mechanisms, and spectroscopic, physical, and chemical properties of the principal classes of carbon compounds. This video is part of a 26-lecture undergraduate-level course titled "Organic Chemistry" taught at UC Irvine by Professor David Van Vranken. Index of Topics: 00:17- Pycnogenol 00:42- What is Pycnogenol? 01:11- Molecular Structure of Pycnogenol 03:22- 14.8: Splitting by More than One Type of Proton 07:55- 14.9: Time Dependence of H NMR Spectroscopy-Bond Rotation 09:42- 14.9: Time Dependence of H NMR Spectroscopy CHAPTER 15- Radicals 15:37- 15.1: Radicals-Reactivity and Stability 21:04- 15.1, 15.2: Reactions of Radicals-a specialized arrow symbol 24:55- 15.3, 15.6, 15.7: Selective conversion of tertiary R-H to tertiary R-Br 29:35- 15.4: Mechanism for Radical Bromination 36:26- 15.8: Carbon radicals react on either end of the p orbital 42:15- 15.10: Allylic Bromination 48:06- 15.13: Anti-Markovinkov of HBr to H2C=CHR 50:39- Chapter 15-Radical Summary
10.5446/19488 (DOI)
I've just been a lot of buzz in the media recently about 3D printing. Not all of it good, but most of it good. I'm talking about the possibilities. This idea that maybe someday if a piece of your microwave oven breaks, you don't have to send it away. You can just make some new little part in your bedroom and then install it yourself or if the heel off your shoe breaks, you can just print out a new heel to your shoe and glue it on and you're good to go. So let's go ahead and talk just a tiny, tiny bit about this idea of 3D printing that you can have these devices. Let me see if I can pull this. How do I even do this? Let's see if I can pull this up on, may or may not be possible. So you can watch a 3D printer in action. Okay, sorry about that. Okay, sorry I didn't know about that. Okay, the sound is inconsequential. The main idea here is that gee, look at that. You can print not pieces of paper like I write my lectures on, but actual 3D objects. And as long as you can imagine each plane of this object as being what you draw on a sheet of paper, you're perfectly capable of printing out complex machine parts, anything you need. Why go to the store anymore to buy things? You can just download the instructions instead and print things for yourself. And it's amazing the complex objects that you can make. This is coming to healthcare, to a business near you. In fact, it's already there. They print out 3D models of teeth, of skulls, little pieces that you can put in the ear or implant in the human body. Now those types of three-dimensional printers or anything this cool, of course, has to involve organic chemistry and so let's come back to that. Of course. Okay, so what is this 3D printing business here? I'm going to show you the lowest tech possible. There are many varieties of ways to deposit three-dimensional materials and they are not all organic. You can also do this with metals, amazingly. I'm going to show you the cheapest version. They're just now dipping below $1,000 to buy and have your own three-dimensional printer. The fanciest ones actually create new molecules at the site of the printhead. They have little lasers that point down and create new molecules doing photochemistry. But the lowest tech models, the kind that you're likely to buy first in the near future, actually use these spools of plastic. And all they do is feed these little plastic lines. You can now have different color 3D printers to print amazing objects. They feed these little spools of plastic thread and then right there at the printhead they melt them and then deposit them on a three-dimensional surface. And sometimes they have an extra line with filler in there in case there's overhangs so that you can print easily. This filler can be easily washed away when you're done so that you leave gaps where that filler used to be. So there's two common plastics that are used in those cheap fillers for the cheap style 3D printers that you're likely to end up with in your home. And this is one of them, polylactic acid. And I think the other one is based on an acrylic acid resin. We're not going to talk about that. And this is polylactic acid. It's a very simple monomer, lactic acid. It's something that you have in the human body. And it's also a molecule that's considered a biopolymer that you can get from bacteria on a renewable basis. So we haven't talked at all about polymer chemistry, but it's this repeating unit very similar to the amino acid alanine. So if you replace that with an NH, this would be basically a polymer of alanine. But naturally occurring polymer that you can find in nature, it's a polymer that lends itself very well to this process of melting and depositing. So I'm guessing in a few years some of you guys are going to have these things in your home, in your bedroom, or office printing out objects, maybe printing out medical devices or not out of this material. So take what you learn in this class and go design some new classes of biocompatible plastics so that you can print out new parts for my human body as it degrades over the next 10 years. So I need you to work on that. OK, let's return back to NMR. I made a point that the sapling homework, we're not finishing the NMR section chapter 14 until today, so I'm extending the sapling homework for chapter 14 until Wednesday evening. We're covering probably today the most complex part of NMR spectroscopy, and it's called splitting. So I mentioned, yes? Sure, sorry, somebody asked to turn the volume up, oh. OK, maybe I could just talk louder. I'm always running the, I'm right on the edge here, feedback, so I think that's good. OK, so we're on the last part of spectroscopy, and I mentioned that there are three different things that affect the frequency which protons resonate in the proton NMR spectrum, and the single biggest effect that you will see in a proton NMR spectrum that shifts things is magnetic and isotropy. Bons that are directly attached to carbons that are part of CC double bonds and benzene rings. Remember the circulating current that gets generated in a benzene ring creates this tiny little magnetic field, and the closer I am to a CC pi bond or a benzene ring, the more I'm going to be shifted down field to seven to eight parts per million. So magnetic and isotropy is the biggest effect in proton NMR. The second biggest effect in proton NMR is being next to electronegative atoms. It's this deshielding effect. If I mix to some chlorine or fluorine or oxygen, it will suck electrons from away from me so I can see more of the magnetic field. So that's the second biggest effect. And then the last effect we're going to talk about today, and that is the effect of nearby protons. Every little proton is a tiny magnet, and because every little proton is a tiny magnet, I'll be able to see those protons that are nearby me because they either lead to a bigger magnetic field or a smaller one. So let's take an example of this effect. I feel like I'm hearing something. Let me turn that down. So proton neighbor's couple. So let's go ahead and think about this bold proton here. Maybe I can try to circle it with a different pen color or just underline it so we can see where our attention should be focused. This is going to create huge problems for you that you're always going to, it can very easily get confusing about which protons we're trying to focus on. So let's focus on this boxed, bold proton there. And consider the effects of the neighboring proton. We're interested in the resonance frequency of the boxed proton there. And it's got a neighbor. Here's this neighbor. And what I'm showing you is that this proton has two quantized choices. It's either spin up or spin down. About 50% of the molecules are spin up, and about 50% of the molecules are spin down. There's a slight population difference. If I take 6.02 times 10 to the 23rd molecules, on average, 50% of that mole of protons or molecules will have this proton with spin up, and the other 50% of those molecules will have this proton with spin down. So in other words, this proton, for half of the molecules, this proton will feel a slightly bigger magnetic field. And then for molecules like this, this proton will feel a slightly smaller magnetic field because this magnetic field here, as tiny as it is, will subtract from the NMR magnetic field. So you don't see just one peak. You see two peaks. The boxed red proton will exist as two peaks because it has two different types of neighbors. And so the important point to remember is that NMR can never, it's not sensitive enough to look at one molecule. We're looking at populations of zillions of molecules at the same time. So let's just remember that these two protons will have different chemical shifts because of that neighboring proton. Now why wasn't this a problem with carbon NMR? We never had any splitting problem with carbon NMR. Let me go ahead and draw out a typical, I guess, section of a large wax molecule for you. It's meant to be some run-of-the-mill organic molecule with lots of carbon atoms in the backbone. It doesn't matter if there are ring or it doesn't matter if there's branching here. The point is that if I take a look at a typical carbon molecule, most of the carbons are carbon 12 that have no spin. Carbon 12, carbon 12, it's the carbon 12 isotope that's the one that's common. 99 out of 100 carbons are carbon 12. It's only one out of 100, and here it is, only one out of 100 carbons will be a carbon 13. And so the chances that this carbon 13 is going to be next to another carbon 13 is so small. There's almost no chance that if you grabbed a carbon 13 that it would have a neighbor that's also a carbon 13. So there's very little chance that you'll see. So I'll just write here, no 13C neighbor. On average, that's supposed to be an H there, on average the typical C13 molecule will not have another carbon 13 neighbor. That just doesn't happen. So we never had to worry about this splitting effect with carbon 13 NMR spectroscopy. That was never an issue for us. So what a wonderful situation for carbon NMR, and that's why I started with carbon NMR. It makes the interpretation of the spectra very simple. Okay, so let's go back to this proton NMR business because it will make our lives substantially more complex and we have to deal with that. Okay so let's go ahead and talk about what happens if we have two different populations of molecules. What I want to do is I want to sketch out a tiny little spectrum up on top here and then below that I'll draw these two possible situations for a molecule where the proton has a neighbor. So I'm going to draw the same molecule twice. And so here I'll draw a molecule and we're really interested in this proton that's next to a chlorine atom just because it gives us something to focus on. And here it's got a neighboring carbon with a proton on it and then right next door I'll draw the same molecule. And then after I've drawn these two molecules in an identical way, then we'll modify them so we can pay attention to the effects of differing spin of neighboring protons. Whoops, I didn't mean for those to be H's, I meant for those to be lines. There we go. There could be H's there. Okay, so I've got two protons, they're happy little neighbors. I would describe their relationship as visceral. Remember we've talked about visceral dichlorides. They're separated by three bonds if you walk between one or the other. And let me go ahead and note that if we were to try to focus on this proton right here, then we have to wonder whether the proton that's next door is spin up or spin down. And so I'm going to arbitrary align these spins here. First of all let me draw out our magnetic field. Here's our NMR magnet. It's this huge magnetic field created by our NMR machine that's superconducting a electromagnet. And now we're wondering what the chemical shift of this proton is going to be. Whatever that chemical shift is, if it was originally the chlorine is going to deshield this proton. And so maybe the original chemical shift might be here. But when we take into account that this proton might have a chemical shift that's going either opposing or with the magnetic field, it's going to lead to two possible states. It's either going to subtract or add to the overall magnetic field. And I think I've already drawn these backwards, but don't worry about that. So in other words, I'll have two different, this proton here. Let me circle it so I can be clear which proton we're looking at. This proton that I've circled now will end up with two different chemical shifts because it's affected by its neighbor. One of the peaks will be higher by a certain amount, by a certain frequency. The other peak will then be lower by a certain frequency from the original value. And we call this difference, this change, we call that splitting. And so you can see how you end up with this doublet splitting pattern because there are two and only two possibilities here. So again, the populations aren't exactly 50% because the NMR magnet tips this. It's like 50.001% and 49.9. But you'll never see that difference just by looking at those two peaks. So that's a classic doublet splitting pattern. And for all intents and purposes, the ratios of those two peaks is one to one. So that's what causes you to see doublets in your proton NMR spectrum. And on the relative scale of the NMR, the distance between those two little peaks looks tiny, so I'm magnifying that here. I've really amplified up this spectrum. So a typical range of coupling constants, and that's the distance in here. The distance between these two peaks. We call that the coupling constant. And that coupling constant, we use the symbol J to symbolize. It's typically equal to somewhere between 1 and 15 hertz. And it is independent of the magnetic field. That coupling is caused by a proton, not by an NMR magnet machine. Because it's caused by a proton, that coupling, that difference in chemical shifts, it's totally invariant and independent of which type of NMR magnet you use. So we always characterize this splitting in hertz, not in parts per million. It's not created by the NMR magnet. It's created by a neighboring proton. So it's going to seem weird to you that we always list chemical shift in parts per million, but we list these coupling distances in hertz. But you simply have to get used to that. And I'm not sure we're going to do so much with coupling constants this quarter. That's kind of an advanced concept. OK, so let's imagine a system that has two neighboring protons. I've explained how complex it can be with one neighboring proton. Let's talk about a system with two neighboring protons. And so once again, I'm going to start off by drawing my NMR spectrum here. And let's go ahead and redraw this two carbon system. And here's the proton that we're going to discuss right here. I'll just draw it right there. And now I'm going to have to draw three different scenarios for you. So I'm going to draw three of the same molecule over and over and over again. There we go. And this has neighbors. There's going to be neighboring protons, not just one neighboring proton, but two neighboring protons. And I'm struggling to squeeze those in here. And so here's my other neighboring molecule. It's got a neighboring proton number one and a neighboring proton number two. And then over here on my third molecule, I've got a neighboring proton number one and a neighboring proton number two. And I'll show you why there's a fourth possibility that we're going to have to consider. So once again, let's imagine that we're in this huge magnetic field created by the NMR magnet. I think physicists use some sort of symbol like B naught or something to represent the strength of the magnetic field. And I'm not that sophisticated. Okay so here's our, so here's our, the proton, let me circle the proton that we're looking at. So we're really interested in what's the chemical shift of this? It's going to be affected by its neighbors. And let's take a look at the possibilities as we look at the various molecules in our collection of zillions of molecules spinning and tumbling around. What are those possibilities? So one possibility is that both of these protons have chemical shifts or sorry, have spins that both align opposite the NMR magnetic field. And so they're both subtracting in the same way. The other possibility is I have a proton that has spin up and the other proton has spin down. So in effect they'll cancel each other out. It's like that proton doesn't even have any neighboring protons because these two neighboring spins can cancel each other out. And there's two different ways you can end up with that scenario. So right below this molecule I'm going to redraw that same situation, two carbons and it has a neighbor with two protons attached. And two different ways to have that scenario and we're focusing in here on this proton that I've circled because I don't want to get all confused and look at the protons that have arrows on them. And so now when I look at these possibilities there's another way that these two protons, instead of having the top proton with spin up, maybe the top proton could have spin down. And then if this neighboring one on the side here has spin up, that's another way that they could cancel out. So there's two equally probable ways in which the neighboring protons can cancel each other out with their spins, with their quantized spins that can only be up or down. And then the last possibility is that both of these protons will have, instead of both protons with spin down, will have spin up. And so now adding to the magnetic field of the magnet. So three possibilities and they're not equal, the middle possibility where the two protons cancel each other out is twice as likely as the two scenarios on the end. So what I'll end up with is three peaks in my NMR spectrum and those three peaks will now look like this. So the circled pink proton here, instead of looking like one peak, will look like, let me just draw a little midline here so I could see what that pink proton would look like if there was no neighboring proton. So one possibility is that these two protons are subtracting, one possibility is that these two protons are significantly adding, and then the middle possibility is that they're canceling each other out. And the ratios of those peaks will be one to two to one. Maybe I didn't do a good job of drawing them where they look like they have that peak area. So that's a classical triplet. And I know it's a triplet because the ratio of peak areas is one to two to one. And it's caused by these neighboring protons. And we characterize this splitting, the magnitude of this splitting with, once again, with this variable J or coupling constant. So if you wanted to measure the coupling constant there, the effect of this neighboring proton, you'd measure either from the outer peak to the big inner peak or from the big inner peak to the far outer peak there. And again, that's going to be some coupling constant J that's measured in hertz. Okay, you can have more neighbors than two neighboring protons, right? You can have lots of neighboring protons. So you can imagine how this complexity can build up very rapidly. To take one simple signal, this one pink proton can be split into seven, eight peaks. No problem. You'll find lots of spectra where a single proton gets split into many peaks. Yes? What does J tell you and how can you use that? I'm peering ahead here to rock. I can't remember whether I talk. It tells you a lot, actually. Well, I'll just tell you. It tells you one of two things. If you're coupled to a proton on the same, so the question is, what does J tell you? So if you're coupled, and we're not going to go into this detail, you don't need to worry about using this information, J is the magnitude of J depends on two things. If you're two protons coupled on the same carbon atom, you're coupled to each other. You're feeling each other's magnetic field, the angle between these two protons controls J. So if you're clever, you can use J to learn something about the angle between these two protons. If you're on two protons that are on neighboring carbons and you're affecting each other's magnetic field, it's the torsion angle between those two protons, like this. You get maximum coupling when the two protons are anti-paraplanar or syn-paraplanar. You get zero coupling if they're orthogonal in 90-degree torsion angles. So if you take an advanced class in spectroscopy, you'll use that coupling constant information to learn about torsion angle and the shape of your molecule. And you won't do that in this class. Too advanced. It's so hard just to get a grasp on simple coupling patterns that you won't be able to – well, I say that. Maybe you will. It would be awesome if you guys could start taking that stuff into account. Okay, so let's go ahead and talk about various common arrangements of protons. What do you expect when are protons close enough to affect each other? So here's – I'll give you three coupling scenarios. So one common coupling scenario is two protons on the same carbon. And these couplings are typically around 15 hertz, but as I just told you, it depends on the angle between those two protons. So in other words, that's – to me, that looks like a big coupling. It's a coupling where you can see right through those peaks on the NMR spectrum. Sometimes the little peaks are so close, you can't even tell that there's two peaks there. It's hard to tell. Okay, that's one coupling scenario where they're close enough to couple. The second coupling scenario is where they're on neighboring carbons. We would call that visceral coupling. And if I count how many bonds between these two protons, there's one, two, three bonds. So that's a three-bond coupling. And this varies hugely depending on the torsion angle. So three to 12 hertz. So in other words, at best, it's almost as big as a geminal coupling, a two-bond coupling. But at worst, it's almost zero. So it can be very small and hard to see that coupling. So I typically would call this a two-bond coupling or a geminal coupling. And I would typically call this a three-bond coupling. So if you hear me refer to that. There's a third type of coupling. And it's rare and it's small. And I don't think I would ask you or expect you to know this one, but you might see it in some NMR spectra and wonder why is that there. So when you have protons separated not by three bonds, but by four bonds, in this arrangement where it has the shape of a W, some people call this W coupling, you can sometimes see a small coupling. And it's small. It's not like 15 hertz, I meant to draw this in black. It's not like 15 hertz. It's not like 12 hertz. It's usually less than two. So when you got this sort of W shape, those two protons can couple to each other. Five bonds, no, you don't worry about that. And so let me just say that this four-bond coupling is rare, but you might see it. I don't think I would purposely give you a spectrum that had four-bond coupling in it. I feel like I might have seen that in some of the lab spectra, but I'm not sure. So mainly, you just worrying about two bond and three bond couplings, you're going to find that proton NMR is this difficult to use spectroscopy at first. It will take time for you to acclimate to that. Okay, so we measure coupling constant. We assign it the variable J, and it's not like you do any math with that, but if I say J value, you'll know I'm talking about a coupling constant. And you can have different magnitudes. Sometimes easy to see two peaks, sometimes the coupling constant is so small it almost looks like one peak. Okay, so when will you see coupling and when will you not see coupling? There's some key rules to remind you of. Equivalent protons don't split each other. Wow. We don't need to go into the profound nature of that. The point is equivalent protons don't split. So here's an example of a situation where magnetically equivalent protons, protons that have exactly the same chemical shift, don't split each other. So if I look at this molecule, these two protons are identical as far as the NMR is concerned. They'll exist as one peak, and they don't split each other. You don't see any splitting by those two protons, even though they are on neighboring carbons. So no splitting here. Actually, that's not the most common case where you see no splitting. The most common case where you see no splitting is a methyl group. In every case, the protons on a methyl group are equivalent. So these always show as a 3H singlet whenever you have a methyl group. So that, 3H, and watch this, I'm going to write the letter S there to mean singlet. They don't split. They're equivalent. So whenever you see a 3H singlet, usually a towering peak in your NMR, that's usually, I can't think of any case where that's not a methyl group, but maybe I could design one in theory. So here's a case. These two protons here, those two protons are an anti-otopic. There's no difference between those in a proton NMR spectrum. They don't split each other. So let me just go ahead and write that here. These two protons don't split. These two protons here, they don't split. And these two protons here, or actually this group of protons here, they don't split each other. But what I want to do is talk about this proton over here, the OH. Hydrogen bonded protons don't spend all their time attached to one atom very well. They kind of hydrogen bond to this group over here, and then they're attached to me, and then they hydrogen bond, and then they're attached to me. On the time scale of the NMR experiment, after you pulse with energy, that proton is moving back and forth hydrogen bonding with lots of other stuff in solution before I finally give my energy back. And as a result, what you find is that H-bonded protons almost never split their neighbors. And I say almost never. In no case in this class would I give you a spectrum, because it would be weird, where the OH, which is capable of hydrogen bonding, would split the neighboring protons. So the NMR spectrum for this would have these two appear, because they're identical. They don't split each other. These would exist as one peak, a singlet, at 4.5 parts per million. In other words, they're not being split by the OH. That's because OHs will be hydrogen bonding with other molecules just like itself in solution. And this OH over here would exist as one peak, not split by the two Hs nearby, at 3.2 parts per million. So you have to look out for Hs attached to heteroatoms, because those are good at hydrogen bonding. Yes, question? Why these split? Why these split? Oh, that's only, yeah, I didn't draw the rest of the molecule. The rest of the molecule has to have stereogenic centers. But these are chemically inequivalent. It depends on what's attached here. If as I showed you here, it's a bromine and a chlorine, well then they won't split each other. I just told you. So it depends on what else is attached here. So maybe you'd like an example of a geminal compound that would have, here's an example of a geminal pair of protons that would split each other. Here's a ring, here's a chlorine on the bottom, and a t-butyl group equatorial. These two Hs are now non-equivalent. One H is on the same face as the chlorine, the other H is on the same face as the chlorine. One H is on the same face as the t-butyl group. And those two Hs are now chemically different, and they will split each other. So I didn't draw the rest of this molecule. It depends on what's attached. Okay, so yeah, let's go on and keep talking about this splitting thing. Yes? Say again? So we talked about this issue of anantiotopic and diastereotopic protons. Antiotopic protons are magnetically equivalent. They give identical chemical shifts by NMR. The NMR experiment cannot distinguish between anantiotopic protons. So because these two protons are anantiotopic, they occur with exactly the same chemical shift and so they don't affect each other. And I mean, I'm not, we can't go into the origin of that effect right here. We need to move on for the, they just don't split each other. Equivalent protons do not split each other. They have exactly the same chemical shift. And thank you for asking those questions because everybody is, even if I'm not ready to go into the details behind that, that means everybody else is wondering the same thing. This tiny little effect that I saved for last, right, we've covered 90% of NMR, but this tiny little effect of splitting is what makes proton NMR so challenging. And we'll create most of the work for you in terms of interpretation. Okay so let's talk about this simple N plus 1 splitting rule. You don't need to draw out these diagrams with proton neighbor spin up and proton neighbor spin down. It's far simpler to analyze splitting patterns just by using an empirical rule called the N plus 1 splitting rule. So the rule is very simple. It says N equivalent neighboring protons give N plus 1 peaks. So N equivalent neighboring, so here's an example where I'm drawing a 3 carbon system and I'm not drawing what the neighboring groups are. What I'm simply doing is I'm simply telling you that there are no protons here, no protons here, no protons here, no protons there. In this situation where there are no neighboring protons, two bonds, three bonds or four bonds away, this would appear as a singlet. So the number of neighbors here, let's just write number of neighbors that are two, three or four bonds away here is zero. So according to the N plus 1 rule, zero plus 1, that should appear as a single peak, a singlet. So let me sketch that out. Zero neighbors, N plus 1, it'll appear as one peak. And we call that a singlet. But now let's take a look at an alternative scenario where there's a single neighboring proton. And who cares what the other groups are? Chlorines, bromines, maybe it's part of a double bond, carbon atoms. I'm not going to draw any of the other neighboring atoms. We don't care about those. I'm simply telling you that in this scenario there's one neighboring proton that's either two, three or four bonds away like this. And so the N plus 1 rule says one plus 1, N plus 1, if there's N neighbors, one neighbor, then I ought to see this appear, this proton appear as a doublet, two peaks. And I didn't do a good job because the area would be half of each peak, but they would add up to as much area as one tall peak here. So I wish I had drawn that shorter. And of course we would call this a doublet. That's our sort of nomenclature here. So now we're going to take the scenario where we have this proton, we're looking at this proton here, and now it's got two neighboring protons that are either two, two bonds away, three bonds away. And so now with those two neighboring protons, the N plus 1 rule says two plus 1, it ought to appear as a triplet. And I don't need to draw any fancy diagrams, I just need to look at how it count up the neighbors and say oh, triplet. And remember the peak ratios I told you for a triplet, it's one to two to one. And if I didn't draw that peak area ratio correctly, then I'm not drawing a correct triplet. And you could go on inventing scenarios where you had three neighbors, et cetera. Okay, so you don't need, so the N plus 1 rule predicts whether you'll get a singlet, doublet, or triplet. Importantly, the peak areas are predicted by something called Pascal's Triangle, which I think you get from some sort of binomial expansion mathematics. Pascal's Triangle, you could recreate that simply by adding one plus one equals, one plus one equals two, and one plus two equals three, and one plus three equals four. So there's some simple addition you can do between each neighboring pair of numbers that gives you the next row of numbers. So what this does, what Pascal's Triangle does is it predicts for you the peak intensities for all the common splitting patterns. Yes? Say again? For this scenario? Yeah, I didn't draw. So let me just invent a scenario where it has nothing else there so that you're not. So it seems weird that I didn't take the time to draw anything here. I just didn't want to, here's what I didn't want to do. If I draw extra stuff here, it becomes so complex. Here's two chlorines, here's a bromine, here's another, right? I just didn't want it to look too busy. So the intent was that there weren't any other protons there, and I was afraid to draw extra atoms because I thought it would look too complex. So you just have to imagine a scenario where there were no extra protons as neighbors. Okay, so let's go ahead and talk about these peak area intensities. For a singlet, you don't need to worry about whether it's one to two to one ratio. A singlet exists as a single peak. And I'm not going to write the word singlet anywhere on any spectrum. I'm simply going to write S, and that's meant to understand that that peak is a singlet and not two peaks that are close to each other. When you see two peaks, tiny peaks in a one to one ratio, that could be a doublet. And I'll symbolize that with the letter D. And the two peaks will of course be close to a one to one ratio. And if you see three peaks, if it really is a triplet, we would symbolize that with the letter T. And those peaks for the statistical reasons I showed you should appear in a one to two to one ratio. And then finally, well not finally, a quartet. So you see how the language works. We symbolize with the letter Q. Those will exist. The peaks will appear in a one to three to three to one ratio. If they are not approximately one to three to three to one, then I would worry that maybe that's not a regular, and you can keep going all the way down to a septet or with seven peaks or more. So finally you'll get to some scenarios where there's so much splitting and so much coupling going on that you simply can't interpret it. And that's very common. And quite often we simply just throw up our hands and say that's a multiplet. I don't know how many peaks are in there. I can't even see between the peaks. They're so crowded. And we symbolize that with an M. And that means I've given up trying to assign how many peaks are actually in that little forest of peaks there. Yes? Why? How is it that the area under the curves are equal? Because in this scenario, this is all due to a single proton. So the area under here has to equal the signal given off by a single proton. And so here this is given off by a single proton. So in other words, a singlet might have an intensity that looks like this, but a quartet, even though the area adds up to the same, will look smaller, but if you add up the area it would be exactly identical because it would arise from a single proton in the spectrum. OK, so let's go ahead and take a look at a real spectrum that is splitting. And I think this came right out of the Gorgzinski-Smith textbook. It's dichloroethane. And this is quite common. So if I look at the spectrum in the blue background here at this peak that's located around 5.9 parts per million, it's kind of hard to tell what's going on there. The peaks are so scrunched together. So quite often, if somebody doesn't tell you how many peaks are there, they might give you an expansion. So see how they've expanded it here so you can now see. Ah, I see four peaks. And look how satisfying that is. They're present in a 1 to 3 to 3 to 1 ratio. That's a quartet. That's not just four peaks that happen to be close together. I bet money that that's a quartet. Oh, I know it's a quartet here. And then here's this other peak where you can't quite tell by looking at the blue tiny spectrum is that one peak or two peaks close together? But when they give you the expansion you can see daylight between those two peaks. That's definitely two peaks and not one peak. So two peaks that are close together. And those two peaks are a doublet pretty clearly. The peaks aren't exactly the same height, but it's pretty close to 1 to 1. So you see these peak ratios for quartet 1 to 3 to 3 to 1 and for a doublet 1 to 1 ratios. So what's going on here? So the proton that's appearing farthest downfield at 5.9 parts per million, is it the red protons or is it the green protons that are appearing here at 5.9? It's the green proton that's closest to the, these, these electronegated chlorine atoms are deshielding that proton, sort of sucking electron density from around it. So that's the proton here that's, that's appearing at 5.9 parts per million. And so why is it appearing as a quartet? The reason that's appearing as a quartet is because, is because red protons are splitting that and there's three of these red protons. And according to the N plus 1 rule, so let's look at the N plus 1 rule, 3 plus 1 equals quartet, we could have predicted that. This green proton is the farthest downfield and it's being split into a quartet and you could have predicted what this spectrum would look like ahead of time. Okay, let's come over and look at the CH3 group. If I look at the integration, there's this lame integration line here, if I took out a ruler and I'd measured, that would correspond to some sort of area under the integration line and whatever, however far up I go with my integration line, it's, it's three times higher than I went up with this first one. So that corresponds to the fact that the area under these two peaks is three times bigger than the area under these four peaks. And that, that methyl group is not shifted as far downfield, this carbon is now one carbon further away from those two chlorine atoms. So those protons aren't de-shielded anywhere near as much. And why is that split into two peaks as a doublet? It's split into two peaks as a doublet because this little proton over here, that's one proton and N plus one rule says one plus one equals two or doublet. So again, the N plus one rule predicts for you this sort of splitting pattern, singlet, doublet, triplet when you look at an NMR spectrum. Okay, let's take a look at another example that has splitting. And again, this is, I think this is a figure that came out of the book, I can't remember where I got this. Okay, so now we have a compound that's highly symmetrical. And the reason I'm showing you this is I wanted to point out that the protons that are, the protons that are splitting don't have to be attached to the same carbon. So these two protons that are next to, that are on carbon next to bromine, there's four of them. And they are indistinguishable and identical. The protons on the left-hand side of the molecule that are on carbon attached to bromine are indistinguishable from the carbons on the right-hand side of the molecule that are attached to bromine. So all four of these protons, I expect to appear as a single signal, maybe not one peak, but they'll all have the same intrinsic chemical shift before you split them. And so, since those are closer to bromine than the protons in the middle of the molecule, I expect these four protons to be shifted far this downfield. And here they are at about three and a half parts per million. And very nicely there's an inset for you that allows you to see those four protons. So here's my signal, it's 4H, it's a 4H signal, there's four protons in there. These are protons B. And they're being affected by their neighbor, the CH2 group. There's two protons there. The N plus 1 rule tells us that these will split. These protons here will split this 4H signal into 2 plus 1 equals triplet. It's amazing. So until these four protons aren't all attached to the same carbon, they still are affected by this neighbor in the same way following the N plus 1 rule. So I would call that a 4H triplet. That's the way you would abbreviate that in an NMR spectrum. 4H comma italics T. We use italics for singlet, doublet, triplet. So now let's walk over here to the CH2 group that's in the middle of the molecule and think about that. And you can see that signal down here at 2.3 parts per million. So when we think about what kind of splitting pattern we expect to see, if we look over here there's a set of peaks at the expansion. One, two, three, four, five. Five peaks, it's a pentet. And so what's happening here is that these four neighboring protons, whoops, maybe I should use it, well I've already started to use the black pen here. These four neighboring protons split this into 4 plus 1 equals pentet. And if I think about the integration there, it should be a 2H comma pentet. That's very unusual actually to see a pentet. But it would be italics P. So often times people won't, I won't show you the inset. I'll simply write 2H comma P. 2H means you don't have to look at the integration line. You know any protons are there. And italics P means you don't have to count up the peaks to know that that's an actual pentet. Okay, let's go ahead and talk about some very, oh it looks like I was ready to talk about some variations in the magnitude of coupling and splitting. Okay so the coupling, as I already mentioned, the coupling constant depends on angles. So the actual angle here between two geminal protons will cause the coupling constant not to be 15 hertz, that's kind of an average number, but to vary between 12 to 18 hertz. So 18 hertz is a pretty big coupling. But there's an exception to that. Well maybe not an exception, but if you really stretch this angle out to 120 degrees, so that's what you, that's the angles that you have for substituents on an sp2 hybridized carbon, 120 degrees. And 109 for sp3 hybridized carbon, but when you really expand that angle out, the coupling starts to get very small. So you can see here for the two H's at the end of a C-C double bond, sometimes it's very hard to see any coupling at all. So the angle matters a lot. So be careful before you say that, before you claim that there's no coupling there, because it might simply be a CH2 at the end of a C-C double bond. So for visceral protons, the maximum coupling you'll ever see is when two protons are anti-periplanar to each other, that can be up to 18 hertz in value. When the two protons are sin, they'll be a little bit smaller. A very typical coupling constant, like the ones you saw in that last spectrum, the sort of distance between peaks has to do with rotatable bonds. So a most typical range for coupling constants that you would see, when you see splitting patterns between those tiny splitting patterns between peaks is about 5 to 7 hertz. 7 hertz is probably the most common average coupling constant you'll ever see for rotatable bonds. Now I don't believe I'm going to show you any spectra that involved, that involved you analyzing those different coupling patterns. So don't worry about that. Okay, sounds like everybody's picking up to go. That means we haven't finished the proton in a month and I'll try to finish up the last bit on Wednesday. But try to do is, you should be able to do almost all of the problems in the sapling homework based on the stuff that you've got right now.
This is the second quarter of the organic chemistry series. Topics covered include: Fundamental concepts relating to carbon compounds with emphasis on structural theory and the nature of chemical bonding, stereochemistry, reaction mechanisms, and spectroscopic, physical, and chemical properties of the principal classes of carbon compounds. This video is part of a 26-lecture undergraduate-level course titled "Organic Chemistry" taught at UC Irvine by Professor David Van Vranken. Index of Topics: 00:38- The possibilities of 3D printing 01:02- 3D home printer 02:23- Meltable Polymers for Low-Cost 3D Printing 04:57- 14.6: Coupling between nuclei leads to splitting of peaks 11:28- 14.6A,B: Analysis of Doublet and Triplet Splitting Patterns 23:00- 14.6C: Splitting Rules 32:02- 14.6C: The n+1 Splitting Rule 39:35- Splitting Example #1 43:25- 14.7: Example-Two types of Protons 46:59- 14.8: Variations in the Magnitude of Splitting
10.5446/19486 (DOI)
So the president of the United States just announced a major new scientific initiative, kind of on the scale of the Human Genome Project, which has been so far the largest initiative and greatest scientific achievement of my lifetime is to see the human genome sequence. And this new initiative, it's going to divert huge resources from the scientific community to this important project. The goal is to map the human brain, to map the function of the human brain, the pathways within the human brain, pathways that lead to diseases like schizophrenia, depression, memory, or associated with Alzheimer's. And so that's the goal. It's ultimately to create some sort of a map like this that allows us to see the pathways that lead to diseases or make people smart or have effects like that. So as I looked at all the news articles that were pouring out about this, it made me wonder, what would it take to see inside the brain? Now ultimately, the picture that is developed will come from different new imaging methods that allow you to see inside the brain and probably a lot of modeling, computer modeling, to put those pieces of information together. And so let's talk about what it would take to look inside the human body and see something going on. And so I thought I'd put together, just on one diagram, a picture to help you see what does it mean to see inside a human tissue? So of course, if you wanted to see inside of my arm, you couldn't see inside my arm. All you see is skin and flesh. That's because my skin is not transparent to light. The light bounces right off as reflected, and so you can't see what's going on inside. And so if you look at the different types of spectroscopy that we've been talking about in this class, you also, and in Chem 1, general chemistry, you spent a great deal of time in general chemistry using UV-Vis spectroscopy. You did things with Beer's Law. Well, Beer's Law still applies to IR and other types of spectroscopy. You put solutions in little quivets, and you measured how much light that was absorbed. If I stretch out the electromagnetic spectrum, and this is just a small fraction of the electromagnetic spectrum, you can see that starting down here at about 200 to 800, that's where you did UV-Vis spectroscopy as a freshman taking some sort of a first-year chemistry class. And there's a lot of stuff that absorbs. You never did any spectroscopy in a UV-Vis below 200, because even water absorbs pretty strongly there. You were typically doing UV-Vis spectroscopy in this region where you could see organic compounds. So water absorbs strongly there. We're not going to see anything in the brain below 200 nanometers. The water would simply absorb all the light. From 200 to 800 nanometers that UV-Vis range, you still can't use light very effectively, a little bit, but not very effectively to see inside the brain. So the first problem is your skin contains a material called melanin that is very good at absorbing light. Light never passes through my skin. That's the purpose of the melanin in the skin. That's what makes skin have brownish hues associated with it. So all this melanin absorbs light very effectively at every single wavelength pretty much. And even if you stripped off my skin, or stuck some sort of probe underneath my skin, the problem is that there's blood in there, and blood contains hemoglobin that's probably the most prominent chromophore. At some wavelengths, it's much more strongly absorbing than others. And of course, that's red. And it's a strong absorber. And so you have lots of blood that will also prevent you from visualizing. We've also talked in this class about IR spectroscopy, and that's way out over here. And you notice I'm using two different units. UV-Vis spectroscopists use nanometers to measure wavelengths. And you might recall, we measure IR spectra using frequency, using this inverse centimeters, wave numbers, types of units. And I've kind of plotted with those units here so you can see how that fits in with UV-Vis spectroscopy. And all kinds of stuff, especially water, absorbs in this region. That's why we never take IR spectra in water. We never use water as a solvent for IR spectroscopy, because it would absorb too much light. And down here in this region, between UV-Vis and between IR spectroscopy, this is called the near IR region. And if you look here in this little valley, this region right here is the most transparent region of the spectrum. Typical organic compounds don't absorb in that region. And so if you could design small molecule probes that absorb, you could see where those probes are inside the human body. If you were a jellyfish, or sorry, if you had some sort of special viewing ability, you could see in this region that has the best transparency where few things absorb. If you could see at those wavelengths, I would look like a jellyfish to you. I would be transparent. The light would pass inside, go right through me. You could stand on the other side. So chemists are actively now trying to design organic molecules that absorb light effectively in this region. Because you could use those as probes and tags to put inside the brain, to put inside the body, and watch where they're going, and the light would pass right through human tissue very effectively. So this was during your first year of general chemistry. Now we're talking about IR spectroscopy. And now we're totally going to switch gears and talk about a completely different type of spectroscopy in the class. Wow. Okay. I don't know how to turn that down, unfortunately. That was fantastic. You're listening to an organic molecule right now. This is an NMR. So when I was a graduate student and I used to take NMRs, I don't know if that's going to continue. I used to always run the NMR spectrometer with a little speaker on so I could hear my molecules each time. And I'll explain what that little post was about just momentarily. So I apologize for the volume on there, but maybe that'll help us wake up this morning. Okay. So chapter 14, we're starting a new type of spectroscopy. We spent a little time talking about spectrometry. And then we spent a whole lecture talking about IR spectroscopy. And hopefully you've been working all the problems in that chapter on IR spectroscopy. And now I want to talk about nuclear magnetic resonance spectroscopy. The fundamental idea here is the basis for MRI imaging, for magnetic resonance imaging. The word nuclear is in here. It has nothing to do with nuclear power or radiation, the kinds of radiation that come from nuclear power plants or nuclear bombs. This is based on radio frequency energy. Okay. So I want to start off by talking about what are we going to see if we use nuclear magnetic resonance spectroscopy. And what you see are atoms and a specific property of atoms. And let's talk about what's required. In order to be able to see things with an NMR spectrometer, there's a fundamental requirement that those atoms must have a property called nuclear spin. And that's not a particular property of elements. It is a particular property of isotopes. So if I take an individual element such as a hydrogen atom, there's multiple different isotopes. There's protons. There's deuterium. There's tritium. And they're not all visible by NMR. So in order to be visible by NMR, you have to have a property called spin. A particular isotope has to have a property called spin. And if you've got spin, there is a quantum number associated with you that will be nonzero. And so in order to see things, elements by NMR, to see isotopes by NMR, you have to have a nonzero spin quantum number. And the origin of that spin is because a spinning nucleus is like a tiny magnet. And so it has magnetic properties. When you put two nuclei that have spin together, those two tiny magnets can interact. When you put a nucleus with spin in a big magnetic field, it will interact with the magnetic field. So if we look at the common isotopes on organic molecules, carbon, hydrogen, nitrogen, oxygen, hydrogen, yes? I wouldn't call them diamagnetic. Maybe paramagnetic would be a better, I'm not even sure, not enough of a physicist to answer whether paramagnetism is a good description of a nucleus. But it wouldn't be diamagnetic. That's for sure. So protons, the typical Hs that you see attached to our organic molecules, those do have nuclear spin. And there's a specific spin quantum number associated with that one half, totally inconsequential to you. You don't need to worry about what the spin quantum number is for a proton. And most of the Hs that you see attached to carbon, 99.98% of Hs attached to carbon atoms in your body, in biology, in the floor, everywhere, those are protons with no neutron in the nucleus. So you can very easily see those by NMR. And so that's the most common form of NMR that's used today is proton NMR. And that's what we're seeing. Now a very small fraction of the Hs that are attached to the molecules in your body are deuteriums. They have one extra neutron in the nucleus. Chemically they behave exactly like protons. All the reactions that you see, if you switch to proton with a deuterium, the reactions would work in the same way. So the problem is that deuterium is not very abundant. And so because deuterium is not very abundant, you could see them by NMR if you jacked up the power on the NMR to see that tiny amount of deuterium in there. But it's very infrequent. So generally you don't worry about seeing deuterium by NMR. You could if you wanted to. Okay, carbon. You can't see the most common isotope of carbon. That's carbon 12. So if I look at all the organic molecules in your body, glucose, glyceraldehyde 3-phosphate, glucose 6-phosphate, citric acid, most of the carbons are totally invisible by NMR. You can't see them by NMR. Their nuclei don't have this property of spin. But there is an isotope of carbon that you can see by NMR that does have spin. And that's carbon 13. And the problem there once again, although not to the extent of deuterium, is that it's not quite as abundant. Only one out of every 100 carbons is a C13. All the rest are carbon 12. They react the same. They do all the same reactions. You can't distinguish them by doing some kind of chemistry. So you can do NMR. It's not as sensitive. Let me put two checks here near proton because it's so sensitive. You can do carbon NMR. But you've got to again jack up the power in order to see the tiny amounts of carbon that are there. Because on average so few carbons are actually C13. And all these other elements that are important, well I guess there's only two other ones that have principal importance. That's oxygen 16 and nitrogen. Those are not N14. Those are not NMR active. So we're not going to look at oxygen. You couldn't even see them. You can't see the oxygens and nitrogens on molecules by NMR. All we're going to see are carbons and hydrogens. So for the next two, three lectures, we're going to talk about proton NMR and carbon NMR. Those are the types of NMR that are useful to chemists. Oh yes. Sorry. Thank you for clarifying that. Yeah, I meant to put a scratch through there. So nitrogen, invisible, oxygen, invisible. Even if you can have 50 oxygens on a molecule totally invisible by NMR. Okay, I've shown you a picture here of an NMR spectrometer. In the basement over here of Reines Hall, we've got a huge room with three, four big spectrometers, much larger than this one. This is a smaller spectrometer. And inside of this, the spectrometer is basically a big tank. And inside that tank, there's liquid nitrogen that's extremely cold. I don't remember the temperature, something like minus 200 degrees. And inside that liquid nitrogen, there is liquid helium, 4 degrees Kelvin. And the liquid helium is used to cool down this superconducting copper coil right there. That's a bundle of copper wire. And they start this electricity running through that coil of copper wire and then take the electricity away. And because it's so cold, the copper is superconducting. The electrons will flow infinitely in that, around that tube creating a superconducting magnetic field. So whenever you have a current running through a coiled wire, it creates a magnetic field. And I've drawn the magnetic field lines for you here so you can get a sense that right through the center of this NMR magnet, you've got this super-duper, duper massive magnetic field. Over each of our NMRs, we've got these planters out in the area between the building so you don't drive your car over there and disturb the field or walk over that with your pacemaker and end up dying. So if you want to know where our NMR magnets are, they're right below those planters in front of Reines Hall. Okay, so that's an NMR spectrometer. And normally they're not cut open. This guy's, I'm not sure why he cut that open. It must be broken in some way. So I brought with you a picture of a tube with an NMR sample. So this is the way we put our samples inside that NMR magnet. And you can see here there's a little bit of liquid in here. And it's got a deuterated solvent in there. And we drop that sample down the center of this tube and it sits on a cushion of air that keeps it right in the center where the magnetic field is super powerful. So that's the way we do NMR. You dissolve some of your sample, you put it in a tube, you drop it down the center of the NMR magnet. And then it sits there in the magnetic field. Now you can't use just any old solvent to do NMR. And I don't know if you can see this because it's not focused very well. We have special solvents. And what this is so, I can't even see if this is focused. But if I try to focus on this bottle, what you'd be able to read right here is that this is chloroform D. There's no protons. This is chloroform C HCl3. They've taken off the H and they put on a deuterium. You don't want to put a solvent with protons in an NMR magnet because then all the protons in the solvent will absorb all the signal. So we use deuterated solvents with deuteriums for NMR, almost exclusively. Okay, so that's NMR. It's a big magnet. So somebody's asked how much the NMR costs and it depends on what size you're buying. How much does a car cost? It depends on what car you buy. And generally it's the size of the magnetic field that makes all the difference. So they can cost anywhere from $100,000 for a superconducting NMR to $2 million, depending on the size. So we have a multi-million NMR magnet over on the side of natural sciences 1 that's vastly bigger than the ones we have over here near Rhinus Hall. That's used for looking at things like proteins. Okay, so what's going on inside that's deep inside that NMR magnet when you drop your sample in? Okay, so you drop your sample inside of that NMR magnet and there's this massive, massive magnetic field. And you need a massive magnetic field. That's absolutely essential for the experiment. So inside that supermassive magnetic field, the whole point. So let's just imagine that we have this supermassive magnetic field and I'm symbolizing that with this shaded arrow here labeled NMR magnetic field. So surrounding your molecules on both, on every side, they're sitting in this superpowerful magnetic field. And I already told you that a proton is like a tiny magnet. That proton knows one of two things. It is either aligned with the magnetic field or it is misaligned with the magnetic field. Those are two distinct choices and they are quantized choices. It doesn't matter if they're sideways or left or right, there's two choices aligned or not aligned. And one of those is better than the other. It is better to be aligned with the magnetic field and I'll just write aligned with. If you're aligned with the magnetic field, you're happy as a tiny little proton magnet. That's a good state to be in. It's an energetically stable state. But the alternative is that you can be aligned against the magnetic field. And again, this is where quantization of states is so mind bending. It's like, what happens if they're halfway aligned? No, no, don't go there. It's quantized. You're aligned with or you're aligned against. Those are the only two choices. And the more powerful your magnetic field is, the more stark those two choices are. So we always try to have the most powerful magnetic fields possible. So there's a good state that's stable, that's aligned with the field. And then there's this other state that is not as stable, that's higher in energy where you're aligned against the magnetic field. And the point is that you can transition between these two things with energy. So in other words, if you absorb a photon of just the right energy, so E is equal to H nu, with just the right energy, you can flip the spin so it's misaligned. So it's aligned against the magnetic field. If you add just the right energy that is perfectly matched, if you put in the wrong energy, you won't flip that spin. And that proton will sit there and sit there and sit there and eventually it'll jostle around with other molecules. And then eventually it will spontaneously revert back to the other spin state. And when it does, when it does that, it will emit energy at exactly the same frequency that it absorbed energy. And this is the basis of the NMR experiment. At the beginning of the lecture I played for you this sound. And I don't know if I can go back to that. I'll try to take this thing off the screen for a moment so you can hear that sound in all of its glory again. You're listening to an NMR experiment. What's happening is the NMR spectrometer pulses the sample and then the spectrometer listens. And it's listening for all the protons in the sample to start giving back their energies at their particular frequencies. So let's listen to a collection of molecules giving back their energy. You're listening to protons giving back radio frequency energy. You don't hear the spectrometer when it pulses because I've taken those sounds out. It would deafen you. But you're listening to the protons giving back their sounds. And if you're a musician or a sound person, you'll notice there's beats in there. That's a function of having two different frequencies that are interfering with each other. That means there's going to be two peaks in that NMR spectrum, two frequencies that you're hearing that are interfering with each other. So that's the NMR experiment. We drop our tube in the spectrometer. We pulse it with energy. The spectrometer listens to the frequencies. And then it plots those frequencies for you. Yes, question? The sound would be able to frequency it. It could save frequency at one or the other. And then it's energy to the left. Well when you pulse with energy, you're pulsing every possible wavelength at the same time. You can't just pulse with one frequency. You pulse with this loud sound that's exciting every single possible frequency. And then the protons all start spontaneously emitting back their sound. So here's a plot, a frequency. Here's a plot of nuclei and frequency. If I had some organic molecule, and I had just drawn a random organic molecule here, this aldehyde with two chlorines on there. So if you were to plot all the protons and all the carbons giving back their energy, the radio frequency energy on one plot, it would be the most useless plot in the universe. And that is because protons absorb and emit energy in a completely different region of the radio frequency spectrum from carbons. In order to fit all of this on one plot, you'd have to scrunch down all the proton peaks so small that you couldn't even distinguish them. And the same thing with carbons, except it's worse with carbons because the carbons are, there's so few carbons that the signals aren't very big. So nobody ever plots carbons and protons on the same spectrum. We always do those separately. We run our, we blast with radio frequency energy over here and then listen over here and then plot over here to see protons. And when we're interested in carbon NMR, we blast with energy over here and then we listen and we just plot this region individually. So from now on, I'm going to separate proton NMR from carbon NMR. We do those as two separate experiments because you just can't fit those onto the same plot. So for the rest of these lectures, I'm going to separately discuss C13, carbon 13 NMR and proton NMR even though the basis of the experiment pulse with energy and listen, the basis of that experiment is the same. There's no difference there. Okay, I want to come back to this thing that I kind of skipped just a moment ago about NMRs, about the physical NMR instrument because there's an important point that I meant to make that I'm realizing that I forgot. And it's essential for your understanding of why spectra look have all these weird labels on them. So here's our NMR spectrometer that I showed you just a moment ago. It's that same slide. And the point that I wanted to make is when you order a brand new shiny NMR, you pay $200,000, $300,000, your NMR arrives. It's just come from the factory. They've just finished wrapping all the coils and packaging it up and you fill it with liquid helium and liquid nitrogen. The problem is that nobody really knows exactly what that magnetic field strength is going to be until they boot up the magnet. And that's the point. When they first boot it up that they realize, oh, now we can finally measure this, the magnetic field of this custom built superconducting magnet that we have created. And no two NMR spectrometers have exactly the same magnetic field. And that's a problem. It is a problem that no two magnets, no two big $200,000 magnets, even if the manufacturers feel like they made them exactly the same way, will have exactly the same magnetic field. And so let's see how that creates complications for the NMR experiment and how the community has had to deal with them and why you're never going to see a spectrum that uses frequency for the x-axis. Yes? Is there a reason why spectrometers don't have exactly the same frequency? I'm sure it's an engineering issue and I'm not competent to comment on why they can't make them exactly the same. Okay, so let me give you an example of a sample. This is chloroacid aldehyde here. And let's imagine I go to my lab. I'm sure we have chloroacid aldehyde in my lab. If I make up some sample in an NMR tube and I pop it into a spectrometer, and let's suppose this is just a thinking experiment that my spectrometer is operating with a magnet with a 9.4 Tesla magnetic field. And then I ask my friend, I call over to Hamburg, Germany, and I say, hey, could you prep up a sample over there in Germany of chloroacid aldehyde and drop it into your spectrometer? The problem is they won't have exactly the same spectrometer. Maybe their spectrometer is operating with a magnetic field strength of 10.3 Tesla. And it becomes a problem if our NMR magnets don't have exactly the same field strength. Because if they don't have exactly the same field strength, common molecules will not resonate, will not absorb and emit energy at the same frequency. So we won't get the same spectrum. So for example, tetramethylsilane, this is very commonly used in NMR spectroscopy, will have a different absorption and emission frequency. My chloroacid aldehyde, the two carbons in there, I might see that absorbing at 100,000,3800 hertz, whereas my friend in Germany will see that same carbon over here, absorbing and emitting at 100,571, whatever, 100 million, at a different frequency is the important point. All our frequencies will be different. Now how are we going to publish our data and have any two people tell that they've made the same molecules? And so here's what we do. Here's what the community has decided to do to make all this work out. What we've decided to do is we've decided to have everybody measure their frequencies relative to one molecule, and that's this molecule, tetramethylsilane. It's volatile, so if you add a few drops to your sample, when you evaporate off the solvent, the tetramethylsilane comes off. The chemical, the frequency at which this absorbs and emits is much lower than the frequencies for most other molecules, so almost always all the other peaks will be on the left-hand side here of the tetramethylsilane, and you're not seeing the silicon, I'm sorry, you're actually seeing the carbon atoms, that's what I mean to point at. Now here's the important point. If I've got a magnet that's 10% stronger in Hamburg than in Irvine, then all the frequencies will be 10% larger. So if I can just divide by that 110% to normalize things, if I could just squeeze that spectrum or stretch the other spectrum, everything will overlay perfectly. If you adjust for the magnetic field strength, everything will overlay perfectly. So we don't plot spectra in hertz in frequency, what we plot is in parts per million. Everybody has agreed that they're going to squeeze or stretch their spectra and plot out the frequencies in 571,000 parts out of every 100 million parts of hertz. So we list frequency using this symbol delta, and our units will be parts per million and not hertz. If you wanted, you could convert it back to hertz, but that wouldn't help you or anybody else. So we're never going to see hertz on that bottom axis. We use this sort of normalized version of frequency, and that's what allows, regardless of your NMR magnet, anywhere on the planet, as long as you take that into account, everybody's going to end up with the same spectrum. Everything is always measured relative to tetromethylsilane. Here's the carbons. That's the carbon atoms there and the tetromethylsilane at that little peak. Here's that carbon atom, and it doesn't matter whether it's, whether it's Hamburg or Irvine or Boston, that's going to be absorbing and emitting at 48 parts per million. And over here, here's that carbonyl at 194 parts per million. That's the carbonyl carbon. Okay, so we're not going to see parts. We're going to see parts per million. There's a second weird feature here because the spectroscopy is related to magnetic fields, and that is we add special labels to our spectra. And we describe this region over here, and you don't need to worry about why. We describe this region over here of the spectrum as downfield, because in the old days they didn't plot against frequency. They plotted against changing magnetic field, and you don't need to worry about why that is. It's just going to seem completely weird to you that I'm going to sometimes say, and I'm going to try to avoid it, but I know I'm going to slip, I'm sometimes going to say, see that carbon resonance downfield over there, and you're going to say, oh, down over, no, it's backwards. It's backwards, and I hate that. And it's going to screw you up because when I say downfield, I mean at high parts per million. I didn't invent that, sorry. Okay, so downfield, when you hear me say downfield, I mean at high parts per million. The other term I'm going to use for this region of the spectrum is I'll refer to that as shielded, and I'll explain that later. Okay, so high parts per million, that's when I say downfield. Over here, this region of the spectrum at higher frequency, we're going to refer to this as upfield, with low parts per million. And the other term that I'm going to use for this parts per million is chemical shift. This is a term that came from physicists who first realized that there was chemical information in these frequencies. For me, everything is chemical, so it doesn't make sense to refer to this as chemical shift, but the physicists who first observed differences in carbon frequencies or proton frequencies were totally mystified. They said, there's some shift, it's a chemical effect. So I'll still refer to that as chemical shift. And this region down here at low parts per million, I'll sometimes refer to as deshielded. And unfortunately, it takes quite a bit of time for you to get used to those terms, because they're opposite. Okay, so we plot chemical shift in parts per million. We don't plot it in hertz. So I'm going to refer to our x-axis as chemical shift. It's measured in parts per million, and when I don't have space, I'm going to use the symbol delta for that. So I'll try to avoid this phrase downfield, because I know it's so counterintuitive and upfield. But if I slip, you're going to have to quickly process in your mind what that means. Oh, my word. Oh, no. Okay. It doesn't matter. I'll manufacture a mice. So my intention here was to draw two spectra for you, and I'm realizing it plotted in such a light gray that even I can't see what's underneath here. This is a two NMR spectra of this molecule, of this dibromopropane. You could have made this dibromopropane molecule here by, let me just make sure I've got this thing focused. You could have made this dibromopropane molecule by brominating a double bond. It doesn't matter how you got it. If I put this into a little sample tube and drop it into the NMR spectrometer and take a C13 spectrum, it will look beautifully simple and satisfying. There's three carbons in dibromopropane. When I look at my carbon 13 spectrum, here it is. Here's my chemical shift. It's measured in parts per million delta. I'll see exactly three peaks. Oh, that's wonderful. It's simple and it's easy. If I then switch the spectrometer, type a new command into the spectrometer and say, okay, now show me the proton NMR spectrum. What I'll see will be, oh, will be unfortunately a mess. It'll have stuff that looks like this, some other peaks here, and some other peaks here. You're gonna have so many peaks. There will be 16 peaks in the proton NMR spectrum for this molecule. 16, how do you get 16 peaks? There's not even 16 protons in here. There's only six protons. Look at the molecular formula. Proton NMR is vastly complex relative to carbon NMR. There's no one-to-one correspondence between the number of peaks that you see and the number of protons in a sample. Carbon NMR is simple because there is a one-to-one correspondence between types of protons and carbon residences. So I'm going to skip ahead in the chapter and I'm going to start explaining carbon NMR to you because it is simple and it is powerful for you. And then when we're done with that, we'll talk about the complex stuff. And we'll talk about why there's so many peaks in the proton NMR spectrum. So once you've used proton NMR for a couple of years, you'll love the complexity of proton NMR because it gives you extra information. But when you're sitting down, taking your exam, you're gonna say, that sucks. That complexity sucks, right? Complexity because you haven't yet spent two years looking at spectra. Yes? So for the carbon NMR, how can you tell that there's so many peaks in the spectrum? Is it that only one-to-one spectrum of the carbon NMR is the same as the other one? Well, when I put sample inside of a tube, I'm putting close to 6.02 times 10 to the 23rd molecules in it, right? You're not putting just one molecule in a tube. You're putting, I don't know, bazillions of molecules. So there's lots of carbon atoms. Yeah, there's no way to measure spectroscopy on a single molecule. The amount of stuff, even a drop of sample in an NMR tube is zillions of molecules. Okay, so the first and the most powerful thing that you can do when you're trying to analyze NMR spectra, the most powerful thing that you can do, is to try to gauge how many different signals should I expect to see in my carbon 13 spectrum. Right, this is the simplest way for you to tell, does my spectrum match this structure? Or does my structure match this spectrum? The simplest and most powerful thing that you can do is to try to figure out ahead of time, well, once I look at the structure, how many signals do I expect to see? And so the fundamental rule here is that carbons that are chemically equivalent due to symmetry give one peak. So let's talk about the effect of symmetry. In other words, if two carbon atoms experience exactly the same environment and are chemically equivalent, if they would react chemically in the same way, then we should expect them to absorb and emit radiofrequency energy in the same way. So let's start off as an example. What we're going to do here is a little exercise where we try to guess how many carbon peaks we should expect to see in a C13 spectrum. So I'm going to start over here and I'm going to label these carbons. Here's carbon one, here's carbon two, here's carbon three, and here's carbon four. And I can immediately tell that all four of those carbons are unique and distinctive. Carbon one is closest to oxygen. Carbon two is one carbon away from oxygen. Carbon three is two carbons separated from oxygen. Carbon four is at the other end of the molecule. All four of those are unique carbon atoms that experience different environments and couldn't possibly experience the same environment because they're separated by different numbers of bonds from that electronegative oxygen atom. I would expect to see four unique peaks in the carbon 13 NMR spectrum for that. I see four distinctive carbons. Now to help you understand the issue of symmetry, let's take a look at this isomer of butanol. Instead of N butanol, here's tert butanol. And when I look at this, I see a carbon in the center here, this quaternary carbon, I'll call that carbon one. And then I see a carbon sticking up that's carbon two. And that's one carbon away from the oxygen atom. And now there's two other carbon atoms here. And those two other carbon atoms are exactly like carbon two. If I just gave this a quick flip around that carbon oxygen bond, all those other carbon atoms, that's meant to be like a rotation arrow there. If I spun around that carbon oxygen bond, what I would find is that all of these other carbons will be exactly the same as carbon two. I'm simply going to label those as carbon two. They're indistinguishable. There's no chemical reaction on the planet that would react with them in a different way. They're related by symmetry. There's no naming principle you can use. We'll allow you to name those differently. And so the carbon 13 NMR spectrum for this, I would expect to see only two peaks. I would expect to see a peak for the carbon directly attached to oxygen. And then these other three carbons that are one carbon away from the oxygen would also be at exactly the same. They would absorb radio frequency energy at the same frequency. And they would emit at the same frequency. Indistinguishable. So in other words, just by counting the number of peaks in the carbon NMR spectrum, I could immediately distinguish between those two molecules. And I don't need to know anything about what frequencies they're absorbing and emitting at. I just count the number of peaks. And that's easy to do. And I expect you to be able to do that. OK, here's another compound. And let me start numbering. You could use letter A, B, C if you want. I'm going to continue to use my numbers. Carbon one here is directly attached to chlorine. Here's another carbon that has an H attached to it. It doesn't really matter that there's an H attached. That's different. It's one carbon away from chlorine. And then I've got two methyl groups. And these two methyl groups will be indistinguishable. If I flipped this around just right, there would be a plane of symmetry through this molecule. So carbon three over here is not distinguishable from carbon three on the other side. Those are the same. They're the same by symmetry. They are symmetrical with each other. So I would expect only three signals for this chlorobutane molecule here. It's actually two methyl, one chloropropane. But the bottom line is that those two carbons there are symmetrical and the same. I could spin around. Let me try to draw this other spin arrow. I don't have a very thin pen here. But if I spun around this bond, I could get those two carbon atoms to experience the same environment. OK, let's take a look at a very similar looking molecule here. And I've got carbon one here. It's part of the alkene that's directly attached to the chlorine. And then up above that, I've got another carbon that has no chlorine attached. I could definitely distinguish those. But what's tricky here is that there's two methyl groups, and those are not the same. There's a methyl group over here that's on the same side as the chlorine atom that is cis to the chlorine. And then there's another methyl group, and it's different. It is trans to the chlorine. And you can't spin around that double bond to suddenly make it cis. Molecules don't do that. This methyl group on the other side is different from carbon three. I'm going to label that carbon four. One methyl group is cis to chlorine. The other methyl group is trans to chlorine. And they don't interchange. There's no, you'd have to spin around the double bond, and double bonds don't do that. So here I would expect four signals in my carbon NMR. And it's very easy. I could look at the carbon NMR and instantaneously. Oh, four peaks. Maybe that's a match. Maybe it's not. But if I see two peaks in my carbon NMR, that's a pretty good indication that it's not the right molecule, that the spectrum doesn't match the molecule. OK, so here's another, and I'm trying to make it look complex and fancy here to throw you off. So here I've got two carbons that are attached to the oxygen atom. I'll start labeling that one as one. Carbon number one here has two H's attached. There's no other carbon like that in this molecule. Here's carbon number two that has a hydroxyl group attached. That's distinctive and unique. There's no other carbon that has a hydroxyl group attached. And then over here, carbon three has a methyl group sticking off of it. There's no other carbon like that. And then the fourth carbon in this structure is just a methyl group, and that's distinctive. This would exhibit four peaks in the carbon 13 spectrum. So I expect you to be able to work through this and identify how many peaks you would see in the C13 spectrum. Here's an aromatic compound, and I think it will help us if I draw the resonance structure of this. So let me start off by taking these double bonds, and I'll draw, and we're going to do a lot more resonance structure drawing in upcoming chapters. But when I draw the resonance structure for this, the point is you can't just look at the positions of the double bonds and decide this is an equivalent representation, this resonance structure up here. This is an equivalent representation of this dichlorobenzene molecule. It's exactly equal. And the important point is if I start numbering my carbons, sorry, that was supposed to be an alcohol, so chlorofenol is the name of this molecule. OK, if I start numbering my unique carbon atoms, I'm going to label the carbon that's next to the hydroxyl group as carbon one. And then when I walk one carbon over, there's two different carbons that are one carbon away from the hydroxyl, and they're identical. And you can't use the positions of the double bonds to tell you whether they're the same or different, because when I draw the resonance structure, now the carbon 2 up above here is double bonded. And so you have to keep that resonance in mind to understand the equivalency of carbons 2 and 2. Now when I walk one carbon further over, I've got two of those as well. Those are identical by symmetry. And then finally when I look at the last carbon that's next to the chlorine atom, there's only one of those. So by NMR, because of the equivalence of carbon 2 and 2 and carbon 3 and 3, they won't give different peaks. Carbon 2 and 2 will absorb and emit at the same frequency. And carbon 3 and 3 will absorb and emit at the same frequency. And so I expect only four peaks in the carbon 13 spectrum for this molecule. OK, so that seems kind of abstract. So let's take a look at our first NMR spectrum. It's a carbon NMR spectrum. And let's try to interpret this. And this is typically the situation you're in. I find some, and everybody, all the books tend to make up stupid problems like this that are of no basis in reality. I'm walking into the lab and I find this mysterious bottle just sitting there that's labeled C2H4Cl2. And I don't know what it is. Here's the C13 NMR spectrum. You tell me which one of these two molecules it is. Now, nobody just walks into their lab and finds mysterious bottles like that. But usually you make things and you're not sure what you made. You synthesize them or you isolate them from nature. OK, so the first thing you should do is notice I see two peaks in my C13 spectrum. And you have to figure out maybe they both should, maybe both of these chemical structures should exhibit two peaks. But at least we can ask how many peaks do you expect to see. So I'm going to start over here with this 1, 1 dichloroethane over here. And I see that this carbon over here has two chlorines attached. I'll call that carbon 1. And then I see a carbon that has no chlorines attached. That's definitely different. There's no way that the carbon with two chlorines should absorb and emit at the same frequency as the carbon that has no chlorines. I expect two signals in the C13 spectrum for that. And look there, I've got two signals. But what about this other dichloroethane? 1, 2 dichloroethane. I look over here at the left-handed carbon and it has one chlorine attached. But then I look over here at the right-handed carbon and it also has one chlorine attached. I look over here at the left-handed carbon and it's one carbon away from a second chlorine. Well, so is this right-handed carbon. There is nothing you could do to distinguish between these two carbon atoms. That 1, 2 dichloroethane will give exactly one peak in the carbon NMR spectrum. Those two carbons are indistinguishable. And the very fact that I see two peaks here in my carbon NMR spectrum has immediately resolved this issue. I immediately know it cannot be this because that should give one peak. Whereas that should give two peaks. And I don't need to know anything about the frequency of absorption for that. It's very easy to resolve that only one of those can possibly match. Okay, here's a set of three isomeric compounds. Let's just see how we can use this symmetry. And three spectra, let's try to match them up. Each one of those compounds matches with one of those three spectra. Let's see if you can predict how many signals you expect to see in the NMR spectrum. Okay, so let's start off up here in the top. How many different signals would you expect to see for top compound? Would somebody like to, it's not matched to the spectra on the side. Yeah, I'd expect to see three, excellent. So I come over here and I see there's a carbon that's attached to chlorine. Well, here's another one that's attached to chlorine. Exactly the same. Just flip over the molecule horizontally and you won't be able to tell the difference. Here's a carbon that's separated by one carbon from the chlorine atom. And on the other side, here's a symmetrically disposed carbon atom, same deal. And then I come down over here and here's now a carbon that's far away from chlorine and there's a carbon down there that's equally far away. You cannot tell the difference between these two carbon threes by carbon NMR. Okay, let's take a look at this next molecule. And we'll ask how many peaks do we expect to see for this next molecule in the C13 spectrum? How many different types of carbon atoms are there? So I see carbon over here that's attached to chlorine and over here I see carbon that's attached to chlorine. Identical. And then I'll walk upstairs here and I'll see this carbon that's in between the two chlorine atoms. There's only one of those, that's unique. And then I'll go one farther away down here. There's a carbon that's attached to carbon one so it's separated from the chlorine by one atom. Well, here's another one. I could say exactly the same thing about this. And then finally there's only one carbon atom here. Sorry, I should put three for that just to give different numbers. And then down at the bottom of this molecule there's a single carbon atom that's as far away as it can possibly get. It's absolutely distinctive in terms of it has one H attached. It's two carbon separated from the chlorine. So I expect to see four peaks. So this would have three peaks. And this would have four peaks. That's peaks. I'm not doing a good job of writing. Now I come down over here to this bottom molecule and you can see the surprising effect of symmetry. I start numbering my carbons. Here's a carbon that's right next to chlorine. And down below there's one that's next to chlorine. It's the same. And then I come over here at two o'clock and I see a carbon that's one carbon separated away from a chlorine. But you could say the same thing for this other carbon on the other side. And when I walk down below, this carbon down below is also one carbon separated away from a chlorine. All four of these carbons on the side are indistinguishable. I would expect to see only two peaks in the NMR spectrum for this compound. Just by looking at the number of peaks in the carbon NMR spectrum and by using my knowledge of symmetry, I can very quickly get a huge amount of information from a carbon spectrum. So I'm gonna give you one last million dollar secret before we finish up here and then I'll explain how to use the chemical shift to make sense of this. Here's a million dollar secret to help you interpret carbon NMR. And I'm giving it to you for free. So carbons that don't have attached hydrogens give small peaks. So when I look at these benzene rings, there's some carbons that have no hydrogens attached to them. They have chlorine atoms. And look at that, there's carbon one. That peak right there has the chlorine. There's no H's attached. I look over here at this spectrum, well you'd have to match it up, that tiny peak there has a chlorine attached and no hydrogen. And then this last compound over here that has a carbon with no hydrogen attached to chlorine, that's that small peak there. And you can use that to help you decipher spectra. Okay, so we'll pick up where we left off on Friday and then start talking about proton NMR.
This is the second quarter of the organic chemistry series. Topics covered include: Fundamental concepts relating to carbon compounds with emphasis on structural theory and the nature of chemical bonding, stereochemistry, reaction mechanisms, and spectroscopic, physical, and chemical properties of the principal classes of carbon compounds. This video is part of a 26-lecture undergraduate-level course titled "Organic Chemistry" taught at UC Irvine by Professor David Van Vranken. Index of Topics: 00:09- Mapping the human brain 01:34- Can we see Chemistry Inside the Brain? CHAPTER 14- Nuclear Magnetic Resonance Spectroscopy 05:52- 14.1: Which elements have magnetic resonance properties? 12:47- 14.1A: The NMR Spectrometer- A Superconducting Magnet 16:38- 14.1A: Energetic Differences Between Two Nuclear Spin States 19:39- The Sound of an NMR Spectrometer 21:03- 14.1: Why we perform H NMR and C NMR separately 23:10- 14.1A: The NMR Spectrometer- A Superconducting Magnet (revisited) 24:16- 14.1B: Strange Terms Because Every NMR Magnet is Different 31:32- 14.1A: C NMR is simpler than H NMR so use it first 34:56- 14.2: How many signals should I expect in the C spectrum? 43:40- 14.2: How many signals should I expect in the C spectrum, Slide 2 46:05- 14.2: Use Symmetry to Predict the Number of C Signals
10.5446/19484 (DOI)
Okay, welcome back to another episode of what's going on cool in the world of, in the work, I guess, not just in the world of chemistry. Saw a news article that had something to do with drugs that could help people lose weight or control their weight and I'm all for that. So this had to do with a study where some investigators at the University of Michigan started screening drugs that were already approved in the market to see if they might do something about obesity. You guys may have heard of this thing called the FEN FEN Diet Pill from the 1990s. It's one of many different types of drugs where people have had high hopes that it could help people lose weight and keep weight off. Most of those kinds of drugs overwork the heart and cause heart problems. So they're still waiting to see if this particular compound that they found, which seems to be very effective, will have those problems in humans as well. So what they showed is that this oral medication, which is actually used to treat canker sores in the mouth, it turns out that when they injected animals with this drug called amlexinox, it made a huge difference in animal weight. So if I could eat whatever the heck that I wanted and then just pop, I am all for that. Get out of here and go develop some pill that I can take so that I can eat whatever I want. So let's go ahead and talk about this amlexinox. I've never heard of that before. It's not a billion dollar pharmaceutical, but it's something that's clearly been on the market for a long time. This is the structure of amlexinox up here. And you can see it's a xanthone, I guess you would call it an azazanthone because there's a nitrogen in the ring. And the target of this is this kinase here called tank 1 kinase, TBK1. And there's another kinase here. They're not quite clear as to what the mechanism is. This was supposed to be an epsilon accorded. I just pulled this signal transduction diagram off the web. They're still trying to sort out this pathway on which amlexinox is believed to act. And the problem is what you're seeing here is a picture that's generated by cell biologists that's an aggregate of many different types of human cells. And so that means it's not perfectly accurate. And so the key point here is that if you have a cell that gets infected by a virus, there's something called a toll-like receptor that sends messages inside of the cell. And that message is controlled to some extent by these two protein kinases, that phosphorylate a transcription factor which then turns on genes. And the effect of those genes depends on what type of cell it is. If it's an immune system cell, it can turn on interferons that help fight viral infections. If it's other types of cells that are simply infected, it can send a message for genes that basically say, hey cell, don't die. Let's keep pumping out new virus. And you'd really like a drug that inhibits that. You'd like those cells to die if they're infected by a virus. Well, those same kinds of pathways, it turns out, control adipocytes. You would like your adipocytes not to proliferate. You'd like them to just stay quiescent, stop proliferating, stop growing. And this drug seems to have the same effect. And lexanauts seems to have the same effect in adipocytes as in virally infected cells. And that's cool. So hopefully, again, I'm not holding out high hopes. The general trend is usually when they find things that induce weight loss, usually those things over work the heart and have other problems associated with them. But I'm sure hoping for that, organic chemistry, to come to my rescue. So we're going to finish, let's go back to the chemistry at hand today for chapter 12 in the Gorginski-Smith textbook. And we just finished talking about dihydroxylation, the addition of two hydroxyl groups across a double bond. And we talked about two different ways that you could do that. One way is you could epoxidize a double bond and then hydrolyze the epoxide open so you get an anti-disposition of hydroxyl groups. The other way that you could do it is using osmium tetroxide and NMO, the secret co-reagent oxidant. And then it adds two hydroxyl groups on the same side of a double bond. And so you need to distinguish those two patterns where the two hydroxyl groups end up on opposite sides or whether the two hydroxyl groups end up on the same side. So now we're going to talk about a completely different type of reaction of alkenes. This is the kind of money reaction that you'll be using for the rest of the Chem 51 series. On through Chem 51C, they'll be throwing this reaction at you. And it's called ozoneolysis. It's a reaction where you use ozone just like the ozone up in the stratosphere that absorbs ultraviolet light. We have little electrical ozone generators. We blow oxygen gas through a current, through a high voltage current, and it converts the oxygen gas into O3 or ozone. So you don't really need to know the structure for ozone. I'll go ahead and draw a resonance structure here that looks like this. Three bonds to oxygen. You have to have a positive charge. One bond to oxygen has to have a negative charge. So that's the structure of ozone. What we're interested in here is the reactions of ozone. So let me give you a couple of examples of what you can do with ozone. And the key phrase here is cleavage. You cleave double bonds with ozone. And it is always a two-step sequence, the way you use ozone. So here's ozone, O3. That's all you have to write. O3 is a gas. So again, in the lab, you've got this machine that generates ozone gas. You bubble it into a solution. You can either bubble it directly into your reaction solution or premake a dilute solution of the ozone in solvents like methanol. So when I carry out this cleavage reaction, I need to follow it with a second step that is always some kind of reducing agent. And the book gives you two different reducing agents. And I don't know why they give you two. It's just more stuff for you to memorize. So one reducing agent is zinc metal. It's not zinc chloride. Zinc plus two. It's just zinc. It's the end. And you use that as a dispersion of zinc powder in water. It's the end product of this. And I feel like it is kind of an easy reaction to see in the forward direction. Because all you do is you sort of split that carbon-carbon double bond right down the middle. And wherever you had a C-C double bond, and I'm just going to put a little squiggly line there so you can see. It splits that C-C double bond and it leaves two carbonyls. And that's very powerful. Sometimes you want a way to generate carbonyl groups. And this is a powerful way to do that. The reaction gets a little harder to see what's going on when you have cyclic substrates. But this is a very common application. And so if I take cyclohexene and I do my ozone-olusus reaction, O3. And in this case, I'll show you the second type of workup that you'll commonly see in our textbook, in the Gershinsky-Smith textbook, and in the Sapling online problem sets. And that is dimethylsulfide. So I'll draw out the chemical structure like this. But I almost never draw it out like that. I write just ME2S as my common abbreviation. That's the most common type written abbreviation for dimethylsulfide. And it's also a reducing agent. It's more reliable than zinc powder. The problem is it smells bad. So I'm more interested in efficiency than in smell. So I tend to ask questions where I use dimethylsulfide more commonly. OK, so now the tough part is how do I draw this out? And one of the key challenges for you is to recognize what used to be attached to the olefin. So I'm going to draw in the hydrogens that were there on the olefin. And if you draw everything that's attached to the olefins, you'll be less likely to make a mistake. So for example, if I come over here to my top case, and I remind myself that there were two hydrogens on that double bond in the beginning. There was a hydrogen up here. There was a hydrogen down there. I'll be less likely to make a mistake when I draw up my product. If I draw that there's, yep, that hydrogen is still there. And that hydrogen is still there. This is one way to help you make sure that you draw correctly draw the products. It's going to get a little bit crowded in here when I try to fit those hydrogen atoms in. But I want to be clear that these are aldehyde products. That I had two hydrogens on that alkene in the beginning. I better see those two hydrogen atoms in the product somewhere. Okay, so when you ozonealize cyclic alkenes, the two carbonyl compounds end up attached to each other. Now this is not a reaction that is just for making aldehydes. If I had a tetra substituted olefin or I had one side of the olefin had two alkyl groups on it, then you'll end up getting ketones. And so here might be a way I would traditionally draw this. And so in this case you'd get two molecules that are identical, both acetone. I'm not going to draw the other acetone molecule. You can do that on your own. In this case because it's symmetrical you get two of the same product. All right, so ozonealysis. You know when I used to work in the laboratory, sometimes you run reactions in lab where instead of getting nice clean reactions you just get brown gunk. And we usually refer to those as hosealysis. That was our way because it sounds like ozonealysis. And that means you just got screwed in the laboratory by your reaction. Okay, let's talk about what's going on mechanistically with this ozone gas. Ozone is very reactive. It's great when it's up in the stratosphere but you would not want to sit around in an environment full of ozone. It does all kinds of things but I'm going to show you what it does in the presence of an alkene. And it involves a class of reactions called a paracyclic reaction and specifically a concerted cyclo addition. So let me try to draw an alkene. And I'm going to do my best, as I sometimes do, to emphasize the fact that alkenes have two different faces. And so I'll try to draw an alkene here that has two R groups on it. And then in the back I'll try to draw two Hs. So you can kind of see that there's a top face to this olefin. And so the ozone has a choice just like electrophilic reagents do to approach from the top face or the bottom face of this double bond. So let me draw this ozone molecule. Ozone is bent. Those three atoms in the ozone molecule are bent. So when I draw my Lewis structure, I'm not going to draw all the lone pairs on here. I'm going to first pay attention to my charges. Three bonds to oxygen has to have a plus charge. One bond to oxygen has to leave a minus charge. And I'm going to take care to draw this one lone pair on the oxygen where I chose to draw the O minus. There's another resonance structure that I could have drawn. And this is going to undergo a concerted cyclo addition reaction in some sense like that osmium tetroxide where simultaneously both carbons of the alkene form bonds with the ozone. Let me draw out the arrow pushing for that. What I'm going to do is I'm going to take this double bond which is the nucleophile and this electrophilic oxidant and I'm going to attack that and give the electrons to that O plus. And at the same time that I'm taking electrons away from this carbon over here on the right hand side, I'm going to use this lone pair on the ozone to attack that. So I'm simultaneously in this mechanism making two bonds with that alkene substrate, two oxygen carbon bonds. So that's called a cyclo addition reaction and you're going to hear a lot about cyclo addition reactions in Chapter 16. Not this kind. We'll give you a different kind called a Diels-Alder reaction. But in Chapter 16 you'll see more paricyclic concerted cyclo additions. You're going to get this very, very, very strange looking intermediate. And the book seems to make a big deal about showing you this mechanism and I'm not entirely clear on how this helps you because you won't see anything like this ever again in this course. This intermediate is called a molosonide and I could care less whether you remember the name for that. So this species right here is called the molosonide intermediate. Whenever I see oxygen-oxygen bonds I think, gee, that's unstable. What the book does not do is it doesn't explain to you how this cleaves the carbon-carbon bond. Ozanolysis is used to cleave C-C double bonds. At some point in this mechanism we have to cleave this C-C double bond and so there's a transformation that occurs that leads to a species called the ozonide intermediate. It is also a five-membered ring. But as I draw this new intermediate out you can tell something very fishy had to happen here. Notice how there's no more carbon-carbon bond where the alkene used to be. Now I just have carbon-oxygen bonds. This is called the ozonide intermediate. And this is what would be sitting around until you come along with your dimethyl sulfide or zinc dust and sprinkle that into your reaction. And let me go ahead and show you the secret of what's happening here. And you don't need to know this. The book doesn't show you this but I'll show you what's happening here that's not shown in the book. Otherwise you'll be left wondering. What happens in order to convert the ozonide into the ozonide is that this undergoes a retro-psycho addition. And I'll draw the mechanism so you can see what's happening. And I've already messed that up. Whoops. There we go. So I'm going to take this weak oxygen-oxygen bond here and give the electrons to that oxygen. And then I'm going to use this oxygen-oxygen bond here to swing down and make a CO double bond. And that's going to induce cleavage of the CC bond. And if you sort of follow through with my arrow pushing, I'll get this other very strange weird intermediate that you've never seen anything like before that looks like this. So what is that? It looks a little bit like the ozone that I started with. I've got this three atom piece here with two oxygens and a carbon. And now I think if you look here you can see that I had an oxygen-carbon species here. And I'm now going to flip that around so that now this oxygen is down on the bottom and this R-carbon is sticking over here on the side. And when I do that I can now see how these pieces map onto the ozonide product. And this does yet another cycloaddition reaction. And if I draw this out it would look like this. This attacks to make an oxygen-carbon bond that breaks this CO-pi bond and now these electrons over here can attack. And that's how you get the ozonide intermediate. This mechanism is like an extravaganza of cycloaddition reactions which would be great except we've got four more chapters before we teach you about cycloadditions. So very obscure stuff. I'm not sure why they make a big deal out of this. So I'm not going to show you the mechanism for the reduction. This is where you come along with your zinc and water or dimethyl sulfide. You have to choose one or the other if I ask you how you do an ozonolysis of some alkene. And so in the end one of these oxygens gets lost and it's completely arbitrary there. And that's what leads to these two alkenes in your product. Okay so that's an ozonolysis reaction. O3 and then you'll follow it up with dimethyl sulfide. Yes, what's your question? For the intermediate, the ozonolysis, the arrow on the left comes from the bottom of the lower pair of bonds. Does this arrow here that I've scrawled over comes from the bond? On this arrow? Yeah. Yeah that's coming from this OO bond. Does that read the other oxygen and not attach? For the, oh you know that's a magnificent question because that's, yes it has to come, sorry, it has to come from a pair of electrons on this oxygen. So let me fix that. So I hope you can see, yes you're right, it has to come from this lone pair on this oxygen not from the OO bond. Otherwise it would have cleaved the OO bond. So excellent point. Yeah so yeah, if I can't make the arrow start from this OO bond because then there wouldn't be an OO bond in this product. It's coming from a lone pair on this oxygen. That would have been better off drawing that lone pair on the outside. Yeah thank you for clarifying that. Okay so ozonolysis. So you're going to be using that as a reaction as a way to make carbonyls and maybe that's not so important now but that's going to be super important when you reach Chem 51C where you're going to do a thousand different reactions where you add things to carbonyl groups. Make CC bonds by adding things to carbonyl groups. So hold on to that ozonolysis reaction, practice it in this chapter and be assured that you will be using that when you reach Chem 51C ozonolysis. Okay this is a little bit, in fact it's substantially less common and that is to do ozonolysis of alkynes. Most of the reactions that we showed you where you did reactions with alkenes, you also do reactions with alkynes that are in some ways analogous. So I'm going to try to take a substrate and all this other spinach over here on the side is not really important. I just got tired of drawing butyne for every substrate. So if I come along with this alkyne starting material here and I treat this with ozonol, and then I follow that up, not with a reductive work up. And this is critical. You don't want to follow this up with a reductive work up. We'll just treat this with water. This leads to oxidative cleavage all the way to the carboxylic acid. So none of this other stuff gets changed in the reaction, the isopropyl, the methoxy group. But now one of the carbons, let me draw a C right here for the two carbons in my alkyne, the carbons on one end of the alkyne gets converted to a carboxylic acid. And the carbon on the other end gets converted into a carboxylic acid. And quite often you'll throw one of the pieces away. You'll isolate both and then throw one of them away. Usually just one end of your molecule is the high value end of your molecule. Don't worry about the mechanism. I'm not going to ask you anything about the mechanism for this reaction. There's nothing about that that's useful or extensible to you by you to other chemistry that we do this quarter or in the 51 series. Okay, so ozone allysis of alkenes gives you either aldehydes or ketones. And ozone allysis of alkynes gives you carboxylic acids. Okay, finally we are moving on to the most important reactions in this chapter. And these by far are the reagents that you need to know from here forward. And so I wish I had a green pen here because all of the stuff that I'm going to show you here, it'll be on every single Chem 51 exam in every section, at every school, at every university. And that is oxidation reactions. And I'm going to show you a series of chromium oxidants that are used to convert alcohols into carbonyl groups. And I'm going to show you a series of four closely related reagents. The first three are essentially identical in terms of what they do. And then the last one is different. So let me start off by drawing out the first reagent. And I'll try to use some different pen colors here so I can try to keep stuff straight. Okay, so the first reagent that I'm going to show you is potassium dichromate. And it's just this sea of elements here. Two potassiums, two chromium, seven oxygens. And what in the heck is going on with that? And what's worse, I think, infinitely worse is that the book also shows you sodium dichromate. Two sodiums, two chromium, seven. There's no functional difference between these two. There's no reason why you should ever worry about what one does. They're identical, so I don't know why the book shows you both. It sometimes asks you one versus the other. That's totally pointless. But let's go ahead and draw out the structure of a dichromate anion. It's very similar to a diphosphate or pyrophosphate group that you might see in biology. So let me go ahead and draw out this chromate species. Kind of similar here in terms of the structure. So here's the two chromium. See, there's an oxygen bridging those two. And each of those chromiums has an oxo group. Looks kind of like a carbonyl, so a double bonded O. Each chromium has two double bonded O's. And each chromium has two O minuses. So you can see why you need two potassiums or two sodiums to balance out those charges. I'll just write the two potassiums down here. Those don't affect anything. So that's dichromate. Now when you put sodium, every case where we do it in this book, when you put sodium dichromate or potassium dichromate in aqueous sulfuric acid, it very quickly hydrolyzes one of these oxygen chromium bonds and forms a species called chromic acid. So in other words, when you use sodium dichromate and you put it in aqueous sulfuric acid, the only reason you're doing that is because you can't buy chromic acid, because you can't buy this species here. So this is called chromic acid. And I'll just write it here. It's unstable. You can't buy it. So you have to make that using sodium dichromate, chromic acid. And that's unstable. The other way that you can make chromic acid, the other reagent that you can literally buy and mix with sulfuric acid is chromium trioxide. This is a planar molecule. It's just chromium with three oxo groups on it. And so the formula is here for this very simple, just CRO3. I think you can see that if you add H2O to that, you get chromic acid just by molecular formula. Okay, so there's two ways to make chromic acid. You can't buy chromic acid. You can make it from sodium dichromate or potassium dichromate. Or you can make it from chromium trioxide. And the trick here in both of these cases, the trick to making chromic acid, is that you mix these things together in sulfuric acid and water. So both of these basically generate chromic acid when you put them in sulfuric acid and water. And that's really what I want you to remember. Now there's a fourth species that I want you to remember. And I hope you'll see that it looks kind of similar to these other species. And this other species that I'm going to show you is called periodinium chlorochromate. And you don't need to know that. You just need to know PCC. So there's two oxo groups on the chromium. There's an O- sticking out here, kind of like the potassium dichromate. And then sticking it back over here, I've got a chlorine leaving group. So that's the chlorochromate species. The periodinium, well, there's nothing special about periodinium. That's the same species you get when periodin acts as a base in any other reaction, thionyl chloride. That's just protonated periodin. So that's the periodinium. That's the P. And then this other species down below is the CC. That's chlorochromate. Okay, so the most important thing about these reagents is not really the chromium. These are all basically the same chromium species. The main thing that you need to remember with these is what solvent you use them in. Invariably, when you use PCC, you avoid water. I can't think of any case in my life I've ever seen it used in anything other than dichloromethane. You do everything you can to avoid water in PCC reactions. With these other species, you're using them in water, using aqueous sulfuric acid. The solvent you use for these two sets of oxidizing reagents is more important than the reagent itself. In other words, if I took PCC and I put it in aqueous sulfuric acid, it would simply generate chromic acid. You would never put PCC in water. Otherwise, why did you take the time to make PCC if you're simply going to convert it back into chromic acid? Remember the solvent for these reactions. It is super important. It's as important as the reagent. Let's go ahead and talk about what you can do with PCC. Before I do that, I want to show you what you can't do with PCC, which may seem odd. It may seem odd that I'm going to show you what you can't do with PCC. But then it will help set us up for seeing what you can do with PCC. I can't resist. Let me go back because I have to show you what the whole point of these reagents is. I'm going to just take a simple alcohol like isopropanol down here and any one of these reagents that I just showed you. Sodium dichromate in aqueous sulfuric acid, chromium trioxide in aqueous sulfuric acid, PCC in dichloramethane. I'll just write an O in brackets here to indicate oxidation. Any one of those reagents will convert an alcohol into a ketone. That's the main point here. You won't be able to use this as effectively as you'd like to until you get to Chem 51C because in Chem 51C we'll show you how to use ketones to make carbon-carbon bonds. That's why this won't be super powerful until you get to that stage. What's the limitation on this? There's a limitation and then there's this little solvent thing that you have to remember. Let's talk about that. Here's a limitation that's, I don't know if it's such a limitation, but I feel like it's obvious, that you may focus on the fact that we form carbon-oxygen double bonds with these oxidations. That's not what I focus on. What I focus on is the fact that you remove an H. In other words, see this carbon here that I have a dot? That's called the carbon-all-carbon. You don't need to know the name carbon-all-carbon. It's just a way of saying, oh, the carbon next to the OH group. That carbon-all-carbon has to have an H on it. Otherwise you can't possibly oxidize this. If I treat this with PCC, there's no reaction. There's no H on here that can be removed and that's really what the oxidant is doing. There is no way to form a CO double bond. You'd end up with five bonds to carbon. Here's another tertiary alcohol. And here's that other recipe that I mentioned, potassium dichromate. Look how complex that formula is. Gee, that's awful. And then you mix that in some aqueous sulfuric acid, H2O. Again, that wouldn't do anything. There's no H's on that carbon-all-carbon there. It's a tertiary alcohol. So tertiary alcohols, you cannot oxidize them to put a CO double bond. Again, you'd have some weird five bonds to carbon situation that would be crazy. So where are you going to use these chromium oxidants? You're going to use them for oxidizing secondary and primary alcohols. And secondary alcohols are easy. Let's talk about secondary alcohols. And any one of those oxidants that I showed you, let me step, well, I'll get to this in a moment here. So any of those oxidants that I showed you will work efficiently for converting alcohols, secondary alcohols into ketones. So again, what you may see is the fact that there's a new CO double bond there. But what I see is the fact that this H got removed. And I hope that that's as plain to use before I drew that, as it was to me. So let's draw one of my recipes here. Just to be different, I'll throw the chromium trioxide in. And then use sulfuric acid and water. Most organic molecules aren't soluble in water. So usually people use acetone as their solvent. In that case, this is called a Jones oxidation. When you use this combination of chromium trioxide, sulfuric acid, water, and acetone as the solvent. I hope you don't get exposed. You don't need to know that. There's no reason for you to learn that. Okay, here's another substrate where I have a tertiary alcohol. Remember what I said, that's not going to oxidize. And a secondary alcohol. And so when I treat this with any one of those reagent combinations, in this case I'll use PCC. I would encourage you every single time you write PCC to write the solvent. If you don't remember the solvent, there is no case where an organic chemist would use water for PCC. So in theory, you don't have to write solvent for PCC. It is simply assumed to be dichloromethane. But I wish you would write dichloromethane as the solvent. Just to reinforce for yourself that, yeah, this is the one of those ox, the only one out of those oxidants that doesn't use an aqueous-coz solvent. So the product of this reaction, the tertiary hydroxyl group, doesn't get touched. That's still no H. But the secondary alcohol that had the H at the carbonyl carbon, that now gets converted into a ketone. So tertiary alcohols, nothing happens. Secondary, any one of those oxidants would convert that efficiently into the ketone. Okay, so very powerful stuff. Let's talk about the mechanism and then I'll talk about what's going on with primary alcohols. Primary alcohols will give you trouble. But let's go through a mechanism for what's going on with the chromium oxidation. So this is an E2 elimination. Now what I want to emphasize is the book shows you a mechanism for oxidation where chromium trioxide is the active species and I don't want you to remember that. None of these oxidants actually act through chromium trioxide. And there are some reagent combinations that involve chromium trioxide and other solvents, but nothing that the book gives you is like that. And so here's the mechanism and I want you to know this mechanism. So let's go ahead and start off by drawing our alcohol. And this is going to be a secondary alcohol. And I'm going to be super careful to draw that H on the carbonyl carbon. I'll just explicitly draw that H because we're going to pull that off. This is going to involve an E2 elimination to make our CO double bond. And the first step here has to do with the lone pairs on the alcohol. That's a nucleophile and all of those chromium oxidizing reagents are electrophiles. Let me draw out our chromium oxidizing reagent and I'm specifically going to give you the mechanism for PCC. There's chlorochromate. There's the chromate. Here's the chloro group on the chromate. That's a minus charge by the way. And that's R prime in case you're wondering what my, I'm just trying to distinguish those two R groups. Okay, so here's chlorochromate. Look at all those electronegative substituents on chromium. Chromium wants to be attacked by things. Oh, look at that. Here's this oxygen lone pair. Oh my gosh. There we go. So the hydroxyl group, the lone pair on the hydroxyl group attacks the chromium atom and you kick the electrons. And I wish I had a thinner pan here, but you kick the electrons up from this chromium oxygen double bond and give it to one of the oxygen atoms. Okay, so let's draw this next intermediate. The only difference between this and the chromic acid is in chromic acid, where I have CL, you would have OH. Okay, so this next intermediate is going to be kind of busy. Now I'm going to literally draw that OH bond there. Here's my two R groups on my secondary alcohol. Oh, there's now a third bond to that oxygen. I'm going to have to put a positive charge on that now. And look at all these bonds on chromium. Oh my god, it's so complex. How could I ever sort all of this out? It's scary. Look at this. There's two minus charges on there. Now there's a plus charge on that oxygen. It'll sort out, don't worry. So I just made a bond to the chlorochromate. I kicked the electrons up from this oxo group to have an O minus group. And now what I'm going to do is I'm going to kick out the chloride leaving group. Basically, we're just finding a way to do, it's not an SN2 reaction. We don't displace chloride through SN2. So let me draw the lone pair on one of those two O minuses. And then I'll try to write more carefully with this fat pen here. Now I'll push downward to make a chromium oxygen double bond again and I'll kick out the chloride. And so when I do that, I once again have two chromium oxygen double bonds. Here's my chromate. It's starting to look a little bit simpler now. Totally simple, but I still have that positive charge on that oxygen. If you've got three bonds to oxygen, you better put a positive charge there. And the book, for the mechanism for chromium trioxide, they eventually reach this stage. It's just that they did this in one step instead of two steps, the way I did it with PCC. The book pulls this proton off, but instead of using arrow pushing, they just write the word proton transfer. If I ask you to write an arrow pushing mechanism, I want you to show the arrow pushing mechanism for removal of the proton. So I'm going to go ahead and write a species here. When you do these reactions with PCC, there's pyridinium and stuff in there. I'm going to write b, but if you wrote a- I would also accept that. But something to act as a symbolic base. Either the conjugate base of an acid, a- or the letter b with a lone pair. Just something symbolic that we can use to pull that proton off. And so now essentially what we've done is we've converted this chromium atom into a leaving group. So when I draw out this next intermediate here, I'm now ready to do the equivalent of an E2 elimination that will- it looks a little bit similar to things that you've seen before, but it's different. And I'll point out why it's different from the other types of E2 eliminations that you've seen before. So here's what's strange about the E2 elimination that's going to ensue here. What we're going to do is we're going to pull off that proton and simultaneously push out this chromium atom. And what is weird is that the chromium is going to walk away with a pair of electrons with a lone pair. So now there's going to be something with lone pairs in there, either the pyridine or- or some sort of oxygen species that now comes along and does the equivalent of an E2 elimination mechanism. We pull this proton off, those electrons push over, make a CO double bond, and we give the electrons in this oxygen chromium bond to chromium. That reduces, that's called- that'll end up being a reduction of the chromium. So instead of having this orange chromate color that you have, it'll suddenly go green, which is characteristic of these chromium oxidations. Once you reduce the chromium, it turns green. It used to be the basis of these breathalyzer tests that the police would give you in the 1980s. You breathe in a bag and if it turns green, they know you've had too much ethanol in your breath. Okay, so let me draw this very strange looking chromium species. You'll never see anything like this again. That's now a reduced form of chromium. I guess that should be a minus charge on there. Okay, so this is the reduced form of the chromium and that's the mechanism. The book mechanism on page 448 is very similar except that they do the first two steps basically in one step by adding to chromium trioxide. Okay, so it's- and this key step here is the E2 elimination mechanism. Now, I just looked on the 51LB website. If you're taking the attendant lab, you did chemistry that was very similar to this in the lab, I'll just highlight how that's similar. So in lab, you did an oxidation with bleach where essentially you had something like this going on. You put a chlorine leaving group using bleach on your ketone. And then along came your base and pushed out chlorine. Essentially the same kind of idea. All of these oxidations of alcohols to ketones will involve putting some leaving group on oxygen, which is not easy to do. And so that's what makes the chromium so magic. Okay, let's talk about primary alcohols because there's something here we need to memorize. It's a distinction between primary alcohols and secondary alcohols. So here's a primary alcohol. And the first thing I see here in my mind is there's two H's on that. And I can't resist drawing them so- excuse me while I obey my irresistible urge to draw those two H's on that primary carbon. And this is what distinguishes a primary alcohol from a secondary alcohol. And so there's two possible outcomes when we do an oxidation and it depends on the solvent we use for a chromium oxidation. So if you use chromium trioxide or potassium dichromate, and you- of course you always do those in water, and you have to write out the water, I expect you to draw this full recipe out. And water, that's the important facet here, the reaction. This oxidizes the primary alcohol, not to the carbonyl, just a simple aldehyde. It oxidizes it all the way down to a carboxylic acid, or maybe all the way up. And you have to remember that. It doesn't stop at just a simple aldehyde. If you want to stop at the aldehyde, you need to go to a non-aquias reagent, PCC. And you don't have to write dichloromethane here, but I wish you would write dichloromethane. Most organic- no organic chemist writes the solvent. It's simply assumed it will be a non-aquiasolvent and specifically dichloromethane. And so in the case of PCC, you stop at the aldehyde. So you get to choose if you have a primary alcohol, whether you want to just make the aldehyde or whether you want to burn that all the way down to a carboxylic acid. So- and it has everything to do with the solvent. It's not the reagent itself that matters here, it's the solvent. So that's why I expect you to be really picky about this aqueous solvent business for potassium dichromate or chromium peroxide. So this is also true. That's right. Instead of potassium dichromate, you could also use chromium peroxide. You get the same carboxylic acid result. Okay, why is there this distinction between what these things are doing? Why is it that in water you get one result, whereas in an organic solvent like dichloromethane, you get a completely different result? And you're not set up to understand this, unfortunately. The book does not set you up to appreciate why this should be true. So I'll show you what's going on here. And it has to do with the addition to carbon yields, of nucleophiles to carbon yields, and the book goes into great immense lengths to explain this stuff to you when you get to chapter 21. What the book explains to you in chapter 21 is that when you have aldehydes, water connects as a nucleophile, not a great one, to set up an equilibrium where you have this adduct called a hydrate. Where you add the elements of water, and I'm not going to draw the mechanism. It is not a one-step mechanism. It's a multi-step mechanism. But whenever you put aldehydes in water, you also have some of this dihydroxy. This is called the hydrate. You also have some of this hydrate floating around. And typically, for most aldehydes, this ratio is about one to one in straight water. So we call this the hydrate. I'll just put a little arrow here. This is called the hydrate. And I hope you can see that that hydrate looks kind of like an alcohol. It looks kind of like a secondary alcohol. And it's not like it's frozen in space here. This is a rapid back and forth equilibrium. And so what's happening here is when you do oxidations of primary alcohols to aldehydes, is that the aldehyde that's present in water forms a hydrate. And the hydrate undergoes an oxidation reaction. So there's, I've just redrawn the hydrate in a slightly different way. So you notice you can see that H on the hydrate carbon. And so this does the same oxidation business that I just showed you. And it doesn't really matter what the chromium species is here. There's some leaving group on the chromium species, whether it's an OH. You don't need to know this kind of mechanism here. And so the point is you'll get to this same stage that we were at before. It doesn't matter that this other group is an OH. You still reach the same stage in your mechanism. You still undergo the same type of E2 elimination. And the only real difference here is that we've got a hydroxy group sticking on the bottom. You still get to this stage where it does some sort of E2 elimination. And that's what leads to the carboxylic acid. You still give the lone pairs to chromium. So when you reach Chapter 21 in Chem 51c, this whole hydrate business and the addition of water to the aldehyde will be completely natural to you. And at this stage, I kind of expect that to be a little bit mysterious to you. So just hold on. This stuff right here, just hold on for Chapter 21. If you'd like to read ahead and go get some more explanation of all the things that aldehydes can do, fantastic. But that's why you can't stop aldehydes from forming hydrates in water. And it's the hydrate that's actually undergoing oxidation to the carboxylic acid. And if you're using PCC in dichloromethane, well, there's no water in dichloromethane. So you can't form any hydrate in there. That's why the solvent is so critical. Okay, so the last part of Chapter 12, there's a section called green chemistry in ethanol. And what they show is that you can take chromium reagents and exhort them onto solid supports. And they say that this is green chemistry or environmentally friendly chemistry. You know, chromium six species are class three OSHA carcinogens. The Occupational Health and Safety Administration labels these as carcinogens. I don't consider that to be green chemistry. And so let me just say you should ignore that. That whole section is bunk. Let's move forward to the last section. There's something called the Sharpless Apoxidation. And the last time I taught this class was many years ago, four years ago maybe. I went through this and we ended up spending 90% of our discussion sections and office hours going through this over and over to the point where I can tell now that this reaction does not merit this much attention. This was one of the first reactions that allows you. And so let me just clarify here. I'm not going to put this on my exam. There was a time about 25 years ago and this was basically the only reliable asymmetric reaction that you could do where you could predictably get one enantiomer versus the other. But that was 25 years ago. And we now have zillions of highly efficient reactions that allow you to get one enantiomer or the other in a predictable fashion. And there's no reason why you should have to memorize this now dated reaction, which was historically important, but now has been complimented by such a vast number of other reactions. Here's what the reaction does. This is called a Sharpless Apoxidation. I'll show you the recipe and maybe you can get a sense. Here's why I want to show you this even though I'm not putting on my exam. I expect you to work each and every problem in the back of the chapters. I expect you to work every single problem. In order to get experience working problems you've never seen before. And unfortunately some of the problems in the back of the chapter involve this Sharpless Apoxidation. They really seem to work this hard. A Sharpless Apoxidation involves taking T-butylhydroperoxide. So it's not T-butanol. There's an OO bond. It's a hydroperoxide. So this is the oxidant in the reaction. And the point of the Sharpless Apoxidation is that you can use it to get a single enantiomer of the epoxide. MCPBA would do exactly the same reaction and would give you a racemic mixture. And this reaction gives you just a single enantiomer of the epoxide. And I don't feel like it's important for you to remember which enantiomer. Go through a lot of work to memorize which enantiomer you get. That does not seem useful in any way. So you use T-butylhydroperoxide so you can see where the oxygen atom in the epoxide is coming from. Yes, you could do the same thing with MCPBA and get a racemic mixture. Then you need a catalyst. It's this titanium catalyst which will look super mysterious to you. So you have four isopropoxy groups. I'll just write isopropyloxy here. That's the catalyst for the reaction. And then you put in this chiral additive called diethyl, excuse me, diethyl tartrate. And I'm simply going to abbreviate that plus diethyl tartrate. It's a single enantiomer of a naturally occurring diol. There's no reason for you to memorize this recipe. If you use the opposite enantiomer of diethyl tartrate, which is also readily available, you'd get the other enantiomer of the epoxide. And it doesn't seem fruitful to me. I'll draw a diethyl tartrate for you. This plus enantiomer of diethyl tartrate looks like this. It's an bisethyl ester. And those two OH groups grip the titanium to create a chiral environment. So I encourage you to work problems in the back of chapter 12. Some of those problems will involve this. Sharpness, epoxidation, I won't put that on the exam. So when we come back on Friday, we're going to start spectroscoping. We're going to spend maybe some of it in one or two weeks just talking about spectroscopy. And so, steal yourself for that.
This is the second quarter of the organic chemistry series. Topics covered include: Fundamental concepts relating to carbon compounds with emphasis on structural theory and the nature of chemical bonding, stereochemistry, reaction mechanisms, and spectroscopic, physical, and chemical properties of the principal classes of carbon compounds. This video is part of a 26-lecture undergraduate-level course titled "Organic Chemistry" taught at UC Irvine by Professor David Van Vranken. Index of Topics: 00:09- Canker sore drug helps mice lose weight 01:37- Amlexanoxx 04:00- 12.10: Ozonolysis of Alkenes with Ozone 10:24- 12.10: Oxidative Cleavage of Alkenes 18:22- 12.11: Oxidative Cleavage of Alkynes with Ozone 20:33- 12.12A, 12.12B: Chromium Oxidant Recipes 26:52- 21.12A, 12.12B: No Oxidation of Tertiary Alcohols 29:48- 12.12A, 12.12B: Oxidation of Secondary Alcohols to Ketones 32:32- 12.12A, 12.12B: Mechanism for Oxidation of Alcohols 40:30- 12.12A, 12.12B: Oxidation of Primary Alcohols 43:12- 12.12A, 12.12B: Why Primary Alcohols Oxidize to Carboxylic Acids in H20 46:48- 12.13: Green Chemistry, Ethanol 47:27- 12.15: Sharpless Epoxidation
10.5446/19479 (DOI)
Okay, we have an exam on Friday. Just to remind you, I hope all of you know that and have been studying all weekend and are continuing to study. So there will be assigned seats for the exam. I'll post those on EEGradebook later today. If you'd like to request a left-handed seat, show up 10 minutes early and talk to the TA here who will have the seating assignments and they can do something for you. That means bring your ID because we have assigned seats. We'll check those. So don't forget that. And there is no discussion section on Friday. So if you have a Friday discussion section, then try to make it to one of the other discussion sections this week. And again, we have extra office hours this week. Check the website. You can check when those extra office hours are. I have extra office hours today, for example, instead of just Thursday. Okay, so I'd like to talk about stuff that I see in the news that relates to organic chemistry. And so here was a recent article on Gatorade. I'm sure a lot of you probably drink Gatorade sometimes. They came out with this. I'm not really an expert on Gatorade. This newer version that seems to have natural ingredients as opposed to the totally synthetic ingredients in their regular mix. But what was fascinating is this story is about them taking out some traditional ingredient that they've been using in their formulation called brominated vegetable oil. And just for me to hear the word or read the word brominated turns me on that something interesting is going on there. So apparently there's quite a few types of beverages that contain brominated vegetable oil. And I was totally unaware of that. And what they're pointing out is that the ingredient is being used as an emulsifier. I'm not sure if that's exactly correct, but you get the idea. Let's go ahead and talk about what brominated vegetable oil is doing in Gatorade or whatever drinks that they're putting in there. What's also fascinating to me is apparently there's a Mississippi teenager who is making all kinds of noise about this saying, hey, how come you're putting brominated vegetable oil into my drink? Take that stuff out of there. So this seems to be catching on. So let's go ahead and talk about what happens if you take natural citrus fruit or citrus oils and you mix them in with a drink. If you've ever taken an orange peel and squeezed it sort of backwards, you'll see this little spray come out. It's full of all kinds of organic compounds that taste and smell phenomenal. And it would be great to make drinks where you can take advantage of those citrus oils. And of course they do that. The problem with oils, organic compounds, is they don't mix with water. If you take any organic compound that exists in a liquid form and you try to mix it with water, the tiny little bubbles that form, like I don't know if you can see the laser point here, you'll have these tiny little bubbles. Even if you mix it really well, all the tiny little bubbles are lighter than water. Organic compounds are less dense than water and they will all float to the surface. And that's not very appetizing if you're drinking your data rate and all the organic flavoring oils have risen to the top and formed some oily sheen that you drink up in the first sip. So what they do is they put in a class of compounds called emulsifiers to help make, to spread out all the organic droplets. But the problem is all these little organic droplets still have a tendency to rise because they're less dense than water. And so what can you do if your oily flavored droplets are less dense than water? If all those citrus oils, those organic compounds are rising to the surface, some very clever person said, well, if we take soybean oil sold as vegetable oil in the department, in the grocery store, and we brominate that using a reaction that you learned in the last chapter, bromine is very heavy. You've probably never picked up a bottle of bromine, but the second you grab it, you realize, oh my gosh, this is heavy stuff. When you brominate organic molecules, they start to become more dense and heavier. And brominated vegetable oil is heavy and dense. It's got a typical density for the stuff that they sell for these applications is around 1.3 grams per mil. So when you mix this brominated vegetable oil in this drink, it goes into these little droplets, and you can adjust it so that the density of these little droplets is exactly the same as water so that they don't all rise to the surface. And so these delicious flavored organic compounds stay dispersed throughout your mix. So they're going to take this out of Gatorade and put in other dense organic molecules that have more oxygens instead of a few bromines. And sort of an interesting application I'd never heard of for bromination reactions that you've been and you've been drinking those compounds without knowing it. Okay, so we've moved on from chapter 10, which was these bromination reactions. I guess we're going to cover some in chapter 11. So let's move on to chapter 11 now. So again, the exam on Friday will only cover chapters 9 and 10, well of course there will be SN1 and SN2 stuff from earlier chapters. Organic chemistry is always intrinsically accumulative but of course the test will focus on chapters 9 and 10. There's no chapter 11 alkyne stuff. There's no new stuff from chapter 11 on the exam. Okay, so let's go ahead and what did we talk about on before we left on Monday? What basically what I said is look, alkynes, C-C triple bonds have pi bonds in them and they're going to act as nucleophiles just like C-C pi bonds in just regular alkenes. Let's go ahead and front end our conversation by introducing a little nomenclature and not really IUPAC nomenclature but just regular nomenclature, just how I'm going to refer to these compounds. So let me start off by drawing two different alkynes because there's an important distinction I'm going to make throughout this chapter. So I'm going to start off with a 4-carbon alkyne where the C-C triple bond is at the end of the alkyne and then I'll compare that with another 4-carbon alkyne where the C-C triple bond is in the middle. So 4-carbons that's butane but these are both butines. Butane has no unsaturation and this clearly has an alkyne. So let me write butine here and if the highest priority functional group is an alkyne then the name will end in ion sort of as an indicator. This would be one butine. You number an IUPAC, you number so that the high priority functional group has the lowest number possible. That would be one butine. So you wouldn't count the other direction and make it 3 butine. And over here it's arbitrary which side I start from. No matter which side I start numbering from, this particular butine will be 2 butine. So that's IUPAC nomenclature. And I think there's a couple of questions on the sapling homework. I don't ask IUPAC nomenclature on my exams but I might ask you a question where I say synthesize the following internal alkyne or terminal alkyne. And those are phrases I want you to know because I'll use them. They're kind of useful phrases. So how would I distinguish this alkyne that has a CH at the end versus an alkyne that has alkyl groups at the end? So this we call a terminal alkyne. That means it's at the end of the molecule. And there's all kinds of distinctive chemistry related to that. So that's why I want you to know what a terminal alkyne is when I refer to that. And this other one where there's alkyl groups at the ends, in other words when the alkyne triple bond is in the middle of a chain, we call this an internal alkyne. Okay, so I want you to know that kind of nomenclature in case I'm writing on my overheads here and I refer to those terms. Okay, so as far as physical properties, there's not a whole lot for us to say about alkynes. I'll simply point out that the alkyne functional group is, it's not like there's oxygen or some sort of electronegative atom on there. So you can expect that any alkyne functional group is not going to introduce polarity to a molecule. So let me draw out a series of six carbon molecules. There's hexane, it's common solvent, inorganic synthesis, inorganic chemistry. We use that for chromatography, specifically because it's nonpolar. And so I'll just write out here hexane so we can compare that. And so let's imagine adding an alkyne to that, introduce some unsaturation that would be hexane, specifically one hexane. I'm not going to worry about that. And now let me draw a four carbon chain. There's three carbons, four, five, and six carbons. So this would be one hexane. And if we compare the boiling points of these molecules, they all have about the same boiling point, same sort of range. Boiling points are around 60 to 80 degrees for these. Celcius. Okay, so they're greasy molecules. If you have alkynes, they don't make the molecule any more polar than any other simple carbon based functional group. So in other words, there's all these sections in the book that talk about the naming of alkynes. I'm not going to ask you how you pack nomenclature. The properties of alkynes. And there's not a whole lot to discuss as far as hydrogen bonding or boiling points. And then in section 11.4, they talk about examples of alkynes. And I would encourage you to read through that section just to understand why should I spend time learning about alkynes. But I'm not going to ask you to draw any of those structures on the exam. You know, I think they might talk about some, a frog toxin called histrionicatoxin or the birth control compoundethinol estradiol. But again, I don't ask you to memorize organic structures, complex organic structures. Just so you can repeat them back to me on the exam. Okay, so a lot of stuff in those three sections that is not really the kind of stuff that I want you to walk away from this class with. I'd like you to walk away from this class understanding the chemistry of atoms and of organic molecules at the level of atoms and bonds. So let's talk about some chemical reactions. So how do you make alkynes? Let's go ahead and start off right out the gate here with a reaction that you haven't quite seen before. What I'm going to do is I'm going to show you two different elimination reactions that you could use to make alkynes. And so I'll finish up this structure in just one moment. And I'll show you a reaction where you take a strong base and a immensely powerful base. So you can see I've got two isopropyl groups. And in between these two isopropyl groups, I've got two carbons. And so if I want to make an alkyne, I can't just have a single bromine atom there because if I treat this with a base, I'll all get as an alkene. So here's one way to make an alkyne is you have to have two BRs. So we can eliminate HBr twice. So if we do two eliminations of HBr. And we're going to want to use some powerfully basic conditions in order to make this happen. And so in this particular case, we have to eliminate HBr once and then twice. We do that all in the same pot. And so we're going to add two equivalents of a very powerful base, sodium amide, NaNH2. And get ready to start using that throughout this chapter. Wow, that's basic. God, that is so big. We'll talk about that. It's super basic, sodium amide. So again, what you can't see, and I'll draw it for you, and I want to draw it small because typically I wouldn't draw these hydrogen atoms for you. But I'm just going to remind you that there's a hydrogen atom here. And then there's a hydrogen atom down here. And so you're losing two HBrs. You're just doing two E2 eliminations. We'll talk about this more in just a little bit. Okay, so what's another type of substrate you could use to make an alkyne? I'll draw another halide here. And you could do the same two equivalents of sodium amide base. You know, in terms of nomenclature, you would call that amide, sodium amide. But I try to emphasize with the word amide because there's another functional group called an amide. And I don't want to distinguish that. So if it irritates you, just get over it that I'm calling it amide. Chemists might say, gee, why are you distorting the name like that? And so I'm going to write potassium tbutoxide. The book writes the molecular formula, the structural formula out. But you'll find I'm going to start abbreviating potassium tbutoxide like this. And so I'll expect you to know that that means tbutoxide. So tert-butyl alkoxide anion. Or I might draw tbu-O potassium. But this is potassium tbutoxide that you've already seen a lot of. Now, as we will see shortly, potassium tbutoxide is nowhere near as powerful as sodium amide. So whether the book does it or not, if you're trying to make an alkyne with potassium tbutoxide, I want you to draw heat. Potassium tbutoxide is nowhere near as basic as sodium amide. So I would like you to draw heat. And typically the temperature is required for 80 to 100 degrees, a little over 100 degrees. So if we eliminate here, there's a two carbon chain dangling off of this benzene ring. So I'm going to end up with a two carbon alkyne dangling off of that benzene ring. And again, you may not be able to see here where those two, you're going to eliminate HCl twice in this reaction. Here's two of the three Hs on that carbon atom at the end. So, okay, so two different reactions. You could use either one of these two equivalents of sodium amide or two equivalents of potassium tbutoxide. Don't forget to heat that. So you can see that these two types of substrates are subtly different. So on the top substrate, I've got the two bromines on different carbons, on neighboring carbons. And we have a term for that. When the two halogens are on neighboring carbons, this is what you get when you add bromine across a double bond. So you already know how to make substrates like this. We call this a visceral dibromide. And that means they're on neighboring carbons. And down over here, where the two halogens are on the same carbon, we call that geminal, a geminal dibromide. And I may use that terminology. I may say, oh, if you add two equivalents of HCl to an alkyne, you get a geminal dibromide. So I expect you to understand the distinction between a geminal dihalide and a visceral dihalide. You already know how to make visceral dibromides just by adding Br2 across double bonds, just like that brominated vegetable oil. Yes? Do you use dichloride or? Dichloride, whatever I say. If I said dichloride here, I meant dichloride. Yeah, geminal dichloride. Oh, oh, here, yes. Ah, yeah. Dichloride, thank you. Geminal dichloride. Okay, so let's talk about these two conditions. You need powerfully basic conditions to do these double elimination reactions. And those powerful conditions are worth talking about. Amide anion bases. Boy, those are going to be super important. Not sodium amide, but lithium amide bases when you get to chapter 23 and 24. And in modern organic synthesis. So I really want you to start getting used to this sodium amide, even though it looks strange. Okay, so let's go ahead and take an example where we're doing another one of these elimination reactions. And I want to just focus in on this. So here would be yet one more example of doing a double elimination to make an alkyne. So there's my substrate. And I'll eliminate H and Br from one side and H and Br from the other side. And let's talk about these fancy new conditions with the two equivalents of sodium amide. Don't write EQ for equivalents. That means equation. That's the abbreviation for equation. I didn't invent that system, but you have to write EQ all the way out. The American chemical society decided on that abbreviation system. Okay, so this would be a way to synthesize an alkyne from this two carbon piece. And this would give a terminal alkyne. Pretty sweet reaction there. And I promise you that will be on this, some form of this reaction will be on some exam in every single section of Chem 51C. So these types of elimination reactions are totally money reactions. And I'll explain why later it's so useful to make alkynes and specifically terminal alkynes. Okay, let's talk about the basicity of these conditions. And it's like what's the deal with potassium tbutoxide and the heat? And what I want to do is I want to draw a typical series of compounds slash functional groups so we can talk about the basicity of those. So let's compare ammonia. That's pretty nucleophilic and pretty basic. You'll have a whole chapter on amines and ammonia coming up later in the book. Much later in the book, I think around chapter 27. And I want to compare a series of compounds that you may have seen used as basis. And we'll compare these with this amide anion. So let's come back over here and compare that with an amide anion. There it is. It looks kind of like ammonia except for that minus charge there. So let's go ahead and compare the relative basicities here. And I'll write this out. Relative basicity. You can get this by looking up the pKa's of the conjugate acids. There's a pKa table in the back of the book. Just by knowing that the pKa of an ammonium ion, if I stick a proton back on there is 10 and the pKa of water is 16, I would know from that the relative basicities of ammonia versus hydroxide anion are about one to a million. So hydroxide anion is a million times more basic than ammonia. A million times more basic. That's a huge difference in basicity. So so far in this book and in the Kim 51 series, you haven't been using amines as bases a lot. They've gone straight to hydroxide anions. I forgot to put this minus charge on tbutoxide over here. And so how much more basic is tbutoxide than hydroxide? It's actually 100 times more basic. So relative to ammonia, tbutoxide is 100 million times more basic than ammonia. See, it's not just that it's sterically hindered relative to hydroxide. It's also more powerful by a factor of 100. But you know what? If you ask a typical organic chemist about the relative basicity of hydroxide and tbutoxide, most organic chemists would tell you, oh, that's about the same basicity. Factor of 100 is just, that's nothing. Let's talk about the relative basicity of sodium amide. I think there's 20, does it matter how many zeros? I think there's 23 zeros there. You can't just write 10 to the 23. You won't get a sense for how much more basic it is. So when I want a base, a powerful base in organic chemistry, I don't go to the shelf and grab a bottle of tbutoxide. I go get some sort of amide anion base. So once you see that, now you can sort of see why I often times say, oh, hydroxide, tbutoxide, those are pretty similar. Compare that with an amide anion. So I want you to respect the huge basicity of an amide anion. It's also more nucleophilic than these others, but it's such a powerful base. You never see it do nucleophilic reactions. It always grabs protons first. Okay, so yes, you can use tbutoxide to eliminate to make alkynes if you want, but I want you to heat if you're doing that. With sodium amide, obviously, you don't need to heat that. You typically need to cool those reactions down so they don't go exothermic on you. Wow, so powerful basicity. And we'll use it for two completely different reactions in this chapter, sodium amide anion. Okay, so let's talk a little bit more about this regio, about this elimination reaction to make alkynes. It's an E2 elimination reaction. So let me draw out a substrate with a geminal dichloride in there. So here's the geminal dichloride functional group. And you can see that carbon that has two halogens on there, there's an ethyl group on one side and a propyl group on the other. So if I come, that means both sides are not equivalent. So if I come along and employ my, I'm so excited about my super new sodium amide anion base, and let's throw, suppose I add in two equivalents of sodium amide NH2. I'll get two different products out of this reaction. Let me draw those hydrogen atoms here, just so we can be clear about the fact that there's hydrogen atoms on both sides. So ultimately the reaction is an E2 elimination reaction twice over, and so what's happening is the amide anion base. I'll go ahead and draw that in here. I'm not going to draw the full mechanism. Here's my amide anion base. Super basic, wow, super duper basic. It can come and do an E2 elimination on either side, and it doesn't care, right? Here's one way it can go. That would be the first elimination, and I'm not going to draw the intermediate, but amide anion doesn't know the difference. It sees two sets of hydrogens. It's not going to make any distinction between those. So as a result, let me redraw my six carbon chain here. One, two, three, four, five, six. What I find is people very often make a mistake in drawing out how many carbons there are. So I'm going to just draw the triple bond, even though this is distorted in a really ugly way. It's kind of hurting me to see an alkyne without 180 degree bond angles, but I'm just so adamant that you have some tool at your disposal that helps you to not forget to put in one of the carbons. So let me draw another six carbon chain, so I don't forget to draw any of the carbons here. You know, I might have drawn the wrong number of carbons here. Yeah, I've got an extra carbon, so you have to just erase that from your mind there, that other carbon atom. So you can't really stop this from eliminating in the other way, and that would be to put the alkyne on the other side. So you could have done another two eliminations of HCl if the amide came and deprotonated on the other side. In other words, you would get a one to one mixture of these. If you had isopropylone, yeah. Why wouldn't you form an alkyne? Because you know, why is it either side of the alkyne? So the question is, why wouldn't you form this? Is that your question? Yeah, that's called an alene, and there's a secret to this reaction, and that is that it's under aquilibrating conditions, and you'd actually get some of this initially, but it'll equilibrate to this, and I'm just simply going to tell you don't worry about that. Just assume that it never forms like we never discussed it, and thank you for asking about that. So good question, and it does happen to some extent, but it'll end up isomerizing over to the alkyne, and you don't need to know anything about that. Okay, so there's this issue of regio control. This is typically why I would never try to use this reaction to make an internal alkyne. It's this lack of regio control when you do elimination reactions from geminal dihalides. So again, if I ask you what's the product of this, because they're basically in a one to one mixture, there is no major product. You have to write both of them. That's awful when there's no major product. Okay, so I just showed you how to make alkynes. You've really got just one reaction. That's double E2 elimination with either sodium amide or potassium tbutoxide and heat. Okay, so let's talk about what you can do with alkynes. Remember there were five reactions that we learned back in chapter 10 where we added things to alkynes. We added HCl and HBr to alkynes. We added halogens like bromine, like brominated vegetable oil and chlorine Cl2 to alkynes. We made bromohydrons. We did hydration reactions with sulfuric acid and water. We did hydroboration oxidation. We're going to do four of those reactions without alkynes. We're not going to do the bromohydrin or chlorohydrin formation. But the other four are same reagents. We're going to apply those same reagents to alkynes. And so let's start doing that. I'm just going to walk you through those same four reagents. Hopefully you may think, God, this is boring. It's the same stuff. Okay, but it's at least good practice to learn it again in the context of alkynes. So let's go ahead and start off. And it adds a little bit of a twist to the fact that there's two pi bonds in an alkyne. Okay, so here's a four-carbon alkyne butyne. And if we come along and add HBr to this, and in this particular case, I'm going to write out, adding two equivalents of HBr. So we can add HBr across the pi bonds of this alkyne in the same way that you can add HBr across the pi bond of an alkyne. And what you can't be sure of yet until we discuss it is where those two bromines end up. So one of them will end up at the more substituted carbon. Ah, it's Markonikoff addition. Where does the second bromine end up? So we're adding HBr. You can't quite tell, but I added an H over here. I'll draw the H that I drew. So the first addition goes here. Where does the second HBr go? And it turns out the second HBr go with the same regiochemistry. So you end up with the geminal dibromide when you add two equivalents of hydrohalic acid across an alkyne double bond. Okay, so let's walk through the intermediates that are forming in this reaction. So initially, what's happening? Let me go ahead and draw out the mechanism for this to get us started. This will end up adding HBr across this double bond. And I'll talk about the carbocation. So get ready to be freaked out here. So let me just skip that mechanistic intermediate. Just momentarily. And after this second addition of Br minus, initially we're going to have this intermediate in the reaction. If you wanted, you could stop the reaction at this stage where you've added just one equivalent of HBr across this double bond. You've added one equivalent of HBr across the double bond. You could stop just by adding one equivalent. More commonly in the book, they get you to add the second equivalent of HBr to make the geminal dibromide, which you can then use to make alkynes through dehydrohalogenation reactions. Okay, we'll come back to the carbocation intermediate that you generate in just a moment. I don't want to freak you out with that immediately, but it's going to be very freaky. Get ready. Okay, so you can add HBr across double bonds. You can add two equivalents of HBr across double bonds. And guess what? HCl, it's the same thing. I'm not going to redraw an example for you where you add HCl across a double bond or a triple bond. You get that idea. Okay, so that's one of the reactions we're going to learn with alkynes. Let's talk about another common reaction that you're going to see over and over with alkynes that's related to that sodium amide that we just talked about. This is just general reactivity. Whenever I see an alkyne, there's two things I want to do with it. I want to add things across the pi bonds. And I also want to convert it into a nucleophile. So we're going to talk about four different reactions where we add electrophiles across the double bond. And then we're going to introduce one new reaction that's nothing like alkyne chemistry. And here's that new reaction. And it's a reaction that is specific to terminal alkynes that have a CH at the end. And you are going to use this and use this and use this and overuse it for the next nine chapters until we show you some really good nucleophiles. So if you take sodium amide and you add it to a terminal alkyne, remember I showed you you could use sodium amides to do E2 eliminations of viscinal dibromides or dihalides and geminal dihalides. But if you have a terminal alkyne that's already there and you treat that with sodium amide, this is such a powerful base, this amide anion that it will rip off this proton from the end. Let me draw that lone pair here and I'll put minus here next to my amide anion and plus next to the sodium. Here's what happens. Remember how basic that sodium amide anion is? And you haven't seen anything like this before. Wow. That is powerful stuff. I'm pretty sure this is the only case so far where you have seen that we deprotonate any kind of a carbon atom in order to make a carb anion nucleophile. And that's the point of doing this is that is now a carb anion nucleophile. There's sodium floating around and look at this. The byproduct of that process is ammonia and you may be super tempted to want to pull the proton off of that ammonia and go back in the other direction but it doesn't work that way. The equilibrium lies on the side of this alkyne anion. We'll talk about this. It's called an acetylide anion. So this is the point of this is you'll make this super powerful carbon nucleophile and we're going to show you that you can use that to make carbon-carbon bonds. Okay. So two types of reactivity for alkynes. The triple bond itself here acts as a nucleophile and adds to things like BR2, HCl, hydration reactions. And then the other pattern of reactivity is with terminal alkynes that we can deprotonate them to make super powerful carbon nucleophiles so that you can construct organic compounds. You can use it as a way to synthesize very large organic compounds in chapters 11 through 20. Okay. When we get to chapter 20 and from then on you're going to stop using these because we'll show you a much more powerful set of carbon nucleophiles where you have carbon magnesium bonds and carbon lithium bonds. But until then this is all you've got. And as I said the book over uses that because once you get to chapter 20 you're never going to talk about those again because we got something that's so much better. Okay. So let's talk about this in detail. Let's talk about this addition of HX, HBR, and HCl across the bonds. I was afraid to talk about that carbocation intermediate but now I don't want to be afraid to talk about that carbocation intermediate. So here let me come back to that four carbon chain that I drew before. This is butyne. It doesn't matter that it's a terminal alkyne. Remember we said that these undergo Marconikoff addition. The mode of addition puts the proton at the less substituted position and the nucleophile will end up at the more substituted position. So if I draw out a mechanism for this reaction where I add HCl, so I guess if I drew the reaction I would draw HCl above the arrow. And the initial product of this reaction where you have Marconikoff addition would put the halogen nucleophile at the more substituted position. And I'll draw the H. There's two H's here. But I'll draw one of them there for you. So you can see we added HCl across the double bond. So notice that the chlorine doesn't end up on carbon one. It ends up on carbon two. Okay, so let's draw the arrow pushing mechanism here for this reaction. It's just like alkenes. You take an arrow and you show that one of these two pi bonds in the alkyne, there's two pi bonds there, attacks the proton, acts as a base and deprotonates HCl. And you can't tell where I'm going to stick that proton yet. Well, I guess you can look at the product and tell. But let's draw that intermediate. Here's the carbon atom that's left over there. And there's the ethyl group that's sticking off. You've never seen anything like this before, right? So if that looks really freaky to you, good. I want that to look really freaky. And the next, you can guess what's going to happen on the next step here. I've got chloride anion floating around and it's going to come in and do a nucleophilic attack. So overall, if you can get over this weird looking carbocation intermediate, this is just like we saw in the last chapter where we took alkenes and added HX across the alkenes. So let's talk about this intermediate. We call this a vinyl cation. It's not called WTF. Let me just, let's talk about vinyl cations. Because I hope you've never drawn this before. If you've drawn this before or now, then it was a huge mistake on your part. And it's the same idea if you add HBR. You'll also generate the same vinyl cation intermediate. But I don't want you to get all excited about vinyl cations because they're very unusual. So let's talk about vinyl cations. So I'm going to draw this vinyl cation here. And I'll talk about two potential approaches to make a vinyl cation. I'm using a little dot there to represent the carbon. Actually, let me draw an empty P orbital there. That'll make me feel more comfortable. Okay, so there's my vinyl cation intermediate. And the way I just showed you to make those is to take some sort of an alkyne. You could have R groups on both sides of the alkyne. And you add HX across that, some sort of an acid. And yes, it could be sulfuric acid that protonates that. It's the same idea. So this is okay. And it has to do with the fact that an alkyne functional group has an intrinsic instability and reactivity associated with it. But here's what I don't want you to ever do. I don't want you to ever think that you can take some sort of a vinyl halide and do an SN1 reaction. Okay, let me just draw a dashed arrow. And I'll just write no. Not just no, but never. So a vinyl halide, you never do SN1 and you never do SN2. You don't know any mechanisms yet by which you can substitute a vinyl halide with a nucleophile. So why is it that you can make vinyl cations from alkynes but not from vinyl halides? It's simply because alkynes are a more reactive type of functional group. They want to react and do things. So I hope you already knew that. And if not, let me just emphasize that. How do you make vinyl cations? Here's some substrates, the typical substrates that you're going to see in this chapter and in coming chapters where you're going to want to do chemistry with the halogens. You all put a tosally done there. Look at those great leaving groups. Boy, the book made such a big deal about what great leaving groups halogens are in chapters 7 and 8. That was the whole focus of the chapters. And yet, even though those are great leaving groups, when can you do this? Never. I'll just write no, don't do that. You can't generate a vinyl cation that way. When can you do this? No, never, not ever. Oh, guess what? On this benzene ring? Now, I don't, I hope I don't have to keep, don't. So you have to resist this temptation. Your temptation will be, oh yeah, Van Franken says, vinyl cations, they form easily from any, no. Just when you protonate an alkyne. You can't do SN2 reaction. So let me just super emphasize this, that there is no mechanism of substitution that you yet know that allows you to substitute. So in other words, it's not just SN1 you can't do. You also can't do SN2 on vinyl halides. It's not that you can't do chemistry of vinyl halides, but not SN1 and SN2 business. Okay, so vinyl cations, no problem if you start with an alkyne, but don't try to do substitution reactions through SN1 or SN2 on vinyl halides. They're special. Okay, so let's talk a little bit more about this HX business, addition of hydrohyalic acids across alkynes. And I'll draw maybe a more full mechanism here. This time I'll take an internal alkyne, also a butyne, but this time it's internal, it's 2 butyne. And so if we add two equivalents of HCl, as I just showed you before, because my substrate is symmetrical, there's a methyl group on one side, there's a methyl group on the other, I don't have to worry about regiochemistry issues. But remember, when you add HX, the 2X's, the two halogens end up on the same carbon. And I'm not going to draw where the 2H's went. I hope you can see that they're over here on this carbon that's a CH2 group. You could also have made the same product by taking a vinyl halide. If somebody gave you a vinyl halide and said, here you go, here's a vinyl halide, you could also add HCl to that. And it'll give you the same, just by adding one equivalent of HCl. So if there's a halogen, or if you already have a vinyl halide, you can add HCl across that pi bond. Okay, so let's talk about these intermediates. I'm not going to go through the mechanism with the first addition of HCl across that double bond. It goes through a vinyl cation intermediate. But the first addition will give me H and Cl added across that double bond. And you get a mixture of E and Z isomers here. When you add one equivalent of HCl, you also get, so this has the high priority group here is chlorine and the high priority group on this other carbon is methyl and those are opposite sides. So this is the E isomer. Let me just write that there. This is the E isomer of the alkene. And you will also get an equivalent amount of the Z isomer where the chlorine and the methyl are on opposite sides. And that's because the chlorine attacks from both sides of the vinyl cation, both ends of the P orbital on the vinyl cation. So you'll get a mixture of isomers. That's not very useful. And that's typically why people don't just add one equivalent of Hx to an alkyne. That's internal because you'll end up with this mixture of isomers and who wants to get a mixture of isomers? But we can take either of these. It doesn't matter which one. They both react in the same way. And add a second equivalent of HCl. Let me draw out the mechanism for addition of that second equivalent. So now when we add that second equivalent of HCl, here's the mechanism. I didn't show you the mechanism for the first addition. And it's the same arrow pushing if I use the Z isomer. And the product that you get out of this has a carbocation next to a halogen. And we'll talk about that in just a moment here because that may look strange to you. What does that mean? Is that a secondary carbocation? Is that more stable than secondary or less stable than secondary? We'll talk about that in just a second. And then that chloride anion attacks that carbocation and that's why you get the geminal dichloride. So again, the second addition of HCl occurs in what you would call a Markonikoff fashion again. It will give the more substituted carbocation. And from an empirical point of view, you can consider the chlorine just like an alkyl substituent. In other words, you generate the more substituted carbocation, whether it's substituted with methyl or chlorine. Okay, so what's up with that carbocation that has a halogen next door? Let's talk about the effect of halogens in general. I'm going to compare two different four carbon compounds, butyne. And if you take butyne and you react that with HCl, there's an addition of HCl across the double bond. And I'm not going to draw the full mechanism there. But if you compare the rates, what would happen if I compared the rates of addition? So you'd get as a product of this vinyl chloride here. Plus you'd also get the other isomer. You'd get the Z isomer as well. I'm only going to draw one of those isomers. Actually, just so you don't worry about that later, I'll go in right plus. This is the E isomer, so you also get plus the Z isomer as well. The point is that if you've got still have HCl floating around, the next molecule of HCl that comes along has to make a choice. Should I add to the alkyne starting material? Or should I start adding to the product as it forms? Which is faster? And it turns out that chlorine has an electron withdrawing effect. And so this second addition of HCl is slower than the first one. That's why you can stop adding one equivalent of HCl across the double bond. If the second addition were faster, every single alkyne would immediately add a second equivalent of HCl and you wouldn't be able to stop at one addition. So the first addition is faster, the second addition is slower. So if you wanted, you can just add one equivalent of HCl and it will just add once. And you can stop at a single addition. Okay, let's talk about the carbocation that you generate if you do throw in a second equivalent of HCl. Let's draw this carbocation that has a halogen attached there. Because I don't think it looks anything like anything you've seen before. And I want to talk about two contrasting effects of that halogen atom on there. So what does that mean if you have a carbocation and one of the substituents is halogen? The problem with atoms like chlorine or oxygen or nitrogen is that there's two completely different and opposite effects. And you don't know which of those effects is going to win in terms of carbocation stabilization. I think the first and most obvious effect to me is that chlorine is electronegative. You know, there's all these protons in the nucleus of chlorine. That's what electronegativity is about. There's all these protons with a positive charge. They all have positive charges in chlorine. And they hate being next to this carbocation that has a positive charge. So that's an effect of electronegativity. The fact that chlorine is electronegative stabilizes, sorry, destabilizes the carbocation, right? You don't want to have electronegative atoms next to carbocations. But there's a second effect of halogens or nitrogen or oxygen. And that is that they have lone pairs on them. Let me draw those lone pairs. And it only takes one, but I'm going to draw three just to emphasize it. So there's a second effect. And that second effect is that the lone pairs stabilize the carbocation. Right? By donating into that empty P orbital. On the one hand, chlorine destabilizes the carbocation. On the other hand, the lone pairs on chlorine stabilize it. Which one wins? It's the lone pair stabilization that wins. So overall, this is more stable than a similar substrate that has no chlorine there. And so that's why, if you have this kind of vinyl chloride and you add a proton to that. That's why you add the proton to the less substituted carbon. What you do not do is you don't add the proton to the carbon that already has the chlorine on it because this would be a less stable carbocation. I'm going to stop there. When we come back on Friday, be here early. Be here at 10 till so you can take a seat. If we're not in our seats with our exams on time, then we're going to start later. We have to be out of here for the next class on Friday.
This is the second quarter of the organic chemistry series. Topics covered include: Fundamental concepts relating to carbon compounds with emphasis on structural theory and the nature of chemical bonding, stereochemistry, reaction mechanisms, and spectroscopic, physical, and chemical properties of the principal classes of carbon compounds. This video is part of a 26-lecture undergraduate-level course titled "Organic Chemistry" taught at UC Irvine by Professor David Van Vranken. Index of Topics: 00:10- Gatorade to remove controversial ingredient 02:36- Soybean oil vs. brominated vegetable oil 05:20- 11.2,11.3,11.4: Names, Properties, Examples 11:00- 11.5: Make Alkynes Through Dehydrohalogenation 16:48- 11.5: Super Basic Condns 22:29- 11.5: Make Alkynes Through Dehydrohalogenation 26:38- 11.6: Alkyne Reactivity 30:54- 11.6: Alkyne Reactivity, Slide 2 34:13- 11.7: Addition of HX to Alkynes 37:17- 11.7: Addition of HX to Alkynes, Slide 2 41:24- 11.7: Addition of HX to Vinyl Halides
10.5446/19477 (DOI)
Nick, one of the TAs, Nick Sizemore, turned me on to this recent news story. So over in England there were a lot of residents who were starting to complain about a very bad smell. And it was very quite widespread, areas Hampshire, Dorset, Oxfordshire, Northampton. And the leak was blamed on a chemical factory in ruin. And the gas, they say, that was causing this smell is mercaptan. And so I want to talk about mercaptan and let's try to introduce ourselves to this class of compounds, which I really associate with, very strongly with one word. And that is it, they smell bad. So there is no actual compound called mercaptan. Mercaptan is actually a class of compounds. And in modern nomenclature we call mercaptan's thiols. The name mercaptan comes from the fact that thiols form very strong complexes with mercury. And so usually if you have a mercury spill you add sulfur compounds to stick to the mercury at the atomic level and clean those messes up. So here's two of the most common mercaptans, two of the most common thiols. So if any of you have ever smelled natural gas, like maybe you left your stove on too long or any source of gas in your house, it stinks really badly, which is great because you don't want to sit in a house breathing natural gas. You've never actually breathed or smelled natural gas. What you're smelling are mercaptans. They add mercaptans. They add thiols to the natural gas so that it will smell so bad that you won't stay in a room with natural gas leaks in them. And what they do is they take the natural gas and they mix it in about one to a million ratio with these compounds. They are so potent that you can't possibly bear to be in their vicinity. So we don't use the term mercaptans anymore. Nowhere in the book do they use the term mercaptans. An old compound, an archaic compound, or sorry, an old name and an archaic name. I'll use the word thiol in this class to discuss this class of compounds. Just to give you a sense for the potency of thiols and their smell, let me just show you a little map. Because if you're not clued in, the town of Ruin is not in England. It's in France. So the Lou Brasol factory was down here. So this is the continent of Europe. And the smell wafted all the way over here to England where all these residents had to smell it. So I can't even imagine the potency of these compounds. And I can't even begin to imagine how bad it was for the people living in northern France here. Of course, the English were the ones who were complaining the most because they didn't create the smell. So you'll know it if you ever smell a mercaptan or a thiol compound. That's the smell of skunks. That's the smell of rotting eggs. Really atrocious stuff. And that's the smell you smell in natural gas. So let's return back to, oh, point of order. We have an exam next Friday. So it's Friday today. One week from today in this room at 8 o'clock, we're going to have an exam. So what that means is we're going to have extra office hours next week. Those office hours are posted on the course website. So you can refer to that. In addition, that means we're not going to have discussion sections next Friday. So if you are in a Friday discussion section, go today. And next week, find a different discussion section to go to because we won't have discussion section next Friday. And it won't help you as much to have that discussion section after the exam. So again, Friday discussion sections, none of those next week, go to a different discussion section throughout the week. And those discussion section times are also posted on the course website. OK. So let's come back to our lecture on alkenes and alkene reactivity. So this is what I already showed you this slide a long time ago. I said chapter 10 is about five reactions. We're going to take five reactions and so many different ways we're going to bludgeon you with those reactions. So we've spent all of our time so far just discussing this one reaction, the addition of HBR and HCl and hypothetically HI to CC double bonds. We talked about the stereochemistry, the fact that you can add the proton from the top face or the bottom face of the CC double bond. We talked about the fact that once you create a carbocation, the nucleophile can attack from the bottom face or the top face. So we made all these big deals about the fact that there's two different faces to the alkene, there's two different faces to a carbocation. So now we're going to spend the next two lectures that's today and Monday talking about these next four reactions in detail. So because we have our last lecture on chapter 10 on Monday, I extended the deadline for the first problem set, the sapling homework, until Monday night. So you don't have to finish that by Sunday. You have until Monday because we'll finish the last lecture probably on hydroboration on Monday. And there's a note on the sapling website saying that the deadline was extended to Monday night from Sunday. So let's come back to these reactions. We've got these other four reactions, number two through four here, that we want to know something about in detail mechanistically. And I won't need to go into as much detail now that we've spent so much time talking about addition of HX, HBR, HCl, things like that. So you can add hydrohalic acids across CC double bonds. And the reaction starts off with protonation. We're going to do the same thing with water. Now water is not very acidic, so we add an extra acid. You have to add an extra acid when you do these reactions with water, otherwise the reaction just won't go. And so the pattern you need to recognize is that if you take a double bond and you mix that around with stirred around in water and you have a sulfuric acid as a catalyst, you add water across that double bond. You add H and OH across that double bond. Now you probably can't see the H that I added because we typically don't draw H as I'll draw it for you here just so you can see. There's the H from the water and I think you can see the OH from the water. So this is a very hard reaction to see just like the addition of HBR because you can't typically see where the proton went to. And so you're going to have to work enough problems to where you're used to that type of pattern. Okay, so if we did the same thing down below, now that you're an expert with this hydration is what we call it. Acid-catalyzed addition of water is hydration. It sort of makes sense with the name. So now let's go ahead and talk or apply that reaction to this substrate and I use pH as an abbreviation for a benzene ring for a phenyl group. So I'll write pH down there. And so based on what I just showed you, I add OH down here and I add H up above. Now notice I didn't create a stereogenic center. In this particular case I chose molecules that would not give a new stereogenic center. So there's no enantiomers in this case. Let me go ahead and draw, you don't have to draw the H but I'd just like to show you where that H went to so you can see. Yeah, I added H and OH across a double bond. So that's hydration and you need an acid catalyst to make this work. Water is not acidic enough to make this reaction work. So let me admonish you not to believe that every single acid is the same because I will count you wrong if you use, don't use HCl or HBR or HI for your acid. I just showed you in the previous lecture what happens if you have HCl and HBR and HI floating around with double bonds. So the problem with these is that these counter ions, things like chloride with its lone pairs, bromide with its lone pairs, iodide with its lone pairs, all three of those counter ions are nucleophilic and the last thing on the planet that you want is another nucleophile floating around in this reaction. So that's why you don't want to use those acids. You want to use sulfuric acid. As far as I know that's the only reaction we will, or the only acid we will show you that you should use for acid catalyzed hydration. So in contrast, let me just, so why is it that we use sulfuric acid? Let me go ahead and draw out the counter ion, the monodeprotonated, I don't know if that's a word, form of sulfuric acid that's called the bisulfate anion. You don't need to know that terminology. So bisulfate anion has very, very, very, very low nucleophilicity. Why don't I just say no nucleophilicity? If sulfate accidentally added to a carbocation, it would pop right back out again. And for halides, that's not the case. It's not as fast for them to pop back out. Okay, so sulfate is super non-nucleophilic and a super good leaving group and so that's why you can get away with sulfuric acid and don't use any of those other acids. Okay, so that's a pretty easy idea in terms of the pattern adding H in some nucleophile across a double bond. It's kind of like HBR and HCL and potentially HI, but that's not used very much. Okay, let's talk about the mechanism for this addition of water across a double bond. The mechanism is going to be very similar to the mechanism that I showed you for the addition of HBR earlier. So let's go ahead and draw a mechanism here. I'll go ahead and take a substrate that is not symmetrical. We get Markovnikov addition with addition of water. And the reason why it follows Markovnikov's rule, where you protonate the less substituted double bond and the nucleophile ends up on the more substituted carbon, is because we're going to generate a carbocation. So the first step in this reaction mechanism, I'm going to protonate the double bond and I'm going to symbolize my acid, sulfuric acid or whatever it is. There's lots of acidic species floating around here. I'm going to symbolize those with this HA and I'm going to use that for my arrow pushing. So the first step is for some acidic species to come along and protonate that double bond. So I'll start my arrow from the middle of the double bond, attack the proton and displace the A minus counter ion. And so now when I get my intermediate, there's now a proton attached. And so now here's my tertiary carbocation. That's lovely. If I had protonated and you can't tell where I put the proton, it's sort of invisible now because organic units don't draw, but I'll draw it for you here. Just so you can see, I'm going to use my little pen because I don't want to overemphasize this. Okay, so that's where the proton went to and it leaves behind a tertiary carbocation and I did not add the proton to the bottom carbon because that would have left me with this sucky secondary carbocation and you don't want to generate sucky secondary carbocations. So now you've got this carbocation and if you're in the presence of water or any alcohol, so notice how I'm going to make this generic. It doesn't have to be water. It could be ethanol, propanol, something more complex. If you want, you can replace the R with H so it looks like real hydration. Okay, so now this carbocation is floating around and you already know the rest of this. We spent a lot of time talking about the chemistry of alcohols and alcohols attacking carbocation in chapter 9. So when you attack, I now have this oxygen attached to carbon. The proton is still there. I have three bonds to oxygen. That means it has to have a positive charge. It's an oxonium ion. Oxonium means oxygen with three bonds. So now I can use the conjugate base from my acid. That A minus is still floating around. Here's my A minus. It was floating around in the previous step and I simply didn't draw that. Okay, so there's my conjugate base from that original HA symbol, the acid. And so I'll simply use that to recapture the proton. I'll deprotonate that oxonium ion and give the electrons back to oxygen, which is electronegative. And so this is what leads you to your final product in this case. If you're adding an alcohol, you end up getting an ether. If you're adding water, you end up getting, in this case, a tertiary alcohol. Okay, so a couple of notes about this reaction mechanism. So the mechanism in this case is the reverse of acid-catalyzed dehydration that we saw in chapter 9. So back in chapter 9, we showed you a mechanism for adding sulfuric acid to alcohols and eliminating to give double bonds. It was a three-step mechanism, just like this is a three-step mechanism. The reaction coordinate diagram had three humps, just like the reaction coordinate diagram has three humps for this. So it's the same mechanism, just the reverse, as acid-catalyzed dehydration. So tricks to this, again, notice in my mechanism, I'm abbreviating my acid as HA. Now could you draw a mechanism using sulfuric acid rather than writing HA? In theory you could. The problem is once this reaction starts going, you have all kinds of acidic species floating around in your reaction mixture. You've got sulfuric acid floating around in your reaction mixture. You've got protonated water floating around in your reaction mixture or protonated alcohols. You don't actually know which of these two species is donating protons to the alkene. When you have acid in the presence of alcohols, it very, it instantaneously creates this equilibrium between protonating the alcohol and having the proton on the sulfuric acid. So because you don't know what's protonating the alkene, that's why it's better to symbolize your acid with HA. And I think it's simpler to write HA than to write these other things, isn't it? Probably. So, okay, so acid-catalyzed addition of water or of alcohols, that's the mechanism. Okay, so again, because we covered the reverse reaction in so much detail, we don't need to make a big deal about hydration or addition of H and OH across double bonds. So let's skip to the third of those five reactions we're going to cover. And again, this is very similar to the addition of HBR and HCl in that you generate a carbocation and something adds to it. Okay, so the third of those five reactions we're going to cover, totally new and exciting because this is different from that HBR addition. So you've already been, some of you have already had your discussion sections and been practicing using these new reactions. So when you add halogens, molecular bromine or molecular chlorine, BR2 or Cl2 across a double bond, each carbon of the double bond gets a halogen. And so I'll show you two, I'll show you a simpler example of this reaction. So here I'll take a simple alkene. And the reason why I consider this to be a simple example is that when I add BR to each of those two carbon atoms in the alkene, I don't create a stereogenic center. So this is a simple application of this. But things can become a little bit more difficult if we have to worry about stereochemistry. And so I'll take this cyclic compound down below here and there's a double bond. The oxygen doesn't do anything. I just put that into this example because I'm tired of drawing simple alkenes. And so now we have to pay attention to the stereochemistry. We have to worry about whether the two chlorine atoms, chlorine acts just like bromine, do the two chlorine atoms add to the same face of the double bond or do they add to opposite faces? Are we going to get a syn mode of addition or an anti-mode of addition? Are the two chlorines going to be syn to each other or anti to each other in the product? And for this particular reaction, they end up anti every single time. So that's an anti-relationship. I'll just write anti down there. And I'll explain to you mechanistically why you get anti very shortly here. So of course, I've generated two new stereogenic centers here. The other product I'll get is the mirror image, which will also be anti, but it's going to be the mirror image of that. And that arises from the fact that the, I mean, well, I mean, you can't control. The reagent doesn't know how to form one an anti-mer versus the other. Okay, I will never ask you what happens if you add fluorine, molecular fluorine or iodine to a double bond. And that's because those reactions don't work. Fluorine will just give you a lot of pain and anguish. And iodine, simply the equilibrium is disfavorable for addition of I2 across a double bond. So bromine and chlorine are the only ones you have to worry about for this section. And those are useful reactions. I promise you you'll use them in this chapter. And I promise you you're going to be using, actually, all of these reactions you've learned throughout the rest of the Chem 51 Organic Chemistry series. Okay, let's talk about the mechanism for this reaction because it's different from HBr and water. HBr and water both started with the addition of a proton to a double bond to give a carbocation. And this reaction does not involve a carbocation. Okay, so it's a two-step reaction mechanism. And again, this is a super important point here because the one you're familiar with now forms carbocations and there's no carbocation in this reaction. Let's draw out our reaction here. I'm going to try to draw, I'm going to struggle here to draw an alkene sort of edge on with a three-dimensional kind of look. One of the substituents on my alkene will be sticking out of the board or my paper. And then the other substitional will be kind of sticking back. And we'll try to imagine what happens is my molecular bromine, I'm going to do a bromination reaction, comes down and approaches from the top of this alkene. So let me draw my Br2. So I wish I'd left a little more room here. Here's one of the Brs and here's the other bromine atom. Geez, I wish I had left more because the bromine-bromine bond is long. That's what makes it so reactive. I wish I had left a lot of room because I would have freakishly distorted that bromine-bromine bond to look super long. Okay, so the alkene has electrons and connects as a nucleophile and you know that bromide is a good leaving group. So I hope you won't be surprised when I tell you that the double bond is going to attack, not proton, but it's going to attack a bromine atom. You haven't seen that before. You're going to have a Br-act as a leaving group. You have seen that before. So what's weird here is that you're attacking a bromine atom. Say, well, you haven't seen that. Bromine is supposed to be a leaving group. When do you attack bromine? Well, when you have a bromide-leaving group attached to it. Okay, but the other part of this is because there's this pair of electrons, let's draw some of the valence electrons on this bromine here at the bottom. There's three lone pairs on that bottom bromine. And as this double bond is coming up to attack the bromine, it's taking electrons away from one of the carbon atoms. You're taking electrons away from one of these carbon atoms here. And as you're doing that, these lone pairs start to see that carbocation form and say, hey, I'm right here. I can do something about that. Watch this. Doot. See how simple that is? In other words, you don't form a carbocation. As you start to take away electrons away from one of the carbons, the bromine lone pairs give them back. So instead of generating a carbocation intermediate in this case, we're going to generate a three-membered ring species that you haven't seen before. This is the way it works with Br2 and Cl2. And there's still lone pairs here. Those aren't really consequential. So you have a positive charge on bromine. And so this is called a brmonium ion. I'll just give that a little name down here. What is it that makes this a brmonium ion? It's not the fact that it's a three-membered ring. It's the fact that there are two bonds to bromine. When there's two bonds to bromine, there has to be a positive charge. Bromine normally has one bond. If there's two bonds, you need a positive charge on that bromine ion. And this particular brmonium ion happens to be cyclic into a three-membered ring. So wow, that's special. You've already seen reactions that involve three-membered rings and positively charged. When you protonate it epoxides. So here's our protonated brmonium ion intermediate. I'm going to redraw this brmonium ion intermediate instead of continuing my arrow here. I'm going to redraw that brmonium ion because I want to emphasize, we'll just call this step one and we'll call this down here step two. And the reason I want to redraw this brmonium ion intermediate is I want to convey this idea to you. And I'm going to really distort this so it'll be memorable. That's my point here. Not necessarily show you something that's perfectly accurate. But I want to distort this to remind you that one of these bonds is almost pre-broken. If I draw it like this, maybe you'll remember it. What I'm trying to do is make it so that one of these bonds to the brmonium atom is really long and just ready to break at a moment's notice. Whereas the other bond between this primary carbon atom isn't about to break anytime soon ever. So this is the way our brmonium ion looks. Let me just write equals here. I'm just trying to depict it in this freakishly distorted way. And so now what happens is that when the bromine counter ion, this Br minus comes in, it doesn't attack this nice short stable bond here. It attacks this kind of pre-broken bond to the tertiary center. But what's important is this is yet another example of an SN2 reaction at a tertiary center. We already showed you that you always do SN2 reactions at tertiary centers with protonated epoxides. With oxonium ions and three-membered rings, you do SN2 at tertiary centers. And so here's another example. Another three-membered ring with that tertiary center. And so in the end, we've now got two different bromine atoms attached. And they've added from opposite faces of the alkene. They have to. Whenever you have a brmonium ion like this, the bromine atom and the brmonium ion is on one face of where the alkene was. And the Br minus has to come in from the opposite side. So you have to end up with this overall anti-mode of addition. Of course, in the product, the thing can swing all around this carbon-carbon bond, but the two bromines add from opposite faces. So that's why you end up with this anti-mode of addition because it goes through an SN2 reaction of a brmonium ion. And I'll just write SN2 because you may be uncomfortable writing SN2 at tertiary centers, but not with three-membered rings that have positive charge. So that's the mechanism. There's two steps. So this very weird addition of bromine to make a brmonium ion that has three arrows, three curved arrows, and then this SN2 opening of the bridged brmonium ion. Okay, so let's walk through some examples that will allow us to see what's the stereochemical implications of this idea that we form a brmonium ion and then the bromide anion pops it open from the opposite side. Let's practice that on some substrates here. See if we really get this Br2 addition, the addition of bromine. So here's a reaction of just a very simple alkene. And I'm going to draw the product of this. So typically on my worksheets and on my exams, I think most faculty members have exams where there's a reaction and an empty box and you have to write the product in the box. So what would I expect you to write? I mean, what's the answer you need to write for a case like this? Well, we're going to add one bromine atom to one of the carbons and then we're going to add another bromine atom to another carbon. But you have to pay super close attention to the fact that you just created a stereogenic center right here. And I'm arbitrarily going to draw this with a wedge coming out of this. There's another H that's going back. So this is one enantiomer that is formed in the reaction. You also form the other enantiomer. This enantiomer forms because the initial bromine gets added from, well in this case, the back face and then the Br minus attacks from the top. But it's just as likely that you'll get the opposite mode of addition in terms of which face of the olefin reacts. So you'll also get this other enantiomer. And if you don't feel like drawing that other enantiomer, you can simply write plus E. And in my class, we will understand that to mean that you have a racemic mixture, one to one, of the two enantiomers, the two mirror images of the product in this class. So I typically will start writing simply like this. I'll simply say plus E. And we'll all understand to mean that you get the enantiomer. Okay. So let's take a look at a cyclic molecule here. And I've got this methyl group. What am I doing? I forgot to simply redrawing my hair. Let me take that out. So we're going to add bromine across this double bond. There's that methyl group sticking on the other side. One of the bromine adds from one face and the other bromine adds from the opposite face. And I'm going to get an enantiomer out of this, plus E. And this was a very particular mesotype substrate with a mirror image plane of symmetry through it. So this is, notice how now that it's cyclic, you can really see that anti-relationship between the two bromines that added across that double bond. Okay, let's take another example of addition. And in this case, just like the first example, the two ends of the alkene are not identically substituted. This molecule has no stereogenic centers in it. That means there is no enantiomer in this particular case. But what you do have here is you have to worry about the fact that the bromine that's at this quaternary center can be either up or down. In other words, the bromine at the quaternary center can either be on the same face as this methyl group or on the opposite face. And I'm going to abbreviate this methyl group with ME to really emphasize the fact. It is just as likely that you will get a product in this case in which this bromine is on the opposite face. And that is not an enantiomer. That's a diastereomer. In my class, you may not abbreviate diastereomers by writing plus D. You have to literally draw them out. So the other product that you get, it doesn't matter whether I orient the bromine up or down. What matters is that I drew it with a hash mark. So the other product that you have has the bromine and the methyl group on opposite faces of the ring. So that's a diastereomer. It's not an enantiomer. There's no stereogenic center here. So if I look at this center over here next to the methyl, it's got identical substitution on top and bottom. So there's not four different substituents on that dotted carbon there. So let me just remind you that this is a diastereomer. And that's why you have to draw that. You can't write plus E. So don't write plus D for that to try to abbreviate. Why didn't we have this issue up above here? Well up above, whether I draw the enantiomer or not, one of the bromines is on the same face as the methyl. So I didn't have to worry about that. Okay, so look for the formation of enantiomers and diastereomers. You have to watch for that. And I'll ask, there's questions on the sampling homework to help you practice that. We have some questions on the problem set to help you think about stereochemistry. But stereochemistry suddenly becomes a big issue here in this chapter because so many of these reactions of double bonds create new stereogenic centers. Okay, let's talk about this four-membered ring case in a little more detail. So we can talk about the stereochemical implications of halogenation. Okay, let's look at the mechanism. And I'm going to once again try to draw my alkene in a way where I can really see that there's two faces, a top and a bottom face to the alkene. So I'm trying to draw this thing edge on. And here's my ethyl group sticking up. ET is my abbreviation for ethyl. And my bromine comes in. In this case, I'll show, I'm going to start off by first showing you the case where the bromine adds from the top face. So there's bromine, my molecular bromine. And here's my arrow pushing. I'm going to take the electrons in this alkene and I'm going to do something almost like an SN2 reaction. But remember there's that third arrow we have to draw in. So of course I'm popping out a Br minus leaving group. But remember there's these electrons here on bromine. All those lone pairs can see that we're forming a carbocation. They said, oh, we don't have to do that. We'll just come right in and attack so that you don't end up with a carbocation. It's that third arrow that's the bizarre one and the one that's hard for you to remember. Because that third arrow I just drew in green is nothing like you've ever seen in chapters 9, 8, or 7. And you're going to have to practice that. So once you add, in this case I'm showing addition of a Bromonium ion from the top face of that double bond and from the same side of the four-membered ring that the ethyl group was on. So I'll end up with this cyclic Bromonium ion intermediate. And I want to make sure I get these things just right here. So here's my Br. So that's my cyclic Bromonium ion intermediate. And I wish I'd drawn this, I wish I'd drawn an attack from the bottom face because now this is going to be sort of weird. So there's Br minus floating around still. And it's going to attack that Bromonium ion. But remember what we said. The Br minus attacks from the most substituted carbon. You get Sn2 ring opening on the most substituted carbon. So watch this. I'm going to attack over here on the tertiary center. And so this Bromine on the bottom side ends up attached. It's not a very good arrow, so sorry that doesn't look very good. So when that Bromine on the bottom side attacks, and here's why I wish I'd drawn this in a different way, and that's going to lead to this diastereome over here. So the Bromine at the tertiary center is now on the opposite face of the ethyl group. And the other product that we'll get out of this reaction is going to arise from addition of the Bromine from the bottom face. So let me try to redraw my two reactants here so you can see how you get this other product. There's Et on the top face. And if I add the Bromine now from the bottom face of that olefin, because the double bond has two non-equivalent faces, one face of the double bond is on the same side as the ethyl group, and the other face of that double bond is on the same side as that H that I drew on the bottom. So once again, I'll draw the double bond attacking. And then I have to remember to draw the lone pairs on Bromine coming back in and attacking one of the two carbons so I don't end up with a carbocation. And there we go. And again, that's the one that's going to be hard for you to remember. And this will generate a cyclic Bromonium-Ion intermediate. And again, these are the same two reactants. I'm just, I don't want to draw everything with one structure. And so now I'll get the Bromonium-Ion on the bottom face. There's my Bromonium where the Bromine is now on the bottom face on the same side as where the H is. I'm not going to forget my positive charge on Bromine. And so now when I draw this Bromide-Anion-Counter-Ion floating around, it's going to do an SN2 opening at the more substituted center. And that's going to lead to, and I'm sorry, my arrows are so messed up. This looks like some sort of bizarre road map. I did not do a good job of thinking this through. And that gives the other diastereomer in the reaction. Okay, so why did we get two diastereomers? We got two diastereomers because the olefin had two faces. And the initial Bromine can add from the top face or it can add from the bottom face. And you have to take that into account. There's two different faces to that olefin. And so you have to worry about that. Not in every case, but in this particular case it becomes an issue. Okay, so again you will see a lot of reactions where you generate relative stereochemistry, synananti, or you have to worry about absolute stereochemistry because you generate a stereogenic center and nothing short of practicing lots of problems will prepare you for that. Okay, so we've now talked about three reactions so far. We've talked about acid-catalyzed addition of HBr, not acid-catalyzed, but addition of HBr and HCl across double bonds. We've talked about acid-catalyzed hydration of water across double bonds or alcohols. We've talked about addition of halogens, Bromine and chlorine, Br2 and Cl2 that go through cyclic Bromonium ion intermediates. So I'm going to show you a fourth reaction now for this chapter that also involves a cyclic Calonium ion intermediate. So it's going to start out, first I'll just show you the way the products look. So here's a double bond and I've got Bromine and that looks deceptively like the reaction I just showed you. The difference is I have a hydroxylx solvent, either water or alcohol and immediately that is just screaming for my attention. I don't know what you see but here's what I see. So you might have just seen water like that but that's what I see and it's blinking on and off. I immediately know it's not going to be like that other reaction where two Bromines add across. So yes you do get a carbon Bromine bond but on the more substituted carbon it's not a halogen anymore. It's whatever your solvent was. If it's water you have an OH there and if you ran the reaction in alcohol like methanol then you have an omethoxy group there. So you have to look for that other water to look to see if there's a hydroxyl look at a solvent included. Now I've just generated a stereogenic center so I'm going to get the other enantiomer out of this where the hydroxyl is going down and I'm not going to draw that out simply right plus E. Okay so we also have to worry about this issue of relative stereochemistry. Here's another one of these cyclic substrates and so when I add this time chlorine, Cl and OH across the double bond they end up anti to each other. So this is another one of these cases where you have to pay attention to syn and anti relationships. So you get anti addition and I'll just write anti down here so we remember that. Wow that water is just, how can I, I can't miss that. I would never miss that. Okay so I get this anti addition so the other product you get out of this of course I've generated two stereogenic centers. The other product is also anti, it's the enantiomer which since it's a mirror image it has to be anti as well. It can't be something different. Now the book sometimes writes reactions using NBS, N-bromosycinamide. So sometimes you'll see stuff like this in the book, NBS and water and you don't need to worry about why the book chooses to use that reagent sometimes but in this reaction it does the same thing as BR2 and you don't need to worry about why. Here's the structure for NBS, it stands for N-bromosycinamide. The N is using traditional nomenclature, the N is in italics because it tells you which atom the bromine is attached to. So that's, if you're interested in what NBS is, this is the structure. We might see this later I think in chapter 15 when we talk about radicals and radical chemistry but for now you don't really need to know the structure because when I show you the mechanism I really want you to learn the mechanism for BR2, not for N-bromosycinamide. Okay, so let's walk through the mechanism for this reaction. These products where you have a hydroxy group, one carbon atom away from a halogen, these are called halo hydrons. So this is called halo hydron synthesis when you mix halogens like bromine and chlorine using water as your solvent. So these products with OH and BR or OH and chlorine are called halo hydrons. Okay, let's look at the mechanism. It's going to involve one of these bromonium ions so get ready. And you guys, by the end of this chapter you guys are going to be experts with these, with bromonium ion and chloronium ion formation. So kind of again I'm trying to draw this alkyne edge on so I can see that there's two different faces here. And so here's my bromine, my molecular bromine, it's bouncing around my reaction mixture, keeps colliding. And eventually one of the collisions leads to a successful bond forming reaction where this double bond now attacks the bromine and displaces the leaving group. And as I mentioned before, the arrow that you're going to be inclined to forget is this third arrow as that bromine gets closer and closer as I lift these electrons away from the carbon atom here, the bromine lone pairs will come back in and attack. And I could just as easily have drawn this with this arrow going onto the other carbon. The point here is I'm making a bond to each of the carbons. So if you wanted to draw this mechanism with a lone pair attacking this carbon instead of that one, you get the same product. But again what I'm thinking about as I draw this is gee it's going to start to form a tertiary carbocation or in this case secondary carbocation. But again I would count it correct if your green arrow attacked the carbon that's less substituted because that gives the same product, the same next intermediate. Okay, so let's draw our very exciting bromonium ion. There it is. Two bonds to bromine, that's why it's called a bromonium ion. This one just happens to be a strain three-membered ring. And now here's where it matters that we use the water as a solvent. You've got this cyclic bromonium and yeah there's some Br- floating around. Let me just draw that Br- floating way over here. It's kind of lost. Floating around looking for something to do. But of course since we chose to use water as the solvent there is water everywhere. So let me draw one of those water molecules everywhere right there. Look at that. Of course since water is a solvent there will always be a water molecule just dangling right below if we're using water as the solvent. So as soon as we form this cyclic bromonium ion it is much more likely that one of your many, many water molecules will attack than this Br- that's often outer space there floating away. And so you get attacked just like before at the more substituted position. Bromonium ions get attacked at the more substituted position. Protonated epoxides which are oxonium ions and three-membered rings get attacked at the more substituted position. And so this is what leads to… So now our water is down here at the bottom. I'm trying to draw my…this kind of pyramidalized. And of course the water still has its proton. There's no hydroxide anion in the reaction. What you'll see momentarily is that we've got…we're going to generate acid in this reaction. I'll go ahead and show the bromide finally coming into play but something will pull the proton off of there. I'm almost inclined to draw A- but I'll in this case draw it as Br-. If you chose to symbolize the thing you protonated with the generic symbol A- I would accept that. In fact I like that. Okay so now your Br- can float around and come back in and finally come around to deprotonating this. So I'm going to use my red pen again. So now that can pick the proton off. And that's what gives you the bromohydrin product that you finally get. You've created a new stereogenic center so that means you'll also get an enantiomer. So there's my bromohydrin. It's a halo-hydrin product. So you get the other enantiomer because it's just as likely that the bromine would have initially added from the bottom face of that alkene. The two faces are the same. There's no…at least as far as bromine is concerned. It'll spend 50% of its time attacking the top face and 50% of its time attacking the bottom face. And halo-hydrin formation gives you an anti-motive addition. The nucleophile adds on the opposite face of the bromine electrophile that initially adds. Okay I'm going to stop right there. And when we come back we're going to finish up with that fifth reaction. So we have five reactions to talk about in this chapter. And hydroboration oxidation with boron is going to be the thing we spend our time on Monday.
This is the second quarter of the organic chemistry series. Topics covered include: Fundamental concepts relating to carbon compounds with emphasis on structural theory and the nature of chemical bonding, stereochemistry, reaction mechanisms, and spectroscopic, physical, and chemical properties of the principal classes of carbon compounds. This video is part of a 26-lecture undergraduate-level course titled "Organic Chemistry" taught at UC Irvine by Professor David Van Vranken. Index of Topics: 00:07- Foul smell complaints in southern England after gas leak 00:51- Mercaptans stink 02:23- The Lubrizol plant map 04:03- 10.8: Addition of Electrophiles to Alkenes 5:44- 10.12: Hydration: Acid-Catalyzed Addition of H2O 09:49- 0.12: Hydration: Acid-Catalyzed Addition of H20 15:30- 10.13: Halogenation: Addition of Br2 and Cl2 18:26- 10.13: Mechanism Involves a 3-Membered Ring Halonium Ion 25:28- 10.14: Stereochemistry of Halogenation 30:44- 10.14: Halogenation Stereochemistry 36:08- 10.15: Halohydrin Formation: Halogenation in Water 40:54- 10.15: Halohydrin Formation: Halogenation in Water-Steps
10.5446/19476 (DOI)
So, I referenced recently to this some news article on, of course, I don't use this kind of stuff for myself, maybe my wife would, about some new product that I guess is supposed to rejuvenate your skin, make you young. And apparently it contains a multi-patented gene-activating 4AR molecule. And when I see the word molecule in the news story, of course, it immediately turns me on and makes me think, gee, there's something cool there. And so I wanted to know, what is it that you could be smearing on your face that might be gene-activating? And these mysterious letters, 4AR, right, that must be better than 3AR. So what is this about? So I wouldn't look up with this 4AR molecules and said it was developed by somebody in Utah. And who is it in Utah? The pad did actually, it's organic chemists just like me there that made a very simple derivative of a compound that got a huge amount of press within the past decade. And that's resveratrol. It's this molecule on the bottom. I'm not sure if you can see my laser pointer here. But at the bottom here I've got resveratrol. And it's a red wine compound that many people were touting as the cure to diabetes, the cure to aging, the cure to every ailment known to man. And it's very active. It turns out that this molecule resveratrol, I wouldn't say it's super active in terms of potency, but it acts on a lot of things through this target SIRT1. So this is a compound that cleaves amide bonds. It's a protease. Specifically, it's a histone deacetylase. And what that does is when this protein acts, it releases all kinds of genes. That's the function of histone deacetylases. So they were correct. This is a gene-activating molecule. The trick here behind this 4AR molecule is that a chemist went in and said, well, gee, you know, everybody knows that resveratrol isn't very useful. Let me turn down the sound here. Because you have to take huge quantities. The body clears resveratrol so fast that you have to sit there and eat it like breakfast cereal in order to keep enough in your body to do anything. And so what this chemist did is went in and made a very simple ester derivative. That's the ester right here on top. That's called an acetate ester. It's an ester of acetic acid. And we'll teach you how to do that in Chem 51C. You may do that in the laboratory and make simple esters. So somebody going and making a simple ester here gives this molecule enough hang time so that you don't need to eat huge quantities of this for it to have some sort of an effect. Now I don't know if this is actually going to make your skin seem younger and to regenerate it, but it is a technically trivial idea that you'll be able to accomplish just by taking a class like this. I hope in your Bio 98 and related classes you're learning cool stuff like this about biology. These are the kinds of things that biologists care about, these types of pathways and these types of activating molecules. OK, so let's go ahead and get back to our, I'm seeing that there's a double bond right in between these two benzene rings. And it makes me want to add something to that double bond. And so let's go ahead and talk about the chemistry of double bonds. That's the focus of chapter 10 for this class. And we spent the lecture on Friday, which seems forever because there was a, we just had this holiday, this university holiday. Let me try to get this document camera aligned here. So it seems like forever ago since we just had a Monday holiday. And this is what we're going to cover in chapter 10. We spent our last lecture really just covering some basic concepts that aren't the kinds of useful concepts that you'll use throughout the rest of the course. But this is, these five reactions here are really chapter 10 in a nutshell. If you can grasp these 10 reactions, you've got it. And moreover, if you can grasp these 10 reactions, you're set up for the rest of organic chemistry, especially chapter 18, which is a big focus for this class towards the end of the quarter. When I teach Chem 51C, when people are behind and feel like they're totally lost, I tell them, go back to chapter 10 and learn those reactions again. So these are absolutely fundamental to your understanding of organic chemistry. OK, so here's the reactions that we're going to learn. We're going to learn how to put a bromine atom on an alkene. And there's a very simple reagent for doing this. I can't imagine reagents that are that much more simple. And it's HBR. And if you wanted to add chlorine in the same way, you'd add HCl. Now this may look very mysterious to you because you can't see the H that got added there. But I added not just a bromine, I also added an H. And just in case it's not clear that there's an H there, I'll draw it for you. But I expect you to be very good by this point in time seeing the H's that aren't drawn. There's the H that was drawn that was added with HBR. OK, so very easy. You could do the same reaction with HCl. I've never seen anybody do a reaction like this with HI, but hypothetically, that's possible. It may depend on the structure of the alkene. OK, so if you also want to add a hydroxyl group to an alkene, you can add the elements of water to an alkene. But we need a trick here. We have to have some sort of an acid in order to add the elements of water. And that is to add catalytic sulfuric acid. And I'm very picky about which acid you choose. I want you to choose an acid that has a non-nucleophilic counter ion. Don't pick HBR, don't pick HCl, use catalytic sulfuric acid. And in order to make this work, you have to add water. And you have to add a lot of water. What makes this reaction go is that water is the solvent and it's present in big excess. So whenever I draw reagents below the arrow, if those reagents are common solvents in organic chemistry like water or methanol or ethanol, you can assume that that's present in a large excess. Okay so again I've added the elements of OH and H. Here's the OH from the water and here's the H. And if that's not clear to you, let me just remind you there was one H here before and now in the product there's two H's. So I did add an extra H and an OH to make this product. Now you have seen both of these reactions before. Let me draw a dividing line. You've already seen these reactions. These aren't new. And you may think, well I didn't see that reaction before. What you've seen is you've seen that reaction in reverse. You've seen elimination of HBr to make alkenes. We showed you strong bases like tbutoxide to do that. Now what I'm showing you is you can take that same alkene and go back again to the alcohol halide. We've shown you how to dehydrate alcohols using sulfuric acid as a catalyst. We just left out the water was the trick. Now we're driving the equilibrium backwards simply by running this reaction in water. So you'll see the mechanisms for those two reactions that I show you look very much like the reverse of mechanisms you already know. In a way these are kind of new, these first two reactions, but really they're not that new. The reactions 3, 4 and 5 here, those are new and you haven't seen anything like these before. There's going to be a lot of stereochemical issues that come along with these. So if I want to add two bromine atoms here to an alkene, I'm going to use bromine, molecular bromine, that's Br2. You don't have to draw the bond there, I'm just showing you that Br2 has a bond in it. And this is a reagent we haven't used yet in this class and you're going to use this a lot. And you could also do this with chlorine, Cl2. Chlorine gas, bromine is a liquid, it's just a dark brown liquid, whereas chlorine is a gas. That's why it would be very rare for people to do this with chlorine in an academic lab. We usually use bromine because it's a convenient liquid. Okay, we can take the same reagent bromine, Br2, and this time I'm going to draw it as a molecular formula because that's more convenient. And if I simply run the reaction in water, same bromine, same bottle of bromine, I take out a dropper and drop a few drops in there. And if I run the reaction in either an alcoholic solvent or in water, that water or alcohol acts as a nucleophile. And so I don't get two bromines, I get one bromine and a hydroxyl group in this case. Now I want you to notice something particular about the stereochemistry, these two bromines on top here end up anti to each other. And the bromine and the hydroxyl group also end up anti to each other on opposite sides of where the double bond was. So that's one stereochemical issue I'm going to harp on and make a big deal about. And the other thing of course here is that we've got, I'm symbolizing this with plus E to mean plus an anti-emmer. So you also get the mirror image and the same down here. On exams, I always front end my questions by saying show any stereochemistry unless otherwise indicated. And this is one simple way for you to indicate that there's also a mirror image that's produced. You can just write plus E and I will understand that to mean that you've generated a racemic mixture of two enantiomers. Okay, so that's two new reactions. Addition of bromine across a double bond or addition of bromine and water. And you could do both of those reactions with CL2, with chlorine if you wanted. You cannot do those reactions with iodine. Maybe the second one in special cases, but I would never ask you to do that. Okay, so the last one here is looks just like the sulfuric acid in water. And what I'll show you is that it's complementary. It's like if it gives the same product, why would I use this complicated bottom reaction? And here's the reagents for this complicated bottom reaction. The first reagent is a reagent you've never seen before. It's called borane. Yes, that's a boron atom. And you haven't seen anything yet with boron atoms. We're going to talk a lot about that when we get to our discussion of these reactions. And there's a second step here. Notice how I enumerate the steps. If I leave out the numbers, it's totally wrong. If I don't enumerate these steps as step one and step two, then that means I've simply mixed everything together. And if I mixed everything together, I'd have a dangerously explosive mixture and I would get none of the product that's shown. So you have to enumerate these. I've enumerated these with Roman numeral I and Roman numeral II. You could use Arabic numerals, the book, just to show you the alternative. You can enumerate things the way the book does. The book uses brackets. That's totally inconsequential. And they use Arabic numerals. Generally in organic chemistry, if you use these little Roman numerals, it means you didn't isolate and purify the intermediate after the first step. Whereas if you use the Arabic numerals, it means you isolated and purified the intermediates. And it doesn't matter. Throughout this quarter, you may use Arabic numerals wherever I use Roman numerals, and that's fine because you don't have to worry about the details of workups. Okay, step number two is to add hydroperoxide anion. And we make that in the lab by mixing hydrogen peroxide. So you can buy hydrogen peroxide. And the book shows HO minus. That's a minus sign there. If you wrote, I would prefer if you wrote sodium hydro, in fact, let me write sodium hydroxide because it's bothering me. There is no reagent OH minus. So that's sodium hydroxide. So you mix these two things together, sodium hydroxide and hydrogen peroxide. And I know it looks kind of complex there. Look at all those steps and those weird reagents you don't know anything about. We'll get to that. We'll go on and we'll show you why you would want to do this other way for adding an OH group. So again, let me just remind you that I've added two things across this alkene. There was one H here down at the bottom in the beginning. And my pen is cooperate. There you go. There was one H there in the beginning. And now in this product, there's two Hs. So you can see this fifth reaction here. I've added H and OH across that double bond. So I urge you to practice until you are an expert, seeing the Hs that aren't drawn for you. I expect you to already be able to see that there was an H added. It'll hurt you if you can't see that and it will help you immensely if you're fast at it. Okay. So those are the five reactions. Let's talk about them. Let's just talk about them over and over and over again. You'll see in some ways they're very similar to each other until we get to the last one. And then things got kind of crazy. Okay, so let's talk about stereochemistry. It's a big issue in this chapter. And stereochemical relationships. So I'm going to start off by drawing a substrate in the middle of my page here. And I'm going to try to pretend that I'm standing and looking at this alkyne edge on. And if I were standing and looking at this edge on, kind of like looking at a piece of paper so that the paper looks thin, I would see two substituents going back and two substituents going forward. So I could see sort of the edge. What I'm trying to emphasize is that I want to try to imagine looking at an alkyne so that I can see it has a top face and a bottom face. Every alkyne has a top face and a bottom face. And I want you to imagine two of those five reactions. Let's take a look at the stereochemical consequences for two of those five reactions so that we can see that sometimes things add on the top face or the bottom face and there are two modes in which the two atoms can add. So I'll show you two reactions from that list. Okay, the first reaction that I'm going to show you is going to be the addition of bromine, Br2. So when I add Br2 across this alkyne, let's take a look at what happens to those two bromine atoms. And we're going to have a special name for this that allows us to discuss it and keep things straight. So what happens is I'm going to get, there will be no double bond in the product. And I'm really trying hard to see anti-relationships by drawing this in this saw horse conformation. It looks kind of like this, this staggered conformation here. Okay, so here's the product. And in the product, one bromine adds from the top face and the other bromine adds from the bottom face. And this is always true with bromine addition with Br2 addition. One always adds from one face and then the other one adds from the other face. And you'll also get a mirror image product. I'm not going to get drawn where this Br is down and the bromine on the other side is up. The important point here is that we refer to this relationship in the product, the relationship of these two groups as anti. That's an anti-relationship and we call this mode of addition anti. So that's the description for the relative orientations of those two bromine groups in this reaction. Okay, now let's go back and look at this boron reagent. That was the fifth reaction because it's different. If I'm going to invent this whole sort of nomenclature here, it must be because I have something, some alternative to anti. And so here's, it doesn't matter what R is, it can be H is or alkyl groups. So if I take a borane molecule that has a BH bond, the B and the H will add across the double bond. But in this case, you don't get an anti-relationship between the way the B and the H add. Those add with a syn orientation. So let me draw this B and this H. So here's the H and here's this weird boron atom. I hope you're going, gee, what's with that boron thing? We've never seen that before. It's this whole group with the two R groups attached. Don't worry about those R groups, it doesn't really matter. Okay, so notice clearly and obviously the boron and the H are now on the same face. If the boron adds from the top face, the H will also add from the top face. If the boron adds from the bottom face, then the H will also add from the bottom face. You'll get usually a one-to-one mixture of addition from top face and bottom face. We call this relationship between these two groups syn. And we call this mode of addition syn. So some of the reagents that I showed you on that last page, I showed you five reactions that we're going to talk about over and over and over again. Some reagents add anti, like bromine and chlorine. Some reagents add syn, like this borane with the BH bond, the boron-hydrogen bond. And then some give you mixtures of syn and anti. And so you're going to have to keep that straight. For every one of those five reactions I want you to know, I expect you to know whether the mode of addition is syn or anti, and I expect you to understand the mechanistic origin of that stereoselectivity. Okay, so generally what you'll find is that reactions that involve carbocation give you mixtures of syn and anti. And that'll be things like hydration or HBr addition. Okay, and we'll talk about that. Okay, so note those syn and anti relationships. Okay let's talk about our first mechanism for that first reaction that I showed you. The addition of HBr across double bonds. So I'm going to start off by drawing a substrate. It'll be a simple trisubstituted alkene. And I've chosen this alkene because I wanted to make it clear that in this particular case the two carbon atoms are different. One carbon atom has two substituents, two methyls, that's the one on the bottom. Because the carbon atom on top in the alkene has only one methyl group. And because of that the reaction will exhibit some regioselectivity. So if I go ahead and draw out my reaction with HBr and I'll draw out the HBr bond because I'm drawing the mechanism for you. So I can add H and Br across that double bond. H adds to one carbon atom in the alkene, Br adds to the other carbon atom in the alkene. And the mechanism looks something like this. We've got this double bond here and this is what you haven't seen before. And this arrow I'm about to draw is really this chapter in a nutshell. This chapter in a nutshell is alkene's attacking stuff. Alkeene's acting as bases into nucleophiles. And there you go. It's like wow! I've seen three chapters already where lone pairs attack things. And now you're telling me that pi bonds can attack things? Yeah. In fact that's what we're going to spend both this chapter and chapter 11 and chapter 18 talking about. Over and over and over again. And that's the heart of modern organics synthesis. Okay, so you have to break the bond to the H, the HBr bond if we attack. So really we're just doing an acid base reaction. It's like who would have thought that an alkene could act as a base? Well if you've got super strong acids it can act as a base. Okay, so now we're going to take this intermediate. What you can't tell, and this is what's frustrating about arrow pushing when you use alkenes, is I've just drawn an arrow here where the double bond attacks the H. But you can't tell from my pink arrow which carbon atom picks up the H. You won't know until I draw the intermediate which of those two carbon atoms in the alkene picks up the H. Some people get really frustrated by that and they want to, they try to make their arrows start from one carbon atom or no, you make the arrow start from the pi bond. That's what's acting as the base. That's the pair of electrons that's engaging this HBr. So let me go ahead and draw the intermediate for you. It's this tertiary carbocation. And let's draw the H's that are, here there's two H's on this alkene. There's one H and here's the other H. So I started off with one H sticking off of here and now I have two H's. So I didn't have to draw those in for you, but just to help you see where did that H go? Okay, that leaves, if I pop off the bromide anion that means that the bromide anion is still floating around right here. There's four pairs of valence electrons. I'm just going to draw one of those lone pairs. And that sets me up to see what's going to happen next. The next, that bromide anion is going to attack that carbocation, that poor lonely carbocation that doesn't have an octet and that Br minus will satisfy that. And so that's what gives you this final product. We've now added HBr across the double bond. I'll typically draw it like this. I typically won't draw the H that I just added. You have to get over this stop. We're not going to draw H's for you anymore. You have to envision where those H's are. Okay, so we just showed you that's addition of HBr across double bonds. You could do the same mechanism with HCl, hydrochloric acid. That's a very cheap reagent that's common in the laboratory. You could do it with HI, very uncommon. And typically alkali dides are so unstable. You just don't see people doing that very often. So HCl and HBr are the most common. Okay, so we're going to see that kind of reactivity where double bonds attack things over and over and over and over again. Yes? So how do you know that the carbocation will be on the second hand side? The question is how do you know the carbocation will be on the bottom carbon? How do you know the carbocation will not be on the top? I will talk about that. I will, in just a couple's overheads, show you something called Marconikov's Rule, which tells you that. Okay. Okay, that reaction generated a carbocation, and we've been trying to teach you in this course, whenever you have reactions that generate carbocation intermediates, you have to watch out for rearrangements. So here's an example of a reaction that generates a carbocation, and you have to watch out for rearrangements. So let me go ahead and draw out what you get. Here's a substrate, and what do I see when I see this reaction? Okay, you're going to add HBr across a double bond, but I immediately am drawn to that strained four-membered ring. Look at all that strain in that form. It's like a square. Bonds don't want to be square in organic chemistry. They want to be 109 degrees. So maybe it shouldn't be that surprising to me that somewhere in this reaction pathway, this molecule found the capacity to rearrange and get rid of the 26 k-cals per mole of strain in that four-membered ring. So let's try to follow this through. So if I ask you to explain how you generate this final product, it's like all kinds of crazy stuff is happening there. One trick that I usually emphasize that I want you guys to try to home in on is if you have a mechanism, if I ask you a mechanism and you're sitting there, gee, I can't see what happens, try enumerating the carbon atoms. Try to track which carbon atoms end up where as just a basic tool. So here's some of the things that I see here. I see in the starting here I've got an alkene and there is no alkene here in the product. So if I arbitrarily start to number my carbon atoms, I might call this carbon atom 1, 2. That's a CH2 group. Notice how I'm not just looking at the atoms. I'm looking at whether they're CHs or CH2s or CH3. So carbon atom is a CH2 group. Carbon atom 3 is a CH2 group. Here I'll enumerate carbon 4 as a CH2 group. And the symbols you use are arbitrary. I could use smiley faces or flowers. It doesn't matter. I'm just going to use numbers because they're easy. And what I'm trying to do here is just come up with a hypothesis. Okay, let me try numbering some other atoms. Maybe carbon 1 is one of these two carbons between the rings. I don't know which one. But one of the things that I immediately see is three CH2 groups in a row. I'll bet the three CH2 groups on this side or on the other side are carbons 2, 3, and 4. In the mechanism I don't break every single bond. There's just a few bonds that break. And so I don't really know which of these is carbon atoms 2, 3, or 4. I might arbitrarily do this. 1, 4, 3, 2, or 1, 2, 3, 4. I don't really know what's attached to what. You start off by making a hypothesis. And if anywhere along your mechanism the numbers stop matching, then you back up and start over and number it a different way. So let me encourage you to number carbon atoms. And you'll oftentimes pick the wrong numbering at first. But at least it helps keep you focused on is my mechanism heading in the right direction? Okay, so let's go ahead and draw out what happens if I protonate this alkene. There's two different places you could protonate this. You could put the proton on here on the right-hand side or on the left-hand side. And I'm going to try protonating over here on the right-hand side, which will leave the positive charge right next to this strained ring. And you wouldn't necessarily know that this is going to work out. You might have to try protonating the other place first. And then if you couldn't get to the right place. So if I draw that proton adding here, I'll just draw that proton just in case it bothers you that you can't see where it went to. There's the proton that I just added. And that leaves me with a secondary carbocation. It doesn't matter which of those carbons I protonate, I'm going to get a secondary carbocation when I add a proton to the double bond. And now this particular intermediate, I have to be very worried. Well, I don't know if worry is the correct emotion here. What I can see is that this has a capacity to undergo a 1, 2-alkyl shift to make a more stable carbocation. Those reactions tend to be fast. 1, 2-alkyl shifts that generate more stable carbocation, particularly tertiary carbocation, tend to be very fast. And if they relieve ring strain when they do that in a 3 or 4-membered ring, they're unstoppable. So in other words, let me draw this other counter ion that's floating around. You may wonder, well gee, how could I have guessed that the bromide doesn't simply attack the carbocation? And it's because rearrangements that relieve ring strain are always faster under conditions that you see in this class are always faster than this kind of attack of bromide on the carbocation. Okay, so let me go ahead and draw that rearrangement. If I'm claiming it's so fast, there we go. See how fast that was? Okay now, here's a place where you might get mixed up really easily. In other words, how do I make sure I draw all of these carbon atoms faithfully? This is where numbering can often help you. If you're worried that you're not going to redraw this intermediate correctly, numbering your carbon atoms can help you. So in this case, you might consider finishing and enumerating all of your atoms. 5, there's a CH2 group number 5, here's a CH2 group number 6, here's a CH with the alkene number 7, and here's a CH number 8. And right or wrong, I have to match these up. I'm looking for a CH2 number 5. Gee, maybe it's still attached to carbon 1, so I'll draw that as CH2 group number 5. Here's CH2 group number 6, maybe that matches. Oh, here's a CH2 group. If 6 is still attached to 7, I have to explain in my mechanism somehow how carbon 7 picked up an extra proton. If this is right now, I've got this very weird, gee, carbon 8 now has all these carbon atoms attached. So again, your numbering could be wrong at first. Be ready to back up with your mechanism and start over. So let me keep numbering. The numbering should still correlate here. And now in this rearrangement, this is where I really have to keep track to make sure I don't mess up during my intermediate. So I'm going to try to make this 5, remember to bring this one over here where I have carbon 1, 5, 6, 7, and 8. And you don't have to number. If you're good enough to figure things out without numbering, great. It's just a tool to help you when things start to get really confusing. So if I break this carbon 1, 2 bond, so carbon 4, I'm not breaking, so carbon 4 has to still be attached. So carbon 3 is still attached to carbon 4. And carbon 2, 3, I'm not breaking that bond. So let me go ahead and enumerate those so you can see. No, my arrow pushing didn't break the bond between carbon 1 and 4. My arrow pushing didn't break the bond between carbon 3 and 4. And my arrow pushing didn't break the bond between 2 and 3. But according to my arrow pushing, I broke the bond between 1 and 2. And I made that bond move over to carbon 8. So let me draw that bond here. Here it is. And if I take electrons away from carbon 1, I have to leave a carbocation there. There's that carbocation right there on carbon 1. And just to be clear, there was an H at it attached here on carbon 8. I always see those H's and it's still attached there on carbon 8 in this intermediate and it is still attached in the product. So that's a relief. At least I'm not veering off in some weird direction. And now I'm going to draw this bromide counter ion that's just floating around. And it's ready to attack that tertiary carbocation. Maybe it's not drawn in a particularly beautiful way. But what I've ended up with is the right ring system with two 5-membered rings and a tertiary carbocation. And so now my bromide counter ion can come in and attack that tertiary carbocation. Okay, so what's the important thing? This is not new, the idea of 1, 2 rearrangements. This is just a different reaction that leads to carbocation intermediates. The addition of HBr and HCl across double bonds leads to carbocations. Just like SN1 reactions lead to carbocation, watch out for rearrangements of carbocations. Especially if they lead to more stable carbocations and they're unstoppable if they relieve ring strain and a 3 and 4-membered ring. Yeah? You said that in this situation with bromide, the rearrangement of the tertiary carbocation before you get a very, very, very intact. Would that be the same for HI? You have to assume in this class that that's true. It's concentration dependent. So for the reactions that we show you in this class, you have to assume that at the concentrations we're showing you that the rearrangements of 3 and 4-membered rings to make tertiary carbocations are faster than attack. And I'm kind of doing a bait and switch because there's a potential reversibility, but I'm not going to, you don't need to worry about that. Just assume it's faster for 3 and 4-membered rings. Okay, so how do you know which carbon you're going to add the proton to? And that's answered by, gee, I don't even know how old this rule is. It's a rule from the, I'm pretty sure the 1800s, Markonikov's rule. Maybe that's wrong. Maybe it's early 1900s. But it's about that time frame. So let's take a look at some unsymmetrical alkenes. And I'll show you a simple, really empirical rule. This was developed without an understanding of the mechanistic basis for it. But how do you predict when you've got an alkene that has two different types of ends and you add HCl or HBr to that? How do you know which end of the alkene gets the proton and which end of the alkene gets the halide? And that's what Markonikov's rule is good for. What Markonikov said is, well, look at the alkene and then you have to decide if the two ends are non-identical, if one is more substituted and one is less substituted. So I'll write less substituted. So the top end of this alkene is less substituted and the bottom end of this alkene is more substituted. I'm just going to abbreviate substituted there. So I've got two different ends. And Markonikov's rule is very simple. You add the proton to the less substituted carbon. And you just need to remember that. So I'll refer back to Markonikov's rule later in the class. It's an empirical rule. And you just have to remember, oh, that means the H adds to the less substituted carbon. So let's draw out the product for this. Here's the product for that reaction. But hold on. Where's that H? Well, I didn't draw it. The H is there. Here it is. There's three H's on this top methyl group that I didn't draw for you. There were two in the beginning. When I say less substituted, I don't mean H is not considered a substituent for Markonikov's rule. I mean substituted by alkyl groups. Those two H's are still there. And here's that third H. And I emphasize over and over that you have to be very good at by this point in time at seeing H's that aren't drawn for you. So you can see I've added H and Cl across the double bond. The H goes on the less substituted carbon. And the nucleophile chloride or bromide goes on the more substituted carbon. Let's try that again. Let's see if we've really mastered this Markonikov's rule. There's a differentially substituted alkene. And I'm tired of HCl, so I'll use HBr now. And I add HBr across that double bond. So you should be able to figure out which of the two carbons in the alkene, one of them gets the H, one of them gets the Cl. So if we apply Markonikov's rule, then again it's just an empirical observation that, gee, the less substituted carbon gets the H, that's this one down here at the bottom. So now the one on the bottom is less substituted. And now the one on the top is more substituted. And by the end of this chapter, you're going to be very fast at recognizing, okay, that carbon is more substituted, that carbon is less substituted. And so when I draw this product out, the bromide is going to be up here. And that H that we usually don't draw, we usually don't draw the H. I'll draw it for you, it's down there. Again, I didn't draw the other H's, so it just seems weird to me that I'm drawing that one H in. Okay, so the H goes on the less substituted carbon. So you're going to be using this over and over. I expect you to be good with that rule. That's a common kind of question for MCATs and stuff like that. Okay, why does that work? Why is it that this, how is it that Markano-Coffee figured this out? And he didn't know anything about the mechanism. You could have invented this rule if you knew the mechanism. Actually, you don't need the rule if you understand the mechanism for the reaction. So let's take a look at what's going on mechanistically that makes the H add to the less substituted carbon. I'm going to come back to that initial example. And I'm going to try to draw it kind of here vertically in the middle of my page because I want to show that this substrate has two possible pathways and it chooses one. So here's an alkene. The top carbon in my alkene is less substituted and the bottom alkene is more substituted. And this has two possibilities when it adds to HBr. Here I'll draw my HBr molecule just seductively hovering over that alkene waiting to do something. And it's got two pathways. It likes the bottom pathway that I'll show you in a moment. And then we'll try to rationalize why it doesn't take this top pathway. And so again, let's just note for ourselves that this carbon atom over here on the bottom is more substituted because this is what we're paying attention to with the Markano-Coffee rule. And the top alkene, top carbon, is less substituted. There we go. Okay, so when this double bond attacks, when this pi bond, this C-C pi bond attacks that H, the proton. I'll draw the arrow starting from the middle of the pi bond. That's the way we do it. And we're going to pop out the bromide leaving group. And so the question is, does the proton go to the bottom carbon or the top carbon? And what I showed you when I drew out that mechanism was that that proton likes to go to the less substituted carbon, that top carbon, to give you this tertiary carbocation. I'll just, in my tiny pen here, sketch out that H atom that I just added. That's not our focal point. The point is that this is a tertiary carbocation. I'll just write tertiary R plus. That's tertiary. If I protonate the bottom carbon, if I did stick the proton on the more substituted carbon, it starts to look very painful. There's that H. And now what I'm left with over here is a secondary carbocation. More stable carbocations form faster. This is a rule you already know in organic chemistry. I'm not telling you that more stable products always form faster in organic chemistry. That's only true half the time. But for carbocations, more stable carbocations form faster. And so given a choice to protonate on the top carbon and form a more stable tertiary carbocation, that's the choice. And the alkene does not pick up the proton on the bottom carbon because that would leave an unstable secondary carbocation. That's why Markovnikov's rule works. Markovnikov's rule works because it basically, when you stick the proton on the less substituted carbon, you leave a carbocation on the more substituted carbon. And so that's why Markovnikov's addition correctly predicts that the nucleophile will be attached where there was a more stable carbocation. So there's the bromide after it attacks. And there's the H-atom that you typically don't draw, but I'll draw it in there so we don't get lost there. Okay, so Markovnikov's rule works. You don't generate less substituted carbocations. When it's a race, it's more substituted and more stable carbocations that form faster. So again, you don't have to remember Markovnikov's rule if you know the mechanism for the reaction. Here you can just fall back on, oh gee, more stable carbocations form faster in organic chemistry. And I'm not going to draw this other possible pathway because I've already shown you the top pathway is not the favorable pathway there. Okay, so let's talk a little bit more about issues of stereochemistry because this whole idea that we can add to top faces or bottom faces of double bonds has some very real implications for how you should draw your answers for my exams and for your understanding of organic chemistry. So let's go ahead and plot out how you get these two possible products in this reaction. So if you had HBR across this alkene, and generally on my discussion section problem sets on my exams, I say clearly indicate stereochemistry in the presence of stereoisomers if any. So if I ask you to draw the products, you need to draw something like this or draw plus E. These are enantiomers of each other. And so why do you get two enantiomers? To help you see that, I'm going to try to draw the substrate edge on again because I want to try to envision this idea that there's a top face and a bottom face to this molecule. So that bottom end of the alkene has an ethyl group on there. I'll just draw that ethyl group like this. And then if I'm trying to envision this so I can see those two faces, then some of the substituents will be sort of angled back and some of them will be angled forward. So I'm just trying to draw this edge on so I can see, okay, alkene has a top face and a bottom face. Every alkene has a top face and a bottom face. There's electron density on both faces of that alkene. And so when this HBR adds, it's equally possible, and we'll get to this in a minute, that it adds from the top face to the bottom face. That's not the important point yet. We'll talk about that in just a moment. So when I take my HBR molecule and I use that alkene as a base, which is weird to think about, the alkene is a base, to grab a proton from the HBR, I want us to look at the carbocation that we generate. Just to remind ourselves that when we look at that carbocation, which I'm also going to try to draw edge on here. So now I've got a CH3 group. If I pick up the proton and I follow Markovnikov's rule, Markovnikov's empirical rule says I want to put the proton on the carbon that is least substituted. So that's now going to be a CH3 group. That's kind of weird. It's like all of a sudden I'm drawing it as a CH3, whereas here I just symbolize it as normal. You have to try to keep that straight. So now I've got this carbocation intermediate. It's got a big fat MTP orbital there. And it is equally possible for the bromide counter ion to attack from either the top face or the bottom face. So if I make the bromide add from the top face of the carbocation, that will give me the synantium over here. And if you assign conningold prelog stereochemistry, you'll find that's the synantium. But it's just as possible that the bromide could add from the bottom face. So I'll write or the bromide adds from the bottom face. There's no steric difference between these two faces. I could spin this little ethyl group around any way I want. If I add, let me make that arrow go a little closer here so I didn't do a good job of drawing that. If I make my bromide attack the carbon from the bottom face, that's going to give me the other enantiomer. And I'll get a one-to-one mixture of those enantiomers because it's equally possible for the bromide to attack from the top and the bottom face. So that's something you should already know from SN1 reactions. This is just like the products you get when you take tertiary alcohols and you add HBR. We're just generating the carbocation intermediate in a different way. So the last stereochemical, what I'm doing here is I'm spending a lot of time to harp on stereochemical issues. And all these things that I'm saying for HBR and HCL, they're true for HCL and they're also true for the addition of water, which we'll talk about when we come back on Friday. So really, I'm going to spend, of those five reactions that I spent that I said were so important, we've basically spent this whole lecture just talking about reaction number one. Okay, so let's talk about a different issue. And again, I'm going to have two different pathways, one going toward the top and one going toward the bottom. And I'm going to take an alkene. In this case, I'm not worried about my Conocos rule. I just want to come back to this idea that there's two faces to every alkene. And so when I add HBR to an alkene that has two different faces, the proton can add from the top or the bottom face. And so let me go ahead and draw it. Let's just imagine what will happen if I protonate this alkene from either the top face or the bottom face. And I'm not going to worry about the fact that there's two different carbons, top and bottom, because those have equal reactivity. So if I protonate the bottom carbon, there's two different faces where I could add the proton from. And so on the top pathway here, I'll draw what happens if I protonate that alkene from the top face. Well the proton is on the top face and that methyl group is now pointing downward if I protonate it on the top face. And now on the bottom pathway here, I'll show what happens if I protonate that alkene on that same carbon, except I protonate from the bottom face. And there's my proton on the bottom and there's my carbocation. It is equally likely. Let's ignore regiochemistry. I don't want to worry about protonating the top carbon. I just want to worry about faces of the alkene now. So it's equally likely to protonate from top and bottom face. I'll have a one-to-one mixture of these intermediates floating around. Now when I do that, this is just to show you how hairy things can get and why you have to understand the mechanism to appreciate the product distributions. So now if I have bromide counter ion floating around along with that carbocation, remember what I just told you on that last overhead, I just told you that with carbocation, the bromide can attack from both the top face and the bottom face of the carbocation. So this carbocation and the top pathway can give two different products. If bromide adds from the top, then the bromide ends up on the same face as the H. That would be syn addition. So if bromide adds from the top, I'm tempted not to draw this proton here, but I'll draw it in anyways. We usually don't draw protons on our structures. So if the bromide adds from the top, then it ends up on the same face as the H. And again, that's syn addition. I'm not going to label every one of these. But it's also likely that the bromide can attack from the bottom face. And so in that case, the bromide would be down with a dash and that H will still be up. And now the H and the BR are on opposite faces. That would be the anti-product. So I'll get both of those products in this reaction, both syn and anti-addition. And that's because you can protonate and generate a carbocation and the halide can attack that carbocation from either face. Let's follow through with this bottom pathway and we'll see how the product distribution relates to that from the pathway above. So I'm going to avoid attacking that positive charge. I'll use my arrow to attack the carbon atom. So once again, the bottom pathway, the difference is that I was drawing out the initial protonation occurring from the bottom face. So both of the products I generate here will have that proton going down. Look at all these products here. So if the bromide adds from the top face, I should have drawn this other line going down, if the bromide adds from the top face, now it's going up and that methyl group is going down. And so now that gives me the anti-product. Sorry, the, sorry, the, you know what, I didn't mean to do, I'm just, it's going to become very difficult for me to, I'm going to scratch that out and I'm going to put the bromide. What if the, well let's consider what happens if the bromide attacks from the bottom. I just want this to try to match. If the bromide attacks the carbocation from the bottom, then this will be the syn product, H on the bottom, bromide on the bottom. If I take that same carbocation and I add the bromide from the top face, that would give me the anti-product. So there's four products that will arise from this really simple reaction. I take an alkene and I add HBr across this. Now there's a simple relationship here. These two products are enantiomers. In other words, as long as you drew one of them, you could just write plus E. And these two anti-products, those are also enantiomers. As long as you drew one of them, you could just write plus E if you were asked to draw. So if you can see these enantiomeric relationships, you wouldn't have to draw all four of these for products in your reaction. You could just write two of them and write plus E as long as you pick the right two. Okay so that's it for the first reaction of those five reactions. I'm not going to go through all this stuff for those other reactions because the concepts of stereochemistry and Rokonikov's rule are similar.
This is the second quarter of the organic chemistry series. Topics covered include: Fundamental concepts relating to carbon compounds with emphasis on structural theory and the nature of chemical bonding, stereochemistry, reaction mechanisms, and spectroscopic, physical, and chemical properties of the principal classes of carbon compounds. This video is part of a 26-lecture undergraduate-level course titled "Organic Chemistry" taught at UC Irvine by Professor David Van Vranken. Index of Topics: 00:16- Resvology Debuts Anti-Aging Skin Care Line with Gene-Activating Molecule 00:54- 4-AR molecule 04:18- 10.8: Addition of Electrophiles to Alkenes 14:03- 10.8: Syn and Anti Relationships 19:09- 10.9: Addition of H-X: Hydrohalogenation 23:56- 10.9: Watch for Rearrangements of Carbocations 33:39- 10.10: Markovnikov's Rule: Add H to less-substituted carbon 38:18- 10.10: Markovnikov's Rule is Based on Carbocation Stability 42:57- 10.11: No control in formation of stereogenic centers 46:53- 10.11: No control in formation of stereogenic centers, slide 2
10.5446/19475 (DOI)
So I saw this little news report from a station in Baton Rouge, Louisiana. He fixed this screen. And the news report was talking about, it was, they were interviewing some pest control person about how they deal with fire ant problems. It's a problem you don't have here in California yet. It's coming. I spent a lot of time growing up in Texas, Louisiana. And I can tell you, fire ants are really nasty. What caught my attention is that this pest control person was talking about, and I'm sorry you can't see this very well. I've lost my other laser pointer. But he's talking about some special powder-like substance, and more importantly, he was talking about, and maybe I can use the mouse to come over here and try to point here. But he was talking about some granular product that is water activated. And somehow or another, that just turns me on, because it sounds like, wow, maybe there's some chemical reaction between rainwater. Yes? Well, yeah, thank you for asking that, but I'll try to turn it up until we get to feedback stage. But somehow the idea that there might be water, here, let me keep going, see if I can get a little, the idea that water might somehow be chemically reacting with some pesticide, and maybe, who knows, doing SN1 reactions or some other type of substitution process, that just sounds intrinsically cool. There's not a lot of pesticides or drugs that are designed to react chemically. So I did some searching around to try to figure out what they were talking about. I had to Google a few terms. But what I came upon was this, oh, I am missing the file here. So there is some pesticide by a green light. And let me see if I can go back. I apologize for this. I should have gone with the PDF version from the beginning. So there is some pesticide here. You can see the cover of that. It contains something that is called water-activated granules. And if you look, of course, you always look down to the active ingredients. It contains 0.1% bifenthrin. And immediately my heart sank because I know that this is going to be a chrysanthemate derivative and nothing new. You wouldn't know from the name, but there's a whole class of insecticides that end in the letters thrin, permithrin. They all contain this three-membered ring and an ester. And they're based on a natural insecticide that's found in chrysanthemum flowers. Those pretty yellow flowers have a natural insecticide that's a selective neurotoxin towards arthropods. So maybe if you ingested this entire bottle, it could affect you. But it's super-duper potent against insects and crustaceans and things like that. So this is the structure of that active ingredient. And there's an ester in here which, in theory, could hydrolyze in the rain or in water. But that's not the way this works. Actually, the way this works is kind of clever. I think this is how it works. So what's notable about this particular version of this chrysanthemum ester that's a neurotoxin to insects is that it's very greasy and has almost no water solubility. And if we go back and we read what this pesticide control person was very excited about, he was excited about the fact that whenever it rains, the ant piles get soaked and all the ants come to the surface so that they don't drown. So they're all hanging out on the surface of their ant pile. And so what he does is he comes along and he spreads this powder on top. And it just sits there and sits there and sits there. And the ants are way down deep under the ground and ignore that stuff. But as soon as it rains, the ants all climb to the surface. And here are these particles. And as it's raining, the rainwater is washing off this outer coating that's water-soluble. And it's leaving behind this waxy biphenthrin that all these ants who have just come to the surface find and think is food, then they ingest it and start dying. So well, it's not the chemical effect that I thought it was. Like I thought maybe there would be a chemical reaction with water. It is sort of a kind of a cool idea. So I'm not sure if this guy appreciates how cool all this stuff is. Gee, insect neurotoxins. This happens to target a sodium-activated ion channel in neurons. That's very cool as well. But next time you're smelling a chrysanthemum flower, you're probably getting a whiff of some of those kinds of compounds. Okay, so let me make a point about Monday. Monday is national holiday. And it's a university holiday, Martin Luther King Day. And I just want to remind you of this quote from Ben Franklin. Drive thy business, or it will drive thee. You have an opportunity to choose what you do with your university holiday. I hope you'll do something to honor Martin Luther King, but I would urge you to find some way to set aside some time to spend on organic chemistry. It's very rare that you get the gift of extra time to get ahead in this class. Try to use that time to get ahead. And also, because we don't have discussion sections on Monday, if you're in a Monday discussion section, try to attend one of the other discussion sections throughout the week. There will be four days worth of discussion sections. You'll be able to find one that you can squeeze into. Okay, Chris asked me to make a point about this, an issue that's going to become pervasive throughout organic chemistry. And so I'm just going to draw this out. I want to remind you that we're going to start doing something in this class and in this book where you do lots and lots of reactions in a single process. So I want to give you an example. This is typical of the kinds of examples, kinds of questions I'll be asking more and more throughout the quarter, where I ask you to take some starting material and then somehow convert it into a product. And it will almost never be one step. It's going to be multiple steps. And so how do you depict transformations that require more than one chemical step? Ah, thank you. There we go. So how do you depict transformations that involve more than one chemical step? And so here's an example of a question, how do you convert this alcohol into this thiamethoxide? There is no one step way to do this. Now the key problem here is that you need to figure out how to convert that alcohol into a leaving group. And you have all kinds of reagents that can convert alcohols into leaving groups. Thiamyl chloride and pyridine. Tossyl chloride and pyridine to make tossily leaving groups. PBR3, no pyridine, just PBR3 will make an alkyl bromide out of that. You can pick anyone you want. I'm going to pick PBR3 because it's easy. But then the second part of this is we have to add in some nucleophile like a methane thiolate anion. It's like a methoxide. It's just that there's a sulfur atom there. I'll just write sodium because, so there's sodium plus thiamethoxide minus. Now this is immediately wrong. It's wrong. It's wrong because if I don't enumerate the steps with numbers, it implies I'm mixing everything together at the same time. If you don't add numbers to these reagents and steps, it means you're simply dumping everything together in the same flask. And if you dump any kind of nucleophile in with phosphorus tribromide, it will react faster with the phosphorus tribromide than the alcohol will. And the way to make this correct is to enumerate the steps by writing the number one. The book uses brackets. I usually use parentheses and writing the number two. Then it's absolutely clear that what you mean is I'm going to take the alcohol. I'm going to treat it with phosphorus tribromide to make the alkyl bromide. And then I'm going to purify the alkyl bromide. And then I'm going to use my pure alkyl bromide and throw it into a completely different reaction. So more and more, we're going to be doing reactions where I simply enumerate the steps because I don't want to draw out every structure and every intermediate. And if you don't enumerate steps, if you simply write all of the reactions and reagents over one arrow or with one reaction arrow, that's just not right. So pay careful attention to this idea of enumeration of steps because it means something completely different if you take the numbers out, the numbers one and two. Okay, so let's get on with our new chapter here. We've got a bright, shiny new chapter that we can spend our time on. And I just feel like I am emerging from the woods into the bright sunshine, finally getting away from this hell of chapter seven, eight and nine and this SN1 and SN2 and E1, E2 business. That stuff is just awful. I feel like I'm hearing some buzzing and feedback. I don't know if I can. Whoa, that was a mistake. Okay, so we're going to start about talking about alkenes and I want to introduce this area by telling you two specific things about alkenes that differ from single bonds. So the first has to do with the reactivity of single bonds. And I'm feeling like I left off a piece of paper here, but let me just go with this. So I want you to, let me try to do this in the same order. Does somebody have printed notes here that I can look at? Because I'm missing one of my pages. Okay, let me first talk about the configurational stability of single bonds. And because I lost my piece of paper to write on, I'm simply going to show you what I have here on my written on notes. Okay, so there's a key point, a key distinction between double bonds and single bonds. And that is you can rotate about single bonds like this. And you haven't really noticed us doing this, but every time we've drawn some sort of a structure like this, I see every single one of those bonds as rotatable in that simple alkane. And that becomes very important when you have to think about reactions where two ends of a molecule have to bend around and get close to each other so they can react. So we haven't talked a lot about intramolecular reactions so far, but we're going to as the quarter progresses. And so when I see a substrate that looks like this with some alkoxide at one end of a molecule and some alkyl chloride at the other end of a molecule, I recognize that this great nucleophile isn't going to do anything unless it can get close to the alkyl chloride. Then will happen if those two can't get close to each other. And so I would rely on the fact that unless, that if I do rotate about these central bonds here, this is not a chemical reaction. I don't really need to draw this as a chemical arrow, that that's an initial requirement in order to get this close enough so that it can do some sort of an SN2. And so bond rotation allows these groups to get close enough so that you can end up with an intramolecular displacement reaction. Kind of like an SN2, but it's intramolecular. Okay, so bond rotation. You take it for granted and you've probably taken it for granted throughout the whole book so far. And starting in this chapter, because we're talking about alkenes, you can no longer take that for granted. The problem is let's take exactly the same molecule except that we're going to put a double bond right in the middle. And the configuration of that double bond matters. So I've drawn a particular isomer, we'll talk about this nomenclature shortly. This is called the trans-isomer. And with this trans-isomer, you cannot, with this double bond here, you cannot freely rotate about that C-C-pi bond, about that double bond. It's locked in that configuration with those two groups sticking far apart from each other. And if you can't bring this O-minus close to the chloride, it will never cycle eyes. So double bonds matter, they're locked in a particular configuration, we'll talk about that, where the groups are on the same side or the opposite side of the double bond. And that's going to dictate some of our chemistry. And so if you haven't been thinking about bond rotations occurring previously, you have to think about that now. Okay, so that's one important distinction between simple alkane single bonds and double bonds. The idea that C-C double bonds can lock configurations. Let's go ahead and talk about a difference in reactivity. How does a C-C single bond differ in, yeah? On the last stage, you said that the bond doesn't rotate or up a double bond. Yeah. How is it that it changes if you're a ring? Well the bottom one can't. Oh, okay. Yeah, so I've got, let me write, I drew dashed arrows to indicate that that's sort of fictional. I'll just write no. And if it doesn't rotate, then no, so that's what the intention. These other things can't happen. It cannot start off trans and then suddenly be what we'll call cis. So I'll introduce that terminology later. Okay, yeah, so the bottom stuff can't happen. Okay, so what's the key difference in reactivity? And this kind of, in a way, I'm going to sum up this entire chapter for you. So here's something that you haven't seen. Let me draw out an alkene for you here. And there's nothing special about this alkane. So far, some of the most reactive reagents that you've seen are things like sulfuric acid, maybe hydroiotic acid. And you've shown all kinds of things acting as bases and nucleophiles to attack. Here's what you've never seen. You've never seen a single bond just come along and attack a proton or attack an electrophile. You haven't seen that. And you're not going to see that. So Cc single bonds are not reactive. They don't act as nucleophiles. They don't act as bases. They don't, and that's sort of obvious. If you take butane, it doesn't do anything. It doesn't react with anything. You could probably use that as a solvent. And I want you to contrast that with chapter 10. Here's what we're going to learn in chapter 10. And we're going to do it over and over and over and over and over and over and over. Have I emphasized that enough? We're going to do this over and over and over again. We're going to take substrates that have Cc double bonds in there. And I don't want to say until you're sick of it. I hope hopefully you'll be happy about it. We're going to use pi bonds between carbons, Cc double bonds, as bases and as nucleophiles. And so we're going to do this kind of stuff over and over and over again. So it won't always be attacking protons, but we're going to use that double bond as a nucleophile to attack things. That's this chapter. So get ready for that. Get ready to do that. What I just did, let me be clear because I want to make sure the arrow starts from the middle of that double bond. So we're going to do that over and over again. Now it's not quite as reactive as an alkoxide anion. And maybe depending on the type of electrophile, it can be about as reactive as an alcohol lone pair. We're going to see lots and lots of examples of this. So let's do it. That's what our chapter is about. Okay, another little introductory idea here. We're going to characterize, before we start talking about, I'm anxious to get started on those reactions, but I have to resist. They're so cool. And they're so much better than this SN2 business. Okay, we're going to talk about a way to characterize compounds based on their molecular formula and their structure. I'm going to give you a new sort of parameter that you can use to describe compounds. This will help you when we get to spectroscopy. When you're taking the 51LB lab, you're going to be doing all kinds of spectroscopy. Somebody's going to give you this super complex looking spectrum and a molecular formula and say, okay, what's the structure of the molecule? And you'll be going, you'll be freaking out. And so this is where this is going to help you. So you have to hold on for a couple chapters till we start NMR, but this is really going to help you when you get to that. So we're going to introduce an idea called degrees of unsaturation. It's a property associated with molecules and you can back it out knowing nothing more than the chemical formula. So once you know how many degrees of unsaturation there are in some molecule just by somebody giving you the molecular formula, you can very quickly rule out structures that don't match. And so the degree of unsaturation is basically the number of rings plus the number of pi bonds in the molecule. That's it. So a saturated alkane like hexane has no pi bonds and has no rings. So that has zero degrees of unsaturation. So let's practice figuring out the degrees of unsaturation in these five molecules here just by simply adding up the total number of rings plus the total number of pi bonds. So how many rings are there in this isobutylene, this two methyl propene? Zero. How many double bonds? Or pi bonds? There's one. There's a total degrees of unsaturation of one that has one degree of unsaturation. There you go, you've mastered it. Okay, let's switch over to this. Oh my God, there's an oxygen atom. Doesn't make any difference. Okay, so how many rings are there in this? There's one ring. How many pi bonds? There's zero. So here's another molecule that also has one degree of unsaturation. Okay, let's come over here. Oh, there's a triple bond. There's no rings in there. I can see there's no rings in this. This is called acetyl nitrile, common solvent. But now if I count the number of pi bonds, that triple bond has two pi bonds. So I have to add the number two here. There's two pi bonds in that triple bond. Each triple bond is composed of one sigl bond and two pi bonds. So this has two degrees of unsaturation. Okay, let's get to more complex structures. How many rings here up above? I see one ring. How many pi bonds? There's two pi bonds. That has three degrees of unsaturation. What you'll find is that typically the more degrees of unsaturation in your molecule, the fewer hydrogen atoms in the molecular formula. Okay, here's pyridine. It's a solvent we've talked about. I see one ring in there, quite plainly one ring. And then how many pi bonds? There's three. That has four degrees of unsaturation. So you have now mastered calculating the degrees of unsaturation or figuring it out. I hope there's an intuitive speed at which you can do this. And you might make little mistakes missing some of these numbers, but generally it's pretty intuitive. What you can't see yet is how you're going to use that. And again, you'll have to hold on with this degrees of unsaturation thing until we get to the spectroscopy chapter. It's really going to help you. Okay, so let's keep going. We're going to do things the other way. So now if I give you the molecular formula, and this is more typical, if I give you the molecular formula, what's important is you can calculate the degrees of unsaturation just from a molecular formula. And so let's practice that. But there's some rules I have to give you. And these rules are just going to seem super complex at first. It's like how can I apply all these complex rules when I'm under time pressure on an exam? Practice. I know you're going to do it. So here's our rules. So if you have some sort of a C and H compound that has nothing but Cs and Hs with N carbons, and you can figure out how many carbons just by looking in the molecular formula. So here's our example. C3H4, there's three carbons. N equals three. There you go. It's a three carbon compound. So I'll just write here N equals three. It's kind of obvious. You just look at C3, C5, C whatever. Okay, so how do we figure out the degrees of unsaturation? What we figure out is what's the maximum number of hydrogens you could have on a molecule that has three carbons? Let me just try to sketch it out here. I'll just use a different pen color somewhere here so we don't get in the way. If I had a three carbon alkane like that, how many hydrogens at most could that have? Eight. Well, you guys are good at that. Okay, two N plus two. That's the maximum number of hydrogens. So if this compound had zero degrees of unsaturation, it ought to be H8, but it's not H8. It's actually H4. The actual number of hydrogens here, four. So you can tell it's missing some hydrogens. C3H4 is missing hydrogens. And what we do is we now divide this difference by two. There's four hydrogens missing somewhere. And if there's four hydrogens, we divide that number by two, eight minus four divided by two. So how did I calculate this? Equals eight minus four divided by two divided by, and that equals two. That's the degrees of unsaturation. And the idea is that it takes two hydrogens to add to a double bond, a C-C double bond. That's why you divide by two. Okay, so how do you use this? Later when we do spectroscopy, I'm going to say here's a molecule with the formula C3H4. And here's a spectrum. What's the structure? And the first thing you need to do is start drawing out some plausible structures that fit C3H4. So I can think of two things that have two degrees of unsaturation. There's a third one I'm not going to draw. There's really only three simple alkenes or simple molecules that have this formula. So here's a molecule that has two degrees of unsaturation and fits that formula. Two double bonds. Or I could have one double bond and one ring. So you need some simple way that allows you to quickly draw out plausible structures. And knowing how many rings and how many pi bonds there are in a molecule is the fastest way to help you quickly sketch out some structures. That's why you, how you're going to use degrees of unsaturation. Okay, let's keep practicing here. So I've got some special sub-rules here for oxygen, halogens and nitrogen. So the oxygen rule, little add-on rule is ignore the oxygens. They don't affect any of those things I just told you. Okay, so let's come down to a molecule C3H6O. So here N equals 3. And what's the maximum number of hydrogens I can have if N is equal to 3? Well, it's still 8. If I have three carbons, the maximum number of hydrogens can be 8. And the number of oxygens you have in there doesn't matter. Okay, how many hydrogens are there on this? Well I just look, it says H6, there's 6. And so how many degrees of unsaturation are there in this molecule? There's 1. 8 minus 6 is 2 and I divide by 2. That tells me there's either one double bond or one ring in this molecule. I can very quickly sketch out the possibilities. Once I know there's either one double bond or one ring, that makes it very quick for me to sketch out a bunch of possible structures. Okay, halogens are a little bit more complex. Our rule is, so let's start off with this rule again. So here's C3H5Cl. There's three carbons. And so the maximum number of hydrogens is still 8. That's always going to be 8 with a C3 compound. Sorry, the maximum hydrogens. The actual hydrogens is H5. But we have this special little modifier rule if we have a halogen. We have to add 1 to the actual number of hydrogens for each halogen. Whenever I have a chemical structure and I have a halogen on there, I had to pull off an H in order to add that halogen. Chlorides go in the same place where hydrogens do. So in order to back out the degrees of unsaturation, what I need to do here is apply this rule where I add 1 to the actual number of Hs, 5 plus 1. Now I can take the difference. Now I can take the difference between the maximum number of hydrogens and the actual number of hydrogens. So I say 8 minus 6 is 2. And then 2 divided by 2 is 1. There's 1 degree of unsaturation in C3H5Cl. And now that I know there's 1 degree of unsaturation, I can very quickly sketch out some possibilities that have either one ring or one double bond. Here's one example. I mean, I could invent all kinds of structures that have either one ring or one double bond. Here's an example of something that has just one ring and a chloride somewhere. And you can draw three-membered rings, et cetera. So wait, that's not C3H. Sorry. It should be three carbons. That's supposed to be a cyclopropane, cyclopropyl chloride. Okay, so I could very quickly sketch out plausible structures that fit that formula that have either one ring or one double bond. Okay, so things can be crazy and complex looking. Here's a compound that only has two carbons. So I'm going to say n is equal to 2. What's the maximum number of hydrogens? Should be 6. Ethane has six hydrogens. Okay, but now we look at the actual number of hydrogens. It's H4, and I have to use these little modifier rules. Okay, oxygen doesn't matter, so let's ignore that. For each chloride or halide or bromide or iodide that I have, I have to add one. So I see one chloride, so I have to add one there. But now there's another rule for nitrogen. For each nitrogen I have, I have to subtract one from the actual number of hydrogens. And so overall, my net number for hydrogens is going to be 4 because I add one for the chloride, I subtract one for the nitrogen. And so the difference between these two is now 2 again, and so now this has one degree of unsaturation. That tells me that this molecular formula, all compounds that have this molecular formula, I have either one ring or one double bond. And so I can quickly sketch out some plausible structures. Okay, so you're not going to use this chapter. Well, there will probably be a few sapling problems to get you to practice this. You're going to end up waiting until we get to the spectroscopy chapter, and this is going to be your favorite tool for allowing you to quickly sketch out structures when I ask you to tell me the structure of some molecule that has the formula C2H4NOCL and matches this crazy complex spectrum that I'm going to show you. You need some way to narrow down the number of structural possibilities. And that's when this is going to be useful. Okay, so sorry I had to show this to you, but just hold on with this. Yeah? Why is fluorine at the halogen? It would belong there, but sorry, you're never going to see fluorine this quarter. I don't think, yeah. Yeah, but fluorine would fit with the halogens. It's just not common in Chem 51. Sorry, I should have put it there. Okay, so let's talk about nomenclature. God, I really want to get to the chemical reactions, and I'm feeling really... Okay, so I don't ask IUPEC nomenclature on my exams. Let me just write here on my exams. But I do ask that on the sapling because on the online problem sets because the standardized exams ask you questions about nomenclature. So the main thing that I really want you to know is that compounds that are alkenes, if the alkene is the highest priority group in the molecule, will end in Ene. As soon as you hear the suffix Ene, you know there's an alkene somewhere. So here's a polymer. I'm going to... There's four carbons here. Sorry, this is not a very high resolution pen. This is a polymer with four carbons. It just repeats over and over again. And this is called neoprene. And so if you went surfing this morning in your wetsuit, it was made out of this polymer. And just from the name neoprene, you know there's an alkene somewhere in the chemical structure of the polymer. And there's also a chlorine atom there. So that's kind of the level at which I know nomenclature. I listen for the word Ene and it tells me, oh there's a double bond in there. Okay, but let's talk about this idea of configuration that double bonds don't rotate easily. I'm going to draw two types of molecules for you. And we'll talk about this nomenclature cis and trans. So here's a four carbon compound. It's not butane, it's butane. And one way that I would distinguish these two molecules, let me draw the hydrogens there. Because sometimes the best way for you to keep track of alkenes and whether they're cis or trans is to look at the hydrogens that aren't drawn for you. That helps you to keep your focus on the fact that both sides of the alkenes are different. Okay, so here's two alkenes, two butenes. That's two butene. And they have different double bond configurations. One of these is trans. And that means that the two alkyl groups are on opposite sides. The two highest priority groups are on opposite sides. And it's a description of the overall molecule. If a molecule has only one double bond, I could say, oh that trans butene over there and it's totally unambiguous what I'm talking about. If there's only one double bond and I say it's trans, that means the two highest priority groups are on opposite sides. If I say that cis molecule and there's only one double bond. Or if I say that cis double bond, I'm talking about the double bond where the two highest priority groups are on the same side. Okay, the problem comes if I have more than one double bond in a molecule. I can't say, oh, if there's more than one cc double bond, I can't say that trans alkenes because you don't know which one I'm talking about. And that's where IUPAC nomenclature comes in. So IUPAC nomenclature works. It uses these descriptors. It doesn't use trans and cis. It uses E and Z to distinguish these. And it's useful even if there's multiple, multiple double bonds in your molecule. So according to IUPAC nomenclature, so let me write this above here, that this isomer is the trans isomer. And this isomer over here is what I would call the cis isomer. The way I might also use these descriptors, I might say, oh, that's a trans double bond and the other one is a cis double bond. I might focus in on the functional group and describe the double bonds that way. Okay, but now let's switch over to IUPAC and that E and Z thing. This makes perfect sense if you're a native German speaker. But if you're not, then the use of the letters E and Z probably is not so obvious. The IUPAC name for this is that it's not butane, it's a butene. And specifically it's E2 butene. What does that mean? E tells you that that double bond has a trans configuration. That's what E means. And for this other isomer over here, it's also butene and the double bond is at the two carbon, two and three, so it's two butene. And this one has the two highest priority groups, cis to each other. So we call that, and I can't do it here with a pen, but those are italics font, the E and the Z. So E2 butene for the trans isomer, Z2 butene for the cis isomer. And every time I have a double bond in there, I have to describe that double bond as either E or Z, and I'll show you an example down at the bottom. So what do these things mean? E stands for entgegen in German, entgegen means opposite, meaning they're on opposite sides. Z stands for zusammen, which means together, and that means these are together on the same side. You're going to need some sort of a simple, well, here's a simple way if you're not a native German speaker to know this. Some people say this, oh, anze zahn zahd. You don't need to speak German to remember that. Okay, so typically, the kinds of compounds that you will be exposed to typically will not be nameable by you using the rules we give you in Chem 51. Here's one of the most important molecules in lipid signaling. A biologist would call this 5HP, because they don't want to say the whole IUPAC name, which is 5-hydroproxy, 6E, 8Z, 11Z, 14Z, acosatetraenolic acid. Nobody wants to say that. But this would be an example of a super complex but important biological structure that's important in inflammation, prostanoid signaling, where you can go back and decipher what they're talking about. So this is a carboxylic acid. I can see it ends in oic acid. And I don't expect you to know the name of this or how to name something as complex, but I want you to see how this E and Z nomenclature works. I can't simply say, oh, there's that lipid molecule. It's a trans-isomer. Well, there's more than one double bond. Some of the double bonds are trans and some are cis. I can't just say trans or cis. This is where we have to use that E and Z thing. So you don't know what acosatetraenic acid means. You just need to know that there's a lot of carbons in there. But if we number this thing by using the IUPAC numbering, the carboxylic acid would get the highest priority number, 1. And I'll keep counting down the chain here, 3, 4, 5. Here's carbon 6. That's our first double bond. And look at this. This is 6E. That means you know that the double bond that starts at carbon 6 is a trans-isomer. And then I keep going over here. I get to carbon 8. There's carbon 8 down there. And sorry, my pen doesn't have high resolution. And you can see that carbon 8 is 8Z on the same side. It's a cis double bond, and the two substituents on there are on the same side. You could keep going. You can see how the IUPAC nomenclature in this EZ stuff works. And this is a typical molecule where you have so many double bonds. And you need to keep track of which double bonds are cis, which double bonds have the Z configuration, and which double bonds have the E configuration. I won't ask you anything that complex. That would be crazy. I don't ask IUPAC nomenclature on my exam. But someday, if you're working in some biochemistry lab and somebody flashes you this complex structure, you might be able to sketch something out that would tell you something about configuration. OK. So typically, the way I expect you to nomenclature on my exam, I might ask a question that would say something like, draw the Z product of the following reaction. And you wouldn't have to name the molecule, but you need to know what a Z isomer is, or an E isomer. And I expect you to know cis and trans. OK. Here's another, there's all these other sections in this chapter that they stick in the front to slow down how quickly we can get to the chemistry. Here's sections 10.4, 5, and 6. It's about physical properties like, what's the boiling point of an alkene? What are some structures of interesting alkenes? And what are some alkenes that you find in lipids? These are all very cool ideas, but I'm not going to put these on my exam. But the only thing I could really do is ask you true false questions. And I don't do that on my exams. I ask you to draw structures and stuff. But let's talk about why should you care about alkenes? Why should you care about degrees of unsaturation? And I think the most important reason that you might care about things like degrees of unsaturation, how many double bonds there are in a molecule, might relate to nutrition. If you look now on the back, on the label of every single food item that's sold, aside from fresh produce and meats and things like that, they now summarize for you the unsaturation and the double bond content of the fats that are in the food that you're eating. So let me just remind you of the structure of a fat versus a lipid. So up above here, I have a lipid molecule. And it's got esters, ester functional groups, two of them, carboxylic esters, and then it has a phosphate ester on there. And these are attached to a three carbon unit called glycerol. So that's a basic lipid. And that makes up the outside membrane of all of your cells. Now you also have, inside of your dipocytes, you have a fat molecule that looks very similar to a lipid. And the difference is that with a fat molecule, you've got three esters. And there's no phosphate or polar head group on that molecule. But what I've drawn here with these squiggly lines are some very long chain carboxylic acid groups. So all of these little squiggly lines that I've drawn here look something like this. They either look like this long chain with two double bonds. You can have as many as four double bonds in these long chains. You can have as few as zero double bonds in those long chains. Or you can have one double bond in those long chains. And so the main thing that you need to know is that the saturated fatty acids that have zero degrees of unsaturation tend to be waxy solids. When you have fats that have no double bonds in there, those tend to be solids. If you go to the grocery store and you want to buy some kind of a fat that's a solid, lard, butter, shortening, Crisco shortening, those are all composed of saturated fatty acids. If you want a liquid fat, vegetable oil, vegetable oil is soybean oil. They just don't want to tell you soybean. So soybean oil, safflower oil, corn oil, those all have double bonds in them. And lots of double bonds. The more double bonds, the more thin the liquid, the more liquidy the liquid. And so that's the distinction that you need to know. So you don't want waxy solids to deposit. This is a sectional view of a clogged artery where you can see there's very little space in here for the blood to flow. You don't want the waxy fat deposits to start building up in your arteries. There's this whole process that starts. Your immune system starts glomming onto that and it includes the arteries. And once you include the arteries, you're right in your heart. It's a bad situation. So they now tell you on the food packaging just how many saturated fats there are in that food. They're the percentage of saturated fats. They tell you that. They're telling you chemical information. For years, they grouped trans alkenes, like this one here, with the good fats, the liquidy ones, which is weird to me because when I look at the structure of that trans alkene, I just happen to know it's going to adopt a configuration that looks like a saturated alkene. And it seems like only about 10 years ago, people started to say, you know what? That needs to be grouped with saturated fatty acids. You can't just have any old alkene in a fat molecule and have it be liquidy. It has to be a cis alkene. So I think about 10, maybe eight years ago, they started to tell you not just how much saturated fat, but also how much trans fats there are because those are going to clog your arteries. And you don't want to clog your arteries. That's a bad thing to do. Okay, so unsaturation. It's on every food packaging. They tell you, they're telling you about how many double bonds are on the molecules of the fats that you're eating. Okay, so let's have a review. Let's review some of the stuff that you've already seen in chapters. I just can't get away from this stuff, seven, eight, and nine. I'm just going to retell you the stuff that I just finished telling you on Monday because why not? Let's talk about the ways that you know for how to make alkenes. You already know how to make alkenes to synthesize them. And so it's just a review. I can't review everything, but I'll review a couple of my favorite ways. So some of my favorite ways to make alkenes are E2 elimination reactions. Oftentimes, so let's practice some abbreviations. Oftentimes I'm going to abbreviate CH3 groups, methyl, with the letters ME. It's just a stylistic preference. It looks a lot cleaner on a page because I don't have to write subscripts. You'll find that many synthetic chemists and organic chemists abbreviate CH3 groups, methyl groups as ME. And so you have to get used to that. So here's a methoxy group at the end of my alkane. And so here would be an example of how I might like to make an alkene. I have some sort of a leaving group here. So here's two oxygen derivatives, a methoxy group and a tosylate group. One of those is an outstanding leaving group, and that's the tosylate leaving group. And I want you to start getting used to using that because you spent so many chapters now talking about halogens get away from that. Tosylates are much easier to, you're going to see them much more commonly. So if I throw a strong hindered base in here, you know, most alkoxides, there's not a huge difference between the most hindered and least hindered alkoxides, but tbutoxide is the one that's most hindered. So here's another abbreviation that I'm going to start using, that tbutyl. So this is the same as what the book writes. The book writes it like this. So that's the way you're used to seeing it from the book. I'm going to start writing O-tbutyl. And you just need to know that that's the same as this potassium terbutoxide. So when I come along and I say, oh, I'm going to take this tosylate here, notice my, I didn't call it an ether, I want to focus your attention on the most reactive part. So I say, oh, see that tosylate over there? Let's throw in some tbutoxide base. So I might draw it like this, tbuO minus potassium plus. Or I might leave out the minus and the plus and just draw it as a molecular formula kind of style. And so this is going to do an E2 elimination. There's beta protons that are on the beta carbon that will get pulled off. And this would allow you to make, oh, I can see I'm reorienting my carbon chain there, but that's okay. So I had started with three carbons. I still have three carbons. And I introduced a new double bond. So I expect you to know E2 eliminations. They're great reactions. They're useful. So let's go ahead and talk about the alternative. Sometimes you typically have a halogen leaving group or a tosylate leaving group. You need good leaving groups for E2 eliminations. By the way, E1 and E2 are not the most common elimination mechanism on organic chemistry. You're going to have to wait until chapter 23 before we show you the most common elimination mechanism in organic chemistry. It's not E1 and it's not E2. And I wish they showed it to you earlier, but we'll just have to leave that as a secret until you get to those chapters. Okay. So that's another way, other than E2 eliminations, to make alkenes. Let's take a tertiary alcohol just as an example. We showed you E1 processes as a way to do elimination reactions. So if I take this tertiary alcohol and I treat that with Pacl3 and pyridine or a strong acid and do a dehydration, I can very easily dehydrate this. I'll use the sulfuric acid approach here. So if you use sulfuric acid, not HBr or HI, because I don't want nucleophiles like bromide and iodide in there. Sulfate is not a good nucleophile, so you don't get SN1 reactions. This will very easily make an alkene. And again, pH, I'm sort of trying to get you to practice my abbreviations. And again, it's not just mine. The book will start using them more and more. That stands for a benzene ring, a phenyl group. And there's two of them on here. So you should be starting to get a lot of practice now with these reagents that we just learned in the alcohol chapter, chapter 9. Dehydration with strong acids, et cetera. Okay. So those are ways that I like to make alkenes. You should know how to make them. So when we come back on Wednesday, I'm going to show you a bunch of reactions that you can do with alkenes, where the alkene attacks something.
This is the second quarter of the organic chemistry series. Topics covered include: Fundamental concepts relating to carbon compounds with emphasis on structural theory and the nature of chemical bonding, stereochemistry, reaction mechanisms, and spectroscopic, physical, and chemical properties of the principal classes of carbon compounds. This video is part of a 26-lecture undergraduate-level course titled "Organic Chemistry" taught at UC Irvine by Professor David Van Vranken. Index of Topics: 00:22- Exterminators use rain-activated chemical to wash away bugs 01:54- Structure of bifenthrin 06:56- How to enumerate steps CHAPTER 10-Alkenes 09:37- 10.1:Introduction 10:51- 10.1: Introduction-Configurational stability of C=C vs. C-C 13:47- 10.1: Introduction-Contrast reactivity of C-C vs. C=C 16:59- 10.1: Degree of Unsaturation 20:40- 10.2: Calulate Degrees of Unsaturation from Molecular Formula 29:20- 10.3: Know cis/trans & E/Z 37:58- 10.4.5.6: Physical Properties, Interesting Alkenes, Lipids 42:48- 10.7: Ways I Like to Make Alkenes (so far)
10.5446/19474 (DOI)
So it's hard for me not to look at the news or walk in the world around me without seeing some place where organic chemistry doesn't become important. I saw this article or a reference to this article in the news that in China there was a factory spill where, I don't know if you can see this little laser pointer, but you can see it enrolled here. Approximately 39 metric tons of a compound called aniline got dumped into a reservoir and ultimately into the Shuangsheng River. You know a ton sounds like a lot to me. 39 tons sounds like an almost inconceivable amount. I feel like I can talk about what aniline is. This is the structure of aniline. We're going to talk a lot about aniline and benzene ring derivatives. It's a very simple compound aniline is. When we get to chapter 18 we're going to do a zillion reactions with aniline and when you get to the later chapter on Amine's chapter 25 in Chem 51c you're going to do a zillion more reactions with aniline. This is the molecule that started the field of organic chemistry. About 150 years ago in Germany people realized that they could take aniline and do a super secret reaction you'll see in 51c and make dyes. Prior to that they used to have to send ships around the world to collect dyes from indigo plants in India, plantations in India and other parts of the world. The idea that you could take simple chemicals that come from coal which you burn and make colored compounds which were extremely valuable really kicked off the field of organic chemistry 150 years ago. One of the things that strikes me when I look at the pictures that were published there were multiple news articles on this is that you look at the safety precautions that people are taking in order to clean up this mess. They're laying down bags of activated charcoal that's something that absorbs organic compounds. But their main precaution here is to basically wear rubber gloves and they're wading around in this sea of polluted water. One of the big problems here is that the water froze over and so they ended up just having to shovel up all this ice that was contaminated with aniline. So really heroic work on their part. I hope we never have that kind of a problem here in California or in the United States or really anywhere in the world. It's a real disaster. Okay. Unfortunately this is the kind of stuff that gives chemistry a bad name and I don't like that. Okay so let's return back to where we left off. When we left off on Monday I had shown you this very powerful reaction. It is super powerful and I tried to convey with you that this is a money reaction. And the mechanism I showed you when I drew the mechanism out, let me go ahead and try to contrast what I drew with what I would like you to draw. I want you to go back and correct your notes so that you and I are both writing the same mechanism as what's in the book. And it's different from the mechanism I would draw in a graduate class. That's why I messed it up. So in class notice up here I drew the arrow going up to oxygen to leave an O minus and then there's other stuff you could draw. But what I would like you to do is draw the mechanism on the bottom where when the chloride anion attacks that you use these electrons in this carbon oxygen bond here to make an O S double bond and simultaneously kick out the chloride. That's the mechanism the book shows. And I want us to try to stick with the book mechanism because we'll all be on the same page as long as we stick with the mechanism that's in the book. Okay, so just try to correct that, don't let the electrons here just drop onto oxygen, make an S O double bond. The main byproduct that you get here is sulfur dioxide gas. And I didn't show that. That's not really important for you. What's the important part here? You can convert alcohols into chlorides and that is a great reaction, thionyl chloride. Okay, suppose you don't want so just that simple little correction on the arrows to correct your notes. Just make sure we're drawing the mechanism that's in the book. And I want to just try to adjust the lighting here. There we go. All right, so what if you don't want chlorides? Suppose it's Wednesday and chlorides are so Monday and we're already on to bromides here. There's a key reagent we can use called phosphorus tribromide. And so I'm going to show you a reagent in case you just happen to not like chlorides, you can make alkyl bromides. And the overall transformation is very similar to that that we did with thionyl chloride. So if we want to take some sort of an alcohol and convert that to an alkyl bromide, I mean this is vastly better than just trying to dump in HBr or some acid. Notice first of all that this process leads to inversion of configuration. Just like thionyl chloride will invert a stereogenic center. Now actually, in most cases your alcohol is not a stereogenic center, but in case it is you'll get inversion. And the reagent that we use here is phosphorus tribromide, PBr3. It's that simple. And what's different about thionyl chloride is there's no pyridine base in this reaction. You generate HBr as the reaction proceeds, don't worry about that. You just let the HBr build up, it'll accelerate the rate of the reaction actually. It's auto-catalytic. So this is great for primary and secondary substrates that don't generate carbocations. You'll get this very clean conversion to the bromide. So let's go ahead and talk about the mechanism for this reaction. The mechanism that they show in the book, and again this is not the mechanism I would show in a graduate class, but this is a good mechanism for us in this class. So the mechanism they show in the book involves the hydroxy group directly displacing the bromide. And so I'll go ahead and draw it like that. So there's lone pairs on your alcohol hydroxyl group, and you've got this extremely reactive phosphorus tribromide reagent. And so now what happens, the book shows drawing this, and you directly pop out a bromide, and so now you've made an oxygen-phosphorous bond. And you're already well on the way to making this a fantastic leaving group. So now let me draw this oxygen with this new phosphorus bound to it. And I've got three bonds to oxygen. I can't have three bonds to oxygen without having a positive charge. So let me draw that positive charge there. That means that bromide got popped off somewhere. Let me draw that bromide floating around down here. There's my bromide anion, and I'll draw one of the four valence lone pairs on that bromide anion. So now I've got this good leaving group, and I can simply use that lone pair to push out this new oxygen-phosphorous leaving group. And that's an SN2 reaction. That's why you get an inversion of configuration. So if you want to make an alkyl bromide, don't just treat alcohols OH with HBR. You'll have all kinds of messy side reactions going on. PBR3 is the best way to do that. So the bromide attacks with inversion of a configuration. It's an SN2 process, and that's the mechanism for the reaction that I'd like you to draw for that. Okay, so very cool. There's incidentally this reagent. This is very similar. If you were cooking up methamphetamines this weekend, this is very similar probably to the method you were using. As you know, you go buy a thousand little matchbooks and you scrape off the phosphorus scratching pad. And then you mix that with iodine. It makes a reagent PI3. It's basically the same as phosphorus tribromide. Oh, why? Do you want to? You guys seem suddenly very interested. Yeah, so if you go to the store and buy 5,000 matchbooks, they know what you're up to. There's no secret there. Yeah, you don't have to show how to make phosphorus tribromide in this class. You just buy that if you work in a chemistry lab. Okay, so if you want to make chlorides, use thionyl chloride and pyridine. If you want to make bromides, just PBR3, phosphorus tribromide. And you don't need to add pyridine to this. In fact, don't add pyridine because that's not the right set of conditions that I'm showing you. Okay, so I just want to step back momentarily. It's like, why would you want to make an alkohalide? And what are some issues that come up when you try to make them? Like, ultimately, the reason, at least at this stage of your chemistry training, the reason you're being encouraged to make alkohalides is so you can convert alcohols into good leaving groups. Let me show you just the kind of thing that I'll often see people do that is kind of right thinking but very quickly goes in the wrong place. So let's suppose that we wanted to substitute this alcohol and make an ether. How do we do that? How do we substitute an alcohol and make an ether? I hope I'm drawing that. That's four carbons. So we need to do that. And maybe there's no one step way to do this. Let me show you how I don't want you to do this. And you'll be inclined to think that this is possible. What I don't want you to do is think, oh, what I learned in class is that I can protonate alcohols and they turn into good leaving groups. So I'll just add a strong acid like sulfuric acid. That converts alcohols into oxonium ions so I can have an H2O leaving group. And so if you did this, what you would have floating around is some sort of oxonium ion. And then maybe you could add some sort of a, and I'm going to have to abbreviate this phenyl with pH. And then maybe I could throw in some strong nucleophile to displace the leaving group. And that won't work. Let me show you why this will not work. I'll just write no here. The reason why that won't work is if you put phenoxide anion or any alkoxide anion, any strong nucleophile, it doesn't matter what the strong nucleophile is. Within the presence of sulfuric acid, you're never going to protonate the alcohol. Any nucleophile that's nucleophilic enough to attack a carbon-oxygen bond is very rapidly going to displace, is very rapidly going to deprotonate the sulfuric acid. And then you don't have sulfuric acid anymore and you don't have any nucleophile. You can't simply add acid and think, oh, well, the proton will stick on my substrate. So in other words, don't hope that you're going to get that proton to stick on the substrate like this and then just wait around for a nucleophile. Maybe you think you'll be clever and you'll add sulfuric acid first and then let it protonate and then walk over and get a bottle of nucleophile and dump that in. That won't work. If you have phenoxide anion floating around, if you add phenoxide anion to an alcohol that's been protonated, it's never going to attack carbon. It will always more rapidly deprotonate the proton. This is what's going to happen. So if you want to make an alcohol into a leaving group, don't try just dumping acid in. Use thionyl chloride and convert it to a chloride leaving group. Or if you want to convert an alcohol into a leaving group, use phosphorus tribromide and convert it into a leaving group. So the right ways to do this kind of stuff are like this. I take my alcohol, I use my money reaction, thionyl chloride, SOCl2. I always remember to put my pyridine base in there. And then I cleanly make the alkyl chloride. And now I can throw in any nucleophile I want. You get to pick whatever you want. I mean, it could be this phenoxide anion if you want. I think you guys are doing SN2 with phenoxide anions in the lab, not this week. I think you're doing recrystallization this week. And that makes this nice new carbon-oxygen bond so easy. And if you don't like chlorides, then you can simply add PBR3. That's your new reagent now. And then do the displacement with sodium phenoxide. OK, so as far as you know now, this is the reason to make alkyl chlorides. Because it allows you to make leaving groups where you can throw in whatever nucleophile you want. But that's not really why we make alkyl halides in organic chemistry. There's a secret reaction you're going to learn at the start of Chem 51c. Super top secret that I'm going to show it to you now. And I won't ask this to you on the exam because this is Chem 51c stuff. But if you can remember this, you're going to be golden for Chem 51c. Here's the super secret reaction from Chem 51c. What we're going to show is you can take any alkyl halide, chlorides, bromides, and iodides. And you add lithium or magnesium to that, lithium metal. Just store this in the back of your mind for another quarter. And this will really be valuable to you. And what will happen is the lithium metal will replace the chloride. And that is the most powerful nucleophile that we have in Chem 51. That's more powerful than alkoxide or amide anion, that alkyl lithium, that carbon-lithium bond that I drew here, is so nucleophilic that we're going to be able to use that to attack carbonyls. This is all of Chem 51c in a nutshell. Don't tell anybody I told you I'll be in trouble. And that's the best you can't quite tell because I did a bad job of drawing that CO double bond. But that right there is the best way of forming carbon-carbon bonds. It is better than any other method that you ever saw or will see throughout this quarter. So this is why we're teaching you to make alkyl chlorides. And you're going to forget about making alkyl chlorides when you get to 51c. And so let me just remind you, it's this CC bond forming process that you're going to use. So you don't need to use that now. Just kind of forget that or store it in the back of your mind. But this is why you really need to know how to make alkyl chlorides. And we're going to bring this back to you in about three months and hit you with it very hard. Okay, so how do I like to make leaving groups out of alcohols? In fact, I'm not a big fan of making alkyl chlorides and alkyl bromides. The book is a huge fan of that. The sapling problem sets that are pre-programmed in that I select from seem to be a huge fan of that. Here's my favorite leaving group, one that I love. It's called the Tosylate Leaving Group. So if you want the best and easiest way to make leaving groups out of hydroxyls, here's the way to do it. You take an alcohol of your choice. And what we're going to do is we're going to replace that H with some special functional group that makes the carbon-oxygen bond easy to displace. And so here's our reagent. It's called Tosylchloride. And we use subreviation TSCL. And over here you can see I've abbreviated Tosylchloride for you. Tosylchloride is a benzene ring with a methyl group on one side that's called toluene. And then on the other side there's this sulfoneal with the chloride. It looks a little bit like sulfuric acid. It turns out that it's very easy for nucleophiles to attack that sulfur and displace the chloride. So when you treat an alcohol with Tosylchloride and a base, and the base we use is pyridine. So this is kind of like thionylchloride in that you add pyridine. We'll have a lot of reactions that use pyridine as a base. That's why you're going to tend to forget what the phosphorus tribromide and accidentally write pyridine with phosphorus tribromide. And you have to avoid doing that. And so when you do that, it now creates something called a Tosylate leaving group. That OTS, that entire OTS is called a Tosylate. Let me go ahead and circle that just here so you can see that this whole group, Tosyl and Oxygen is called a Tosylate. And how do I label that? I've got the word Tosylate over here. There it is. I've underlined it. So that's a Tosylate leaving group. It is now very easy to displace that carbon-oxygen bond. What a fantastic leaving group we have here. And so I can add the nucleophile of my choice. And I'm just, for the sake of having some room, I'll draw a very small one like Sodium Methoxide. That'll very easily do an SN2 reaction. Let me draw some arrows here so we can see that SN2 reaction. There's my Alkoxide and it will displace. That whole Tosylate business is a fantastic leaving group. And usually I don't draw the bond between Oxygen and Tosylate. I just write OTS. Let me just complete some charges here on this Sodium Plus and Oxygen Minus. There we go. Okay. So you can use any nucleophile you want. Gee, what a great way to make a leaving group out of Oxygen. And so let's go ahead and talk about the mechanism for this so I can give you a sense for why this is a superior to Thionyl chloride or Phosphorus Tribromide for making leaving groups out of Oxygen, out of Hydroxyl. So the mechanism for this reaction, I'll take my super simple propanol substrate and involves the lone pairs on the Hydroxyl group attacking this Sulfonyl chloride leaving group. So this Sulfonyl chloride sulfur is tetrahedral. Mechanistically that's not important but I just want you to have a sense for the shape of that molecule. And so you can imagine the Hydroxyl group. This is the book mechanism that I want you to know. So you can imagine that Hydroxyl group just coming in and doing a displacement that pops out chloride anion. And there we go. We've formed an Oxygen sulfur bond. And now I'm smart enough to draw this OH bond because I know I'm going to pluck that proton off in the next step. And now I have this very electron withdrawing. I'm going to abbreviate that toluene, that benzene ring as tall. That stands for tall. But you can get what the abbreviation means just by looking over here to the left. Okay, so now we have this Oxygen or three bonds that better have a positive charge that really wants to be deprotonated quickly. And what's weird to you is that, or may seem weird to you is that gee, there's chloride in there. How come that chloride doesn't do some SN2 reaction? There's no way that's going to happen. The pyridine is going to so quickly deprotonate. Proton transfer reactions are always faster than reactions, comparable reactions that form bonds to carbon. So now that pyridine is going to come back in here and deprotonate that proton. And that's it. That's how we put the Tossel group on. This whole Tosselate thing, this whole contraption that I have attached here is my Tossel group, Tosselate group. So this whole thing is a great leaving group. Now what's the magic behind this that makes this so much better? Why is this so much better than the thionyl chloride? Because nowhere in this Tosselate business did I break the carbon-oxygen bond. When you make an alkyl chloride from an alcohol using thionyl chloride, you have to do an SN2 reaction with chloride. Nowhere in this bottom mechanism scheme did I have to break that carbon-oxygen bond through a lousy SN2 reaction. SN2 reactions are lousy. The more SN2 reactions you have to use to synthesize something, the more chances it's going to fail or give you elimination of some kind. So the fact that I can convert this oxygen into a great leaving group without breaking the carbon-oxygen bond yet means that this is just plain superior to thionyl chloride. So Tosselates work better in practice. Now maybe when you're just drawing reactions on paper, it doesn't matter. But what you'll find is that I tend to favor making Tosselate leaving groups over thionyl chloride. It's probably coming forward later in the chapter when I'm asking you, how do you synthesize this? I'll tend to pick roots where forming Tosselate leaving groups is the way to go. So Tosselate, let me just write here because that's one of your money reactions. So remember this one, make Tosselate leaving groups. The tough thing is you've had an entire chapter, two chapters on chlorides and bromides. It's going to be hard for you to steer away from that. And I get that. Money. Okay, so I showed you ways to take alcohols and do chemistry with those. You can convert alcohols to chlorides. You can convert alcohols to bromides. You can convert alcohols to Tosselates. So what can you do with an ether? There nowhere near as reactive, but you can break carbon-oxygen bonds with ethers. So let me take an example. And there's a strategic thinking here. Here's an example of an ether where one of the carbons is tertiary and the other is primary. And I like that distinction because those are hugely different. I hate secondary because I can never figure out whether it's elimination or substitution or what's going on with those. In the lab I avoid secondary substrates because the molecules don't know what to do either. So here's an ether. This is T-butyl methyl ether. This carbons tertiary. This carbons primary. So if anything is going to happen, so let's suppose I add an acid and protonate this ether. There's two different things that can happen. One thing is that the tertiary carbon can pop off the oxygen and form a carbocation that's stable. The other thing that can happen here is that bromide can substitute at this very unhindered carbon and do an SN2 type reaction without forming a carbocation. And in practice you'll see both. So if you add two equivalents of HBr you'll get this through an SN1 reaction and I'll show you the mechanism for a minute. And you'll get this through an SN2 reaction. In other words you can cleave both of the carbon-oxygen bonds by adding HBr. Okay, so let's draw out a mechanism for this for how to think about this. And the main thing I want to do is give you a sense for under typical reactions which carbon-oxygen bond breaks first under typical reaction conditions. So when you take HBr, excess HBr, and you put it in here, the first thing that's going to happen is that we're going to protonate that oxygen. HBr is a very powerful acid of three bonds to oxygen and I wish I had drawn a bigger bond, a more space there for my bond. But there's lone pairs on this oxygen and they're going to pluck a proton off the acid because that's such a strong acid. And I'll get this oxonium ion, oxygen with three bonds. That oxygen wants to take its electrons and walk away. And so the main thing that you wouldn't know right now, there's no way you could know this. I simply have to tell you otherwise you couldn't know, is it under typical concentrations where you would run this reaction. And this is concentration dependent. You've got a choice. Either the bromide with its lone pairs can come in and attack the methyl or you could simply ionize out the oxygen. And it depends on the concentration of bromide. If I have, if I dump in sodium bromide and have 10 times the concentration of bromide, the bromide will attack the methyl group faster. But under typical reaction conditions, that's not fast enough. Under typical reaction conditions, this bond simply cleaves before bromide can attack that methyl. And you couldn't have known that. I simply had to tell you that this is, of the two possibilities, this is the more likely to happen faster. So you generate a t-butyl carbocation. There's my t-butyl carbocation. And your byproduct is methanol, momentarily. And so what happens now is that the bromide anion that's floating around in there can come in and easily attack. Let me draw that bromide. Just adding into that, that pathetic looking carbocation that doesn't have an octet. And now the alcohol that's in there can be protonated by the second equivalent of HBr. So this equation I showed you up above, I showed two equivalents of HBr. And so now we simply reprotonate that. And now the slower reaction. This is not quite as easy. So now the water's okay, a decent enough leaving group to where this bromide can now attack this very unhindered. There's no hindrance with a methyl group. Whoops, I wish I were using green there just to be consistent. That bromide anion can now displace to make the methyl bromide. So that's the mechanism for the reaction. That's not a very, I would say that's not a very interesting reaction. But we have to show you something you can do with ethers. We have super secret reagents that involve boron, that involve similar mechanisms that are a little bit more efficient for cleaving ethers. But we won't show you those in the lower division classes. Something for upper division classes. All right, so ethers, you can cleave them, use strong acids, could protonate oxygen and make oxygen into a leaving group. It's good with HBr and HI because bromide anion and iodide are so nucleophilic. It's not quite as good with HCO. I can't think that I've ever seen that in my personal experience. Okay, so strong acids can cleave ethers, especially if they're tertiary and can form stable carbocation. Okay, huge shift in gears now because I want to talk about an ether that's a special ether and that's an epoxide. So let me go ahead and draw out an epoxide here. And I want to admire the ring strain in that epoxide. Oh my. You know, carbon and oxygen, second-rate, typically want, if they've got four bonds to them, typically want to have 109-degree bond angles. And that epoxide has 60-degree bond angles, 60, not 109-60. There is a lot of strain in there. And that means that we can use nucleophiles to a cleave epoxides which are ethers in ways that we couldn't do any other kind of ether. So I'll show you a typical sort of reaction sequence here. And what I want you to do first is note that I'm enumerating my steps. And this is something you're going to have to learn how to do. I'm going to throw in my nucleophile sodium, this sodium thiolate nucleophile that's Na plus SET minus, or if you just stuck them together and didn't write the plus and minus, that's okay. So there's a thiolate anion there. That's a great nucleophile. It's way more nucleophilic than it is basic. And we'll draw out a mechanism for this. It will add in and open up that epoxide. And then in step two, I have to protonate the O minus that I generate. And so I have to write a step two. So I'm enumerating these, step one and step two. If I leave out the one and the two, the enumeration, that's wrong. I can't simply mix sodium ethox. Well, you'd get a poorer reaction if you simply mix the sodium ethoxide anion in the water. It would not be as good. And I'll walk through the mechanism just momentarily. See how I've made a sulfur carbon bond? And over here where the O minus sprung up, the point of swamping that with a ton of water, I write the word workup. It just means you shake it with a bunch of water, as that you protonate the O minus. Okay, so let me draw out that mechanism for this. Okay, so again, we're going to see this a lot, this idea of working up reactions, water workup, excess water. The reason is it's just very hard to isolate anions and cations. And chemists always want to convert charged molecules into neutral molecules, because then we can extract them into organic solvents. So the word workup means I was just trying to take O minus and convert it into a neutral OH. So you'll frequently see us add water in a way that looks like a reagent. I usually write the word workup, so you know I'm simply trying to stick a proton on some anion to get a neutral molecule. Okay, so let's go ahead and draw mechanistically what's happening. First step is nothing more than a simple SN2 reaction. And I say simple, it works because of the ring strain here. So here's my thiolate anion. And my thiolate anion comes in and attacks this very strange system, and it attacks on the least hindered side. Just like all the other SN2 reactions that you've seen so far. It attacks the least hindered side of this epoxide. If they were both equally hindered, you'd probably get a mixture of attack on one side plus on the other side. But I was careful to pick something where the two sides are dramatically different in terms of steric hindrance. So that strain is what makes that work. And so now we pop this open, and we have this O minus floating around. And I don't have any good way to isolate that in the lab. So in the laboratory I need to protonate that so I can extract it into an organic solvent. This is why you use water. And it's kind of like Le Chatelier's principle. If we just had one equivalent of water, you know, I'll end up with a one-to-one mixture of hydroxide anion and my alkoxide. You have to use a ton of water to make sure you fully transfer all the protons over to this alkoxide in order to neutralize that. And so the end result is I have a neutral organic molecule that I can isolate. I can extract it into an organic solvent and then evaporate all the solvent off. And there I go. I've got pure molecule there. So that's the point of the workup is I don't want to end up stuck with this sodium alkoxide trying to isolate that. Let me draw the sodium counterion here. That would be really hard to isolate in the lab. It's very easy to isolate neutral organic molecules. So there's all kinds of nucleophiles that you can use like this to do SN2 reactions on epoxides. I could have used a methoxide anion. I could have used a phenoxide anion. I could have used an azide anion. It's a nucleophile you forgot about back from chapter 7. So epoxides have all this strain built into them that allows you to do SN2 reactions on them. Okay, so let me just remind you of the distinction between epoxides which are ethers and typical ethers. Yeah, epoxides. So let's just be clear here about what the differences are. And I'm going to try to jazz this up. I'll make one of these an ethyl group because I'm tired of drawing the same epoxide every time. So we're going to have all kinds of reactions where we can throw in nucleophiles that thylate anion, alkoxide anions. There's just enough ring strain. It sounds like a lot of ring strain, 26 kC per mole. But alkoxides are lousy leaving groups. There is just enough ring strain to allow you to do this SN2 reaction. Just enough. And I'll just write here. The reason why you can attack an ether like this is because of strain. But if you have any less ring strain, it doesn't work anymore. So in other words, if I have a four-membered ring, it doesn't work. You can't do SN2 reactions on this kind of four-membered ring with basic anionic nucleophiles. So it's not enough strain. So you won't get SN2 with an alkoxide anion. So I'll just write no. Don't try to use. It's not that there's not strain there. I'm just saying you don't get any SN2. And a five-membered ring, look, if a four-membered ring doesn't have enough ring strain, of course a five-membered ring doesn't have enough ring strain. No. If you try to do just a regular acyclic ether like diethyl ether, there's not enough ring strain. It's only epoxides that have enough ring strain where you can use anionic nucleophiles like alkoxides or thiophenylate anions in order to push those open. It's just too hard with any other kind of nucleophiles. So epoxides are obviously very special ethers, even more special than four-membered ring ethers. Okay, I want to strongly contrast these kinds of basic reaction conditions where I have alkoxide anions and thiophenylate anions. Those can open epoxides by attacking the least hindered side. But now, let's switch gears. Totally different universe. We're going to talk about epoxides and acidic conditions. This is going to be hard for you to keep straight. What does it matter? Epoxides and basic conditions, epoxides, acidic conditions, makes all the difference in the world. And I'll show you how the results will differ here. I'm going to take exactly the same epoxide that I showed you before. And this time, I'm going to run the reaction in the presence of sulfuric acid. And I'll write catalytic here just so we can remember that the role of that is as a catalyst. And as you might guess, the sulfuric acid is going to protonate the epoxide. Now I can't throw methoxide anion in with sulfuric acid. If I throw methoxide anion, it's simply the sulfuric acid will simply protonate the methoxide anion. But I can throw neutral methanol in. I can use that as a solvent. It's a cheap solvent. And so now when we look at the result, yes, the methoxy group is going to attack the substrate. But let's take a look at the regiochemistry here. In this particular case, and I'm going to use a colored marker here so you can see the new bond that I formed, the methoxy group attacks at the more substituted position. Right, in the previous example that I showed you, it was totally expected. Oh yeah, nucleophiles always attack more hindered positions. And now suddenly I'm showing you that the nucleophiles attacked the less hindered positions. Now I'm showing you that the nucleophiles attacked the more hindered positions. What are some common nucleophiles for these reactions of epoxides under acidic conditions? Let me just make a little list of the common nucleophiles. One would be to have water act as a nucleophile where you replace the H bond with some carbon. Another would be just like I showed you here, to have an alcohol act as the nucleophile. And then another example would be to have HBr and even HI, not so commonly with HCl, but HBr and HI would be common nucleophiles. Now whether it's where the H would end up here and the bromide would end up there or the H would end up here and then the OH nucleophile would end up there. Okay, let me walk through the mechanism because there's no way in the world on the planet that you could guess this. So the first step you could guess. I'm going to abbreviate my acid with the symbol HA. And the first step I think you could guess, it's simply that you protonate the epoxide. And that converts the alcohol now into a good leaving group. But when I draw this, when I draw this next intermediate, I'm purposely going to distort it so you can get an appreciation for what happens when you protonate a strained epoxide. What I'm going to do is I'm going to distort it so you can see that this bond to the tertiary center is now elongated. In a way, you can kind of think of this bond to the tertiary center as kind of prebroken. It's almost like it doesn't pop open and make a tertiary carbocation. But it's almost as though this oxygen is walking away with its electrons already. So the bond to the tertiary center is now easier to break. And that's what you couldn't have guessed. And so now I'm going to show you something that should be totally unexpected to you. And that is that nucleophiles like water, like bromide anion, anything that can exist without being totally protonated in sulfuric acid, they don't attack with this charge on here. They don't attack at the less substituted position. They attack at the more substituted position. So if you had some kind of rule in your head that, oh no, you don't do S2 attack at tertiary center, yes you do. In the case of strained three-membered rings that have positive charges, you always attack at the more substituted position. So there is no rule that says you can never do SN2 at tertiary centers. This is where you do it. Three-membered rings with a positive charge on one of the atoms in the ring. And it's going to be hard to get away from this. You've now had three chapters telling you never do SN2 at tertiary centers. Okay, so here's the next intermediate. We've got this inconvenient proton sitting there on that nucleophile. So let's get rid of it. There's three bonds to oxygen. There has to be a positive charge on there. I've still got my A minus leftover from my acid floating around. That's my symbol for sulfate anion or anything that's got a lone pair in solution. That simply plucks the proton off and gives me my product in the end. Okay, so do you see how this is totally different from the methoxide under basic conditions? Methoxyne anion attacked the least hindered side. But under acidic conditions, A, I can't have methoxide. I have to have methanol. Methoxide would grab the proton off sulfuric acid. So under acidic conditions, you can't have anionic nucleophosphate methoxide. They'll simply protonate. So you use methanol and that attacks at the more substituted position. And it goes with inversion of configuration. It's not obvious with this particular substrate, but you end up getting inversion of configuration at that center. And that means it's stereospecific. Okay, let me just give you a quick heads up for something you're going to, you see, this is the last slide and I'm simply going to, well actually I'll draw these for you instead of showing them. I just want you to see in one slide this summary of epoxide reactivity. So let's go ahead and start off. If I have an anionic nucleophile under basic conditions, those attack at the less substituted position. But if I choose to use acidic conditions and I rely on the protonation of my epoxide, you typically don't have anionic nucleophiles like methoxide. You have neutral nucleophiles and those attack at the more substituted position. So under basic conditions with methoxide and things like that, you attack the less substituted position. With acid catalysts like sulfuric acid, you attack the more substituted position. So that's the important, sorry my arrow here doesn't look so nice. Okay, you're going to see stuff like this again later. In the next chapter, get ready, in chapter 10, I'm going to show you this kind of idea again. We're going to have species that you've never seen before called chloronium ions, strained three-membered rings where there's a charged atom in there. And what you're going to see in chapter 10 is that nucleophiles attack those at the more hindered position. In the next chapter, I'm going to show you the same thing with brmonium ions that are three-membered rings. And nucleophiles will attack these at the more hindered position. So you can see the analogy with protonated epoxides, this weird thing called a chloronium ion, this freaky thing called a brmonium ion. These three-membered rings are special and it's only three-membered rings. You attack at the more substituted position. Everything else is the same way you've learned it. Avoid steric hindrance and attack at the less substituted position. But it's this positive charge. Okay, so that's it for chapter 9. On Friday, we're going to start with chapter 10 and do, and we're going to learn a lot of reactions in chapter 10.
This is the second quarter of the organic chemistry series. Topics covered include: Fundamental concepts relating to carbon compounds with emphasis on structural theory and the nature of chemical bonding, stereochemistry, reaction mechanisms, and spectroscopic, physical, and chemical properties of the principal classes of carbon compounds. This video is part of a 26-lecture undergraduate-level course titled "Organic Chemistry" taught at UC Irvine by Professor David Van Vranken. Index of Topics: 00:18- Chemical leak into river puts focus on plant 00:53- Structure of Aniline 02:35- 9.12A: SN2 conversion of R-OH to R-Cl with SOCl2 4:03- 9.12B: SN2 conversion of R-OH to R-Br with PBr3 08:51- 9.12C: Why make alkyl halides? 14:57- 9.13: Convert R-O-H to R-O-Ts 22:16- 9.14: Reactions with Ethers with Hl and HBr 28:29- 9.15A: SN2 Reactions of Epoxides Under Basic Conditions 33:29- 9.15A: Reactions of Epoxides Under Basic Conditions 36:00- 9.15B: SN2 Reactions of Epoxides Under Acidic Conditions 41:46- 9.15B: 3-Membreed ring "onium" ions = strange regioselectivity
10.5446/19473 (DOI)
Every time I open the news, I seem to see some article, or at least the past week, about something called the Consumer Electronics Show. And I guess this is one of the kinds of devices that they were showing at the CES. And you're going to see a lot more of this. So technology is changing this year. These won't be the same anymore. So I think a lot of you have heard of this idea of OLED. I mentioned before that many of you have cell phones, maybe Samsung cell phones that are AMOL-ED, Active Matrix Organic Light Emitting Diode. So that's this term right here. So in the future, and I'm not sure how far in the future this is, two years, three years, instead of having a projector screen like this and a light in the back. So the projector is a bright light, and it filters the light to make these pictures. In the future, there won't be a projector. There's just going to be a paper thin screen here, and all the light will come from this screen. This will be the source of light. There won't be any projector in the back that can make a shadow like this. And all of that has to do with this idea of organic light emitting diodes. And so what you're starting to see are new displays that are super-duper thin, not quite paper-thin, but pretty darn close. And that's all organic chemistry that is making that possible. So if you look at the future of displays that are going to power your television sets, your computer monitors, your cell phones, this is all made possible by organic chemistry. So at the same time that they're making display thinner, what organic chemistry does is it allows you to have flexible displays that can now be bent without breaking. You're not going to have to worry about having a super hard cover for your iPhone because there's no worry about organic displays shattering. So again, the future of super-thin displays is already here, and the future of bendable screens. That's already here. And it's made possible by organic molecules. So I mentioned this term OLED. So every time you hear the word OLED, this is stuff we're teaching you how to do in class. The idea behind an organic light emitting diode is if you take a certain class of organic molecules and you expose them to an electrical potential, they start to emit light. And these are some of the game-changing types of organic molecules that emit either red, green, or blue lights that you can modulate the wavelength by changing the structure of the molecules. And I would say this may look a little bit strange to have iridium in here. That's too expensive for general use right now. But aluminum, this is already being used in the displays in your cell phones and in these super-thin TVs. Well recently people have moved to polymers. And by the end of this quarter, you're already going to be able to make things like this, to synthesize things like this, and particularly by the end of next quarter in Chem 51c. And you just need to get out of here and go do that. Go make a billion dollars and be the people driving the next generations of display and the next generations of technology. So every time you use your cell phone, that's organic chemistry going to bat for you. Okay, I'd like to pick up where we left off. We left off talking about E1 dehydration of tertiary alcohols. And I think a lot of people were confused. Let me see if I can find a pen here so that I can rewrite this stuff. Some people, I'm not sure. There was some confusion over the way that I drew the molecules. Once I stopped drawing all the hydrogen atoms, it becomes non-obvious as to what's going on. I'm going to take this mechanism that I showed you last Friday before we left and I'm going to redraw it, just in a slightly more clean way. And what I showed you was this reaction where, and this time I'm going to draw the C's and the H's for you. So if you expose an alcohol like this tertiary alcohol, so again, I'm just redrawing what I did on Friday. Hopefully, you've already got this in your notes. And you expose that to a catalytic amount of a strong acid. And usually, even though it's catalytic, you use higher concentrations. You can protonate that alcohol and turn it into a good leaving group. I'm not sure that that's the best way to turn an alcohol into a good leaving group, but it's certainly a very cheap and inexpensive way in the laboratory. And so now you can see that that alcohol has a positive charge OH2 plus, it's an oxonium ion. Oxonium means oxygen with three bonds. That's now a good leaving group. And that will leave. And so once this group pops out here like this, it will leave a carbocation. And when I showed you this mechanism on Friday, I did something kind of, I did something kind of tricky by not drawing all of the hydrogen atoms. I was just using line structure. So this structure that I drew at the bottom, where I very kindly just drew out the CH for you, in line drawing structure looks like this. I'll just draw is equivalent to. So if I don't draw the H's or the C's for you, you might not see that there's an H. In fact, there's H's dangling all over this thing. And those H's can be deprotonated. So if I have the counter ion from my acid still floating around, and it's got its lone pairs, if it's not very nucleophilic like a sulfate anion, then instead of attacking the carbon, what you can have is that this thing pulls off a proton and gives you an E1 elimination reaction. So in lecture, I sort of bent the bonds a little bit and I wasn't drawing the C's and H's for you. But I had many people come to me and ask, hey, what was going on with that? I couldn't tell what was going on. So here I'm redrawing it with all the C's and the H's so you can see that when you treat alcohols, especially tertiary alcohols with acids, you get an E1 elimination mechanism because tertiary alcohols are so good at forming carbocation. Okay. So that was section 9.8. I'm just redrawing what I drew for you on Friday to clarify that in case I made that complex. Okay. So that's tertiary alcohols. Tertiary alcohols form tertiary carbocation and that's so easy to form tertiary carbocation. Well, I love that. There's something that's not quite so good but possible. It's possible to do that with secondary alcohols. And so let's try to redraw this scenario where instead of having a tertiary alcohol, I've got a secondary alcohol. Let me just draw the other thing that's attached to this carbon, the carbon-ol carbon. I'll show that there's an H there. So if I can get that hydroxyl group to leave, it's just going to be a secondary carbocation. And that's not going to be very easy and it's not going to be very good. But you can do it. So if I treat this alcohol, this secondary alcohol with the same reagent that I used before for the tertiary alcohol, you can't just let this sit at room temperature. You have to heat this. These are the conditions I found in the literature, 150 degrees Celsius. You don't have to remember that. I just want you to see that secondary alcohols, you have to beat on those to make carbocation. That's nothing like, so you don't have to remember the temperature for that but the book pretends that secondary tertiary are the same because they don't show you the conditions. And I just want to make it clear that anything that requires you to form a carbocation like this, I'm not going to draw the whole mechanism for you, that that carbocation is just awful, secondary carbocation. So ultimately the elimination product that you get out of this will now have a C-C double bond in there. Now I want to emphasize for you the importance of you seeing the hydrogen atoms that we don't draw. Why is it so important for you to see the hydrogen atoms that we don't draw? So this is the same molecule as if I eliminated the double bond up above. That's the same thing as this. I've just reoriented the molecule. These are equivalent to each other. So there's H's here that we could have eliminated. And this is what you don't see if you're not yet practiced enough. What we've done is not just create a C-C double bond. The important part about this mechanism is that we've also removed a proton. And if you can't see that, it's going to burn you later when we get into chapter 51C. And so I feel like I'm really harping on this idea that you need to practice taking line drawing structures and adding all the H's in because a large fraction of the time those H's are important for the mechanism. So if we pull the H's off the top, you get this structure over here. If you pull the H's off of the bottom, you get the structure over here on the left. And those are the same compound. You just rotate the molecule and those are identical. No human on the planet or any... There is no ability to distinguish these two structures. They're the same. Okay, so you can do E1 eliminations of secondary alcohols. You use sulfuric acid. You don't use hydrochloric acid or hydrobromic acid because those have chloride, bromide, and halide ions floating around. Those are good nucleophiles. You use sulfuric acid because the sulfate anion is not a good nucleophile. So that's the recipe you need to know for dehydration reactions, for this E1 reaction. And again, secondary alcohols take some heating to make those work. They're not good reactions. I don't ever want you to think that secondary carbocation are good. That would really depress me if you walked away thinking that. Okay, anytime we talk about carbocation, there's a real lack of control. And the lack of control comes from the fact that you can get alkyl shifts. And so let me just remind you of this. This is something that you learned about in fact in chapters 7 and 8. And this is just a reminder that those things can occur. So let me draw a substrate. This is about the simplest substrate that can undergo a superfacile alkyl shift. So this is a secondary alcohol that's going to create a very unstable and unhappy carbocation if I can somehow make that hydroxyl group leave. So if I take this secondary alcohol and I expose it to sulfuric acid, there's sulfuric acid. And you would have to heat this, otherwise it wouldn't work very well. I'm just showing you the temperature so you can go, wow, 150 degrees. That's way hotter than boiling water. Just to reinforce the idea that secondary carbocation are not very good. So the products that you get out of this reaction look like this. The carbon, here's one product. And the carbon skeleton is rearranged there. That's not the same carbon skeleton. And here's the other product. Also has a different carbon skeleton. So the products of this reaction both result from some sort of a rearrangement has occurred there. Maybe it looks kind of, oh, that's easy until you sit down and try to figure out what happened. Okay, so let's go ahead and walk through the mechanism for this reaction just to understand what's going on with these rearrangements. Just walk through the mechanism of an ionization reaction that creates an unstable carbocation. And now I'm not going to show the protonation of the alcohol just because I want to conserve time and space here. I hope that you can draw some mechanism where you use the lone pairs on hydroxyl to grab a proton off the acid. That's up to you to draw that in. So there's lone pairs on the alcohol. Two of them, one of those lone pairs grabs a proton off the sulfuric acid. And if I, well actually why don't I just draw it? It's so easy and it just makes me feel good to draw that. Watch this. Oh, yeah. And notice how I'm depicting that as HA. I'm not going to draw out the entire structure of sulfate anion. For arrow pushing mechanisms, I encourage you to use that symbol HA instead of drawing acid catalysts. So this oxygen here has three bonds, so it has to have a positive charge. We call that an oxonium ion if oxygen has three bonds. There will be a positive charge on there. And I hope when you see that positive charge on oxygen, you're thinking, well that's not very happy. That probably wants to act as a leaving group. So let's make it act as a leaving group. That oxygen's going to walk away so it gets the electrons all to itself. And so that generates water as a leaving group. Now this is not an easy reaction. This step right here is exactly why you have to heat it because it's not easy to form secondary carbocations. And I'll draw that secondary carbocation. It looks like this. Now whenever I draw carbocations, you're going to notice this. I take the time to draw all the things that are attached to the carbocation center. There's an H there and it's plain as day. It's plain as the nose on my face. I'm going to draw it there just so I don't forget it just in case I need it sometime in the mechanism. And you don't have to do this. I'm sure the book doesn't always draw everything attached to the carbocation centers. But there's that carbocation center. I'm drawing a dot on it right now. And I always, if there's hydrogens there, I draw the hydrogens that are attached to carbocations. It just reminds me of whether the carbocation is primary, secondary, or tertiary. Okay. Secondary carbocations are so unstable. Let me just write this down here. Secondary carbocation. It is very fast. If you can do some hydride or alkyl shift to convert a secondary carbocation into a tertiary one, it will be very, very fast. So let's draw out that migration reaction. There is a very fast migration in which one of these three methyl groups, and it doesn't matter which one you pick. It's very, very identical. Can migrate over, can just move over, and attach itself to that carbocation center. And when it does that, it will create a much more stable, and let me draw that H so we can see that it's still there. It didn't move anywhere. And I don't have to draw that H, but I want to make sure we don't miss it. So now it's this other carbon that's lacking an octet of electrons. And now there's a tertiary carbocation, and that is definitely a fast carbocation rearrangement. If you were trying to rearrange a secondary carbocation to another secondary carbocation, that wouldn't be fast at all. In fact, I would never draw that. It's when secondary carbocations can rearrange to tertiary. Those are the fast rearrangements. So now, so in theory, you could migrate the methyl group back. I'll just draw this tiny little arrow here. Well, that's too big, but whatever. To indicate that in theory it's reversible, but you don't want to go from tertiary to secondary. That's just not thermodynamically favorable. It's not fast. So maybe if you could somehow draw that the size of an atom, the reversible arrow, then it would be more appropriate. Okay, so the importance is whenever you have secondary carbocations and they can rearrange to tertiary, it will be fast. Okay, once you've done this, once you've made this tertiary carbocation, look how valuable it is that I took the time to draw that H out. If I didn't draw it out, this might be impossible for you to see. But I expect you to see every H on every one of these line drawing molecules because you never know when you're going to need those Hs. Watch this. Good thing I drew that H there. Now I can see how I could easily pull that proton off in order to give me the more substituted olefin. Generally, more substituted olefins are favored in E1 elimination reactions. Okay, so there's another alternative here. I'm going to redraw this same intermediate just so we can draw a second type of mechanism and I won't have a thousand arrows on this one mechanism here. So there's another way we could eliminate. And the other way we could eliminate requires us to see that there are also Hs here. And if you're not good at seeing those Hs, you won't see that there's another way to eliminate. And so if I come in with my counter ion from the sulfuric acid, which I've abbreviated A-, now I can eliminate like this. And that's what leads to this other product of the reaction. So there's two different products of elimination here. The major one is going to be the one that's more substituted. But you can see the impact of carbocation rearrangements. Where you see carbocation and especially secondary carbocation. You need to really watch out for this. Well, what about primary carbocation? Forget, I'm not going to do anything with you this quarter that leads to a primary carbocation. That doesn't make any sense as far as stability. If you have to heat to 150 degrees to get a secondary carbocation to form, imagine how ridiculously and almost impossible it is to generate a primary carbocation. And I've seen the book show nonsense like that and it just doesn't make any sense. I'm not sure why I titled the slide this. One, two, shifts make challenging test questions. In a way I'm trying to galvanize you to pay attention because I'm not saying I'm going to put this on the exam but it's the kind of stuff that you'll see on every exam because it's hard. It's one of these things where if you don't draw all the hydrogens and see where they all are located. Yeah. Is that the two prime or is that the two prime? The minor product. This, wait, is say again? Is that two prime? Two prime. These are the prime. So this, are you talking about the little symbol up above here? So that means secondary. I mean the lingo is secondary, not two prime. So this is a secondary carbocation. This is a tertiary carbocation. And these two right here are the same. These are just the same molecule. I just re-drew it again because I didn't want to put extra arrows on this structure because I thought if I put all the arrows on this one molecule it would get too confusing. So I just re-drew. And I just re-drew the molecule here. It's the same thing. Yeah. Can you be a management to have a re-array of the end product? If you ask for the products, will you write everything on the products or do you want to simply put the only and all staples on the products? Generally I want to see the major products. In this case you'd have a mixture that's close enough to where you'd see both. One would be slightly major. So usually, so I hate that kind of ambiguity. And I know that in the book they'll ask you questions like how was I supposed to know? I should draw the minor product. I'll usually make the question clear. Draw all the products you expect in the following reaction. Or I might say draw the major, if I know that there might be a mixture of two products I'll say draw the major product of the following transformation. There's a general rule that I want you to follow when you answer questions on problem sets or on my exams. If I draw some sort of a reaction out like this and I draw a box, what do I want you to draw on the box? I want you to draw where all the carbon atoms end up in the product. So in other words, the product of this reaction might be some sort of an SN1 process. There's also HCl. But I just want to see where the carbon atoms end up. Unless I specifically ask you about the inorganic things that don't contain carbon, you don't have to draw that in the box. I just want you to show me where these carbon atoms end up. Not this second proton or the inorganic ions and stuff like that. So I'm trying to get you to show me where these atoms end up, the carbon atoms, because this is an organic chemistry class. And so if I think there's going to be multiple products, I'll usually try to clarify that. If I have reason to believe that you'll get an equal mixture of two, then I'd expect you to draw it. And I usually in class will tell you, oh, you always get two things out of this. So let's carbocation rearrangements. Let me keep drawing out these carbocation rearrangements. Here's an example of once again where I can see that this thing has no choice but to form a secondary carbocation. So here I'm using my acid for elimination. And if I want to do an elimination reaction, don't use HBR or HI or HCl because halide anions are nucleophiles. I don't want any nucleophilic attack going on here. So the product of this reaction forms a C-C double bond, but it's not even in the same place as where the leaving group was. What's essential here? What is it that would make this easy for you to see what's going on? Well, what will make this easy for you to see what's going on is if you know, oh, there's a hydrogen atom here, and suddenly there's two hydrogen atoms there. If you can't see those hydrogen atoms, if you're not instantaneous at seeing the locations of the hydrogen atoms, you're going to miss that, well, I've got to somehow get a proton on there. The other thing that's important is there used to be a hydrogen atom here, and it's no longer there. You have an instant clue. If you're good at seeing hydrogen atoms, you have an instant clue what happened? Well, the hydrogen atom that used to be here, maybe it migrated, you know, something like that. So that's why it's important to see the locations and how many hydrogen atoms there are, because we're not going to draw them for you anymore with these line structures. We don't do that for you anymore. Okay, so let me go ahead and draw the carbocation. Again, I'm not going to take the time to draw this whole mechanism for you, but let me draw this carbocation intermediate that you would get. Here's the carbocation. And I'm going to draw in this, I'll draw in the hydrogen atom. I'll draw it in in green just to remind you that that's not drawn for you. There's that hydrogen atom over there at that tertiary center, and there's that really angry and frustrated secondary carbocation that's hating life and wishing it wasn't secondary. And so now this hydride can just migrate over, this hydridogroup can migrate over and satisfy the secondary carbocation, but leave behind a tertiary carbocation. And I'm going to draw one of the hydrogen atoms that was already here. There was already a hydrogen atom there. And here's the one that migrated over. I'll draw it in green. And here's my tertiary carbocation. And again, if you're not good at seeing the locations of the hydrogen atoms, you're going to be stuck. So let me, I'll draw it for you. Here's the other hydrogen atom. You need to know that that's there because the last step of this mechanism involves plucking that proton off. And so I'll come along with my symbolic A minus here. And I'll simply pull that proton off to make a double bond. So what's the importance of this problem? It's once again to remind you that when you make unstable secondary carbocations, to look for rearrangements, and it's to show you the importance of seeing hydrogen atoms that aren't drawn for you. The assumption, again, I'm very soon I'm going to stop harping on this and just expect you to be fast and good at this at seeing the locations of hydrogen atoms. And nothing short of working lots and lots of problems will help you to have the experience that you need to be fast with seeing those types of deprotonations and hydride migrations. Okay, so how do you eliminate alcohols without getting secondary carbocations and rearrangements? There's a secret reagent that I'm going to show you that allows you to eliminate alcohols without getting these kinds of complex rearrangements. It's called phosphorus oxychloride POCl3 and you always use it in conjunction with pyridine as a base. I'm going to draw the chemical structure over here in the corner for phosphorus oxychloride. There it is. There's five bonds to phosphorus. Don't freak out about the five bonds. Phosphorus is not a second row atom. Second row atoms can only have four bonds. So once you drop to the third row, fourth row, fifth row, you can have five bonds. As many things as you can fit in some cases. DNA is a phosphorus five oxidation state. There's five bonds to phosphorus and DNA. So I don't actually call the, if I make a mistake and use normal organic lingo, forgive me, but I call that most organic chemists call that POCl3 just because it's clumsy to say phosphorus oxychloride. Okay, so let's see how to use this. I'm going to draw one structure in the middle and then show arrows going left and right. So let me start in the middle of my page here and I'll draw a secondary alcohol that is just primed for some kind of rearrangement. Let me put two methyl groups here. There we go. So if I formed a secondary carbocation, liquidy split, I'm going to have one of those methyl groups migrate over. And how can we avoid that? So in other words, if we go back to our standard E1 elimination formula, dehydration we call it, we're going to use a catalytic acid. In this case, you'd have to heat this. I'll just write heat here just to remind myself that gee, that would take some heat. When you form the carbocation, I just showed you two cases where things can migrate over. So one of these two methyl groups would migrate over and I'm not going to draw that mechanism for you now. I'm going to draw one of the methyl groups where it was before. The other methyl group I'll have drawn have migrated over and you'll end up with the more stable double bond. So this mechanism involves a one-two shift and I'm not going to draw that out for you. But suppose you wanted to eliminate over here to the right-hand side, what could you do about that? This is where you can use this reagent combination. POCl3, again I call that Paco3, phosphorus oxychloride, and you include pyridine as a base. If you can't remember what pyridine is, you don't really need to draw out the structure of pyridine. You'll see this used as a weak base later in the race. That's pyridine over here in the corner. There's a lone pair on that nitrogen and it's good for plucking off protons. So in this particular case, POCl3 will efficiently eliminate without generating any kind of carbocation. And mechanistically what's going on is that this reaction over here on this side involves E1 reactions, carbocation. This reaction over here with phosphorus oxychloride avoids carbocation formation. The elimination is an E2 reaction. So let's talk about what's going on with phosphorus oxychloride. So the mechanism for this reaction, I'm not going to draw the full mechanism for you. You don't need to know this full mechanism for how you do this. But hydroxyl groups are nucleophiles in this phosphorus atom and phosphorus oxychloride is an electrophile. So the hydroxyl group will attack the phosphorus and substitute out one of the chlorides. So let me draw out this new group we have here which turns out to be a very good leaving group. Boy, that phosphorus is now, has all these electronegative atoms attached to it. Look at that phosphorus. It's got electronegative chlorides, electronegative chloride, electronegative oxygen. It's really going to stabilize an O minus if that oxygen can just walk away. So this is a very special leaving group. And I'll just write that here. This whole P phosphorus with the two oxygens is a good leaving group. It is not such a good leaving group that it can just walk away and leave a secondary carbocation. It was very carefully chosen, well not chosen, but it was screened to show that as long as you don't heat this thing up, this thing will never walk away. This thing, this P O, this phosphate, this chlorophosphate ester will never just walk away to leave a carbocation. It's carbocations that lead to rearrangements like this. So you don't have to worry about that happening. That's just slow. So don't worry about that. That's why we use phosphorus oxy chloride and pyridine. So under these conditions, yeah. Why is it necessary to remove the hydrogenous pyridine? Because pyridine is a strong enough base. There used to be an H here on this oxygen. Pyridine is a strong enough, but once you form that oxonium ion with O plus, the pyridine will remove that proton that's there. Why is it necessary to remove it? But it's not an issue. That would be so easy to deprotonate. It would not last a zillionth of a second before pyridine pulls it off. Why do you have to add the pyridine? Well the pyridine is there for this step, the E2 elimination step. So this is an E2 elimination, and it's an E2 elimination. Here's where the pyridine really, so the pyridine has already removed one proton here. Here's where the pyridine really comes into play. It induces the E2 elimination. So that's why the pyridine is there, mainly. And so that leads directly to the, this is one step here. That leads directly to the E2 elimination product. So again, there's no carbocation rearrangements because there's no carbocations. This POCl3, 2, whatever, yes? What happens to the other CL? They used to be there. I'm not going to walk through that mechanism. You lose, here's what you lose. You lose this, and you lose this, and there's a byproduct here that's HCl. It's essentially, I'm not going to draw the whole mechanism for that because the book gives you an incorrect mechanism for showing that. So you don't have to know the mechanism by which the OH goes to make that chlorophosphate ester. You just need to know that the OH can go to a chlorophosphate ester. You don't have to know the mechanism. The important point is this is an E2 elimination mechanism. And that's why you won't get carbocation rearrangements. And that's what I want you to remember. I want you to remember that you can use this combination to eliminate alcohols without getting carbocation rearrangements. You're free to look in the book. They show a mechanism for that. I will never ask you that. They show an SN2 reaction, and that's not. That's going to, if you learn that, it will fool you later. Okay, so use POCl3 in pyridine if you want to eliminate alcohols and not have carbocation rearrangements. Use sulfuric acid if you want something desperately cheap. You don't care about the cost. Well, mainly it's if I ask you. I would use it if I wanted something super cheap. That's when I would use sulfuric acid. Okay, let's go back to halides. Chapters 7 and 8 were all about halides. Alkyl halides is substrates for carbocation formation. Alkyl halides for SN1 and SN2 reactions. And you can make alkyl halides from alcohols, for example, using SN1 reactions. If you take tertiary alcohols and I expose this to sulfuric acid, I'll get elimination. You don't get to choose any kind of acid on the planet. If I use another strong acid, hydrochloric acid, I won't get elimination. I'll get substitution. And here's the difference between HCl and sulfuric acid. Chloride anions are good nucleophiles. Sulfate anions are not. So the product of this, because chloride anion is a good nucleophile, is not elimination, it's substitution. So this is nothing more than a run-of-the-mill SN1 reaction. But it kind of shows you an example of if you protonate alcohols, you can convert them into good leaving groups. So let's draw out the mechanism here. There's lone pairs on alcohol. And just like with the sulfuric acid, you can deprotonate. Now if I use the symbol HA here, then I won't know that there's a chloride anion floating around. So I'm not going to symbolize my acid HA. Just because I want to remember that, oh, there's a chloride anion floating all around in my solution. So here's my oxonium ion. I've got oxygen with three bonds. Therefore it must have a positive charge. And I hope you're not happy when you see oxygen with positive charges. That's not a happy situation. There's a chloride anion floating around. I can't resist drawing this chloride anion floating around. There's the chloride anion. Just waiting to do something. Yeah, it could deprotonate one of the protons and go backwards, but that's totally not interesting. Let's allow that oxygen to act as a leaving group. It's really angry. It hates sharing its electrons. And now I generate a tertiary carbocation. And there's all kinds of beta-hydrogens floating around. But because there's chloride floating around, and chloride is nucleophilic, just like bromide and iodide. So you'd also get SN1 reactions with HBr and HI. So now the chloride anion attacks. And this didn't happen with sulfuric acid because the sulfate counterion is not a good nucleophile, but chloride anion is. And so this is how you get, I don't need to redraw the product. That's this final product already drew. Okay, so again, it's the same with HBr. Let me draw an example with HBr. As you can see that these reactions are different from sulfuric acid. So if I take a tertiary alcohol and I treat it with HBr, I'm going to substitute the alcohol. If I use sulfuric acid, I'll get an alkene. If I use hydrohalogen acid, I'll get substitution of the hydroxy group for a halide. H means a phenyl group, so you're going to find me doing this a lot more equals phenyl. We're going to have an entire chapter, chapters, chapter 18, actually on chapter 17, where we're going to talk about the chemistry of benzene rings. So don't worry about the structure of that phenyl group right now. I'm just trying to abbreviate to make things fit in there. And this tertiary alcohol would work in the same way. And this is just to show you look HBr, HCl, HI, same deal. Totally different from sulfuric acid, which doesn't have a nucleophilic counter ion. So in other words, when you want to do an elimination to make a double bond, don't use HCl and HBr and HI. I mentioned a little point on the bottom that you could do these reactions with secondary alcohols, but you're going to get all these shifts going on. And I don't want to show you an example that has more carbocation, one, two shifts, because I typically wouldn't go into the lab and run reactions that would give me those kinds of side reactions. Yeah? What's the best one that you use at HCl, HBr? Is HI more active than those other two? What would you rather use here, HCl or HBr? It depends on the product that I want. If I use the iodide, the tertiary alkyl iodide is so sensitive that it's hard to work within the lab. It pops off to get carbocation so easily that when you try to concentrate your sample down, the reaction starts decomposing because tertiary alkyl iodides are so sensitive to carbocation formation. If I wanted one that's stable enough for me to do high temperature reactions, I'd go with the chloride because sometimes you're going to have to heat that in some other reaction and you don't want the chlorides to just pop out and make carbocation. So it depends on what I want to use the product for, whether I use HCl or HBr. Another clue when you're doing exams is if I asked you to make the chloride use HCl or if I asked you to make the iodide, then use HI. That's your clue. So let's talk about a super secret reagent here. Not that super secret. I wouldn't say this is your money reaction, but the book seems to love this reaction. It's actually very old, but maybe that's why they love it because you can find it in textbooks dating back to the—what happens if you have a primary alkohalide? We're not going to have any carbocation business with a—sorry, with a primary alcohol. You're not going to get any carbocation with this. You know, maybe you're not going to be able to just treat this with HCl and get that to work. So there's a reagent we can use if we want to convert this into—and I'll draw a way over here, leave a little bit of space. Whatever I want to convert this into an alkyl chloride. So I've got three-carbon propanol and I want to convert this into three-carbon propyl chloride. So it's all allopropane. And so here's the reagent that you use. You use zinc chloride. It's a pretty simple-looking reagent. And the reagent, zinc chloride, loves oxygen. It's a Lewis acid. We're going to see a lot more reactions of Lewis acids coming up, but Lewis acids, in the same way that the lone pairs on oxygen can attack protons, the lone pairs on oxygen will also attack zinc. So zinc is the most common transition metal in the human body. If you want to call it a transition metal, it's a main group metal. It's the most common metal used by human enzymes. And the whole point of that in your body is this, is that zinc forms bonds to heteroatoms. So there's a vast number of zinc proteases that where the mechanism starts with some oxygen atom coordinating to zinc. Okay, so when you do that, let me draw out this intermediate, which is going to look very busy to you. Maybe this is going to bother you because it's got all this stuff on here. And I hope you won't be too bothered by this. So here's this zinc. Two things that have to happen. If I make a third bond to oxygen, I have to put a plus charge there. It's called an oxonium ion. When you have three bonds to oxygen, you better put a plus on it. You don't have a choice. Now if I've got a plus in this molecule, there must be a minus somewhere because I started with two neutral reagents. Whatever I make has to be neutral. And so the question is, where do I put the negative charge? Well the zinc just picked up an extra pair of electrons and now has two minutes. So there's nothing intuitive about yet to you because you're not familiar with looking at zinc. If you looked at 5,000 zinc species with two bonds, it will look odd to you that there's a third bond to zinc and you'll want to put a minus charge there. But for now you just have to remember that that zinc has a minus charge. If I wanted to be really precise here, I would call that a zincate to tell you that there's a minus charge on zinc. Okay so now, here's what's totally weird. So you'll have to have some faith here for a second. Here are chloride anions floating around in this solution. So first just believe me and then I'll show you how I know that. So if you want to draw the correct mechanism, you have to draw a chloride anion that's like, well where's the chloride? I'll show you in a minute. Just be patient and I'll show you where that chloride anion is coming from. So the chloride anions that are flowing around in this solution can come back in and push out this leaving group. And you could never have guessed what would happen with zinc chloride. We have to show you what happens with zinc chloride. You couldn't have known all this stuff. And so you get an SN2 substitution. You totally avoid carbocation formation. The zinc loves oxygen so much it grips that oxygen and allows it to turn into a great leaving group. Okay so the byproduct in this reaction is this species right here. Here's the byproduct. The zinc species that left here is the zincate species that's the byproduct and that's not stable. As soon as you pop that off, this will start to dissociate. And that's where you get the chloride anions from. And it's going to seem to you like this chicken and egg problem. But where do I get the first chloride from to get the whole reaction started? Every bottle of zinc chloride has chloride anion contaminants in there. This is the mechanism for the reaction. This is the origin of most of the chlorides. You've got in a typical reaction you don't have just one molecule. You've got 6.02 times 10 to the 23rd molecules and there's plenty of chloride contaminant floating around. So as the reaction goes it generates chloride anion and that chloride anion serves as the nucleophile to come back in and attack more of these Lewis acid species. Okay so this is a good example of how Lewis acids can bind to oxygen and make them better leaving groups. That's a great example of that. That's not the best way to make a primary alkyl chloride. Let me show you the best way to make a primary alkyl chloride. Let me show you a money reaction that you will use over and over and over and over and over and over again. And I can't imagine that you will escape this class without me asking you about this reagent. Oh I've got a green pen here. That's money. And it's not just for this conversion. We're going to use this again when we get to chapter 18 for a similar reaction and you will use it over and over and over again. The toughest thing about this whole transformation of alcohols to alkyl chlorides is just remembering the name of the reagent, SOCl2. We call that thionyl chloride and I'm going to draw an alcohol that has a very specific stereochemistry just so we can see that it's an SN2 reaction because we'll see inversion of stereochemistry. Here's a secondary alcohol and we take this SOCl2 that's called thionyl chloride. This is the best way to make an alkyl chloride. Primary secondary, you could use HCl for tertiary but we don't make tertiary alkyl chlorides that often. Super common reaction here. And so here's the reagent combination that we use. Thionyl chloride and pyridine. And I'm not going to draw the structure of pyridine. We just covered that with that Pockel 3 reaction. We don't call this, nobody calls this SOCl2 for some reason. Everybody just calls it thionyl chloride so I'm not sure why. In other words, if you say SOCl2, I'm going to think, oh, what, you're over stretching with the lingo. So here's the product. You get a chloride and the configuration is inverted. It's now dashed. That means there was some sort of an SN2 process that occurred in this reaction. So we'll go ahead and draw part of the mechanism. In fact, I'll just draw the mechanism. I'm going to be very careful here. The reason is they record this on video and people around the world are watching this. So I'm going to be very clear to say this is the mechanism the book shows. I teach a graduate class on organic reaction mechanisms. This is not the mechanism I would show in that class. But this is the mechanism I want you to know because it's the mechanism in the book. And this will give me a chance to show you the structure of thionyl chloride. So let me start off by drawing the alcohol. And the stuff on the bottom of the alcohol doesn't matter that much. Just the lone pairs on oxygen. And here's the structure of thionyl chloride. It's pyramidal. There's a lone pair here on this thionyl chloride. The lone pair is not involved in any part of this mechanism. But I just like to show it there so I can see. Thionyl chloride is pyramidal. Looks a little bit like Paco3. But the important point is that it's very easy to attack that sulfur. And here's I want you to draw the way the book draws it. Because it will make our lives easier. The book draws this as an SN2 reaction. That pains me. The important point here is that we're going to go from an OH which is a lousy leaving group and we're going to convert that into a great leaving group. And I have three bonds to oxygen now. It's not happy. You can, I'll draw it down here just so we can see. The chloride anion leaving group is floating around somewhere. So now the pyridine base can come in. And I didn't leave a whole lot of room for the pyridine in here. So let me, I'll just try to squeeze that pyridine in. I'm using these big fat pens. I'll try to squeeze that pyridine in here so I can use it to pluck the proton off of that oxonium ion. So here's the pyridine and it can come along and pull that proton off. That makes that oxygen a lot happier. But that whole group, this whole OSOCl thing is a great leaving group. So now I'm going to draw the full structure of that intermediate so I can see all this business attached to there. And now here's this leaving group here. This is called a chlorosulfite ester. I will never ask you the name for that kind of a functional group. Just in case you're wondering, that's a chlorosulfite ester. And that's a great leaving group. Let me just put a little label on there. Great leaving group. Who would have thought that? That's a great leaving group. You got the chloride that's electron drawing on the sulfur. There's another oxygen on sulfur that's electron drawing. All of it is going to stabilize the buildup of negative charge on this oxygen leaving group. So you could never have known that this would be a great leaving group for SN2 reactions. They had to experiment quite a bit, I'm sure, to stumble on this right combination. And so now the chloride anion can come in and do an SN2 attack. If you stick with these conditions, you get very little E2 elimination. Who would have thought that? You couldn't have guessed that. That's why you have to memorize this secret recipe of thionyl chloride and pyridine. And so when you attack and do an SN2 reaction, let me just write SN2 above this arrow to remind you, you get backside attack and inversion of configuration. When the chloride comes in and displaces that leaving group, there's no carbocation. So we'll end up with clean inversion of configuration here because it's an SN2 process. So this is the reaction that you should use to make alkyl chlorides. And you're going to use it throughout this book. There's a zillion problems in the back of this chapter. You're going to see a very similar reaction with thionyl chloride where you don't need pyridine, you can convert carboxylic acid OHs. Okay so that's all we're covering for today. When we come back, we're going to talk about how to make bromides to a good reaction. And then we'll keep going.
This is the second quarter of the organic chemistry series. Topics covered include: Fundamental concepts relating to carbon compounds with emphasis on structural theory and the nature of chemical bonding, stereochemistry, reaction mechanisms, and spectroscopic, physical, and chemical properties of the principal classes of carbon compounds. This video is part of a 26-lecture undergraduate-level course titled "Organic Chemistry" taught at UC Irvine by Professor David Van Vranken. Index of Topics: 00:17- OLED TV 01:38- OLED explained 03:34- 9.8: E1 Dehydration of tertiary Alcohols via Carbocations 07:00- 9.8: E1 Dehydration of secondary Alcohols via Carbocations 10:28- 9.9: Carbocations rearrange through 1,2 shifts 18:38- 9.9: 1,2 shifts make challenging test questions 26:09- 9.10: Dehydration with POCl3/pyridine 33:35- 9.11: SN1 conversion of tertiary R-OH to tertiary R-X 40:00- 9.11: SN2 conversion of primary R-OH to primary R-Cl with ZnCl2 45:29- 9.12A: Sn2 conversion of R-OH to R-Cl with SOCl2
10.5446/19467 (DOI)
Inactive neurons are targeted by your immune system for complete destruction. This is just another variation on the theme of use it or lose it. Whichever neurons are just sitting around not pulling any weight, they eventually get tagged with a protein. And that protein tells the microglial cells to get rid of that stinker. It's not doing anything. And then you lose that one and all its connections. And that could be a physical mechanism for why even somebody who's extremely good at a musical instrument and doesn't do it for years comes back and they feel very rusty. They can't play with the same rapidity and style and verve that they had. Because when they stop practicing and those neurons become idle, your body says, well, look at all this metabolic load we've got here. 15 watts steaming out of this skull. And this guy here is taking energy and food and oxygen and nutrients and blah, blah, blah and not doing anything. We can prove he hasn't fired in years. He's gone. And perhaps when that mechanism goes astray or goes out of whack when you get older, your immune system starts getting rid of even parts of your brain that you would prefer to keep. And then you suffer cognitive loss. And the second is a dual thing, the observation that Europeans are putting on weight, well, as Gomer Pyle would have said, surprise, surprise, as they've become more like us, driving around everywhere. And the interesting connection here is that you are like a Prius. If you sit down for 20 minutes, it's over. You're on battery power. Your biochemistry detects in 20 minutes that you're bone idle and it shuts down. And why should it keep metabolizing fat and be ready to run and do things when you aren't doing anything? This is a self-defense mechanism so that you don't run out of energy. However, if you sit down for extended periods and then you eat, you pile it on. Your biochemistry can't believe how fortunate things are. Guess what? I'm like the king of France. I'm sitting down, I'm doing nothing, and I'm getting food handed to me. That never occurred, naturally. You had to climb a tree to get some sour apple. You had to chase something down. You had to at least run after the bugs you were eating because we ate plenty of them. They were much safer to eat than big animals because a big animal might injure you with its great big antlers. And if you got injured, you would often die of infection. If you know that, then you can explain why people who are every day on the treadmill, which I wouldn't recommend at all, are still heavy. They're the arts. You know what happens? On the way out, 300 calories of something or other, there's three miles down the tube right there. Did you do three miles on the treadmill? Maybe not. Then sit down in your car and then let nature do its work. To defeat that, interestingly, you don't have to be an avid exerciser, but just don't sit down for longer than 20 minutes. Always get up. Do a few deep knee bangs. You'll fool your system. It'll say, who? It'll keep the fat oxidizing enzymes going, and you'll be able to maintain your weight much more effortlessly than by making a big push, being tired, and then the rest of the day, you sit around. When you aren't keeping track, if you hadn't gone to the gym, you would have walked around a lot more. You actually defeat yourself because you pay attention to this big thing like the payoff in Vegas. I'm on the treadmill. I'm doing it. Then the rest of the day, when you do nothing, you don't even pay any attention. You say, well, I'm tired. I want to sit down, and I'm hungry, so I want to eat. Then you go backwards. Let's go on now and talk about equilibrium. First of all, equilibrium is dynamic. We talked about that last time. Carbon dioxide is the brown haze over Los Angeles. A lot of it comes from cars. It was much, much worse before the days of catalytic converters, which attempt to remove NL from the exhaust bloom. It has an odd number of electrons, which makes it very reactive, and it can dimerize to make N204, which is colorless. If we have a bulb then of NO2, we have a forward reaction, which I've just decided to put N204 as the reactant, and it falls apart into 2NO2, the revert, and then these sometimes recombine. At a certain temperature and pressure, there will be an equilibrium concentration of these two different molecules in this container. We know by now that if we press on the container, if we shrink it by putting pressure on it, that we will favor the reactant because the reactant is less moles of gas. If we heat it, if it gets hot in the afternoon, then we will favor this. We'll get much more of that coming up. Smog, of course, is much more than just NO2. It's a whole witch's brew of stuff that has to do with photochemistry, and that's why it's much worse in the afternoon. That's why the time to run is 5 a.m. because that's when the air is the best and all the idiots driving their cars are not up yet because they're still shaking off the night before. You're much safer when you cross the road as well because you won't have some car. I guess some people have actually been hit on the sidewalk by someone in a car because they're fiddling around doing something else and they jump the curb and then they smash into you. That's really unfortunate, but it does happen. Well let's suppose we looked in this bulb and we tag, we make an imaginary tag. We put a tag on one NO2 molecule and we follow that guy. Problem is this is very hard to do because molecules are so tiny we can't usually see them. We can imagine it. If we did that, we'd find that part of the time it spends its time as NO2 gas and part of the time it spends its time as N204 as the dimer hooked up with somebody else. The bonds are made and broken and remade all the time. In fact, if we follow the percentage of time that this guy is either NO2 or N204, we'd find that was directly related to what the equilibrium concentration was. There's a connection between time averages and averages of other properties. That study of so-called statistical mechanics is a highly interesting thing to engage in in a more advanced course. Let's have a look. Suppose then you don't believe this. You say you told us you should rely on evidence. What you've said is plausible, but what's the evidence that that actually happened? How could we either confirm it or rule it out? The answer is we could do so by employing isotopes. In this case, stable isotopes. We could use nitrogen 15, which is an isotope of nitrogen rather than nitrogen 14. It has pretty much the same bonding characteristics and everything else as nitrogen 14, but it has an extra neutron in the nucleus. The electrons are pretty much the same. We could use oxygen 18, which they use in some medical procedures. We could make some molecules that have N15. First we make a batch of molecules, N15 and oxygen 16, the abundant isotope. Then we make another bunch that are N14 and O18 in another container. Now we mix the containers. If after we mix them, we find by, for example, mass spectrometry, we find that there's an O18 and 14 hooked to an N15, O16, then we know that they rearrange, that they randomly assorted. If, on the other hand, when we prepare this guy and we only find this guy and we only find that guy in the mixture, that's all we find, then we know that they stayed put. Basically, they didn't rearrange at all. When we do this experiment with this particular molecule, we find that they rearrange all the time. In fact, sort of the presence of both the monomer and the dimer indicates that they have to break, otherwise we wouldn't have both. If you do the same experiment with carbon dioxide and you prepare some carbon dioxide with carbon 13, O16, and then carbon 12, O18, and you mix those together at normal temperature and pressure, there's no exchange. You never find any oxygen moving off one and onto the other. If you go to extremely high temperature, then you can make it happen, but that's extremely high temperature where those bonds can actually break. If you do the same thing with water in water, you find that the hydrogens hop around all the time. They fall off, they come on, they go every which way. They're exchanging quite rapidly in liquid water. Let's have a look at why this bond is so weak. Actually the Lewis structure is kind of a good way to start and look at a bond. Let's then write Lewis structures for NO2 and N204. Remember what we have to do. We have to count the valence electrons. We have to know how the atoms are bonded because it says NO2. That's going to be N in the middle and two oxygens sticking off like spokes. N20, which is nitrous oxide, has N then N then O. It's different. Let's draw them. There's five valence electrons for nitrogen. There's six for oxygen, but there's two oxygens, so I have 17. This is very rare because whenever you have an odd number of electrons, that means that you have one unpaired electron somewhere. Those guys are called free radicals. They usually cause mischief because they're quite reactive. If you ever breathe any NO2 and I have done it by mistake, you never forget it because your lungs tighten up and say that's enough of that and you feel like you need oxygen for the next couple of hours, depending how concentrated it was. Don't try to clean up any nitric acid because it won't work. It will produce NO2 instead and the penny will disappear. I tried to make an octet around each oxygen and I can do that, but in order to do it, I have to have a minus charge on this oxygen because remember we count one electron for the bond, then one, two, three, four, five, six. We count seven electrons, but oxygen's group six. This has a formal negative charge. Here we count one electron here, one, two, three, four, five, six. This has no formal charge, so we put nothing. The nitrogen group five, we count one, two, three, four. He's got a positive charge. Then we can play the usual game of flipping this guy in and flipping this guy out like playing dominoes and the negative charge moves back and forth. The actual structure of NO2 is 50% this and 50% that. It's one structure, but we can't write a proper Lewis structure for it like that. With Lewis structures, when we have more than one resonance structure, what we're saying is the real guy is a mule, but a mule is not a proper species because it's a mixture of a horse and a donkey. What we try to do to make it look like a mule is we flash a horse 50% of the time and a donkey 50% of the time. If we flash them very fast, we get kind of an average, and that way we can draw a proper Lewis structure for each one. This is not meant to mean that this is literally happening. This is just meant to mean there's a percentage of each in the real structure, which is an average, which we don't want to draw because then we have to draw dotted lines and funny things and we don't know where the electrons are. I think you can probably see that there's an electron here and an electron here. I think you can guess how N2O4 is made and I'll let you work out N2O4. Then I'll probably ask you about it on Tuesday to see if you did it. I think you can see why it's a weak bond because when I make it, I have to put those two formal positive charges together and those formal positive charges hate each other and they're closed. That bond is quite weak. That means we can break it apart fairly easily. It's an abnormally weak chemical bond that allows this thing to happen. We can take a kinetic view of equilibrium and I'm going to go through quite a lot of mathematics here just so you've seen it, not because I want you to reproduce it, but so that you've seen it so when you see it again, it'll be familiar. The chemical reactions can only happen when atoms or molecules are close enough to make a bond. That basically means the molecules have to collide. They first have to hit. We can figure out how often things hit in a gas. They have to collide and if we look at our kinetic theory of gases, we know how many are going how fast and we can figure out how many times they hit per second and in a gas it is a very, very, very large number of hits at normal pressures. We have the kinetic theory of gases and we can figure out how often the atoms or molecules are going to collide. If we heat things up, two things happen. They're going to collide more often because everybody's going faster, so it's as if time got shrunk and when they do collide more often, they're going to hit harder as well so there's more chance that they hit so hard that something gets knocked off and then you get a reaction initiated. That's why most reactions speed up in both directions, not just one, but in both directions when we heat things up. We'll see this in the summer if you're going to continue on in this series in Chem 1c with the Arrhenius equation. Let's have a look. Suppose that we are isomerizing cis-butene to trans-butene. We're taking something like this and we're isomerizing it like that, which means we have to formally break the double bond momentarily, slam into it, get this guy to twist and around. We know from before that usually the transform when you've got two things sticking out is slightly more favorable because when you're like this, these guys tend to repel each other a little bit and it puts a little bit of extra energy there that gets released when we go like that. That doesn't mean it's easy to do, but it can happen. If we have a forward rate constant, which we call little k for forward, of 5.59 times 10 to the minus 3 per second and the reverse reaction has a slower rate constant of 4.41 times 10 to the minus 3 per second and we begin with a mole of cis-butene in a one-liter flask, what will be the concentration of the two isomers at equilibrium? The forward reaction runs at a rate that depends on the product I meant of the rate constant and the concentration of cis-butene. It says however many I've got this many per second are going to tend to go this way, just like a conveyor belt. That makes trans-butene and then the trans-butene reacts backward but at a slower rate, more sluggish and that reverse reaction depletes trans-butene. And the one weapon that we have in this time view of equilibrium is that at equilibrium, whatever the amount of trans-butene is has to be fixed because that's what equilibrium means, the concentration's not changing. And that means that the rate of gain plus the rate of loss must equal to zero. So if the money in my bank account every month is the same, that means my income and what I'm spending match. That's the only way it can be the same. Let me say that again. The only way it can be the same is if the amount you get and the amount you spend match. If they're even slightly off, you eventually go into a black hole. If on the other hand you have a slight surplus, every month you end up in a white hole up here and that's the correct way to operate, of course, much less stressful. Now let's write the rate of gain. The rate of gain depends on the forward plus how much cis-butene is there at equilibrium. And the rate of loss depends on the reverse, but it's negative. I write plus, but I write the rate of loss being a negative number is minus whatever the rate of trans disappearing is times whatever the concentration is at equilibrium. And if it is at equilibrium, that should be zero. And if I solve this, I find that the ratio of the forward rate constant to the reverse rate constant is nothing other than the equilibrium concentration of trans-butene, the product, divided by the concentration of cis-butene. And that means I can get a number for it. So trans-over cis is forward, which is 5.59 times 10 to the minus 3 divided by 4.41 times 10 to the minus 3. 10 to the minus 3's go away and I get 1.27. Aha, but the concentration of the products at equilibrium divided by the reactants at equilibrium, that's none other than k. And so we have a number for k. K in this case is 1.27. Not a very favorable reaction, but more favorable to make trans than cis. This is a general conclusion. Equilibrium, so I had to abbreviate it, can be viewed as a detailed balance between all the ways that things are made and all the ways that things are destroyed. And at equilibrium, they're being made just as fast as they're being destroyed. It's not that nothing's happening, plenty's happening, but it's all a wash in the end. If you change one of the rate constants, for example, you have two kinds of cells that have to do with your bones, osteoblasts and osteoclasts. And one of them tends to make your bones bigger and stronger and the other one tends to make your bones disappear, get weaker and smaller. If you go up into space and float around in the space station, or you try to go to Mars, which wouldn't be a good idea, because there's no gravity, the osteoblasts say, guess what? There's no reason on earth to pile on bone. I'm not feeling anything here. The osteoclasts, however, are always running. And that's the rule, is that the machinery that's tearing you down is always running. So that the minute you stop building yourself up, you go to a lower state. That's again adaptive because you don't want to be trying to maintain gigantic bones and muscles that you don't need. Where are you going to find the stuff to eat to support all that if you're running around in the wild? So if you don't need it, you're going to just get rid of it, just like the brain. And that's why when they come back from the space station, they're basically on a gurney or in a wheelchair because they're so weak, their muscles didn't have anything to stand on. I don't weigh anything. I'm sitting down all the time. Plus, my blood doesn't even have to work to get back from my calves up to my heart. So my heart turns into this little pathetic thing. And I come back down to gravity. And I feel absolutely miserable. I'm weak, bones like balsa wood and so forth. And I expect that if you sent a human to Mars, they wouldn't even be able to get out of the spacecraft if they were the only person. Because when we take people out, we wheel them around and rehab them so that they can get back to normal function. My view is we might send a robot to Mars, which is made out of metal and doesn't have any active, degradatory mechanism. And that would be fine because that's not a living thing in the strict sense. So just like water, if we have a bunch of interconnected cisterns, we'll only be in equilibrium when the water level's at the same in all of them. So a system, no matter how complex it is, will only be at equilibrium when the rate of production and the rate of destruction of all the molecules in there is equal. Some of them may be destroyed and produced quickly. Others may be destroyed and produced slowly. It just depends. And in general, we can write this as a differential equation. And this is what I want you to see, but not necessarily digest today. So let's look at the rate of change. This is how the water level's changing. Is it going up or is it going down? What you read, the concentration of trans dt is just the rate of change. And because I don't want to write concentration of trans everywhere, I'll just write that as TR, and I'll write concentration of cis as C. Then we can get a differential equation. The rate of change of the trans depends on the rate of production, kf times C, and the rate of destruction minus kr, the reverse reaction times trans. And we can simplify this equation because in this case, I said we started with one mole, and so there's always one mole of material in there. It's either cis or trans. And that means we can substitute for C1 minus TR. So now we have a differential equation that involves the derivative of TR with respect to time and a bunch of stuff that has TR in it. This is called an ordinary differential equation. It's ordinary because this is a regular D and not the funny D. Yes? So this would only be if you were going from the cis to the trans estimate rate. Yeah, I'm talking about the rate of production of the product. And it's made by the reactant making the product, and it's subtracted by the product going backwards and making the reactant. You can solve these with Mathematica or Wolff from Alpha. It'll solve them for you. But until you learn how to solve them yourself, at least a little, the solution may not mean much. It just looks like a bunch of gobbledygook. So the problem is, often you can get the answer and you haven't learned anything. And that's something to remember when you say what's the answer. If somebody tells you the answer, you haven't learned anything. If you get the answer yourself, you have learned something. Let's put in the numbers that we have. We have those rate constants, so we have now a numerical equation. The rate of change of the concentration of trans with respect to time is equal to 5.59 times 10 to the minus 3, that's 3 times 1. And then these guys I put together, minus 1 times 10 to the minus 2. We solve this by separating variables. If you can separate variables, you can solve the differential equation instantly. And what separating variables means is get everything with the DTR and TR on one side, and then get everything with T and DT on the other side. This equation is easy because this side doesn't have anything that has T in it. If I had another term here plus T squared or something awful like that, then that would be much, much, much harder for us to solve. Because now I've got something else going on. It's as if not only am I trying to have it come to equilibrium, but I'm pushing one of the pots up, I'm lifting it up, and then I'm asking, okay, what's the water level? Then that's much more complicated to do. We can do that too. And when you're modeling weather or concentration of chemicals in the atmosphere, you have to solve lots of differential equations like this, and some of them can be very, very tricky to solve. Usually they're done numerically by giant computers that don't care what the equation is, they just integrate it the way a graphing calculator doesn't care what the function is, it just graphs it. Okay, so let's try separating variables. I look at this equation, and I want everything with TR on the left and everything with T or DT on the right. And I can pretty much see how to do that. I can just divide both sides by this guy on the right and multiply both sides by DT, and I get this great big equation here. DTR divided by 5.5 times 10 to the minus 3 minus 1 times 10 to the minus 2 TR equals DT. Good. Now I can solve that because this side only depends on TR, so I can integrate it. This side only depends on time, so I can integrate it. That's why I have to separate the variables. And so I put an integral on each side, and I say, okay, I'm going to integrate from the concentration of trans at some time I'm going to call zero, which is when I start the experiment maybe, or start the stopwatch. And I'm going to integrate up to some concentration of trans at time T. And then over here I'm going to integrate time from zero to T. Strictly speaking, this is sloppy notation because usually the variable you're integrating over and the limits, you don't like to use the same letter because sometimes it's confusing. If I were really doing this correctly, I should call this DX and integrate it from zero to T, but it doesn't matter because we can get the answer. The right hand side is just T minus zero because the integral of DT is T. And I evaluate it at the top limit and the bottom limit. And I subtract them so I get T minus zero is T. That's this side. And the right hand side, we can either hand over to integrals.com. If we're lazy or we can make a substitution, we can call U equals the denominator, 5.59 times 10 minus 3 minus 0.01 TR. And if I do that, which I'll do just for fun, we can set up the integral. And this is what you would probably do if you were doing it by hand. I have this new variable U. It's 5.59 times 10 minus 3 minus 0.01 TR. And I take its derivative so I know what DU is. And that the derivative of a constant is zero and the derivative of TR is just DTR. I end up with minus 1 times 10 to the minus 2 DTR. And then I solve this for DTR. DTR is minus 100 DU. And at T equals zero, TR is TR zero. And therefore, U at time zero is 5.59 times 10 to the minus 3 minus 1 times 10 to the minus 2 TR at time zero. And the upper limit is just the same thing, U at time T is this minus this times the concentration of transit time T. And then I put all those into the equation so I get something I can solve. When I put all these in, this minus 1 and this 10 to the minus 2 comes outside. And now I'm integrating DU over U and I know that's the natural log because now I have it in a form I can recognize it. The other side is T and that means the log, natural log of U at time T minus the natural log of U at time zero is equal to, I brought this thing over here, minus 1 times 10 to the minus 2 T. And I'll just remark as long as you make the variable X and you hand this thing like that to integrals.com, it'll give you the answer straight away. The variable has to be X for that particular website. And we know when we subtract logs, it's the same as dividing the arguments so we can clean this, tidy this up. We now have this. The natural log of U at time T divided by U at time zero is equal to minus 1 times 10 to the minus 2 times T. And then if I take the exponential function to get rid of the log, I end up with the following answer. Our new variable U at time T is equal to our variable U at time zero times E to the minus T over 100. The reason why the exponential function is so important is that lots of differential equations depend on how much stuff you've got. Compound interest, for example, is an exponential equation. You just plunk the money in and you leave it and you get 8% interest and you end up extremely rich in 30 years because it keeps going up and up and up. And as there's more money in the account, the interest is more. And then there's even more and then the interest is even more, et cetera, et cetera. On the other hand, if you borrow money, then you're going down like an exponential, especially if you keep borrowing more and more money. I'm amused that the credit card offers I get to get rid of my debt by transferring the debt to someone else. So you notice you didn't get rid of anything, but now you're paying the interest to them. That's what they're interested in. If you're a good risk, they want to get the 17% or whatever they're charging or even 29%, I guess, if you're unlucky and miss a payment and don't read the fine print. Okay, then now we don't like this. This is a nice equation, but it has u. It doesn't have the concentration of trans in it. So I have to go back and I have to substitute in the whole thing to obtain the final answer. I put in all this stuff for u at time t and I put in all the other stuff for u at time zero and now I have an equation where I have to solve now for transit time t, but basically I'm there and I can predict now from any starting place how much trans I'm going to have at any time. And here's the final result. The amount of transit time t is.559. Not surprisingly, that's the equilibrium concentration and you notice it doesn't have any time on it. That means as time goes on, it's going to settle down to this number. And then whatever the difference between where I start and the equilibrium amount and then multiply by e to the minus t over 100, when you multiply anything by e to a negative exponential, it gets smaller and smaller and smaller. So this part here dies out and I end up with the equilibrium concentration. We had an assumption here that we started at 1.0, but that was my first initial thing where I got rid of c. If now that we have more confidence, we could certainly go back and we could say, look, let the total amount of stuff be c naught or anything and we could do it again and then we'd have a completely general answer to this particular problem. Okay, just to emphasize, will you have to do this? No, not now and certainly not under the pressure of an exam. However, yes, eventually you will have to do things like this and much, much harder things because if you can't do things like this and much, much harder things, then you're down there with everybody else who also can't do that. If you can do something that other people can't do, you tend to get a job that they can't get. That's how that works. They have requirements. When you do this kind of computer programming, are you familiar with this process? Have you ever done this and so forth? If you have, you're a good candidate. Even if you do use modern software, you can get mixed up if you don't understand how the equations are behaving and what you're supposed to be trying to get. Most people view mathematics as something scary or difficult, but in fact, mathematics is the quickest, cleanest shortcut. That's why we make mathematical models of the universe because mathematics problems are much easier to solve than vague problems and words. Whenever somebody says something about the future in words and they don't have any mathematics behind it, then you have to ask how they're going to get it to happen. I will create 250,000 jobs. How? What's the equations? Show me the curve that goes up and levels off at 250,000. Why'd you pick that number? Why isn't it 253,000 or 225,000? What exactly are you going to do to create jobs out of thin air if there's no work to be done or no people who can do the work that's required? Gets much, much more complicated than to implement something like that. Let's plot our results. Once we've got an equation, we can see exactly how many molecules we're going to create. Let's suppose we start with no trans at all. It's all 100% cis. How long does it take to get to equilibrium? Well, we've got an exact solution, so we plot it. So I started with 100% 1.0 of cis and 0.0 of trans, and I just put those into the equations and I plotted it versus time here in seconds. I can see that after about 300 seconds or so, it settled down. That lets me know how long I have to wait in the lab before I make a measurement. If I want to know the equilibrium concentration as a function of temperature or pressure for this system if these rate constants are correct, then I have to change the temperature and then I have to go get a cup of coffee because I have to wait 300 seconds at least before I can know that it isn't moving around anymore, settle down. Chemical engineers really like to know exactly how long they have to wait. They're bunging in chemicals and they want something to come out. How long do I have to treat the wastewater? How long does it have to cycle around in there before it's clean enough or it's as clean as it's ever going to get? And then I get rid of it. It's very important to know these kinds of things. Sometimes the only way you can know is by careful measurement because you don't know these rate constants very well. If we start with no cis isomer, about how long is it? So now I've got the opposite. I start with 100% trans and some of it starts immediately going backwards because Q is bigger than K so it starts making cis and it takes about the same amount of time, about 300 seconds in, it's leveled off. And I would get the same conclusion no matter what I started with because these are the two extremes. If I'm lucky and I started with the equilibrium concentration, they both flat line all the way across. So here's the conclusion. The time it takes to establish equilibrium depends on the size of the individual rate constants more than the initial conditions. If the rate constants are fast, that means it's going to settle down very, very quickly. It means instantly I'll have equilibrium. If the rate constants are very slow, I'm going to have to wait forever to let equilibrium establish. On the other hand, the final concentrations don't depend on whether the rate constants are both big or both small. The final concentrations only depend on the ratio of the rate constants. How fast is this guy shoveling stuff in and how fast is the other guy shoveling stuff back? That ratio is going to tell how much I've got at equilibrium. And these same conclusions apply to processes like biological fermentation, which they're using to produce things like fuel and drugs. I'm growing yeast. I want to heat it up maybe to get the reaction to go better, growth, and other reactions that we'd like to be able to control. The equilibrium result of a bunch of fresh raspberries is the raspberries spoiled. They mold. They start smelling bad and so forth. And if you leave them out on the counter, that happens very quickly. If you put them in the refrigerator, the same thing happens. But you usually don't leave them there so long that you notice it happening. It just happens much, much more slowly. If you take food and put it in a freezer, it also spoils, but it spoils much, much more slowly. If you put it in a deep freezer or liquid nitrogen, it spoils very, very, very, very slowly. And so it keeps a very long time. And for each 10 degrees Fahrenheit you go down, you can keep the food in there a lot longer. Assuming it can tolerate being frozen, sometimes if you freeze things, they change. So frozen raspberries aren't the same as fresh because of the ice crystals rupturing things inside the fruit. Okay. Now let's talk about something which we will definitely have on Tuesday, which is we're going to add reactions. And we know that when we add reactions, any state function, big H, any big capital letter, big S, big G, they all add. Let's then talk about, suppose we have this reaction. This reaction in the 60s was a big problem because coal has a lot of other stuff in it, in particular sulfur. And high sulfur coal is a lot cheaper than low sulfur coal because of this reaction, basically. If we burn the coal to produce power and we have sulfur in it, then we also make SO2. So just like the C in the coal, the carbon makes CO2, the sulfur makes SO2. And if delta G for that reaction is delta G1, and I have another reaction where I take SO2 and it goes up into the air and it reacts over time with oxygen in the air out of the smokestack, then it makes SO3. SO3 is called sulfuric acid anhydride. If I add water to it, I get sulfuric acid. When a lot of coal plants in Ohio were burning a lot of coal and there were no emissions controls, the SO3 would drift over Canada, up north, and then mix with water and rain down on all their nice forests. And that was the so-called acid rain problem. The trees would defoliate because the pH of the ground was changing. And also, if you just spray dilute sulfuric acid onto the leaves of plants or pine needles, they don't like it. It's too acidic for them. So the trees wouldn't grow. And in Canada, of course, they're doing a lot of lumbering. They have a lot of people cutting down trees, turning them into planks and selling them. And if their trees don't grow, that business is dead. And so there was quite a tug of war. You've got to stop burning this stuff. That's your problem. But that drifts up there. You find another kind of tree. Well, eventually they said, well, OK, we'll stop this SO2 going up. But that cost a ton of money. Now you have to put something on the smokestack that captures the SO2. And then you have to take it out. And you have to keep it clean. And that costs a lot of money. And where am I going to put it? What am I going to do with it? Can I sell this material for any purpose? Or is it just junk that's dangerous and toxic that I've got to somehow figure out what I'm going to do with it? It depends. Well, if we add those reactions up, and we just imagine doing it in one step, then the SO2s go away here. And I have a net reaction, sulfur, elemental sulfur. And 3 halves of molecular oxygen gives SO3. Delta G for this reaction, whatever it is, is just the sum of this one and the sum of this one. We just add them up. If we turn a reaction around, we change the sign of delta G because we changed the initial and final state. And if we carry out these two reactions at the same temperature, then I can multiply by minus 1 and divide by RT. And I have, instead of this equation, minus delta G over RT is equal to, I'm sorry, minus delta G1 over RT plus minus delta G2 over RT. And that's of interest because that means since delta G over RT, minus delta G over RT is log K, that means that log K adds up. So log K for the total reaction is log K1 plus log K2. But I know how logs work. I can always combine them. If I add them, I multiply them and take the log of the total. If I divide them, I subtract them. And then if the log of K is equal to the log of K1, K2, that means that K is equal to K1, K2. Therefore if we add two chemical reactions, we multiply the equilibrium constants. Let me say that one more time. If we add two chemical reactions, we multiply the equilibrium constants for the reaction. The reason why this is not just academic is because one of these reactions might be unfavorable. It might be one we want to run, but it's not going anywhere because K is tiny. But if we couple it to another reaction that is favorable, then we can drive the whole log to go to where we want. And that's what chemists always do. Chemists run a ton of unfavorable reactions as do all living things. They assemble these gigantic molecules that are very, very low entropy, and they do so by running a ton of other reactions that are favorable, like burning up glucose with oxygen to make CO2. That's a favorable reaction. So as long as I can eat and I can run that favorable reaction, then I can run a lot of unfavorable reactions like get smarter. But if I can't eat anything, I can't get any smarter. And if I eat too much, I won't get smart either because then the blood ends up in your stomach and your brain needs blood to work. So before the exam, you don't just eat a ton of stuff because then you'll fall asleep in the exam. That's the natural result. You look at a lion that's hungry. How does it look? Right? Right alert. That's the way you want to be for an exam. What's the problem? You look at a lion that's just finished a giraffe. It's a dead, right? It's asleep. It's digesting all that food, all the bloods in its stomach, doing all that biochemistry. You only want to do one thing at a time. So you come into the exam hungry, and then after the exam, you eat and relax. But don't get the order wrong because if you do, you won't do as well. Okay, let's finish up by talking about Le Chatelier's principle. And Le Chatelier's principle is just that if we have a system at equilibrium and we change something, how will the equilibrium shift? Or will the equilibrium shift at all? While Le Chatelier worked this out and made the following general statement, the equilibrium will always shift in the direction that tends to counteract whatever the change is. For example, and we worked this out in some detail, if we increase the pressure in the Haber reaction to make ammonia, then we saw that we made a lot more ammonia, the right hand side, because making more ammonia minimizes the number of moles of gas and counteracts the increased pressure. When I squeeze on a chemical system, it tries to get smaller if it can. And if it can get smaller, it does. And in this case, that's our lever to get more product out of the reaction. Okay, so let's consider a reaction to synthesize Fos genes. Don't try this at home. Very, very, very reactive guy, this guy. Let's take molecular chlorine and carbon monoxide and make Fos gene, COCl2. It has a carbon, double bond oxygen, and two chlorine sticking out like a triangle. And let's consider the effect of the following changes. Let's suppose we have the reaction at equilibrium. That'll be the effect of each of the following on the concentration of carbon monoxide. One, I inject additional chlorine. Two, I add argon gas and I make the total pressure higher. Total pressure is higher because I've pumped in argon. But argon doesn't react with the other guys. Three, I just compress the mixture by increasing the pressure. Or four, I decompress the mixture by lowering the pressure. Okay, let's go through them then one by one. First we'll start with injecting additional chlorine. If I add additional chlorine, I'm going to increase the denominator in Q because Q has the concentration of Fos gene and in the denominator the concentration of chlorine times the concentration of carbon monoxide. Q is K at equilibrium and K doesn't change. Therefore if I add more chlorine in the denominator, I'm going to have to get less CO. Otherwise it's not going to work and I'm going to get more product. And this is another clue. Suppose I have two reactants. One of them is extremely expensive and the other one is cheap as dirt. And I want to use up the expensive reagent so I don't waste it. Then what I do is I just pile in the dirt until I drive it over to the other side. And if the dirt cheap reagent is a gas, it's great because I can pile it in, get the product, isolate the product, and then vent the gas off, assuming it's harmless. That's another trick. Two, adding a dirt gas does not shift the equilibrium. Why not? I just said if we increase the pressure, we shift the equilibrium if the number of moles of gas of products and reactants is different. And now I'm saying I'm increasing the pressure but nothing's happening. The answer is argon is not in Q, the reaction quotient. If I don't change the reaction quotient, I can't change any of the concentrations of the things. So although the total pressure in the container is higher because I didn't actually change the reaction quotient, I just added something else that doesn't react. Nothing changes. So there's no change in equilibrium if I add an inert gas. If on the other hand I squeeze on it like this and compress it, then I'm going to get more product because there's again Q, if I work it out with the moles of gas, there's going to be a P standard over P left over. And so if I increase the pressure, I'm going to decrease the number of moles of CO. And so not surprisingly, if I expand it, then I'm going to shift it and get more CO because some of this phosgene will actually react backwards and make both CO and CO2. And I'll get more CO. And that's how we keep track of it. So here's the summary. If I change the concentration of something in the chemical equation, not something else, but something that participates in Q, the reaction quotient, then I'm going to shift the equilibrium, but I'm not going to change the equilibrium constant. If I put pressure on a gas, I'm going to shift the equilibrium potentially if the number of moles of gas is different, but I'm not going to change the equilibrium constant. If I change the volume, I'm going to shift the equilibrium, but not change the equilibrium constant. If I shift the temperature, ah, log K minus delta G over RT, I know then that the equilibrium is going to shift and the equilibrium constant is going to shift. And if I add a catalyst to make the equilibrium come more quickly, a catalyst, strictly speaking, this is never true, but a catalyst, a true catalyst is unchanged. So if it starts on the reactant side, catalyst plus blah, blah, blah, blah, blah, and then on the product side is products plus the same catalyst, the catalyst cancels out because whatever its concentration is, it's in the numerator and the denominator. So if it's a true catalyst, it can't shift the equilibrium. It just makes the equilibrium happen more quickly. Really what happens is the catalyst gets dinged over time because our reagents aren't 100% pure and if we've got a tiny, tiny amount of some bad guy in there, it wrecks the catalyst. That's why the oil companies had to get rid of all the sulfur in the gasoline because it was reacting with the platinum and palladium and the catalytic converter and making it fail. And there was a big battle. You guys make a better catalytic converter. You guys get the sulfur out of the gas. We can't make a better catalytic converter. So usually the oil companies and the auto companies are on the same page, but not always. Whenever one's going to have to try to do something very hard that's going to cost a ton of money, then they try to say, well, the other guy should do something very hard that costs a ton of money. Instead, the result of that is that we have gas that doesn't have as much sulfur in it. Okay. We'll finish up here with a few subscripts on K. There's lots of little subscripts on K and they're all Ks. They're all ratios of products and reactants and they're just meant to be descriptive. So if I have K sub A, that means this reaction. That means an acid dissociates to give H plus and the anion. And here's the formula for K. And if I have KB, that refers to a base. I have a base. It pulls a proton off water and makes hydroxide. I could have a neutral here like ammonia plus water gives ammonia and myon plus hydroxide. That's why they tend to put ammonia into things like Windex. Okay. Because it gives the right amount. You say, why don't they put Drano in Windex and make hydroxide that way? And the answer is it will leave a residue on the glass, number one, because it won't evaporate like ammonia. And number two, it's usually too strong. And if I make it too basic, I'll actually start affecting the glass. I'll actually start polishing away the glass so my glass window is getting thinner and thinner as I keep cleaning it over time. And that's a bad strategy to do that. Okay. So at this time, what we'll do is work some problems, okay, which will be good ones to know.
UCI Chem 1B General Chemistry (Spring 2012) Lec 17. General Chemistry Intermolecular Forces -- Equilibrium Calculations -- Instructor: A.J. Shaka. Ph.D. Description: UCI Chem 1B is the second quarter of General Chemistry and covers the following topics: properties of gases, liquids, solids; changes of state; properties of solutions; stoichiometry; thermochemistry; and thermodynamics.
10.5446/19465 (DOI)
We'll have the grades posted, the scores posted soon, and the exams are being scanned until you get them back. If there are any mistakes on your exam, just send me an email, caps, error on midterm 2, and then what it is. And then I have a copy so I can look at it and fix it. And then we'll post all the updated scores for midterm 1 and midterm 2. But look, don't sit on midterm 2 and come to me after I'm out of town at the end of the quarter and say, there's a goof on midterm 2 and I waited two weeks to find out about it. Go over it yourself, add up the scores, make sure there's no mistakes on your exam. If there are, we can fix them. If you wait till later, it's much more difficult. As a kid, I loved reading stories. I particularly liked reading the Greek myths about my purported ancestors. And I liked reading about all the pagan gods because they seemed like bigger versions of what I wanted to be. Powerful, but they'd get in fights with each other like I did with my sister and I wished I could turn her into a spider some days. And I guess I sort of liked Hercules because I liked the idea of being strong. But my favorite character was Anteus. Anteus, as the myth goes, was the son of Mother Earth and another Greek god. And he was a wrestler. But here's the metaphor. Anteus could never be beaten because every time you threw him down to the ground and he touched Mother Earth, he came back stronger. That's the metaphor that you need sometimes in life. Things don't always go your way. They don't always go your way the first time. They may not go your way for a long time. But the difference is whether you give up or you come back stronger. That makes a world a difference in the long run. And with that in mind, I want to kind of go over a post-mortem on some of the problems that I graded that I saw mistakes on. I toyed with the idea of the following. If on the final, you have those distributions of speeds and you draw it wrong the third time, you just flunk. I just post your three bad graphs as evidence that you learn nothing at all. Don't let that happen. That's a two second problem and I'm going to go over it now. So make sure you get it right. It's not that important, but it's kind of a metaphor for actually paying attention and learning what you're supposed to do. First, I want to start though with some corrections. Some of you figured out on your own that I made a goof when I analyzed the energy density of octane and hydrogen and the goof is big enough. It was a simple mistake that I'll show you. But like the Mars orbiter, it has a big impact. So hydrogen's not nearly as bad as what I sketched out in problem 41. So let's first fix my mistake. And here was the problem. I said, suppose we want to transition to a hydrogen economy, what volume of hydrogen gas at 1,000 psi in 25 Celsius is required to produce the same heat enthalpy of combustion as 25 gallons of octane. And then you get the density of octane and its standard enthalpy of combustion, 5,500 kilojoules per mole exothermic. And here's what went wrong. Right here in bold. What I originally put made no sense, but I put it, the units canceled out, so that was okay. But I got the ratio wrong. It's one mole is 114 grams, not 114 moles is one gram. And by putting the 114 on the top, I got a factor of 12,000 wrong. And that makes a huge difference in how practical you might assess hydrogen to be. So let's go through it now and get it right. So with this ratio correct, that one kilo mole is 114 kilograms, then we have 582 moles of octane in 25 gallons. And if we work that out, we get 3.2 million kilojoules. But I think before we had a much, much bigger number. With this 3.2 million, we have to figure how much we would get from hydrogen. For hydrogen, we get 241.8 kilojoules per mole just from the enthalpy of formation of water vapor. And remember I said I was using water vapor. It doesn't matter as long as you use the same thing. And that means that when you convert it to the moles of hydrogen you need, you get 1.32 times 10 to the 4 or 13,000 moles of hydrogen. That's quite a lot, but it's not a million moles. Sorry, I have a duplicate. And then we had to figure out the volume. And now the volume comes out to be something much more reasonable because the number of moles is not so huge. We get 4,762 liters. And therefore the hydrogen gas tank that you need would have to be about 50 times larger than the petroleum gas tank. But it wouldn't have to be as big as the car or me set on three sides like a giant cube. And that makes quite a bit of difference. In addition, we don't have to burn the hydrogen. If we use the hydrogen in a fuel cell then we can extract the energy from the hydrogen much more efficiently because we don't make heat. An internal combustion engine works by exploding and making heat and expansion. And whenever you make heat you take a bath because once you make heat you can't extract all the energy back out of the heat. You've made something very disordered and there's only so much order you can milk back out of it. That's what the second law says. But if you don't make heat, if you make work first by converting the hydrogen in a fuel cell to electricity that can be far more efficient. And so we might, I doubt, we'll get a factor of 50 out of that, but we'll get something out of that. And that means that it might be possible. The big problem right now with the hydrogen is that the best kinds of fuel cells use platinum as a catalyst to make the fuel cell go. And because they use platinum, that's like paving the roads with gold. It's extremely expensive to make cars that have appreciable amounts of platinum as part of the car. And that's where chemists have to come in and find a better solution to a fuel cell that only uses cheap stuff and that doesn't need to run at elevated temperature. The other problem with a fuel cell is to get the rate to be good enough, you have to heat it up. And that heat has to come from somewhere, probably from your car battery, but you still lose by having to heat that thing up all the time in order to run it. It has to be quite hot to get an appreciable rate. And right now there doesn't seem to be a solution for that to have a fuel cell that runs more like a battery just sits there at room temperature and runs and produces electric power for your car to use. Okay, now let's go over a few of the exam. There were still errors on the plots of the relative numbers of atoms versus speed for argon and helium at 25 Celsius. We didn't grade on the exact shapes of the curve, but there are zero atoms moving at zero speed because moving at zero speed means you're a solid and there's no solid in there. So the curve starts at zero. It then comes up and then it has to die out again to zero. It can't keep going up because if it keeps going up you're implying that there's a ton of energy from somewhere to make those molecules keep going faster and faster and there isn't. It's at 25 Celsius. It has a finite amount of energy that depends on the temperature. So we wouldn't want that. Now let's have a look then. This was slide 62 I think before. They all start at zero. They all hit a maximum somewhere and the heavier you are the slower your most probable speed is. The most probable speed is the highest point on the curve. I think in the problem I said it was around 1100 for helium, right? So you draw from zero to 1100 and then you draw something that goes back down. And you can draw it roughly symmetric. It's not quite symmetric, but roughly the distance from here to here and the distance from here to where it goes back down to almost zero is about the same. Now you could have drawn me a very accurate one for argon. Here's argon here because you know that the most probable speed goes like the square root of the molar mass. So if you know the most probable speed of helium, 4 grams per mole is 1100, you can take the ratio of the square roots of the molar masses and figure out exactly where this is and you can draw a beautiful thing like that. What you don't want to do is draw argon as having a peak out here somewhere to the right because that implies that the heavier guy is moving faster and that can't possibly be true. If you just think about collisions between things, the heavier guy doesn't get knocked around nearly as much because he's heavier. Three light guys hit him and he's still not moving very fast. Okay? All right. Let's go on. Well, I just wanted to say again that it was Maxwell who worked out that this particular distribution maximizes the entropy. So it's the most probable. And we have all the masses. If you want to practice, just take the function. This is basically got v squared and then e to the minus sum number times v squared. So just plot x squared times e to the minus ax squared and look at it. And you'll see it starts at zero, it goes up, and then the exponential, the Gaussian function kills it, keeps it from going too fast. This one was a weak point. Of the papers I graded, one person got this right. I didn't grade every single paper, but I did grade a lot of them because I like to see what people are doing. And only one person of the ones I graded, which was about 50, got it right. Let's then make sure that if this problem makes an on-core appearance that we get it right. We were supposed to estimate the enthalpy of combustion of propane using mean bond enthalpies. Okay. I tried to indicate by writing h3c and then dash, ch2 and then dash, ch3, what the structure would be rather than just writing c3h8, which is a little vague. But the actual structure, if you write it out, looks exactly like this. In a two-dimensional schematic form, of course, this is a three-dimensional molecule, and the bond angles are not 90 degrees. There are tetrahedral angles, and they form a 3D structure, and they can move, they can move around like spaghetti. But for the purpose of analyzing it, all we need is this. We count 1, 2, 3, 4, 5, 6, 7, 8, ch bonds, though we have to break. And 2cc bonds that we have to break. And then we're asked to get delta h for some reaction. Now here's the thing. Whenever you write a state function, delta g, delta h, whatever, if you're referring to a chemical reaction, write down the reaction. That gives you kind of a fixed point to refer to. What reaction am I talking about here? Many people just figured out how much energy it took to bust this thing apart. But that's not what I'm interested in. I'm interested in the enthalpy of combustion, which means I'm reacting this with oxygen and producing CO2 and H2O. So there's a lot more to it than just breaking this thing apart into atoms. That's not the reaction we're talking about. If you don't write down the reaction, though, you can kind of forget what you're talking about yourself, and you start computing the wrong thing. And I think that may have happened for some people. So they did a right calculation, but for the wrong reaction. That's the upshot of it. So delta h of combustion refers to a reaction always write down the reaction, and then balance it. Atoms don't appear and disappear in chemistry. They just rearrange. That's all they do. The nuclei in chemistry, except for nuclear chemistry, are fixed. And it's just the electrons that move around and rearrange, just like the letters in the jumble we did are fixed. It's just that one of them makes a word and the other is nonsense. So we start here by saying, right, we're burning C3H8 propane with oxygen, and we're producing CO2 and H2O. And that's what complete combustion means. We have three carbons here, and this product side, the only molecule with carbon, is CO2. So we have to put a three there. We have eight hydrogens. The only molecule with hydrogen on this side is H2O. So we have to put a four there. And then we count up the number of oxygens. We've got six and four is ten. This is molecular oxygen. We have to put a five there. And so now we want to break apart the reactants and the products into atoms and then figure out which side wins. First, let's estimate how much energy it takes to break the reactants formally into atoms. We know we aren't ever going to do this, but remember the beauty of state functions is the path doesn't matter. So the path can be fantasy, because the path doesn't matter. It doesn't have to be something we can really do. It can just be anything that we can figure. So let's figure it. Let's break this apart into three carbon atoms in the gas phase, eight hydrogen atoms in the gas phase, and ten oxygen atoms in the gas phase. Well, I have to break eight CH bonds, two CC bonds, and five oxygen double bonds. And you were given all those on the front, and I think I've used the same numbers. Eight times 412 plus two times 348, that's the carbon, plus five times 496 to break these apart. So this reaction to make this go on paper requires 6472 kilojoules per mole. It takes a ton of energy to break all those bonds apart. Okay, I have that number. Now what I want to do is go to the other side, and if I've balanced it, I'm going to have the same atoms here, but I have to count up different kinds of bonds, because here I have OH bonds, and here I didn't have any OH bonds, and here I have the strong CO double bond, and I didn't have any of those over here, so we have to take a look at how those pan out and see what we get for this. So let's do that. Here we have to again count up the bonds. Each CO2 has two CO double bonds, so we're going to have six of those. Each of these has two OH single bonds, so we're going to have eight of those, and we get the same atoms. The question is whether it takes more energy to break the products apart to atoms or the reactants apart to atoms, and because of the very strong carbon-oxygen double bond, this number 743 here is the winner in this game. We get 6 times 743 plus 8, and it turns out OH bonds are pretty good too, 463, so we get 81,62 kilojoules per mole on this side. And now I'm going to go over this very carefully, because I had a lot of questions, is it reactants minus products, or why is it different for this or that? And what I want to do here is just go over this so that you can't get screwed up. Trying to remember if it's reactants minus products or this minus that is hopeless. What you want to do is say, I've got to add up these reactions somehow, and however I add them up, it's got to total up to the reaction I want, not some other reaction out in left field. Once I've got them so that they add up to what I want, it'll be absolutely clear which one's negative and which one's not, and there's nothing to remember. The less you have to remember, the better off you are, especially as you get older, because your memory will not be as good. If your only strategy to learn things is to somehow remember things, you're going to be hopeless. You have to just learn how to figure them out. You have to remember something of course, but you don't have to remember the details. Now the reaction that we want is this one, and you see that the CO2 is on the right hand side here, whereas the CO2 is on the left hand side here. On the previous slide, the propane was on the left hand side, so the propane thing going to atoms is fine, plus whatever it was. This one, however, I've got to turn it around backwards. Otherwise, I won't have CO2 on the right, and therefore I have to change the sign of this one. I don't give a toss which is products or reactants here. I'm just saying there's an easy way to see what it has to be, and that's the way to remember it. Not by saying, oh for this it's that, and for this it's that. So we have to turn around this product atomization, this imaginary reaction. We're forced to turn it around, and when we turn a reaction around, when the initial and final state swap, the sign of the state function for this reaction also swaps, because that's just the right minus the left, and if I interchange them, it changes the sign. Therefore this one is going to become negative simply by the fact that I have to turn this reaction around to get the one I want. So let's do that. Let's leave this one as it is. We figured that one, 6472. Let's turn this one around, and now we see that all the atoms go away, all these imaginary things go away, and when we add up the two chemical equations, we get the reaction we want, it's balanced the way we want, and now we see we're going to take 6472 minus 8162. The way I think of it is, I'm always adding, but I had to change the sign of this one from what I figured, because I figured it the other way around. So I write them as plus, and then I change the sign of any reaction that I turn around. I don't even think of subtracting. I always add everything, but some numbers are negative. And there's the right answer. 1690 kilojoules per mole. Yes? Why is there some time between the bonds of oxygen and the bacteria? I'm going to go over that on the next few slides. It depends whether you're talking about mean bonds and thalpeas, whether you're going through this imaginary intermediate where you've broken all the bonds, or not. All we're doing, we aren't saying that this reaction actually occurs. Nobody is proposing that we can do this in the lab or that this ever happens, but the beauty is it doesn't matter if it happens or not as long as we've got numbers. In other words, if I go to the top amount, Everest, and then come back, and I come back 10 feet less, I know I'm 10 feet higher than where I was before, and it doesn't matter that I didn't actually go to Everest. In fact, based on recent news reports, you don't want to go to Everest unless you want to end up with a very short life. Here's my thought then. It's not worth trying to remember which gets the negative sign, because it'll be obvious when you just add them up. If you cancel out all the things, either it'll be the reaction you want, or it'll be some mumbo jumbo that you don't want, and then you have to figure out which ones you turn around. But you just have to find reactions that add up to the ones that you want. Now, we could also do this problem a different way, a more accurate way. We could use the heats of formation. Remember, the bond enthalpies are an average, and it depends what kind of compounds were included in the average what I get. The average score for this exam, which was pretty good actually, I think. I never look at the average, but just marking the papers, would be much higher for this class than it would be if I just gave it to every registered voter. And since I don't know exactly which compounds they've included in the CH and so forth, I expect this to only be approximate, not accurate. Now, let's try it another way then using heats of formation. Let's try another imaginary path to get to what we want. Suppose we were given the same problem, but we had the heats of formation of propane CO2 and H2O, and remember the heat of formation, the enthalpy of formation of molecular oxygen is zero because the heats of formation are from elements in their standard states made into the molecule. It's the heat that we would get if we did that imaginary reaction. But these can be measured in many cases, and so they're much more accurate. For the heat of formation of propane, now I've got a different reaction. I don't have gas-faced atoms. I have elements in their standard state at 298.15 Kelvin. And the elements then are three carbon in the form of graphite as a solid. I should probably put an S, a graphite here, but graphite is a solid. Plus four molecular hydrogens, not hydrogen atoms. Molecular hydrogen is hydrogen in the standard state at 298.15 Kelvin. This hypothetical reaction, if I could carry it out and make propane this way, which I cannot, gives an enthalpy of minus 104.6 kilojoules per mole. How do I know that? I have to look that up. I don't know it. And on an exam, of course, you'd have to be given all the heats of formation of every single compound in a chemical equation, otherwise you can't do the problem. And I can do the same thing with CO2. I can imagine taking three graphites and three molecular oxygens and making three carbon dioxide molecules in the standard state at 298. And since I've made three, I have to take three times delta H of formation because delta H of formation of CO2 is per mole of CO2, and I'm making three moles. So I've got three times as much. That's minus 393.5. I think we've seen that figure before. And I have to multiply that by three. I keep this sign. And then the last thing I have to make is water. And to make water, I take four hydrogens as molecular hydrogen and two molecular oxygens, and I make four water molecules. And I have to look up the delta H of formation of water, and I have to multiply by four, and I have four times minus 241.8. Now, if I were to say, well, what about the oxygen in the combustion reaction? That's a reagent. How would I make oxygen from elements in the standard state? I'd make it from oxygen. I'd start with O2, however many I need, and I'd make O2. I'd do nothing. And so delta H for that is zero, because both sides are the same. It has to be zero. Even if I write it down, if both sides are the same, it has to be zero. So then I realize that I don't need that one for this approach using formation because I'm using the elements not imagining going to atoms, which are not the same as the elements. And if I use then this approach, here's the difference. The products that we need are already on the right-hand side, because we made them from the elements. We made CO2 and H2O on the right-hand side, but the reactant propane was also on the right-hand side, and therefore I have to switch this around because I want this guy on the left-hand side. That's all. So I turn this chemical equation around, and I change this from minus, put a minus sign in front of it because I've turned it around, and before it was minus 104.6, therefore for this reaction written this way, it's plus 104.6, and I put the plus sign just to emphasize it. And therefore for this reaction that we want to do, we have propane and then these we already had on the right, and this is zero. We add this equation and the other one, so we take 104.6 plus 3 times minus 393.5 for this guy, plus 4 times minus 241.8 for the water, and if we do that, we get minus 2043.2 kilojoules per mole, which you see is pretty far off from the other one, more than 10% off. I would trust this number much more. Keep in mind when you do this, you're imagining doing the combustion at 298.15. If you're actually burning propane in a flame, you have to be careful because the temperature is not 298.15 in a flame, it's potentially far higher than that, and you would have to correct for that by knowing all the heat capacities of all the products and reactants, and then that would be much more detailed to actually figure it. So just always write down the reaction you want, put it together any way you want, like tinker toys, pull the things apart depending what information you have. If you have delta H of formation for all the things involved, always use that because it's more accurate. If you don't, guesstimate with the bond enthalpy. You'll be in the ballpark, but you can't assume that that's going to be an accurate figure. Okay, so here's the summary. Know what reaction delta H is referring to by whatever the definition is. For bond enthalpies, it's breaking it apart into atoms in the gas phase. For formation, it's using the elements in their standard states, which are different. Then just add up the reactions until you get the reaction you desire. And usually, to make things cancel out, you have to turn at least one reaction somewhere backwards. And if you reverse a chemical equation, you're just changing the initial and final state the other way around. And therefore, you have to reverse the algebraic sign of the state function because it is a state function. It's a difference between the final and initial. If you swap them, it changes sign. And finally, keep in mind that mean bond enthalpies are not going to be as accurate as using the enthalpies of formation, the heats of formation. Because they're averages and we're making specific molecules. If we know the specific molecules, we've got the data. Okay. Now then there was this bonus problem, which I thought would be a gimme. I thought I'd put the ball on the green about a foot away from the cup. And all you had to do is tap it in for 20 points. But what some of you did is you said, gee, there's a ball on the green. I think what I'll do is I'll stick this wooden stick in the ground, put the ball on it so I can really whack it. And I'll just hit it off into the wood somewhere. And you can still actually complete the hole that way, but the problem is it takes a lot longer. In this problem, we didn't give the temperature because the temperature doesn't matter. That was supposed to be a hint. Recall, here's what we have. We have these guys connected. Series of flasks. We have argon, this is one version, argon, one liter, one atmosphere, here it is. Helium, one liter, half an atmosphere, here it is. And neon, two liters, one atmosphere, here it is. Of course, we assume they don't react, these are noble gases, they aren't going to react. But you have to be careful if you have real chemicals here, if they react, that's a nightmare. Because then the temperature will change for sure, and the number of moles will change for sure, and you have to be very careful. But there was nothing like that here. And what the question asked about was the partial pressure of each gas. And the total pressure after the stop cocks or the valves are opened. And at first blush, this looks a little bit tricky, but here's the thing. You just look at each gas on its own and pretend the other ones aren't there. You just pretend they aren't there. Because in terms of the helium, they aren't there. They're ideal gases, the particles have no size. In terms of heat argon here, when I open it, this is a vacuum. And so is that. And the argon just spreads out through the whole thing. Well, I know P and V here, and it looks like V changed to four times. So I know P, end of story. Okay, it takes one second. Let's do it. We don't need to know the temperature. Each gas is independent of the others, and we're assuming they're ideal, but that's safe. And none of them have any excluded volume. We're assuming the volume of the atoms is zero. So all we do is just use Boyle's Law for each gas separately. We figure the pressure and then add up the pressures to get the total pressure. Therefore, for each individual gas, it's as simple as P1V1 equals P2V2. I need to know what P1V1 is, but that's written on the diagram. And I know V2 is four times V1. The argon starts at one atmosphere and one liter. It ends up in a total of four liters, so the argon is 0.25 atmospheres. Done. The helium starts out in one liter and 0.5 atmospheres. It divides by four. The partial pressure of helium is 0.125. And the neon starts out at two liters in one atmosphere. It goes to four liters. Therefore, it ends up as half an atmosphere. I add up to get the total a half and a quarter and an eight and I get 7 eighths or 0.875 atmospheres. Okay? Very, very quick. I think I've got that on a slide, but I'll get the slides in order for when they're posted on the video. Okay. There was another one here, osmotic pressure. We had some strontium nitrate, an imaginary pollutant from a farm. The nitrate's probably not imaginary, but I don't think anybody's putting strontium on their crops. The key here is that strontium nitrate, written like this, it all dissolves. We get one strontium ion and we get two nitrate anions. So we get one strontium cation and two nitrate anions. And therefore, we get three moles of particles for this problem. So we take the molarity that we're given, 0.1, 0.08, whatever it was. We multiply by 3 because i is equal to 3 for this problem. And then we use pi, the osmotic pressure, as the moles per liter times RT. T was 300 Kelvin and then we get the answer. And again, it's quite quick. And now I have the slide that was out of order with the answers here, but I'll get it in the right order for the video. This is exactly what I said. And this is the total pressure, 0.875. Okay. So I hope you can see that this wasn't as hard as it might have seemed on the day. Alright, let's get back to free energy. So recall the second law of thermodynamics asserts that for any spontaneous process in an isolated system, the entropy change is non-negative. At equilibrium, the entropy change is zero, but that's a special case. Or if we do a reversible reaction, then delta S is zero, that's why it's reversible. If we don't make any kind of additional entropy in the surroundings or in the system, then we can go backward because in a certain sense, entropy changes chart which way is forward in time. Since energy is conserved, we can't look at energy and decide which way we're going forward. But if I see a film that's running backward, it's very easy for me to tell it's running backward because there's somebody at the bottom of the pool there, and suddenly, magically, there's all these swirls of water, and the water kicks them up and into the air and back on the diving board, and I say, hey, this film's running backwards. I've never seen that happen. The water spontaneously in a pool just has this massive fluctuation and hurls me out. Obviously, the water has enough energy to do that, but because the water molecules are not working together, they can't do it on their own. They can't just suddenly decide to hurl me out of the pool. Yes, there's some chance, 10 to the minus 130, that that could happen sometime, but it's not large enough that I'm ever going to see it in the lifetime of the universe. And so if I see something like that, I can tell immediately if a film's running backwards by the way things are happening, what you're sensing is that it's very unnatural for entropy to decrease, and when you see that, you just automatically assume that the film's running backward. And therefore, it's really entropy that we want to watch out for. When we burn things and create heat to generate power or do other things, what's happening is that we're creating entropy. Energy's conserved. We're turning chemical energy into heat, but heat is much less useful than chemical energy, so we're increasing the entropy of the universe. And when we do that, we can't go back. And well, in every actual case, the total change is irreversible because reversible is kind of a special case for us to think about. Real reactions are irreversible. Why does entropy increase? It just increases because it's the most likely outcome and atoms don't have brains. It's the same reason that if you throw two dice, you get seven a lot more often than you get two. It doesn't mean the dice are loaded or the dice are trying to do anything. You just throw them and it turns out there's many more ways to make seven, one and six, two and five, three and four, then there are to make two. You've got to have both dice come up one and one. Then you've got snake eyes and you just lost your bet. Or if they both come up six, you got box cars, you lost your bet. That's not very likely, but that does happen sometimes. But if I have ten to the 23 dice and I just throw them all, there's going to be a certain range of numbers that it's going to be very likely that I get and it's going to be very unlikely that all ten to the 23 dice come up one. That's extremely unlikely. And therefore when we talk about large numbers of particles, it's overwhelmingly probable that the entropy is going to increase. And that's because molecular motion is random just like heat and therefore entropy is going to increase to the most likely state. There's no rhyme or reason, it's just probability. In fact, Boltzmann expressed entropy in terms of the probability that a particular microstate could arise. And this is in the book, but we talked about this when we were looking at molecules dissolving. All gas molecules on one side of a two-sided container, that's like throwing snake eyes over and over, that would have very low entropy. That's where you start when the valves close because you've got them trapped. But once you open it and they can decide what to do on their own, they're never going to go back to one side when you've got large numbers of particles. Never going to happen. So whatever you did there is irreversible. When you open a tank of gas and let it get out, that's it, it's out. On the other hand, equally distributed, roughly, would have a very high entropy. And on Boltzmann's tombstone is his famous formula, that entropy is proportional to the natural log. There's a reason why it's the natural log and not just the thing itself, of the number of ways that you can actually make this state. You can just think of w as the number of ways. If you take a course in statistical mechanics, then you'll see this formula. Or if you look at Professor Tobias's license plate, you'll see this formula as well. Okay, the universe, whatever it is, is an isolated system because when we say universe, there's nothing outside. There's no surrounding. And therefore, for any spontaneous process in this universe, the entropy change in the universe is greater than zero. The sun doing nuclear fusion and creating heat and spewing off all the solar winds, everything else is creating huge amounts of entropy. But when we're talking about the lab, we aren't interested in the universe. We're interested in our system. And therefore, we focus on what we're doing, our chemical reaction in a flask, and everything else, the heat bath, the stirring bar, everything else is the surroundings. And we focus on the system because that's what we want to study. We don't want to try to study the whole universe. It's too big. And in fact, this is what all living organisms do. They create entropy in the surroundings so that they can order themselves. And if you look at your own physical being, where do you think the lowest entropy is? In your brain. Highly ordered. Amazing. And in a way that you can take gas molecules and snap your fingers and you get a human brain. And in order to keep that going, which burns about 15 watts continuously, we chuck out heat. We're hot. We're producing heat all the time. We're eating all kinds of fuel and we're burning it up and we're producing gases. CO2 comes out in our breath and so forth. And if we don't have a source of energy, we die. And as a society, if we don't have a source of energy, we die. We're just at equilibrium. We're in trouble. We don't have a source of energy. We have to have some way to pull that tractor through the field. We have to have some to eat for ourselves and so forth. And that's because the only way we can survive is by creating more entropy in the environment. Therefore, the more things you have, the more energy you go through, the more entropy you create. There's no way it has to be. There's no way around that whatsoever. Delta S, recall, it's just a measure of how much extra chaos we're creating. And therefore, and I think I gave you the analogy that in a library, if you say a loud sentence, everybody notices because it's so quiet in the library. And likewise, if I have a very ordered system at low temperature and I inject heat, it does a lot of damage. The entropy goes up like crazy. But if I have a very disordered system that's already chaotic at high temperature and I inject a little heat, it doesn't do much additional disordering. Therefore, the change in entropy is low. And so we have to take a ratio of the heat that we add to the temperature that already exists. That's the measure of the entropy. And to be careful, we have to add the heat reversibly because heat itself, remember, is not a state function. So I can't just say I add some heat. I need to specify the path so that the heat is accountable and reversible is the nicest path. So I add the heat at constant temperature, then I can figure the entropy that I created. Otherwise, it's much harder. And for an exothermic reaction, the reason most exothermic reactions are favorable, like our metabolism and burning fuel, whatever, is that they disordered the surroundings because we add positive heat to the surroundings divided by the temperature of the surroundings. And the positive heat we add to the surroundings at constant pressure is just delta H of the surroundings. And that had to come from somewhere, so that's minus delta H of the system. Therefore, when delta H itself is negative, minus delta H is positive, and the entropy of the surroundings is positive, the entropy of the surroundings has increased. Broadly speaking, why exothermic reactions are favorable. And then recall that this is how we derive why we are interested in delta G. We don't want to take into account the surroundings at all, so we divide the universe into the surroundings and the system, and delta H of the surroundings, we substitute minus delta S of the surroundings, we substitute minus delta H over T. That's the entropy we created by having a reaction add or subtract heat from the surroundings, plus whatever happened to the system, did the system itself become more ordered or disordered. We multiply through the whole thing by T minus T, we get this, since delta S of the universe is greater than zero, that means that minus T delta S of the universe is less than zero, and that means that this thing, which is the same, is less than zero, and because this thing occurs so often, we give it a special symbol delta G. So at constant temperature and pressure, delta G decreases, things roll downhill, G goes lower and lower and lower until G goes to the lowest possibility, and then it sits there forever. Therefore, we can say for any spontaneous process at constant temperature and pressure, the free energy decreases. So we write delta G as delta H minus T delta S, and we forget about putting surroundings and system, because this always means the system. The whole point of delta G is we don't want to take into account the surroundings at all. A reaction that dumps heat into the surroundings is favorable, because it has a big negative delta H. So I have a big negative number here, it looks like delta G is going to be negative. If in addition to dumping heat into the surroundings, the system becomes more disordered. For example, I produce a gas from a solid, then it's going to be wildly favorable. And that's why burning a chunk of wood is wildly favorable, because I produce heat into the surroundings, and I produce CO2 and stuff from the wood from a solid, I turn it into a gas, see you later, off it goes. Disorder increases like crazy, that reaction is very, very favorable, and humans figured that out. That's why what we do mostly is we burn stuff, because that works. This kind of reaction then, that is exothermic and disorders the system, will be spontaneous at all temperatures. Now that doesn't mean that it will be fast, it just means that it's eventually going to happen, that if I leave a chunk of wood out in air, eventually it's going to all turn to CO2 and H2O. It's not going to help me much if I don't actually light it on fire, because it's going to happen too slow. But if I look at old books, I notice that the pages are turning yellow. They're sort of looking like I put them in the oven. They're burning. They're just burning up very, very slowly. And if I leave them a very long time, they'll just turn into ash. It's going to be a very long time, but that's why preserving old manuscripts is tricky, because they can be very fragile and they've been oxidized over time. The only way I can stop that is by storing the manuscript in an atmosphere that's got nitrogen. Say no oxygen, then I'd say I'm safe because there's no oxygen, then the reaction can't happen, since combustion requires oxygen. So I could do that. If I've got a reaction that absorbs heat from the surroundings, a reaction that when I run it, it gets cold, it absorbs heat from the surroundings. It has a positive delta H, and that positive delta H means that delta G is going to be positive unless something else makes it negative. If the system becomes more disordered, then delta S is positive, and that means that minus T delta S is still negative. And so it's a tug of war between delta H, which is positive, and minus T delta S, which is negative. And that means that if I make T big enough, it's going to happen. That means that any reaction that absorbs heat and the system becomes more disordered will be favorable at high enough temperatures. The example that I gave you was dissolving ammonium nitrate in water. It gets cold, but it still happens. And this reason is part of the reason why your clothes usually get cleaner if you use warm or hot water to wash them in, because the kinds of things you're trying to dissolve don't want to actually dissolve. That could be an endothermic process to try to get oily gunk off your clothes to go into solution in water. The water is making all these hydrogen bonds and saying, no, keep out, keep out. And so to overcome that, you heat it up. And if you heat it in hotter and hotter water, sometimes it works better. It just depends what the material is, what the reaction is, and so forth. For blood, you don't want to put it in hot water because then that sets the protein, like frying an egg, and then the stain never comes out. If you put a little bit of blood on something, you wash it in cold water very gently to get it out. And you don't just dunk it in very hot water because then the stain sets and that's it. It turns brown and then it's there forever pretty much. Now if we have a reaction that dumps heat into the surroundings, but the system becomes more ordered, then minus T delta S is positive. An example of this, I haven't thought of a chemical equation, but a phase change. When I have water and it freezes to ice, it dumps heat into the surroundings. People find that confusing because they're saying, well, you're making ice, isn't it getting colder? The way to think about it is this. If I have a chunk of ice and I want to melt it into water at the same temperature, do I have to put in energy? The answer is yes. I have to put in energy to melt the ice. Therefore, when the water freezes, that same energy comes out into the surroundings. In this case, the reaction will be spontaneous at low enough temperatures. Of course, we know that ice only freezes at low enough temperatures. If the temperature is not low enough, the ice doesn't freeze. Oftentimes, if you've got citrus crops and you're worried about a hard freeze, if you've got water, you spray the trees with a ton of water because then a lot of the cold air will waste its time freezing the ice. It will freeze the ice first before it gets any colder, and hopefully by then it's dawn and you haven't frozen the leaves solid and so you haven't killed the plant and killed your harvest for the year. So, it's always formed at low enough temperatures because they're the most ordered form of matter with the lowest entropy. We can make solids form just by cooling things down lower and lower and lower. We can make solid nitrogen, for example, if we want, by cooling it enough. If we have a flexible here, we just lower the temperature until it's favorable. If we have finally a reaction that absorbs heat from the surroundings and has a positive delta H and the system becomes more ordered, that's a no starter. It won't be spontaneous at any temperature, so we cannot do a reaction like this and let it happen by itself. If we have some kind of chemical equilibrium that has this characteristic that the system's becoming more ordered and it also has a positive delta H, that means if we try to run a reaction like this with a positive delta G, we aren't going to get much product. We're always going to have a ton of reactant and a little product. What chemists do in that case is they couple the reaction they want to run with another reaction that's wildly favorable, like burning coal. I can make any reaction run in the lab. I can electrolyze water with electricity and produce H2O2 or whatever I want to do, run things backwards, as long as I have a power supply and the power supply is plugged into the wall and the wall somewhere is plugged into a power plant and the power plant, I assure you, is running a wildly favorable chemical reaction to generate power of some type. It's burning natural gas, oil, coal, nuclear, you name it. It's doing something like that and together, if I include the power plant and what I'm doing, the overall delta G is negative and so I can synthesize very complicated molecules, very highly ordered things by expanding enough energy and that's exactly what we do. When you grow up and develop from just a cell that's sitting there and dividing and turn into you, that takes a lot of energy. If you figure out how much you eat over all those years, et cetera, et cetera, et cetera, it's a lot and all that's wildly favorable because you metabolize, you produce CO2 and then your body takes things and intricately makes gigantic molecules that are very unlikely to occur spontaneously but they can only happen as long as you find something to eat. They won't happen if you don't. Cannot. Okay, we'll stop there and we'll pick this up next time.
UCI Chem 1B General Chemistry (Spring 2012) Lec 14. General Chemistry Intermolecular Forces -- Corrections, Midterm Postmorterm, Free Energy, and Equilibrium -- Instructor: A.J. Shaka. Ph.D. Description: UCI Chem 1B is the second quarter of General Chemistry and covers the following topics: properties of gases, liquids, solids; changes of state; properties of solutions; stoichiometry; thermochemistry; and thermodynamics.
10.5446/19462 (DOI)
Dr. Okay, here's friends. Today we are going to start with you on the material. And for the next week, we are special people finally. And that means, of course, you are going to show all the educated representatives how great the person you are. Time to get those names, right? But let me give you some information about our exam that may be helpful. So first, this class is evaluated. Every class that does the research is evaluated through this system. I think you have a couple of invitations to fill out the questionnaire. It's rather long, I mean some of them. But it's actually very useful and these evaluations are taken quite seriously. In fact, every time my performance is evaluated by my department chair, we have all these stats, all the comments that are made by students. And this course, and it doesn't look good, it's kind of a smacky. So it's a serious thought, it's not something that should be taken lightly. So fill out your impression, if you like it or don't like it, you can just fill out what you thought and your experience was. Okay, in addition, next week Laura, one of the TAs, has kind of generously offered to do a review session. Next, we, of course, are now official classes, so this is an extra review session in this auditorium, thanks for this place. It's at seven o'clock on December 10th, so she will be at your service to ask you questions, just like you film at work, to do it again. Unfortunately, on Monday I'm unable to be here, I have a very important engagement in Rochka Line and Tooth University, I can't never do it myself, that's for Laura, just stepping in and she's having a whole class event. Alright, so December 14th, it's on a Friday, it starts at 1.30. Like I said, the exam will be two hours in total, so that's much longer than the mid-furnace, and that means there's a little bit more breathing space for the protein question, and you can withhold your answers probably several times, and make sure you, you know, you get to do as best possible performance on this exam. So, while I said the more information, again, we have allocated seating, so keep an eye on the website, the class website, all the information will be there, when you post it. The practice mid-term is already been posted by the way, so you can already start looking at that. Yes? The practice exam has been posted. I just said that, and you can just go there and look, and you get an idea of how long the exam will be, what kind of questions you may expect. As I said, it's going to be slightly different, but this is a very good impression of the level of difficulty, the length of the exam. Things to bring, as usual, an index card, your calculator, cell phones, we don't like so much, so leave them in your bag, turn them off. Can we get two of these cards or two of these? Oh, very good question, people. How many index cards can you use? The answer is uno. Okay. And that is the same as before. So, I'm not, this is not because the information is here, we have two cards, one card. Okay. So, you can use that wisely. Some people write very beautifully with, you know, fine liners, they do a great job. While people just print it out on a special printer, they also do a great job. That's fine, okay? You don't have multiple liners, it's not open. That's not a lie. Okay. This is the list of topics. There's nothing new about this, I'm just going to do it for formalities sake. Okay. Everything we have talked about is going to be on final time, it's truly a cumulative kind of a Xen. There are basically a facility in Hyde Force in its entirety. And these are the things that we talked about. Basically, if you like the book as a main source, it runs from chapter one to chapter four. Okay. That includes the following topics. Dealing with numbers. Okay. SIGFIX, units, prefixes and so forth. Dealing with numbers, writing numbers in scientific notation is part of this class. So, we should do that on the exam. Even if it's not explicitly stated, we should do that because it's part of this exam. Unit conversions are ultimately important, converting one unit into another unit. Seven meters into meters, but also density into mass, or, for instance, inches into kilometers. Those kind of concerns we have had many times over. And be sure to be able to do that on the exam. Adam is an isotopes. We talked about the basic architecture of an atom, isotopes, ions and so forth. And we should know something about the orbital and where the electrons are. Remember, how many electrons a certain atom has. How many protons, how many neutrons, because the basic architecture of an atom is something that's part of this exam. As is, naming these atoms, making molecules from them, and naming their ions probably. Knowing the charges of the ions, and knowing the difference between a polyethylene and anion, and an elemental anion, for instance. Then, we started to do some calculations with molecules, atoms and ions. Namely, we started to determine the molar mass of these guys, and mass percentages of elements in compounds. These calculations are part of the final. Then, we looked at chemical reactions. So we have molecules that are actually engaging into a chemical interaction, and there are reagents and products. And we should be able to balance such a reaction, and come up with the right stoichiometry. Why is the stoichiometry so important? Because we have to be able to determine mole ratios between things. Mole ratios can be used to convert one type of compound into another type of compound. It turns out, how many of you have? But we need to be able to do the mole ratios properly, to store chemical reactions, and give you the mole ratios. Molarity, and again, stoichiometry and solution. We have done that, we look at many compounds, and it dissolves in water. And then, react in a solution. Molearity is an expression of concentration, and along with it, we should be able to calculate, for instance, how many ions of a particular kind are in a solution. If I throw a luminous chloride into a part of water, you should be able to calculate the number of chlorine ions in it. If you dilute it, put a normal linear in there, you should be able to calculate the number of chlorine ions again. For calculating the concentration, those are very standard calculations that we've done. It's part of the problem. And then finally, three types of reactions that we've wrestled with, precipitation reactions, acid-base reactions, and redox reactions, as examples of very important chemical reactions. There are more types of chemical reactions, but these are three main ones. We should be familiar with, dealing with, the stoichiometry, being comfortable with the naming of compounds, but setting off for a successful 10-1-a series after this one. Okay. Now, I'm going to say a few more words in details about exam-taking, and then I'm going to say a few more words about redox, just to wrap that up. Here's a kind of a snapshot of an exam. Two years ago, there's a question about monium and terms of molarity. We're not going to look exactly at how this is answered. I'm going to tell you that, show you work, because we are creating your work. Okay. In this particular question, you're asked to calculate the volume of a solution, and there's some details to show you. But you have to do the first thing, always have to do with the term of how many moles of the stock do I have. Always, you want to know how many moles you have. If you want to know the number of moles, you can easily calculate the degree of grams, or the molarity, so that's the first step. You have to determine the number of moles. Check. That check means, if you're on the right way, that means you get points. Okay. Then, you have the number of moles, you have to do something correct with it. Okay. You have to convert out, in this case, to volume, the molarity is given, is a ratio. Then, the definition of molarity is, number of moles or volume. That means, if the volume is unknown, and the amount you are given, you calculate the volume, that's exactly what you have to do here. And that's the second check. If you know how to do that, you get points. In other words, you get points where the seps, for instance, 5 and 5, total of 10 points. The final answer, actually, is not even the most important. Okay. So, even if it's completely wrong, you still get points where doing this correctly, the methodology is very methodology. Okay. So, a lot of time for us to do that, because we think it's very important. Okay. So, we go through all the calculations, all you guys, three monotheism exams, we go through all the questions and see if there's something correct in there. The better, the more correct we will get. If you want to help us, this will help you to get more points, be clear about what you calculate and what steps you get. If you can write it down like this, what brings in this example, where I say exactly what I'm trying to do in each step, I'm going to calculate the number of moles, near and so forth, conversion to gram, I'm going to just explicitly write out what I did, then the grade, you can see, oh, look, this is very nice. One, two, three, four steps, beautifully laid out, maybe a little mistake here, but at least the person knows what he or she is doing. This greatly helps, it's great, and helps you get more points. Because if this is all messy and jumbled up, we have a very hard time giving you partial credit. So, check, check, check, we can give you more points. That's the bottom line. It's completely fine to do this first on the user blank page, first write out the way to think the answer should be, and then reproduce the answer neatly and nicely with the correct steps in the blank that we're actually working on. Just one tip, you don't have to do this, I'm just telling you, it's an option that makes life a lot easier for us. Okie dokie, keep it in mind, I'm going to wrap up the topic of redox very briefly by the following, you know, we know what redox reactions are by now, redox reactions are reactions where there's an oxidation step and a reduction step. Something is losing electrons, something is gaining electrons. Here's an example, in this particular case, I can split this into half reactions, namely, the iron is losing electrons, so that's an oxidation step. And the copper here is gaining electrons, so that is the reduction step. So I can write this, you never know what the phrase is in the following, right, forget about this sulfate, it's a spectator anion, it doesn't do anything, it doesn't rotate the anion, what so ever, everything is achely, so I can just get rid of it, and just write this. It's very easy to see in this case that, look, this guy is changing to 2+, this 2 plus copper is changing it to solar copper, which has an oxidation state zero. In other words, this is the reduction step, copper, and that is the oxidation step, both each state plays at the same time. So you can nicely see in this way of writing that the electrons lost by the iron have been eaten up by copper. Effectively, the only thing that happened here is that two electrons lost by iron have gone to copper. So there's this whole review this week, okay, Friday, as usual, we'll have a talk, it's about the reaction in all the conditions that we have considered, namely just normal reaction, reaction in solution, two flavors, acidic and basic conditions. So here are a couple of settling questions that have come up through an office hours, and I'd like to just quickly go over, hopefully it will clarify a few things. So I'm just going to see if we can get this thing up. That's a challenge. Small screen up, down. How do we get this thing to work? Okay. So let's look at the first one, because something must stay slightly differently than we have talked about in the last. And so, you should know that. So the first one is O2 and then 4 copper and then copper oxide. So you see, first of all, what settling doesn't do so nicely, which I really don't like, is there's no physical states, okay? That's not nice. Don't do the same thing on the exam. We have to write physical states, because actually, this is something completely insurmountable in settling, but we really don't know. So, in this case, what they want to do in the first equation is to write half an answer. And the problem is, copper oxide, this thing actually is a solid, and we have said, it implies that you should keep it as a solid. But settling doesn't stick to regularity. So what they say, fine, consider this as an ionic compound, and in fact, I have two ions, namely this thing is oxygen, oxide, always 2 minus. And this copper, because this is 2 minus, the 2 of them, must be copper plus. In other words, this is copper 1, oxidation state 1, this is oxide. Standard oxide is always oxidation state 2 minus. Okay, so now I can write a half reaction, because we really have to do it in this case, oxygen, O2 turns into O2 minus. And copper, which was oxygenation in zero, turns into copper plus. And they want you to balance these two gas, relative to one another. So we can see which one is the oxidation which is the reduction. This, in fact, is the reduction step, because this is zero, this is 2 minus, so it becomes more negative. It has taken up electrons, and this is the reduction step, this is the oxidation step. Indeed, this one is losing electron. So some electron has to appear here, and some electron has to appear there. So to that, I have two oxygen here, one here, so I need to put a 2 there, to balance the oxygen. So there's no need to put water there, there's already oxygen there. It's already oxygen. You just have to balance out the oxygen, then I can do it, so I have four charges there. In total, 4 minus, that means I have to balance that out. So in this case, I have to add four electrons to that side. Four minus on each side. This is the reduction step. The tie is the reduction step, it should appear on this side. Copper, the elements are already balanced, the charges are not. I have to add an electron here. So that's it. The only thing I have to do now is to make sure that the balance is balanced to one another, except that it wants to do that. You can do that by putting a 4 there, a 4 there, and a 4 there. Four electrons in each state, and this is the final result. That's the second one, funny one. Funny, funny, funny one, and not something you can expect on the midterm, I saw it on the final. So it's very much an exception, but I just want to show you so that you don't get stuck on the whole thing. The question is, if you balance this equation, okay, plus copper again, yeah, copper again, 2 plus, and it generates S4O6 to minus plus CU plus. Okay, so what I'm going to do, I'm going to split this again in two steps. I'm going to write down copper to plus, and then I'm going to copper plus, oh, this one is taken up an electron. So an electron plus this gives me that. This is the reduction step. That means the other guy is the oxidation step. Let's just put it down. Now this is indeed an oxidation step, but there's something very funny going on with this particular compound. If you try to find the oxidation state of sulfur, you are in for a big surprise. The oxidation state of the sulfur is 2.5. That doesn't make any sense. It doesn't make any sense because it's a very particular compound where there's four different solvers actually in different roles in different oxidation states. So this goes way beyond what we should know at this point, and it's also not relevant for our discussion. So I'm going to tell you what you should focus on with these kind of questions. You balance the elements. You can do that quite easily, but according to today. So now I have four solvers, six oxygens, that's the same as here, but in doing so I haven't really balanced the charges because 2 times minus 2 is minus 4. I have minus 2 here, so I need to add 2 more there. So now it's balanced. This is the oxidation reaction. It is indeed an oxidation ad reaction because I'm generating an electron plus. To balance the balance from one another, I have to multiply this whole thing by 2. 2, 2, 2. And now I can add them up. And the final solution, I can put it in here. 2, 2, 2, and that's it. That's the answer for that. Now to the final one, 2. Why not? I'd like to do this also because I'm going to show you that even though these pressures may seem laborious, if you know your stop, you can just simply write, as if you write a letter to your mom. Okay? And in that kind of case, you can solve this problem. It is straightforward adaptation of the rules of your dealt. So here this is again for magnetase, NaO, that is only going to be the RCI. So I'm going to write down for magnetase, it's changing into 2 plus. Quickly look at the oxidation states here. This is 2 plus evidently. This whole thing has to be minus 4 times minus 2 is minus 8. It's nothing to the 7. Okay? If you don't know how to do that, teach yourself how to do it. We have done it a lot of times, it's essential you are able to determine the oxidation states of this state. Namely, oxidation states that all these guys added should add up to minus 1. This is minus 2, the store of them is minus 8 plus 7 equal to minus 1. This must be plus 7. It should take you a lot of time. Later on, the algebra should take you about 10 or 15 seconds to figure it out. You don't lose time on that. So I'm going to balance this equation. What do I have to do? It happens in the city of Riga, let's say. O4, I have to add 4 waters. But I have added also 8. H must, if I do that. So I put it on the other side. Okay? And now, I have balanced all the elements, but I've not balanced the charges. I can tell you what the charges should be. I don't even have to charge the little side. I can tell you that since this is 2 plus and this is 7 plus, it needs 5 electrons. Right? It has to be 5 electrons on this side. Because it's got the 7 plus and the 2 plus. That's a check, but I can also do it like this. The whole total charge on this side is 2 plus. The total charge on this side is 8 plus. Okay? Minus 1 is 7 plus. And I need to get to 2, so I need to subtract 5. That's exactly these 5. So either way, it doesn't matter when I get there, but do this consistently. Correct. Okay, now the second one. So this is the reduction because it eats electrons. This guy moves into N of 3 minus. What's going on here? Let's look at the oscillations. This takes very quick. The whole thing is minus 3 oscillations, minus 6, with numbers plus 5. What is going on here? This thing here is the nitride, non-A-on, okay? And H-noubles X. So this whole thing here is oscillations, say, as charge minus 1. Oxidation state minus 2 times 2 is minus 4, plus 3 is my ionic energy. This is plus 3. Oxidation state of the nitride is changing here by 2. By 2. Okay? So I know 2-in-nitrons have to material here. I can already tell you that without looking at anything else. So let's see if that actually works out. First of all, there's two oxygens here. Three there, so I can add water here to balance the oxygen. The dual-cell we can use two extra hydrogen. There's already one here. There's three in total. There's plus 3 and plus. Let's look at the charges. Did I add up correctly? No charge on this side. Okay? No charge on this side. At least it has to be no charge on this side. So I have a charge minus 1, 2 electrons, minus 3, 3 plus, correct. Right? So the charge is balance of element. Now I have two reactions. This thing has 5, this thing has 2, so this falls in reaction, multiplied by 2, this whole reaction, multiplied by 5. And then you can add them up. That's it. So you can do that for yourself. And then cross out the H pluses and cross out the water. Okay, so that's just a little detour. But you see, you can just write this at waters, at H plus, balance with electrons, and this can be done relatively quick. Okay? And doing this several times, like doing the homework, is really helpful in getting comfortable with these kind of questions. Typically people do pretty well on redox on the final. So I'm pretty confident you guys will step it up. Okay. Let's rewind and go back at the very beginning. When we talk about dealing with numbers, dealing with units, one of these things is writing numbers correctly. Significance figures is the way of writing numbers correctly. And we should do that. We should just do that. So if you do that, make sure you determine the multiplication division and the division of the subtraction. They have different rules. Occupation division says you have to give the number that you are calculating the same number as the least precise number in the calculation. But that rule is different if you add and subtract, because in that case the rule holds that your answer should have the same number of decimal places as the least precise measurement in the calculation for the number with the least amount of decimal places dictates how much you have to be answered. So let me quickly give you an example of how that plays out in practice. Let's look at the following. Can't play the math of, let me put it easier here, 0.643. Well if you do that, if you go into the figure of table and you look at the molar mass of the prism and you find 24.305. This number comes from the figure of table and has five different figures. This is not the limiting factor in the calculation. If that's five, this one has three. So the final answer is that this is a multiplication. It should have also three significant figures. Okay, I think we can all do that and most of you have done that correctly on these maps. Now there's a situation where you may go and learn what to do and that happens when you first have a calculation that involves both multiplication and an addition of some sort. For instance, calculate the total mass of this much magnesium and this much chlorine. Okay, so what you have to do is, well I have an answer here already, 15.6. I do the same thing for chlorine. I take the number of moles, I multiply that by the molar mass of chlorine that is 35.453. It gives me this number here in grams. Okay, so that is the answer but this should be given in three significant figures. Because 1 to 3 is the least precise measurement in this particular question. And so the answer here is 1.61. I have two numbers, these two I have to add up. So what I do here is, at first, finish the number that I'm getting to and I have to add up. And I'm rounding this because this multiplication step is over now. And I have to make sure that when the number rules out of the multiplication it has to be the proper number that means something. It means something if it has an x-ray number, of certain figures. So what I'm doing, I'm taking this as the input in my addition. So I'm going to add this number to it. These are two results that I added up. As you can see, this is what your calculator says but you have to realize that this number here has one decimal place and hence you should also have this number in one decimal place. That is the rule for subtraction. So the answer is 70.3. It has three sig-picks, not because there are three sig-picks here but because the addition says that the final number needs to have one decimal place. So first complete the multiplication and division. Then add them up and use the rules for each operation. Okay, now let's do an example of the kind of calculation of the F-dial. Let's determine the mass percentage of each element in this particular formula, this particular molecule. So let's do that. Here's the chemical formula of this compound. From this formula I can calculate the molar mass. 14 times the molar mass of carbon, 12 times the molar mass of hydrogen and 3 times the molar mass of oxygen, which gives me the molar mass. What I do then is 14 times the molar mass of carbon divided by the total that I just calculated, times 100, and you get a percentage. What is the number of sig-picks in this answer? Well, this is the division in the multiplication, hence the least amount of sig-picks is determined in the answer and in this case that is this number right here. Okay, this one has four. This number comes from the table. If this number would have five, then this would be in five. You would have three places after a decimal point. Okay, three. But because this is in four, your answer is going to be in four sig-picks total. Hydrogen, let's say for instance that the table you get the information from has three sig-picks for this number, the molar mass of hydrogen. Then your answer should also be in three. Okay, if this was four, the answer was in four. And you get 5.307. There's one more digit in that case. Right? And the second oxygen in this case, there's four, that means the answer should be in four. But maybe this is an example that's not well-chosen. If this is four, then you get three places after the decimal point. Right? Three digits. Which is two here, two there. So it doesn't mean these calculations are independent of how many numbers. This can have three digits after a decimal point. This one can have two, this one can have two at the same time. So you don't have to kind of line them up for some kind of symmetry reason. That's not what they say. Sig-picks. Look at each calculation set. Yeah. Is 5.307 two sig-picks? No, this zero is after a decimal point. This is significant. Yeah. Conversions evolve. You have to be able to construct or write unit factors for converting one unit into something else. And one of the most, you know, I would say, involved calculations are calculations of volume. Because you have to multiply 90 to the power three. Okay? So for instance, here you have a box. Here's a calculator of volume. The box is given in inches, as you can see. But I have to give my answer in liters. Everything okay? So liters is decimier cubed. Right? So the definition of one liter equals one decimier cubed. So I have to go from this, an inch, into something that is method. And so you want to go from inches to centimeters and centimeters to decimiers and then decimier cubed. So what we can do this in a variety of ways, this is one way to do it. These are the two definitions that you need. The relation between inches and centimeters and the relation between liter and decimier cubed. So, for instance, I can convert each length separately. That's a possibility. This is 1.5 inch. I can convert it to centimeters by multiplying by this unit factor. One inch, 2.45 centimeters. This one goes on top, this one at the bottom. Inches is crossing out. I get my answer in centimeters. Everything between parentheses here now is in centimeters. And I can do it for each of the lengths that I multiply. For instance, width, length, and depth. I do it for each one. I do each of these types. I can do a conversion on separately. That's completely fine. I could also have done it in one step, of course. I could have multiplied these numbers and then have this conversion step raised to the power of three. It's exactly the same calculation. Because, effectively, that's what you do here. One conversion, two conversion, three, all multiplication signs. You basically raise this conversion to the power of three. That's exactly the same operation. Wherever you prefer a sign, these things are equivalent. The answer is 446 centimeters cubed. Why is it cubed? Well, we have one, two, three centimeters multiplied. It becomes centimeters cubed. The next thing I have to do is relate this to decimeters. I convert that by using the conversion between centimeters and decimeters. Ten centimeters to one decimeter. One decimeter equals ten centimeters. The centimeter goes at the bottom. This one goes on top because I go from centimeters to decimeters. And, raised to the power of three, so the unit factor also goes to the power of three. That means you can convert this number now to decimeter cubed. And, one decimeter cubed equals a liter. So, you can just multiply a decimeter cubed by liter. And, this is your final answer. I'm going to put that in two stick pegs. Because this one has two stick pegs, this one too. Okay? So, be familiar with this kind of calculation. If you are only exam and you see this volume conversion, and you have no idea what to do, then you haven't prepared a solution. Okay? Will we probably do something like this on final, if you want to see if you can do this? This is how it works. This is the one way you should solve the problem. Now, throughout this class we have used different formulas. The main formulas, formulas from which you can derive everything else are equal. Density equals mass over volume. Model mass equals mass, total mass, over number of moles. Okay? That's how you calculate the model of mass. Or, you can also say, you can circle this through, right? You can basically put this mole by a key, number of moles equals total mass if I go to the model mass. That's the same. And the definition of molarity, which is the number of moles, in the number of moles of the solute, in the leaders of the solution. Almost all calculations may use either this, this or this, in one way or another, four. Okay? So, typically, something is given, two rivals are given, you calculate a third. Be it mole, be it leader or molarity, it doesn't matter. These relations can be used and rotated through to calculate any of the missing variables. Right? This is really all the math that is doing it. It's either a division or multiplication. That's it. And your relations will tell you what it is. So, don't flip things. Again, there were lots of situations on the last lecture where people simply guessed that it was a multiplication or division. If you do that, you have 50% chance of doing it. Okay? Two ways to avoid it is to probably think about these relations and you're able to tell yourself, or you can tell yourself what you have to do. If that is enough, look at the units. The units should cross out properly. Okay? If they do not, you're probably going to say. So, look at that, that your approach definitely gives you. You know what to do, of course, no issue, but if you're stuck, you feel like, I know you're good at multiplying and dividing. You have to use logic. Never ever guess, because the chances are pretty high if you make the wrong guess. Okay? This is not how we do science. The science of mechanics, if you are in a hospital and everybody says, here this person has this many molecules of his drug and you have to guess when you have to multiply, and you divide, you are in big trouble. If you guess the wrong, patient may die. Okay? You don't want that on your resume. You'll never find a job again. Okay? So, these things are things you can avoid if I just stay in calm and there is all these things on logic that are not blurry lines. They are not that. The blurry lines are only in your head. Get rid of them. Okay? An example of a quick calculation. Could be anything. I have 1.2 liters of calcium sulfate solution and a certain concentration. Now, the question could be, for instance, calculate how many moles you have or how many grams of this stuff do you have? How many grams would dissolve in this solution? How do you do that? Well, I want to know how many moles. I know, liters times molarity equals moles. Boom, boom, boom. Okay, this is something I've done so many times that I've trusted this, okay. Letters times molarity equals moles. If you don't believe that, suddenly. Okay? So, maybe I say, oh, hold on a second. I don't believe that. And you can always say, look, molarity equals moles over volume. That's the unit of molarity. Molarity is moles over volume, m over l. L is here, l is at the bottom, l crosses out. Your unit is going to be moles. That's called dimensional analysis. You can use that unit trick to figure out if you're doing the right thing. Always check out if you have time. If you know the number of moles, you can do a simple multiplication with a molar mass to find the amount of grams of calcium sulfate that would dissolve in this particular solution to get to this concentration. The number of moles times the molar mass equals your answer in grams. If you don't forget about this, look at the units. Mol here, the unit of molar mass is the amount of mole. Mole crosses out and gets to the amount of grams. All right? Another one. 1.2 liter solution is a density. It's not given in molarity, but in density. Is that a reason to mean you're panicking? Because I'm used to working with molarity and suddenly the concentration is given in density. Kilograms over liters. No? It's not a reason to depend on what's around. I can do exactly the same calculation because I can calculate how many kilograms I have in solution. Another relation of density, liter and mass. So that means that if you multiply volume with density, you should get an answer in kilograms. The unit of density is kilograms per liter. So if you multiply this with liter, L will cross out and your answer is going to be kilograms. So here I have a measure of mass. Thank you very much. And this is a measure of mass. Can be related to how many moles of that stuff are in it, for instance. Okay? All right, so this is again molarity. It was an important quantity and we should be able to do quick calculations with it. This is a typical question. This is a question that was on the midterm and the last midterm. Okay? I would say probably 50% of people did this incorrectly. And you shouldn't do that again. Okay? So this is a very standard and very practical situation. You have a certain volume of solution, 1.2 liters, and you have to add a certain amount of sodium phosphate. Actually, sodium phosphate is the main ingredient of a very important buffer system that people use in the biology lab all the time. Okay? It's also a very important buffer in medical sciences. So this is not a ridiculous question. Five grams of that stuff dissolved in 1.5 liter. Your advisor wants to know what is the molarity of that? Okay? The molarity of sodium ions in 1.5. Okay, so you have to realize that, look, sodium phosphate is this. Phosphate is 3 minus. You need 3 Na plus to create a neutral compound. So Na3PO4, that is sodium phosphate. If you dissolve that in water, what you get is 3 sodium ions, 1 phosphate, and enough. In other words, for each one mole of this, you generate 3 moles of sodium. So, 5 grams divided by the molar mass of sodium phosphate, okay, gives you the number of moles of sodium phosphate. This is the amount of sodium phosphate in moles that has been dissolved in 1.2 liters. But it does not tell you what the concentration of sodium ions are. Yes. So, you can take this and divide it by liters, that gives you the molarity of sodium phosphate. But you have 3 moles of sodium ions for each one mole of the compound. So you have to multiply that by 3. That 3 should not come as a total mystery to you. Okay? This is not a mystery. There's no other way this can be. Because there's 3 sodium ions for one mole of the compound. You have to multiply that by 3. You get 3 times as much sodium as you have this, as you have sodium phosphate. So, the answer is in this case 7.2 times 7 to the minus 2. Give your answer to the correct number of symphics, preferably in scientific notation, and with a unit. Please, add a unit so we know what you are talking about. Molts per liter is basically a unit for molarity. So you have to put a big end there. Okay. 2 more minutes. Naming compounds is something we have to be able to do. Here's one. What is that? A rillium sulfide. Yep. By the way, rillium is 2 plus. Sulfide is always 2 minus. Good to know. What is this? Phosphorous tribromide. Tribromide, because this is a cobalt compound, a molecular compound. This is not a magnetic compound. You have to tell the reader exactly how many anion's you have. In this case. How about this? Ammonium hydroxide. Yes, ammonium hydroxide. This is the ammonium cation. If the H plus splits up, you get NH3, which is a molecule, that's the ammonium molecule. The ammonium molecule we have seen many times. Ammonium is a molecule that you add a proton to it, becomes ammonium. N02, what is that? Nitrogen dioxide. Nitrogen dioxide is not nitrite. Why not? Because there is no minus there. Polyatomic anions always have their charges indicated. Always. Some people ask me, if I write down the charge of the anions, the answer is, yes! Is that clear? Yes! Always add the charge, the charge of the ion. If you don't do that, you just write down something else. For instance, if you forget the, if this was nitrite, you forget the charge, it becomes nitrogen dioxide. This is completely different. What is this? Nitrogen, nitride, sodium nitride, because this is an anion that has three negative charges, right? Let's do one more. What's that? Aluminum oxide. Yes, is aluminum oxide, do I have to say, do I have to stipulate oxidation state of aluminum? No, you don't. You don't. Because aluminum is a type one metal, not a type two. It only has one oxidation state, which is 3 plus ammonium oxide. All right, see you on Friday for the second session of the review.
UCI Chem 1P is a preparation go General Chemistry that covers: units of measurement, dimensional analysis, significant figures; elementary concepts of volume, mass, force, pressure, energy, density, temperature, heat, work; fundamentals of atomic and molecular structure; the mole concept, stoichiometry; properties of the states of matter; gas laws; solutions concentrations. Course may be offered online. Slides: 01:42- Evaluation 08:37- Topics Covered in the Exam 09:53- Examples-Show your work 12:01- Redox 13:52- Sapling hints 27:02- Calculations and Examples (Significant Figures) 31:20- Significant Figures, More Examples 32:10- Conversions 36:07- Math: 39:50- Quick Calculations 41:30- Molar Mass and Molarity
10.5446/19461 (DOI)
All right, friends. This is the final week of this quarter. Next week is going to be final week of the last opportunity for the last bits of studying before we go back to the auditorium to do another class. Today I'm going to cover the last bit of information of this course, and that means that Wednesday's lecture and Friday's lecture are review sessions in class review sessions, in which I will go through again a couple of points of interest, point out some general mistakes people made, and hopefully getting off the speed for the final. The final is going to be on December 14th. It's a two-hour exam. The exam is going to be a little bit longer, but not twice as long. So less than twice as long, that means we have relatively much more time for the final, and just some people were asking questions about this, about time issues. There is no time issue on the final. There's plenty and plenty of time to finish all the questions. Most people hand in their exam before time is up. The auditorium will probably be half empty by the time you call off the exam. Okay, so we had a midterm last Friday, and that was an interesting experience. So let me show you how well we did all together. Let's see if this works. Oops, there we go. This is the performance. It's really an interesting, it's really all over the map, so it's a huge distribution. The mean is billion in middle, 52. Last year it was 56. This year it was 52, so it's somewhat similar, a little bit lower. The exam was a little shorter this year, about the last years. The distribution is 23, that basically means the huge spread. 23 simply means how broad the distribution is. Interestingly also, it has all these spikes, and I have no idea where they come from. I can't explain that. It's very untypical. Usually it's a rather smooth distribution, this one. There's all kinds of peaks, and the guy did something very amazing from that perspective. This performance is just incredible. So people had lower scores in this area here. People had high scores, one person 100%, everything like that. Very nice, congratulations. Nice. The person maybe didn't even meet here. The person probably doesn't need any doctor. Most of the people are here in the middle. If you are in this segment, so I would say below 30, then there is reason for really focusing very specifically on things that you want to improve on. Because if you are in this area, there's really no, I would say, if you have two midterms, or still in this area, that tells you a story, that you are not fully up to speed to ace the exam, or to put it like that. It doesn't mean that you are in your lost case. Absolutely not. Midterms are meant to practice, get used to the material, get up to speed, see for yourself where are the problems that you have, and what are the things you have to improve on. That is what the midterms are for. The final is really the place where you have to show how you have to digest and process the information with the course. It's almost 5% of your grade. The final is really where it's at. Midterms are preparation for the final. So we didn't do well on the midterm. It doesn't mean you have to plunk the class. Absolutely not. It means you just have to focus on those things and it didn't go so well. Sometimes not doing a midterm so well is actually not a bad thing, because it tells you precisely where are the issues that you focus on. I'll say a few words about that in a few moments. There's lots of comments about the time issue in the exam. We have 15 minutes in principle, typically the last. We have to get started and not do the exam with one chair because there are less than 10 people here. So we don't occupy all seats. We have to learn about on the spot, take time, try to do as fast as we can. So we can't do this for 15 minutes. I was trying to go a little over time. It's a 52 and the writing has to kind of basically end in their sense. So we have to do a little bit of flexibility there. But basically in less than 15 minutes you have to show us what you can do. Now, it is fully understood and I know that very well that it is sometimes hard to complete all the questions. We're all in the same situation. Everybody is in the same situation. The time constraint is annoying but it is somewhat hard doing an exam. There's always a fixed time of exams and it turns me into a different. We have to test a bunch of topics, concepts for me to see where do we go about that when you understand it. So if I just put one or two questions on the exam, you may be able to finish them. But what if you mess one up completely, you still have 50 points. Now I've started out with more questions and you have a chance to show us what kind of questions you can do well. You get full points for that because you can demonstrate that. And then the questions you don't go so well, you use full points on them. Also because you probably don't have time to finish them. So shorter exams, when you have necessarily better imperfections, you have seen that shorter exams actually lead to lower grades. Because if you mess up a question, it's going to cost you dear on shorter exams. Longer exams have that advantage. You can spread out your capabilities over more seconds on the exam. So please understand that. Secondarily, like I said, the time is not an important factor. These calculations may be new to you or maybe you've done it before. But you have to be able to do them in a certain amount of time. We don't have two hours or three hours for an exam. And in practice, if you are in the lab and your advisor asks you to make a solution of as many chlorine atoms in solution, certain malaria, you should be able to do that in a couple of minutes. It shouldn't take you 10 or 15 minutes to figure out how many of these chlorine atoms are in there. You just try to write it out and just be able to quickly translate that. This is a skill. You can have those skills. So time is a quantifier. It shouldn't take you an hour to determine what the concentration of chlorine atoms are. In a limited time, it's a chlorine solution. Let me give you two quick snapshots of the exam that we had last Friday. And just to highlight a couple of points that went wrong, about 50% of the time. This is the first question. Question one. A sample here happens to be version B. There is a molecule here, like a corona, and it says it contains four grams of carbon. It says it contains four grams of carbon. You've seen those questions before. You have this specimen here that contains X grams of oxygen, of the element of oxygen, of the element of carbon. The question here is, question B in this case, how many moles of this stock do you have? More than half of you do this. Four grams divided by the volume of this. Most people actually calculate this correctly, which is good. Is this many moles? Unfortunately, that is not what this question is telling you to do. The question, we can just take a little time. Don't think it's only too straightforward. We have had questions like this where an element is being specified. You know how much carbon, how much C there is, but you don't know exactly how much of the total compound there is. So you have to relate the amount of C to the amount of the total compound. This is not correct. You can divide four grams by the molar mass of this, because that would imply you have four grams of the compound. You have four grams of carbon, which is part of the compound. So it's different. This is not correct. Unfortunately, this is just the wrong amount of carbon. So what you have to do, and this is something you can do quick, you don't have to think about this for a long time. The nice thing about this is that four grams of carbon, I want to know immediately how many moles of carbon do I have. Boom, there it is. Four divided by twelve. Eighteen out of the moles of carbon. Well, eight moles of carbon per amount of compound. How much? Well, I have four carbons per compound, one out of four. That is the amount of mole of the compound times the mole. Sorry, I have no mass. I have to calculate the many moles, how many moles. So this is directly the answer. From carbon, two moles of the compound. A factor of one out of four. That's it. So this is an example where you have to calculate each question. You process that, you think, ah, carbon, grams, you never want to do anything in grams. Immediately going to moles. How many moles of that stuff do you have? Always got two moles. I have this many moles. This many moles of carbon means I have four times less moles of this stuff because it contains four carbons per compound unit. So the only thing I have to do is to divide this by four, and I have the number of moles. This is the final answer. By the way, again, if you are alert, please write this in the correct number of significant figures and in scientific notation, which was actually on the first page, okay, as you said. Write this just in the scientific notation and significant figures at all times, okay? Even if it is not asked specifically in the question to do it like that, do it anyway, because this is always correct. Scientific notation and the regular significant figures is something that's good practice we should stick to. If you stray away from that practice, you may have a chance to do it wrong. Okay, another example. This is the last question, question five. A particular reaction doesn't matter which one. Look. In this case, it is the following, where we generate sulfur dioxide. Question eight says, I have formed five grams of sulfur dioxide. Okay, I also happen to have 1.5 moles of oxygen, which is one of the reagents. The question is, how many grams of one of the reagents do I have? Lead to sulfide. Lead to sulfide is right here, okay? So I have to know how much of this do I need to make five grams of that. Now, usually, in many kind of situations, what you've done is the starting amounts are given, okay? And so you've got that how many moles are given like this, how many moles are given like that, and then you can determine how many moles the product is worth. This question says, okay, I can already determine how much product I formed because it's given. The amount of product is already there. How much of the ingredient does it need to be to enable you to generate this much of sulfur dioxide? In other words, I have to know how many moles of sulfur dioxide are there, and how many moles of lead sulfide I need to make that, okay? So the first thing I do, always take this, convert this from grams to moles. You divide it by the molar mass. So this here is the number of moles of sulfur dioxide. The only thing I have to do is to convert the number of moles of sulfur dioxide to the number of moles of the reagent needed to generate that product. So I just have to look at the mole ratio, which happens to be 2 to 2, which is 12 to 1. In other words, this number here is the number of moles of sulfur dioxide equal to the number of moles of lead sulfide, okay? So it is a 2 here, 2 there. You can immediately see that for any given number of moles of this, you need the same amount of moles of lead to sulfide. Then you multiply that number of moles. This is number of moles of lead to sulfide by the molar mass of lead to sulfide, which is given here, and that's your answer. 18.7 in sign representation would look like this, okay? Sorry, it should be a 1. Apologies, this should be a 1. Alright, cool. So in other words, this is basically one division. This is really 1 to 1, and you can see it immediately, okay? And this is really just 1, and this is just multiplying by the molar mass. This is a calculation that you can do in principle in two or three minutes, right? This is reading. This many-inch sulfur dioxide right there, I can compare the lead-linked moles, another number of moles of this, it means that no number of moles needed to make that, right here. Another number of moles, another number of marks, right? Boom, boom, boom, boom. Three steps, but I should be able to hash out somewhat quickly, right? Of course, it takes a little while to compare those two questions in a couple of minutes, but I mean, you shouldn't stare yourself blind on what the situation is here. It's no different from anything we've done, right? The same principle, you convert one quantity into another quantity. Okay, so keep those things in mind. I mean, another thing that I pointed out on the PIATSA is that the practice exam tells you quite nicely what kind of questions are going through the exam, also how long the exam is going to be, and what the difficulty of the exam is, okay? This is a great amount of information for you to gauge yourself where you are at. If it takes you 24 hours of the practice exam, you probably are not in your check yet, right? You should be able to solve the practice exam in about 50 minutes, right? And so that means that reading the question and translating that question directly into things like this becomes like a second language to you, right? You have to learn to speak the chemical language here. The chemical language that you are trying to convert should come somewhat quickly after practicing all the time. Alright, so keep that in mind. You will get a practice final, okay, which I will post at the end of this week. Don't do the final in the very beginning. Don't do this practice final in the very beginning. Or study only off this practice exam because that is not the right recipe. You want to use a final maybe in the last few days to test yourself where you are at. This is also why I don't give any answers. Because if I don't give answers, you will go like, oh, I see you. Oh, I see you. You don't test yourself. You don't test yourself. Seriously, I follow that, okay? You would really consider the practice midterm or the practice final in this phase as an exam to see where you are at. How do we use this all these practices? It's too hard. You may have the same situation as the exam. Right? Or the actual exam. So take advantage of these practices, okay? You know, in general, this class is a primer for KMLA, KMLD, KMLC. You get used to the college style of education that we have, right? And you get used to doing exams with huge auditoriums where you cramp up against your neighbor, okay? But it's limited time and you have to show in a short amount of time what you can do. This is how we do the massive classes. This is the way we do it. So this is where you get the opportunity to get used to it. I don't enjoy punishing you for anything. I hate it. I want you guys to successfully pass this class, okay? That's my goal. My goal is to pass as many people as possible. So I hope that I give you all the tools for you to do that. These tests can only help you to point at those things that need attention from you. So consider these tests in that context, okay? The only thing you should take right from this class, don't focus on your grade right now. Forget about the grade. Focus on the material. Seriously, I mean that. Focus on the material, manage the material, process that, be able to do well, and the grade will follow that performance. Question? I said focus on the grade. Say again? I'm talking about the grade. Yes. I said don't focus on the grade. I'm talking about the grade. Yeah. I'm talking about the grade. Okay, so this is, okay, so let me show you the, this review here. 52. Last final, last midterm is about 55, 56, I don't know. And so the average is about 50, whatever, 50.5, 55. The final typically is done not better, high grades, okay? Because people really step up and it do pretty well, typically. So the average is going to shift up to typically about 65%. That's going to be the mean. The mean is going to determine the average grade. The average grade is between a B-minus and a C-plus, depending on which grade it involves, okay? It depends on kind of distribution. So sometimes it's a B-minus, sometimes whatever. So that determines basically your grade. So if you are at the mean, you can expect basically a B-minus. If you are significantly above the mean, you're going to be higher than a B-minus. Again, depends on distribution. If you are consistently in the 90 to 80% off, you are a material, okay? Definitely a material. If you are between 80 and 60 B-ish, okay? And then below 60 C-ish. That's kind of like a rough scale. But again, I hope you guys don't worry about, I know how hard it is. It's all about grade, it's all about the way you're related to something else. Please don't make it your main objective. Your objective is try to do this material well. Your grade truly will follow your performance and how well you know the material. Even though it doesn't feel like that maybe right now, you will see in the end when your homework and your final is going to be added with your current standard, you will be at a higher percent of, I can promise you that, okay? So all that matters is just to do as good as you can on the final design. Okay, let's now move on because I still have to do it there with the problem, okay? Here we go. Redox, who remembers that? Redox. We talked about it before in the midterm, okay? You were actually working on balancing the redoxing equations. The last thing we did, we were balancing redoxing equations in acidic solutions. Because solutions have a high concentration of H+. And we noticed, if you remember this, that the H+, and the H2O, the water molecules, participate in the reaction. In fact, we need these molecules to balance the redox reaction in solution. So in acidic solution, the H2O molecules and H+, are actually part of the reaction. Often times, not always, but often times they are. How are basic solutions? In basic solutions, there are no H+. So what we have is H2O and OH- can be apart. We'll have reactions and the total reaction. So we've done this already, and we'll do it again. But now we add the possibility that the reaction takes place in a basic chemical environment. On the basic solutions. Okay, so what we will do is, the same thing as we did before, we'll split the redox reactions in two parts, an oxidation step and a reduction step. And I'm trying to balance each of those steps. And then in the end, we'll just worry about the water molecules and OH-. But you will see. So, let me, I'm going to give you the recipe, and then we'll, you're going to apply this recipe to a problem. Okay, so what is the recipe? Let's say I have to balance the redox reaction on the basic conditions. What I do is, I use the same tools that I already applied last time. Use the half reaction method for acidic solutions to balance the equation. As if there were an excess of H+. Very strange, but this is how we're going to do it. Okay, so we just, we're exactly the same as before, in acidic solution. Okay, so that basically means that I end up probably with some H+. in my final equation. Now, evidently, H+. is kind of B in basic solutions. So what I do is, at the very end of my exercise, I am going to add enough OH- to get rid of those H+. Okay, so let's say on the reaction side, there are four H+. I'm going to add to them four OH-. And then I cancel them out because all the H+. become H2O. On the other side of the equation, you also add four OH-. So now it becomes basic. What I do is, I generate H2O on one of the sides because I combine OH- with H+. So I cancel out the H+, it's generated water. So I get one molecule, if there are one molecule on the other side already, I cancel them and roll it to one another. And then what I end up with is the final result. Lastly, you always want to make sure that your equation is balanced in two ways. First, number of elements need to be balanced. The number of elements needs to be balanced. And secondarily, the charges need to be balanced. You need to have the same amount of charge on the reaction side as on the products. Okay, so there are two checks that you would like to apply. And on the final, you actually will have time to do that check. Okay, so let's apply this recipe. Ensure that this recipe is exactly the same as we did before in the city solution, except at the very end, we had enough OH- to get rid of any flaws from the water and cross out the water if needed. So here's our reaction. It's a very nice one, not completely straightforward, but that's why I like to show you an example to show you the problem. So here we have a reaction of permanganate, anion, anion, permanganate as a charge of minus, plus sulfide anions. So two anions are reacting. There are, of course, cation in the solution as well. They're not giving you, because they don't do anything. They don't have any redox steps, necessarily. So they're not shown. So two anions. Then on the other side, I have MNS. This is manganese sulfide and sulfur sulfide. So this is an interesting situation. Why is it interesting? Because this sulfide anion, part of it is going to be converted into this and part of it is going to be converted into that. So the sulfide plays a double role. We'll see how to deal with it. It turns out it doesn't really matter. It may be confusing at first, but it's just five steps, and it rolls out just very nicely. So what I have to do is I just have to solve this thing as if it happened in acid, an acid solution, and the way we did that is to split this into oxidation and reduction half reactions. So let's see what is being oxidized and what is being reduced. Okay, the oxidation half reaction. Let's look what is being oxidized. Oxidation means, what does it mean again? You lose electrons, right? So the sulfur here has two minus, so it's negatively charged, and here it's zero, so clearly it has lost some of my electrons. That is an oxidation stuff. Okay? This manganese ion is changing as well, but as I will show in two seconds, it is changing in the opposite way. Because I can see this sulfide here has charged two minus, that means it has here two plus, so this manganese is two plus right there, here it has a higher oxidation state, because there's four oxygens, which are two minus. The oxidation state here is seven plus, two plus here, so this one, manganese, is going to be reduced. In other words, the oxidation half reaction is the sulfur, which is oxidized from two minus to oxidation state zero. And the reduction half reaction is this guy, this manganese, which is going to be from seven plus to two plus. Plus seven to plus two, okay? So this is how I write that down. Now, look at the following. I have to write this whole compound, okay? Including the oxygen, because this is one polyatomic anion. I kind of just split this off. This is one covenant link unit. This thing stays as it is. This is a polyatomic anion. It can't split into separate ions, okay? Some people did that actually, again, on the midterm. They split polyatomic anions into separate pieces. You can't do that. You can't do that. It doesn't come back. An anion is a stable species that is charged. It can't separate into elements, as if each element were an ion. Okay? So this stays as one unit. Why is this sulfur here still appearing? Nobody appeared in the oxidation half reaction. I need it, because it appears on the product side. And this is a solid, which is one unit that I can't split. Okay? So this sulfur appears here. I have to add a source for sulfur on the other side. So it's right here. I have to list this one more time. The confusing part is, I already listed the sulfur here. I have to list it again. But that's fine. That's fine. Okay? That is not, that is not necessarily against the rules. I can have just simply two here. One sulfur is going to associate with these meganese, and the other sulfur is going to be there. So I can easily solve that problem stoichiomagnetic. And it will roll out accordingly. Okay? So this is the reduction half reaction. Oh, sorry. This is the oxidation half reaction, and this is the reduction half reaction. If you look at this reaction, this looks almost balanced, except for the chargers. This one, a far cry from being balanced. So I have to work on this one. Let's first look at the oxidation half reaction. Okay. So what I have to do is balance it both in terms of the elements as well as the charges. The oxidation set is already balanced in terms of the elements. That's easy. I only have to work for the charges. There's two minus here. There's a zero there. Evidently, I need to have two electrons on that side. And that is exactly what it should have, because in the oxidation set, electrons should appear as products. We generate these products. Okay? So this oxidation half reaction, I am very happy with, is basically balanced. Let's look at the reduction set, because the reduction set is the most complicated set for this problem. Okay, so here it is. Let's look at the oxidation states. This is minus two. Here, still minus two. Okay? Still minus two. Soap reaction associates with another compound is like oxidation. And its oxidation state is minus two. Magnet is two plus here, because sulfur must be minus two. This is something that we haven't explicitly touched on, and this is why I'm telling you right here, that the sulfur here, but associated in a younger compound like magnet and sulfide, is typically two minus. Life oxygen is two minus. Sulfur appears right below oxygen in the pre-artic. Okay? So, plus two here, two minus there, two minus there. You can see the sulfur is a spectator ion, spectator L in this equation. It doesn't do anything if you sit there. It doesn't change the oxidation state. The thing I see in the oxidation state is the manganese. It goes from plus seven to plus two. Why is it plus seven? Four oxygen times minus two, minus eight, already was one minus there. And you see the extra plus seven, like the manganese compound, with the charge minus one. Okay, so this is the setup. I have to balance firstly, number of elements. How did I do that? On this side, I need oxygen, because oxygen sits here, but not here. I have to add water molecules. How many? Four. Okay, so what's with that? Four water molecules need to be added, because I need to balance. The oxygen. Okay, by doing that, I created one problem, because I introduced a total of four times two, equaling eight protons. Eight ion-gain atoms. And I can solve that problem by just simply putting eight protons on that side. Okay, so now we check right carefully, one manganese here, one manganese there, balance, sulfur, one here, one there, balance, oxygen, four on each side, correct. And then finally, the hydrogen, also balance. Balance in terms of the elements, not balance in terms of the charges. So let's do that. On the product side, zero charge. The thing on the creative side, also zero charge. But it's not zero charge, right here. I have a two minus here, and eight plus right there, and another minus here. Okay, so minus minus, that is a total of three minus eight plus, that's a total of five plus that I need to compensate with five electrons. Okay, so balancing in charges required me to add five electrons to balance this five plus charge in total that these components really need to be compensated. So now I have that involved in elements, as well as in charges. Okay. Let's say this, and let's balance these two equations relative to one another. So let's do that. I see I have two electrons there, in the first reaction, half reaction, and five in the reduction half reaction. By the way, the reduction half reaction should have electrons on the reagent side, which is the case. So here's my handle on the fact that I'm doing things right. Okay, so this is looking good. I have two here, five there, they need to be the same. So I have to multiply the equations with the lowest multiplier to get the same amount of electrons. So I have to multiply this by five, and this by two. Okay, this whole thing by five, this whole thing by two, and then add up those two equations to get the final reaction in acid. I'm not done yet. Okay, so let's do that. I multiply it by five, so I have five solvers, ten electrons, ten electrons here. That's good, that's exactly what I wanted. These ten electrons will cross out, and then just one another. Okay? If you add this up, you find the following, ten electrons on the reagent side, ten electrons on the product side, seven solvers here, five solvers there, and so forth. So the first thing I'm going to do is to cross out these guys. Okay? Those two guys, I'm going to cross out. And then this is the final result. You have to write it over again, okay? Just crossing out the things and following them. So this is my final result. As if the reaction would proceed in acidic solutions. Okay, so sixteen protons, an awkward number, right? But that's fine. These numbers can be very strange. It doesn't have to be two or three or four. It could be sixteen. Sixteen, two, seven, two, eight, and five. Okay, so now I have to do the trick that if this is taking place in an acidic solution, I have to get rid of those H pluses. So what I have to do is I have to add to this side sixteen OH minuses, at the same time adding sixteen OH minuses to the product side. Okay? So there we go. Sixteen OH minuses to this side. These should officially have aqueous signs, okay? They come to cross out, so I just completely forgot to write them down. And on this side, also, sixteen OH minuses, they should have an aqueous sign associated. Okay, so what I have to do now, I combine this sixteen OH minuses, sixteen H pluses, how many motors? Yeah, they generate sixteen waters, right? So I'm going to cross this part out and replace this by sixteen waters. That's given over here. All right? The only thing that I change here is I put a six sixteen waters in here. And now, if you look carefully, if I have already some waters on the other side, and I do eight, then eight of these will cross out again sixteen of those. So in other words, subtract eight from sixteen and you'll left here with eight waters. Okay? Everything that appears double can be crossed out against the other side. So let me do that. I just cross out eight against the sixth sixteen. So what I left with is eight. Eight water, and now I'll put the phase there properly. It's liquid. Water is not aching, okay? Water is becoming part of the liquid inside. So water in the solution is always getting L as the phase. Aqueous for this guy, aqueous for all the anionic species. Magnesulfite and solute sulfur. And then this guy should also have aqueous sign, which it doesn't have. Here, I'm going to show you how. So you put an aqueous sign right here. So this is my final result. Final operation. Okay? Pretending everything happens in F in acid, then I cross out the H plus and the Gantt order. That's the only thing I have to do. Different. Okay? So, since I have still a time left, okay, let me check if everything is correct or not. I want to see if the charges and the elements are balanced. So there we go. Here's the reaction once again. This is my solution. Let's see if it fits. Let's count the number of elements. And let's start with hydrogen. Why not? 8 times 2, 16. 16 hydrogens. Right there is no hydrogens in these compounds. So 16, 16, that looks very nice. Sulfur. 7 here. 2 from the manganese sulfide. Manganese 2 sulfide, actually. Okay? Oxygenated states 2, which is a special hydra. Manganese 2 sulfide. And 5 from the solute sulfur. The total of 7 of solute sulfur. 7 stoichiometric solves here. 7 right here. Let's look at the oxygen. Oxygen has age from the water. And 2 times 4, also 8 here. So 16 total. And then from the hydroxide anions, I see indeed 16 oxygen atoms. Then it goes as well. And then finally, manganese has 2 here, 2 there. Seems to be fine in terms of the elements. What about the charges? Let's check that too. On this side, very easy. I have nothing here. 16 minus. So I need 16 minus. Let's see if I have the same here. This one is neutral. This is 2. That is minus 2. This is 7 times 2 is 14. 14 and 2 is 16. Indeed, 16 minus charges here, 16 minus charges there. Pretty convincing. This must be the right answer. This is how it works. So the tricky part about this example is, this is how I put it up. Look at the role of the sulfur. Plays a double role. That is a lot of fun. So don't get confused. Yes? How do you know what that's the case? How do you know what that's the case? In this case, it must be the case because the sulfur appears as a product of the oxidation step. It is 2 minus here. It is 0 here. That means it is being oxidized. That means it appears to be an oxidation happening. It also appeared in the reduction step because the product of the reduction step contains sulfur. So I have to add it. I cannot leave it out because then I don't list the full product. The full product needs a solver. If you say solid, I cannot just split up one of the elements just because I think it can be. It has to be there. But naming a solver, right here, that means I need a solver on the other side. I need to keep it. Just keep it on the reagent side. As a source. Now, that's what it oxidates in the hydrogens. We can add those by adding water and adding salts. But from a solver, you cannot say I'm not going to throw a solver at it. You have to say the solver is already there. Okay? So look at the generator. Look at the product. The product needs an element. Okay? On the reagent side. If the product also is being part of the one of the oxidation of the doctor's step, you have to list it there as well. And that's fine. You see that of these seven solvers, two partakes in this part and the other five are being oxidized. Okay? So if one of the seven solvers is in the equation, two are not oxidized and five are. Right? So that's what the equation is. So be aware. Does that make sense? Anybody else? Okay. Who likes this? Nobody likes it. You'll see. Two weeks from now, you'll know. This is completely normal. This is really nice. Okay, folks. Never go on.
UCI Chem 1P is a preparation go General Chemistry that covers: units of measurement, dimensional analysis, significant figures; elementary concepts of volume, mass, force, pressure, energy, density, temperature, heat, work; fundamentals of atomic and molecular structure; the mole concept, stoichiometry; properties of the states of matter; gas laws; solutions concentrations. Course may be offered online. Slides: 00:07- Redox in Basic Solutions 02:51- Midterm Results 07:56- Midterm Woes 11:27- Midterm Woes, Slide 2 20:16- Redox Reactions in Solution 22:07- Balancing Redox (Basic) 24:40- Half-Reactions (Basic)
10.5446/19460 (DOI)
All right. He is unaware of the fact that there's a midterm Friday. You don't know? Guess what? There's a midterm. So today is a good day to walk through a couple of topics that will be on midterm. So I'll go through the eggs. You can ask questions. Not right through, of course. In addition, tonight is a new session organized by the peer tours of the Department of Chemistry. At 7 o'clock, we're going to call Room 101, so you are welcome to join that session. They have a review package online that they prepared. So they will talk about those questions and you can ask questions to them. So it's pretty useful. In addition, tomorrow night, at least Thursday night, there is another review session for those folks who really want to talk about this kind of stuff. There's an opportunity at 7 o'clock in Don Grand Park, 11-0-0. So that is probably the final review session that you can attend. And it's all there for you. So many, many opportunities for us to actually improve your skills. Okay, so what's the deal? Friday, we do a midterm. Where? Right here? What do you bring? Same things as before. A calculator and you can bring the e by 5 flash card. Okay? What we do not like is cell phones that go off. So, turning off, really do that because when they go off, it's just upwardly annoying. Alright, so what will be on the midterm? Basically, it's everything that's covered in Lectures 11-18. Let me quickly go through that. Mold and mass, that is something we talked about. Mass to scientists, talked about the mass to scientists and how to use it to determine the empirical form of reference. So empirical in the likelihood of formulas, you have to know what they are. The difference is between the two and how you can determine your empirical form of reference and your likelihood of formulas. Long-lead and perfect formulas. Now, balancing counter equations. Identity is a very important thing that we should be able to do to balance an equation. Because if you do stoichiometric calculations, we have to know the stoichiometric numbers and that comes from equation. So balancing equations is very important. Limiting reagents, something we talked about, that enables you to determine how much product you generate and also how much excess reagent you have left after the reaction. Equal solutions, which one do well and which one do not. Polarity, that is a measure of concentration, number of moles per volume of the solution. And then we talked about precipitation reaction, know where they are and understand the solubility table. But solubility table is very important. There's a lot of detail on that table. So you're welcome to put it on your index card. That's a typical thing that I would put on there. And then finally, acid-base reaction. The final topic we talked about in lecture 18. And it is part of the return. Okay, so this is the, these are the ingredients of the return. Not bad, not bad. Alright, so let me, let me go through a couple of these, these items. So we'll not go through all of these, but there's a couple of topics that I think are very relevant. So, the mole, you know what the mole is then, right? The mole is just a number. What number is it? This number. That's it. That's the definition of the mole. And we use it exactly the same way as if we used the word dozen times. The word dozen in calculations. It doesn't mean it's trouble, and mole means it's not. That's it. Nothing to be serious about. What is very convenient for us is that one mole of an atomic mass unit, so atomic mass unit, if you have one mole of that, you have one gram. Okay? And that enables us to do calculations of molar masses in terms of grams. For instance, one mole of any compound, let's take beta-carotene. You've never seen this, let me burn beta-carotene, but this is a thermo-lock, C40H56. Very strange numbers, doesn't matter. This is a real compound. You should be able to calculate the molar mass of this. Because 40 times this thing here, which is the molar mass of carbon, this is, if you have one mole of carbon, carbon contributes 12.01 gram. That's because of this relation right here. 56 times the molar mass of hydrogen, okay, that's this guy. You just have these contributions up to come to the molar mass. We've done it many times, and it's the worst of every particular compound. No matter how strange they look. So, whenever you see a strange compound, a double matter, you can calculate it, okay? All the elements are in here at table, and you should be able to determine the molar mass of each and every compound that is served to you. Okay, so then, once you know the molar mass, you can do a couple of conversions, which were very important to us. For instance, you can convert from moles to mass. If you know the amount of moles you have this relation here, you multiply with the molar mass, you get the amount in grams, and conversion can also be done from mass to moles. If you have a certain amount of material, give it grams, amount of grams divided by the molar mass gives you the amount of moles. These are useful approaches, okay? So, and use them many, many times, okay? Okay, so, what else? Mass percentage, something we talked about. What is the definition? The mass of a particular atom, a particular element in a compound, okay, so let's take one mole of the compound, then the mass that that single atom contributes, that the element contributes to one mole of the compound, goes here in the numerator, and in the denominator goes the mass of one mole of the compound, which is nothing but the molar mass of the compound. So here, molar mass of the compound, here the mass contributed by that element, times 100%. We've done this several times. Let me show you an example that appeared on a midterm two years ago, or a couple of years ago. What are the mass percentages of the different elements in sorbitol? Three elements, carbon, hydrogen, and oxygen, and we can determine the mass percentages of each through this formula. So let's do that, you see how that works. Carbon, this is six moles of carbon per one mole of the compound. Six times the molar mass of carbon is the contribution of carbon to the total. This is the total of one mole of the compound, that's basically the molar mass, 182.17, is the molar mass of sorbitol. This ratio, six times this, divided by the molar mass, times 100 gives us 39.56% of this particular case. What are these six things that you need in this calculation? Yeah, you need four, because this number here is given as four. Let's say you grab this from the pure table, and that's four smithing figures, this is a limiting factor, that means this should be four. Some people ask, should percentage be in some kind. If the number is smithing figure, no, it's a calculation, you just stick to the rules. People ask, when do I need to apply significant figures? Yes, the very quick answer is, if you simply always stick to the rules, you can never go wrong. If you decide, well, maybe not when necessary, you actually risk a chance of doing it wrong. So just applying those rules actually will teach you to get into the habit, it's not really that difficult, you just have to do it several times, and then you can assure yourself that you at least won't lose points in that department. So the different figures, just stick to it, even though it's not explicitly said. Okay, mass of hydrogen, how do you do that? Same way, 14 times the molar mass of hydrogen, this guy here is the contribution of the mass of hydrogen, contribution of hydrogen to the mass, and this is the molar mass of the total compound once again, that ratio times 100 gives us 7.75%. That is the percentage, the mass percentage of hydrogen and sorbitol, and finally, the last element is oxygen, same deal, 6, that's a subscript that means 6 moles of oxygen per one mole of the compound, 6 times the molar mass, 16 grams per mole of oxygen, divided by the molar mass of sorbitol, that ratio times 100%, gives us 52.70%. Okay, if you're not sure that you did it correctly, you can always do a final check, and that is adding these guys up. Should add up to 100 if you include all elements. We have included all elements here, so they should add up to 100%. In this case, 100.01. This 01 is within experimental uncertainty, so this is perfect. Question? Why does hydrogen have 3.60? Say again, why does hydrogen have 3.60? This one here, this one should be in 4, that's a very good point, this one should have one more 6.00. That's right, absolutely. So this answer is not completely correct, but it's a more 6.00. Okay, another one. This is balancing equations. Balance the following molecular equations. This is a funny reaction. We haven't seen this one before, but it doesn't matter. We should be able to balance it, nonetheless, right? Barium oxide, this is reacting with hydrochloric acid, this is hydrogen peroxide, and this is barium chloride. So we haven't really worked a lot with this hydrogen peroxide, but it doesn't matter in this question, we just have to determine the correct stoichiometric coefficients in this equation. We can just try and balance. Okay? So rule of thumb is, we first want to look at those elements that are not hydrogen peroxide, so they are more exotic elements, so to speak. Barium is one of those. Barium has one here, one there. That seems to be fine. Chlorine, that's the next one I'm going to look at, because chlorine is not hydrogen peroxide. So take that one, I have two here, I have one there, so I need at least two there. So I'm going to put that there for starters. So I'm going to put it with another two, make it four, who knows, but at this point I have taken care of this chlorine, relative to this contribution right there. So there's a two here, that means I also have two hydrogens. Does that make sense? Hey, look at that, there's two there. That's good. Two oxygens and two oxygens, that means that putting a two here was sufficient for balance in the equation. So at this stage I'm done with this guy. Okay, another one, a typical question where everything is spelled out in words, and you have to first of all find the compounds and then balance them in the equation. Okay? Iron III sulfide is one reactant. The other one is hydrogen chloride. Gas is hydrogen chloride. Okay? So if you put hydrogen chloride in water, it becomes hydrochloric acid, HCl. Right? In the gas phase it's called hydrogen chloride. Those are the two reactants. The products are iron III chloride and hydrogen sulfide, which is a gas as well. So let's write down those reactants and products. Iron III is iron III plus, right? It's an ion. Sulfide has as its charge two minus. To make them equal and charge anionic side and cationic side, you need to have the lowers multiplier. That does that for you. So this is III plus, this is II minus. I need to multiply the anion with III and the cation with II to make a neutral compound. Thus, I have iron II and then SIII. That is iron III sulfide. Make sure you do that, okay? This is very important. We've done it some of the while back, but being able to write these compounds correctly is of course very important. If you make a mistake here, everything else is going to be different. If you want to balance the equation. Because you get a different number of elements that you have to balance out if you make a mistake. Okay, the other reactant is not so difficult. It's hydrogen chloride, which is HCl. In the gas phase, it's called hydrogen chloride. Okay, on the product side, I have iron III chloride, chlorine, the chlorine ion, as charge one minus. I've used only three of them to make a neutral compound. So, I have FECL III, which is a solid. Let's give it a year in question. And then the other product is hydrogen sulfide. Sulfide, again, is an anion with charge two minus O vice. That means I need two hydrogens to make a neutral compound. So, hydrogen sulfide is H2S in the gas phase. If you put this in water, it's called iron sulfuric acid. Okay. So, now we have to balance this. So, first let's look at the iron here. So, iron is two here, there is only one there. So, I'm going to put it two there. So, that's iron. And then let's look at the next element, which is sulfur. So, here, there's only one there, so I put a three there. Okay, so at least this part is balanced with respect to this. Now, I'm going to worry about the second reaction here. It says I have three times two is six hydrogens. So, that means I need a six there. Okay. And then, luckily for me, two times three, that means also six fluorines. So, I'm done. All right. So, this one is also balanced. These are real questions from exams. Okay. So, if you are comfortable with this, you should be fine on the exam. You feel like I am very jittery on this, then you know what to focus on. Okay. So, here we have a reaction. And the question is, write this reaction and balance it, but do that in a molecular equation way, the complete ionic equation, and the net ionic equation. Okay, so I have to write the same equation basically, three times. Molecular, complete ionic, and net ionic. So, let's do that. This seems like an acid-base reaction. Okay. So, this is called hydrosyanic acid. Hydrosyanic acid. We've seen it several times. That is sodium hydroxide. Those are the two reactants. It's an acid-base reaction. What happens? This H is going to meet up with this OH- to form water. Okay. So, let's write that. Here they are. These are the specimens, the reactants, in form of molecular compounds. This H plus here is going to interact with this OH- to form water, which is a liquid. Okay. And then the other two ions are sodium plus and CN minus, and they can be written as one compound in the 8-base space. Once again, 8-base space means this thing is fully dissolved, and either it is an ionic compound, or it means that they are dissolved into ions. That is not a specific set of equations. In the complete A-ion equation, we do explicitly write out the ions. Okay. We write out everything that exists in a ionic form in solution. That's what the complete A-ion equation does for you. So, how do you write this? H plus N. And CN minus. That's right. H plus, CN minus, both are dissolved. Okay. I have seen folks do the following, and please do not do this. They write H plus C4 plus N3 plus. Okay. I have no idea where this comes from, but it happens every year on exams. Every year, a couple of folks will do that. So, somebody must have told them that, but it was not me. I tell you this. And since I am the one that is taking your exam, you better listen to me. Okay. I am the joke. This is the truth. Okay. Okay. Sodium hydroxide, right there, and you have hydroxide, any ion. Sodium, any hydroxide, any ion. Okay. So, they are both stable ions in solution. On the other side, does water split? No. Let's say compound, that's already in solution, it's very happy, is non-ionic species. Okay. So, water stays water. This, however, is the ionic species, fully dissolved into sodium and the CN minus Na. Okay. Last step, net ionic. What we do here, of course, is cross out spectator ions. Spectator ions are those ions that appear on both sides of the equation in the same form. Okay. For instance, the CN minus here in the aqueous form, and there, it's exactly the same, I can cross that out. And the sodium in the same form here, as it appears on the other side, can also be crossed out. And what I am left with is simply the proton interacting with the hydroxide and the ion to form our good friend, the water one. Some people have asked me, in the acid-base reactions, is the net ionic equation always this? The answer is not always. Okay. For instance, I can have an acid-base reaction where the base is NH3, which is ammonia, which can accept the proton, then the product is NH4 plus. You do not form water explicitly. So be aware, it's not always this. You don't always have to form water in acid-base reactions. Acid-base reaction is defined in this particular case as the reaction where the proton is exchanged between two components. Okay. Another example. We have to write, again, the molecular, completely ionic and net ionic equation of this reaction. This is not an acid-base, but a precipitation reaction. So that means we have to recognize what is in precipitate. That means you have to know your solubility state. Okay. Aluminum nitrate bearing hydroxide are the two reactants. So let's write them down again for all intents and purposes. These are the reactants. The products are, well, let's figure out which is the one that is the precipitate. I can make two more combinations. Barium with nitrate and aluminum with hydroxide. Which one do you think is the precipitate? Aluminum hydroxide or barium nitrate? It's not barium nitrate because nitrates always dissolve well. That means it must be aluminum hydroxide. Okay. So the precipitate is aluminum hydroxide. Let's write that down. Aluminum hydroxide. Aluminum is 3 plus, OH minus, 1 minus, of course. That means I need three of these guys. Right? So it's Al OH 3. And then barium nitrate, two nitrates per barium because barium, of course, is 2 plus, always 2 plus. So these are the compounds. Okay? I belt this already for you. There's a 3 there, a 2 there, a 3 there, and a 2 there. Okay, so let's now split all these things into ions if they exist. This one is ionic and dissolves well. So I get aluminum and nitrate, barium and hydroxide. Okay? There's a 3 there, there's a 2 there. That means I get six hydroxides. Please take note, folks. Don't make a mistake. Don't write three hydroxides because you have really six. There's a 2 there. So look at the subscripts very carefully. Same here. There's a 2 there. The 2 multiplies with this 3. You have six nitrates. Okay? On the other side, I have my precipitate, which, of course, does not split up into ions. It is a solid. And then this guy is fully dissolved, which means, as a younger compound, it exists in a form of cation and anion. Again, 3 times 2 makes nitrate and anion in storage. Okay, so let's figure out which ones are the spectators. They need to appear on both sides in the same form. Okay? Nitrate, I see here, six nitrates right there. Beautifully crosses out. Three bariums and three bariums right there. Also very nicely crosses out. This hydroxide does not cross out because even though it's over here, this is part of a solid. Okay? Well, here it is fully dissolved. So this hydroxide does not cross out. So what I'm left with is the aluminum, the hydroxide, and the precipitate. That is the nettinger equation. One note is there is a 2 there, a 6 there, and a 2 there. That means 2, 6, 2. In the nettinger equation, what I want to do is to show you only the lowest stoichiometric coefficient. I can divide the whole equation by 2 to have 1, 3, 1. Okay? Do that. In the nettinger equation, you want to show the lowest stoichiometric coefficient. If you can design the whole thing by 2 or 3 or 1, whatever, do it. Okay? Then we talk about concentration, in terms of molarity. So the definition is mol of the compound over the volume in the air of the solution. Actually, this one should not be there. Okay? It's not the definition. It is mol of the compound in the volume of the solution, in terms of the air. So this one is incorrect. So if you dilute the solution, and you solve a stormalac, which is very convenient to use in several calculations, we realize that if you dilute a solution, the number of moles of solute do not change. Okay? So if I put sugar in a cup, let's put it even more simply. I have a cup of coffee. I put sugar in there, 1 cube. Then I put more coffee on top. Does the amount of sugar change? No, still 1 cube remains. But the volume has changed. That means the concentration has changed. The number of moles of sugar before and after I put extra coffee on top is the same. So before and after I have the same number of moles. Mold equals volume times molarity. So that means M times V before equals M times V after. That's where the formula comes from. This formula is indeed very convenient. You can use it when doing calculations in the volume of the solution. However, use it in terms of understanding the problem. Okay? Don't blindly apply this to anyone. Because you're going to run yourself into the ground at some point. Okay? So let me give you an example. This is a question which is very similar to the one in the practice measure. It says the following. I have a 0.675 liter solution of sodium chloride. It also says how many moles sits in there. Okay? How many liters of water needs to be added to make 0.15 molar of the solution of NaCl? Okay, so let's have a look. I can use this equation. Okay? I can use this equation. So what I have, I have a situation before which is this many liters. And I can calculate the molarity too. This amount of mol divided by this number is the amount of liters. So is the molarity. Okay? So I have a molarity and I have volume. And I can also determine the... I also have the molarity after. That means I can calculate the volume after. So this is V2. So let's plug in those things. Okay? So before times V. So m times V. m times V really is the number of moles. Okay? The number of moles is actually given right there. I don't even have to calculate this step explicitly. It is 0.34 moles. Okay? I'll show you this example because I wanted to realize that just m times V simply means number of moles. If the number of moles is already given, you don't have to make a conversion back to molarity and then multiply the volume again. Okay? So this is the numerator. This is the denominator, which is the concentration that you want to have. Okay? And 2, that's the one that you want to have. That means V2 can be calculated. V2 is 2.67. So that means initially I had this, 0.675. My final situation says the volume is 2.67. Okay? The volume is larger than before. I have added more water to it. That means the volume has gone off. However, the question is this. How many liters do you need to add? Okay? I don't need to add this much. This is the final volume. I already had something before I started. So what I have to add is the difference between the two. Okay? This is the final situation. This is what you started with, so what you have to add to get to the new volume is 1.59 liters. That is the answer. The answer is not this. Okay? And here's an example of understanding the question rather than just plugging in a formula and hoping that you're doing it right. Okay? I can very easily see whether you understand the question or not. If you forget this step, you probably just blinded your by the formula and everything will turn out well. Okay? But if you do this step, you actually have a whole of the problem. You know what the problem means. This is the final answer. So read carefully and visualize the problem. Try to understand what is going on in this particular situation. Okay. What are the reactions? You know I have a problem for red and blue sears. Okay? So I'm going to go through this once again. Hope on it. I have 1, 2, 3, 4, 5 red guys and 1, 2, 3 blue guys. Okay? That's what I have. Now these guys can react. We've got another. Namely, a blue guy can interact with a red guy in a form of a bomb. Two friends, arm in arm, walk forever. Okay? The question is, what is the limit in radiation? Blue or red? Blue. Yeah, you can see that very quickly. Blue. You don't even have to do anything special. However, we can do this also in the brain of these dumbbells. We have molecules. And this situation is so easy, you can just look at it and see the answer right in front of us. Okay? If you do molecular calculation with molecular compounds, you don't see that right in front of you like that. Okay? But I wanted to show you a similar area in two situations. Okay? So the way we do it is this. You look at the ratio between red and blue. They react one to one. Okay? What I have here actually is not one to one. I have five to three. Okay? That is larger than one. And then the definition is that I have a limiting reagent, which in this case is the denominator. Okay? The limiting reagent is the denominator if this is larger than one. Okay? So blue is the limiting reagent. How much excess reagent is left? Two. I can see that directly. No calculation needed. Again, look at the similarity here. Okay? The answer should be two. What do we do? We start with the limiting reagent, relay that to how much of the other guy has reacted. Okay? Through the mole ratio. The mole ratio is one to one. So I convert blue to red. That means I have reacted three red guys. What is left is what you started with minus what has reacted, which is two. We do the calculation as we do it in chemistry. And it is really the same kind of calculation as we do intuitively, but to spell it out in such a way that if you follow this track, you won't make a mistake. When things get more difficult, your intuition will leave you at some point. Let me give you another example. This is situation number two. Three guys in blue. One, two, three, four, five, six, seven, eight guys in red. Okay? The only reaction is four. Not one to one, but one to two. Okay? Each blue guy likes to have two reference. Okay? So which one is the limiting reagent? Is it blue or red? Let's calculate that. I mean, you can maybe say blue, but since it is a record two to one, you have to take into account that you have to multiply this with two first to see how much you have left. Okay? So let's look at a little bit more involved. You can imagine when the numbers are very different, and the ratios are completely different, if this is three to fifteen, you lose track. Okay? So this is when your intuition is escaping you, and you better stick to this way of applying it. It's the same way as if your intuition spelled out mathematically. Okay? The equation says this reacts one to two. Okay? Two red for each one blue. Actually, the actual situation is eight over three. That is larger than two. That means blue again, once again, is the limiting reagent. Okay? To calculate how much you have left, you take the limiting reagent, convert that to the other guy. Through the ratio two to one, that means six hundred reactors, you have eight minus six to the left. Two is the normal axis. Right? So the calculation here with the sears is down in exactly the same manner with molecules. No difference. Absolutely no difference. The ratios are ratios of number molecules, or moles of molecules. It doesn't matter. The ratio is a ratio. Okay, so let's apply that in the following way. Oh, this is actually the recipe that we're going to follow. This is what we have done so far. Okay? If you've got such a question where you have to determine, for instance, how much water do you pour, or how much excess reagent is left, you always want to start with writing out the equation and be correct. So write a balance equation. Then you want to determine which one is the limiting reagent. The recipe that always works is to identify the mole ratio of the reactants according to the equation. Then you cover the actual numbers, determine the ratio, and compare it to. From that, you can determine the limiting reagent. The ratio is more, the denominator is limiting reagent, and it's less, the numerator is the limiting reagent. And then finally, once you know the limiting reagent, the limiting reagent determines how much product will be poured and how much of the excess reagent will react. You always start using the amount of moles of the limiting reagent to calculate how much of the other two guys you have. So here's an example. This is a precipitation reaction. I have barium chloride, and I have iron sulfide. The question is, how much of the precipitate, in this case, it's given what the precipitate is, it is barium sulfide. So we have to determine how much in grams of the precipitate do we pour. First things first, I want to write down the balanced equation. Let's write down the reagent, barium chloride, that is 1, and then iron 3 sulfide. You've seen it before. Iron 3 sulfide is Fe2S3. Barium 2+, chlorine 1-, that means barium Cl2. Barium sulfide is this compound right here, BASS. Barium is 2+, sulfide is 2-, that means one sulfur for each barium. And iron 3 chloride, iron 3+, chlorine minus of the rest ions, and there's three chlorines for each one iron 3+. If you balance it, there's going to be two there, three there, and a three there. Okay, so now I know this equation. To simplify matters, you don't have to do this. Some people ask, when do I need to use the net end equation? I mean, it's up to you. The net end equation is very convenient in the case of precipitation of the actin strength, it tells you directly what are the things to look at. Okay? The net end equation of this situation is the following. Barium needs one ion of sulfur to form barium sulfide. Sulfide, sorry, barium sulfide. So this simplifies things dramatically. I don't have to worry about all these things, the stoichiometric coefficients are all different now, because the only thing I have to worry about in the net end equation is, one barium ion to one sulfide ion gives me barium sulfide. That's it. Okay? I have to determine which one is the linear reagent, the barium ion or the sulfide. And then I have to determine how many moles of these guys do I have. The equation says it reacts one to one. So let's see how much we actually have. How do you find it out? Well, look at this. I can calculate the number of moles of barium chloride. Each barium chloride unit has one barium. So if I multiply this with that, the molarity with the volume, I get the number of moles. Okay? The number of moles is 0.1 liter times 0.2 molarity is the number of moles of barium 2+. That's over here in the numerator. In the denominator, I do exactly the same to calculate the number of moles of the sulfide anions. Okay? There's three sulfide anions for each one mole of the compound. So this liter times the molarity times three. Okay? Because there's three of these guys for each one mole of the compound. So this denominator here is the number of moles of the sulfide anion. To complete this, you'll find the following 0.67 is the ratio. That means the numerator is the limiting reagent, which is the barium ion. Okay? The barium ion is the limiting reagent. How many barium ions do I have? Well, I've just calculated. It's right here. 0.02. 0.02 is the number of moles of barium ions. Is this a solution? Yes. Okay. Okay. Who can explain to me why do you simply multiply this number here with three? Why is that? Yes? It's three, I think, and the number is three. Yeah, three is because 0.1 liter times 0.1 molar to do the local technique, you get the number of moles of iron-3 sulfide. Number of moles of iron-3 sulfide. Each mole of iron-3 sulfide has three sulfides. Right? That's the three right there. Each one mole of iron-3 sulfide has three sulfides. If you throw in one mole of iron-3 sulfide in a solution, you will have three moles of sulfide anion. That's why there has to be a three. This is an important step, folks. If you don't get this, you should really ask the credit for me to explain it to you one more time. Because it's important to realize that this compound gives you three sulfide anions in solution if you dissolve one mole of it, three moles of sulfide. Okay. Barium is limited in reagent, you conclude it. So let's start with barium sulfide. So let's start with barium to calculate how much barium sulfide will produce. Okay? One to one. I saw in a previous page, one barium produces one barium sulfide. That's the product, so one to one. That means that it generates the same amount in terms of moles of barium sulfide. 0.02 times one is 0.02 moles of barium sulfide. The amount of moles of barium sulfide multiplied by the molar mass gives me the amount in grams, 3.4 grams of barium sulfide. Okay, let's do one more or not. Let's do a precipitation reaction. Okay? This is a table of condensed form that we already saw. So be sure you can work with this. Okay? And in the following way. This is precipitation reaction. Potassium sulfide is reactant with barium chloride. Again, to calculate the amount of product in precipitation. Same kind of question. Always starts with writing down the equation. Nobody's talking about it. Okay? So potassium sulfide, that's one reactant. Barium chloride is the other guy. Here they are. Okay? Potassium sulfide. This is barium chloride. The precipitate is going to be barium sulfate. Because potassium chloride is not a precipitate. Potassium dissolves with almost everything else. So it will be no precipitate with potassium. Barium chloride is not precipitate either. So the only option left is barium sulfate. And indeed, sulfate forms a precipitate with barium 2+. That's an exception. It's in the table. Okay? Now, this equation is already balanced for you. Determine the limiting reagents. We do it, of course, the same thing, because we always do. Look at the ratios in the equation. We have these two reactants. Okay? This is one mole to one mole of barium chloride. One to one. That means this ratio of the equation is one. And the actual numbers are here. One mole of potassium sulfate, four moles of barium chloride. So one to four is 0.25. That means this guy here is the limiting reagent. Potassium sulfate is the limiting reagent. Okay? In this case, I've not converted it to a net-eonic equation. We don't have to. Okay? Whatever works best for you. Okay. So I have to calculate how many grams of the precipitate. This is the precipitate. This is the limiting reagent. Okay? So what I'm going to do is I'm going to start with the number of moles of the limiting reagent, potassium sulfate, convert that to the number of moles of the precipitate. Let me go back very quick. One to one. Okay? Number of moles of the limiting reagent, converting that into the number of moles of the product, barium sulfate, one to one. That means I generate one mole of barium sulfate. Multiply that by the molar mass of barium sulfate. Gives me the amount of grams of barium sulfate. The nice thing about this example is that I have already everything written out in moles. Okay? All right. Very last example, two seconds, is an acid-base reaction. I want to show you that not every reaction has to form water. And here's an example. This is an acid. This H splits off. Ammonia is a base, a base, an acid. This H goes right there. Okay? Forming NH4 plus and the rest NIN. So take note of that because acid-base, in our definition, needs a proton to be transferred from one compound to the next. Often times, forming water in the counter ion is always minus. But if it's something else, like ammonia, people count the notes. Okay, folks. See you on Friday.
UCI Chem 1P is a preparation go General Chemistry that covers: units of measurement, dimensional analysis, significant figures; elementary concepts of volume, mass, force, pressure, energy, density, temperature, heat, work; fundamentals of atomic and molecular structure; the mole concept, stoichiometry; properties of the states of matter; gas laws; solutions concentrations. Course may be offered online. Slides: 00:07- Midterm II Review 01:46- Midterm II Information 02:20- What Will Be On the Second Midterm? 04:34- Moles and Mass 07:12- Mass Percentages 11:48- Balancing Chemical Equations 17:43-Chemical Equations 22:26-Chemical Equations, Slide 2 26:31-Molarity and Dilution 28:32-Molarity and Dilution: Midterm Example 32:04-Limiting Reagents 36:37-Limiting Reagents: Midterm Example 43:52-Precipitation Reactions 46:50-Acid Base Reactions
10.5446/19457 (DOI)
So, so, chemists, time flies, my son is 19, he came back yesterday, he's the first man. Now we're already very good friends, so you know, we're going to progress here, and we are continuing our journey into chemistry, I think, with getting on our final topic of the entire course, which is read-off reactions. So, the fact of the last part, we've again, are three main types of reactions, which you know about, but you guys are so careful with chemistry that you need to have this knowledge for it. And these are the precipitation reactions, the acid-base reactions, and finally the read-offs reactions. And in terms of the news to read-offs today, and we will be continuing talking about the read-offs reactions till the end of the presentation. So, it's the final, the full-time topic we will all discuss. So, the long-term read-off, that's why we spent several lectures on the topic. We will have a lecture on Wednesday, and Wednesday is a funny day because some folks will be traveling to their homes elsewhere, and that's fine. But for those of you who are here, I strongly recommend you try to make that come because I'm going to discuss some very important points, basically about the journey of the department. So, it's kind of like we're going to review a section of really specifically targeted points that are typically partial people to kind of like digest. So, it's very useful in your own bias. Next week thereafter, after the Thanksgiving, we have midterm. It's midterm number two. Midterm number two is a little awkward because of the time it comes on. It's kind of late in the season, so technically we have our midterm this week, but because of Thanksgiving and holidays, we shifted it up. And that's a little, these two very strange situations that the midterm and the final are separated by only two weeks. So, that's very close. So, I apologize for that, I just couldn't figure out how to do it, but we were basically depreciating this problem. So, midterm, then we have only one week of lectures left, and then it's the week of the time it's over. We're seeing the end of the final coming very close. Alright. Before we do that, we have to talk about read-off reactions, so let's get started. Here is a beautiful, you may recognize it. This is methane, and methane has, of course, a carbon atom right here in the middle. Carbon is, of course, a very invigorating atom that comes to organic compounds, and that organic compounds are carbon-obesiding compounds. Here's another one. This is carbon right here. And at first sight, we said, well, this is the same kind of carbon atom, which is a different box. But we would like to have a way to kind of maybe classify differences between these atoms. One thing I could say, for instance, is that this carbon has four bonds, four single bonds, and this one has two double bonds. Clearly, this carbon sees the slimy environment. And because it sees the slimy environment, I could insinuate that the electron distribution around the carbon atom, the central carbon atom in this case, is a little bit different compared to the situation here. So these two carbon atoms can go in terms of the intrinsic atom, they're exactly the same, but in terms of their surrounding, they're different. They're involved. So there's many ways of chemistry in which we can describe those differences. And in one way, in particular, is relevant for us and for our read-off reactions. One way to kind of classify such differences, the immediate environment of the atoms in terms of the electron distribution is a quantifier, this called oxidation state. So oxidation state is a funny descriptor. It is a descriptor like molecular activity. It is a number that the S chemist came up with, just to simplify our thinking about particular processes. So as you will see, it has to do with losing and gaining electrons, but it's not the same as charge. So we'll get to that point. So for now, consider it as just a trick for chemists to keep track of certain processes. So it's really an artificial descriptor. So for instance, chemists would call the oxidation state of this carbon atom minus 4. So the value of the oxidation state is minus 4. And just to indicate the differences between those two situations, this is plus 4. And you'll see that these numbers will get some meaning in a few seconds. But you clearly see, even though the carbon atoms in the carbon atoms are exactly the same, there is a need surrounding in terms of where electrons are close to it, the fact that the oxidation state here is minus 4, and here is plus 4. Now, if the atom is just by itself or part of the elemental material, for instance, is a carbon, the elemental material of carbon is dynast, only carbon atoms. So in its elemental form, the oxidation state is always 0. However, when the element is part of a compound where there are different atoms associated with it, then it is generally non-zero. So if the atom is part of the elemental material, the oxidation state is 0, but if it's not part of the elemental material, in the case of carbon, it will be diamond. This is including the other diamond. So these are compounds that are not elemental. Then the carbon has generally an oxidation state that is not zero. And that holds for every element, not just carbon. To make a long story short, the oxidation state is a descriptor that can be used to identify differences in the surrounding of the atom in terms of where the electrons are. So let's look at this table. This is a table that contains elements, but this is the truncated form of the periodic table. And you see here numbers in red, and those numbers are oxidation states. So let's highlight the problem. Let's start with fluorine. Fluorine, if it is part of a compound, has oxidation state minus 1. If fluorine is in its elemental form, which is fluorine gas at 2, the oxidation state is 0. But if it's part of a compound, or it's bonded to something else, the oxidation state is minus 1. Sodium, if it's bonded to something, typically in form of an anionic compound, its oxidation state is plus 1. So you see here, this is very close to what we would expect based on their charges, if they are ions. So we know that the charge of a sodium ion is 1 plus. The oxidation state is plus 1. Fluorine, we just saw, has oxidation state minus 1. We know that fluorine, when it is in ion, has the charge 1 minus. So these are identical to each other. Let's look at another one. Here is beryllium. Beryllium has oxidation state plus 2 when it is part of a compound. The beryllium ion has charge 2 plus. So again, this is the same as the charge of the ion. And in terms of iron, we know iron, we have seen, actually, it can have two different types of charges. It can have two different kind of oxidation states. Those oxidation states are plus 3 and plus 2. Those are the most common. Because we actually got more, these are the most common oxidation states of the ion element. So unlike fluorine and sodium, which only have one oxidation state, this element here, iron, has at least two oxidation states. And the same goes for carbon. Carbon does not have one oxidation state, as multiple. And the most common ones are plus 4 and minus 4. And even iron, the simplest element we have, can have two oxidation states. Plus 1 and minus 1. So we've seen that some elements have one oxidation state and others have two. So how do we go about this? We need a set of rules, yes. The three-some are the two-fourth elements that they can have. These guys are the noble gases. And so they typically don't have oxidation state. You will see, actually, an example where we will highlight oxidation state, xenon. You see, xenon actually does have one. So not all noble gases are completely without oxidation states. But basically, this table here, we will simply not use those elements in the discussion of the talkers. Okay. But actually, the reason for that is that these elements simply don't form compounds in general. They form compounds under very extreme situations. So a vehicle, noble gas, because they don't form compounds or something else, they don't react. And so that means they're always in an elemental form. That means that the oxidation state is always 0. Okay. So when an atom is in its elemental form, the oxidation state is 0. Then this is basically our definition. In other words, carbon in its elemental form, diamond. The carbon atom here has an oxidation state of 0. Oxygen in its elemental form is oxygen gas O2, and has oxidation state 0. And iron, the soul of iron in its elemental form is also oxidation state 0. And also, every element in its elemental form has oxidation state 0. If you have a monotomic ion, so we look at an ionic form of an element. This is sodium chloride, sodium and the gel in its elemental form. It's monotomic form. Then the oxidation state is the same as the charge of the ion. And the soil of the brain. Chlorine minus 1, sodium plus 1. So these are the charges of the covalent ions. That means that barium 2 plus has oxidation state of plus 2. And chlorine minus 2 plus has oxidation state of minus 1. Bless you. Want some water? Actually I don't have any. You want some H2O? Alright. That's a neat one. Okay, chlorine, like I said, has oxidation state of minus 1. So that means that chlorine is part of the compound, for instance Hf. And this F has an oxidation state of minus 1. The same holds for this F, which is part of the covalent compound. This is the full carbene line. It doesn't matter if the F is associated with an ionic compound, or the covalent compound. Sf6 definitely is a covalent compound. Yes, the oxidation state of chlorine is classified as minus 1. It doesn't mean that the chlorine is part of the compound. This is why I'm saying that this minus 1 is just a descriptor of chemistry to keep track of chemical reactions. And you'll see how it comes into play. So don't confuse these oxidation states with it being charges. They're not related, but they're not the same. Okay. Oxygen, if it's part of a compound, its oxidation state is minus 2. Except when oxygen is in a peroxide. We will not consider those cases. So in H2O, this oxidation state of this atom here is minus 2. And it doesn't matter where the oxygen is. So in nitrogen NO2, the oxygen is also having oxidation state of minus 2. It doesn't have a charge of minus 2. It has an oxidation state of minus 2. When hydrogen is part of a covalent compound, for instance H2O, let's covalent it here, we know that, then its oxidation state is plus 1. Okay. And the same for NH3. So when the hydrogen is covalent, we bond it to another element, then its oxidation state is plus 1. However, when hydrogen is part of a compound that involves a metal, like a sodium hydride, then the oxidation state is minus 1. Yes. What about hydrogen peroxide is in a peroxide? Hydrogen peroxide is plus 1 for hydrogen. It's different from oxygen. But hydrogen has been hydrogen peroxide is still plus 1 because it's covalent compound. Okay. So these are a set of rules. And with these set of rules, you can do almost everything. Yes. What is the relationship between concentration state and charge? There is a relationship on the level of ions. So as soon as you avoid the ionic compounds, then it is 1 to 1. That is, if you have covalent compounds, then that relation starts working. Because with covalent compounds, you don't have charge separation. But we keep this method anyway because it really helps us find out how electrons flow in the chemical reaction. Okay. So in addition to these basic rules, we have two more rules that will help us to find oxidation state of all elements. Okay. Rule number one, the oxidation state of all atoms in a neutral molecule adds up to 0. So if you have a molecule that is neutral, doesn't have charge, okay, so it's not an ion but a neutral molecule, then if you add up to oxidation state, all these ions should add up to 0. This rule is going to be very helpful for us. And if you have not a neutral molecule but you have an ion, a fully atomic ion, like this sulfur, S of 4 to minus, then if you add up to oxidation state of the atoms in the fully atomic ion, they should add up to a charge of the ion. So, if you add up to sulfur plus the 4 octatons, you have a fully atomic ion state, you should retrieve minus 2 because that's the charge of the ion. Alright, so this list of rules will actually help us determine the oxidation state of a whole bunch of elements that are greater or far from. Okay, so let's put it into practice and do a couple of quick exercises to see if we get this. Here are three. HBR, that's the first. So, H has oxidation state of plus 1 when it is bonded to a nonmetal. Okay? So this is a nonmetal. So in this case, this H has an oxidation state of plus 1. Now, this whole thing must be neutral because it is. That means that this guy must have oxidation state of minus 1, okay, because they have to add up to 0. So this BR, actually, I don't know at the onset what the oxidation state is, but I use what I do know about hydrogen and then from using the rule that it must add up to 0, I can determine that bromine has an oxidation state in this compound of minus 1. It doesn't mean that every bromine always has oxidation state of minus 1 because in this compound, as you will see in a second, it does not have oxidation state. So let's do that. What do I use here? Well, I use the same trick as before. This H must have oxidation state of plus 1 because it's not bonded to a map. Okay? So this one has plus 1 once again. I also know that oxygen, when it's bonded to another element, it has oxidation state of minus 2, okay? Except when it's peroxide, but I promise you, we will not talk about peroxide. The only reason for it is the oxidation state of oxygen is minus 2 in the compound. Okay? So this is minus 2. Now, what do I do now to determine the oxidation state of bromine? I take this one, 4 times minus 2 should add up to 0, and that allows me to calculate the oxidation state of bromine. So what I do is I have 1 times plus 1, 4 times minus 2. When I add up the unknown oxidation state, X of bromine, I should add up to 0. Okay? So I can quickly solve for X, and if you do that, you find X is 7. See, X is 7 here, it's minus 1 there, very different. So the oxidation state of bromine in this compound is plus 7. Okay? So I use what I know for hydrogen, what I know for octogen, and that is how I can determine the oxidation state of the alloy. And I do not know the oxidation state. In terms of notation, this is how it works. You always indicate the oxidation state of a single atom. And then to calculate what the missing oxidation state of the other atom is, you consider the stop squares. Okay? Like you don't put here minus 8. It always means the oxidation state of a single atom. Irrespective of the substance. Okay? Okay, so let's do this one. This hydrogen bonded to calcium is a metal. So now in this case, hydrogen has an oxidation state of minus 1. And there's two of them. And that means that calcium is having an oxidation state of plus 2. This is to be expected. Calcium has typically a charge of 2 plus. This is a very logical outcome. Okay? Calcium has an oxidation state of plus 2 in this compound. Okay, let's do another three. Interesting compound here. Where do I start? Well, let's first see that this looks to me like an ionic compound. This here is a polyatomic anion. This is a, this is magnesium. Magnesium has always only one oxidation state, which is corresponding to its charge. It must be 2 plus. Okay? Magnesium, in its an ionic form, its oxidation state is 2 plus. I also know oxygen, when it's bonded to something else, the oxidation state is minus 2. Okay? So I use that as well. And I have only one element missing, which is a phosphorus. So when I do the same trick, 7 times minus 2 plus 2 times plus 2 equals 2 times the missing oxidation state of this element. So I have the following equation. 2 plus 2, which is corresponding to magnesium, plus 7 times minus 2, which is this one here, plus 2 times the missing oxidation state of the element, phosphorus, should add up to zero. Only one unknown in this equation, so I can quickly solve for x. And x is 5 in this case. And 5 indeed is a common oxidation state for phosphorus. So even if you don't know that, it should be fine. Okay? Any questions? Alright, so now here is an interesting situation. This is not a neutral molecule. Okay? This is a polyatomic anion. This is nitrate. It's a minus charge. So what I do is the same trick as before, about I don't put in zero, but I put minus one, because it adds up to a charge of this polyatomic anion. So let's do that. I'm going to start again with oxygen, because I know oxygen always has oxidation state minus 2, and it's bound to something. Okay? So minus 2, this one, nitrogen, I don't know the oxidation state of, but I do know that one times nitrogen plus three times oxygen, which has minus 2, must add up to minus 1. Okay? Because the charge is minus 1. From 1 minus. That means again, I can solve for x. In this particular case, x equals 5. The oxidation state is 5 of this nitrogen. Yes? Why does it add up to zero? This does not add up to zero, because this is a polyatomic anion, and the rule is, if it is so, then the oxidation state adds up to the charge of the polyatomic anion. The charge of this molecule is zero. So it adds up to zero. The charge of this guy is minus 1. It adds up to minus 1. Okay, final one, exotic compound. One with xenon. Xenon is a normal gas. It doesn't really form a large stable compound. This is actually one of them that is stable. It's a little bit of an exotic case. But it doesn't matter for our purposes. We can just try to calculate the oxidation state anyway using the same set of tricks. Oxygen, once again, minus 2. Fluorine is always minus 1 in compounds. So I have fluorine here as well. I indicate the oxidation states of the single atom here. Okay? Then I'm trying to calculate the oxidation state of xenon by considering 4 times minus 1 plus 1 times minus 2 plus X equals zero, because this is a neutral compound. Okay? Minus 2, that's for the oxygen, plus 4 times minus 1, that is 4 times minus 1 of fluorine, plus the unknown, X equals zero. That means X equals 6, and xenon adds an oxidation state of plus 6. Okay? So you can see that by using the rule for a disadvantage, looking at hydrogen, oxygen, and fluorine, and using a factor that should add up to either zero or the charge of the chromium is coming up, it should be able to derive oxidation states and all the atoms get a particular component. Now, this is the first step to understanding what happens in an oxidation and an induction reaction. So let's have a look at that right now. This is what happens. I have a compound A, okay, to be specified, and a compound B. This is before the reaction. After the reaction, this happens. Okay? So A apparently has lost two electrons in this particular example, and B took them off. So what this really is is basically the transfer of electrons from one compound to another compound. You can compare this with an acid-base reaction, for instance, where we have a proton that goes from one compound to the next. It goes from an acid to a base. Here, it's not a proton that travels, but it is a electron, or two electrons or three electrons. So electrons are being channeled from one compound to the next. Now, if you do that, we can look at this a little bit more closely and realize that this guy is losing electrons. This one is losing electrons. Before the reaction happened, it had more. After the reaction has completed, it has less. That step, the losing of electrons is called oxidation. So oxidation means the compound loses electrons. That's what it is. If you lose electrons, you're being oxidized. So A is being oxidized. And because A is being oxidized, it has a name, and it's called the reducing agent. So the reducing agent becomes oxidized. That means the reducing agent loses electrons. Compound B, actually, the situation is reversed, because compound B gains electrons. And the process of gaining electrons is called reduction. Reduction, and that means that B is being reduced. B is called the oxidizing agent. It is the agent that makes this step possible. A makes this step possible. That's where the names come from. So the oxidizing agent is being reduced, which means it gains electrons. The reducing agent is being oxidized, meaning it loses electrons. That's it. So in an oxidation reduction reaction, these two steps happen at the same time. So one is gaining, the other one is losing. It happens at the same time. That's why it's called redox, oxidation reduction. What happens is one or more electrons are transferred from one compound to the next. And this diagram can be summarized as follows. The reducing agent is oxidized. That means it loses electrons. The oxidizing agent is reduced. That means it gains electrons. The oxidizing agent means if you oxidize, you lose electrons. If you are reduced, you gain electrons. Okay. Now let's look at this a little bit closer. And some pictures will be helpful. So here we have sodium. Sodium here is solid. That means it's in its elemental form. This is chlorine, CO2. And this is chlorine gas. It's also in its elemental form. I can make these things react in a particular way. And then after the reaction, I have low in the hole, NaCi. Sodium chloride. Sodium chloride looks very different. Okay. And it's solid. You can eat it. Actually, you can eat this, no problem. But you cannot really eat this. And certainly, you shouldn't eat solid sodium. Okay. And it will explode from the inside out. But it's remarkable that these elements here, in their elemental form, once they exchange electrons, they become something completely different. Okay. Completely different. So let's look at this. This is an oxidation reduction reaction. I'll show you why that is so. So let's look at sodium first. Sodium is in its elemental form. That means it has oxidation state zero. After the reaction, it's right here. Now it is an ion. That means it has oxidation state plus one. Because the charge is both of us. If you look at it, you see it has become more positive. The oxidation state has grown. That means it has lost electrons. Okay. If something becomes more positive, which is a charge and oxidation state, that means you won't lose electrons. Okay. That means it is being oxidized. Because being oxidized means you lose electrons. So in this process, sodium is being oxidized. It loses electrons. Chlorine also has oxidation state zero, at the very beginning. But after the reaction, we see it is in an ionic form. Meaning it has charge minus one. And I think it's oxidation state minus one. Charge one minus oxidation state minus one. It's reversed. So before zero, after the reaction, oxidation state minus one, it has become more negative. That means it gained a light-force. That means it is being reduced. So this is an oxidation reduction. A reduction reduction. So in the reduction reaction, you can say that the oxidation state of reducing an oxidation agent are changing. If the oxidation state do not change, it's not going to be a redox reaction. But if they do change, this is a redox reaction. That is a definition of a redox reaction. The oxidation state of the reducing an oxidation agent has to change. Okay. Another example. This is a combustion reaction. We've seen it many times. The combustion of methane. CH4 is reacting with oxygen to form CO2 and water. So let's look at the oxidation states of all these elements before and after the reaction. Let's see what happens. So let's start with hydrogen on the metal. When hydrogen is bonded to a non-metal, oxidation state is plus one. Okay? So what is the oxidation state of this carbon? Minus four, right? Because I have four times plus one. The whole thing needs to be zero. That means oxidation state equals minus four. The oxidation state of oxygen is zero because it is in its own metal core. Okay. So this is for the reagents. Let's look at the products. Let's first look at carbon dioxide. The oxygen is part of a compound. That means oxidation state minus two. Two times minus two, this guy is plus four. That's right. Because again, if you add four times minus two, so two times minus two is minus four, you have to add four to make a neutral compound. Add up to zero. So the carbon here must be having an oxidation state of plus four. Let's look at this oxygen here, minus two. And this H here is plus one because this carbon is part of a compound not called a fluid metal, so plus one. Okay, so let's make a table of carbon before and after. The oxidation state before equals minus four. After plus four, it becomes less negative, more positive, that means it loses electrons. And that means it is being oxidized. So a carbon atom here is oxidized in this process. Hydrogen. Hydrogen has plus one here, plus one there. That's funny. It doesn't change. So is it an oxidizing agent or a reducing agent? Neither. This is a spectator, tell us all. Like a spectator ion in a precipitation reaction, we can have elements here in the redox reaction. We don't know anything if they don't change in oxidation. They are spectators. So the combustion reaction is zero before the reaction takes place, after minus two. So it changes, becomes more negative, means it must have gained electrons. It has gained electrons, UR, V8, reduced. Okay? So combustion reactions are redox reactions. Now let's look at this a little bit more closely and we'll look at the next lecture, actually the next lecture. I mean we've got half reactions. I have here, carbon has minus four here, plus four here. The difference is eight. Eight electrons. Okay? So eight electrons must have been transferred from carbon and it goes somewhere else. Whether they go or they go to the oxidase. Oxygen actually has more negative oxidations there. So carbon basically transfers eight electrons to oxidase nearby. Okay? And we'll see again, when we talk about half reactions, how you can understand the transfer of the light. You can keep track of this. Okay, here's another example. I have here a copper wire and I dunk it into this solution, which contains two things. A solution of silver nitrate. Okay, so there's silver ions in the solution and a little bit of ammonia in there. A little bit of ammonia. So what happens here is a problem. The copper wire actually, as you can see, the copper is going to lose electrons. So it's being oxidized. And this guy here, the silver ions in the solution take those electrons. So they are gaining electrons. They are being reduced. So silver is reduced. Copper is being oxidized. And in this particular reaction, it's even beautiful blue color. And that is because they add a little bit of ammonia to this solution. Okay? And this ammonia then will make it complex with copper ions. So I can detect whether or not copper ions are formed because it's complex with the moment. Here, it is beautiful blue color. At the same time, if you look at this wire here, it's very crony. And that's because silver deposits sit on this wire. Part of the copper, which was a solid, has gotten the solution to become copper ions. And in return, silver ions decay solid silver to the copper. So it looks like a crony silver coated wire coming out. This is a typical redox reaction. Now let's do a couple of examples that are faders stacked. Okay. Here's the situation. I have zinc metal. So that's solid zinc. And it is reacting with aqueous hydrochloric acid. The products are zinc chloride and hydrogen gas. The question is, is this a redox reaction? And if so, could you tell me about the oxidizing agent, the reducing agent, and the substances being oxidized in reduced R? Okay. So let's look at this. The first thing you would like to do is to write out what you can re-inverse into a chemical equation. So let's do that. I see zinc here on the reagent side and hydrochloric acid. So let's put that down. Zinc hydrochloric acid. It forms zinc chloride right there and hydrogen gas, H2. So ready balance for you? There's a 2 here to balance the number of hydrogens and chlorine. Okay. So this is the balance equation. What I have to do is to determine whether or not this is a redox reaction. So I have to look at the oxidation states, the 4 and after. Let's do that. I see here this is an elemental form. That means zinc has oxidation state zero. Zinc is in that element of 1. This H here is bonded to Cl. This is not a metal. That means this has oxidation state plus 1. And that means that chlorine has oxidation state minus 1. I could already tell you that because this is basically in solution to the ionic form, the Cl is minus 1 and the hydrogen is plus 1. I can tell you that right away. Okay. On the other side, I see zinc now is in ionic form. That means this is 2 plus because Cl is in ionic form as well. That means it has oxidation state minus 1. Zinc must have 2 plus. Okay. So 2 times minus 1, Z must be 2 plus. And then hydrogen here, what is oxidation state? Zero because it is in its elemental form. H here is in elemental form of hydrogen. Okay. So the next question then is, is this a redox reaction? Yes. Yes, it is. There it is. It's because zinc is changing its oxidation state and also hydrogen is changing its oxidation state. Okay. So what we get is following. Zinc goes from zero to plus 2. Is it gaining or losing? Yes. It is being oxidized. That means it's losing electrons. It is a reducing agent. So zinc is a reducing agent. It is being oxidized because it loses electrons. The hydrogen went from plus 1 to zero. That's more negative. It's a more negative charge added to it to become zero. That means it is being reduced. The definition of something is being reduced is the oxidizing agent. And finally, chlorine does not change its oxidation state. And therefore, it is a speculative. Yes. Is it possible for a global environment to be able to produce a negative charge? Yes, it's possible. But usually, we zoom in on the element. We usually zoom in on the element. So for these examples, zooming in on the elements is the right thing. Okay, another example. Liquid silicon tetrachloride is reacting with water and it forms hydrochloric acid and silicon dioxide. The same question. This is a redox, the next example can be identified in oxidizing and reducing agents. So the first thing to do, again, is to write down in form of a chemical equation what is going on. This is silicon tetrachloride. This is water, this is HCl, which is a product, and this is silicon dioxide. Okay? I have a balance set for you. And there's a 2-debt to make the number of oxygens in hydrogen's equal amount. Okay, so the next step is to assign oxidation states. Let's do that. We'll see if we can do it quick this time. Chlorine and silicon. Chlorine typically like chlorine when it's part of a covariate compound. It has oxidation state minus 1. Okay? It's very similar to chlorine. So I can state and assume that, and this is why I'm showing you the example. Chlorine like chlorine typically has oxidation state minus 1 in the square of a compound. That means that the silicon here must have oxidation state plus 4. 4 times minus 1 needs a plus 4 to make it 0. Oxygen always minus 2 in the square of a compound. This H must be plus 1. Okay? On the other side, the Cl must be minus 1, the H must be plus 1, because they're ionic. And then oxidation states are similarly charged on the lines. And here on this side, I see oxygen that's minus 2. Okay? Times 2, I need a plus 4 there to make it 0. Is this a redox? The answer is yes. Okay? That means no. And that is because there's no change of oxidation state. There's no oxidizing or oxidation. Okay. Well, let's look at one more example of silicon tetrachloride. Okay? Another reaction of silicon tetrachloride. It's reacting with magnesium metal. And it will form magnesium chloride with solid silicon. Same question again. Because an XR can be identified as an oxidizing of the two species. Okay? Then I'm going to start writing down the equation. Silicon tetrachloride, because they continue to slide. It's now reacting with magnesium, which is solid. It is elemental magnesium. It's just a ionic compound, magnesium chloride, and solid silicon. If you look at this reaction, we think it's a redox now. Yes. Yeah, you can see it already, right? See, magnesium is elemental, and here it's not. So there must be a change of oxidation state. Well, let's say, what? That's a sinus oxidation state. In the previous slide, I already did the one for silicon tetrachloride. So plus 4 minus 1. This is an elemental state. That means 0 for magnesium. On this side, magnesium in its ionic form has oxidation state. Plus 2, chlorine oxidation state, minus 1. Plus 2 minus 1. And this is elemental silicon, must be 0. So this is definitely a redox, because there's changes in oxidation states. And let's see if we can identify what is being reduced, what is being oxidized. Okay? So let's look at it. Let's look at silicon. It goes from plus 4 to 0. Oxidized or reduced? Who says oxidized? Who says reduced? Okay, so this is a 50-50 slide here. Let's look at this closely. Plus 4 to 0. It was more positive, it becomes more negative. You gain electrons, that means you are being reduced. You gain electrons if you are being reduced. That means if you are being reduced, you are the oxidizing agent. Okay? Another example, of course, is magnesium. From 0 to plus 2, it lost electrons. It becomes more positive. It loses electrons, and if you are losing electrons, you are being oxidized. And that means that you act as the reducing agent. Chlorine, again, once again, is a spectator element. It doesn't do anything. It doesn't say it's oxidized. Okay, so make sure you can identify these two processing. Being reduced or being oxidized. Okay? That is the recipe for next time. See you on Wednesday.
UCI Chem 1P is a preparation go General Chemistry that covers: units of measurement, dimensional analysis, significant figures; elementary concepts of volume, mass, force, pressure, energy, density, temperature, heat, work; fundamentals of atomic and molecular structure; the mole concept, stoichiometry; properties of the states of matter; gas laws; solutions concentrations. Course may be offered online. Slides: 00:06- Redox Reactions 04:30- Odixation State 06:55- Oxidation States (Periodic Table) 10:26- Oxidation States (Chart) 16:11- Oxidation States: HBr, HBrO4, CaH2 19:39- Oxidation States: Mg2P2O7, NO3-, XeOF4 24:05- Oxidation and Reduction 27:30- Oxidation and Reduction Example 1 30:26- Oxidation and Reduction Example 2 34:08- Redox Reactions 35:44- Redox Reactions: Example 1 39:43- Redox Reactions: Example 2 41:51- Redox Reactions: Example 3
10.5446/19456 (DOI)
All right scientists. Let's talk about the essence of A-reactors. You guys already know this. We started talking about particular types of reactions. This week we talked about precipitation reactions. Today we will talk about acid-base reactions. And on Monday we will touch on V-Docs reactions. Next Wednesday is a very funny day. I'm not sure if everybody will be here. But we will have a lecture together. So I will not do new material, but I will go through some of the previous topics. And point out some interesting points that have been made highly interesting. So today, acid-base reactions. This is a very important class of chemical reactions. It's already a part we have to know about. So it deals with important acids and bases. These are just chemical compounds. And they have a sedative or basic property. So let's look at a couple of examples in part to understand what are acids and what are bases. Acids are molecules or compounds that can give off an H plus, a proton in solution. And this is one example. This is a very interesting molecule, a cyclic acid. Cyclic acid is an acid because this H can split off and go in solution. Then you have a proton that is fully dissolved in water. And hence it is acidic. So the concentration of protons defines how acidic a solution is. Another example is acidic acid, that is the acidic component in vinegar. This H will split off. HCl, hydrochloric acid, we've seen this several times, or it is an acid because this H is fully dissociated from the Cl and hence you have a chosen solution and that is the definition of an acid. On the other side we have bases. Ammonia we've seen already, that's a base. Why is that a base? Because the connection accepts an H plus. And so one definition of a base is that it accepts protons. We'll see that in the next slide. Here's another one. This is baking soda. It's also a base. So this ion here can accept another H plus, that's why it's basic. And then finally this is NaO8, sodium hydroxide or caustic soda. This O8 report is highly basic and is very happy to accept an H plus in solution. So these are very common materials. You may have one of these things in your kitchen currently. And so relevant chemicals and we have to understand how they react and why they react. And what quantities they take. Okay, so let's look a little closer and come to a certain definition that we can use in this course. An acid we can define as a proton donor. Meaning that this H here, that guy, can split off from the compound and can be fully reporting in solution. The base on the other hand can accept such protons. So there it is. So effectively what you have is kind of an acid base reaction. You have an acid that gives off an H plus and a base that accepts an H plus and finds it. So this is one definition of an acid in a base. There's more definitions. But for this particular course, PEM1P will use this definition. The Bernstatt Low-Re definition of acids and bases. The definition is really what the graph is all about. An acid is a proton donor and a base of proton exactly. Very useful definition. But you'll see chemistry will see there's more definitions of what an acid or a base can be. Okay. You remember, we've seen several types of acids and bases already. And when we talk about stroke and weak electrolytes, some of them are strong. Other ones are weak acids or strong and weak bases. So let me summarize that once again because it's going to be important for this discussion. So strong acids, or those acids are completely dissociated into H pluses and the corresponding N a-hons. Example here, hydromeric acid is fully dissociated into H plus and the corresponding N a-hons, Br minus. There's no H Br left. Everything is split. In other words, this reaction, this direction is highly unlikely. The back of the direction is highly unlikely. And we have already seen that there are six main strong acids. And here they are. Hydrochloric acid, hydrolytic acid, hydrionic acid, nitric acid, perchloric acid and sulfuric acid. Those are the acids that are classified as strong. So it also implies that if you see an acid that is not part of this list, if it's not part of this list, you can actually interpret it as a weak acid. So the weak acids are those acids that do not fully dissociate into H pluses and N a-hons. And the corresponding N a-hons, meaning that there's a likelihood that the H plus would go back to the N a-hons and maybe use the corresponding N a-hons or the original compound. Let's give an example. This is a seeded acid. This H can split off. And we have seen this example already. This H can split off. Producing H pluses in solution, and it is an acid, this is the acetate N a-hons. But the acetate N a-hons can accept the H plus once again and go back into this species, the original compound. So at all times there's a portion that is always in this neutral form and then a portion that is split. Not every thing is dissociated. Only part of it. So basically every other acid that's not part of this list can be classified as a weak acid. Just let me give you some examples. The simplest acid that contains, that is basically a carboxylic acid is a formic acid. Formic acid is the seeded compound in a bee sting or in antifungus. So that's a simple carboxylic acid. Seedic acid, this is a hydrosceneic acid, is also a weak acid. And a posterior acid, also a weak acid, is not part of this list. Anything else is basically a weak acid. There are actually very, very strong acids beyond this, but we'll walk this through to the next slide. Okay, so we have strong acids and weak acids. We also have strong bases and weak bases. So let's look at a couple of examples. Strong bases are formed by those that fully dissolve, could dissociate in solution to form OH- in the ideal solution. So the compound is fully dissociated such that it generates OH-. Here's an example. This is sodium hydroxide in water fully dissociates into sodium ion and hydroxide and ions. And the speck of reaction is highly unlikely to happen, basically, under the saturation. So this is a very strong base and basically most salts that contain OH- at hydroxide and ion are strong bases because they generate directly OH-. But there's more species that generate OH- and we've seen the example of ammonia. This is the ammonia molecule. When it interacts with water, what it does is it accepts an H from the water. So it becomes NH4 plus and the remnant, the water molecule that is now missing NH- becomes OH-. So effectively it generates OH- in solution and hence ammonia is a base. It is not a base that contains OH- already, but it does generate OH- if you put it in solution. But of course it's a weak base that means that the speck of reaction is taking place and not all ammonia molecules are protonated into NH4 plus. And then we'll go back this way. So that's, you know, we should be able to distinguish those four cases. Strong acid, weak acid, strong base, and weak base. Okay, so now we have these acids in basis. How long do they react? Well, let's have a look at the particular reaction. Hydrochloric acid is reacting with potassium hydroxide. There it is. Hydrochloric acid in solution is H plus and CO minus. Two ions that are fully dissolved. And potassium hydroxide are these ions, potassium plus and OH-. So this is, I'm writing this out in terms of the complete ionic equation. So this is the acid because this is the H plus and the base in the solution is the OH-. And so what will happen is, what do you think will happen? This H plus will go there. So they interact from water so that H plus will go to the OH- to form water. And then these two guys are left. Nothing happens to them. They just stay in solution. H plus and CO minus, they will stay in solution, will not form a new compound. And therefore these guys are called the spectator ions. So I can again use the same trick that we learned about last time. Cross out those spectator ions and I'm left with a net ionic equation, which is H plus, interact with OH- to form H2O. This is the base, the most fundamental acid base reaction. Where you have H plus in the solution, interact with the OH- to form the solution, and they form the water molecule. This is the most fundamental acid base reaction. There's more times. This is the most funnable. Now, if you have a very special situation that you have exactly the same amount of H plus as OH- in solution, so the same amount of moles of H plus and the same amount of OH-, they will combine to form the water molecule. And if you do that, you have no H pluses and no H minuses left, and you have neutralized your solution. So a neutralization reaction is when the amount of base reacts exactly when the amount of acid in solution neutralizes the acidity. There are technically no H pluses floating around in the solution, all taken care of. And the solution is called neutral. You learn in chemical theory that neutral really means, okay? neutral means there's not all the H pluses that are gone because you have to sell deprotonation of water, but beyond that, all the H pluses are gone. So for all intents and purposes, you consider the solution to be fully neutral. Let's look at another example. Here's one. Aqueous sodium hydroxide is reacting with acetic acid. Now acetic acid is not a strong acid. This one is, right? This one is not. So here it is. This is the completely ionic equation again. Sodium ions, hydroxide ions, that are sodium hydroxide. This is acetic acid. Acetic acid is actually a compound, okay? Where H is attached, this is a molecule that dissolves in solution, so this ac is mean that the solution doesn't necessarily mean that it is spoiled already. This OH likes to pluck out this H from acetic acid, okay? So this is the base and that is the acid, and they interact very strongly. In other words, all the H's will be plucked away from this weak acid to form H2O. Sodium is a spectator and the rest ion is the acid data. Now, interesting situation here. This was a strong acid in a strong base. Water is formed. This spectra reaction doesn't shape the place. Here I have a strong base and a weak acid. Does the spectra reaction take place or not? Yes or no? What do you think? What do you think the acid is like? What do you think it's like? No. What do you think it's like? I don't know. I don't know what to say. Good. Alright. So this is indeed a weak acid and if there wouldn't be no OH in solution, there would be a reversible reaction. However, OH is a very, very strong base. It likes H plus a soma that it keeps nibbling away as a seeding acid, okay? Because the reaction is very strongly with it. In other words, there is no type of reaction because it is much less favorable to give up the H from the H to rho, second again to the acid state to form OH minus. OH minus, we need to go back this way. So as soon as you have a strong acid or a strong base in solution, the corresponding reaction will most likely be not reversible, okay? Only if you have a weak acid and a weak base, both then you have a reversible. So as soon as you have a strong acid in there or a strong base, you can consider this reaction to be unidirectional, okay? All the H pluses in OH minuses will be consumed. Okay. Let's say one more time and get away. We saw this reaction on the previous slide. We saw HCl and the reaction to the rock site. Now I'm ready in terms of molecular equation, okay? So this is just another way of writing the same equation. HCl is now written as a molecular compound. Aqueous means it's fully resolved, right? Okay, OH, aqueous is also fully resolved. If you write it like this, and I've seen several people do this, okay? Don't write a plus here and a minus there. Because this compound, aqueous means it is already resolved and it is fully sure that it is split. If you split it, you have to split it both and put the A to sign the code. Don't smoosh it together and then squeeze it plus and minus in there. This is not a problem for you. Writing this compound. You either split it fully or you leave them together without showing the process. Okay. So we saw what happens. The H plus in reaction to OH forming H2O and HCl is the other compound. That is still in solution fully split and in the Michael equation, it don't show that they're separate. Put them together without showing the process, the ions. Michael equation, this was the net electric equation. If you put it, H plus, OH minus, H2O, all the rest ions are constricted ions. They're taken care of. They're not shown. Again, this is an example of a fundamental acid-based reaction between H plus and OH minus. Okay. Well, let's look at one more example and try to write these equations correctly and then we'll jump into who the calculations were. Okay, so I have here a reaction. It is perchloric acid and it is interacting with magnesium hydroxide. Perchloric acid is a strong acid and magnesium hydroxide is a very strong base. This will definitely be a unidirectional reaction. In the Michael equation, what I do is I'm going to write down full compound. Okay. Perchloric acid is here. HClO4, aqueous, that is the molecular compound. Don't show the charges here. Okay, once again. And this is magnesium hydroxide. Magnesium with two hydroxide attacks because magnesium is two plus. Maybe two hydroxide, maybe neutral. Magnesium hydroxide happens to be a solid. That's not given here in the question, so I'll put it here anyway. All right, what's happening? Well, this is OH minus. That's a strong base. H plus, of course, is interacting with it to form water. And the other two that are just still in solution are magnesium ions and perchlorate anionis. And to write that in the molecular equation, it's putting together as a compound. But it's understood that they are fully dissolved into ions. There's one problem with this, and that is it's not balanced. Okay, you can see that immediately because I have two, I need two of these perchlorates for magnesium to make it neutral. I only have one here. So I need definitely a two there. I put a two there, but if I do that, I have an issue with the number of H's that I use. There's two here, and there's two there, but there's also another two there. So I need a two in front of the water. Let's check if I do everything right now. Two oxygens, two oxygens, four H's, four H's, and two perchlorates. Two perchlorates, this is right, this is balanced. Make sure you balance the equations right because if you do calculations with the equation where it's not balanced correctly, you get very wrong numbers, so you think it's going to be more or less. Okay, the other part of the question was to write the same equation in the end term that you put the anionic. There we go. What I do is I just split this compound into ions. I'll show you an example I think on the next one there. From these exams, people are trying to do this, and a common mistake, I'm not sure exactly what a mistake comes from, but some, about 10% of people do this, is when I ask you to split this molecular equation into a completely ionic equation, they take each element, H, C, L, and O, and split them all up into 80 dissolved elements. I've never seen this anywhere in the lecture in the program, but some people do that. I would like to make sure that you are not one of those thoughts. If you split something into ions, you can split it into ions. You don't split it into all kinds of elements, right? That's not the idea of a completely ionic equation. So the ions in perchloric acid are H plus and perchlorate. Perchlorate is an anion. This is the anion. You don't split the anion again into elements. Two H pluses, two perchlorates. Magnesium hydroxide is a solid, so I don't split that into completely ionic equation, because these are bonded, but they're not fully dissolved in solution at this point. However, when this H plus is attacking the OH minuses, it will fall apart. This is kind of like how it is understand. The fact that this is an S doesn't mean that it doesn't react. It does. It's like you throw some solid material in solution. The H pluses will directly attack the OH minuses in the lattice, in the solid lattice, and flock away these OH minuses, bringing into solution the rest ions, magnesium, are floating around here. So what we have, we generate two waters. We know that from here, magnesium ions and the rest ions, the spectator ions, perchlorate. The last one is an anion equation, all you have to do is strike out all the spectator ions. This is a relevant example, okay? Because you are not striking out magnesium. Magnesium appears here, but the ionic form of magnesium is not on this side. So you can strike out magnesium here, take it out here, and it doesn't work. If you cross out spectator ions, there really have to be ions that are fully dissolved in the separate, then you cross them out. So the net ion equation is this. H plus, magnesium hydroxide is fully here. H2O, magnesium 2 plus is there. Not cross that, okay? The only thing that's cross out is perchlorate, because that's appearing here, and it's the same form as it appears over there. Is that clear? Yes. Can you try to get away with this with magnesium hydroxide? Magnesium hydroxide is a solid. The magnesium ions are not dissolved in solution on this side of the equation. Only after the H plus is reacting with it, they become available as ions in solution. So you cannot cross out this ion on this side with this bonded ion in the lattice. Okay? You cannot do that. You can only do it if it's a real spectator ion. The real spectator ion is if it appears fully dissolved in solution on one side and on the other side. Now you see this equation here. You can have this plus here, this little awkward. There's also a 2 plus here. If you cross out a charge, there's 2 plus and a 2 plus. This equation is fully balanced in terms of elements and conditions which are. This is a perfectly balanced, balanced, and ambient equation. Okay. Let's move on to the following. This person looks like a very capable chemist, and he's doing something here. He has some red solution here. It opens up a little valve. It drips into here. And this is beautifully green. This is wonderfully yellow. Actually, when you are in the lab, for real, most of you can have this boring, you know, transparent, you can never call it at all. But for photo, graphics, opportunities, they're beautifully colored. This is just to get you excited about chemistry. So what is this person doing? He's doing a titration. What is that? Well, you have this thing here, the bereft. And he's dripping something of that stuff that's sitting in here in this beaker till the moment when a certain reaction will take place and complete, and he can read out on this bereft, which has an indicator on it, how much he used. And he can use that information to quantitatively determine how much of the other stuff is sitting in this beaker. So it's kind of a quantitative analysis method to find out how many ions at a certain time are in here. Okay? So in terms of acids and bases, this is typically what you use for neutralization reaction. Let's have a closer look. Here's one. NaOH, sodium hydroxide. This is hydrochloric acid. This is the two products that form water and sodium chloride in solution. OH is interacting with the H from the HCl forming water. So you can do this reaction in a following way. I have, in this particular case, HCl, the acidic solution in a beaker, and I'm dripping with this bereft NaOH, the basic solution. Okay? And I can control how much I add. So I know exactly how much I add. I know the molarity of this. Think about it. You know the molarity. You know how much volume you apply. Volume of the molarity is exactly how many moles you add. This is why it's correlated. And you can see when something happens here. Now, importantly, there's also an indicator. The indicator tells you exactly when the pH of the number of HCl is dramatically changing. So this will tell you something about whether the reaction is completed or not. There's actually a little movie here that I have. Let's play that. See if it works. Alright, I don't know why it doesn't play. Oh, there it is. A titration is a controlled acid-based neutralization reaction. 20 milliliters of hydrochloric acid of an unknown molarity. Oops, sorry. Two blocks of an indicator dye are added to the acidic solution. This indicator dye is clear in acidic solution and pink in acidic solution. The viran is filled with a sodium hydroxide solution of known strength and an initial reading is taken. The base is added to the acidic solution until the solution stays a slightly pink color. At this end point, a final reading is taken. The moles of base added equal the moles of acid present. This same reaction can be followed using a pH reading instead of an indicator dye. Initially, the pH change is very low as base is added. Suddenly, the pH change is rapidly as the end point passes. The solution quickly becomes very basic, and again, the pH change is very low. The end point occurs at this little point on the curve. Alright. So, that is the reaction. Thank you, YouTube. Let me tell you something about the paper color in this song. This little segment here, producing it two slides long, is not part of any example. It's just extra information. This is a good thing to have an idea of. These are called indicators. The element that gives it a color are called indicators. These are just molecules that are following extra ion solution, and these molecules can sense what the pH is, how many H plus I enter R. In other words, they assume a different color depending on the concentration of H plus I in this solution. Now, I'm going to give you an example of how that can work. Here's one. This is a phenolithylene indicator. Here is the structure. It looks a little bit dramatic. But what happens is, if the pH, the number of H plus is very high, this part of the molecule will be so-called protonated. It will be in H plus sitting here. Now, when the solution becomes more basic, that means there's a very high chance that this H plus will come off and not go back. And if that's the case, H plus goes away, then this unit becomes different. This double bond clicks here. This one clicks there and pulls a double bond in this location. That change in molecular transformation leads to pink color, obviously. So the molecule literally changes color because there isn't H plus attached to it or not. This is how molecules can tell you something about what's going on in this solution. Only you'll ask me about it. Alright, so let's do a calculation with this kind of nucleotidation reaction. So let's say I have, just like the movie, you have NaOH, sodium hydroxide, in a heater. And you have 25 milliliters of that stuff and the molarity is 0.4. And then I want a neutralizer solution with an HCl solution. I have HCl in my u-rat. Okay, and I'm going to add some of this, concentration is given to, till it is neutralized. The question is, how much do we have to add? What is the volume of this neutralizing acid to neutralize only OH-minuses? Okay, so let's do this. As always, you'd like to understand what is the system that we're talking about. What is the system? So what you can do is just to see what kind of ions are there. So I have evidently H plus, I have CCl, and sodium hydroxide. Then I'd like to find out what are the actual reactions that take place here. This is the reaction we've already seen in several quarters. This is the H plus reacting with the olefinis. So this is the net ionic equation. C, elements, Na are just specularized. H plus, 1H plus, one part of H plus, or one mole of H plus, reacts with one mole of olefinis. So from one mole of Y, 1, 1, 1, are more reactions. Okay. Now, previously the next step would be to determine which one of these guys is the limited reaction, which one of the reactants. Okay? Our two reactants, H plus and O times, which one is the limited reaction. In this particular case, we probably don't have to do that. Because the question says, we just have to add enough H plus to neutralize all the OH minus. Okay? So that basically means that the OH minus is the limited reaction. Just have to add enough H plus to add the same amount as the OH minus. I'd like to know the number of moles of OH minus that I have. The number of moles of OH minus that I need to neutralize. So how do I do that? Well, I have a volume and I have a molarity. So I take the volume and V times M equals the number of moles. This is a milliliters and molarity is in moles per liter. So I convert this right quickly into liters. Okay? 100 milliliters in one liter, ML strikes out, now this is in liters. And then multiply it with the molarity. 0.4, 0.4 moles per liter. If I do this operation, I have the number of moles. It turns out to be a nice number. 1.0 times 10 to the minus 2 moles of OH minus. This is the amount of OH minus that I have in my liter. So now I know the number of OH minuses in my liter. Okay? I said already that there's not going to be a limited variation here. I just have to add enough H plus to neutralize all these guys. Okay? So I have to know how many H pluses do I need to neutralize 1.0 times 10 to the minus 2 moles of OH minus. I need to know the molarity between the two. Okay? So for 1.0 times 10 to the minus 2 moles of OH minus, I need to multiply it with the molarity ratio of how these two things react. For each 1 mole of OH minus, I need 1 mole of H plus. In other words, I need just the same amount of H pluses that I have as I have OH minuses in my liter. 1.0 times 10 to the minus 2 moles of H plus. You can do this directly, right? If you know that they react 1 to 1, you can immediately say, this is how many moles of OH like that I have, that's exactly how many moles of H pluses I need to neutralize it. But if you're not sure, you can always do these low ratios which are always right. You can always dive into the right direction. Okay. So this is the number of moles. I need to know the volume. How do I do that? Well, I have the number of moles. I have the molarity. The only missing parameter is the volume. So I know that V times M equals the amount of moles. I have the amount of moles. I have the molarity and V is equally unknown. So these two values are given. This is the molarity of the solution. That is the amount of moles that I need. So if I rearrange this, I find the volume of the solution that contains this many moles of H plus. And that is this number, and divided by this number. 1.0 times 10 to the minus 2 moles divided by 0.13 molarity and that equals 7.7 times 10 to the minus 2 liters. This is the volume that contains this many protons to neutralize this many molarity minus 2. Okay. One more question. Yes. One question. Instead of doing all the six steps, we can just do M1, M2, M3, M4, M2, M2, M2. Just so we can just do it. You can in some cases, but you have to be careful when you apply that formula. This way, you actually approach the problem from understanding the work you're doing, rather than blindly applying formula and hoping that it will work. In order to understand the problem, you basically understand and use the right formula. Okay. Another example. Hydrochloric acid is added to the baryon hydroxide. Luckily for me, the volumes and the molarity are given for each solution. That means I can immediately get to the number of moles on these things. The question is, what is the concentration of the excess H plus or OH minus high H solution? So, I throw these two things together. Clearly, this is an acid, hydrochloric acid, clearly baryon hydroxide is in place. I throw them together, a reaction happens, an acid-base reaction happens, the H plus and the H minus, a reaction called water. So then, when the reaction is done, either there is H plus and the left or the H minus. That's what I have to determine which one is left and how much of it is left after the reaction has come through to stop. Okay, so again, so in the beginning, I just want to see what am I talking about. Here are the ions in solution, H plus, CO minus, baryon 2 plus and OH minus. And the reaction that's taking place is, again, you say H plus and OH minus are called water. Cl minus and baryon are just spectator ions. Okay, so what I really want to know then is how many H pluses do I have, how many OH masses do I have, and which one of these is the lubricant, V8, which one is running out first. Okay, well, the information should be obtainable from the information here. Okay, so here it is. I'm looking at and calculating how many H pluses I have from the amount of hydrochloric acid that I have. This is the volume. I convert the volume to liters and I multiply that by the polarity of HCl. The amount of HCl is 0.25. I also see immediately that each HCl molecule has one H plus. So that means if you do this operation for HCl, you have the same amount of H pluses as you have HCl molecules. So what I have after this operation is 1.88 times 7 to the minus 2 moles of HCl and that's the same as the number of moles of H plus because each HCl only has one H plus. Number of moles of H plus, number of moles of OH minus, I also need, so let's do that. This is the volume of the barrier hydroxide solution. Solvendial liters. So I just multiply that by the polarity of the solution and if I do that, I get here the number of moles of the barrier hydroxide units. But each unit has two OH minuses, so I have to do the following conversion, convert from the unit of barrier hydroxide to number of OH minus. Here I have 1 to 1, here I have 2 to 1. Each one mole of barrier hydroxide produces two moles of OH minus because of the substrate 2 here. So it gives me 2.48 times 10 to the minus 2 moles of hydroxide anion. This solution. Okay, that's good. Next step for me is to determine how these things in the air come into the mole ratio, which one is the one here in the air. If it is very quick, or if it is very quick, what I have to do is I know that in the air 1 to 1 H plus or H minus. I have less of H plus and more of H minus than H plus and more of H minus. So that H plus and more of H minus must be the limited energy. If you do the official way, you should find the same thing. So let's just double check. The mole ratio, according to the equation here, is 1 to 1, so the ratio is 1, and the ratio that I calculate from the actual amount of the compounds is 1.8 divided by 2.48. I just calculated these numbers, and I have less than 1, meaning the numerator is the one in the reagent, is exactly what I thought. Okay, so you can always double check whether your intuition is correct. So I take the number of H pluses then, and calculate how many OH minuses I have left, because OH minuses is in excess reagent. As a reaction, all the H pluses are gone, as OH minuses is left, as OH minuses is in excess. So the question then is, the first part is, this was blue and green, and so I only have OH minuses left in solution. How many do I have left? Okay, the first thing I have to know is how many have reacted. Well, I know that the react 1 to 1 with H plus, this is the amount of H plus, that means this many of OH minuses will react. Okay? So this is what I had in solution previously, at the beginning, 2.48 times center minus 2 moles, that is the total I started with, 1.88 times center minus 2 moles reacted with H plus in a 1 to 1 ratio. So I'm going to subtract these two from one another, if I have one, I have left the solution in terms of moles. This minus that is the number of moles of OH minuses left after the reaction. Okay? This is the number of moles of OH minuses. This is the total volume. This volume plus that volume is here, and if you divide the number of moles of OH minuses by the total volume, you find the polarity of OH minuses. Okay? That's the real question here. What is the concentration of the excess reagent after the reaction? Okay? This is what I talked about right here. This is the total number of moles. That is the total volume of the solution, and the concentration therefore is, in this case, 1.8, 1.98 times center minus 2 moles of OH minuses. Okay? Does this make sense? Who feels like I'm not sure about this? What is the problem that we're not really sure about? This number here? This number is this starting amount of OH minuses, the number of moles that you have in the game, minus the amount of the reactants of H pluses, is what you have left. This is the amount of moles of OH minuses, as well as the amount of subtraction here. That's a negative circle. Yeah, negative. But this is a small number, right? This is the number of moles that you have left after the reaction, so this is the total volume of the sub-discrete amount. Okay. I think that's enough. I'll see you next week.
UCI Chem 1P is a preparation go General Chemistry that covers: units of measurement, dimensional analysis, significant figures; elementary concepts of volume, mass, force, pressure, energy, density, temperature, heat, work; fundamentals of atomic and molecular structure; the mole concept, stoichiometry; properties of the states of matter; gas laws; solutions concentrations. Course may be offered online. Slides: 00:06- Acid-Base Reactions 01:37- Acids and Bases 03:39- Acids and Bases, Slide 2 05:12- Acids 08:25- Bases 10:29- Acid-Base Reactions: Hydrocholoric Acid and Potassium Hydroxide 15:53- Acid-Base Reactions: H+ and OH- 17:48- Acid-Base Reactions: Perchloric Acid and Magnesium Hydroxide 24:03- Titrations 25:22- Titrations: Neutralization Reaction 26:41- Youtube Example: Titration 28:06- Indicators 28:49- Indicators, Slide 2 29:52- Acid-Base Reactions: Neutralizing NaOH with HCl 35:35- Acid-Base Reactions: Hydrochloric Acid Added to BA(OH)2
10.5446/19454 (DOI)
to school so apologies for that. It happens, you know. Today we are going to transition into the first part of chapter 4. So we are really making progress here. It's November already and we are ending the last chapter. The last chapter will be quite another bulky chapter. So we'll be walking through what we're talking about. It's all about chemistry in solutions. So we talked about chemical equations and the balance of equations. We talked about the calculations using chemical equations. Now we're going to add two more pieces here. Namely, looking at the reaction in a little more detail in the environment in which the reaction takes place. The topic that we started with is the reactions that take place in solutions. And more particularly in aqueous solutions. Aqueous of course means a solution of water to the solvent. So water is a great solvent. Your body has a lot of water for good reasons because of water. And you involve in water. Water is your personal solvent. Ocean water of course is a solution. It's actually not pure water. It is water with stuff in it. Among which a lot of salt. This deliciously would be a lot of beer. That's really nice. I like it. It's not pure water. It is water with stuff in it. It's dissolved in it. It's called the solute. It's called the stuff in water with the solute and the water itself is the solvent. So water is called the solvent in this case. It is the medium in which other species, other molecular species, or ionic species are dissolved. It's called the dissolved compound of the solutes. Of course, in the chemistry lab water, which is really important for the solvent as well, lots of so-called odor compounds dissolve dutifully in water. And this is a great solvent on your chemical branch. Okay, so why is water such a great solvent? Let's have a close look at the water molecule. Here is the water molecule up close. We know it has an oxygen. We know it has two hydrogens. H2O is the molecular formula. But if you look at this, and this will be talked about in a little more detail in chemistry 1A. Okay, so we'll just dive into it a little bit in chemistry 1P as well. The hydrogen atom has a little bit less electron density than the oxygen atom. What does that mean? Well, we know that these atoms are nuclei with electron around. The electron will sit in order. There is closed-shadow opon, which is very closely linked to this. And you have open-shadow electrons that are newly formed in order to open-shadow electrons. Are the electrons that like to make chemical bonds with other atoms? Okay, so this oxygen has electrons, some of them will partner with an electron from the hydrogen in the form of a covalent bond. However, if you look carefully at this, we know that if the electrons have formed this bond, they tend to spend a little bit more time on this side, the oxygen side, than on the hydrogen side. Even though the electrons are shared, it seems like they must share completely. The oxygen atom is more electronegative, which means it tends to attract the electrons a little bit more than the hydrogen does. And it doesn't mean that there's actually a charge here. It just means that, on average, the electrons spend more time there on the side of the oxygen. Because, frankly, we can indicate that with a delta minus meaning there is a fractional charge on the oxygen. Not a real charge, but just a little bit more on the negativity, because the electrons spend more time there. So there's a little bit more negativity on this side relative to the side of the hydrogen, where there's thus a little bit more of a plus side. We call that delta plus, a fractional plus charge on the hydrogen. So if you look at that, there's a minus side and a plus side to the water molecule. A fractional charge, not a full charge, a fractional charge. So what does that mean? That means that this molecule has a polarity. It's not completely the same from each side. One side looks a little bit more like plus, the other side looks a little bit more like minus. And that means there will be a different kind of chromatic interaction with different molecules. On this side, it's minus side, there will be stronger attractions with things that are plus. So another molecule, but as a plus, for instance, tends to align with this oxygen, but not so much with the hydrogen, because they're polar. On the hydrogen side, things that are a little bit minus, fractional minus or fully minus, like the ion, tend to align with the hydrogen. They're like the unit side of the water molecule. So there are colloquial interactions. The water molecule, we call that, is a polar molecule. It has a fractional charge on one side. That is plus, and the other side, that is minus. So many of the properties of water follow from this phenomenon of polarity. So let's have a look at what it means for dissolving molecules in water. Okay, so here's a, here's sol and A-C-L, sodium chloride. If you buy it in the supermarket, it's a solid, right? If you throw it in the water, it just disappears. It just completely dissolves. It used to be a solid, and now you just, you can't even see it. What happens? Well, if you throw it in the water, it will be dissolved, literally, by water molecules. And that's why we don't call this solid phase anymore, we call it the aqueous phase. But what does that mean, and how does that work? And why does that? Well, let's have a closer look at this. Here is kind of a, kind of a close-up of a sodium chloride crystal. Okay, so we know, what's a bachlorine, a solid? These ions, they align with lattice, so it's a crystal of material. You see a magnet is the chlorine, it's the sodium plus, right? And they kind of like form this lattice structure. The forces between these ions is like we said, and they keep each other at bay. They keep each other aligned in this crystal lattice. But, if you throw this crystal lattice in a bachloric water, or a glass of water, then these water molecules, they start to impinge at the fringes. I just told you that it has a positive side and a negative side, a fractional positive and a fractional mass. Okay, so, if this water molecule encounters at the surface a chlorine, it tends to align with its hydrogen, which works with chlorine, because the hydrogen is our fractional plus, and the oxygen tends to be away from the chlorine, because chlorine is minus. Because the chromatic interaction keeps the pluses and the minuses along. All right, so there's not just one, there's a whole bunch of water molecules, and at some point, there can be so many water molecules sitting close to this chlorine, they actually exert a force on the chlorine, they want to cool out, like a static one. Okay, and this works for me so strong that it can overcome the forces that hold this chlorine in the lattice. In other words, those are the forces of the sodium ion, the heat of the chlorine in the crystal. The forces of the water that are now encapsulated in the chlorine are stronger, so they plug it away, and now you have individually dissolved ion in solution, fully encapsulated by a water molecule. This ion is no longer part of the solar, we call this aqueous, it is fully dissolved. This ion here is not a solv anymore, so the solv disappears, you don't see it. And the second is true for the cation, sodium. Now in this particular case, force the water molecule's day around. Now, the negative side, because the oxygen side, fractional negative side is the oxygen side, aligns towards the plus of the sodium. Again, it fully encapsulates the sodium ion, plugs it out of the lattice, because these forces are now stronger than the forces within the lattice, and consequently all these ions are after taking out the lattice, and the lattice is gone, the lattice is gone, there's no solv anymore. That crystal doesn't exist, all these ions are individually in solution, and you have this situation right here. Now, that is because of the polarity of water. If you throw the same solv crystal in olive oil, it won't dissolve. Because olive oil doesn't include enough polar, it will not encapsulate these structures, and so these structures will be staying together, the ions stay together in a lattice, and thus, when that was all, crystals stayed together, straight crystals. Okay, so it's the balance between the forces of the water taking out the ions, and the forces that keep the lattice together. If they do water, the latter are weaker than the forces of the water molecules encapsulating the ions. Now, that means that if a compound is polar, or has charges, but if the molecule has a charge of an ion, then the same thing can happen to a solid chloride. Or if the molecule has loops on it, that also have a very strong fractional part, then this will also be very strong in the part. An example is for this ethanol. Ethanol has an OH group. This OH, again, has a negative side and a positive side. This is a fractional charge, delta minus delta plus. The water, again, likes to align here, in this case, with a negative side, the fractional negative side of oxygen, towards the fractional positive side of hydrogen. This interaction is strong, strong enough to fully encapsulate the entire molecule in this whole ethanol. This part of the ethanol molecule, CH3, is not moving forward. So it will not interact very strongly with the water. However, the interactions here are so strong that water can fully dissolve ethanol. However, if you take away these polar bonds, these strong polar bonds, like OH, then the molecule will not dissolve in the water. An example is Decane. Decane has no strong polar bonds. It only has CH bonds. And you will learn in chemistry 1A. That CH is not a polar bond. The likelihood of activity between carbon and hydrogen is almost the same. So there's no lot of difference, which means there's no polar bond. And so this molecule will not strongly interact with water. It rather stays with its peers. Because interactions between Decane molecules individually are stronger than their interactions with the water, and so they are not mixed. Their mother's oil, they have an inextinguishable solution, so to speak. There is basically water at the bottom and Decane at the top. Okay, so if a molecule is non-polar, like fat or oil, the solubility is low because it doesn't strongly interact with the solvent. If it does strongly interact with the solvent, like polo molecules or ions, then there's a high chance that it will dissolve. There's a lot of details here that can deviate from this general rule, but this is the general rule. Let's have a look at this. If I have here a water solution, let's look at this side first, okay? To the right. A water solution. And I don't have any blinding, so nothing is dissolved in this water. And you put a current through this water here, the lamp will not go off. And that's because the electrons, the charges will not really go through the water here. But if you now add some salt in it, you actually create pluses and minuses in the water. Those pluses and minuses are charged carriers, and now the lamp is vaguely dim but on. And then after a while, if you add more and more salt, you create interior water charge carriers, and you actually can form a current between these two electrodes through the water. So now it is conducting. And this is one way to classify aqueous solutions that are ionic. So solutions with a high concentration of dissolved ions are called strong electrolysis. It's a little bit of an arbitrary solution, because what does it really mean, high concentration of dissolved ions? And we'll try to kind of be a little bit more nuanced about that in a moment. By subversa, solutions with a low concentration of dissolved ions are called weak electrolytes. Weak electrolytes. So this solution here, weak electrolytes, will not really conduct current, and strong electrolyte solutions will conduct currents. This is one definition of a ionic solution. So this is a useful definition to look at differences between solutions that could be source. Here is our friend, sodium chloride again. If you throw sodium chloride in water, you know, if you throw a little bit of salt in water, you can shake it, it will become, and that basically means all the sodium chloride will dissolve. It will be not the last of the atom in the cup. Unless you throw so much salt in there that it will start to, and below the saturation limit, the sodium chloride will dissolve. The same holds for ammonium nitrate. If you throw that in water, it will also fully dissolve, and if it fully dissolves below the saturation limit, we tend to call these solutions a polychromic strong electrolytes. Okay, so what happens again? You have salt, which is a solid, it is in water, and after a while the complete crystal structure is gone. All of the ions are in solution and will not spontaneously recombine into a crystal. Okay? This is the definition of a strong electrolyte. Below the saturation limit, there will be no spontaneous recrystallization of this compound. So, these solutions, salts, are strong electrolytes. Now, we'll see actually later on in a couple of lectures that not all salts are strong electrolytes, but most of them are. And we'll learn which ones. Okay. Let's look at strong acids. What is an acid again? An acid is a compound. If you throw it in water, it will generate a plus. Protons. This is one definition of an acid. Okay? If it generates a proton, it also generates an anion, in this case chlorine minus. Now, this compound here, HCl, will fully dissolve in water. In other words, you will have no HCl at it. Okay? So, it fully decomposes into ions. We call this a strong electrolyte. Another example, this is perchloric acid. A perchloric acid, like hydrochloric acid, fully decomposes into HCl and you counter anion to chlorine. Another example, hydrochloric acid. Sorry, sulfuric acid. This is sulfuric acid. Decomposes into protons and anion. In other words, there are certain acids that if you put them in water, they will fully, fully dissolve into protons and anions. And these are six acids that are classified as strong acids. Okay? These acids you should know, at least these acids, you should recognize them as being strong acids. So, let me say which one they are. This is hydrochloric acid, hydrobromic acid, hydroionic acid, nitric acid. This is perchloric acid and this is sulfuric acid. Those are six acids that are classified as strong acids. In other words, strong acids are acids that fully decompose, fully split, dissociate, and you can probably understand. Yes. Yes. So, the question is that your water molecule itself, when you consider it's a very, very weak acid, and that is true. Okay? That is true. There's always a certain factor in protons and hydroxide anions in this solution. Very small amount. We'll come back to that in chemistry one, C. I mean, we'll write that as pH and pKa. Here, we just have to focus on the physics behind it. What is going on? Try to understand these solutions. You want to understand that these compounds fully dissociate into protons and protons. So, strong acids are strong electrolytes. What about strong bases? Okay? What is a base again? A base is, one definition of a base, is that if you put this in water, you will generate OH-minus. Okay? So, sodium hydroxide is one of those compounds. It generates sodium ions, cation, and hydroxide anions. So, this is a strong base, and it does so by fully dissociating, below the saturation, fully dissociating. In other words, this OH-minus and this Na+, will not recombine to form this again. Once they split, they remain split. That means you have lots of charges in solution, lots of ions, and that means that this is classified as a strong electrolyte. The same holds for calcium hydroxide. The same deal. They split completely, completely dissociated into ions. So, in other words, strong bases are strong electrolytes, like storm acids. Now, why do I use these examples so explicitly? Because I want you to discriminate this from a weak acid and a weak base. Let me remind you what the differences are. A weak acid, like acetic acid, acetic acid, of course, is the acidic component in vinegar. Okay? This H here, once it's split off. Okay? So, there you go. That's this H, once it's split off, in the following way. H+, and the rest is an anion now, because the plus charge has gone, it's become negative. This is acetate, a proton and acetate, two ions. Okay? However, this H+, has a chance of getting back to the acetate anion and reforming this neutral compound once again. Okay? So, there's an error that goes back. This is unlike strong acid and strong bases, where this doesn't happen. Okay? So, it is a reversible reaction. And that means that at all times, at all times in the solution, you will always have these neutral compounds sitting there, while a fraction of them is dissociated into protons and anions. Right? That's the difference. This is not a strong electrolyte. It doesn't generate the maximum amount of ions. It doesn't classify this as a weak electrolyte. You see, these structures here, even though the molecule is fully dissolved, it is not dissociated into protons. Please discriminate that. Some people may mix it up. I think, if it dissolves in water, it is going to be a high amount. This thing here is fully dissolved in water, there's a polar compound. There's a right polar bond here, so it dissolves in water. It's dissolved. Okay? In addition to being dissolved, it can split into an anion in a proton. It is not always permanent, and it comes back to reversal. That's why it's called a weak electrolyte. And of course, weak bases have the same kind of characteristic. Okay? Here's ammonia. Ammonia is a weak base. Why? Because if you throw this in water, it steals an H from water and thus generates OH-, which is the definition of the base. It generates OH- and OH- in this solution. Okay? This H is belonging to the water molecule that is now sitting on the ammonia. It called this now the ammonium ion, NH4+. This is a reversible process. In other words, this H doesn't have to be there permanently. It can go back to an OH, which is called an insolution, and reform water. That's why, anytime in a solution, you will find only a fraction of these NH- molecules that are dissociated in charges into ions. The rest of these molecules are in solution but are neutral. Okay? They're not split into a proton, sorry, into an ion. A cation in an anion. Again, these ammonia molecules are fully dissolved in water, but they're not split. They're not ionized. Okay? Alright. V bases are recollectual. Now, in addition, there are, of course, compounds that are so-called non-electrolytes. For instance, sugar, or another form of sugar, multiple, is a compound. Look at all the OH's here. This guy really likes to sit in water, which affects right-stronging and normal molecule. And if fully-detachable, if you fully dissolve, if you fully dissolve in water, it will not form ions. Okay? It will not form a proton or an anion. This thing here is a new proton, fully dissolved in water. So how to write that is here. This is a formula of multiple. It is a solar. If you throw it in water, it happens. It doesn't split, but it does change its space. So this is the reaction, so to speak. The molecule remains intact, and it's just encapsulated by water, and therefore it's in an empty space. If, countably, nothing changes here, physically, the situation is quite different. These OH's are not very strongly interacted with what goes around them. Okay. Now, now we have a formula of standard of solutions, no-electrolyte-no-electrolyte solution, and meet-electrolyte-no-electrolyte, okay? How do we quantify these solutions? In other words, how do we know how many ions or solar molecules are dissolved in my water? Any other salt. The way to quantify that is through concentration. Because concentration means quantity per volume, okay? And the unit that we chose to work with is molarity. Okay? What is the definition of molarity? It is this. Mol's of the solute that you have in your pot. And then the volume of the solution. That's it. That's the definition. This is a concentration unit. So the unit is M, sometimes written in a text, and M stands for molar, and this means mol's for liters. So in other words, if you have a 1.0 molar solution, that means that you have one mol of solute per 1 liter of the solution. That's the definition, okay? And we will work with this definition. You can choose a different kind of definition, but we just tend to work with this definition. Oh, we're doing a picture with that one. All right. Let's give you an understanding of this. Let's calculate the molarity of this compound, the posterior acid, which is H3PO4, posterior acid, in the particle. Okay? So one of the things that's given here, it says that it's 50.8 grams of this stop. And I have a volume of the solution, which is 0.28. So how do I proceed with coupling concentration? What is the definition of concentration? Molarity? It is mol per liter. So I have to know how many mols I have. I have to know how many liters I have. Well, the number of mols I've given, that's by this given, is grand. And we know, very well by now, if you want to convert mass to moles, you have to divide by mol mass. Right? So I'll do that. Here it is. That's the mass of the compound, the solute. How do you know that? Divide by mol mass. In this case, 98 grams. One mole is 98 grams of posterior acid. And that is 0.161 moles of posterior acid. Then, step two, since I know the number of moles, and I know the volume of the solution, I can directly calculate the concentration, express the molarity, and that is the following. The definition of molarity is the number of moles that you have in your solution, the volume of your solution, which is 128 liters. Okay? That means 0.126 molar posterior acid. You see here, the N is the italics, and that's a very common way of writing. So this is how you calculate the volume. Here's another one. What is the concentration of each ion when dissolving this compound, cobalt 2 nitrate, in half a liter of solution? Take the solution. I dissolved this much. So again, I have a mass. The mass, you always want to convert into moles. But they ask here, what is the concentration of each ion? You have to be a little careful here, because I have to realize that the cobalt and the nitrate are in different proportions. It's namely 1 to 2. So what I'm going to do is first determine how much cobalt nitrate I have. How many moles of cobalt 2 nitrate do I have? Okay, so I take the mass. I'm going to divide that by the molar mass of cobalt 2 nitrate, which is 182.96 grams per mole. And I find 0.129 moles of cobalt 2 nitrate. So this is a quantity of cobalt 2 nitrate that I have in my hands. The question is, how much of that is cobalt and how much of that is nitrate? In other words, how many moles of cobalt do we have and how many moles of nitrate do we have? So in other words, if I look at the reaction or the dissolving equation, the following happens. I generate for each one mole of cobalt 2 nitrate one mole of cobalt pethion and two moles of nitrate in the hands. This is important because the concentration of cobalt and the nitrate will be different. You generate twice as much nitrate but you generate cobalt particles. We dissolve this. In other words, this was just one particle, one compound, one molecule. But it splits into three particles. One cation of it into two nitrate ions. So for each one mole of cobalt 2 nitrate I generate one mole of cobalt into two moles of nitrate in the hands. So now I have the quantities of each. This is the number of moles. That is the actual number of compounds. This is the ratio 1 to 2. And from that I can calculate the eulogy because also the volume is given by the eulogy. Let's do that. Let's put the pieces together. Here we go. This is the number of moles of the compound, 0.129. The ratio means that for each one mole of cobalt 2 nitrate I generate one mole of cobalt pethion. And that I'm going to divide by the volume of the solution. Which is 0.5 liters. So I have this whole thing here is the number of moles of cobalt pethion. Divide the number of moles of ions by the volume and then the concentration of cobalt ions. 0.26 molar of cobalt solution. The same for nitrates, the nitrate anions. I start with cobalt 2 nitrate, the number of moles of my compound. But for each one mole of the compound, 2 moles of nitrate divide by the volume I get my concentration, 0.25 molar pethion. This is twice as much as the cobalt concentration. That's not strange, this is the way it should be. Because it's generating more nitrate. Okay, another one. This is important. Important calculation. A chemist wants to make two liters of a solution. It's a very difficult situation in the lab. If you want to be a biologist, biocamist, or if you're a pharmacist, you will have to make offers. And the problem with all of this is that you need 100 million liters of dismal energy. Now you have to determine how much you have to weigh off your balance. This is a very difficult situation. The thing is that you want to have a 2.0 liter solution, and you want that to be at this concentration, 0.1 molar. That's what you want. First of all it's easy to go to the safe, put water in the fuel water in there, 2 liters, but then you have the following problem. How much sodium sulfate do you have to weigh off on your balance? Okay? Okay, well, let's first see how many moles do I need? Okay? How many moles of sodium sulfate do I need? Actually, there's a mistake here. It should be Na2, Na2, S or 4. Okay? I'll correct that when I post. How many moles of the sodium is required? How do I find out? Well, here we go. This is how many liters I have. This is the molarity. Molarity is moles over volume. If you multiply that with volume, volume, volume, you get moles. So multiplying molarity with volume gives you the number of moles that are in the pot. That's what I want to know, because that's how much I'm going to put in. Okay? So I'm going to have a two-liter solution times the molarity. The definition of molarity is mol per liter. 0.1 mol means 0.1 mol per one liter. Liter crosses out, and I have a bottle with 0.2 moles of sodium 2 sulfate. Okay? So this is how much I want. Now, how many moles do you have? The only thing you have to do is to convert that to mass. How do you do that? You multiply that by the mol. That's what you've done in the past week. Okay? 0.2 times the molar mass of sodium 2 sulfate. Okay? This is 28 grams of sodium sulfate. Okay, how about this one? This is, again, let's go back to the salt water, the ocean water. Ocean water, of course, has a high concentration of rock salt, NACL, sodium chloride. The concentration is as high as 0.45 mol. It's a very high concentration. As you know, probably, I think all of the gold in the ocean is pretty solid. Now, the question is, what volume of sea water contains exactly 1 or 0 grams of salt? What I really want is, my question for you is, but first of all, I'm a superlator. Okay? And I say, I want 1 gram of NACL. Here is a little scooper area. Why don't you go to the ocean? It's just enough water, so that in that water is exactly 1 gram of salt. How would you know that? How would you calculate it? Let's do that. Okay? Again, what you want to know is, what you want to get a handle on, how many moles of sodium chloride am I talking about? All right? Well, I have 1 gram, so I can calculate how many moles do you need. Let's do that first. You have grams, convert that to moles, you got a molar mass, you got a dot. 1.7 times 5 to the minus 2 moles of NACL. Okay? So that's how much I need. So I have a mole number, and I have a concentration. Concentration again, what is it again? It is mole over volume. I have mole, I have the concentration, and I don't have volume. So it's only one or none. Okay? So in other words, molarity equals moles over volume. Okay? So that means that molarity times volume is the number of moles. Okay? So in this particular case, V times the number of moles divided by the volume is giving me the number of moles of the whole volume. Okay? So let me rephrase that. Molarity equals moles over volume. Okay? That means that moles equals volume times molarity. That's what I say on here. Volume times molarity equals the number of moles. That's the only or none. Okay? So as we raise that for volume, that is the number of moles divided by the molarity gives me the volume that I need. Okay? So we're getting used here to this formula, which is the definition of molarity. It relates to three variables, namely the number of moles, concentration, and the volume. V, the special leaders, the value of the volume is the number of moles. Okay? So these three parameters are related. And I can calculate each one of them, even though the other two. The answer here is 3.8 times 10 to the minus 2 liters. Okay? Now let's take one more step, since we're not having fun anyway. Okay? Let's look at a bucket of water. solution and the tablet of concentration. OK? And do that now. There's another volume. There's another volume of water. Concentration. But now to do something very interesting, I think you've got to put this water. Put it in there. I put more water in there. Now I have a different volume of the solution. Right? I have the same number of volts of my salt, because it didn't change the amount of salt. It just changed the amount of water. So the amount of salt is changing. The amount of water is not changing. Sorry. The amount of salt is not changing, but the amount of water is. And the volume is changing. So if you look at the polarity, the number of volts stays the same. Volume gets higher. Concentration goes down. Because the denominator is a higher number. The number of moles after the dilution is the same as the number of moles before the dilution. So again, I have water and salt in there. Then I put more water to it. I don't have any salt. The number of moles of the salt in the water can make the same. The only thing that's changing is the amount of water. So that means the number of moles, obviously, with the form after is the same. I also know that the number of moles that are just concluded from some of these calculations equals molarity times volume. The amount of moles is molarity times volume. Again, you might use that again. Because the definition of molarity is moles over volume. So I take the volume to the left side. M times V equals number of moles. Number of moles is the same before and after. That means this. Number of moles before this, number of moles after is that. So M times V before equals M times V after. I can use this to determine any variable that is missing in my calculation. Be it either the molarity or the volume that I need to make a molarity. Let's do that. So we have initially a solution of 1.2 liters. The concentration was this, 1.4 of acetic acid. Then I'm going to add something to it. I'm going to dilute this solution. Concentration goes down. What is the new concentration of acetic acid? The new is in two ways. The useful one I just showed, or do a step-wise. The first one I'm going to do a step-wise. This will show you how it works. The number of moles, like I just concluded, is not changing of acetic acid. Only the water is changing. I get more water. The number of moles of acetic acid stays the same. How much do I have? Well, I have here a liter, which is the volume, and a molarity. And I've just included molarity times volume equals number of moles. So let's do that. 1.2 liters times the molarity, 1.4, equals 1.7 moles of acetic acid. That's the amount of acetic acid that I'm talking about. Check this very quick. Leaders here, leaders there, crosses out. New units is moles. Always check. Now, this is the amount of moles that is now changing. The only thing that's changing is the volume. So the new molarity then is the same amount of moles. That's constant. But the thing that is changing is the volume. Namely, 1.2 liters plus this is the new volume. Because I added that to it. So the volume has changed, and consequently, the denominator is larger, and the molarity becomes smaller. 0.98. That is smaller, indeed, than 1.4. If you do a calculation like this, always check if your answer makes sense. If you dilute something, it doesn't make you should go back. So this number should be smaller than your start. If you get something else, you must have done something wrong. You want to go back in your first attempt. OK, another example. Sulfuric acid. I have 15 molar sulfuric acid. That's what I want. I want 15 molar solution. What volume of that do I need to prepare? What volume of that do I need to prepare this volume at this particular molarity? So initially, I have 15 molar. I have a very folicic acid solution. What I then want is I have a molar. I want to take a little bit out, put it in there. So I have a sulfuric acid solution diluted up to this number, almost one liter. And what I should end up with is 0.12 molar. So I'm going to make a dilution. I'm a very strong, very silky. I need a little bit of that. And then I add more water to it, up to this number. And I should be getting this. The question is, what volume of this concentrated solution do we need to start with to end up with this solution? So let's now use this formula, because I think it will be clear in this case. What is given? Well, what is given is the end situation. The end situation is this volume you need and this molarity you need. That is this. After this process, the molarity should be M2. That is this. And the volume should be V2, which is this volume right there. At the beginning, I have this molarity. That's my starting molarity. V1 is the volume that I need of that solution to make the final solution. When all you're saying is V1, the starting volume. There we go. 15 molar of my starting solution, the volume of that is V, which is unknown. Is the new situation, which is 12 molar at this volume. Remember, this formula came from the notion that the number of moles of the sodium remains the same. That's why this is done. Only thing I'm changing is the amount of water. The only unknown is this guy. So I rearranged this formula for solving the volume. 12 molar of sulfuric acid times the volume that it should be at. This is the initial concentration. M1, that's M1. So again, this is M2 V2 M1 V1. The original volume you need is 7.5 times 10 to the minus 3 degrees. So you need this much of the solution to end up with the solution that ends these four marks. And you can rewrite that into milliliters of the 1, 7.5 milliliters. OK, well, let's do the final one. Another version of the same kind of calculation. What concentration of a solution, which is a silvanite solution, the volume is given, but the concentration is not given. So that's the thing I can determine. So I quickly recognize, great, this beginning concentration is unknown. M1 is unknown. V1 is given. V1 is given. And what I need is V2 is volume 2, 2.9. And the final molarity is also given. That's M2. M2 is given. V2 is given. M1 is given. V1 is not given. Sorry, M1 is not given. But V1 is given. So I use the same formula. I recognize that the beginning concentration is the one I have to determine. That's unknown. This one is unknown. That one is given. That one is given. And that one is given. You just plug it in. And you rearrange for the molarity. So let's do that. That's the only one that's unknown. The molarity rearranges. Basically put this guy underneath. It's 0.055 molar of silvanitrate times the volume divided by the initial volume, V1. And you should be getting the answer. 0.23 molar of silvanitrate. That was the concentration of the initial solution that you had to tell you to deliver. OK, see you on Monday. Don't forget about homeworks.
UCI Chem 1P is a preparation go General Chemistry that covers: units of measurement, dimensional analysis, significant figures; elementary concepts of volume, mass, force, pressure, energy, density, temperature, heat, work; fundamentals of atomic and molecular structure; the mole concept, stoichiometry; properties of the states of matter; gas laws; solutions concentrations. Course may be offered online. Slides: 00:07- Aqueous Solutions 01:35- Water: Universal Solvent 03:00- Properties of Water Molecule 06:38- Ionic Solutes 10:39- Nonionic Solutes 13:10- Strong and Weak Electrolytes 14:59- Strong Electrolytes: Soluble Salts 16:39- Strong Electrolytes: Strong Acids 19:18- Strong Electrolytes: Strong Bases 20:25- Weak Electrolytes: Weak Acids 22:20- Weak Electrolytes: Weak Bases 23:38- Nonelectrolytes 24:57- Molarity 26:14- Molarity- Example Problem: H3PO4 28:21- Molarity- Example Problem: Co(NO3)2 32:02- Molarity and Known Concentration 38:27- Dilution 40:40- Dilution Example Problem: Water Added to Acetic Acid 42:38- Dilution Example Problem: Sulfuric Acid to H2SO4 45:40- Dilution Example Problem: AgNO3 to Silver Nitrate
10.5446/19453 (DOI)
Okay, finished. I'm going to see valves. I'm going to do a very important chemistry. And today I will not introduce anything new. I'm probably already sure. Oh, I'm going to bring up this guy. So, very cute, very cute. I love this. Lots of parents, if they have a cool baby, they give this baby an iPad. And then they're so happy that the baby after about figures out and press something out. Technically, a little child out is an amazing thing. The fact of the matter is, who wants more babies to do? It's not really the problem. As long as you train a little puppy something eventually, it will do that. You can train a dog to pee in his place, where we can train a baby to press this button. So, in any case, these are things that are within the capabilities of us being humans. These are things that we humans can do. Now, we humans can also do things like this. Who likes to go to the causes? I like what the great amount of people likes to go to the causes. I like it too. Every night, I do want to try to go to the causes. That's very cool. I can tell you that the go to the causes are much more complex than what the calculations we do here in this class. There's no comparison. This is orders of magnitude more complex, higher order of thinking, and the kind of exercises we do in this class. Mathematically, it's just very easy to show. Even this is more difficult. Yes it is. Yes it is. So, what I'm trying to do today is try to do a couple of exercises that are within the material that we're working with, and we'll try to break it down, and we'll try to put the pieces where they belong. The mathematical steps are a multiplication or division. So we have to be able to understand the problem and just do those operations correctly. So let me first start with balancing equations. Balancing equations is like a little puzzle. It is like a little puzzle. So let me give you an example. Here's one. What do you have to do? Well, I just have to make sure that on both sides there's the same amount of atoms of each kind. I see two here. There's only one there. I see three there. And there's two there, so evidently this is not balanced. Now what happens? This is two, and this is three. So there's no way you can make this equal by just multiplying this with, let's say, two and this with two. If I multiply this with two, I generate a total of six. Six oxygens. That means I need six oxygens here too. That means if I multiply three there, I get six. And because I multiply by two, I get four of these guys, and the four of those guys. This is it. So I'm just going back and forth until everything is the same inside. Another example. Strontium phosphorus. This four here, this one there. I need three here and two there, so this evidently is not correct. I can start trying to make one of the elements correct and then balance with the other one. Now what I'm trying to do now first, let me just show you why I do this in this order. I see a E four here, and I see a one here. This one means that I can put any number in front to match the missing correlation. So this is not the one I want to balance in the beginning. I want to make sure that the phosphorus is balanced first because I see, ah, there's no coefficient there. I can put any number in front to make a match. So I start with phosphorus in this case. I have four here. I need four on the other side, so I need to multiply this by two. Two times two is four. So I generate six of these guys, the six of them there. See why I'm starting with phosphorus, right? Now let's not do that. Okay, another type of question is this. This is just kind of like a huge chemical equation not to be so scared of them. I have two Y, and this Y is an unspecified compound. It reacts with Br2, and I have two times sodium bromide. What is the missing Y? If you just have to look at this, this question, unfortunately, if you look at the equation, you just put the pieces together, really. What I see here, I have sodium and bromine. Bromine is there, sodium is not there. So I need something with sodium, and there's an iodine there too. So I need sodium iodide. Sodium iodide. If I put this one here, let's check if this is correct. Two times sodium, excuse me, two sodiums, two times iodine gives me I2. So this is a balance equation. You know, this is really actually no puzzle. This is a puzzle, I think, that falls within our union chain of deltas. There's nobody that is so challenged that they cannot solve this puzzle. The only thing is to overcome your resistance for a chemical equation. That's it. As soon as you take out the stack, then you can do the solving. Let's do this one here. Why? If you set the fill out, what is why? I see here hydrogen sulfur. Sulfur is here, hydrogen is there. And it's also oxygen is there. So oxygen is missing. Okay? So this is most likely an oxygen. So let's say this is O2. Let's see if I put O2 in there, if I actually balance the equation. Three times O2 is six octagons. Two times two is four. Two times one is two. Two plus four is six. So that means six octagons. That's right. The other one is four hydrogens, four hydrogens, and two solvers, two solvers. So this is balance, this is balance. Okay, so make sure you're just comfortable with these equations. They're little puzzles and they can be solved. All right, now let's do this. So this is a little bit of a visual illustration of the actual problem. Sometimes in the building house, if you take a question from the abstract, which is a text, into something that is actually completely an object, see the molecules and then it is built into an act. And this is the reaction that we're looking at. This should be an arrow. This is H2, and O2 is these guys. So the red ones are the oxygens, the gray ones are hydrogens, and the fourth one is water. Each water has one oxygen, two hydrogens. So the one to make a water molecule here, I need at least two of these hydrogens and one oxygen. I see one, two, three, four, five, six oxygens, so I could tentatively make six water molecules. I count six oxygens, I can make six water molecules. Okay, and that means if I can make six, I need for each water molecule two hydrogens. So each hydrogen molecule contributes two hydrogens. So if I need six water molecules, I need six of these pairs. One, two, three, four, five, six. So if I use those six plus those guys, I have these two left. So what is the situation after the reaction happens? Choose from this. I just determined that if this react reacts, I can form six water molecules out of three O2s and six H2s, and then I have two H2s left, two hydrogen molecules left. They will not react because they're running out of red spheres. So this one is not correct because I have an accessory agent which is H2. This one is also not correct because I said I could make six. This one makes three, also not correct. Look, this guy here can still react. This oxygen can react with this guy, the other oxygen with this guy can form water molecules. One, two, three, four, five, six plus two hydrogens, this must be the right one. Okay, so again, it is basically a puzzle. You just lose the idea to click, and you just have to determine how many do you form, and what do you have left and what do you have left and what. That's the problem. Okay. Now look at this. This is an interesting one. This is a sample of a compound that contains chlorine and oxygen. So this is a compound that has two elements in it, C, L, and R. Nothing else. It will react with an excess of H2. So this is the accessory agent, the other element, the other compound that's unknown at this point is the limited reagent, and they will produce two products, H, C, L, and H2O. The quantities are given in grams. So determine the empirical formula of the compound. Now, if you read this the first time, you may say, what's going on? How can I determine the empirical formula for this piece of information? That's the first response. The second response is, okay, let's first look at that. Let's see what that is. You want to visualize this problem, okay? The way I visualize it, I'm going to write a chemical equation. I'm not sure what happens with this error. Sorry, it should just be an error to the right. Apparently there's a compound that contains C, L, and O, but I don't know the substance because that's unknown. That's what I have to determine, right? So I call it X and Y. I know it reacts with H2. I also know there's a lot of H2, so H2 is not a limiting reagent. If this is a limiting reagent, okay? It produces H, C, L, and H2O. Okay, so that's that number. And I have to determine apparently what this X and Y is. How do I get that? Well, let's have a look at this problem a little closer. I see that each mole of C, L, X, or Y can produce how many HCl's? If there's X times C, L in there, if I have one mole of this, I can make X mole of HCl, right? Because each chlorine gives rise to one HCl mole. So if I have X4H in my compound, I can make XHCl's. Same for oxygen. Each water molecule has one oxygen. The oxygen must come from this. There's no other source. So if I have Y oxygen atoms, I can make one-eight quarters. What about the H? Well, I just said, no one but eight. There's enough H to take care of this. The limiting reaction is this. So the amount of HCl and H2O is determined by this compound. That means I can make X mole of HCl, Y mole of H2O. All right? Now, that is almost already the problem, because I owe us a solution to the problem, because I have in principle the quantities and moles of these guys. It's given in grams, but I know right now that I can convert grams in a flash into moles. Okay? By the time I'm done with moles. So that's what I'm going to do. I'm going to see how many moles of HCl did I generate? How many moles of H2O did I generate? The ratio between the two should be the ratio between X and Y. Okay. That's what basically what this line says. If I determine how many moles of HCl I generate, how many moles of H2O I generate, then I know the ratio between X and Y. And the ratio between X and Y is the interval. Okay? Okay, let's do this. So what I have to do is I have to calculate how many moles of this I have and how many moles of that. That is something we can do. Okay? Grams converting to moles by dividing by the mole of X. That's your conversion pattern. You don't know yet that you have to divide. You always do this conversion and check the units this has to cross out. This conversion will give you the number of moles of HCl generated. I find 6.3 or 6.4 times the number of moles of this compound. Let's assume everything happens in water. And this thing here is hydrochloric acid. How about the other guy? Okay, so this HCl corresponds to this many moles of chlorine atoms, right? Because each molecule has only one chlorine atom. So this is the amount of chlorine. All right? This is the quantity of H2O. I quickly convert that to moles by dividing by the mole of H2O. This is a division. What I get is 2.24 times 10 to the minus 2 moles of H2O. Each H2O molecule contributes one oxygen. That means I have 2.24 times 10 to the minus 2 moles of oxygen. So this is then X moles of this, Y moles of that. So this is X is Y. I have to calculate the ratio between the two. So that means I can find the empirical ratio between chlorine and oxygen. Chlorine I have the quantity of, oxygen I have the quantity of. The ratio between the two is the ratio between the subscripts. How many moles of C I have relative to the amount of moles of oxygen? So if I divide one by the other, let's just put oxygen on top. It doesn't have to be a quantity, right? Just choose one. Oxygen on top, divide that by the amount of moles of chlorine. The ratio is 3.5. That means for each chlorine I have 3.5 oxygens. Right? For each chlorine I have 3.5 oxygens. That's what this calculation says. We also know that in the empirical formula, we don't have fractions. It should be an integer. So it's not close to an integer number. Is that a problem? Not necessarily. I could just multiply it with a number so that I can make an integer. So let's look at that. I have here for each one Cl, 3.5 oxygens. That's what I just determined. For each one Cl, for each one mole of Cl, I have 3.5 moles of oxygen. If I multiply this whole unit by two, I get this. Cl2 of 7. That is the empirical formula. It's not the molecular formula yet. That's not a question. The question is determining the empirical formula. And the answer is right here. So this is a slightly different question. But again, with the same kind of thinking. How many atoms do I have? How many moles do I have? And how do they relate to one another? If I have this much of this, how much do I have to be audible? That is the kind of thinking I have for applying the multiply. I have a question. Why do you multiply it by two? The question is why do you multiply it by two? Because an empirical formula should give you the substance in integers. This is not an integer. This is 3.5. You have to do that. You have to multiply it with the lowest multiplier that gives you the degree. And that is what we do here. The lowest multiplier is two because two times 3.5 is seven. That is an integer. And in the process, I have two here as well. The empirical formula CO2, 07. Yes, another question. I have a question. I said hydrogen is an excess. I did not have to worry about the high. But for each molecule of HCl, I need one atom of H. One hydrogen. For each molecule of oxygen of water, I need two atoms of hydrogen. So it depends on if you look at this guy or this guy. So there are different ratios. You need more H than you need oxygen and CO. But fortunately, there is an abundance of Hs in the process. So I do not have to worry about it. The pressure is not about that. The pressure is typically about that. And then we just look at how many Hs in that. It needs to be tonic energy. And how much we need. And how much H we have consumed. You can do that calculation as well. Okay. So let's do the following. Another reaction. Remember, these typos are arrows. C6 H14 is converted into C2 H4. That is a reaction. There is also other stuff that I do not have to worry about. Basically, this means that I have one mole of this that is converted into one mole of that. The ratio is one to one. If the yield of this process is 42.5%, what mass of this starting material, which is called hexane, must be there to produce 481 grams of the product, which is called ethylene. So, in other words, your boss tells you, I need from you 481 grams of ethylene. Okay? And he also tells you what. This reaction is on very efficient. Efficiency is exactly 42.1, 42.5. And I want you to determine how much hexane do I need to pour. Can you give me that answer finally? He said, ah, I can do that. Come on, I need only three. All right. So what you do is this. Okay? You would like to know how many moles of the product do I need? How many moles of the product do I need? Again, grams, you want to move very quickly, convert grams all the way to moles. So, something like a countable number, which is moles. 48, 481 grams divided by the molar mass of ethylene. Okay? Which is 28.05. Says 70.1 moles of ethylene. The boss apparently needs 70.1 moles of ethylene. That's what he needs. So that means if you have 70.1 moles of ethylene, how much starting material do we need? Well, the reaction says it reacts one to one. One mole of hexane, the starting material, the reagent produces one mole of this. Okay? So, if this reaction were to be one hundred percent efficient, you would need 70.1 moles of the starting material to react one to one. 70.1 moles in, 70.1 moles out. Okay? However, the efficiency is 42.5. So, you have to take that into consideration. Apparently, you need more than 70.1 because efficiency is rather large. So, how do you do that? Okay? So, this is what I just said. So, take into account the yield. The yield expressed in a fraction times the amount that you need will be 70.1 moles. Okay? You need 70.1 moles. That should be the outcome. Okay? You need 70.1 moles. But you need to put more in because you multiply something as small as one. Okay? So, the fraction corresponding to this percentage is 0.425 times the amount that you have to put in should give you the amount that you have to give to your supervisor. So, that means the amount that I need, I can quickly calculate, 17.1 moles divided by this fraction 40.2 moles is the amount you have to start with. Now, this is the amount of moles. The question also says, I need it in grams. So, what you have to do is, you have to multiply this by the molar mass to get the amount of grams in grams. Is this set clear? Does that make sense? Alright. So, the multiplication of the molar mass you can do for yourself when you have the answer. So, we just move on to this. This question. This question is the same kind of question, but the phrasing is a little different. Now, don't be shaken by this. It is again the same kind of thinking. And the reason why I like this example is it forces you to really think about these things as countable objects. Some of this, some of that, the reactometry and so forth. Okay, so here's another reaction. Methane reacts with oxygen, combustion reaction with methane. CO2 and 2H2O comes out. I have to determine the number of excess reagent. So, excess reagent means what is left in the pot after this reaction is over. Okay? How many do I have in the beginning? Well, it says I have 70 molecules of methane and 142 of oxygen. The funny thing about this question is it doesn't say how many moles you have or how many grams you have. Okay? That is another problem. That's the same thing. Another molecule suggests another molecule. But it is specified in an actual number for a mole that doesn't matter. Irrigate with the numbers. Okay, so what I have to do is to determine which one of these reagents is the limited area. In order to do that, I play the same trick as before. I want to know what is the mole ratio between these two guys according to the equation, the balanced equation. It says you need two moles of oxygen for each one mole of methane. And that means the ratio of 0.5. If you put methane on top, the ratio will be 0.5. The next thing I'm going to do, so this is the mole ratio. Mole ratio. I want to determine the mole ratio that I actually have. Again, the number of moles is not given. The number of molecules is given. But what is a mole? A mole is a number. It is 6.05. So, we're at 6.02, the time is 6.33. So, I think you can convert this to moles if you want. You multiply this by moles, by a mole number, this by a mole number. But the ratio will change. Because if you multiply this by a mole, this by a mole, you divide them out, you just see what I'm saying. The ratio is determined by the proportionality between the two. Whether you have a mole of it, or just a countable number of molecules on your fingers, the ratio is still the same. So, I can determine the mole ratio simply by dividing the quantities of these numbers. Of the number of molecules that I have. Okay? So, let's just move on with this. So, 70 molecules of CH4, 142 molecules of O2. So, this is the actual mole ratio. Not given in moles, but in just molecules. Because the ratio between molecules and the ratio between moles is the same. Okay? I can convert this to moles if you want. It doesn't matter, because you convert also this one to more. The ratio between the two is 0.49. 0.49 is a little bit smaller than 0.5. I think the numerator is the limiting reagent. I eat the molecule of one dot first. You will burn through the 70 sooner than you burn through the 140. Okay? So, it's a smaller than 0.5. That means CH4, methane, is the limiting reagent. That means the other guy is the excess reagent. Okay? This O2. That means I have something left in the pot after the reaction has completed. Okay? So, how many molecules of oxygen did react? Same kind of calculation. 70 molecules of methane were there. That's the limiting reagent. I will convert the number of reactive methane to the number of reactive oxygen through the mole ratio. Okay? Two molecules of oxygen for each one molecule of CH4. That's what the equation says. That's the ratio between the two. For each one molecule of methane, any two molecules of oxygen. So, each one molecule of methane, two molecules of oxygen. This one goes at the bottom because I want to cross this out. I want to go to the number of molecules of oxygen that has reacted. 70 times 2 equals 140 molecules of oxygen have reacted in this process. Okay? So, how many do I have left? Yes, you have 142 minus 140, two molecules of oxygen. Now, mind you, this is exactly what we did before. Previously, we did it at quantities expressed in moles. Now, we do it in the physical number of molecules. But it's exactly the same because you work with ratios. You work with ratios. So, you're going to replicate them exactly the same. I'm going to do another one which is virtually the same. Just to get used to this. The same kind of question, a different reaction. This is also open-bush reaction. It's a different kind of molecule. But the derivative of this should be the same. Okay? Calculate the number of excess reagent molecules after this reaction has proceeded. I'll do the same thing again. First, the mole ratio according to the equation. The equation says two moles of this reagent for each 15 moles of oxygen that ratio is 21.36. That's what I call the Bellos ratio. The ratio stipulated by the Bellos chemical equation. Then, I want to see what I actually have. What is the ratio of the chemicals to reagents that I actually have? Well, here are the numbers that I actually have. Okay? The same kind of calculation. 74 divided by 585 equals 0.126. This number? Less than that. That means the numerator is going to be my limiting reagent. Okay? So, C5H10 is the limiting reagent. You can always determine how many molecules have reacted. All the limiting reagent react, and when the limiting reagent reacts, it takes with it, in this ratio, the oxygen. That means it's compared by how many oxygen's have reacted in the process. So, that conversion is, again, number of molecules of limiting reagent is reacting. It takes with it, for each two of this, 15 molecules of oxygen. That's the mole ratio of the two molecules. Okay? So, 74 molecules of this reagent react in this ratio. Each two molecules reacting take with it 15 molecules of oxygen. That means 55 oxygen molecules have reacted. The conversion here is from number of molecules of C5H10 to number of molecules of O2. O2 goes on top. This guy's going at the bottom. This is what I'm always doing. We need to convert from one quality into the next. How many did I have in the beginning? 585. This many have reacted. So, 555 minus this 30 molecules of oxygen are left. They cannot react. Why? Because there's no other reagent anymore. It can't go on. Okay. I think we've got to run for it. I do one more of this, and then we'll do a final thing accepting SSI. Okay. So, we do it all quick. Another reagent is safe. Unlike repetition, it really gets you into the mood. And these, like I said, dissolve white foam. Okay. So, another compound reacting with an oxygen oxide producing these two compounds. And again, I've got the excess reagent. So, he is the truncable limited reagent. What you do is look at the mole ratio before we get up to the chemical equation. Two to ten, at least, points. You compare that with the actual number that you have. Okay. That is, this number, compared to that number. Whether the number is stipulated or given in grams or moles or number of molecules, it doesn't matter. It can give you a ratio. Okay. Grams always have to be converted to moles first. And then you get the mole ratio. And the number of molecules that have a number of molecules is also mole ratio. This number divided by that makes you 0.182. Sorry, 181. That is less than 0.2. That means numerator, again, is the limited reagent. You have all the numerators here. So, there are numerators always the limited reagent. You could have as well been the denominator. In other words, it just happens to be the numerator. Okay. So, the numerator is the limited reagent. In this case, this is a di-I-D pentoxide. That means I take the number of limited reagent, okay, and I convert that into the number of excess reagent. Reactive. How? Multiply that in a ratio. So, I take the number of the three units of this, I take with it 10 units of nitrogen oxide. This times that gives you the number of nitrogen oxide mole to mole with half the reactant in the process, 980. This is the amount that I had in the beginning. So, I take that, subtract this from it. I have exactly 100 units left. Units is nothing but the mole. Okay. So, this is the flow of these kind of aeroexercises. You can see that, and hopefully that will not be too hard for you. Okay. So, let's do a couple of minutes. Let's say there's no life that we have. We apply to an actual problem. So, the problem of exploring cars. So, we've seen it in some of the movies. We've seen it in some more of the left and right. The same question we've been trying to solve before the problem. It seems like it is extremely easy to realize. Take a car and explore it. Let's see if this really is that easy. Okay. What happens in this process is there's a chemical reaction. One is exploding, gas will leave. What does gas leave? Mostly, captain. That's captain. And it reacts with oxygen. That's the arrow that should go to the right. And it generates C2O2 and H2O2. This is combustion reaction. And it's boundless being all red. So, when does this explosion happen? It happens when this, the meeting of O2, but half day, is very efficient. So, if these chemicals are present in the right proportion, they can very actively react and explore. If there's not enough oxygen or not enough captain, then the chemicals have to wait till they leave and it slows down the process of the laserous process. So, what I really want is I want this reaction to be complete. I want the reagents to be present in the right proportions and, in the optimum, react with conditions. That's a long way to say that what I need is, for each one mole of heptane, I need 11 moles of oxygen. That's what I want in my tank. So, let's look at that. Here's a tank. A typical tank is about 14 gallons, converted immediately to metric units. It's about 53 liters. This is a very rough definition. Let's make it a 9-number, 53 liters is the approximate volume of a typical gas tank. The density of heptane will need that, this number right here, given in grams per mil. And the density of oxygen is also given, remember oxygen is a gas, okay, so that is 22.4 liters per mole. And here's the reaction once again. So, what do I need? Well, I just said it. What you want to do is you want to have quantities of oxygen and heptane that are correct for reacting explosively. That means 11 moles of oxygen for each one mole of heptane. So, the ratio needs to be 11. Okay, now let's see intuitively, we think this is what your first gas would be. I need as much heptane as possible to invest, explosion time, completely fill the tank. So, let's do that. Let's assume the tank is a 24, because I think in that case, more heptane means bigger explosion. So, 53 liters, that's the whole thing, tank, it's all full of heptane now. How many moles of heptane is that? That's a couple, I think. So, the gas times the density converts a volume into a mass. So, I multiply this by this number here. This is the density, 0.684 grams per milliliter or kilograms per liter. Remember, grams per milliliter is the same unit as kilograms per liters. It has the same value of the density. The value of the density is the same, it's expressed in kilograms per liter, more grams per milliliter. Or you can use that, and that's helpful because this is liter times liter, so this crosses out, now you have the mass of heptane in the tank. Okay, if the mass is expressed in kilograms, I can express mass in moles by the value of the volume, mole mass. So, watch out if you can do that correctly. Usually, the mole mass is given in grams per mole, but now I'm going to do kilograms per mole. So, that means you divide it by a thousand. The kilogram across out, what you get is moles of heptane. Same calculation that we did. You have the mass, you divide it by the mole mass. The mass is known as kilograms divided by the mole mass, and you can express in kilograms per mole. Heptane is about 100 grams per mole, that means 0.1 kilograms per mole. I find 3.6 times 10 to the second mole of heptane. So, this is the amount of heptane that I got. Okay, so I need relative to heptane, 11 times more oxygen for this we have to have. Well, the problem is, I don't have any oxygen because the thing is full. There is no oxygen to react with. The thing is completely full, there is really no oxygen that can officially get to the heptane. It's not in the same place. This is a Q student pipe, that's R-I. There's no oxygen there for all the molecules of heptane to react with. So, this is absolutely not the situation that we're dealing with. If you're dancing to school, you're very sick. You're a lot of swell. You can fire for yourself, you can make a car of fire, you can make a car of speech, you can see, boom, swell. Make sure you jump out before the falls. So, what we need, what we need is we need more oxygen. Okay, we need more oxygen to live here because the reaction needs oxygen, there's no oxygen in the present yet, so I need to get some heptane out and put some oxygen in. Okay, so let's assume for the following, let's say I have only one liter of heptane there for me, and let's assume for all kinds of purposes that the air is 100% hydrogen, which is not sure. Well, that's just a super-design. One liter of heptane in tank, one liter, it'll be the same calculation, let's see how many moles are there. One liter times the density gives me mass, mass divided by mole, mass gives me moles. I complete this calculation, I find 6.8 moles of heptane, not that the quantity of heptane. And now I need to see how many moles are hydrogen. So, let's see, if this is one mole of heptane, the total of 53, so that means 52 liters is hydrogen, and I assume now, again, all the air is hydrogen. It's not sure what it's going to say. So, let's just do that. So, what I do now, I convert liters directly to mole, because I have this conversion here, 22.4 liters per mole. So, if I multiply 52 liters by this conversion factor, I put liters at the bottom and mole on top, I directly convert the mole. I find 2.3 moles of hydrogen. So, 52 liters of hydrogen gas, apparently, is 2.3 moles. Well, due to the division in 2.3 moles by 6.8 moles of heptane, it's 0.33, I need 11. This is W plus. So, even in a situation where 100% oxygen in the air, one liter of heptane is maintained, and it won't explode. Very very unlikely. So, when it actually does it, I want this thing to explode. I'm not giving up. So, I'm going to take almost all the heptane out of the tank. Let's just say that I, you know, I think it's almost completely filled with oxygen. That means 53 liters is now oxygen, and I'm going to convert how many moles that is to the same calculation. 53, this conversion factor from up here, this one at the bottom, this on top, gives me 2.4 moles of oxygen. So, I have 2.4 moles of oxygen in my tank. How much heptane do I need to make this fully react? Again, under the assumption, there's 100% oxygen in the air. Okay, well, the ratio needs to be 1 to 11. 1 to 11. What we need is 2.4 moles of oxygen. I take the ratio of oxygen at the bottom, 11 moles of oxygen for each one mole of heptane. So, effectively, you divide this thing by 11. Okay? This here is the number of moles of heptane. Okay? I multiply that by the molar mass. That means how many grams I have. So, this is the mass of heptane. Okay? And then I'm going to multiply that by, let's see, by this density conversion. So, I convert the mass into volume. So, I divide it by the mass. So, I'm going to do a free conversion here. First, from number of oxygen to number of heptane that I need, moles of heptane converted into grams of heptane, and then mass, grams, converted into volume. Through the density, I divide that by this. You see, grams at the bottom across out, I need a time to answer in milliliters, 32 milliliters of heptane. 32 milliliters is about a quarter of a total. Okay? 1-eighth on a cup. 1-eighth on a cup is what you need approximately to have 2.4 moles of oxygen to react explosively with heptane. Okay? So, that is basically what it says. You need a small fill of gasoline on your tank to make that thing explode. And then you also need about 300 percent oxygen in here. Then you can have a very, very strong flow of oxygen. So, less is better, less is better. Alright, so this is an example of calculations. It uses mole ratios. It also uses things like this, volumes, densities, right? These are things we have seen in the first part of this class. We're getting close to the first couple of lectures. We're all about densities, volumes, so forth. This is a real-life situation. You could do these calculations with the tools that we've talked about. One more question. Yes? Yes, hold on a second. There's a nice question here. Okay? So, does that necessarily mean that with, you know, the degree of the particles on my tank, it's really more density? The question is, why does it explode in a movie? Well, first of all, in a movie, it's for the good sticks of dynamite, to make it explode, right? But particles can explode. And typically, it comes to explode when you have a leak, and stuff drips from the floor. It's a small film with what you did, and that's what it's set up. It typically in itself, it won't have conditions or something. Okay, whoa!
UCI Chem 1P is a preparation go General Chemistry that covers: units of measurement, dimensional analysis, significant figures; elementary concepts of volume, mass, force, pressure, energy, density, temperature, heat, work; fundamentals of atomic and molecular structure; the mole concept, stoichiometry; properties of the states of matter; gas laws; solutions concentrations. Course may be offered online. Slides: 00:07- Fun 02:08- Puzzles 02:54- Balancing Equations 07:15- Limiting Reagents: Diagrams 09:50- Limiting Reagents: Cl and O 18:42- Percent Yield 22:46- Example Problem: Excess Reagent Molecules 28:06- Example 31:03- Example 33:31- Exploding Cars 35:23- Exploding Cars, Slide 2
10.5446/19451 (DOI)
Okay friends, today a very important lecture for your chemistry brain, about chemical reactions. This is definitely not an important topic to chemistry because this is what it's all about, reacting molecules forming new compounds. So just to summarize what we've done so far in this course, you know we started talking about atoms and the way they were built, we've got technologists, up on the stand, identified them at the PR table, and I'm building molecules from new atoms and ways to draw these guys. And then also, this week we started doing sort of calculations with molecules in terms of finding their masses and calculating what is the percentage of a certain atom in a particular molecule. So these kind of calculations should be familiar. So this kind of like sets the stage for the next step, which is when molecules start to interact with one another. Okay? So let's look at these two guys. I have two hydrogen molecules here. This is one, and that's one. Each of these molecules is two hydrogens together. So it's a term of two molecules here. So we interact with oxygen, okay, and then form this, two water molecules. So you see there's red spheres, are the oxygen, they are now in the water molecule. Those hydrogens that were originally associated with one another in hydrogen molecules are now part of a completely new structure. So this is a very nice example of a chemical reaction. You see those atoms are rearranged to form different compounds. Okay, so that's basically, that's the basics, right? I think you know that concept. Let's look at another one. Oops, let's look at some kind of examples of important reactions. Actually, reactions are just everywhere. You can just look in your kitchen and it's all about chemistry right there. What happens in your engine is pure chemistry, it's a combustion reaction that makes you be able to get here. Photosynthesis is a very nice, beautiful example of chemical reactions. Formation of oxygen on a CO2 and formation of sugar. And this is a very nice one, an atlator in brown. It's a chemical reaction. You see, something happens through the surface that is a pure chemical effect. If you don't expose this thing to oxygen, it doesn't happen. So this is a reaction to oxygen in the air. Okay, so reactions are just everywhere around us without chemistry. Your body can work with all the rocks in the dead. So this is just a very important moment that you are here, right? A place talking about the world of liquid. Okay, so people have thought about the idea of chemical reactions, how to understand these things, and how to do calculations with them. Here's one of the pioneers, Antwoch Leibler-Ga, the instrumental friends. Long time ago, back in the old days, people emerged from the Alpine practices and put themselves into more, I would say, scientific researchers. People that stuck to particular methodologies very nicely and figured out what they did and figured out how things work. If you put certain things together, you get a new compound. Okay, so let's look at another chemical reaction. We saw the first one was very simple. It was hydrogenated with oxygen. Here's another one. This is methane. This is a carbon in black, and those white knobs are the hydrogens. If you let this react with oxygen, in fact, this is a hydrocarbon that is reacting with oxygen. That is called combustion of the oxygen. This is the combustion of methane. Okay, so methane is interacting with oxygen to form CO2 and H2O. Carbon dioxide and water. Those are the products of the combustion reaction of a hydropower. Alright, so we can write this in terms of molecular formula, and this is a bit called chemical reaction. Chemical reaction says on one side are the reacting species. Those are the reactants. In this case, CH4 is methane and oxygen. Oxygen 2, because that's the oxygen molecule. Look at this symbol here. This means it's in the gas phase. We know that in these reaction equations, we always indicate the phase of the compound. Then arrow to the right, I mean this way, the reaction, and the CO2 and F2 are here. Also in the gas phase, and H2O and water, this guy also in the gas phase. These are all the products. So on the left, we have the reactants, and on the right, we have the products. And there's a right arrow in between. Makes a lot of sense. Alright, this is all good and well, but if you look carefully, you see something is not quite right about this picture here. For instance, I see two hydrogens there, but I see four there. Yeah, this one is not balanced. This is not a balanced equation. Another problem is I have two oxygen, and I have one, two, three. It doesn't make any sense. I can't create out of nowhere oxygen F. So something is not right, and what is not right? The reason why it's not right in me is this reaction is not balanced. We have to balance this equation. So let's look at that for this particular reaction. It turns out to be fairly simply balanced. What's the other one? What if I have two of these oxygen molecules? So that means one, two, three, four oxygen atoms. Okay? Then I can form the following. I can form, again, one two molecule, which is using up one, two of the oxygen, and one carbon. Then I have two more oxygen atoms, and four hydrogen atoms. And from them, I can make these two water molecules. So we used all the atoms that we had at the beginning, and we formed new compounds. So that's what accounting here. This is basically what the chemical equation says. CH4, and then two oxygen molecules. That's why there's a two there. This is called the stoichiometric coefficient. The stoichiometric coefficient, two. One CO2 molecule, and two water molecules. Again, this two right here is called the stoichiometric coefficient in front of the water. Alright? So we can quickly verify this is correct. So let's count the number of carbons. I see one here, one there. Let's count the number of hydrogens. Four, two times two is four, four hydrogens. And here I see four oxygens, two times two is four. And two here, this two, also applies to this oxygen, okay? Two oxygens from the water, and two oxygens from the CO2. So this is a balanced equation. Okay, so why do these equations tell us? They actually tell us something very, very interesting. Alright, so this is the reaction again. That means one molecule of methane reacts with two molecules of oxygen to form one molecule of CO2 and two molecules of water. That means if you multiply or molecule by any number, 12, or Avogadro's constant, which is the mole number, this is a p-hole. So in other words, one mole of CH4 plus two moles of O2, then I will be getting one mole of CO2 and two moles of water. It just multiplies this whole thing with a number. Then I chose to multiply with the mole number. The ratio is the same, right? It doesn't change. So one mole equals this many molecules, right? Because that's what a mole means. So this many molecules of methane plus two times that many molecules of oxygen gives me this many molecules of CO2 and that many molecules of water. I can calculate how much these molecules together, how much they contribute in nets, okay? One mole of methane, I can calculate how much that is, that is 16 grams, okay? Roughly 16 grams. Why? Because that's the mole mass of methane. 12 plus 4 times 1 is 16. Okay? So that's 16 grams, that is the mole mass of methane. Then I had one mole here. I have two moles of oxygen. Oxygen 2 has a mass of 32 times 16 times 2. So this here together, if you add up these masses, you get 80 grams of reactants. So I started out with 80 grams of reactants. That's what I started out with. On the other side, I see one mole of CO2 has a mass of 44 grams. That is the mole mass of CO2. I'm going to do it carefully because I've previously already filled it. And then two moles of water has a mass of 2 times 18, because 18 is the mole mass of water times 2. If you add these numbers all, you have 80 grams of products. This is not an accident, right? This is not an accident. And there's conservation of mass in a chemical reaction. What does that mean? It simply means that you don't add or take anything away in terms of the number of atoms. The number of atoms is conserved. It just narrates these things. You don't destroy your containing atoms. It is just rearranged. So another way to do that, to kind of explain that to my dog, for instance, which side results, you can do the following. Let's say, this is actually our first loop log loss. I took this photo with my own camera just to explain to her concept of chemical reactions. I think she got it though. CH4, look, CH4. This is my carbon. One, two, three, four, kind of news. And then two oxygen molecules. This is one oxygen molecule. Two oxygen atoms, oxygen is orange. Now what I'm going to do now, this is the key step. I'm going to take this apart like that. And I'm going to build something else. Yes. CO2 right here, and then two water molecules right here. I used all my bricks. There's nothing left. I have not added anything to it, nor taken anything away. I just rearranged these atoms. This is exactly the same as with the actual atoms. This is exactly the same as with atoms. So I'm sure you have this reaction. But really, you can think of it as like taking everything apart and rebuilding. So we come from the reaction of these. All the compounds are rearranged. The making of compounds, the number of atoms is conserved, and hence the mass is conserved. The mass of the reaction and the mass of the product is the same. Conservation of mass. Okay, now let's look at a particular example. This is actually kind of a summary of the goal to do now. So if you want to balance a reaction, typically this involves a piece of text. From a text you have to kind of write down the chemical equation and then balance. So first you want to know what kind of reaction is happening. Write down the reactants and products in the physical states. Identify what are the reactants, what are the products. Then you write on those equations simply meaning the reactants to the left and the products to the right and arrow in between. And then you start to balance the equation. Now this whole conservation which you can do it, my recommendation is you just iterate until you find the solution. And some people have nifty methods of that. I'm not sure if I like to advocate one particular one. But what you want to do, you want to start with the most complicated or the most exotic atoms. And then always end with either oxygens or a kind of atoms. Because those are usually the ones that are most abundant in the equation. Those are the ones you can kindly balance the equation with. Make sure the exotic atoms are always balanced first. So let me show you an example of products. Here's a particular reaction. It says I have a solid ammonium dichromate which can be ignited. And when that happens it forms nitrogen gas, water vapor, and solid chromium oxides. But I have to do this to write down a balance equation. So we're going to balance the equation here. Interestingly, this particular example you see in a few moments, there's only one reaction. And that's possible, right? I can just one reaction that just falls apart under the influence of heat and forms new products. I don't always need multiple reactions to form something. So this is just the side number. Here's a couple of pictures. So when it looks like this, orange stock is ammonium dichromate. Right there. You can set this, you can ignite this. And this kind of like blackish dark grayish cold is the chromium that we are starting. You can also put it in a nice heap. And then you ignite in the middle, you get a nice little hole in the panel. Which is why this reaction is called a volcano reaction. Okay. So what we have to do first is to determine why are there reactants and what are products and what are their states. Okay? Reactants is only one. This thing, ammonium dichromate, there it is. And it's solid because it's given in the particle. There's no more reactants. So I move on to the products. The products are kind of three. Magnesium gas, it says. Water, gas. And chromium 3-oxide. Chromium 3-oxide. Okay. So these are the reactants and the products that I have. What I have to do now is to put it in a unbalanced chemical reaction. Chemical equation. So that is not difficult. Let's put this guy to the left. And these guys all together to the right with an arrow in between. Put the gap, this. Alright. So next, or if you'd like to balance this equation, it's not balanced. I can tell you that immediately. For instance, I have a lot of hydrogen here. Eight. And I only have two here. But clearly something about balance here. So what do I do? Well, let's first start, like I said, with the most exotic element. And not with oxygen and hydrogen. So we start first with nitrogen and chromium. Let's see what they're all doing. So I count two nitrogens here. Why is it two? Because there's a two there. This whole thing is basically a multiply by two. That means two nitrogens. Don't be fooled here, okay? I'm saying this is only one. There are two. There's also two of this side. That's pretty good. It means nine minutes' balance. Chromium, I have two. I also have two there. Great. Also two that means I don't have to change that for now. But then the problem starts. I have seven oxygens here. I have three there and one here is four. So four on this side, seven there, not balance. And also the hydrogens are not balanced. Because I find two times four is eight. And I see only two there. Okay? So three here, oxygen, one there, and two hydrogens. Okay. So my first guess is the following. Four hydrogens. What about these two there? So I need eight hydrogens in total. I have two here. I can put a four in front of this. Like that. I have eight hydrogens. Right? So that means my hydrogens are balanced. But what happens to the oxygen to this day? Four times O is four oxygen and three, low in the wolf. That means I have seven. That's all I have to do. I just have to put a four in front of my wire. And I have six. Okay? So this reaction now is balanced. And again, typically you balance an equation with oxygen or hydrogens. Those are the ones you want to multiply. Okay. So this is a balanced reaction now. Now let's move on. Let's move on. So here's my balance equation once again. This is my star material. Beautiful orange. I'm moving back home. Looks yummy, but don't eat it though. Not good for you. It's 15, let's say I'm 15 grams. Let's say I'm 15 grams. I'm going to do this reaction. And at the end, I have chromium-3 oxide. This two here doesn't mean it's chromium-2, right? You know that, chromium-3 oxide. So we have a capital N. So here it is, but the question is, how much do I have? What if I have 15 grams at the start? And I want to calculate how many grams of this product can I make given about 15 grams at the beginning? You can't really say that straight away. What I really have to do here is to follow it. 15 grams means 15 grams of this. It doesn't even tell me how many atoms I have. But that's really what I want to know. Remember, it's all about taking atoms apart and rebuilding something else. So what you want to know is that the number of grams, how many of them are accountable objects? Masses are not accountable things. Because each molecule has its own mass. Each molecule has its own mass. You can't simply add up masses of two different molecules and then figure out how much you generate in a second or a third of a molecule. What I want to know is how many of these molecules are in 15 grams. Once I have enough moles of molecules I have, and atoms I have, I can determine how many of these guys, the moles of the product I generate, the ones that are the number of moles accountable things of my product, I can determine what is the amount of grams of the product. So there's a flow of convergence here. You'll see in the two examples, two important examples here, flows of spores, you have the amount of grams of your reaction. You do a conversion into the number of moles. The number of moles of the reaction is related to how many moles of the product you generate. Then the number of moles of the product is converted into grams of the product. You do three conversions. And I'll show you how to do this. Okay, in these calculations or in these determinations we have to do conversions. The conversions are as follows. The amount of moles is the total mass of what you have of that particular compound divided by the molar mass of the compound. That gives you the number of moles. And we've done this this week several times. And then the other one is from moles to grams. It's a reverse basically. The total mass of the compound that you have is the amount of moles of the compound times its molar mass. These two relations are of course the same. I just reorganize. The three variables are the same here. I just reorganize them. I took out the grams to moles and the moles to grams. Okay, so keep these conversions in mind and you'll be doing the following two examples. And some of these will be your homework five. Okay, so the arrays of the molar are generally breaking because homework five last four questions are a whole lot more than a liter. Okay, so here's our reaction volts again. This is what I really wanted to do. Same reaction. And I say I have 15 grams of my starting material among that permeate. And I'd like to determine how much of this chromium free oxide I have in grams. Okay? Now, the first thing you have to do is to move away from the grams which is not a countable quantity if you compare the two molecules. But atoms and molecules are countable objects. Those two are not. So what you do is you'd like to determine the number of moles of this stuff. Okay? The reaction is already balanced, so that's good. I convert the known mass of the reactions into the number of moles of the reactant. Here it is. 15 grams of my starting material. How do you convert that from grams to moles? So you divide that by moments. Okay? This is the molar mass. So you divide this number by moments. You can see if you write it out nicely, but the fact is you beautifully have these grams cross out and you now have your number expressed in moles. Okay? So this conversion allows you to calculate the number of moles of ammonia electron. 0.0595. So the first step you take, move away from grams and move to moles. Then what you'd like to know is, given the amount of moles of your reactant, how many moles of the product do you want? Okay? Well, let's have a look. One mole of this makes how many moles of these things? I have to look at the stoichiometric coefficients in front of these compounds. So for each one mole of this, I make one mole of nitrogen gas. I make four moles of water. And for each one mole of this, I make one mole of chromium bioxide. Okay? Now, look at this. What you can do now, you can relate the number of moles of this to the number of moles of any of these guys. You can actually make a unit factor or convert the factor. This is a relation. One mole of this equals, for instance, four moles of water. One mole of this equals one mole of that. I can use it as a unit factor and then convert the number of moles of the product to the number of moles of the reactants to the number of moles of the product. Let me show you how to do that. So what I do is I'm going to say this is the number of moles of reaction. The number of moles of the reactants expressed in this unit here, I like to convert that to the number of moles of the product. So let's do them all. Let's do first conversion to N2. For each one mole of N2, I found one mole of this. So the ratio is one to one. This is a unit factor. You have a relation on the slide. This is the second one. This unit here, one mole of this, is the same as this. So this unit crosses out. This number times this is going to be the number of moles of N2. That's it. 0.0595. I converted the number of moles of reactants to the number of moles of the product through this relation. That's my conversion identity. Okay, let's do the same one for water. For each one mole of a mole in dichromate, I add four moles of water. So four moles of water in a tub, because I want to go to water and move away from this. This one goes in the bottom. You see this one is crossing out. The unit of moles of the reactant is crossing out. There's this, and now there's moles of water. This times that number equals the number of moles of water. 0.238. And I do exactly the same for the last product, chromium-phozoxide. That had this identity, one mole of chromium-phozoxide, or each one mole of the reactant. This is the unit after here. That was the one-to-one. It could be anything else. This is basically the ratio of the stoichiometric coefficients in the equation, you see? That's why the stoichiometric coefficients are so important. So the number of moles of chromium-phozoxide is, again, the same, 0.0. 5.5 moles of chromium-phozoxide. Alright, I'm not there yet. I was asked to calculate the amount of grams, not the amount of moles. So I have to do one more conversion. Namely, converting from moles to grams in each of these compounds. So let's do that. This many moles of nitrogen, I've just calculated it, times the molar mass of nitrogen. Okay, this is 28 grams per mole. The mole's dropping out. I get 1.67. So I used both conversions, right? First I went from grams to moles, and now I'm on moles to grams. Okay, 0.2, 3.8 moles of water. I just calculated that in the previous slide. Times the molar mass of water, 18 grams per mole. And you find 4.29 grams of water. And the last product, which is the one I was really interested in, is this many moles of chromium-phozoxide, times the molar mass of chromium-phozoxide, 1.52. And I find 9 grams of chromium-phozoxide. Alright, now in this particular case, I can do a quick chat. Okay, because I only had this reactant here. That means on the reactant side I had 15 grams. That means on the product side I also had 15 grams. If you add these guys up, because a couple of the amount of grams in each of these guys, you add up to 15. Here's a take, extra-revolving. And you can see that that is the squaker, and you can see that that's the partial reaction. Okay. So let's do another one. This calculation is exactly the same, but this calculation is so important that I really wanted to get a few questions. If you get this right now, you will use a very important calculation. Okay, another compound. This is a chemical reaction. I have here two cell materials. One potassium compound with platinum anion here, and I find here the ammonium oxide. Those are two reactants. And I make this product here, which has a name that is cisplatin and potassium chloride. Okay. So in this case, two reactants and two products of compounds. The question is, how much of this stock, this guy here, can be made if you have 100 grams of this stock? And what mass of this potassium chloride is also full? That's exactly the same question. There's one more piece of information to mean, actually, for this, and that is that there is enough ammonia in the pot to convert all of this one into grams. Some explicitly stated here, but that must be the case, otherwise we cannot execute this calculation. In other words, the full 100 grams of this starting material is converted into these two guys. All right, so what do I do first? Make sure that I look at the balanced equation. Why does the equation need to be balanced? Because I need those stoichiometric coefficients. Okay. And I'm going to relate the number of moles of the reactant to the number of moles of the product. I need to know the ratio of the stoichiometric coefficient. The means, the reaction has to be balanced. Won't work for an unbalanced equation. This one is already balanced. Okay. You can try to find it for yourself. This is a balanced equation. You can count the number of apps. Okay. So, second step. I want to know how many moles of this material there are in one of the grams. I don't want to work with grams. I want to work with moles. Because I can only relate stoichiometric coefficients on a level of moles. Okay. So, the ratio is called the mole. You have to move away from grams to virtual moles. Then the ratio is going to be back to grams. Okay. So, 100 grams of the starting material. How do you convert that? Well, I have to divide this by the normal mass of this stuff. Okay. So, it's about the fair table. Calculate the molar mass. And it happens to be 415.1 grams per mole. Okay. If you punch that into your calculator, you'll find 0.241. All right. That's pretty good. The next step then is to determine the amount of products that you've been formed given this much of the starting material. So, what I do is, one mole of this material makes one mole of this is platinum and two moles of protection chloride. Because there's a 2 there. So, this is the identity basically. And from there I can make a conversion factor, a stoichiometric ratio, or another work of that is called mole ratio. And the mole ratio will be very important to talk about it sensitively. Okay. So, I'm going to make a conversion then for real. So, here I have my starting material. I want to convert moles of the starting material into moles of cisplatin. To do that, I make conversion. The conversion must come from identity, which is the stoichiometric ratio. One mole of cisplatin for one mole of the starting material. One to one, the number remains the same. 0.241 moles of cisplatin. And since we're at it, let's do also the protection chloride. And it will be exactly the same calculation. Okay. The number of moles of mariathum converting into the number of moles of the product through their ratio. That's the ratio. So, we have two moles of potassium chloride for each one mole of the starting material. Of course, this thing has to go on the top, right? Because we want to go from the whole material to the product. So, the conversion has this potassium chloride on the top. 2 over 1. You just multiply this number by 2 basically. You only find 0.482. The number of moles of potassium chloride. Okay. So, now I have the number of moles of both of these guys, both products. And the only thing I have to do now is to do a final conversion from moles to grams. That involves multiplying the number of moles with the respective molar masses. Here, the number of moles of cisplatin converting to among grams by multiplying that by the molar mass. The molar mass is always grams over moles, right? So, moles crossing out, and you find grams as the units. So, multiplying this number by that number gives you 72 grams, 72.3 grams of this product cisplatin. And to find the potassium chloride, it looks exactly the same, right? The number of moles of potassium chloride that I found, which is more than this, right? Because the ratio of the two here, not one. So, I have more moles of the case of Yaw. I have four more of these guys, and I have four more of this. To find the number of grams, I multiply that by the molar mass. 74.5, that is the molar mass of potassium chloride. And we'll take this calculation, which is 35.9 grams. Now, a quick check, okay? You see the real understanding. The molar of grams of this, if you add up these two numbers, I get more than 100. How can that be? Did I make a mistake? What's the problem? Why did I get more than, I just told you, this conservation of mass. Now, I find 100 grams of the sodium material, and I find more than 100 after. The calculation of how this is done, right? Well, the thing is, of course, this. This thing here, we didn't specify. Alright? This one has mass, too. If you add it up, put that number to calculate the total. So, we didn't say anything about this. We just said there is enough of this, such that everything that is here can react. If you calculate how much of this you use, it turns out to be exactly the difference between 100 and this number. And again, total even search, the mass of this. But this is just a looking out to do a quick comparison to check if the mass is the same. Make sure to take the mass of all the reactants in the consideration, right? Okay. So, I'm going to end by doing the same calculation fast. And here you can see kind of the flow of the actual process that we've taken. Right? So, to calculate the amount of grams of this value, what I did is, I started with my stalling material, 100 grams. The first step I took was to convert that rapidly into number of moles. I didn't want grams of 100 moles. So, what I did is this kind of conversion. Now, this number is given in moles. Moles of the stalling material. The next conversion I did is converted moles of the stalling material into moles of the product through the ratio. That was this idea. And you look carefully, you see, moles of this process out, and I convert my number into moles of the product, cisplatin. So now, after completing this whole thing, I have number of moles of cisplatin. The next conversion is from moles to grams. Okay? And that means grams goes on top, number of moles at the bottom, you basically multiply it and multiply it. That's what we did. You see, we did three conversions. From grams to moles, moles of the, of the reactant to moles of the product, that's the middle part, so product to grams of the product, that's the third part. Okay? Completing this calculation, 72.2. And we did exactly the same for the second product, which was potassium chloride. Start out with this, convert it quickly again, exactly the same step, right? Into moles, then convert number of moles of the reactant to the number of moles of the product. That was a picture of the two-fold line. That's why this two-fold line, you need to look at the balance of the weight. This will not regularly come down to the weight. You need to know the social network of fishes. And then to find the number of grams, you multiply the number of moles of the product with the number of grams. That's not, I'm sorry, the molar mass of KCl. And that is 35.1. So if you can do this, that's all there is to it, it's all story, right? These converges, these converges. Try to understand the principle behind this, and why this is so. Alright, we'll leave it at that, and we'll see each other again in a moment.
UCI Chem 1P is a preparation go General Chemistry that covers: units of measurement, dimensional analysis, significant figures; elementary concepts of volume, mass, force, pressure, energy, density, temperature, heat, work; fundamentals of atomic and molecular structure; the mole concept, stoichiometry; properties of the states of matter; gas laws; solutions concentrations. Course may be offered online. Slides: 00:13- Chemical Reactions 00:37- So Far... 01:18- Molecules Interact 02:17- Chemical Reactions 03:26- Chemical Reactions: Antoine Lavoisier 04:04- Chemical Reactions: Combustion of Methane 06:26- Chemical Reactions: Balancing the Equation 08:14- Information in Chemical Equations 11:06- Chemical Reactions 12:43- Balancing a Chemical Equation 14:09- Balancing a Chemical Equation Example: Solid Ammonium Dichromate 18:48- Reaction Stoichiometry 21:39- Remember: From Grams to Moles 22:45- Stoichiometric Calculations: (NH4)Cr2O7 29:52- Stoichiometric Calculations: Cisplatin 38:13- And Now Fast...
10.5446/19450 (DOI)
Okay folks. That's going to X-ray and try to focus on the assignment portion of the lecture. I want to remind you that there's homework again this week. You know, you like that. It's new Friday at 11 o'clock. Make sure your clock is set correctly to specific time. Nothing central time. And today we'll be actually talking about the portion of your clock and all of your homework. About math to set. And careful homework and molecular homework. Okay? So, what if somebody gives you this? Like a handful of dirt. You know, you may wonder what's in there. This is a very general question. A question you're going to have to call, what is material? And that is something that cameras can say something significant about. Alright? So, if you want, it looks like this one's brownish material. But in fact, of course, that we know, these things are made out of atoms and molecules. And they have certain ratios and certain combinations and so forth. How do you find out, how do you find out what are the ingredients of something like this? There's a variety of chemical and political tools. And one of them is a quite powerful one. It's called a mass spectrometer. Okay? There's many more kind of political tools in chemistry. But this is just one of them and this will be available for talk today. So, you can put something in there. Okay? And this instrument, what it does, it ionizes the material. Basically, it completely disintegrates the material and ionizes the individual atoms. And then the atoms are kind of like funneled from here where they are being accelerated. How does it work? If something is charged, an ion, then you can put it between two atoms and it will start to move. Okay? So, you can accelerate the ion, send it through a slit, and then you bend it over for the magnetic. And it turns out that some heavier particles will have a more shallow end than the lighter particles which are a shocker end. Okay? So, if you have the technical screen, you can see, based on the location here, how heavy a circle is. And if it colorizes from very carefully, you can actually do elemental analysis. You can put something in there, and you see three peaks, big one, and then two small ones. You see that beautifully separated. In fact, this is neon with its isotopes. Okay? So, you see, there's two more isotopes of neon. Neon 20 is the abundant one, but you have isotopes of other abundance. You can see in that mass spectrometer. This is a beautiful device. It tells you basically what kind of atoms are in your material. Okay? Neon, this is your neon, but it could be any of them. The location on this screen tells you what kind of elements. So, what you get from this analysis, the relative peak heights, correspond to mass percentages. Okay? The required peaks can relate to mass percentages. You can say there's so much of this atom, there's so much of that atom, so much of this element, so much of that atom in my experiment. So, the quantifier mass percentage is an important one. So, how do you calculate that? This is the definition of a mass percentage. It is the mass of the element, one mole of it, in... Sorry, it is the mass of a certain element in one mole of the compound. So, let's say I give you something, and there's exactly one mole. The mass of that element contributes to one mole is going up here, and under the line here sits the lower mass, or the mass of one mole of the compound. So, what this really is, is the ratio of the mass of one mole of the compound, and then the mass of the element that's in it. Okay? The ratio between two times 100 is the definition of mass percentage. In this case, we do it for carbon, but it could be for any, any element. Okay? This could be neon, this could be an oxidizer, it could be anything. Okay? So, this is just another way to express the relative amounts of elements, atoms, in a compound. Okay, so let's do a quick exercise to see if we can understand that. Here is a molecule, this is glucose, and we are asked to determine the mass percentages of all the elements in glucose. What element are we talking about? Well, this three is carbon, hydrogen, and oxygen. And based on this formula alone, we should be able to tell the mass percentages in glucose. How do you do that? Well, use that formula and we'll just show you the previous slide. Okay? The denominator was the molar mass, or the mass of one mole of the compound. So what we have to do first is to determine the molar mass of this compound, glucose. So let's do that, this is how it works, again, we did it last time. We determine the contribution of each of the elements. I, for each one mole of this glucose molecule, I have six moles of carbon, because there's a six there. So six times the molar mass of carbon, 72. So carbon contributes 72 grams to one mole of the compound. And this is another new use, subsequent. Okay? We're going to say to the hydrogen, we have 12 moles of hydrogen and one mole of the compound, times the molar mass of hydrogen, hydrogen contributes 12 grams to that one mole of the compound. Oxygen, six. The six moles in one mole of the compound, have been six times the molar mass of oxygen, which is about 16. And that equals to this contribution. So oxygen contributes this much, hydrogen contributes this much, and carbon, this much. If you add this up, I should be getting the molar mass. Okay? So one mole has a mass of 180 grams. So, if enough, I can determine the mass percentage of carbon. What I do, I take this. This is the contribution of carbon, divided by the total, which is one mole of the crazy. Okay? So let's do that. Here it is. The mass percentage of carbon is this 72, the contribution of carbon, to one mole of glucose, and this is the mass of one mole of glucose. That ratio times 100, in this case, is very nice. Number, 40%. And then I'm going to do exactly the same for the other elements, hydrogen and oxygen. Okay? So here's hydrogen. That is what I found for hydrogen in a previous slide, the contribution of hydrogen to one mole of the compound. This is the mass of one mole of the compound. This ratio times 100 is the mass percentage of hydrogen, 6.7. And finally, oxygen, the exact same calculation. 96 is what I found in previous slide, and 180 is the molar mass. The ratio times 150, 3.29. And that should give me all the percentages of the elements in this compound, glucose. Now, I can do one last check to see if what I've done is correct, because I use up all the elements. If you add a percentage, it should be getting 100%. Because if you add them all up, you get 100% of the mass. So I'll do that, let's add these things up. The lower the hole, it works. This is how I do it, exactly to 100%. So this is a kind of check, a quick check for yourself to see if what you did is correct. Okay, I'll do another one. This is something you could do very quick in calculation. Here's another addition molecule. It's called 80-80. It's actually from the skin of this very interesting frog, and it's poisonous. So this is a poisonous frog, because this element sits on the skin, and it's not here for the rat. So we're asked to determine the mass percentages of the elements of this compound. This compound has one, two, this is chlorine, so there's three, four elements. So I'll do the same thing as before. The first thing is to calculate the molar mass. So I'll do that by calculating the contribution of each element in animal oil. I have 11 moles of carbon in one mole of the compound, and I find 1,132. That number I'll use in my subsequent calculation. Hydrogen, there's 13 moles times the molar mass, 13 grams. Chlorine, one in one. So one mole times the molar mass of chlorine, 35 grams per mole, and that equals 35 grams per mole. And then finally, I see two moles of nitrogen in each molar of the compound. Two moles times 14. 14 is the molar mass of nitrogen, and I find 28. And if I add these numbers up, I'll find the molar mass of this particular compound. So I'll add 208.6. Okay, I'm going to use that number, and look at the ratio. And this guy and this guy, I'll find the mass of carbon. So there it is. 132 was the contribution I found for carbon, divided by the molar mass times 163. And for hydrogen, same thing, 13 divided by the molar mass times 100 is 6.3 almost. Chlorine, 35 divided by the molar mass, exact same calculation, 16.99. And then the last one is nitrogen, which has 28 divided by the molar mass times 100%, which is the 13.43%. So the exact same calculation, this is going to come back. If you do this a couple of times, you should be able to do this without any difficulty. Again, I want to check what I did is correct. I've added up to 100%, and that is correct. Very good. I'm very good at this. I've never made this statement. Okay, so this is part of homework 5. The people who have never seen this, the sections are right there. The homework sits right there. Sorry, I've always been referencing. Okay, so that's all good and well. What do we use these percentages for? We use them for ourselves. Well, we are going to use this to determine what is an unknown problem. I know we're using a master program. For instance, I can get master percentages experimentally. So then I have a master percentage of how do I get a master percentage to an actual molar form. How do we do that? Okay. The first step to that goal is to find the so-called empirical form. What is that? The definition is right here. The empirical formula is the simplest possible formula for a compound. What it shows is the relative number of different types of elements. So the ratio of the finite elements is what the empirical formula tells you. But it does not tell you the actual number of the elements. It only shows the ratio. So why is that a useful thing? Because an empirical formula is something we can determine from experiment like in master commentary. Experiment. Or different kinds of experiments like the chemical absorption or some kind of government analysis. Right in place, measurements that can yield master percentages. And from that, we can determine the empirical formulas. Okay. So like I said, it does not take into account the actual number of elements. Just the ratio between them. Between different kinds. Okay. So let us just do an example. Here is one. I give you a white pigment, okay, like a white powder. And I tell you in it, my master commentary says in it are two things. The tainy atoms and oxygen atoms. So the element tainy is in there and the element oxygen is in there. The master commentary also tells me that of it, 59.9% is the tainy. Master percentage. Okay. So this is something that comes from an experiment. So you're probably in your company is doing a experiment and it gives you the results. And you, sitting at your desk and you're trying to figure out, okay, so what is this one? Oh, wow. That is your tax credit. How do you do that? You can follow the path. I'm going to tell you how you should do it. So I'm going to assume that I have 100 grams of the compounds. This is an assumption. Why do I do that? Because if I have 100 grams of the compound, then 59.9% of it is 59.9 grams. Okay. So all my 100 grams, I have 59.9 grams of the tainy. So 59.9 grams is just the tainy atoms. The other part is oxygen. Okay, so what I can do is, I can calculate how much oxygen there is, 100 grams minus 59.9 grams of the tainy equals 40.1 grams of oxygen. So the ceiling that I have, 100 grams, I have 40.1 grams of oxygen and 59.9 grams of the tainy. Now, knowing grams, I can make a conversion to number of moles. Okay? Random to mole conversion. So let's do that. 59.9 grams of tainy. This is a conversion, right? Divided by the mole mass. Divided by the mole mass. See, the grams crosses out, I get a number of moles. 1.25 moles of the tainy. So assuming that I have 100 grams of the compound, I have found 1.25 moles of the tainy. This is the quantity. I have this many atoms of the tainy in this compound, assuming 100 grams. I also know that I have 40 grams of oxygen. I convert that to how many moles of oxygen I have. Okay? So I take the amount of oxygen divided by the mole mass, 16 grams per mole, and I find 2.5 moles of oxygen. This is exactly what I want. I have now two quantities. The quantity of the tainy atoms and the quantity of oxygen atoms. Quantities, countable things. I can just look at the ratio. And that's what you can perform with. It's a ratio of 3 to the yellow. So let's do that. I can determine the relative amount. So one relative amount between these guys. You divide them all by the other. You find this case almost one half. Not exactly. This will be zero. But again, remember, these are experiments. They're never perfect. So you get really close to one half. So I can assume simply this is the ratio of one half. In other words, I have half the amount of tainy atoms for each one part of oxygen. Or, twice the versus. There is two oxygen atoms for each tainy atom. There's two oxygen atoms for each tainy atom. And that basically means that is the equivalent. TiO2. Tainy diopsy in this case. So the third problem I'm going to tell you is, the very show between the atoms for each one to take in a two oxygen atom, that is what I'm going to determine. I'm not sure this is a final form of tainy. This could be the actual formula for the tainy in its A-option. The ratio is the same, but the actual number is different. But this is the empirical. The empirical one doesn't stipulate how much actually that is just a ratio. Okay. I'll show you another one. Okay, actually this is a very quick summary. What we really did in the following, we assumed one of the grams of the compound, or the unknown compound, that from these one of the grams you determine how much each element contributed in terms of grams. Then you convert the grams to moles. Okay? If you have the moles, you look at the ratio between the elements. If the ratio is two, then there's two times more of that amount than the other one. If the ratio is half, that means you can multiply by two. For instance, they still find there's two more of one, rather than the other one. Okay? So in other words, what this is trying to tell you, you multiply by an integer as necessary to get the empirical formula. There are now halves in the empirical formula. You multiply by two, you get one, two, two. Okay? For the ratios in terms of real integers. If you get, again, if you get a fraction, you multiply that, and it's proper, multiply to get to a real integer. Okay. Now let's do another one. And this is a very important class of chemical reactions. We'll come back to this repeatedly. It is the combustion of hydrocarbons. It's a very simple experiment, and you can actually tell a lot about what the molecule is that you're looking at. So here's how it works. A hydrocarbon is basically a molecule that has carbon and hydrogen in it. Okay? So the molecular formula is C, A, with an index, X and Y, depending on what molecule it is. What I'm going to do with this molecule is to burn it. Okay? That means I'm having a combust with oxygen. It's going to react with oxygen, and this reaction has this in the outcome. Corrosion reaction takes a hydrocarbon and turns it into CO2 in H2O. That is a classical combustion reaction. Now, look at this C here. It's blue. This C is blue, too. That means this C in carbon on the outside must have carbon from this hydrocarbon. It can't come from anywhere else. It doesn't come from the oxygen. It actually doesn't deliver any carbon. All the carbon must have come from this hydrocarbon. Compact. The oxygen must have come from this. Okay? So this is just oxygen. Yeah, I'm going to use a lot of oxygen around it, so I don't have to worry about this. I'm going to use the oxygen atoms available to make CO2. Also, water has the hydrogen atom in it, two of them, and then must have come from the Hs right there. There's no other way, because oxygen doesn't have hydrodes. Okay? In other words, these numbers of CO2 molecules and H2O molecules, the numbers of them, tell me what those any states should be. They need to follow. For each one carbon dioxide molecule, I've used XCs. Okay? So I'm sure, sorry, I should say it like this. For each X number of Cs, I use this X here in the index. If it's one, if my compound has only one carbon atom, that may, can only make one carbon dioxide molecule. Okay? So I have two hydrodes per compound, per unit. Here I have two hydrodes. Okay? I have a Y here that means half Y. Okay? Why is that? Well, to have one water molecule, I need this to be at least two. Okay? So if this is one, it's going to be half. If you do only one here, you have half a water molecule. If you have two here, you have one. But the relation is one to half. For each one H here, I can make a half water molecule. Alright. So what do you do? And I have, I say, and I have only an amount of oxygen available. So let's put these pieces together. This is my combustion tank. In it is my hydrocarbon, let's say is a, let's say is a decade, let's say it's half tank, component of the gasoline, but it's a liquid, it's a liquid hydrocarbon. Then I'm going to purge oxygen through it and I'm going to burn it. Out comes CO2 and H2O. Okay? So what I can do is I can determine how much, how much of this CO2 comes out and how much water comes out. I can have the chemical analyzer behind it and this measure. How much CO2 is there and how much water is there. The ratio between that water and CO2, the actual numbers, tell me what those coefficients are. And then I know the molecular form, right there. So just by weighing and determining the mass of carbon, the oxygen, and the water, you can determine the molecular form. Or the inert form. Okay. So I, as I make a long story short, the combustion analysis allows you to determine an empirical formula. The ratio between Y and X. That is what you're going to determine. Okay, so let's do an example. Here we go. I have a compound, it is a hydrocarbon, so it contains C and H. I'm going to put it in this tank. And I'm going to measure how much CO2 and how much water I have. So the chemical analyzer says you have made 3.38 grams of CO2 and you have made 0.692 grams of water. That is what the experiment tells you. So from these values alone, I should be able to determine the surface formula of the unknown hydrocarbon. How do you do that? Well, these grams here can be converted into number of moles of the compound, in this case CO2 and water. But from the number of moles, I can determine how many carbons and how many hydrogens I have. And that is what I want to know to determine the empirical formula. The number of moles of carbon equals the number of moles of CO2. Because each CO2 mole equals one carbon that must account for the hydrocarbon. Okay, so if you want to know how many moles of CO there, I just have to count the number of moles of CO2. How do I know that? Well, the mass of CO2 is given you. This is how much you have. If I divide this by the molar mass of CO2, I get the number of moles of CO2. There you go. This is it. That's the mass of CO2. This is its molar mass, 24.01, which means the mole. And again, there's no 0.0768. This is the number of CO2 molecules in moles. Which means this is the number of C atoms in moles. Which means that is the number of C atoms that you have at the beginning. And you're higher up. I'm going to decide for water. I want to determine how many hydrogens I have at the beginning to start with. I can take the number of moles of water, realizing that each water molecule needed two hydrogens. So if I count the number of water molecules, let's say you count four, four water molecules, that means you have used up eight hydrogen atoms. If you use 12, if you actually find 12 of these, you use 24 hydrogen atoms to make that. In other words, twice the amount of the number of moles of H2O tells you how many hydrogens you have to give to the system to make this point. That number is the number of the present intent, the number of H. I did the same thing for C, now I do the same thing for H. Just the number of this effect of 2 here, because water is an index of 2 right here. Okay, there we go. I find this much water in grams. I convert that from grams into moles by the value of the molar mass. So this number right here, this thing right here, is the number of moles of water. That's the number of moles of water. Times 2 is how many Hs I have in the system. Okay, that is this number. 0.076A. And very nicely, the number happens to be the same as the number right here. So this is the number of carbon atoms. That is the number of carbon atoms that were present in the tank. So that means that now another ratio between C and H is actually 1 to 1. Okay, so the fifth problem is C-H. C-H, it doesn't tell me it's C4, H4 or C5, H5. It just tells me the ratio is going to come up to C-H. That is the third problem. Okay. Now, that has all been well, but we have to step it up a little bit. What I really want is the molecular formula. The molecular formula tells me the actual ingredients of the compound, the actual number of atoms in each of the molecules. So the molecular formula is the same as the empirical formula or a multiple of it. Right? In the last example, we found C-H. If we take a multiple of that, we get that C2 and H2, C3 and H3. This can be the molecular formula. That is the molecular formula. It's a multiple of the empirical formula. It's the same or a multiple. So to give you an example, here is the empirical formula of hexane that shows the ratio between C and H. For each three carbon, you have seven hydrogens. But this is not a molecular formula. I'm going to like to formalize this times two. C6H14, hexane has six carbons. C6H14. But this empirical formula is this. That is the ratio. That is the relative number of C's versus H's that we have. For each three C's, you find seven H's. Same here. Dynatogen, tetroxide. The empirical formula is NO2. The molecular formula is NO2O4, which is twice the empirical formula. So the empirical formula tells you for each one nitrogen, I have two oxygens, but the molecular formula tells you, look, I have actually two nitrogen, so these are four oxygens. This is the molecular formula, the actual number of atoms in your complex. Now how do you get there from the empirical to the molecular? You need an extra piece of information. The extra piece of information. Typically this is the information that's attorney's density. The density of the information. Because if you can attorney for the density, the more mass that you are in your ship. The more mass you can attribute to the molecular formula. Let's see how it works. Here's an example. Here's my molecule, CA. The empirical formula CA. So we just find it. Let's say that the mass of 0.25 mole of it is 6.5. So 6.5 of this compound, CA, is 0.25 moles. Okay, so let's look at this. In molar mass, I can determine from these two quantities. I have the number of moles and I have the mass of this quantity. So it basically means if I take the mass and divide it by a number of moles, I find the molar mass. 26 grams per mole. So I do a lot of mustache writing. This thing is cooking into my mass. So I know the molar mass of the compound. The actual molar mass. Now let's see what the empirical formula says. The empirical formula says CH. So let's pretend this is the molar mass. So here we go. CH has 12, that's the 12 is the molar mass of carbon, and 1 is the molar mass of hydrogen. So it's about 13 grams per mole. That is the molar mass of the empirical formula. So if the molecular formula would have been the empirical formula, its molar mass should be 13 grams per mole. It's not. It is 26. If I take this and divide it by that, I find how many times I have to multiply the empirical formula to find the molecular formula. So I see it's exactly a factor of 2. 26 and 13, that means I need to multiply this by 2 to get to the actual molecular formula. C2H2. This is the end of the mustache. Actually, I caught this out right before class. So it's a piece of fault, and I used a piece of electrical wire. It kind of catches the mind. So it's highly improvised. Okay, so this is one example. Let's do another one, which is slightly more involved. Malague acid. And again, I have to get the result of a mass decrometer, measured. Okay? I find 41.39% of carbon, 3.47% of hydrogen, the rest is oxygen. So this is a compound, as 3 elements, C, H, and O, and the mass decrometer is not given, but knowing that all these things should add up to 100%, I know also the mass decrometer of oxygen. Okay, so that is one piece of information. Another piece of information is here. 0.129 moles of that compound has a mass of 15 grams. Knowing the number of moles, knowing the amount of grams, gives you excess to the mole mass. The amount divided by the number of moles equals mole mass. So this should be enough for me to determine the microfoam. That's right. I do the same thing. I'm going to take 100 grams of the compound, and I'm going to try to find the number of moles of each of these guys. So let's start with the first determinant, determining how many grams of oxygen I have. I assume 100 grams, I subtract 41.39 grams, that goes 41.39% to the equivalent of grams, right? And then I subtract the portion of hydrogen, which is 3.47, which is coming from this percentage here. It's now grams. And so I find 55.14. 55.14 grams of oxygen. So for each of the other ones, I have the quantity expressed in grams. The quantity converted to grams for each of the elements is into number of moles. Okay, so here's how it goes. I take first the carbon. I have 41.39 grams of it. I have a molar mass, and I find 3.44 moles of carbon. So this 100 grams of the compound, mullet of acid, has in it 3.44 moles of carbon. Same for hydrogen. I found 3.47 grams divided by molar mass, and I have 3.44 moles of hydrogen. Again, mullet of acid, and I have 2.4 grams of molar acid, has 3.44 moles of hydrogen in it. And then finally, oxygen. I take this mass, and I just calculate it. 55 can convert it into number of moles. So I divide it by the molar mass of oxygen. 55.14 divided by the molar mass of oxygen, which is 16 grams per mole. And you find 3.44. Okay, so in this case, again, I'm going to write as examples, because I find in the ratio of 1 to 1 to 1. Within extra minute error, this is 1 to 1. So that means that the empirical formula is CHR. Right? So let's summarize that. The compound density is this, number of moles of HV elements. That means that the empirical formula should be CHR. For each one problem, I have 192.91 moles. So I want to determine the molecular mass, the actual molecular molar mass of this compound. By looking at this number and that number. Okay, apparently we're going to do this first. We're going to calculate what is the molar mass of the empirical formula. 12 plus 1 plus 16, 29. So if this would be the molecular formula, then each molar mass would be 29. But the actual compound is defined by this measurement back there. Okay? So I'm going to determine the molar mass. The actual molar mass is 15 divided by 0.129, 116 grams per mole. Okay? So from an independent measurement, I find that the molar mass must be 116 grams per mole. So by empirical formula analysis, I say, the empirical formula has this molar mass. So what I have to do now is see how many empirical formulas go into the actual molecular formula. What is the molecular formula? That means I have to divide this by the empirical molar mass. The molar mass opening empirical mass equals 116 divided by 29, approximately 4.0. 4.0 is damn close to an integer. That means this is my molecular formula. Because the molecular needs to be an integer. Okay? So that means that my molecular formula is C4H4O4. This is the actual molecule. This is it. So from my list of experimental values, or from instruments, I can tell you what the molecular formula of the four-manifold compounds is. Okay? There's another way in which you can do it. But first, let's summarize what we did so far. What we did is this. We first found the empirical formula, and we calculated the mass, the molar mass of the empirical formula. Then we did this, ratio. We took the molar mass of the actual compound. The molar mass of the independent measurement. And the last case, it was 1.6 grams per mole. And divided by my molar mass of the empirical formula. That ratio is in integers. And it's not an integer. You have to multiply it with the number that first integer. Okay? So once you find the multiplier of an integer, you multiply your empirical formula by that integer, and that is going to be your molecular formula. Okay. Now, I want to remind you that what we did in the beginning is we made this assumption. I said, let's assume we have 1.1 grams. Why did we do that again? It's easy. It makes the calculation easy. That means you can convert percentages into grams. But I didn't assume something else. I didn't assume, for instance, that instead of having 100 grams, I have one mole of the compound. Another sum. So why is that useful? Well, it's useful for going like this. So let's assume that I have one mole of the compound. I can then determine that I have, instead of 100 grams, I have 1.16 grams. Because of the molar mass. One mole of the compound in this particular case is 1.60 grams. Okay. Now, I also know that I have one mole of the compound. I can calculate what is the contribution of carbon. Okay. I know that 41.39 percent of my mass is carbon. So that means if I take 41.39 percent of this, okay, that means I can calculate the amount of moles of carbon in this one mole of the compound. Let me show you how it works. This percentage from this tells you the mass contribution of carbon. Okay. So let's turn this into a fraction. This is the fraction times that number equals 48. 48 grams is the contribution of carbon to this 1.16. If I divide this by the molar mass of carbon, I find the amount of moles of carbon. Now, I will have to find here the integer. Okay. Why is that? Because I assume that one mole of the compound. So that means in the whole amount of molecules of integers as an index, such as for the elements. So if I have one mole of the compound, let's say C2, or not to example, C4H41. If I have one mole of the compound, I have four moles of carbon. So I must find the integer. So if I divide this by 12, that is a molar mass of carbon. And yes, it's 4. This is not an accident. It's right? This is not an accident. This is what I believe what I want. Assuming one mole, I find the number of moles of carbon in that one mole of the compound. That would be the same thing for hydrogen. Again, I must find. I can predict what I'll find. I have to find 4. Let's see if that works. This was the percentage, turned into a fraction. I have this number. That is the contribution here in grams of hydrogen if you divide that by the molar mass of hydrogen to find the number of moles of carbon. Okay? That is 4. And I find the weight of oxygen. Same thing. This is the percentage, the mass percentage. I have that into a fraction times the mass of one mole of the compound is the contribution of oxygen to one mole of the compound in grams divided by the molar mass of the new term grams of the moles. That means you can write the number of moles of oxygen if that is again 4. Okay? So this is another way of doing it. I see again that if I'm C4, A4, or 4, those numbers here is the number of moles in one mole, number of moles in the elements in one mole of the compound. So what we did is the following. Instead of assuming one mole of grams, I said let's assume one mole, one mole of the compound. Then we're going to calculate the mass contributions in grams of each of the elements. Okay? If I have the quantities in grams, I can convert that to moles at the divided by the molar mass. That's what we've been doing all the time. All the while. We've concentrated the grams at the molar mass, and we get the number of elements in the number of elements in the moles. Okay? So then I have the number of moles. Now the number of moles must be in the integer. Must be. Okay? And those numbers are the subscripts in the molecular form. Okay? So the integers you find in the previous step are the subscripts in the molecular form. This second method is equally valid, and it's usually a little fast. So if you're comfortable with this one, then I would suggest you this. If you like the quantum of grams or something better, you can use that. Okay, so again, these two tricks are relevant to molar mass. All right? I think we are at the end. Yes. Thank you. Thank you.
UCI Chem 1P is a preparation go General Chemistry that covers: units of measurement, dimensional analysis, significant figures; elementary concepts of volume, mass, force, pressure, energy, density, temperature, heat, work; fundamentals of atomic and molecular structure; the mole concept, stoichiometry; properties of the states of matter; gas laws; solutions concentrations. Course may be offered online. Slides: 00:06- Mass Percent 00:56- Measuring Compounds 01:54- Mass Spectrometer 03:42- Mass Percent 04:53- Mass Percent Example: Glucose 08:30- Mass Percent Example: Epibatidine 10:22- Mass Percent Example: C11H13ClN2 12:13- Empirical Formula 13:38- Empirical Formula Example :Ti and O 18:10- Calculating Empirical Formulas 19:24- Empirical Formula: Combustion Analysis of Hydrocarbons 23:52- Empirical Formula Example: Burning a Sample 27:49- Molecular Formula 30:01- Molecular Formula Example: CH 32:22- Empirical and Molecular Formulas 37:43- Calculating Molecular Formulas: Method 1 39:09- Shortcut 42:25- Calculating Molecular Formulas: Method 2
10.5446/19449 (DOI)
Welcome back after a nice long session on Friday. Let me guide you through it. That's the score chart from last Friday. The knee was 56.2 standard deviation, which is basically a measure of the spread of the knee. It was 18.6, which means that this exam really cooled a lot of performances away from the chart. So it's a very broad distribution. For a teacher, this is great because I can beautifully expect a lot of performances. But a student in this report is not great, you all want to be right on close together and maybe somewhere more towards the 90s. So you may feel that 56 is not so good. Actually, completely fine. Completely on target. Last year, the performance was only 1 percentage point higher. So it was 57, now it's 56. That was very much average, I would say, for the years to come. Anything out of your board there. Let me say a few things. The exam was, like I said before, it was a little bit tight. It was part of the parcel of having only 50 minutes, including the ranging things. Again, other class, our new class, taking the same distribution exam. You cannot do it in another way, you cannot put your exam on the seat 400 percent. You don't have six hundred copies of several chairs, you simply cannot do that. So you have to move to the way you did it, takes a little time, takes a couple of minutes of your examination time. You know that. Many people told me that, and I said, I know that. And this is again part of this exam. This exam was tight, it was not very pleasant and comfortable. But on the other hand, you know, we still get a very good impression of what the performance of this class is. The second exam, you will see, will go a lot better. It is a little less intense. And it will feel more comfortable in the final, for me, relatively, I would say, now, even more time for you to take three questions. This is also kind of like sets the stage, because there are a couple of topics here that are important for you to be able to do these questions quickly. And so I definitely have had a lot of stuff here. I was trying to test you on several things, you sweep it all in, and this is the result. So not bad at all. We are on target. If you are on the low side of the mean, take this exam as an opportunity to see what parts of material need to be improved. So what is your personal weakness on the exam that means extra attention? You can hunt the office hours, you can go up and speak to your Twitter's, there's a special leader's Laura and Mike, who are very happy to help you out, ask them specific questions, take a human understanding, and ask for a specific answer. So again, you are in charge of your own success. You identify which parts of material are not easy to go with the use, and you act on it. Make sure that you get the information and be able to do the questions next time around. So I want to remind you, it's only 15% of your grade. This is for a particular reason. 15 makes up a lot. It really is not. The final is almost half of the grade. The final is really where it's all happening. The exam is really just a warming up exercise. Just to get started, so don't be demoralized, we didn't go so far for you. Actually, if you didn't go so well, it tells you which things you are going to go on. So it is more like an opportunity than an analyzing experience. Okay, yes? Do we get our grade too bad? Well, you can't approach the list first. Okay? It's actually on the slide. The grades of the old tests will not be curve. Only your cumulative grade will be curve. Your cumulative grade is two minutes, one final, and a homework together. That is your overall grade of this course. That will be curve. In my opinion, it doesn't make a lot of sense to curve individual exams. The much better measure of your performance is to look at your score. Your score is metric. It is a number that tells you how well you did. The maximum score is 100, and you have 50% of it means you get half right within a lot of time. That's what it means. Very good innovation with your performance. Don't do a riveting at the stage of your grade. It makes no sense. But it makes no sense to do that. Do that have an A or B. It makes no sense. At this stage of your grade, the only thing you should be concerned about is, do I understand that you're in? Okay? That is what you're in for. Worry about this riveting just till the better grade. Don't go telling your opponent what to do right now. It is just a waste of energy. Your exam will be available on the triple E page on Friday if everything goes right. So we have, as you noticed, we've rated everything on Friday. Very hard work. It's lost for educators and everything is done not manually. It's a very small thing. It's interesting how long you're in the same team. They are now currently in the coffee center. They're all being stamped and reproduced. And you'll see an idiot version in the real box. You're only in the airport when we're in town. This will take a couple of days. This is not really my control. It's not in the coffee center. Okay. You can contest your score if there is a genuine rated error. Don't come to me please with all kinds of arguments about why you should have more questions. That's not really the purpose of contesting your score. We have given questions, but it may be stuck to a very specific recipe for that. And we think the dollar can write a job. If your answer is correct, like you didn't get the points, you get your entire potential points. But if your answer is not correct, and someone in the margin has written something amazing, right, a little bit of an imagination, we cannot give you the answer points with that. Okay. So, if you guys do that, that's possible. Basically, I'm on the auto major. I'm just going to spend all my time with that. It's impossible. That's also not the purpose. I think you've graded very fairly. Okay, so the grading errors will be considered till... This is a Friday the 9th of November. So that means you get to return that on Friday, Monday and Friday, this Friday. And then you have one week time to talk to me. Talk to me. Send me an email. Okay, if you have a simple question, send me an email. I can do things right if you have a question. If you have specific questions, you can come to an office hours. Or you may even find it. Don't...the TAs are happy to discuss answers with you, but they cannot give you a question. They're only high to do that. Okay. All right. Let me quickly look at one question on the exam. It's about the can of Coca-Cola. This question, surprisingly, went not so well. Okay, most people were probably confused by this question. Let me go through it and just see who developed it in place. It says in doctor advices the patient not to consume more than this. Okay, so this is 85 grams. Okay, so I'm just quickly comparing the amount of what I have. This is 8.5 times 10 to the minus 2 kilograms, so it's 85 grams. Okay, so this patient should not consume more than 8 times the amount of sugar in an egg. Okay? Now, in one of these cans, there are 12 ounces of...sorry, this is 12 ounces. Okay? And it contains sugar at this concentration. So this is a volume. This is a volume. And this is a concentration, or a density. As you can see. This is gram of a liquid. This is mass of a volume. This is a density, and this is a volume. How many of these cans can this patient have? Alright? And the conversion here of ounces to milliliters is shown as well. So what do we need to calculate here? Well, what I need to calculate is, in the end, how many cans can the patient consume? What does that depend on? It depends on how much sugar is in there. Okay? 85 grams is the mass. So what I need to know is how many grams of sugar are in one can. Okay? I need to know how much sugar is in this can. It's a very simple thing. If your doctor tells you, you cannot eat so much sugar a day, and you see this on this...or probably... You want to know how much sugar is in this can. How many grams of sugar is in one of these cans? Right? How many grams of sugar is in one of these cans? Right? How many grams of sugar is in one of these cans? So that's a mass. Mass is volume times density. Do I have that information? That volume is not in milliliters or liters or whatever, but the conversion is right there. So what I do is this. Mass equals...this is the density, which I quickly convert from liters to milliliters. Okay? That's a factor of 1,000. If you can do that with a square meter in your hand, you can just write it out, because the difference between a milliliter and a liter is a factor of 1,000. Okay? So point 110 grams per milliliter times the volume. And the volume is right here, between parentheses. I want the answer in milliliters, so I use this conversion right here. 12 ounces, that's the volume, times this conversion factor. You see, the ounces will cross out, I get my answer in milliliters. So if you actually give this one here, you have your volume in milliliters, times this, milliliter, you get an answer in grams, 39 grams. 39 grams in one of these hands. Okay? You are almost right here to answer. This multiplication here of 1 to 3 numbers is basically the whole thing. All right? How many cans can you have? Okay, well, I have a maximum of 85. This is 39, so how many 39's are sitting at 85? 2.2. I can have 2.2 cans. That's it. That's the calculation. Okay, another issue is naming compounds. Naming compounds is something you can literally learn is a method, and to stick to the method, you will be fine. I saw a wide variety of very interesting, very intense. I'm going to give you a simple, some people say, this is sulfur fluoride, it's almost right, but not quite. This is hexafluoride. Okay? Sulfur hexafluoride. Oh, this is a nice one. I remember in one of the lectures, I say, be careful, about 20% of you guys are going to do this one wrong. Okay? Because you will say sulfuride, and it is sulfur fluoride. And you can hit it. I'm going to say 20%, about 15% of the folks did exactly this. Okay? So, you have to pay attention to it, because even people that's actually very interested in me, they put in 2-minus here, and I said, if I forgot, who's the 2-minus? They put in 2-minus here, and I said, oh, it's sulfur. This is solvent trioxide, it's a neutral compound. Okay, this one. Some folks said, disesium carbonate, this is an ionic compound. You never use this indicator, okay, this prefix. It is cesium carbonate. Ionic compounds do not have prefixes indicating the number of atoms. How about this one? A lot of folks said this, copper 1, selenide. But selenide is in the same family as oxide, right? It's in the same column, but this is 2-minus, I mean, the copper is 2. It has a charged 2-plus, oxidative state 2. This one, now what does this mean, guys? It's dissolved, and this is an H. What does it mean? Acid. Still, still, okay, a fraction of folks still call this ionic nitrate. Don't say the name, okay? This is nitrous acid. And this one, lastly, this is almost the same kind of situation as in this one, copper selenide. People call this barium, actually not the same situation, shavings iterations here, they think this is a type 2 metal. Barium is not, barium is 2-plus type 1, okay? It's in a second column, and those are type 1 metals. You never specify the oxidation state of type 1 metal. So, barium is 2 chloride, a disbarium chloride. Okay, keep your states in mind, keep practicing, and then we'll see if I've tried to find a concept on the UBU leadership. We have to move on, okay? We're going to chapter 3. So, we did already a quite big chunk of the material so far, and we're hopping into the next set of topics. So, what it is about. In chemistry, we deal with a lot of atoms. We need a material which is the whole of your hand, the solution, the sugar in your coffee, if not one molecule, there's too many. So, instead of talking just about one thing, we have collections of atoms, like collections of Ticke. But the problem is that these collections are rather large. Okay, so I'm just giving you an idea. This is one person, you can easily think of this, of this one person, just conceptualize it, there he is, one one guy. And then, we can even conceptualize this iteration here as counting about 300 million people. Even though here, there are people who say, look, there's a huge number, for some reason, our brain kind of understands that number. And we understand 300, that's about this. So, we kind of conceptualize it. Now, if you look at ions and molecules and atoms, the numbers are rather staggered. Okay, so this is one ionic hand, you can easily grasp it, this is just one sodium and one chlorine ion, they're together, nothing is wrong with it, easy to conceptualize. But what if you have one of these little chunks, one little grain of salt, tissue salt, already has one times 10 to the 19 ionic pairs. 10 to the 19 is a staggered number. Okay, that's huge. And this number here fades, prepares, to how many ions are in there. Our mind cannot poke in hand the magnitude of this number. You can try, but you don't, because you don't have the frame of reference. You're kind of lost on this number. And consequently, it's hard to do calculations and calculations with these numbers. So, it makes a lot of sense for chemists, and also for you, that you are as far in hands, you don't know yet, as you will. To have a different way of treating these large numbers. And you have to work this number, and that's the mole. What is it? It's a number. I can feel you excited. Okay? It is a number, that's it. That's all you have to know. We're not sorry. It makes funny numbers. I'm not sure if my M3 is very impressive, when you memorize this number, it's like my name. Oh really? That's great. So how many digits do you know? How many digits do you know? Four digits, or five, six? So, this number is big, right? It's big. It's 6, 4, 0, 2, 2 times 10 to the power of 23. And that's a very, very big number. But it is a number. I just want you to understand it's a number, like any other number. It has no units, right here, at the moment. So it's a number like 12 is a number, or 6 is a number, or 222 is a number, this is just a different number. It's a quantity of days. So how is it defined? What does it all come from? So it's defined, again, to your best rate of carbon. Definition is as follows. 12 grams of carbon-12, that is the isotope of carbon. Okay? Isotope 12 of carbon. Carbon-12. If you have 12 grams of only these atoms, then, the definition says, you have one more. Okay? If you stick to the definition, if you say that this is the definition, you can add what you have. And it turns out that this definition stipulates that you have this many. Right? So I'll tell you this moment here, 12 grams of carbon-12, that is your method, that is your new unit. Okay, you say, we're going to do it here, not how many of you have these things. Oh, I found this many atoms in there. And that's it. That's the definition. Nothing mysterious about it. It's a definition. Even if I'm a summer, so this is a pretty good definition, like A. Okay? So, again, I just want to re-emphasize that it is a number. People mix this up. People say the mole is so mysterious. Ah, just a number. Like a dozen is a number, you have to refer to comparison probably. But it's really true. Okay? You can have 12 atoms, or you can have this many atoms. In one case, you call it a dozen. In another case, you call it a mole. Now, I'm surprising that if I give you a question, and I replace every word mole with a word dozen, you have no problem with solving the question. But if I give you a word mole for dozen, you are completely clear. I'll give you a whole lot of people. Because you think the mole is hard to understand. It's not. It's just a number. Like a dozen is a number. Okay? So, in case you are confused by a question, and the word mole is nothing in your face, just secretly replace mole by the word dozen. And suddenly you think, oh, you just have to multiply two numbers. Okay? So let's look at a couple of consequences here. All right. So, if I have one mole of carbon C prime. Right? One mole of it. Well, then I have 12 grams. I have a very good definition. One mole of carbon C12 equals 12 grams. Because 12 grams of carbon C12 is one mole, is my definition. All right? So, the mass of carbon 12 is 12A mu, 12 atomic mass units. Okay? I mean, that's another definition. That's octagonal mass. So one mole times 10. So just substitute this here with that. Equals 12. Same line. But from this, I can just bring this guy to that side and put him to the following. One mole equals one gram per atomic mass unit. Atomic mass unit is a unit of mass. Gram is a unit of mass. So, in fact, it's dimensionless. It doesn't relate to a physical unit. It's just a quantity. Now, this is a very useful kind of conversion that you want, a relationship. Because I can do the following. I can take another element, let's say aluminum. Okay? One mole times the mass of aluminum. Okay? So let's say one mole of aluminum atoms. The mass of aluminum atoms should be supposed to go here. What is the mass of aluminum atoms? Well, in A and U, I know what it is. It's right here. 26.98, but all of us want to hear it today. The average mass of aluminum atoms is right here. That is the number in the bureaucrat. Okay? If I multiply that by one mole, look, one mole is this. So I put it right here. I see A and U are crossed out. And they get an answering branch. In other words, this is 26.98 branch. All right? So one of the lines says, if I have one mole of an atom, I get my mass expressed in grams. Okay? The average mass of the atom is now expressed in grams as opposed to A and U. So every time you take one mole of these atoms, that means a whole bunch of them, they get them. Then the mass of that will be equal to the molar mass of that element, but this A and U replaced by grams. Okay? So on the other hand, we look at the bureaucrat table. This is what we just did. We have an element. We take exactly one mole of that element. It turns out its mass is equal to its atomic mass in grams. And it holds for every other element. Fantastic. You take one mole of it, you get this mass, which is the number in the bureaucrat table, which is the bureaucrat table that says A and U. And if you take one mole of these elements, you get that number in grams. Zin, say hey. You take one mole of same atoms, you get this mass, and the number in the bureaucrat table are now expressed in grams. And it holds for any other element. It doesn't matter which one. Okay? Because now I can just say one mole of all these elements and I know how much they weigh expressed in grams. What the masses express in grams. Okay, so let's do an exercise here. Let's take this block of titanium, a small little cube of titanium, and let's assume that this little tiny cube is 3 grams. Okay? And I'm going to ask myself a question. Okay, I have 3 grams of titanium. How many titanium atoms are in there? That's what I want to know. How many titanium atoms are in there? So I have to do a conversion. I have something in grams. I want something in number of atoms. How do we do that conversion? Well, one way to do that is this. I have grams. I know how much one mole of titanium is. But it is not that there are grams. Okay? I can make a conversion factor. One mole of titanium equals this many grams. And I can use this as a unit factor. Okay? A conversion factor in my calculation. So what I do is I start with listing this number in grams. I'm going to synthesize, out of here, a conversion factor. I want to go to quantity, number. Mole is a quantity. So I put mole on top and this at the bottom. And there is mole location. You see, grams will strike out. And I get now the number of moles of the tinny that are in three grams. Okay? This is it. 0.0626 moles of the tinny. So how many atoms are there in this cube? Well, this many. Okay? This is the quality. This many. But the quantity is expressed in moles. And I want it in real number now. So how do you do that? This is a mole. I just multiply by what the mole is. Just like I said, there are this many dozen titanium atoms. You would multiply by 12. So I multiply this at 6.0, 2, 2, 5, 10, and 20. Okay? So I get a number multiplied by what the mole is. That is a mole. This number is a mole. And then I get the normal atoms. 3.7 times 7.2 times. Again, this number is rather staggering. That's why we typically don't really bother about really calculating normal atoms and we stay on the level of the moles. Because those numbers are much easier to work with. That's the purpose of the mole. To make calculations easier and more manageable. Okay. Two quick examples. A sample of CO2 has 1.4 times 7 to the third moles of oxygen atoms. Not a question if how many moles of CO2 molecules are present? Okay? So what is the question about? Well, this question is about this. What is given is how many oxygen atoms you have. Not how many molecules of CO2 are present. Okay? I know how many oxygen atoms I have, but from it I can determine how many CO2 I have. So it's a relation. It's the same as saying you have two eyes. You all have two eyes. So in this room there are 600 eyes. How many people are there? 300. For each person it's two eyes. It's the same here. Each molecule has two oxygen atoms. Right? So for each molecule there are two oxygen atoms. So what I want to do is just take that number and divide that by two. Then I get this number, and that means I have this many CO2 molecules. And this is another situation where the different words can see diffusion. If I say molecule and methodus, you tend to think that this is going to be a very complicated calculation. But if I say eyes and people, no way to understand. So mathematically this is a job. Right? So just conceptually you have to give the same meaning. Don't be afraid of the number of atoms. Or how many atoms there are in certain molecules. It's just a calculation. It's just like two eyes of a person is a calculation. The sooner you can convince yourself that this is all straightforward, the faster you will get the answer. Okay. How many moles of H atoms are present in this molecule? If I have 2.88 moles of H. Okay, again, 2.88 moles is a quantity of molecules. Alright? What I want to know is how many H atoms I have. The quantity of H atoms. So what I see here, I have a molecule. It contains Cs and Hs. It contains six Hs. So for each one molecule I have six hydrogens. So how many hydrogens do I have? Well, I take this number, which is the number, a quantity, and I multiply it by six, 17.3 moles of H atoms. That's it. I just have to multiply this number by six. You can see it. Very easy, seems. And these simple exercises just for you to get used to where as molecules happens in, don't be afraid of doing these calculations. Yes? What about the part of the universe? What happens to it? What happens to it? Do you not have it? Well, I mean, you know, that's the same as saying, if I tell you that there are 600 eyes in the audience, how many people are there? Okay? That your question would be, but how long is that? How many noses are there? Right? I said, well, it's here on the nose. Right? Because each molecule has one target. Sorry, that means there's just the same number of particles that there are on the nose. The question was about oxygen, and how many molecules do you have? Eyes and people. But of course, people, I hope, are noses. Actually, people have many noses. If you are, you have to lie. They're all noses. This here is where the only particles are. Okay, now, what holds for atoms also holds for molecules as a whole. What does that mean? That means the following. I can determine not only how much or what the mass is of one mole of an atom, I can also determine what is the mass of one mole of a particular molecule. Right? So, for instance, let's take this one. It seems to age 6, power. That's ethanol. If I have one mole of ethanol, what would its mass be? How do you calculate that? Well, what you have to do is, you can see what's in it. One molecule of ethanol has two carbons, six hydrogryms, and one oxygen. Right? If I have one mole of ethanol, what means I have one times two moles of carbon, six moles of hydrogen, and one mole of oxygen. So that's what I have to calculate. Here we go. The mass of two moles of carbon equals two times the mass of one mole, which is this, 12 grams. Six moles of hydrogen is six times the mass of one mole of hydrogen, which is 1.00 grams. And one mole of oxygen is just the mass of oxygen, one mole of it, which is 16 grams, or 515.99. Okay, so what you have to do is, you have to do these notifications, and then add them up. Okay? The answer is 46.07. That is the molar mass of ethanol. So that means that if you have one mole of ethanol, a quantity, a certain quantity of ethanol, you will have, if you put the same on your balance, you will say this is 46.07 grams. Okay? So we say 46.07 is the molar mass of ethanol. Okay, so we do the ethanol here, right? What do you want? Asteroid. Asteroid is a cool molecule. If you feel generally the same, it's a very simple, but it's a small molecule, not to be speaking. Okay? Here is the mass structure, your favorite very good molecule. And here is the chemical formula. Chemical formula is in this regard very important. If you want to calculate the molar mass. Okay? That's 9, sorry, it has 9 carbons, 8 hydrogen, and 4 oxygenated. So what I want to do here, the first step I want to do, even before worrying about this question here, I want to know what is the molar mass of this compound. So what I do with this again, 9 moles of carbon, that means 9 moles, 9 times the mass of 1 mole of carbon, that's 9 times 12.01, that's this number right here. 8 moles of hydrogen, 8 times the molar mass of hydrogen, which is 0, sorry, 1.008, the multiplication you find this. And then 4 moles of oxygen, because it's 4, there's a 4 here, the thing's got 4 is right there. 4 moles of oxygen, 4 times the molar mass of oxygen, which is about 16, they get 64 is contributed by the oxygen. Put a line here and add one. 1 mole of acid is 180.60. So, if I had 1 mole of acid, this would be its mass. Let's look at this number here. I don't know how many moles are in this mass. This mass is much smaller than this mass. Why do I say that? Because if you look at how many moles it is, it is definitely much smaller than 1 mole. So if your n is going to be larger than 1 mole, you get something wrong. I have to find an answer for 50 milligrams of acid, and I know it's going to be a number much smaller than 1. You guys have to stress it a number of moles. So what do I do? I write down again the quantity, which is 50 grams, sorry, 50 milligrams expressing grams, 0.050 grams. Why do I do that? Well, because this is defined in grams, not milligrams, so I'll rewrite this in terms of grams. Then the conversion. Where do you want to go to? To moles. Where do you want to move away from? I want to move away from grams. So put gram at the bottom, moles on top, like this. This gram will cross out, and this calculation gives me a number expressed in moles. This is my unit factor, like we did with the conversions all the way. Okay? 2.8 times 10 to the right score. That is the answer. So this question is converting a quantity expressed in a mass, milligrams, into a quantity, which is moles, and you can use this unit factor to do that. Okay? Vitamin C, another very cool molecule. Here it is. Vitamin C is nothing but a sorbic acid. And here's the structure. Again, relatively small molecules are quite similar to gestication or even calc. If you don't have this thing, if you don't ingest it, your body can't eat it, as you're going to get it to redness and fruits, and you're actually pushing your unit system. This molecule has 6 carbons, 8 hydrogens, and 6 oxygens. So knowing this, those subscripts tell me exactly what the molar mass is going to be. Because we're going to do 6 times the molar mass of carbon, 8 times the molar mass of hydrogen, and 6 times the molar mass of oxygen. Okay? There it is. 6 times 12, 8 times 1, 1, 0, 0, 8, 6 times 16, and the total is going to be 176.12. That is the molar mass of vitamin C. Okay, that's it. What is the question? How many oxygen atoms are there in 5.3 micrograms of vitamin C? This is a number expressed in grams. So I have something in grams, micrograms, a mass unit, as a convertible to a quantity unit. So it's a conversion property. I'm going to need this. I'm going to need this as a conversion factor. They want the answer in oxygen atoms, the number of atoms, not the number of moles. So I have to do extra conversion and multiply it in the end to get what the mole is. So let's get that one out. What I do is I'm going to write this, write it. Okay? It's roughly arranged. 5.3 times center minus 6 grams, because the microgram is 10 to the minus 6. I want to convert this from gram to number of moles first. That means I take the scene here, put mole on top and this thing at the bottom. Grams will cross out. So I get 9 number now expressed in terms of number of moles. I find 3.0 times 10 to the minus 8 moles to sort of ask for minus. This is 2 significant figures, so I have 2 significant figures right here. Is this a final answer? No, it's not, because they want to have a number of oxygen atoms, okay, not in moles of the molecule. There's two things I have to do. First, I have to determine how many oxygen atoms there are for each molecule, that's 6. And then I have to convert that to number and multiply it back with the mole, with the mole number. So let's do that. This is the number of moles of vitamin C molecules. This is what one mole is. So I do this multiplication and get a total number of molecules. 1.8 times 10 to the 16 molecules of vitamin C. Again, replace this, not by the mole number, but by the number of dozen. The right thing to do automatically, now even thinking, you would say, oh, if this many dozen, okay, that's just like a number of times 4. Same here, just multiplying with the mole number. I'll cover God's concept, but I do not like the problem. Okay, this is the number of molecules. Each molecule has 6 oxygen atoms, so the number of oxygen atoms is 6 times this. This number of times 6 is going to give me my number of oxygen atoms. 1.1 times 10 to the 17 oxygen atoms. Make sure you really understand this, and you're very comfortable with calculation. And discriminate number of molecules from number of atoms in the molecule. The molecule can have multiple atoms in it, but that's not going to be bigger than that. Okay, another one. How many moles of lead for chloride are present in this many grams of it? Another conversion, from grams to moles, to one step conversion, if you know the molar mass of lead chloride, you can directly calculate how many moles there are in this mass. What do you do? The molar mass, if you calculate it first, comes to the clear table, one lead atom. This is the molar mass of lead. Okay, 4 times the molar mass of chlorine, that is the molar mass of chlorine, 4 times that, we add just the whole thing up, 0.49 from the zero grams per mole. Each mole you have 249 grams. This is my conversion factor. I'm going to write down this number, okay? This is another way to say it. The number of moles is nothing but the mass divided by the molar mass. It's not going to memorize it as the same trick. Basically, you take your mass, which is this number, you multiply by conversion factor, but always this number appears at the bottom, and on top is one mole. In other words, it's mass divided by the molar mass. That's a quick way to remember this. So, 5, 4, 4, 0 grams divided by that number equals 15.6. That's the number of moles. This formula here is exactly the same calculation we did on the previous slide. You take the rest in gram, you multiply by the new factor, molar mass at the bottom, this is one. So you just do it together, you get mass over molar mass. That's what it is. It's the same calculation, sourced together in one experiment. Number of moles equals mass over molar mass. Okay. Another one, very quick. Another sample, iron. And this is monoxide, sorry, carbon monoxide. It's found to contain, oops, I'm sorry, this is a complex, okay? It's a complex of iron and carbon monoxide. It contains this many grams of oxygen atoms. How many grams of carbon atoms are present? This is interesting. I have to convert a number of oxygen to a number of carbon atoms. Okay? Especially as a scientific notation. So, I know the number of oxygen, what is the number of carbon atoms? Well, it's one to one, actually. Okay? The number of oxygen atoms is basically the gram divided by the molar mass. That is a quantity. So 1.94 times 10 to the minus 5 grams, that is the mass quantity, divided by the molar mass, gives me the number of moles. Okay? 1.21 times 10 to the minus 6 moles. So what I did, I took the formula from the last slide, N and VA, number of moles, equals mass over molar mass. Mass over molar mass gives me a quantity, especially more. This is how many oxygen I have, and that is the same as carbon molecules. Okay? In other words, I have exactly the same number here as carbon. 1.21 times 10 to the minus 6. The only thing you have to do here is to convert a mass quantity into a mole quantity. That's it. You do that by this expression. What time is it? Um... Oh, look at this. I can do one step more, because what they ask is, not how many atoms you have, but what is the mass of those atoms. So once you have the number of atoms, you multiply it by the molar mass. Okay? So what I find is this many moles, this is the molar mass. The number of moles times the molar mass gives you the mass. Okay? So let me read it again. This is number of atoms. Okay? Number of moles. This is what one mole weighs. What the mass is of one mole. So let's say 2 dozen eggs, okay? One dozen eggs, five grams, so you multiply it by numbers. You're exactly the same thing. You have a number of moles, molar mass, you multiply it to, okay, the answer in grams. Okay, okay. That's it, and I'll see you on Wednesday.
UCI Chem 1P is a preparation go General Chemistry that covers: units of measurement, dimensional analysis, significant figures; elementary concepts of volume, mass, force, pressure, energy, density, temperature, heat, work; fundamentals of atomic and molecular structure; the mole concept, stoichiometry; properties of the states of matter; gas laws; solutions concentrations. Course may be offered online. Slides: 00:06- Mole and Molar Mass 00:24- Midterm Results 04:34- Midterm Summary 08:02- Coversions 11:58- Naming Compounds 14:46- Moving On: Next Stop Chapter 3 15:20- Counting Atoms 18:00- Mole 20:36- Mole, Slide 2 24:19- Mole: Example, Titanium 26:59- Mole: Example, CO2 30:54- Molar Mass: From Atoms to Molecules 33:12- Molar Mass: Example 1 36:36- Molar Mass: Example 2 40:25- Molar Mass: Example 3 42:50- Molar Mass: Example 4
10.5446/19448 (DOI)
All right folks, take your seats. All right, I'd like to ask if you have a camera in the audience? Camera? Camera. Camera. No, you don't see the camera. Sure. Another important announcement is that next week on Monday, I'll be in Washington like I said last time, but our teaching assistant, Laura will be in a redo section in class. So on Monday, you have a redo section in class, come on by Laura. So please come. On Wednesday, the Wednesday class is technically canceled. But I'd like to say that the homework is sooner than usual. I'm required to have a student on Wednesday, so you can use that hour, the extra hour to actually work it back. And then the Thursday evening at 7 o'clock, the evening of the exam. Because the exam was Friday. 7 o'clock in HSLH, one of the eight different people you have in class in the new section. And you can come through that with all your partners. Yes. Do you have to set the review example? Yes, the review of the practice exam will be posted online, Tuesday night. Okay? We'll look at that. Yes. The information is all posted online, you will need an article to play. So please check there for details. Yes, sir. Monday and Wednesday? Monday and Wednesday, I will physically not be here at your bar. So if you want to see me, you have to come to Washington. I'm going to be seen. Okay, so I apologize for my absence, but there's really no other way I can un-camp this. It's a very important meeting after the class. Okay, folks, so this lecture is the last student information that will be served on the midterm. Okay? So we know new information to do. Next week is only about rehearsing and practicing. So today, the last information, but a very important piece of information. Okay? It's all about articles and the structure of your table. So please pay attention because this is going to be a substantial part of the midterm. Part of the midterm. Okay, so the question we're trying to address here is related to, you know, continuing atomic question. If you look at the sentence, you know that the nucleus proposed by Kroger was a neutron is kind of the core of the act. That's the nucleus. It's the center of the atomization. But where is the electron? Where exactly is the electron? The electron, as we talked about it before, seemingly is floating around the nucleus. But what is the mean floating around? It means it's just here, it's just there. Is there a particular path it takes or a particular area that it occupies? This is a very important question. The question of where the electron is, you will see that where the electron is at such a prominent location that we actually will be able to explain chemical functionality in the product. This is a picture that, you know, if you google atom, then you get a picture like this. You see these orbits and this supposedly is an electron, I think it's a nucleus. But as you will see in two seconds, this is really not the way it looks. This is really not the way we understand an atom is structured. The electrons don't go in circular paths like planets circle our sun. It's quite different. So that's where the similarity stops. So let's have a look. This is a nucleus. Let's put it in the middle and then let's just pretend that the atom is a one-dimensional object. Meaning that I only consider one spatial group of x. I forgot about the y-axis. This is basically the state that the electron can occupy. It can be close or can be far from the nucleus. And I'm just also going to assume that this here, this last point, is really the end point of the atom. In other words, I just convinced myself the electron cannot be beyond that point. The electron must be somewhere on this line. So I also like to find the location of the electron knowing that the electron is not having all kinds of funny jumps in its probability distribution. Meaning that if I put the electron like this, I would say that's a good solution. This is a good probability function of the electron. This probability function is smooth. It doesn't have a jagged shape. That's unlikely. The electron is a high likelihood to be here, here, here. And then towards the edges, it disappears. Because at the end, what I just said, it doesn't exist beyond that point. So the probability here is zero and gets a little bit higher here, here, here, here, here, and it goes down here to zero. This is a beautiful function. It satisfies my initial terms. The term is that it's here, but it's a smooth kind of function, a smooth distribution. And the probability of the electron being somewhere should disappear at the edges. This function does that. So I said this is a good function. This is a good description of where the electron is. Now, this is also a good one. It also disappears at the edges. It's smooth, and it's not disjointed. It is a different kind of curve. But also this curve fits nicely into this length here, the length of this line, where I say the electron can be. So this is also a good or really disjointed. I say here two-half wavelengths. This is one-half wavelength, two-half wavelengths. And here's another one, three-half wavelengths. So this is also zero here at the edges. A smooth function that comes back to zero right here. So all these functions, these kind of wavy patterns, are good descriptions of the probability that this would disappear from the electron. Now, I say three-half wavelengths because this looks like a wave. I'm going to call this a wave function. The electron function looks like a standing wave. These standing wave shapes describe very well the probability distribution of the electron. It fulfills my conditions, the conditions that are disappearing at the edges, and that it's smooth and not disjointed. So these functions are good distributors. I also see that there's not one kind of function that I find. I find a whole bunch of them. So I find a whole bunch of wave functions and I call these things psi. Because I feel this is a very special topic, and in special topics, four people tend to give them three letters. This is a three-letter, which means it's very important. And this end here is a label for how many half-waves you have. So the first one is one, the second one, two, and the third one, three. So I have a label here. This is the number of probable functions I can find, and it goes from one to eight to infinity, because there's an infinite amount of these functions that can add more than one-waves. So this is a function and a good description of the probability distribution of an electron in an atom. However, I've made some pretty harsh assumptions. I've said that I demanded that the electron function should go from zero here and there. But that's probably not really true, okay? Because how can an electron just be stopping to be here and not be on that side? It's a little silly. Who could be here? Maybe the probability is lower, but it's definitely not just a part zero. And that's definitely true in reality. So you can solve that problem by making this edge here go away and stipulate that in infinity the electron should go to zero, the probability of the electron should go to zero, because you cannot find an electron infinitely far away from the atom. If you put an extra condition in there and you're a smart mathematician, you can come up with solutions. And this is what people find. They find, again, the same kind of trend. They find the function, function describes the probability of finding an electron in an atom. Here's the inner phase again. You see that if this is just right far, the probability goes down, down, down. This is the first one. This is the second one. It makes one extra swing. But then at infinity, again, it goes to zero. And here, another swing, and so forth. So again, I have a wave function here, which has a label N, and the label N indicates what kind of solutions I've found. All these solutions are good solutions. Okay? Probable descriptors of what an electron can be. Okay. Now this N is what I call a quantum number. It is the label of a function. I call the thing a quantum number. It kind of quantizes which function is allowed and everything else is not. Okay. That's good. But there's another very, you know, hard assumption I made. And that is that the atom was a straight line, a one-dimensional object. It's not true. It's a three-dimensional object. How do we deal with that? We have to bring it into the picture for sure. But here we go. This is the atom. This is the nucleus. Okay? So far, I consider only the distance away from the nucleus. Okay? The distance away from the nucleus. And I saw that along this distance, there is a wave-shaped kind of behavior of the electron. The electron distribution of the pull-outs. A wave kind of pattern. That's along this coordinate situation. That's the distance away. So that, in addition to the distance away, there's also the distribution on the circle, or the sphere. The sphere becomes larger and larger if this R grows larger and larger. So I know that this wave function has swings go over and down. There's a wave-y pattern along this coordinate. What about this coordinate? What about this sphere? Is the wave function also having interesting wave-y shapes on that sphere? The answer is yes. That has. Okay? We're not going into the details. Because this is one coordinate, R, and this whole sphere, the shell of its spheres, is described by two extra coordinates. Two extra dimensions. It's a surface, which has two coordinates. I find a total of three coordinates. This is a three-dimensional object that has three coordinates. And along each coordinate, it's quantized. That means it has three quantum numbers, N, L, and ML. Those are the names. This is the one we already have. We've already seen that quantizing basically the behavior on this axis, and then there's two more coordinates on the surface S, and the quantum numbers corresponding to that surface are L and ML. Okay? So in each of the dimensions, the circle surface S, and the distance R, there is a wave behavior, which is labeled by a quantum. Okay, so this is the quantum number along the regular coordinate. These are the quantum numbers on the surface S. If you add them up, you get three quantum numbers. Okay? Now, this electron wave function, sometimes called an orbital, maybe module squared, is defined by three quantum numbers. That's the first thing we have to try to finish that. The electron distribution, which is described by a wave function, is a function that's labeled by three things, three quantum numbers, because there's quantization in three dimensions. All right. Now, what do these quantum numbers look like? Let me show you. We've already seen one, N. Okay? So this is N, and that is called the principal quantum number. The principal quantum number. That's just to make this name. What are the values? I mean, you can see it already. It starts at one and runs to infinity. Okay? That's it. The number of any say is one, because it's just N. Now, the second quantum number and the third are a little different, because they are not independent of the other quantum numbers. N is, N doesn't depend on N, just a number. But L, you will see, depends on N. The name is angular momentum. That makes sense. Angler means the angle on the surface, so that means something on the surface, that has a way to pattern. The way these are pattern is indicated by a quantum number L. Okay? It's called angular momentum. Its values, like I said, are not completely independent. They are 0, 1, 2, 3, and integer. Start from 0, runs to a maximum number of N minus 1. So the maximum number of L depends on what N is. Alright? We'll see a couple of examples of this. That means if you have the quantum number N, the corresponding L has N different L's. What does that mean? Well, let's say if N is 2, then L can be 0 and 1. It cannot be 2, because the maximum number is N minus 1. This is 1. So L can have only two values, 0 and 1. So for each N, the corresponding L, there's N possibilities for L. We'll wrap this up in a few moments. The last quantum number is called the magnetic quantum number. It has also to do with the quantization on the surface. In a slightly different way, the orientation of this pattern if you made it with L, its orientation is very much dependent on M. Its value is dependent on L. So if L has a certain value, then there are several solutions from M at the time. They run from minus L in index steps to L. Let me give you an example. Let's say L equals 1. If L equals 1, for that quantum number, there are three possible M-L quantum numbers. So, basically, minus 1, 0 and 1. The total of 3. There's a total of 3 if L is 1. The total of M-L quantum numbers is 2L plus 1. If L is 1, 2 times 1 plus 1 is 3. So this is what we just did. There are 2L plus 1 different M-L values for each L. So you see these quantum numbers have three of them, they are interrelated. N is independent. But L depends on N and M depends on L. Okay. Now let's give these things some meaning here. You will see it all falls into place in a few moments. Okay. So, let's look at a couple of great ones. Remember, these are quantum numbers on labels. Okay, so here's one. This, bless you, is a wave function with a certain N. And I'm going to set L and M-L both to 0. If that is the case, then we speak of an S orbital. An S orbital always has surface symmetry. Why? Because it doesn't have any quantization on the spherical surface. Because L and M-L both to 0. That means there's no distribution on the surface. Looks like a sphere. So there's a 1S. You get a 1S if this N is 1. You get a 2S if this N is 2. Alright. And then there's a 3S and there's a 4S and a 5S. Depending on what the number of N is. All of these are solutions. These are the solutions of that color called the S orbital. Okay. We'll skip this. And skip to number 2. The P orbital. The P orbital are wave functions. And typically, we speak of the word orbital if we take the square, the modular square, the wave function. Then we typically use the word orbital. Okay? So what is it? Those are only orbitals that have the value L equals 1. So if we have the wave function that has L equals 1, that wave function, and we take the modular square with it, is called a P orbital. What does that look like? Well, first of all, there is not just 1 for each of these guys. There's 3. Because if L is 1, that means that M-L can have two values. There's three possible T orbitals. And those two orbitals have different orientations. Okay? So all of these have L equals 1. All of these look like, don't look like spheres anymore. They now have a wave pattern on the circuit which makes them look completely different. They look like domes. Okay? So because L is not 0 anymore, they look different. They have a different shape. So this is the primary shape of the orbital that was defined by L. And the orientation of this shape, more or less, more or less, is defined by L. There's different values of M-L. They define the different orientations of these shapes. These are not straight. I mean, it's not true if M-L is always aligning things, but this is just a rough understanding. Okay? Okay, so let's look at orbitals in half. Now, let's first see how many of these things there are. There are total of 2L plus 1 equals 3 over P orbitals. Always. Okay? So the total number of P orbitals equals 3 because the P orbitals are always L equals 1. 2 times 1 plus 1 equals 3. So you can have, for instance, 2P orbitals, there's three of them, you can have 3P orbitals. There's also three of them. 4P orbitals and so forth. Okay, L equals 2 is called the D orbital. What is it? It goes away function where the L label has the value 2. You can take the modulus squared, you speak of M, D orbital. Okay, so if the L equals 2, then M-L can have even more value. It can have minus 2, minus 1, 0, 1, and 2. That's 5. There's 5 D orbitals. There they are. Here they are for a situation of N equals 3. So the 3D orbital. There's 5 different flavors. See, they have very different shapes. The approximate orientation is defined by M-L. The approximate shape is defined by L. Okay? How many do we have? Again, 2L plus 1. 2L plus 1. Since L is 2, 2 times 2 equals 4, plus 1 equals 5, is 5. Here about it. Okay? So these plots that you see here is just plotting this thing. The modulus squared of the wave function, that shape is what you see right there. That's it. All these things are wave functions. Possible solutions of the electron distribution. Right? So the electron can be in all... It describes where the electron can be. It will be in these loads. Exactly where the loads we cannot say. But I can say that it's on... It's very improbable that the electron will be there. It's very likely it will be one of this, this, this, or this. Okay? And it's unlikely that it sits in between, because in between, there's a zero there. So that's what these plots tell you. They tell you what is the likelihood of finding an electron near my nucleus. D-shaped, right? Okay. So let's start to see if you can understand these systematics here with these numbers. Okay, so let's start with n equals one. And if n equals one, l can only be zero. Because the maximum number of l equals n minus one. And if n is one, the maximum number of l is zero. So it's zero. When l is zero, m is zero. And when m is zero, you only have one orbital. And that is called 1s. There's only one of it. Okay? So let's go to n equals two. n equals two has two values for l, namely zero and one. Because l runs from zero to n minus one. If n is two, n minus one equals one. So zero and one are the two allowed values for l. When l is zero, one of the possibilities, then m-l, again, will be zero. And if l is zero, we have an s orbital. Only one s orbital. So in addition to a 1s orbital, there is a 2s orbital. When l equals one, you still have this guy, right? This is still for the value n equals two. There's two possible values for l. Zero, which is discussed. One is the next. When it is one, there's three values for m-l. Namely, minus one, zero and one. When l equals one, we speak of a p orbital. That's the definition of a p orbital. l equals one. So this is p, called 2p, because the function number n equals two. This is a 2p orbital. How many are there? There's three. There's three 2p orbitals. Okay. Then we have exhausted all the possibilities for n equals two. So we go to n equals three. There's three possible values for l, mainly zero, one and two. For zero, again, m-l is zero, and it is an s orbital. That's the definition of an s orbital. The definition is l equals zero. That's an l orbital. There's only one of those. So in addition to a 1s and a 2s, there is a 3s orbital. When l equals one, again, I have three possibilities for m-l. It's called a 3p orbital, because I'm in the three shell. I'm in an n equals three shell. This is a 3p orbital. They are again three. The last possible value for l when n equals three, l equals two. That's the last one. When l equals two, there is five possible solutions for m-l, namely minus two, minus one, zero, one and two. That is called a 3d orbital. Why? That's the definition of d orbital. When l equals two, you speak of the d orbital. There's five of them. So you've seen that the list of possible overflows. When you rank off the number, you can hold possible a lot of values of the quantum law. These are the lowest energy overflows that we have. And they fall out, or you can go to n equals four, n equals five. You get more and more and more solutions. Okay. Now let's look at, so now we have to find these overflows. But which orbital is the orbital, the lowest energy? What's the fourth one? Because the lowest energy orbital will be the orbital that is occupied. The high probability, the higher energy. So the lowest energy orbital is a 1s. And then the next is the shell, where n equals two. So n equals one is the lowest energy. n equals two has a higher energy. Both the two s and the two p have the same energy if you look at the hydrogen atom. Okay. So here's the hydrogen atom, the nucleus, the electron. The lowest possible energy it can be in is in the s orbital, the 1s. The next lowest possible energy it can be in is the two s or the two p. They're both at the same energy. And then, if you increase the energy even more, n equals three, you see the three s and three p and the three d all have higher energy. You can see the levels in the n equals two level and the n equals all that. Okay. So here you see these lines. These lines indicate, as read here, the s orbitals. There's only one, and this is one orbital, one orbital, one orbital. For each p orbital, you have three solutions. So three two p's, one, two, three, one, two, three. And the three d has five. One, two, three, four, five. Okay. So each of these lines here, this one here, is a wave function with a label. Okay. Two, one, let's say minus one. It's going to be three possible values. One, zero, minus one. Let's say this is minus one. This line here is one possible wave function. One possible set of quantum numbers. Okay. So if I ask you what is the, where is the electron in the hydrogen atom? Well, I say these are the possible locations the electron can be. So it will be in its lowest energy state. So the electron will be in the one-ethnological. The electron goes in here and will basically sit anywhere and is strictly distributed around the nucleus. That's the answer. Okay. So for hydrogen atom, the electron sits strictly distributed around the nucleus. That distribution looks like a decimal. That's possible energy. Okay. This is the hydrogen atom, which is not a very difficult atom. There's only one nucleus and one electron, or one proton and one electron. Okay. Other atoms have multiple electrons. The next one over is helium. It's two electrons. What happens to that? Turns out things have indeed lived in more complicated. As soon as you have more than one electron, the levels are slightly shifting because of the electron-electron interaction. Okay. The one-ethnological is still the lowest, followed by the two-ethnological, but the three-ethnological is slightly shifting upward. It's no longer the same as the energy of the two-ethnological. That is due to the electron-electron interaction. Because you have multiple electrons that will shift things around a little bit. If you look at the third shell, where n equals 3, we have three different kinds of orbitals. The s, the p, and the d. In the hydrogen atom, they were all the same energy. In any other atom, which has more than one electron, that's not the x. Okay. You see the 3s is lower than a 3p, and the 3d is the highest energy. So, the cold days, the fact that these things are shifted, we call that, at least, as we can, the non-digital degeneracy as God has built this. Hydrogen is the only atom where all the energies in the n equals 2 and x 3 levels are equal, between the hydrogen and the hydrogen. Okay. So, what is the counterpoint theory? It's a following. The s levels have lower energies than the p levels, which have lower energies than the d levels, which have lower energies than the f levels. The f is the next one over, and the cold days are 3. Okay. So, for any given n, s lowers, pulled by p, then d, and f, then g. So, okay. So, here is a list of table, actually. You see 1s, 2s, 3s, 4s, 5s, 6s, 2e, and so forth. This is n equals 2 shell, n equals 3, n equals 4, n equals 5, n equals 6. So, what is the energy high of me here? I know that 2p has a higher energy than 2s, and a 3d higher energy than the 3p. Okay. So, the way in which these states are organized is false. The lowest energy is 1s, all the way to 2s, then 2p, then 3s, then 3p, okay, and then 4s. This is our equation. The 4s energy is lower than the 3d. Okay. Then the 3d, 4p, 5s, is kind of a little mix up here. It's not true that everything has a, you know, a 3 in front of it is always lower of energy than something that has a 4 in front of it. Okay. You see that the 3d has a higher energy than the 4s. In the same fashion, the 5s has a lower energy than the 4d. Okay. And so forth. So, you can fill out this table like that. These arrows indicate how the energy is organized in terms of the lowest energy and the highest energy volume. So, if you can remember, first I would say 7 of these and you can get a shape. Okay. Now, as the example might have been, you don't complicate things even more. This is the last complicate. Okay. So, we see that the distribution of the electron can be described by a wave function that's three layers of closer numbers. There's possible solutions of these and these possible numbers are each of the layers. You can assert the values. The table is labeled as the wave function with a lower or higher energy. Okay. Because orbital has a higher or lower energy. Now, this is an orbital. Okay. The orbital, the number, the quantum number, is described in kind of the shape and the energy of the orbital. However, the electron that goes in, turns out the electron itself also has a quantum number. It's called the electron spin quantum number. Alright. There's two possible quantum numbers. Two values that's quantum. It is plus half and minus half. And sometimes we call this spin often spin down. So, the electron spin quantum number is another quantum number. This is not called the number of the orbital, but of the electron itself. There's two possible values. Plus half and minus half. Now, what I like to think about it is a problem. The orbital is basically the three-dimensional space in which the electron is inside. And then the electron itself in that space can be either plus or half or minus half. It's kind of the same as if you are driving in your car on the one-strand highway system, let's say. The one-strand highway system is described by three parameters. Okay? X, Y, Z. Those are the orbital quantum numbers. They define the space where you can navigate. And then in your car, you can be either, let's say, a boy or a girl. Two possible. Plus half and minus. That's what we like to spin. So, the driver can be either wheel, can be either wheel of two things. Right? And that person that is driving in the three-dimensional space which is labeled by three quantum numbers. So, but in the end, what we have is four labels. Namely, the first three, which are the orbital quantum numbers. And the last one is the electron-spin quantum number. The whole thing together is called the electron-rate function. The electron-rate function is four labels. Three four-spaces, and the last one for what's going on with the electron itself. Is it plus half and minus? Okay. Now, here comes the person called Mr. Paul. And he, who's a smart guy, he thought about all these things a lot, and he derived through all kinds of difficult mathematics. A rule, and the rule is the following. It says, in a particular atom, no two electrons can have the same set of quantum numbers. What does that mean? This is a white function, which describes an electron. There are no two electrons that have exactly the same white function. It means there are no two electrons that have the exact same set of quantum numbers. They must have a different set of quantum numbers, which means they have different rate functions. So, there are no two electrons that have exactly the same rate function. It must be different. That's what Pauli's solution is. This is called the Pauli-exclusion-prism. Okay. So this is what I did, Seth. The light comes in the same orbital. It has the same values for ML. So they must have different values for MS. So what does that mean? That means that if I speak of, let's say, a 1-ac as N equals 1, L equals 0, N equals 0. Now, we need 1-ac, which is MS. So if I put 1 electron in there, let's say it's plus half. If I put the second electron in there, minus half. If I put the third electron in there, I have a problem. We're only going to have possibilities. There are no other labels left. I exhausted all my possible values of the last quantum number. We only had two. Plus half and minus half. Okay. So this phrase here basically says we can only have two electrons in a orbital. Let's do that one more time. Here it is. Let's look at the p-roll. Let's look at N equals 2, L equals 1, and ML equals 0. Here it is important. That's the order. That's the rate function. Module square root is the order. How many electrons can occupy the orbital? All right. Well, I could put one in there. But if I put one in there, I have to give it a quantum spin. Do you like the spin number? So let's say I give it one half. The second electron that I put in there, I must give it a different quantum set. The set of different quantum numbers. The being said, the only way to do that is by giving it another electron spin quantum number because the first three are already set. That's the shape. That's the shape I want to do at least. Okay. So now I have two electrons that both occupy this orbital. Can I put another one in there? No, you can't. Because I've exhausted all possibilities in the last quantum. There are no other solutions left. If I want to put another electron in at them, I have to choose a different orbital. That means I have to change one of these quantum numbers. But if I do that, I am actually looking at a different orbital. So the third electron must go into a different orbit. So knowing this, let's look at the following situation. So this is what I just said. Only two light-years figure will work into one orbital. One spin-off and one spin-down. That's the total set of possibilities. Here I have the hydrogen atom. We just looked at it. We concluded there's one electron in the one s-mortar, the lowest possible energy orbital. That's the lowest possible energy situation in nature. So we have to look at the next experiment. The way to know to write that is one s-mortar, one electron in the one s-mortar. This is called an electron configuration. This electron can be spin-off or spin-down. It doesn't really matter. Let's talk to Williams over here. There's two electrons. The second electron must be of opposite sign. To call that, these two electrons are of the same pair. They're both hit the one orbital, the one s. The next element has three electrons. We just concluded the good electron cannot go into the same orbital. It must go through a different orbital. Therefore, it helps to the next lowest energy orbital, which is a 2s. So lithium looks like this. The electric configuration for lithium is 1s2, 2s1. Now look at that. I jumped on the first row for the second row right here. You see the H, the hydrogen has one electron in the 1s, lithium has one electron in the 2s. So they're kind of similar. That's why I'm going to say 5-blogger. Let's talk to Beryllium. Beryllium has a total of four electrons. To me, they're already occupied. So the fourth one will go in the 2s, because they're still placed. The fourth electron has to be of opposite sign, 2 to 1 is already dead. Okay? Now, boron has 5. This is the number 5. It means 5 protons, 5 electrons. 4 right here, that means that the fifth must go into the next available, which is the p. It actually goes into the p-sub-shell. Okay? Here it is. It goes right there. Now before we continue, I want to let you guys know that the 1s, the first row is completely filled with electrons. We call that the 4 or closed-shell electrons. 4 electrons are the electrons that sit in a closed shell. N equals 1 is here. Okay? All the N equals 1 orbitals are occupied. The 4. The 2s is still open. The 1s is filled, yes, but the 2p is still open. That's why this is called the open shell. We call those the valence electrons. Okay? So let's go to carbon. There's one more electron. What does it go? Here or there? It goes to the next. That's a rule, let's call it the Hons' Rule, that says the maximum number of unfair electrons is the lowest possible energy ratio. I would have put it right there. Put a little more energy. Put it next to it, and lower it. It goes into a different p-order. Okay? So that is carbon. Nitrogen, same, right there. So this is the electric configuration of nitrogen. 3 electrons and a 2p. For oxygen, I have no choice but to pair up one of the electrons. Okay? It doesn't matter which one. It doesn't matter which one. It could be any one. Let's start this, let's start by doing it. Okay? So this 4 means 3 are unpaired. The 4th must pair with one of them. And then we just start filling it up. F, put one more in, okay? So that means one is unpaired, the rest are scared, and neon has all of them paired up. But it has 6 electrons in the 2p. That means this entire 2p sub-shell is not filled. That means that neon has its entire n equals 2p shell filled electron. It is a closed shell per unit. Okay? So this is n equals 2p. It's filled now. That means the next element must be in the third row of the PR table. Okay? That's a neat case. That is sodium. There's one electron in the 3s. You're going to have to write down this orbital explicitly at this point. You can just do with this notation. One electron in the 3s, all the other ones are filled. Another way of writing this is a polymer. Neon. That was the configuration right here. A closed shell arrangement. Sodium has the same configuration as neon plus one extra electron in the 3s. This is a good way of writing the electron configuration of sodium. Magnesium, same deal, just one extra electron in the 3s. Okay? Or neon 3s2. We can go a little faster now. This is phosphorus. And it has an electron configuration of neon 3s2, 3p3. All these 3 electrons in the sub-shell of the p, the p orbitals are unparalleled in phosphorus. Argon on this end has all the electrons fill up the 3p shell, the 3p sub-shell. That means that now the entire n equals 3 orbitals, this whole set is filled with electrons. That's why Argon also had a closed shell arrangement. Very similar to neon. Very similar to neon. That's why they would say this is a lot. So the appear on table really tells you the electron configuration of the elements. Can you see it once again? You notice that all these guys, this whole column here, all of the elements have one electron in a s-lombon. These next guys, the rillian, magnesium, and so forth, have two electrons in a s-lombon. These guys here are all elements that have their last electrons in the p-cell shell. That's why they are related in the product columns with p-melons, p-blogons, and so forth. So we'll talk about this section right here. It's a little bit more complicated. All right, so I'm going to separate it very briefly. Remember the color. The orbits are not circles, okay? Of these electrons, not circles. They're best described by a wave function. Wave function has great particularity. Properties. It is labeled by quantum numbers. Quantum numbers indicate which wave functions are alive, which shapes are alive. Which shapes are good distributors and which wave functions are alive. So the wave function is called a wave function. It is labeled with quantum numbers. The quantum numbers are related to each other. The allowed wave functions, the one with the correct set of quantum numbers, if you take the modulus spread of it, you call that important. It really describes the distribution, the likelihood of finding the electron closely within these distributions and describe the value of modulus spread wave function. And only two electrons fit into one orbital. That is called Pauli's exclusion principle. Very important because that principle allows us to kind of derive the pure object using these principles. The energy of the orbitals, a particular row in the hurrow table, goes like this, as lowest than P, than D, than F. And then the last thing we did is we literally kind of derived the free-or-tale by filling up those orbitals. We put an x electron in depth of each subsequent element. And we see if we do that, and beautifully, between the structures we call the free-or-tale, the x-or-tale column is only too much. Only two electrons fit in that field, that's all. The p-block is 6y. There's only six electrons filled with pure objects. The p-block is only 2.3, 2 times the integral of 6. That block is 6y. This is y. All right. That's it. I see you on Thursday. Please don't clap and bump back for me.
UCI Chem 1P is a preparation go General Chemistry that covers: units of measurement, dimensional analysis, significant figures; elementary concepts of volume, mass, force, pressure, energy, density, temperature, heat, work; fundamentals of atomic and molecular structure; the mole concept, stoichiometry; properties of the states of matter; gas laws; solutions concentrations. Course may be offered online. Slides: 00:06- Orbitals and Periodic Table 03:15- Where is the Electron? 04:48- A Function for the Electron 09:48- The Radial Wavefunction 11:14- The Three Dimensional Wave Function 14:08- Allowed Wavefunctions 17:35- s-Orbitals 18:50- p-Orbitals 20:53- d-Orbitals 22:56- Orbitals 26:12- Energy of Hydrogen Orbitals 29:14- Energy of Polyelectronic Orbitals 31:12- Ascending Energy Levels 32:57- Another Quantum Number 37:54- Orbital Occupation 39:47- s- and p- orbitals 45:28- Modern Periodic Table 46:09- Remember This
10.5446/19446 (DOI)
All right. Here are the friends. Welcome back. Chemistry, lecture 8. We're going pretty fast through this. I'll say a few words about that on Wednesday, but there's over the midterm kind of flavor coming along. So we will just get a bit around and move to that shortly. Okay? For now, we don't have to worry about it, but just to let you know, things are moving along. Today we're going to talk about the naming of compounds. Okay? So we already talked about what compounds are, and now we have to know how to give them a proper name and how to recognize them. So let me turn back to these notations. This is from the pre-art table, right? And these are the elements. Element in its single form is an element. And this is boron. And boron, actually, do you remember this from the previous lecture, is an element that is not present at very high quantities on our planet. One of those elements had a pretty big dip in the abundance graph that I showed. But I just bring up this issue for two reasons. The first reason is that boron, what was among the very first lectures, and I think it was the first year that I was here at UCI, who would do things like this, I was trying to make a joke about boron. Okay? Boron, I thought, was a funny word. I thought it was a very, you know, a combination of somebody who's very boring and boron. So I was joking about that a little bit. I had a good time. Most of the people were laughing. After class, there was a person coming to my data table, and he said, look, I didn't really like my job at all, because I haven't done my boron. It's a great element. And instead, my entire summer working in a boron factory. I did not believe him, but I looked it up, and he's right. He said, I work close by instead, I work relatively close by in a boron factory. There is a boron, no, not really factory. It's more like a mine, if you want. Okay? So this is Rio Tinto. It is north of Los Angeles. It's one of the locations on our planet where there's a very high concentration boron in the soil. And people here have a set of camp and are digging out that soil and filtering out boron. Here it is. Big chunk of boron. Looks a little metallesque. Boron is an element. As you can see, there's a metalloid. So it has both angelic and metallic properties. So, for those of you interested in stories about elements, this is a nice book to read. So if you're interested in how elements got their names or peculiar properties of elements, this is actually, this is excellent reading. It's really a lot of fun. Here's boron once again. This is basically when you take a big clump of boron and you drain it out. It looks like this. A little metallic looking pebbles. And again, that's elemental boron. But elemental boron is not a compound. It's an elemental compound. It's not a compound made out of different kinds of elements. If I take this boron element and put it into something else, for instance, barrier boron. You see here is boron. That is the element boron that sits in this particular compound. This is an element, an elemental compound. This is not an elemental compound. This is a compound in cumbos of multiple elements. This is barrier boron. It's a glassy type of material. It's transparent. Just to let you know that these materials have nothing in common except for the fact that they contain boron elements. This is not transparent whatsoever. This is. So completely different material properties. If you put these atoms in different places and you give them different neighbors. I find it a fascinating aspect of matter. If you take the same elements, you could even slide a difference around you and you get something completely different. What kind of name do these compounds have? It's all barrier boron. That's a name for that compound. How do we assign certain names to certain compounds? Is there a set of rules? The answer is yes. For a simplest compound, there is a set of rules. And today we're going to talk about that. Okay, so let's talk first about binary ions. Binary ions, that is a compound that contains two ions. Depending on which ion. So the compound is a binary ion. Binary ionic compound. Sodium chloride is a binary ionic compound that contains two ions, the cation and an anion. Here they are. Sodium plus chlorine minus. The name is sodium chloride. Another example, cesium bromide, also is a binary ionic compound. It contains two ions, cation and bromine minus the anion. It's named as cesium bromide. You see already systematic here of the naming of these things. If you want to name binary ions, you have to look at the kind of metal that forms the cation. If the cation is a type 1 metal, then this kind of naming is appropriate. But if the type 2 metal, then we have to make sure that we give this name an additional bromide. So we have to make a distinction between type 1 metals and type 2 metals in terms of the naming of compounds that follow from these ionic compounds. So let's first start with binary ionic compounds that contain a type 1 metal. Okay, so what is the set of rules? Everybody can do this because it's a set of rules and if you follow it, you arrive at the right answer. So if you want to name a compound like that, you name the cation first and the anion second. Remember, sodium chloride, sodium is the first element. You say sodium first and then chloride, chloride is the chlorine anion. That one is second. The monotomic cation takes the name of the element. All right, sodium chloride contains sodium, so that monotomic cation is just called sodium, sodium chloride. The monotomic anion takes the root name of the element plus the suffix i, sodium chloride. The element is chlorine, but if you make the compound we call it sodium chloride. That's the name of the anion. Here's a couple of other examples. This is a binary ionic compound that contains two ions, cation anion. The cation is cesium plus. Cesium is a type 1 metal, so I just have to give it the name of the element which is cesium and then substitute that with the word fluoride because that's the n ion name. The anion is made of chlorine atoms and suffix i, cesium chloride. Another one, aluminum chloride. Aluminum, that's the name of the metal. It's a type 1 metal and then chlorine is becoming, it's now called chloride because it's an anion. Aluminum chloride. Is that not what it's made for? Now note that I don't bother here about the number of chlorine ions in there. There's three, but that's not specified here. It's just called aluminum chloride. How about this? What's this called? Calcium sulfide. Absolutely. Another one? It's an easy mark site. Very good. Now how about those type 2 binary ions? What's the difference? So if the compound contains a type 2 metal, then we have to do something extra. And that extra is, you call it exactly the same set of rules as before, but we supplement the name of the cation, the metal, with a Roman numeral indicating a chart of the ion or an oxidation state that we'll find out in the subsequent lectures. So here is an ion. This is manganese. Manganese plus. It is an ion with a chart 2 plus. If I make an oxide out of this, like this, this is manganese oxide, I have to specify the chart of the manganese ion. In this case too. The name for this is not manganese oxide. It's manganese 2 oxide, like this. Because manganese is a type 2 metal that can exist in multiple oxidation states. Here's another one. It can exist in oxidation state 3 plus. Manganese 3 plus. The oxide that follows from it has a different formula. So there's multiple manganese oxides. And I can specify them based on the oxidation state of the cation. This is called manganese 3 oxide. Which has a very different formula than manganese 2 oxide. Manganese can yet exist in another oxidation state where the chart of the cation is 4 plus. And in this case, the oxide that follows from that cation is manganese O2, because 2 oxide and then O2. The name of this compound is manganese 4 oxide. So here you see the necessity of specifying with the roman numeral the oxidation state of the metal. Yes? The question is how do you differentiate between type 1 and type 2? Remember from the last lecture there was a periodic table with colors. And in that periodic table there were metals. Some of these had only one option, the other one said multiple options. So those are the ones you have to know. Yeah, that's right. But a rule of thumb, actually, the first two columns in the periodic table are always type 1. Okay? Those are the mortality and alkali levels. Yes? So we need to have these like the one with the wheels. Like the oxide or something? No, no, no. We use the roman numeral for every binary compound that has a type 2 metal there. Okay, we'll see more examples of this. Okay. Yes? Is that something we need to memorize then? What we need to know is whether the metal is type 1 or type 2. And as you'll see, this is not completely arbitrary. Because the first two columns in the periodic table, right from the left, are type 1 metals. Okay? That's not hard to memorize. And aluminum is one of them too. All the metals in the middle, so to speak, are generally type 2. There are a couple of exceptions, but... Okay, so this is the same table from last time. I'm showing it once again. These are common type 2 ions. Okay? It would be good if you know them. You don't have to know them by heart necessarily. But be familiar with them enough. If you may recognize them, or you know them, you know iron tracers, iron clupons, and clupons. So these are very common. You don't have to reproduce this table per se. That's not a perfect word. You can work with this in a sense that you can find a name of these compounds. So here's an example. This is copper 1 chloride. If I would call this just copper chloride, I would be making a mistake. Because I have to specify what the oxidation state for copper is. Copper is a type 2 metal. It can exist in several oxidation states, among which 2 plus and plus. You specify which copper cation I'm talking about. This is copper 1 chloride. Copper 2 chloride would have a different formula. It would have looked like copper in a 2 chlorine anion. Right? Different comma. This is iron 3 oxide. How do you know that? There's 3 and not 2. Because there is 3 of these oxides. Oxides are always 2 minus. 3 of them means 6. 6 negative charges. That means if you have 2 of these, then the charge of the iron cation must be 3 plus. Right? This is what you should be able to figure out. If I give you this name of the compound, you should be able to write this. Okay, how about this? Now let's look at the chart here. I see here 2 types of mercury. It's a little funny. Mercury 2 plus is here. Mercury 1 is also 2 plus, but it has 2 mercaries together. So basically 2 mercaries together, and overall charge is 2 plus. Great special situation. In this case, what I have is mercury and oxygen. This is 2 minus, so this must be 2 plus. That is this guy right here. Mercury 2 oxide. How about this? What is this? This is lead? Is it lead 2 or lead 4? It's lead 2, right? Because Cl is Cl minus. That means 2 negative charges. That means this must be 2 plus. Oh, it goes fast. So this is again another chart I showed last time. Okay, and this is a table. Once again, you should be able, I can ask you to memorize this, which is really more than is needed. You have to be able to work with this. Work with this. Recognize the names. That's the kind of idea. You don't have to reproduce this table. You have to work with the compounds that are on it. Again, there is systematic in this table, especially in terms of those compounds that contain oxygen atoms. For instance, the nitrate and nitrate. This guy, which has one oxygen less, is called nitrite, and the one that has one oxygen more is called nitrate. In the same holds for sulfite and sulfate. I said it last time. I'll say it again. But note that sulfite is O3 and nitrite is O2. So the i and h doesn't specify how many. It just specifies relative to the 8, and the i is well less. That's the good thing. You see the same thing as we produced on this side. This is chloride. This is chloride, which is one more. And then hypochloride is one less. So hypo, i, a, then perchloride is one more. So from one to four octatons, oxo-NALs have this kind of homo-plagiar. Okay, so again, we'll work with this, and you'll see in what way you have to be able to reproduce this information. All right. So now let's move on to another type of compound. It's not ionic, but covalent. Binary covalent, meaning two types of elements make up this compound. And they are covalently bonded. Here are two examples. This is nitrogen monoxide. It is a covalent compound. Neither of these elements are metallic. So this is a covalent link between them. This is called nitrogen monoxide. Okay, this is also a covalent compound, sulfur dioxide. None of these elements is metallic, so this is a covalent compound. The name is sulfur dioxide. How do you determine the name of this covalent compound? This binary covalent compound. Here's the set of rules. If you follow these, you will be fine. Okay, again, the first element is named first. In this case, nitrogen, in this case, sulfur. The second element is named as if it were an anion. Okay? It's not an anion. It's covalent link. But just pretend it is, because that's what the naming... the naming follows the same kind of recipe. Then prefixes the number of atoms. If there's one, mono, two, di, tri, tetra, for four, pentaprofi, hexaprof6. Okay? But the prefix mono is never used for the first element. Okay, so let's put it in the pattern and see what happens. Here's one. This is an element. Sorry, the compound composed of two elements, phosphorus and chlorine. Both are not metals. It's a covalent compound. A binary covalent compound, could have mattered. What I have to do is name the first element first. That is phosphorus. The second one is as if it were an anion. That means chloride. So phosphorus, chloride. However, I have to specify the number of atoms. There's one phosphorus and three chlorines. That means, if I follow this business rule over here, this should be called mono-phosphorous tri-chloride. However, the last rule says the prefix mono is never used for the first element. So I drop the mono for the first. Hence, phosphorus tri-chloride. Phosphorous tri-chloride. Another one. This is nitrogen, two of it, and then one oxygen. Also a covalent compound. I see two nitrogen. So I call this dye, because definitely this is not one. Mono, I can't really use the first element of dye again. So I have a dye nitrogen and then one oxygen, monoxide. Dye nitrogen, monoxide. So the naming is different from the naming for the binary anionic compound. Specify the number of atoms. Okay. We'll practice a few later. Let's first move to another set of important compounds, namely acids. What is an acid? We'll talk about it extensively. Close to a second different, not now. But very briefly, an acid is a substance that, when dissolved in water, the cation is split off, forming a dissolved hydrogen ion or a compound. Now, acids are typically written with an H as their first element. Like here, HCl. This is called hypochloric acid. This is another acid. It starts with an H. This is sulfuric acid. So how do we find out the naming of these compounds? All right. Now, let's first distinguish two types of acids. One that contains an oxygen atom and one that does not. Let's start with the one that does not contain an oxygen atom, like this one here. How do you name that? All right. Here we go. You add the prefix hydro to the anion name. And then the suffix, IK, is added to the anion name. So this is chlorine. I add hydro to it, hydrochlorine, but then I change the suffix into IK. So hydrochloric acid. I always add the word acid to the final name. Hydrochloric acid. You add hydro to the suffix, and you add IK as hydro as the prefix and suffix IK to the anion name. Here's one. This is a compound. It's an acid. It starts with an H. It has no oxygen, so I can follow this set of rules. This is sulfur, and this hydrochloric acid. Hydrochloric acid. Another one. What is this? Hydrochloric acid. Hydrochloric acid. Okay? All right. So keep that in mind. And then we'll stick over to acids that do have an oxygen present. And it's different. Because if it has an oxygen, what I have to do is I start with the anion name, be it in elemental anion or a polyatomic anion, as you will see in a few seconds. And to this anion name, if this thing ends in 8, I add the suffix IK. But if it ends in 8, I replace it with IK. Remember, those polyatomic anions contain oxygen, they can end in 8 or 8. And depending on whether they end in 8 or 8, I have to do different things. So let me give you a couple of examples. This here is an acid. It starts with an H. It has an oxygen in it. In fact, this is a polyatomic anion. This is phosphate. Phosphate. So I take that word phosphate, and then I substitute 8 for IK. Phosphoric acid. Here's another one. An acid. This is the polyatomic anion. Its name is sulfate. And I change the 8 into IK. Sulfuric acid. The name of the anion, sulfuric acid, is the name of this compound. Here's another one. This is an acid. It contains an oxygen. This is nitrite. It ends in IK. This should be nitrous acid. Oops, that was too fast. Nitrous acid. So whether the polyatomic anion and oxygen ends in 8 or IK, we use the sulfate to get more costs. That's it. Alright, finally, the last set of percentages of compounds we're looking at are the so-called hydrates. Where are these? Well, hydrates are compounds that have a specific number of water molecules that are incorporated in the structure. Here's an example. This is cobalt-2 chloride, but in the lattice structure are incorporated 6 water molecules per cobalt chloride unit. So if each cobalt chloride unit has 6 water molecules associated with it, that unit will be itself, throughout the crystal. The proper name of this compound is cobalt-2 chloride hexahydrate. We're already on the naming of the, the naming of the spores. Right in the name of the root compound, which is cobalt chloride, can add prefix hydrate to the root. Prefix meaning the number of water molecules. Alright, so this takes 6, so hexahydrate. Here's one. This is barium chloride dihydrate, 2 water molecules, and it's 2 barium chloride. How about this one? How does this? Copper-2 Copper-2 sulfate pentahydrate. It's copper-2 because the sulfate anion has a 2 minus charge. 2 minus, the aim of the copper must be 2 plus. I can specify because copper is a type 2 number. So copper-2 sulfate pentahydrate. Alright? Alright, well those are the set of rules for this kind of compound. So we talked about binary anionic, binary cobalt, acids, both acids contain an oxygen and acids do not contain an oxygen, and hydrates, those are the ones that we talked about. So we should be able to name these compounds properly. This is just a small subset of a total number of compounds, of course, right? These are the simplest ones and we should be able to deal with them. Okay, so a few common stinkers. This is not iron chloride because iron is a type 2 metal, it is iron III chloride. Now, I can predict that on the midterm and the final, for a matter, there will be about 25% of the people that just forget about their own anion. Every game, just like that, we have about 3%. Let it not be you, okay? Just be mindful, even if it is a type 2, add this only normal to it. Another one, what is this? A very common problem with this one is that some people think, it looks a lot like SO3 2- from the table of polyethylene anion. It is called sulfide. This is something that, again, about 20% of people call this sulfide. It is not sulfide, this is not an ion. This is a neutral molecule. This is sulfur trioxide. Okay, how about this? Well, I put this in here because some people call this hydrogen carbonate. This is a carbonate anion, this is hydrogen, so this is not wrong, it is a serum. But we do consider this wrong in this particular context because it says aqueous. That means this thing is dissolved in water. Once it is dissolved in water, it is an acid. We don't call this hydrogen carbonate anymore, it is called carbonic acid. Why is it called carbonic acid? Because this is carbonate, it is an acid, it ends in 8, it becomes 8, carbonic acid. Here's another one. This is a compound that contains selenium and fluorine. It is a covalent compound. A lot of folks call this selenium fluoride. It's not correct because it is selenium hexafluoride. The hexafluoride has to be in there because this is a covalent compound. So this hexafluoride indicates what kind of compound it is. If you say selenium fluoride, you consider this to be a binary ionic compound, which it is not. How about this one? Covalent compounds containing nitrogen and oxygen. Some people call this nitrogen trioxide. It's almost right, but not quite, because it is a dinitrogen trioxide. Why do people drop the dye? Because they tend to drop the monoxide and then they drop everything. It's like dye, trie, tetanus, it doesn't matter. But if it's in the monoxide, all in the monoxide prefix is dropped from the first element. That's it, nothing else. Okay, another example. Select the cases in which the compound name correctly matches the porvola. Okay, so here I have a series of compounds. Let's see the name is correct. Rebedium selenium. Yes, there's a person. Now in this particular case, and this is maybe a little bit early, but I have to check whether or not the charges are correct. Rebedium is always 1+. Okay? Rebedium is actually the first column of the pair of table. Those ions always have 1+. The second column has always 2+. Rebedium must be 1+. Selenium is 2-minutes. So this is non-dutritional. Okay, this is not correct. Another example, Rebedium iodide. Is that good? Yeah, this one is good because iodide always has negative 1. Rebedium is 1+, so I could just stop it. Okay, how about this one? No! It's wrong. Good answer. Tell your ion is 2-minutes. 1+, is not correct. How about the fourth? Sodium bromide. Is that correct? No, it's not correct. Sodium is a first column, okay? Macaulay metal. It's 1+, bromine, 1-, so this should be just NABR. Then it would be sodium bromide. In this case, it's not. This compound does not exist. How about this? Sulfide is 2-, Rebedium 1+, incorrect. And finally, this one here. Completely nonsense. Rebedium is 1-, 3-, Rebedium is only 1+, doesn't work. Alright, so this is kind of the kind of exercise you have to be able to do. And things like this. Enter the formula for each compound. So we'll start with cesium iodate. This is kind of a tricky situation because iodate we haven't talked about. So let's see what it is. Iodate is an iodine atom with three oxygens. Just like carbonate is a carbon with three oxygens. Cesium iodate is a combination of these two guys. Both have charged 1-, sorry, 1-, here, 1+, for the cesium. Put them together, they form a neutral compound. This is the formula for cesium iodate. Iodate is a compound I'm showing it to you, so you know it exists. It's not part of the table, you have to be able to work it. But this is just to indicate that there's more beyond that table, okay? And your chemistry is not just the solaris and the small amount of table. It's much more than that, and it's giving you a flavor. Don't be afraid. Iron II carbonate is composed of iron II+, and the carbonate anion, which happens to be 2-, okay, so when you put them together, they form a nice neutral compound, iron CO3. How about this? Cesium sulfates. Cesium I+, sulfate SO42-, there it is. This is two, this is one, so I need two cesiums. I need two as a form. Chromium III chloride, okay, there's a three here. That means that chromium is in its oscillation state, three, that means three plus for the chart of the cation. Chlorine is always one minus. I need three chlorine to make a neutral compound, so it's chromium Cl3. Chromium Cl3, a beautiful purple compound. Very nice. That's it. That's it. Real true? Okay, before you guys go, let me make a one-clog, one-clog. I sent a false email, and I'm a left-right home professor. We have a form called the alpha form, some people left-right. It is actually a great means to discuss flavors of here. If you're unable to solve a question on the homework, you can just ask a question online, and hopefully somebody will answer, including myself. So try to use it. It's a great tool. You'll see again in the future, and we'll be happy to answer that.
UCI Chem 1P is a preparation go General Chemistry that covers: units of measurement, dimensional analysis, significant figures; elementary concepts of volume, mass, force, pressure, energy, density, temperature, heat, work; fundamentals of atomic and molecular structure; the mole concept, stoichiometry; properties of the states of matter; gas laws; solutions concentrations. Course may be offered online. Slides: 00:05- Naming Compounds 00:58- Elements... 03:09- Bedtime Stories 03:29- From Elements to Compounds 04:50- What's in a Name? 06:55- Binary Ions- Naming Type I Binary Ions 09:21- Binary Ions- Naming Type II Binary Ions 05:15- Naming Compounds: Binary Ions 12:57- Binary Ions 16:13- Naming Compounds: Polyatomic Ions 17:27- Naming Compounds: Binary Covalent 20:51- Naming Compounds: Acids 23:09- Acids 25:14- Hydrates 27:48- Common Stinkers 30:55- Example 33:21- Example, Slide 2
10.5446/19444 (DOI)
or is there one pole called an ad? No more old ad. It's really nice. Finally, we can talk about the loop ties. We try to figure out what the loop ties are going to be, and how to think about them. So the first week, the show summarize, we talked about numbers and units, and how to do basic calculations with time. Know your three phases. Know your basic convergence between the units. Take particular care when you are trying to convert the units that are based on the same. Amnioc or voluminous as a power two, the power two or power three, to make a conversion, make sure your unit that or also has that power unit. So that's where a lot of the calculations go wrong. The key to these calculations is that we are really basic and you really need to move on this practice. So please practice with a homework in a building way, take it seriously. It's for your own good. And not because I want you to do it, but because you want to do it for yourself. Educators, that's why we're here. You don't have to please me. Please don't make me happy. Do not make me happy. Make yourself happy. All right, Adams, yes. Oh, I haven't even looked up on the chemistry Nobel Prize. Yeah, I think one was issued today. Yeah. All right, great. Yeah, let's all look that up after class. I actually haven't seen it. I was so busy on things, but yeah, today was the release of the Nobel Prize. Thank you for pointing that out. Okay, now, we already have seen in the first lecture, and this is something that we all know about, that matter is composed of atoms. Chemical first atoms are the building blocks of nature. So this one just reiterates that point. We'd like to conceptualize the rule of roundabouts in terms of small particles that build up something bigger. Okay, this is, of course, little tiny objects, little tiny objects that are small things that make something bigger. U is basically, you go down to a very, very small scale of what we see, the special instrumentation. I pointed out a week ago, these little tiny blocks are individual atoms or particles like small molecules that can be sensed with these special instruments like STM, microshoves. So these particles, these little objects are really there. Not some kind of creation by scientists, okay? Which is just conceptual, this is real stuff, and they make up matter around us. Now, this is a concept that really goes back all the way to the Nobel Prize, as you can see. Here he is again, he says, matter in space are infinitely divisible. At some point, you cannot divide out any more, you are going to hit a fundamental particle. This fundamental particle is the fundamental building walk of matter around us. The Nobel Prize is very close in his description of matter. That leads to the way we understand matter. Okay, but this is not something that is easy to conceptualize. We all, again, we know this because of years of human history, but after Democratist, Aristotle, as we know, said, I don't believe that. So he went back to insist that in terms of matter, in terms of different kinds of elements, like fire, air, and so forth. So currently, we don't like to use self descriptions because it doesn't really fit with all the experiments, as we know. So years after Aristotle, people like Joe Dalton realized that the Democratist description was a much better way to explain the world around us. Much more consistent and with much more predictive power than the way in which Aristotle envisioned. He says, I think, Democratist is right. And Joe Dalton thought about this even more. And he says, I think we should think about matter in a following way. He says, matter is composed of elements. And those elements are extremely small particles, which are called atoms. Okay, an atom is a particle, and an element is a kind of atom. So there are different elements, which means there are different kinds of atoms. Now, all the atoms of the same element, so all the atoms that are the same kind really are the same kind. They are no different. They cannot be distinguished. They have no different features. They are all identical. So whether you have one group of people, five or seven, or a group of people, or a gazillion, they all are exactly the same. Yes? Not the isotopes. Well, I talked about, well, we'll talk about it in a moment. Yes, talk about isotopes in a moment. Okay, so how can we think about it? We have atoms of element X, which have a certain kind of characteristic, but all of them are the same. Okay, so this one and this one cannot be discriminated for each other, in terms of their properties, other than their location. This is another element. So these are atoms of another element, and they're kind of like, conveniently drawn a little bigger in a different color. But the point is here that they are different elements. The atoms here are all identical, but they're different from the atoms here, because they're different elements. Okay, so that is an important realization. Then, Mr. Dalton says, compounds are composed of more than one element. So I can combine elements or atoms together. They can be of the same kind. They can be of different kinds. It doesn't matter. And I can make compounds in this way. So compounds are particles that have more than one atom in them. In this case, it looks like a water molecule. Let's think of these as being oxygen atoms, atoms of the element oxygen. Atoms of the element hydrogen, they can form a water molecule, which has one oxygen atom and two hydrogen atoms. So this is the basis of thinking about matter. Okay, so then Dalton continues, and he says, in any compound, the number of atoms of any two of the elements present is either an integer or a central fraction. What that means is an atom is an atom cannot be split. It's either there or not. That means it's either zero, it means it's not there or it's there, which is one. So carbon monoxide has one carbon atom and one oxygen atom. Not half an oxygen atom or a quarter oxygen atom is one. One is the longest number that you can have. The ratio between the two, therefore, oxygen and carbon is one for one. The outcome of that is an integer or a central fraction. Another example, carbon dioxide. Two oxygen atoms, one carbon, so two oxygen, one carbon, two for one. Again, the ratio between the two elements is an integer or a central fraction. Point is, atoms are not divisible. So they're either there or not. There's one here, one there, one there, not half or a quarter atom in a molecule. And then lastly, and very importantly, a chemical reaction involves only the separation combination or rearrangement of these atoms. It does not involve any creation nor destruction of these particles. So the atoms themselves are not created or disrupted in the process. Chemical reaction is just a rearrangement of the available atoms. You don't take any atoms away or you add any atoms to it. Total rearrangement is same. You just bring them into places and you form different molecules. So we'll talk about this extensively in classes. Okay, so the atom is an important concept and fundamental in chemistry. So one atom made out of, well the atom is made out of electrons, protons and neutrons. So we have to look at these particles very briefly in order to appreciate what they do and where they are in the atom. Let's start with the electron. The electron is basically symbolized by a letter E and you can put a minus sign behind it because the charge is negative. Now what is a negative charge? It means basically that the particle has a charge. The negative is just by convention. I think this well called is also a charge. Okay, but if you call it a negative charge, if you see the obviously charged this, it's positive. But it's interesting to think about, this is just by convention. I could as well have decided as a charge of electrons positive, then the charge of a proton will be negative. Okay, that's how we did it. We said the electron has a negative charge. Okay, now the existence of electrons can be proven. And here's one way to do it. You can generate electrons in this fashion here. There's a capital N-O. This contraction here generates electrons. And then you can actually send them through this field. This magnetic field. Electrons have a very fluid property that have a spinic quantum number, which is either half or minus half. And so what you get basically is you get two different spots, A and C, of the electrons that are having their virgin paths. There's two possibilities. Either electrons are not scattered, or they're scattered in two ways, and these two ways correspond to the quantum number and electron spin of our doubt. Okay, so this is a kind of a pretty complex measurement. And when we get back to this, what is the electron spin? But the fact that you can prove the product that has an electron spin proves that an electron exists. Okay, it also gives information about the charge that this particle really has a charge. And that actually explains why it has a magnetic quantum number, and the charge is, like I said, by convention, a minus sign, the value is expressed in Coulomb. And that's a capital C, okay? This is the value of the charge of the electron. 1.6, 0.2 times 10 to the minus 19 Coulomb. A very small number, a very small charge, and the charge of the electron is very little. It also has a mass. The mass of the electron is also very tiny, expressed in grams. Now be careful here, because sometimes in some tables, the mass is expressed in kilograms, in other tables in terms of grams. The difference is a factor of about 10 to the third. Okay, so please look carefully in what unit the value is expressed. This case, it is in terms of grams, and in terms of grams, it's 9.1 times 10 to the minus 28. 10 to the minus 28, very little. One times your cube, small cube, weighs approximately a gram. And so this thing, one electron, is 10 to the minus 28 times lighter. So this is a humongously small number, very small number, that forms the mass of the electron is very, very tiny. Okay, let's move to the proton, which is also a charged particle. So it's indicated by this plus sign. You can prove their existence, and there has been one of them this street, including the existence of common other particles. Here's one for the proton. You can create so-called alpha particles, which are basically are helium nuclei, and you can send them through a piece of gold foil. And this is basically how researchers envisioned that. If the atoms of the gold would be basically empty space, then these particles sent through would simply just go straight through. It wouldn't change their path. Okay, so the alpha particle is a positive particle. When it hits one of these nuclei, then it can actually change path. All right, and the charge of the nucleus is an indication of how much and how far these alpha particles can scatter and change their path. You don't have to worry about the details, but the fact indeed that you get a particular pattern behind this gold foil indicates that the alpha particles are second of positive particles in the gold atoms, and the positive particles are identified as protons. All right, so how people prove that these things existed. For us, what we have to realize is that it has a positive charge, which basically means an opposite charge relative to the electron. There's a plus sign, the value is the same. It's the same value if and so on. The value of all cells is 1.6 times that of the minus 19 kilo. It also has a mass. The mass is again super tiny, 1.67 times that of the minus 24 grams, and that means if you remember the value of the nucleus of the electron, that is more than the mass of the electron. In fact, it's almost 2,000 times heavier than the electron. So the mass of the proton is more than the mass of the electron, while the value of the charge is the same. The value of the charge is the same, the sign is different, and the mass is different. There's another particle. Actually, this is the way in which people in the physics department like to think about a proton. It is actually composed of quarks, two of quarks and one down quark. We don't really have to bother about this. This is very interesting, but for us chemists, the existence of quarks is irrelevant for explaining chemical phenomenon. So we'll leave that to the physicist. The neutron is our final particle of interest, not Jimmy, but this thing here is where people can generate neutron beams and study properties of neutrons. Very interesting, and they are an essential component of atoms. The charge, interestingly, is zero, because it's a neutral particle, hence the name, neutron. It does not have a charge, but a proton or electron. It does have a mass, so it's a real particle. It has a mass. And imagine 1.67, almost the same as the mass of a proton, but a little bit different, a little tiny bit different. 1.67 times the number of monostrobe quarks. For all intending purposes, the mass of a proton and a neutron is approximately the same. Okay, so electron, proton, neutron are the ingredients of an atom. And again, the neutron can be thought of as composing three quarks, one up-court, and two down-court units. All right, now, how does it work then? This is the way in which we understand atoms are below. They have a nucleus, and the nucleus is composed of neutrons and protons together. They form the nucleus, and the nucleus is held together by a particular force, called the nuclear force. We sort the right term in it, the length scales that are relevant to the atom. This nuclear force is not relevant to length scales in which we live. So we really experience the nuclear force. Gravitational forces, electromagnetic forces, and forces we have to deal with, but on the length scales of atoms, the nuclear force becomes very important, and this nuclear force holds together the protons and neutrons. So, as you can see, the neutrons are neutral. The protons are positive, so overall, the nucleus has a positive charge. Of course, it has positive protons in it. Now, the number of the nucleus is rather small. We have actual numbers for these things. Okay, the hydrogen nucleus, which is one proton, the hydrogen nucleus is one proton, zero neutron, just one proton, one polynomial part. That is the hydrogen nucleus. The approximate diameter of that thing is 1.7 times 10 to the minus 15 meters, or 1.75 femtometers. That is the diameter of a hydrogen nucleus, a very small number. A femtometer is a very small number. Yes? Can you say that one more time please? What is the force of the electron? Oh, well, the main force of heat the electron is close to the nucleus is the electromagnetic force. The electromagnetic force. So basically, the electron is negatively charged, the nucleus is positively charged, and that is the main attraction between the nucleus and the electron. Keep the electron close to the nucleus. Okay, so this is the hydrogen nucleus, very small. Euradium nucleus, which is much larger, looks like this. Euradium nucleus has 92 protons, and so the hydrogen has only one. Euradium has 92 protons, and in addition it has 146 neutrons. That's a much bigger unit, much bigger particle. Its diameter is almost 10 times larger, 15 femtometers. Okay? So again, a very small number. So the nucleus is tiny. Now, how big is the nucleus compared to the electron overall? So this is a good way to think about it. Here's the nucleus, and its size is in the order of a femtometer, I mean, just at C. Okay? A femtometer is approximately 10 to the minus 13 centimeters. Okay? So 10 to the minus 13 centimeters equals one centimeter. So that's the size of the nucleus, and then this kind of haze around it is the location where the electrons float around. The electrons can be here in this area, okay, that is shaded here, and the extent, the distance with which they can move away from the nucleus is much larger than the size of the nucleus. Okay, so in this case you can see 10 to the minus eight. The difference is pretty common. Now, I'll give you an example with a few moments to appreciate the size of the nucleus compared to the size of the electron at the hole. Here on this table we see very quickly summarized those fundamental particles, the electrons that are basically somewhere around the nucleus, and then the nucleus itself composes protons and neutrons. The mass of the atom is largely determined by the protons and neutrons. The mass of the electron is very tiny compared to them. The electron is very contiguous to the mass of the atom. It is the protons and neutrons that define the mass of the atom. Electron is charged by this one, and the proton plus two, and the neutron is neutral. Okay, so let's look at this one more time in terms of numbers. Okay, so the diameter of the hydrogen atom, the hydrogen atom is a proton nucleus and an electron. One electron, one proton plus minus overall neutral. That constitutes one hydrogen atom. In the middle there is a nucleus which is a proton, and around it somewhere is squirming an electron. So the orbit of the electron, the extent of the orbit, is five times ten to the minus eleven, in terms of the diameter. That's 50 picometers, about 50 picometers. That is the extent of where the electron can be relative to the nucleus. So remember that the diameter of the nucleus itself is 1.7 femtometers. So this is a picometer, 50 picometers, this is femtometers. Pico is 10 to the minus 12, femtor 10 to the minus 15, which means a lot smaller. The nucleus is a lot smaller than the total size of our P-hex. So let's do a quick calculation with that. So the ratio between these two numbers, which is the size of the nucleus relative to the size of the atom itself, is a small number, 3.5 times ten to the minus five. So that means that the size of the nucleus is just a fraction of the total. And we do a very precise calculation because the diameter in half between here is the radius, the radius is this much smaller. And that means that if you take the cube of that, you end up with a difference, or a ratio between the volume of an atom and the volume of a nucleus, which is very, very small. So 10 to the minus 15. So that is an enormous difference. The nucleus is a lot smaller than the atom itself. That's basically what it says. And just to kind of reiterate that, if you think of the atom as a big football stadium, and you put a little tiny marble in the middle, then you can say that the nucleus to an atom is what the marble is for the football stadium. So in the middle, you have a tiny little marble. That will be the nucleus, the orbit, the size of the orbit of the electron is kind of symbolized here by the extent of the football stadium. The electron can be anywhere in the stadium while the nucleus remains there in the middle. So that basically means the atom is mostly empty space. Mostly empty space. What an empty space? It's nothing. There's no soft air. No air or whatever. There's nothing. Okay. Now we're going to hit the topic of isotopes. I'll run it right up here. What is that? Okay, so let's look at this particular nucleus. This is a nucleus which is the sodium nucleus. The sodium nucleus has 11 protons. Okay? 11 protons. In fact, the number 11 defines that this atom is a sodium atom. It is the atomic number. Every atom is atomic number 11, which means it has 11 protons, is a sodium atom. This atom also has 12 neutrons. 12 neutrons. Okay, so 11 protons, 12 neutrons. That is going to be the nucleus. If you add these guys up, you get 23. 23. That is this number right here. So this number right here is the sum of the protons and neutrons. Okay, now look at this guy here. This little brother. It's also a sodium atom. Why? Because it has atomic number 11. It has 11 protons. But lo and behold, it has 13 electrons. Sorry. Neutrons. Thank you very much. It has 13 neutrons. And that means that, let me ask a question, does that mean that it's still a sodium atom or is it something else? It's still a sodium. Because sodium is basically 11 protons, but it's a kind of sodium atom. So it's true indeed, you can have different kinds of atoms, but it's the same element. So you can have different isotopes. The second right here is 24 is the sum of the neutrons and protons. This one is still 11. So these two sodium atoms are each other's isotopes. Okay? Both have 11 electrons. Why? Because an atom overall is a neutron. They both have 11 protons. That means they have both 11 electrons. The only difference between the guys is that this guy has one more neutron and therefore is heavier. Okay? So this is a heavier isotope relative to this guy. But their masses are different. They can have different masses. Same characteristics. Otherwise, but their masses are different. Here's a list of isotopes. Most elements have multiple isotopes, some of which are very abundant and others are very scarce. Okay? For instance, there's more... Actually, these are just two, but there's more than two isotopes of hydrogen. The most prominent ones are hydrogen one. The abundance is 99.9%. And then the tiny fraction is deuterium, which is hydrogen two. Two meaning it has a neutron and a proton. This one only has a proton. Lithium, lithium-6, lithium-7, the difference between them is one proton. Sorry, one neutron. They do have the same amount of protons. They have different amounts of neutrons. You can look at the abundances here. Lithium-7 is the most abundant lithium atom. Boron, this two listed here, there's actually more in reality. They are the same. They have the same amount of protons, the difference of neutrons. They differ by one. Carbon, carbon-12, carbon-13. Oxygen, there's three listed here. Oxygen-16, 17, 18. They are all oxygen atoms, but they have different amounts of neutrons. The abundances are also very different. Look, this guy here is the most abundant. The other ones are very rare. And so forth. So, in summary, most allobots have multiple iso-nodes. Usually there's one or two iso-nodes that are very abundant. The rest is very rare. Or, as a very short lifetime, they fall apart. Okay, now let's look at this a little closer. If you look at the periodic table, you will see something like this. Six above this symbol, which is carbon. This is the symbol for carbon. And then below it, another number. That is the number of protons, or the atomic number. So the atomic number corresponds to the number of protons of the element. That is the average atomic mass. Tell me something about the atomic mass. But this word has a different color than this, which means this is important. This is the average atomic mass. What does that mean? We're going to talk about it right now. Okay, so this P doesn't belong here. The isotope notation is the following. If you have C12, it should be a six below it. That means the six protons 12 is the sum of protons and neutrons. So we subtract six from this. You get six neutrons. So carbon 12 has six neutrons. The relative abundance of that is pretty high. So most of the carbon atoms are actually carbon C12. Carbon C13, 13 minus 6, that means 13 is the sum of neutrons and protons. You subtract the total amount of protons, which are left-legged, is the number of neutrons. It has seven neutrons. Its abundance is much less. It is 1.1. If you add these guys up, you get almost 100%. So carbon C12 and C13 together basically comprise all of our approximate. A few more times, I tell you there are no significance. So what is this average atomic mass? It is the atomic mass of both elements given their abundances. You have a question? So we don't need to do the carbon 14 effect. That's not much. Carbon 14, its abundance is extremely little and has no impact on the average atomic mass. That's why we leave it on the discussion. Okay, so let's look at this atomic mass a little closer. What is a unit of atomic mass? You can express it in grams if you want. But there's a different unit that is easier to work with. And that is simply called the atomic mass in a form a and u. a and u. This is the definition of a mu. One mu equals the mass of one C12 atom divided by 12. That's very interesting. That is a definition. Why this? It's not something else. Well, we could determine something else. This is just a definition in the market. So this unit is just a convention. It's not rooted in any polynomial. We have to design a unit. We decide to do it in this way. One mu is the mass of one atom for carbon 12 divided by number 12. That's it. So then, what is the atomic mass of carbon C12? Well, you can see it here. The mass of carbon C12 is, put this 12 to the other side, is 12 a mu. Okay, so one carbon C12 atom equals 12 a mu. 12 atomic mass units. That's our convention. That's our convention that we will work with. Okay, so what is then the mass of other atoms? Okay, for instance, what is the mass of carbon 13? Is that just 13 a mu? The answer is not exactly. So let's look at that. The mass of carbon C12 equals 12 a mu. We just decided that. What is the mass of carbon C13? Well, that equals the mass of carbon C13 divided by the mass of carbon 12 times 12 a mu. That is the definition of the mass of other atoms. So you take the mass of one of these atoms, you divide it by the mass of carbon C12 and then multiply it by 12 a mu. That is the definition of the mass of other atoms that are carbon C13. Now, why do you do it in that way? The reason is because this number here can be determined experimentally, relatively easily, because it's a ratio. Okay, so I can have the ratio of the relative mass of one thing to another thing. I have C12 here, I have C13 here. I don't have to determine the absolute numbers. Only the ratio of these. That's something I can help you do. That number follows some experiment and is somewhat easily accessible. That's why we have this distribution in place. Okay, so this number is not exactly one, as you can see. Okay, it's 1.08. Multiply it by 12, you get something very close to 13, but not exactly 13. And that is because the mass of carbon of the nu is a little different. This number is slightly higher than 13. Only carbon C12 is precisely 12 a mu, and all other elements have the number, which is not exact in integer, slightly more or less. Okay, so now we are in a position, actually, to calculate the average atomic mass of carbon. How do you do that? You do like this. You take the fraction of carbon C12. This is the abundance expressed in the fraction, times its mass, and you add the fraction times the mass of the other guy, and you add the fraction of carbon C13. But this is a weighted sum. This is the contribution of carbon C12. This is the contribution of carbon C13. The weighted sum is the average mass. It's 12.011. I'll put another one behind me. 12.011 is the average atomic mass of carbon. The average atomic mass includes the weighted sum of all significant isotopes. Okay? Remember that. Okay, what is the average mass of other elements then? Well, let's have a look. Like I said, the mass of other elements are determinants follows. You take the average mass of the element divided by the mass of carbon C12 in a multiple of 12 a mu. Again, the reason for that is that this unit here, this thing here, is relatively easily accessible, experimentally. Okay, so what is the average mass of aluminum? Let's do that. The average mass of aluminum equals 2.248. What is this? Well, this is separation. Determine from experiment. It's not an absolute number. It's a unitless number. It's a ratio between two experimentally accessible numbers times 12 a mu equals 26.98 a mu. And that is exactly what you will find in a periodic table. 13 is the atomic number as 13 protons. Each aluminum atom has 13 protons. The average atomic mass equals 26.19. Question there. You always use carbon for the power? Carbon is the reference. Yeah, not a question. But how much of a fun that that was the one before I went into this? This number follows from experiment. You and I are the one who do experiments, or you don't know. But there are people that are doing this, their jobs, they do things like this, and they come up with these results. Are we using it? Yes. Where are the question marks? Are we using them? I just like how you... This is okay. The good question is, if you have to memorize a number like this, and you have to tell someone you know, this is just to show you that this is the way it becomes with these numbers in the periodic table. What you should remember is that these numbers are all relative to carbon. That's the message. Okay. Here it is, the periodic table. It all is one and unity. Okay, look at this. We will actually dive in this a little more carefully in subsequent lectures. But you see those numbers here are now more familiar. They are the atomic numbers, they correspond to the number of protons. Okay? In this particular case, there's no atomic mass indicated. If you look at that one, in that periodic table right there, you see the number below the bed, or the masses, the average total masses. Okay, we'll talk more about the structure of the periodic table. Let me briefly end this lecture with kind of like giving you an appreciation of where the element goes from. Okay, so this is an interesting striking statement. Approximately 70% of the mass of the visible universe that we know is hydrogen. Okay? Hydrogen is the most abundant element. Hydrogen is the most abundant element. Hydrogen. Okay? In our universe. In our reality, it is hydrogen. Helium makes up 25%. So we add these two numbers up, you'll left it 2%. Everything else is 2%. Okay? 70% hydrogen, 25% helium, the two lightest elements constitute almost all the mass in the universe. All the other elements are a side note. Okay? Virtually all helium and hydrogen were formed during the first three minutes of the birth of the universe. This is how we understand how the universe is related. Okay? So, that leaves us with the question where are the other elements come from? It's kind of strange, because there really are many more elements. Okay? So, they must come from combinations of helium and hydrogen. So this nuclear reaction is taking place that synthesizes all the elements that are having it by combining the lighter elements. Remember, the hydrogen has a only as more proton. If you smush it together, you have two protons. It means a heavier element. Okay? Helium has two. So putting two hydrogen atoms together, it's called helium. So we put a helium and a hydrogen together, it has three protons, which is a lot of the amount. So, basically combining atoms, using them, creating new nuclei of both protons and neutrons, is a way to synthesize new elements. And the way that happens, the way we understand it, is that it is stellar nucleosynthesis, which produces these heavier elements. Okay? We need very special conditions. Very high temperatures, very high pressures to accomplish this kind of reaction. It doesn't take place all around us in a particular condition, and they are obtained in the core of stars. This is where I take this. Now, interestingly, that is a process that can produce elements up to iron. Beyond iron, this process cannot produce heavier elements. So iron will be the heaviest element. We know that there are heavier elements than iron. So where do they come from? The only way they can be brought into existence is through a supernova explosion. Okay? Again, the way we understand it, is that the supernova explosion is the only natural process that otherwise is doing with, actually, we can reproduce it and occur in a nuclear reactor. So we can recreate conditions of supernova explosions. But without our own intervention, the only natural way that this happens is through a supernova explosion. And that is pretty striking when you think about it, because it lists in the form of a explosion. All the gold and silver you're wearing, and even the calcium in your bones, come from a supernova explosion. Many be overgun. Okay? So that's interesting. So the atoms that make up your body are very old. Actually, the calcium in your bones and things like that, having atoms, are old, old guys, having been around for a long time. Long before you were here, they were dead. They come from the stars. These are the faces of people who say, we're made out of star dust, that is literally true. Literally true. We are made of the dust that's produced in supernova explosions. Okay, so look at this. Hydrogen helium, the most abundant elements, then a big dip, and then all the other elements up to iron, another peak, and then beyond iron, it goes down again. It's really something we can explain now, because of how easy it is to synthesize a thing. Iron is very stable. To make elements beyond iron, it's more and more difficult in supernova explosions. Okay? So in the first two, which is uranium, the nuclei are not stable. What does that mean? The nuclear force is not strong enough to keep these particles together. That means that the particles tend to fall apart. That's called the radio pitting. And here's kind of like the first radioactive elements beyond uranium are neptunium. Okay, so this uranium is after uranium, neptunium after neptune, and plutonium after a plant of Pluto. Okay, so these neptunium and Pluto are a natural radioactive material. Their nuclei are not stable. They tend to fall apart after a certain time. It's called the life time of the nucleus. So what is radioactivity? It's basically if you have plutonium nucleus, it doesn't live forever. It's not stable. It likes to emit an ultrachronical, takes four particles out, two protons, two neutrons. If they're two protons out into neutrons, you arrive actually at a uranium nucleus. This is really a nuclear reaction where one element is converted into another element. Okay? That kind of concludes the basics of atoms. And we'll talk about it on Friday.
UCI Chem 1P is a preparation go General Chemistry that covers: units of measurement, dimensional analysis, significant figures; elementary concepts of volume, mass, force, pressure, energy, density, temperature, heat, work; fundamentals of atomic and molecular structure; the mole concept, stoichiometry; properties of the states of matter; gas laws; solutions concentrations. Course may be offered online. Slides: 02:18- Atoms 02:20- Particles 03:33- Atomic Theory 05:03- Dalton's Laws 09:40- Elementary Particles 13:40- Elementary Particles, Slide 2 16:40- Elementary Particles, Slide 3 17:45- The Nucleus 20:46- The Architecture of the Atom 22:25- Concept of Size 24:43- Concept of Size, Slide 2 25:36- Isotopes 28:05- Common Isotopes of Some Lighter Elements 29:41- Atomic Number 31:53- Atomic Mass 33:21- Atomic Mass- Average Atomic Mass 36:24- Atomic mass- What is the Average Mass of Other Elements? 38:24- Periodic Table 39:00- Origin of Elements 40:29- Beyond Helium 42:16- Heavier Elements 43:39- Element Abundance 44:02- Exotic Elements 44:52- Radioactivity
10.5446/19441 (DOI)
All right, folks, welcome back. Another fourth is chemistry. And this lecture is called Classification of Matter. Okay, so I will say a few words about science in general. Chemistry is one of the natural sciences. It has a long history, and I would say for 10 minutes, it's kind of like motivating why it is what we're doing and why we're doing it in a particular way. It also holds for physics or geosciences, whatever kind of natural sciences we're dealing with. It's the same kind of method, same kind of history. So I like this picture a lot. I think it's beautiful. And you may have gotten those moments, I think you all have. You look up in the sky, thinking else around you, you wonder how can all this be divided so beautifully and amazingly. Now, one way to address that and to try to kind of like get a grip on all these beauties around us is to kind of, you know, give the scientific description, right, to put some elements in place. And that is more easily said than done. So it's fun to realize, you know, put yourself in a situation thousands of years ago, and you're one of those Greek thinkers, and you're lighting your back, and you look at the star and you wonder, what is that light there in this part? What is that? Right now we know it's a star. You know, in our sun is a star too. We know that, but back then, of course, I did not know. How do you actually come to such a conclusion? That is not trivial, right? I mean, right now in our lifetime, we know so much. We take a lot of knowledge, or granted, knowledge has accumulated over the years, right? But this is not trivial stuff. All this knowledge took time to build up. So it's fun to realize that sometimes it's actually not trivial to come to a certain conclusion. So these people lived in those ages where not a lot of things were known, okay? They were starting to think about what is matter? I mean, how should we think about matter? Do we get proper descriptions of matter? So this person, Thales, he says, everything is made out of water. So he was trying to understand why the material is a certain properties, and his way of thinking about it had to do with the equities of different amounts of water. Maybe water acts in a particular way in different materials, right? Democratic says, well, I don't think that's the case. He says, I think that materials are based on an accumulation of many, many, many, many, many terrible particles altogether that are returned indivisible. So at the most fundamental level, I just have a whole array of particles together, and they form the material on a larger scale. It's the atomistic theory that we know now is the best way to think about materials. But in those days, it did not. So Democrat is actually, he's a person that lived at a later time than Thales. However, Aristotle, you may know him, he was a falsity classist, was a person that lived at a later time, a Democrat, and he did not believe this assertion of Democratism. He said... He said something about the computer stuff. Okay. I don't know what happened there. He says the materials are not made out of indivisible particles, but they are composed of different amounts of fire, earth, water, air, and ether. So it's a very different way of thinking about materials. Now, all of these things, they can be true. How do you know? At some level, you can say anything you want. So how are you going to discriminate between these different worldviews if you want? So how can we be sure that if you know now, Democrat is totally the person that gave you the best description? But how do we know that? Well, it turns out that if you actually start to do experiments and test things over and over and over again, at some point you can arrive at conclusions that make more sense, more sense than political views. And then at some point you may be able to rule out some hypotheses and confirm others. So basically, you take materials, you start to look at them very carefully, manipulating them, do experiments on them, a whole series, and based on the logical kind of the dash, you can arrive at certain conclusions. So this is something that people started to do very early on, that really they were ramping up in medieval times and accumulated into kind of a method that we now call the scientific method. So this is kind of like early days, and in terms of chemistry those were the alchemists, and they were really fascinated, of course, by turning everything into gold. Everybody wanted to be rich, if you're a poor person, of course, you're going to want more money, and what you're going to get at is to have more gold. If you can turn dust into gold, then you are golden. But you have to be able to do that, and so in order to do that, motivated by this kind of like, say, pressure for economic welfare, you kind of like start to experiment, so to manipulate, and you actually discover a whole bunch of properties of matter that you have not encountered before. Okay? And here's the first one that was also in that tradition, one of the later ones. So this is almost leaving in medieval times here. And he says, why don't you just like forget about making gold, but instead use the methods that we're working with to do something good, for instance, finding medicines. He was a person who was very motivated by helping other folks, other people, medically. He said the best way I can do that is by actually using these methods, like observing, experimenting, and trying to understand how a human body works, and then trying to help this person. This may seem like a trivial, but this is not trivial, because most medical practices were based on mystical beliefs, that had not necessarily anything to do with a logical deduction of observations, or the use of observations. Okay? So he actually used observation and logical deduction, and did something good. For instance, he says, infection comes from outside the body, okay? Which is something that people did not know. People thought that if you get infection, it comes from you, because you did something bad. Now we know it's a little like organism, the tattoo, it sits there, there's problems. Right? He was observing that, he took his things out of people's situations, you actually have less infection. Okay. He was still like a person of his time. For instance, he still believed in blood landing, planting through blood landing. Not something that was proven, but this, because we believe it's so strong, he's still following those good practices. Okay, so the thing that he was hearing, basically he had this method of trying to get closer to, I wouldn't say the truth necessarily, but to a better description of what matter is. And so I want to make a distinction here that, that method is very different from an opinion. Okay, scientific inquisition is not coming up with better opinions. So for instance, if this person says, that's how it is, he might say, it's not. You will say yes it is, you will say yes. Okay, so these people have different opinions, and you will never agree, right? But it's very hard to make sense of those. Okay, so opinions are great for a whole bunch of purposes. They're driving the forces in our society, if you want it good. But when it comes to trying to draw the descriptions of nature, this is not a good way to go about it. Okay, scientific inquisition is very different. And, you know, this is kind of like a very short explanation of how the method works. You have a clear observation of an event. You give a very proper description of an event, which is framed, which is as framed as you can be, not biased by what you wanted to be. Okay, this is really the difference between opinion and scientific inquisition. You have to believe everything that you believe out of your system, and just let the observation do its work. It's really hard for people, okay? But that's really important. So, a detailed description of the phenomenon by Frank observation, trying not to be biased of colors in your observation. Then, you come with an interpretation. For instance, this is Newton, well-known example. Apple falls, he gives a very detailed description of what he saw. The apple will sit in there, and there's a lot of loose, fell on the ground, very close to him. Very detailed description. Then he says, well, I can explain that if I come up with this formula. Of course, we destroy it much longer than that. But he has a formula then, and then, very important, you take that interpretation, and you test it again. Is this interpretation true on an all-circuit instance? That means if the apple falls from this tree, is this also true for another apple? From a different tree? Or from an object? For instance, if I throw a glass of building forward, does it also obey his law? And if his law describes the folding of objects throughout, then only then you can give this a certain amount of credit, so to speak, in the sense that this is a good description of folding a tree. This is not an opinion at all. This is scientific acquisition. This, of course, is also the method that we follow in chemistry. Let's say we have a beaker with chemicals. We do an experiment. Something changes. We provide the tail restrictions of these changes, of these phenomena, then we come up with an interpretation. This substance must be a reducing agent. That is an interpretation. You have to test it. You go back, change something. You can, for instance, say if this is a reducing agent, if I put a lot of oxidizing agents in there, the reaction must be different. So you do that, and indeed, if it is different, then you have to strengthen your hypothesis. You go back several times, tilt, you exhaust it all possibilities, and you can conclude that this must be an excellent description of this situation here. Again, this is not an opinion. You cannot just say, oh, I think this is a reducing agent. It must be something. No, you actually investigate that scientifically. Here's a couple of people. So after medieval times, people started to use that method consistently. Robert Boyle was one of these people, and he, through that method, the scientific method, actually uncovered a lot of different kinds of law that are available to chemistry, for instance, the gas law, and the differences in compounds and mixtures. Now, the law of war is called the Bursary. Also, the preposkler theory of matter was reaffirmed. He brought back his idea from democratic law, and forgotten because Aristotle had donated the weight of the thought about matter. And he said, hold on a second. My experiments indicate that if you assume that materials are made out of indivisible particles, I can explain all my observations. Therefore, this must be a better description than the description based on, for instance, earth, fire, air, and heat. So based on that, he could throw out our formal description as not being in your description. No hard feelings, just not a good description. All right, another person, very important to chemistry, Lavarje. He was the person who discovered the conservation of mass during a chemical reaction. We'll hear about that in this class. He also was disproving the Flaugiston theory. What is that? It has to do with, for instance, if you burn something, where does the flame come from? And so people thought that that was a material. It was actually baked in the matter, if you were. So the flames were already in there. That material causes flames once the material itself. So people had different levels of wood and a lot of flugiston. And water has none of this. So that, of course, is another good description but now we know that if something combusts or is on fire, there's a reaction with oxygen in the air. It's nothing intrinsically true. Also, the strawberry hydrogen, oxygen, and various other elements can be traced back to an formal avarice. That's an important contribution to the basics of chemistry. Thanks to this method of scientific thinking in precision. People were starting to discover more and more materials and started to organize these based on their properties. This person, Dimitri Mendelev, was smart enough to put him in a kind of a table based on their properties, their mass, the way they reacted. And so this is an early version of the periodic table. It's not a version that we have right now, but this is again, the very early stages, differently organized. There's many more elements. But based on this logical deduction, taking elements that you have and then combining them logically, he could say that Scandia, which was unknown at the time, he said based on my ordering, there was a blank here. He said the must-eval material that has these properties and this mass Gallium and Germanium were also not wrong at the time. And he's actually predicted that there were holes in this table. He said based on the fact that this table looks like the way it is and there are holes there, there must be elements with these properties. And he called them after the fact we called them Scandia, Gallium and Germanium. So this is extremely powerful. Applying these set of principles, organizing them, trying to make sense of it, he could actually predict that certain things existed and had nothing to discover here. And he of course was right. These are extremely encouraging developments that basically told people that they were on the right track interpreting what matter is. Now, this is a quote from Mandela. He says, we could live at present day without a play-doh, but a double number of newtons is required to discover the secrets of nature and to bring life into harmony with the laws of nature. What does that mean? He says, what? Play-doh is a good guy. He says, beautiful things. Nice philosophy. What we really need is something like Newton who applies a scientific method and actually investigates things and comes to conclusions that you cannot arrive at by just sitting on a rock on the hill and thinking for yourself. So this is the way that Greeks used to do it. They used to think just by thinking you can actually play-doh reality or basically give an expectation of reality. He says, that's fine, but that's not enough. We need scientific acquisition. Apotheosis is tested in real life and see if it is true. And then go back and strengthen your apotheosis. Really, he says, what will bring life into harmony with the laws of nature. Okay, last example, just to kind of like quote a story on this. This is Sherry Rowland, who recently passed away, sadly. He was here in the chemistry department. He won the Nobel Prize for the discovery of basically the completion of ozone in the ozone layer. He said, certainly, Victoria, the CFKs will deplete the ozone in our atmosphere and that is not good. So he set out actually on a campaign to prevent the release of the CFKs in our atmosphere. Successfully, and thanks to him, the ozone layer is no longer, I would say, the hole in the ozone layer is no longer at the stand, but actually straight. So this is a really important element. He was a very good atmospheric chemist, done many, many experiments, very meticulous, very scientifically accurate, so to speak. Took the scientific process extremely serious. So this is a statement that says, chemicals expelled into the atmosphere and pronounced climate effects, which is something that we observe through his experiments. So if you look at the conference data, it's something else. This person says, the greenhouse effect is utter nonsense. Now, whether he is right on the level, on the metaphorical level, and say, who is right? I don't know. But I can tell you that this is a binding by the scientific method and is trying to do the best you care based on scientific evidence. And this is not necessarily something. This is much more color and based on opinion. Okay, opinions are good in our society. But opinions do not have necessarily anything to do with scientific thinking. It's a very different way of true seeking. Okay, so distinguish these two things. The scientific thinking method is one of the best methods in my opinion we have to get to a better description of the world around us. We can understand the basic of our own thinking. Okay, so, it's all about matter. So let's look at this glass of, I don't know what it is, kind of juice, orange juice. It looks particularly delicious today because it's kind of hot. I would classify this as a homogeneous mixture. A homogeneous mixture, it's a mixture because I know there are multiple things in this glass. For instance, there is water in there, H2O. There's also sugar, sucrose in there. Another compound. Water is a compound, sucrose is a compound. They're all in this glass. Or, citric acid. Citric acid is a component that sits in oranges and it gives it a slightly acidic flavor. Or, vitamin C. Another molecule, a compound that sits in this glass. Together, they form a mixture which is homogeneously mixed in a sense that they will not separate out. So on a molecular level, they form a homogeneously. Nowhere in this glass I have one chung here, that is sugar, one chung here that is citric acid, and one chung here that is water. They're all formed together, they're mixed on a molecular level. And thus, it is a homogeneous mixture of compounds. These are compounds. Okay, so these compounds, they turn out to be pure substances in and of themselves. So, if I just have the water, if I'm able to take the water out here and just have the water, I have a pure substance. And so a compound can be a pure substance when it is just by itself. Pure water, or if I just have sugar, I have pure sugar, which is a pure substance. There's nothing else in it, it's sugar. So these compounds, once isolated, are pure substances. Now, as you can see, a water molecule, this compound, has still multiple things in it. It has hydrogen atoms and hydrogen atoms. So I can separate water out, and also sucrose, for instance, into individual elements. In this case, carbon, oxygen, and hydrogen. All these compounds here are made out of these atoms, either carbon, oxygen, or hydrogen. So these are elements. And then the elements themselves are composed of individual atoms. And the atoms are composed of electrons, protons, and neutrons. So we have a flow here from mixtures to pure substances, which can be compounds. The compounds can be separated out into elements. Elements are composed of atoms. And atoms are composed of electrons, protons, and neutrons. So let me classify this, or put it into a different scheme, which is a little bit more easy to understand. So I have matter here. I can separate matter into roughly mixtures, things that are mixed, and things that are pure substances. Let me first look at the mixtures. I can have heterogeneous mixtures. What is that? Well, let's say if I have, in one hand, some salt, and in the other hand, some sand, and I put it together into a small pile, then I have a mixture. But I know this is another homogeneous mixture. Because on a molecular level, these two substances are not mixed. Okay? It's a heterogeneous mixture. On the other hand, the glass on lemonade is a homogeneous mixture. There's no locations in this glass where somebody, you have only water or only sugar. It is mixed on a molecular level. Okay. All these mixtures are made out of pure substances, mixed together. So the pure substance then can be separated into elements. Okay? For instance, sugar contains the element of carbon, oxygen, and hydrogen. Okay? So the compound sugar is containing elements. Okay? And the elements themselves can also be in material. For instance, carbon, diamonds, is made out of only elements. Only carbon atoms. It's an elemental material. Okay? So diamond is a material of pure substance which only contains the element of carbon. Sugar is a pure substance, but it is a compound because it contains multiple elements. It contains carbon, hydrogen, and oxygen. Bones are called pure substances. Okay? So pure substances therefore can be distinguished with two categories. One is the compounds, which means the material is composed of multiple elements, or elemental materials. A material only is composed of one type of element. Think of diamonds. Only contain the carbon. Okay? So both of them, of course, are composed of atoms. Okay? Elemental materials only contain one type of atom. And compounds contain typically different types of atoms. Now, atoms are composed of a nucleus, okay? In the middle of the atom, and then electrons around. Finally, the nucleus is composed of a neutron and a proton. We'll look at these particles individually a little bit better. Okay? So these are the fundamental particles, the elemental particles. The neutron, the proton, and the electron that constitute matter. You can go even deeper and talk about quarks without doing that in this class. Okay? Don't talk about quarks. You and this chemistry class, you stop at this particular level. Neutrons, protons, electrons, provide us enough information to explain the different properties of materials. Okay. Now, now we have the concentration materials. These materials can exist in different states. Okay? We all know that. Think of water. Water can exist as ice, which is a solid, as a liquid, liquid water, and as a gas, water steam, water vapor. Okay? In all cases, the water molecule is the same. It's the same water molecule. It is just organized differently. Here, they're all very close together, organized into molasses. Here, they're still close, but not organized as well, a little bit more periodically, and here, they're not close at all. Okay? But realize that the molecules themselves are just water. No change, no chemical change between a solid, a liquid, and a gas. It's the same material, it's just organized differently. It's in a different state. Here's another rendering of gas. You see in the gas, you see little ping-pong balls going around those are molecules, I'd say. They're moving around in the liquid. They do too, but much more closely. Okay? And then finally, in solid, they're very closely packed. They still move around a little bit, not fully quiet. They still shake and bounce a little bit, but they don't move as much as they could in liquid, and no more close to the gas. But the properties of the individual spheres here don't change. It's just the packing and the closeness relative to the other particles that sets the difference between things. Okay. Now, let's look at a couple of fundamental properties of the trees. And I'm sure you're completely familiar with this. But let's just do this anyway. Mass is an important property of matter. And mass relates to the quantity of the material. The more you have, the more it's mass. Usually we indicate mass by this letter m. Volume is another property of materials. Volume, of course, relates to the amount of space occupied by matter. Now, sometimes that relates also to how much you have. Because if I have more of this particular metal, then this volume will be larger. But not always so. For instance, if I take this balloon, which is containing gas inside, and if I put the balloon into a fridge, the temperature will get colder, okay, lower, and then the gas will shrink. And hence the volume of the balloon will shrink too. But the amount of gas, the amount of molecules inside hasn't changed. Okay? So the volume is not necessarily dependent only on the quantity of the material. The mass is. This balloon and that balloon have the same amount of gas molecules inside. Yeah, their volumes are there. Just because of the temperature. Okay, now density is another very important property. Density is the ratio between these last two properties, the mass and the volume. Mass over volume, that is the definition of density. Okay, so here's an example. This is an example of a high-density material, lead. This is a chunk of lead. It's quite heavy. It's quite heavy for its volume. Okay, so the mass is high for its volume, that means that density is a large volume. So here is a......washing. Here are a couple of bullets. These are lead bullets. Okay? The mass in the bullets is much less than this big chunk of lead. Is the density also less? No. No, the density is exactly the same. Because the density is independent, completely independent from the quantity. Okay? So the quantity doesn't matter. Any amount of lead has the same density. It is mass over volume. The mass for volume, units, is the same no matter how much of the lead you have. Here's an example of a material that has a low density. This is bromine gas in a flask. The molecule is a very hard part. That means you don't have a lot of material per volume unit. Okay? So per volume, you don't have a lot. You don't have a lot of mass, that means the density is a low number. This is a low density material. Okay. So we talked about the different phases in which materials can be. We also know that materials can change their phase. Okay? So water can melt. Meaning it goes from a solid state to a liquid state. Okay? Let's see. So if you go from the solid to the liquid phase, we call that melting. You know that. This guy is experiencing that right now. Liquid to the gas phase is called vaporization. Okay? Liquid to the gas phase is called vaporization. P vaporization is the typical word used for this process. Gas to the liquid phase is called condensation. Okay? You've probably heard of that. Liquid to the solid phase is called freezing. Same thing happens with water. When it freezes, it goes from the liquid to the solid phase. And from the solid to the gas phase directly. So let's say a chunk of ice is directly changing into water vapor. That is called sublimation. You see a chunk of frozen CO2. Okay? So if you take a big block of CO2, you can keep that low temperature, it will stay in the solid. If you take that out into the room temperature, suddenly the CO2 molecules will quickly go into the gas phase, without going through liquid phase first. Okay? So that is an example of sublimation. This little kind of, let's say, vapor you see on top actually is not CO2. That actually is water of condensation on the surface. In this case, it should be little water vapor droplets. That's what you can see. The CO2 itself, you can see in the gas phase. Okay, so here's a diagram you'll see in the book as well. The solid changes into liquid. That's of course called melting. The opposite is called freezing. Right? We know what that is, words. Liquid to gas is called vaporization. You typically do not call it boiling. That's a typical language. You call it vaporization. The opposite is called condensation. And then going directly from the solid to the gas, sublimation and vice versa from the gas to the solid, deposition. That's the last word. Deposition. So recognize these words and know what they mean. This is a picture of the book, so you can deal with that. Okay. Let's look at some changes that take place when one of these space changes takes place. That's a very under-ascended. Here's an ice cube when it melts, it turns into water. Okay? And then when it vaporizes, it turns into steam. But during these processes, the density of the material will change. Okay? The separation between the water molecules will change if they go from the solid phase to the liquid phase, and from the liquid phase to the gas phase. Here they will be extremely far apart, meaning the water now has a very low density. Here it has a pretty high density. And here it has also fairly high density. Water is an interesting material because it turns out that the solid form of water actually has a lower density than the liquid form of water, which is quite unique because most materials have their highest densities in the solid form, but that's where they are the closest, and that slightly lower density is in the liquid form, and by far the lower densities in the vapor form, the gas, the gas phase. Okay? So that makes a lot of sense. You think about how far these things are apart, that means the density goes down. Okay? You can also have phase changes between two forms, two forms of solid. Let's look at graphite phases. Graphite is composed solely of carbon. Okay? And if you compress this, very high pressures, you can turn that into a diet. It's a very hard process. Extremely high pressures are required. You can do it. In both cases, the element that makes up this material has a lot of change. Okay? This is pure carbon, this is pure carbon. The way in which they're organized is slightly different. Okay? So in graphite, the carbon atoms are organized in sheets that are stacked, and in diamond they're organized in this very nice, exactly like flat, dimostructured glass. In all these cases, all these little balls there, the spheres are carbon atoms. Okay? So this is a solid to solid phase transition. Same ingredients, different properties based on different packing of the atoms. Okay? Another very important phase change is the change from something that is a solid to something that dissolves in water. Okay? So here's an example. Look at this example several times. This is an ionic lattice, composed of ions, negative ions, positive ions. This is a piece of salt, let's say, rock salt, or sodium chloride. For instance, you put it in water, it will dissolve. That means that the individual ions, this is the chlorine ion, this is the sodium ion, will be encapsulated by water molecules. It's taken out of the lattice, and thus floating away from the solidness. The process continues until there's no ions left in the lattice. Okay? So that means that the lattice is gone. That means you have no, you have no solid anymore. This material is dissolved in water. And the way you write that chemically is the following. Sodium chloride, it has an S, that means it's in the solid phase. I put a grain on this stuff in a cup of water, and then after a while, the lattice is gone. All the individual ions are now floating about. Okay? In the achy space, in the water phase. And therefore, the individual ions now are written down separately with this as a specifier. Okay? This is aqueous. It means they are dissolved. They're encapsulated by water molecules. Individual. Okay. So these are phase changes, and they should be discriminated from chemical changes. Okay? A chemical change, it's not just a difference in arrangement. Okay? So a physical change, a phase change, means that I have particles. How do I say the same? I'm just going to reorganize it. Put it in a different place, second differently. That is the phase change for a physical change. A chemical change is different. In a chemical change, you are actually forming new materials. Okay? Here's an example. A pretty brutal one of a chemical reaction. This is the combustion of organic materials. The tree is on fire, and that is basically the organic material would turn into CO2 and H2O under the release of heat. Another example, this is basically the deterioration of metal compounds. Corrosion. And here's a lovely lady doing experiments in the lab. Okay? Something you will be doing as well. In all these examples, the materials you are working with, and not just to be organized in space, they're actually making new chemical bonds. Okay? So different atoms now are making new bonds, forming new materials. Okay? So we will talk about it very extensively, but just to give you an idea, some very simple examples will help to clarify the difference. What happens if a silver spoon tarnishes? Is that a physical change or a chemical change? Who says physical? Who says chemical? Chemical. It is a chemical change because basically it is the reaction of silver, which is the spoon, with silver to form a new compound, a new chemical on the surface, which is this silver sulfide. Water freezes to become ice. What is that? That is physical. Okay? The water molecule itself doesn't change. It stays water. It just organizes itself differently and goes from a liquid space to a solid space. How about this? Sugar cube dissolves in your coffee. Chemical or physical? Physical. Yes, because the sugar stays sugar. It never changes. The molecular structure of sugar is the same. It is just surrounded by water molecules. It doesn't form a lattice. It's rearranged into the solution. And it acquires this A cube sign. And this, Tums, neutralizes your stomach acid. Is that a chemical reaction or physical? That's a chemical reaction. That's right. It's actually an acid-base reaction. Okay? This OH compound then is reacting with acidic components in your stomach, creating new materials. Okay. All right. Well, I think that's all you have for today. I'll see you guys on Wednesday.
UCI Chem 1P is a preparation go General Chemistry that covers: units of measurement, dimensional analysis, significant figures; elementary concepts of volume, mass, force, pressure, energy, density, temperature, heat, work; fundamentals of atomic and molecular structure; the mole concept, stoichiometry; properties of the states of matter; gas laws; solutions concentrations. Course may be offered online. Slides: 00:15- Classification of Matter 00:18- Lecture Notes and Worksheets 00:20- Understanding the Natural World 02:12- Greek Thinkers 04:47- Manipulating Nature 06:20- Manipulating Nature, Slide 2 08:05- Advancing Understanding 09:09- Scientific Method 11:10- Scientific Method, Slide 2 12:13- Pioneers of Chemical Science 14:41- Building Upon Knowledge 17:33- Scientific Method? 19:54- Classification of Matter 23:09- Classification of Matter, Slide 2 26:26- Classification of Matter: 3 States of Matter 27:28- Classification of Matter: 3 States of Matter, Slide 2 28:09- Properties of Matter 29:42- Properties of Matter: Density 31:17- Phase Changes 33:22- Phase Changes, Slide 2 34:06- Density and Phase Changes 35:24- Solid-Solid Phase Changes 36:33- Dissolution Phase Change 38:09- Chemical Change 39:38- Chemical or Physical Change?
10.5446/19437 (DOI)
The first observation is fairly obvious, and that is, dead people don't move. So don't pretend you're dead any more than you need to, or you will be. This is a paper that came out that looked at 17,013 Canadians aged not 18 to 90 years, and followed them for 12 years and asked them how much they sat down. Now there was some independent assessment too of how much they sat down. Some people, the working construction, for example, they aren't sitting down very much, except maybe when they get home, watch TV. Other people are sitting down a lot. For example, if you're a truck driver, you might be sitting down all day. And here's the conclusion, it's a little bit hard to read. These data demonstrate a dose response association between sitting time and mortality from all causes and cardiovascular disease, independent of leisure time physical activity. That's important because that means the guys who are there on the treadmill and then sit down the rest of the day still die. It means it's more important to be active all the time than it is to make a great display and then collapse. And they conclude in addition to the promotion of moderate to vigorous physical activity and a healthy weight, physicians should discourage sitting for extended periods. Well, you're going to have to probably sit down for two hours on Tuesday, but the rest of the day you should be ambling around all the time. And the second article, which this is very recent, June 1st, Immune cells gobble up healthy but idle brain cells. Here's the first line, use it or lose it, a class of immune cell demolishes idle searches and connections in the brain, even a healthy one, understanding more about the process could help prevent the onset of degenerative brain diseases. I've seen firsthand that when people retire, they often die or decline surprisingly quickly thereafter. And when people get older, everything slows down. You can't run as fast, you can't think as fast, you can't do anything as fast as you used to. And it could be that this immune system in older people mistakes the diminished activity in parts of their brain to mean time to get rid of this and it overreacts and then starts demolishing their neurons one after another. There are other mechanisms which destroy your brain as well, but this could be a new one. Until now, microglia have been dismissed as simple immune cells that do little more than protect brain cells from damage and tidy up in the aftermath of the disease. The idea that they can clean up brain debris has been well established in studies for brain disease as best students of Boston children talk about. But now, even without damage, we found them to respond to subtle changes in synastic function. And here's what they did. They took mice, they covered one eye on the mouse, so that eye is not nearly as active. And then they looked at their brains and they could stain the brains with dyes and then look at them under a microscope and see which cells are getting targeted. And here's what they found. Though with the help of dyes to distinguish the signals from the left and right eye, they saw in postmortems that microglia had preferentially proven its connection for synapses from circuits serving the underactive eye. Synapses were marked out for destruction through labeling with an immune chemical called C3. You can read this article in Neuron if you're interested. We think C3 is an eating signalist, says, Steve, and here are the green cells marked for destruction because they aren't being viewed. Green for go, which means go and disappear. Okay, no danger of that today because we're going to do some difficult problems. So we're going to be firing a lot of action potential today. Stay attention. Problem 64. Imagine this scary thing appears on an exam out of nowhere. Oh my God, oh my God, what am I going to do, what am I going to do? It's not the Zander-Wall's equation. It's some funky equation. Does anybody have any idea how many equations of state there are for gases? Just alphabetical list of everybody's names, Ken Robinson, Guillain-Riche, Reglett-Quang, on and on and on. They all have basically the same kinds of features. Some are more accurate than others. Some, instead of having two things, have three things that makes them more accurate and more tedious to work with. Here's the question, first of all, what do you think the roles of A and B are? And here, Bm is the molar volume, B over n, the number of moles. But here's the first question, what do you think the roles of A and B are? What are the units of A and B? Or do they? B is easier. And then, suppose that B is 0.1 and A is 0.05. What molar volume, in other words, what's B sub n, does the gas occupy at 5 atmospheres and 25 degrees Celsius? I didn't put the units on here, but they're going to be in leader atmospheres, blah, blah, blah. But you're going to have to figure out what they actually are. The units are not discordant units like PSI or something funny. And I'm going to do this two ways. I glue the cobwebs off this calculator, and courtesy of Kevin, who's sitting right over there, will put me in on a great way to solve these. I want to go through calculator method to solve these today. You've got a graph in calculator, so you can pull that out. And if you don't, you're going to go through the guessing method one more time, because that'll be just as good. The calculator method will turn out to be very useful if you want, very high accuracy. But I'm never going to demand very high accuracy. I'm not going to say, please give me this to four significant digits or something, so you're guessing correctly. So either method will work, but why not let's calculate or do the work if it will do it? Okay, so let's go through this. First of all, what are the roles of A and B? Well, the term B sub M is the molar volume. And we're subtracting a positive number from it. And therefore B must have something to do with repulsive forces, and that makes sense, because at least they seem to have standardized the notation for equations of state with two parameters. Usually B has to do with repulsive forces or excluded volume. Something to do with how small the thing can get before repulsive forces say, hey, forget it. You can press all you want, and I'm already a liquid or a solid, and I'm not going to change any further. The exponential term is new. It's on the right-hand side of the equation, and it's always less than one. But if we divide both sides by it, or multiply both sides by E to the plus 8 over RTVM, then we see that it increases the pressure. It increases the pressure because the real pressure, P, is too small. And the reason why the real pressure, P, is too small is because the gas is tending to shrink. In other words, it's always attracting, so it's not hitting the sides as hard as it could. But therefore, A has something to do with attractive forces. In the Van der Waals equation, what we did is we added a term to P. We added that term A n squared over V squared. That's one way to do it. Here we're multiplying it by something that's bigger than one. That's a slightly different way to do it. It may have some advantages. It may have some disadvantages. We just have to see. This equation is theoretically interesting to a number of people. And there are people publishing papers in 2001, 2003, and so forth about this equation. So they're still actually looking at it. It's a topic of research in some circles. So B is repulsive, or excluded volume, and A is attractive forces. Well, the molar volume has units of liters per mole, and because we're subtracting B, B has to have the same units. You can't subtract something that has different units. B must have the units of liters per mole. For A, it's a little bit more subtle, but we realize that no term in any exponential function can have any units. So A has to have the same units, since it's on the top, as RT times Vm. And I'll let you work out what the units on A are over the weekend. It might come in useful. Now for the last part, remember that we want to have an equation, if we're guessing, and it turns out for the calculator method, that doesn't have both sides changing. And when I did previously the moles problem in the Van der Waals equation, I divided by 1 over n, because that just seemed like the most obvious thing for me to do. But it may not be the best thing to do, and now I've decided that probably the best thing to do is get everything on the left side and make the right-hand side zero. Because if your calculator says a negative number, you know you're too small. And if your calculator says a positive number, you know you're too big. And on an exam, that may be faster than comparing with 26.3472. Okay? You just try to get it to zero. And it turns out your calculator, if you're trying to get it to zero, will do that for you. So here's what we do. We take our equation which was written in this form, this is just how it was presented in a reference, and we multiply both sides by the molar volume minus b, so we bring that over here, and then we multiply both sides by e to the plus a over RTVM. And then we still end up with the RT over here. We could start guessing with this to get v, for example. Or we could go one step further and subtract RT from both sides and make both sides zero. And when you're rearranging equations, the correct way to think about it is that whatever you do on one side of the equal sign, you got to do the same exact thing on the other side. I don't know how they taught you to do it in high school, but sometimes it seems like it's a little bit muddy or iffy. The clear way to think about it is to just guarantee that you're doing the same thing to both sides. If x is equal to y, then 2 times x is equal to 2 times y, and log x is equal to log y and so forth, and 1 over x is equal to 1 over y. Just make sure that you're doing the same thing to both sides. Now with this equation, it turns out, let's see what this one is. This is not so fancy. T i 83 plus. I don't think that's a super-duper fancy calculator, but I confess I don't know. Okay, so oops, excuse me. But once we have it in the form on the third line below, once we have it in this form, your calculator will solve it if you know how. However, once I get the solution for whatever I'm looking for here, I would put it back in one time to check the answer because I don't like a little black box telling me what grade I'm going to get in a course. I like to verify myself what the solution is and make sure when I put it in, it balances out about right. So let's have a look. So you first go to the, well, first of all, I should be complete. You first turn your calculator on. If you don't, then the rest of the instructions don't work. And then you go up to this top thing where it says y equals, and you hit that. And you're going to use the first, this one here has five of them. Maybe there's more, but it's showing five. y1, y2, y3, y4. And for the first one, I enter the equation in with numbers. We'll do it in a second. I'll show you the numbers. So you have to type in your equation. You don't have to simplify it. It can be as messy as you like. But get the parentheses in the right place or it'll be wrong. Missing parentheses or a syntax error when you do the calculator way will be fatal. And then for y2, you just type in y2 equals zero for the second equation. And then for the rest of them, you make sure it's showing nothing at all, this blank. On this one here, it's highlighting the equal sign for the ones that it's actually going to graph for me. So y1 and y2 are highlighted, and it's going to show those two. And then you have to select a region to plot. We can do that in all these problems because we have an estimate for v from the ideal gas. And we can plot from smaller than v to bigger than v. If you let the calculator choose, it may make a crazy choice on its own. Like from zero to some number, and then when v is zero, the equation may blow up. Or become nonsense. And so you may want to control what it does. And then if you want to zoom, you can select the region to plot in the zoom menu, or you can let the calculator choose it by just entering zero in the menu. And your equation has to be, the variable you're solving for has to be x, not v, or anything else. And it has to be of the form some function of x equals to zero, not some other number. But that's not a big deal, especially if you practice. Then you hit graph and your two functions come up. Your y1 function and the function y2 equals zero, which is sometimes hard to see because it might be right on the axis. And then the calculator will figure out for you where the two graphs intersect. And that's your solution. You press second, and then you go on the trace. You press second trace. And then once you get in that menu, you press five on this calculator where it says intersect. Or in your calculator, you press whatever it takes. And then you hit enter a couple of times I found. And it may ask you a few questions like, I can't recall all of them, but one of them was important. One of them was initial gas or something like that. And I thought, perfect, because I can put in the ideal gas equation for my initial gas. And that will pretty much guarantee that the calculator doesn't get lost. It doesn't go looking way, way off somewhere else. Give me a crazy number. Okay, and then it should, it waits a while because what it's doing is guessing. And it's not as fast as a computer. It waits a while, don't panic, and that says, boom, number. And the third time I tried it, the number was correct. I made two mistakes. So practice if you're going to use this on Tuesday. You're welcome to try it. So let's try it with our gas function. Here's our numerical equation. If you want, you can go ahead and enter this in. Instead of Vm, use x. So mine here has 5 times quantity x minus 0.1 times e to the quantity 0.05 and then I put in 24.46544 times x. I just went ahead and multiplied r times t. And of course, I would never be in such a hurry that I would use 25 Celsius because that would be a disaster. So I put in this here, minus 24.46, etc. That's my function. And for y2, I put 0. And then on this calculator, which had some funny variables set for x, I had to go to window and tell it to plot it from x equals 1 to 10 because it was plotting from some other problem in the ancient past. It was plotting negative values of x and volume is positive. I just picked x equals 1 to 10 and I didn't give it a guess the first time. I tried it. And bingo, it came out and it said x is 4.991 and that's exactly right. That's right on. That was very interesting that it did that so quickly. You can try this. These slides and all the other ones will be up there the second I get back to my office today. Try it and practice if you want to use this method. I would be in favor of this. I would have told you about this right at the beginning had I been using this calculator, but I tend not to use calculators much. I either use a computer or I use this thing. And that's in fact correct. The molar volume is about 5 liters. That seems to be a very good method. And it will work with any equation that you can enter into your calculator, which is any equation that I'll ever give you on Tuesday. It doesn't matter what it is, right? And as long as you have a good guess to start with from the ideal gas equation, you're pretty much in like flint. Now if you don't have such a fancy calculator as that one, like I say, I don't think it's that fancy, but if your calculator will not solve it automatically, you can still get it with guessing. Let's just try the same equation here. 5 times molar volume minus 0.1 times the exponential function of this spinach minus the same thing equals to 0. And let's figure out our ideal gas estimate. The molar volume for the ideal gas is just RT over P because N is 1. And I put in R times T in Kelvin, 5 atmospheres. And my ideal gas estimate was 4.89309 liters. Of course, many of those digits are not important. Usually I only need 2. And let's just try guessing. So now we're going to guess and try to get it to be 0. Well, I guess the ideal gas and I get minus about a half for the function. I want 0, so I'm too small. And I could see right away by looking at the 5 atmospheres times V that if I change V by 0.1, that it's going to give me the right answer. But let's suppose we didn't know that. Let's guess a little bit bigger. Let's guess 5.1. Now I see that it's about equally on the other side, a little bit bigger. Target value is 0. It's too big. Well, I'm going to guess halfway in between because this is minus a half and this is plus a half. I'm going to guess 5. And bingo, it's very close. But it's a little bit too big. And therefore I'm going to drop it down just a smidge, 4.99. Now it's a little too small. I can usually stop here on an exam because I know to two digits the answer is 5.0. And if I only want two digits, I'm done. Because the true answer is between 4.99, which is too small, and 5.0, which is too big. So I know that to two digits it rounds to 5.0 and I'm done. But it's not really too much longer depending how, what kind of facility you have with typing equations into your little calculator. You'll have to decide which method is better. And then I added just a little bit more. And boy, it's very, very close. That's certainly okay. My comment here is that if you need a lot of digits, then the calculator method is superior because it'll give you a lot of digits and it's worth doing it. But if you don't need a lot of digits, it depends how fast you can type the equation into the y1 equals whatever. How quickly you'll be able to get it. So try that and see how it works. Now when I quit last lecture, I was talking about Ka and Kb. And there are lots of subscripts on K because there are lots of different kinds of equilibrium constants. One for any kind of chemical reaction. And certain kinds of reactions turn up a lot. If you're working in a biochemistry lab, you're going to be working with acids and bases a lot, making up buffers. And you're going to want to know Ka, or as you'll see in a more advanced course, you're going to want to know Pka that you'll learn about in Chem 1c. And Ka always refers to an acid dissociating. That's what it means. And it's always this kind of equilibrium constant. Concentration of H plus, concentration of A minus, divided by the concentration of the reactant acid at equilibrium. Kb always refers to base. And for example, we showed this last time, if we take some base and we add it to water, then we get the conjugate acid and hydroxide. And Kb is always the concentration of this times the concentration of hydroxide, divided by the concentration of this. And you notice that it does not, does not, does not, does not contain the concentration of water. The reason why it doesn't contain the concentration of water is a little bit of a subtle point. But just keep in mind that if you've got a pure liquid or water as the solvent, you don't include it in the equilibrium constant. And you likewise do not include solids when things are dissolving. So we don't include concentrations of water when it's the solvent, nor do we include pure solids or pure liquids in the equilibrium constant. The final K that's interesting to know about is Ksp, which is called the solubility product. For a salt like sodium chloride dissolving in water to give sodium plus ion and chloride minus ion, Ksp is just this concentration of M plus times the concentration of X minus, and I do not divide it by the concentration of the solid, whatever that was. Part of the clue is when you look at something and you say, well, what is the concentration of the solid? You stop and you say, wait, that doesn't make any sense. How am I going to know what that is? What does it mean? Does it mean? And then that's the clue to leave it out. Don't put it in. If it's Mx2, then it's the concentration of M times the concentration of X squared because there's a 2 here. And if it's Mx3, it's the concentration of M times the concentration of X cubed because there's a 3 here. That's our rule for the reaction quotient. There's nothing new about that. Ksp is listed for all kinds of things, and Ksp is important to know because if we can make something insoluble, we can make it come out of the water. Therefore, if we're doing something like we're trying to remediate some pollution in water, if we can get the bad guy to precipitate by putting in some other stuff, then we may be able to then filter out the solid and let the clean water go on. And there's a lot of interest in doing stuff like that because water is being recycled more and more and more and more because we want to use it many times before it actually gets to the ocean because fresh water is very precious. If we had a better plumbing system, we would not have drinking quality water go into the toilet because first we cleaned up the water like crazy so you could drink it if you wanted, and then what happens to it? Well, it's pretty much non-drinkable fairly quickly. We could actually have two pipes coming into every house and have grey water in the toilet and drinking water only coming out of the tap, and that would be much more efficient, but we would have had to have thought about that back then when we wired up every house with plumbing, and nobody did. It didn't seem important at the time, and so it's not done. Anyway, let's figure some solubility here and see how it works. Solubility just tells us how many moles per liter of compound will dissolve in a solvent. So for example, some kind of salt dissolving in water, and Ksp is going to tell us what the solubility is because once we know Ksp, we just solve an equation and we can figure out. So here's an example of this. The solubility product for calcium hydroxide I found is 5.02 times 10 to the minus 6. What is the solubility of calcium hydroxide in water? What that means is how many moles per liter of calcium hydroxide can you throw in water before you're going to have some gunk at the bottom? No more will dissolve. Let's see how to do it. So we have an Mx2 equation. Well, anything that's an equilibrium constant, if you see K on the exam, you don't start doing anything at all until you write the chemical equation. You write the chemical equation down and then everything is crystal clear. Yes? Sure. But if you don't write down the chemical equation, it seems obvious to a chemist, but it's not obvious if you're a chemist in training. You may start doing things, calculating things, and you go around in a circle like a cat chasing its own tail because you never wrote down the proper chemical reaction and balanced it and see what's what. Whenever you see K or delta G or anything, you say, what's the chemical reaction that's occurring? What is this referring to? And for solubility, it's always this stuff dissolving. I've left out the water. The water is kind of riding along in this aqueous, but obviously we need some water on this side to dissolve it, but we don't include water in the equilibrium constant for Ksp anyhow, so it doesn't matter. And we don't include the pure solid either. It's just these guys that matter. Ksp, this number, 5 times 10 to the minus 6 is equal to the concentration of calcium times the concentration of hydroxide squared. Now we have to say, okay, we don't know what either of these are, but we know the stoichiometry. Every time one of these guys dissolves, we get one of these and we get two of these, so we know exactly what we're getting here. We let X moles per liter dissolve. We don't know what X is. We get X moles per liter of calcium 2 plus in there and we get 2X moles per liter of hydroxide. Therefore, in terms of our variable X that we're going to have to solve for, our solubility product equation here, our algebraic equation becomes the following. 5.02 times 10 to the minus 6 equals X and boy, do I love the parentheses here because I have been fiddled so many times by not squaring the two. And if you don't square the two, you're a factor of two wrong. And I think you know by now what happens on my tests if you're a factor of two wrong. You get X times 4X squared, which is 4X cubed. And this equation is easy to solve because there's nothing to really isolate. We just divide by 4 and take the cube root. That's what I've done here. X is 1 fourth times 5.02 times 10 to the minus 6 raised to the 1 third power or the cube root. And I got out X is equal to 1.08 times 10 to the minus 2 molars. That's how much calcium hydroxide will dissolve in water. About a hundredth of a mol per liter. It's not very soluble. The concentration of hydroxide is twice the concentration of calcium. Therefore, if an exam problem says instead of the solubility, if it says what is the concentration of hydroxide, you go through all this and at the end you say wait, the concentration of hydroxide is 2X. The concentration of calcium is X. And so you have to multiply this by 2 and you get 2.16 times 10 to the minus 2 molar for the concentration of hydroxide. And I've just made a little summary here of all the common cases. For a regular one to one salt, Ksp is X squared. You want to figure the solubility, you just take the square root of Ksp. That's pretty quick. For a salt like calcium hydroxide of the formula Mx2, Ksp is 4 times X cubed because we had to square the 2. For a salt like aluminum chloride, Mx3, Ksp is 27, which comes from 3 cubed times X to the fourth. And then the one I always hated when I was a student, which is the one we always got, was some salt like this, aluminum carbonate, diabolical. We have 2X squared here and 3X quantity cubed here. We have 27 times 4. We end up with X to the 5. And you can just count the number of ions and that's the power of X. There's 3 guys here, there's 4, there's 5. That's the power of X. But this number is important. And this one in particular is very error prone because you have to square the 2 and you have to cube the 3. And if you don't, you get it wrong. But whatever it is, just write out the reaction, see how many moles of each ion is made, and then raise it in parentheses to the appropriate multiple, to the appropriate power. And then solve it. And they're very easy to solve because there's nothing to do except take the fifth root or the fourth root or something like that. Okay, let's have a bit of a review on something else. Tantalum. We're going back a bit here. Tantalum has a body-centered, boy, this is so rich, isn't it? Every word means something. Tantalum, metal, has a body-centered cubic lattice. Wow. That now means a lot to me and should to you as well. And has a density of 16.65 grams per cubic centimeter. What is the atomic radius of Tantalum in the metal? Of course, you have a periodic table because you have to know the molar mass of Tantalum. Otherwise, all bets are off. But let's assume we have a periodic table and I had one. So I'll give you. Here's what we're thinking here. Body-centered cubic has how many atoms of Tantalum in the little cube? Well, I have to remember that or know it. There's one in the center. There's eight times one-eighth on the corners. That's what body-centered cubic means. So there's two atoms of Tantalum in the little cube. And if I know how many grams, literally, the two atoms of Tantalum have, then I can figure out the size of the little cube because it has to come out to the same density as the overall stuff since the overall stuff is literally made out of these little cubes. And then I have to remember, gee, how do I figure out the atomic radius? Always take a path where they touch. In body-centered, they touch from one corner of the cube through the big guy in the center to the other corner. And there's one radius, two, three, four, radii, and then the side of the cube. If it's d, this is the square root of three times d, which you can get by making right triangles. So when I see this, I say, gee, I could do that one. I may go on to another problem. I may say, well, I've already done that one. Of course, you do have to write it down on an exam, but sometimes you can just put a mental placeholder and go on to some other problems. I can get that one in my sleep. Okay, here we've written it out. There's one atom in the center. There's eight on the corners. And that means I have to realize what BCC means, body-centered cubic. So there's two. And the molar mass of tanolum, I need to know. There's 180.9479 grams per 6.0221415 times 10 to the 23 atoms. And therefore, I can figure out the mass and grams of a single atom of tanolum. It turns out to be 3 times 10 to the minus 22 grams. Very, very light. Using this, the total mass in the unit cell, which is twice this, is about 6 times 10 to the minus 22 grams per unit cell. And now I have to figure out how big the unit cell should be so that this much mass per volume in cubic centimeters comes out to 16.65 grams per cubic centimeter. Obviously, since this is very small, the size of the unit cell is going to be very small. And that makes sense because it's atomic size. So from the density, we can determine the edge length of the unit cell because we can figure out the volume. And then we take the cube root of the volume. And then the atomic radius is related by going across the body center of the cube. 4r is the square root of 3d. And I will let you work this out. Or not, depending on your predilection. And then check your answer. If you do work it out, look up the atomic radius of tanolum and see if it makes sense. Okay, let's do another one. We're going back again. The enthalpy of vaporization, delta H, VAP. I should have said the molar enthalpy, but the units give it away. The molar enthalpy of vaporization of diethyl ether is 27.24 kilojoules per mole. And the normal boiling point, which is where the vapor pressure is one atmosphere, is 34.6 degrees C. And here's the question. Is diethyl ether likely to have extensive structure in the liquid state? Is it making long chains or elaborate patterns of cooking up to itself? Or is it random? Well, first of all, we have to make a connection between what we're being asked and what we know. Anything that has to do with randomness or structure, we immediately think of entropy. What this problem is asking about is the entropy of vaporization consistent with random order in the liquid and the gas we assume to be random. And we did that, but it's been a while, so let's go back. The condition for equilibrium between the two phases is always that delta G should be zero. And I have a relationship between delta G and delta H minus T delta S. They're equal, so delta H minus T delta S should be zero. Therefore, at the normal boiling point, delta S should be delta H upon T. Let me put in the numbers. Of course, I don't put in 34.6 degrees Celsius because by now I automatically convert everything to Kelvin as fast as possible. Delta S of vaporization is 27.24 times 10 to the 3 joules per mole divided by 273.15 plus 34.6, and that comes out to 88.5 joules per mole per Kelvin. And a number like this should ring a bell because we had this rough rule that if you went from a completely disordered liquid to a completely disordered gas, that that would create the same amount of chaos independent of what the stuff was. And that's called Trouton's rule. It says that the entropy, excuse me, of vaporization from a random liquid to a random gas would be about 88 or so. And since this is close to that, I would say diethyl ether has no structure in the liquid state. And when I look at the molecular structure of diethyl ether, I see that it can't hydrogen bond like water or methanol or some other molecules, and so that confirms it. If this number delta S of vaporization were something like 100, then I would say, aha, it has structure in the liquid because when I convert it to a gas, I'm creating more chaos than if it were a random liquid. Therefore, it had to be structured as a liquid, and I first had to break up the structure and then get it to go to the gas. This gives us a useful trick, in fact, and so I'll show you what this trick is. You can estimate the boiling point of almost anything without knowing too much because delta H has been measured. Now, look it up. If we've already got the enthalpy of vaporization and we think that the liquid will follow Troutin's rule, then we can estimate the normal boiling point by just taking whatever the enthalpy of vaporization is and dividing it by something like 88. Books vary on the number. Some books insist it's 87.5, other books say it's 88.5, but if it's about 88 or so, it's in the ballpark. Don't worry about the exact number because this is not going to be that accurate anyhow. And although you can do this with vaporization and although sublimation follows exactly the same equation, the Clausius-Clapeyron equation, as a liquid, therefore if I look at the vapor pressure above solid CO2, it'll be log P is minus delta H of sublimation over R times 1 over T plus 1 over T. Same equation, but there's no Troutin's rule for sublimation because solids are certainly not random condensed phases. Solids usually have structure because when things form a solid, they often form a repeating lattice depending on how the tinker toys fit together. And oftentimes, they exclude other things that don't fit in. That's why water, when it's frozen, is pretty much pure unless you flash freeze it. Because if you freeze it slowly, even if it's salt water, when the water forms the ice crystals, it bungs the salt out. Keep pushing it out. Get out of here. Get out of here. You're screwing up my lattice. And as it forms, it just pushes it aside like that. And that's a good way to purify things, in fact, is to crystallize them. And in organic chemistry lab next year, you'll probably do some crystallization to purify things. It's a good way to do it. Okay, let's try it. Here's a problem. Estimate the boiling point of hydrogen sulfide, H2S, and argon, which is obviously a gas at room temperature, knowing that their enthalpy of vaporization values are listed as 18.6 kilojoules per mole for H2S, and 6.4 kilojoules per mole for argon. Well, okay, we need two pieces of information to get it. The first is, if the two phases are present, which they are at the normal boiling point, that's why it's called a boiling point. At that exact temperature, delta G is zero. That's why they can both be there. It's a wash. You could either be the liquid or you could be the gas. And the second is, well, we'll just assume that they follow Trouton's rule, and here I've used 87.5. Therefore, at the unique temperature where delta G is zero, the boiling point, delta H is equal to 18.6 times 10 to the 3. Get the same units. I assume what delta S is by essentially saying that the liquid is totally random and the gas is random, and I get 213 Kelvin, which is minus 60 degrees C, roughly. I'm not going to worry about the 0.15 because I have no illusion that this is so accurate that I'm going to bother putting extra digits like that into this kind of problem. And for Argonne, doing the same thing, but with a different value here of delta H, 6.4 times 10 to the 3, I get 73 Kelvin, which is about minus 200 Celsius. And I looked up the values, and they aren't bad. This is just a fluke that came out that close, minus 60.2, and this one is off by less than 5% error. So it can be useful because you can guess sometimes the boiling point of things without knowing. Okay, here's another one to remember. Remember this one? You might say, wait a second, that was supposed to be on midterm 2, right? There was all this groaning. The reason why it wasn't on midterm 2 is because I don't have a colored printer. And if they're all gray, it's not a very fair question because you can't tell who's who. And I don't like to just make things different sizes, but I have all weekend, and so I can replace this with some pattern that you can see. Okay? Of course, it may not be this exact one, barium, titanate, but let's go through it again anyhow. We have a titanium 4 plus ion right in the center of this cubic lattice. We have the oxygens on each face, so they're cut in half. And we have the bariums on the corners, so they're cut in an eighth. If there were one right here, it would be cut into a fourth. You don't actually have to remember, you just have to say, look, nothing can be outside the cube. If it's outside the cube, when I put the cubes together, they aren't going to fit. So just saw off this and that and this, and you'll just see there's a little 1-8 inside the cube. That's all I can keep. I can't have anything poking out of my unit cell because I'm going to produce the solid by pasting them together. You don't actually have to memorize which one's which. So here is what we said before. 8 times 1-8 for the barium is 1. The titanium's in the center, so that's 1 because it's totally inside. And the six oxygens are on the six faces. They're cut in half. 6 times a half is 3. And the charges also help us because 2, 4, and minus 6 means its salt is neutral, and it better be. And therefore the formula is barium titanate. You wouldn't necessarily know from the structure that it's barium titanate, but from the name we would put whichever one's first as the first one in the molecular formula. But I wouldn't care if you wrote TiBA03. That's fine at this stage. Well, here's my observation. There are 68 problems. That's a lot, but there's more than 68 hours. An hour of problems, not that big a deal. Go over them. Make sure that if that same stupid problem appears that was just up here in technicolor, that it's just nothing but net. Second, turn them around and solve them the other way. Solve for all the independent variables. Don't just do it one way. And then turn it sideways and solve it as well. And when you solve it, pay attention to units. Pay attention to significant figures and pay attention to accuracy. And as far as I know, our exam is on Tuesday at 10.30 in this room. It'll be fine with me if you come a bit early, but if you come a bit late, we actually do have to get out by 12.30, so you'll be short on time. Come early, get organized. Same seats as your last assignment.
UCI Chem 1B General Chemistry (Spring 2012) Lec 18. General Chemistry Intermolecular Forces -- Chemistry Applies to Us and Review Problems -- Instructor: A.J. Shaka. Ph.D. Description: UCI Chem 1B is the second quarter of General Chemistry and covers the following topics: properties of gases, liquids, solids; changes of state; properties of solutions; stoichiometry; thermochemistry; and thermodynamics.
10.5446/19435 (DOI)
We're ahead of schedule slightly. We're going to do a little bit on free energy today. That part will not be on the exam, however. And then we shall review. We'll throw up problems and we'll look at them and we'll do them. The other thing you should review is any problem on the last exam. Because if that same problem comes back and you club it again, it looks bad. Especially if I told you to look at it. And there I am Monday in the afternoon and three people come by and we work out the problems. 297 don't, so all I can assume is you know what you're doing. Make sure you know how to do all the problems on the prior exam. And fast. Okay? Not slowly. Fast. Put a stopwatch on it. Pretend you're going to flunk out if you don't get that problem right. Don't look at the answer. Ready go. See how you do. Okay. Free energy. Some review problems. And I guess a cautionary tale. So I hope this is the right set. Most reactions that are favorable, in other words, that give mostly products are exothermic. They also produce heat by far the majority. And for a while it was thought that the reaction being exothermic was a requirement for it being favorable. In other words, that's how you could tell. If it were exothermic it would be favorable. If it weren't, then it wouldn't be favorable. But that's not true because if you dissolve ammonium nitrate in water the reaction goes. The ammonium nitrate dissolves and that's a chemical reaction. And the solution gets cold. That means it's endothermic. It's absorbing heat. And there are lots of other examples like that. This one's pretty striking because it's quite a big positive number. And therefore this discovery forced people to consider as a chemist you want to make something, how do you tell if the reaction you've written is going to be favorable? If it isn't, if it produces 10 to the minus 6% of products then that's not going to be a going concern in terms of making something. It turns out that the reaction you write doesn't need to necessarily be favorable on its own as long as you're willing to do work. If you're willing to do work then you can make it favorable. For example, supposing I have a reaction that produces 10 to the minus 6% of products at equilibrium, if I can take the product out, if I can pump it off so that the product falls below the equilibrium value, then the reactants make more. And if I keep pumping the products off, the reactants keep making more because the concentration of product is always too low. And so I do a ton of work and I get my product eventually, but it's a ton of work. Where did the work come from? The work came from running another reaction that is favorable, like burning coal, which makes electricity that runs the pump. And when you consider the coal burning and then your reaction going and you add them up, it's favorable. And that's why you can do it in the end. But there's sometimes a reaction hidden in the background that we don't necessarily see. All right. Someone got caught cheating on sapling. I won't go into details. So I thought we'd have a lesson. In honesty, since on Sunday you may have seen somebody lost their job, some people exaggerate accomplishments. I was the senior manager. I was the senior accountant. I have two degrees. I got my degree a year sooner than I did. I have a higher GPA than is actually true. Scott Thompson resigned as CEO of Yahoo on Sunday. That's kind of a, would have been a nice job to keep. He claimed to have a BS degree in computer science. He had a BS degree in accounting. And on his CV or his resume, he put that he had a BS in accounting and computer science, which may sound a little bit better. But in fact, he did not. He had no such degree. And in the days of public records, that thing is pretty easy to find out pretty quickly. There isn't much cover anymore. People can find out a lot of stuff. Oh, he and five board members who didn't do the right fact checking are gone. They all resigned. Oftentimes people will remember you by either the best thing you ever did or the worst thing you ever did. And everything in between will be forgotten. Make sure they remember you by the best thing you ever did. And remember the guy who resigned as CEO of Yahoo? That's who you become. That's how people remember who you are. Hi, I'm Scott Thompson. Ah, the guy who resigned at this grade. I remember that. I think T.S. Eliot summed this up pretty well in one of his poems, the awful daring of a moment's surrender which an age of prudence can never retract. OK, let's get back to our ammonium nitrate. It's the change, tennis worked out, it's the change in free energy, not just the heat, but the change in free energy that dictates whether a reaction is going to be favorable in terms of giving more products than reactants at equilibrium. Or whether the reaction, quote, will go at constant temperature and pressure. And G, named after Gibbs, is a state function and it's partly the heat, that was partly right, and then there's an additional term, minus T.S. And S is a little bit more abstract. It's also a state function. And S, the entropy, has to do with the amount of disorder, whether something is random or whether it is organized. Organized things have very low entropy, disorganized things have very high entropy. And if we get the G function, the Gibbs function for both products and reactants, then we can write the change, which is always the final minus the initial. So in this case, it's G of products minus G of reactants. And when G is negative, the reaction is favorable. G rolls downhill, just like things fall in the gravitational field. Chemical reactions or phase transitions start somewhere and as they can fall down, and that means there has to be a path for them to fall down, sometimes they can be like a boulder jammed in a cliff. They're going to fall down, but not yet. That's us. We're unstable. That's why we die. And you're only at equilibrium when you're dead and gone and the bacteria have finished munching on your corpse and there's nothing left except minerals. Then you're at equilibrium. The reason we can stay and maintain what we've got is that we consume energy. If we don't eat, then we die because we're actually expending a lot of energy to do all the housekeeping, to keep everything in order. Why do things happen at all? And the answer is, and I hope you remember the lecture on solutions, we had some spheres on the right and some spheres on the left and we just counted. If they just move around at random and we just look once in a while, what's the chance that they're going to be all on one side? The answer is the chance is small. And when you have as many molecules as you have in this room, while in principle they could all suddenly rush to the wall and then we all die of lack of air, we don't fear that because that's so unlikely. It's so unlikely that we discount it. In fact, if we start with a canister of air and the whole room's a vacuum and we open it up, after a while the pressure is equalized everywhere in the room because the molecules don't have any brains and they just go wherever they go. And therefore this measure of disorder has to do with probability. It's much more likely to be dead than alive. That's why you end up dead, unfortunately. The metric is that if we have an isolated system, so we don't exchange mass, we don't exchange energy, we just have a closed system. We don't look in, there's no light in there. And we let it sit for a very long time and it comes to equilibrium, its entropy will have increased. It will have just randomly moved to the most likely state. And once it reaches the most likely state, it'll just fiddle around there. There'll be some fluctuations. If it's 6 and 6, it might be 5 and 7, but it's only very rarely going to be 1 and 11, for example. And when we have a lot of particles, the chance that it's ever going to do that is so small that we couldn't wait long enough for it to happen. It would be many, many, many times longer than the age of the whole universe. And we can't wait that long for the air to rush over to the other side of the room. And the universe itself isn't isolated, I'll put the D on, system. And so for any spontaneous process in the universe, the entropy of the universe must increase. That means when you flush the toilet, when you brush your teeth, when you eat something, whatever you do, the entropy of the universe will increase. And the question is, how can we make that more useful? Because we aren't interested in the whole universe, we're interested in the system, or we might be interested in our own health and welfare, in which case I consider my physical being to be the system and the other things around to be the surroundings. And in fact, that's mentally how people carve up the universe, me and everything else. But everybody's doing that. If we divide artificially, we make a mental division, into some part what we're interested in called the system, and the other part called the surroundings, then the entropy of the system and the surroundings for any spontaneous process is going to be positive entropy, if I add them up. And that means that we have to disorder the surroundings to order the system. And when you think about it, that's what humans do big time. We wreck everything else so that we can have it our way. You eat things, you break down big molecules, you take in energy, you chuck out small molecules as waste, you produce a ton of heat, you're on fire, dogs are even hotter. The hotter you are, the quicker you go. Dogs are about a degree warmer than us and they fizzle out pretty quickly. Some other things that have slow metabolism like tortoises can last quite a long time, but they don't do very much. So they sit around, pull their legs in, and so forth. And so there's sort of a constant area under the curve. You can be tall like a spike like that, like a cicada, or you can be long and last a long time like a tortoise. The entropy is really a measure of how much extra chaos we're creating. And the chaos depends on the current state. If I'm at a rock concert and it's loud and people are cheering and clapping so there's a high noise level, then even if I scream, I don't add much to the noise level. But if I'm in a library or in a church and it's dead quiet and I start screaming and tearing on, it's very, very noticeable. It's a big intrusion, it's a big change. And likewise, if we have a cold system and we add heat to it, we disorder it a lot. But if we have a hot system and we add heat to it, we don't disorder it very much at all. And therefore, to keep track of the entropy, we have to take a ratio of the heat that we add because heat disorders things. It gets things to move around more randomly. And the temperature that we're already at is a measure of how disordered it already is. And so we take a ratio and to make it a good quantity, we have to add the heat reversibly. So we add the heat as carefully as possible and then we measure how much disorder it created. And then we'll have a measure of the entropy. For an exothermic reaction, then, the reason why exothermic reactions are favorable is because the heat they produce disorders the surroundings. That's why they go. They're creating a ton of disorder in the surroundings. And so at constant temperature and pressure t, if we add some heat to the surroundings, then we know that that's delta H at constant temperature and pressure. And the heat had to come from somewhere, so it's minus delta H of the system over t. That's the change in entropy for the surroundings. Well to figure out the total sum, we have to not only add the heat to the surroundings, but we have to see if the system itself disordered. In ammonium nitrate, heat came in from the surroundings, so the surroundings became more ordered, but because the ammonium nitrate dissolved and could just move around and had many more possibilities than the solution, the ammonium nitrate itself became very disordered and it became more disordered than the surroundings became ordered and so it goes. That's how we keep track. It's always the entropy of the universe and we could use delta S of the surroundings plus delta S of the system, but we don't like talking about the surroundings because usually we don't measure them. We don't know that much about them. And so we replace delta S of the surroundings with minus delta H of the system over t and now we're good to go because this thing here only has state functions and temperature and that measures whether it's going to be likely to go. If I multiply both sides of this through by minus delta T, I get minus T delta S of the universe is equal to delta H minus T delta S for the system. Delta S of the universe has to be greater than zero for any spontaneous process and that means that minus T delta S has to be less than zero because T is always positive. This is absolute temperature of course in Kelvin. And therefore if this has to be less than zero, since this is equal to this, this thing has to be less than zero, but this thing is so useful we call it delta G and so we say delta G has to be less than zero for a process to be spontaneous at constant temperature and pressure. And that's why we want to know delta G up front because we want to know what kind of yield we can expect if we're a good chemist and we do everything perfectly, what are we going to get? And then because we aren't perfect, we always get less than that. So just like the reversible work sets a limit on what we can possibly get. So delta G sets a limit on what kind of yield we can get for any kind of spontaneous process at constant temperature and pressure. Okay, we'll leave delta G there. We'll come back to delta G next, a week from Thursday, we'll come back to delta G and we'll continue on it and we'll see how we can use it to predict the ratio of products to reactants and other things like that. For now though, let's press on and do some review problems. And I've tried to make these a little bit topical. They aren't just problems, but these are stories like Esau's fables. They have a moral at the end. Sometimes it's good to work through a problem just to see how something would work. So if Governor Schwartz and Egger says we're all going to be driving hydrogen cars in 10 years, you can say no, we won't be. And that's that. Let's have a look. Suppose we want to transition to a hydrogen economy. Scientists are working on this, chemists, chemical engineers, and so forth. But let's have a look at what we'd have to be able to do. Let's just figure out the volume of hydrogen gas at 1,000 psi. That's pretty high pressure, maybe not unbelievably high, but pretty high. 1,000 psi and 25 Celsius. And remember, if you're going to have a tank at 1,000 psi and you park your car in a parking lot out in Indio, you have to make sure that it doesn't explode. Usually that's going to mean a containment vessel which typically is heavy. The more mass you lug around in your car, the worse the efficiency is. Now I've looked up an approximate value for the enthalpy of combustion of octane. Octane is 2.66 kilograms per gallon. And delta H of combustion is minus 5,500 kilojoules per mole. So it's very, very exothermic. That's why we use it. OK, let's go through and see what we can do. Let's start with octane. We've got 25 gallons in the tank. It's 2.66 kilograms per gallon. The gallons go away. I look up the molar mass of octane. And I could do moles per gram, but I've decided to do kilomoles per kilogram. Same thing. Now the kilograms are gone. And I've got kilomoles. So it turns out in the tank I've got 7,596.3 kilomoles, or 7.6 times 10 to the 6 moles. That's a fuel. Now that I know how many moles I have, and I know I get 5,500 big fat kilojoules of exothermicity per mole, I can figure out that I get 4.2 times 10 to the 10 kilojoules. That's how much energy manifested as heat that we're putting into the tank. 40 billion kilojoules. Now let's do hydrogen. Well, for hydrogen we need to decide on the phase of the water. What I'm going to assume, but it won't make too much difference, is I'm going to assume that the water is produced as water vapor, as gas. Because I don't think in the piston where we're going to get the energy that we can condense the water to water drops, and then milk out extra heat and use that for something. I think that heat just goes out the back. We get water vapor coming out, and then it condenses. If the tailpipe is cold, initially you may see drips of water as the water condenses, or if it's a cold day. So I'm going to assume that the water is water vapor. Our books always assume it's liquid. But anyway, it won't matter too much. We look up the enthalpy of formation of water vapor at 25 Celsius, and we find that the delta H of formation, it's exothermic, is minus 240, 1.8 kilojoules per mole. What we're going to get, that's the only product. In fact, is H2 plus 1.5 O2 equals H2O. This enthalpy of formation is actually the enthalpy of combustion, because it's burning with oxygen. Therefore we need to get 40 billion kilojoules, and then per mole of H2O we get minus 241.8 kilojoules. We can figure out by the balanced chemical reaction that 1 mole of H2 gives 1 mole of H2O. So everything goes away and we have moles of H2 left, 1.73 times 10 to the 7 moles of H2. It seems kind of big, but it doesn't. Offhand to me, this didn't seem so bad. Yeah, seems like a lot. The problem is that the gas has low energy density, even at 1,000 psi. And so the volume that we're going to need to lug around is going to be uncomfortably large. Let's figure out how large it's going to be. Well we aren't given any van der Waals constants on hydrogen or anything like that. Or all we can do is assume hydrogen's an ideal gas, good enough for the back of the envelope here. So without any further assumptions, we just use the ideal gas equation. And we say the temperature, we'll assume that the temperature is 25 Celsius, and of course whenever we see that we say no straight to Kelvin. And back to Celsius or Fahrenheit, whatever the public's more comfortable with, V is equal to nRT upon P. We know how many moles. We know R. We know T. And we know 1,000 psi. Ooh, psi, constant per square inch, what's that? Well, we have to convert to atmospheres because this is atmosphere. If we write in all the units and we don't convert it, we have atmospheres over psi times liters in the answer, and that's a clue that we aren't done. We convert 14.7 psi per atmosphere, and we find we need 62 million liters of hydrogen. And how big is that? Our liter is not so big, but millions of them is getting to be large. And if you work it out, this requires a cubic tank that's about as tall as me on each side. That's what you need. In other words, it's almost as big as a whole smart car, just the fuel tank. By the way, is a smart car a smart choice? Only if you don't value your life. The smart car doesn't have very good mileage either compared to how tiny it looks. And if you have a collision with another car that Mercedes-Benz makes, like just a regular sedan, the smart car is annihilated. And if you figure out the acceleration of the crash test dummy, you're dead. And the other car, just kind of hears this crumpling sound like paper tearing and keeps driving. It doesn't slow down at all. The smart car is called a bus, where you get 50 people on and you're getting the same mileage as the smart car, and you're completely safe under most circumstances. OK, the 25-gallon gas tank is only 94.6 liters. And what this means is that even if you can get around all the problems with refueling and stuff, who's going to be driving a car with this huge thing on the back? Well, OK, you make the pressure higher, you say. Make it 3,000 psi. But there's a limit to that before you need really, really heavy cylinders, and they're heavy to carry, and that wrecks your mileage compared to a lighter car. So my conclusion is that the hydrogen economy is going to face a lot of practical problems before it's going to contribute to mobile transportation. So I wouldn't hold my breath. And keep in mind that although we figured it out with heat, it's really delta G that we need to figure. Because if we figure delta G, we can tell how much work we can get. We'll get to that later. But heat is reasonably good. It's closed. All right, let's try another one. Hydrogen may not work. Let's try some other clean burning fuels, some things that don't produce particulates and soot and stuff that gasoline tends to do, and diesel does big time. And let's see if we can make a go out of any of those. So let's compare then the energy density of methane, natural gas, ethane, C2H6, acetylene, C2H2, and hydrogen, H2, for mobile transportation. The delta H values of formation for these guys are respectively minus 17.9 kJ per mole for methane minus 20 kJ per mole for ethane and plus 54.2 kJ per mole for acetylene. OK. So we'll start with those, and let's just go through them one by one and see how it pans out. We have to do two things. We have to look up the delta H of formation of the products. And on an exam, of course, you would be, yes. Of course. On an exam, of course, you would be given a table of the delta H of formation of these things. Don't memorize numbers that you can look up. We want delta H of combustion. We have to balance it, and then we have to use Hess's law to figure out what it comes to. And the delta H of formation values for CO2 are minus 393 kJ per mole. And for water vapor, I'm going to assume they're all making water vapor, so at least it's a fair playing field, is minus 241.8 kJ per mole. We balance it, and the way we balance it is we start with CH4 and we write plus O2. And for complete combustion, which we don't always get in a vehicle, we get 100% CO2 and H2O. Those are the products. If you see the word, if you see the phrase, complete combustion, that means CO2 plus H2O. If the fuel has nitrogen, I think I told you you have to be careful. You can get different things dependent on the condition. I have one carbon atom, so that means I have to have one CO2 because CO2 is the only thing with carbon. I've got four hydrogens, so I have to have two H2Os because this is the only thing with hydrogen. And then I just figure out how many oxygens I need to make sure oxygen atoms aren't disappearing. And there I go. And now I can figure out delta H of combustion. That's delta H of formation of the product minus the reactants. Delta H of formation of CO2 is minus 393.5. Plus there's two moles of this, so I have to make two of them, plus two times minus 241.8 minus, this is an element, delta H of formation is zero. This is minus 17.9, and if I total this up, I find for methane I get minus 859.2 kilojoules per mole. That's a lot better than hydrogen, and that's why you see some cars marked CNG on the bumper already because they're running on compressed natural gas. And the reason why it's better than hydrogen is that unfortunately most of the oomph comes from forming CO2. But CO2 is the villain currently. And if we're burning any kind of carbon fuel and forming CO2 and letting the gas just go up, then we're going to be increasing the concentration of CO2. Yes? How do we come up with the combustion reaction? Well we have to know that. But we have to know the complete combustion means that the products are CO2 and H2O. That's what we have to know. We have to know complete combustion really means CO2 and H2O. And then we have to balance it, and then we just use the numbers and the stoichiometric coefficients. OK. Let's go to, let's see, I think the next one's ethane. Yes? For ethane, we have two carbons. Therefore we get two moles of CO2. We have six hydrogens, so we get three moles of H2O. And then we just have to balance the oxygen so that we end up with seven on each side. And so that's seven halves moles of O2. The computer that controls how the air intake and fuel intake goes into the cylinder has to know what fuel you're burning. Or it doesn't know what this coefficient is. And therefore if you take a car with a computer with fuel injection and you just put in some other fuel which has different stoichiometry, your car won't work right. It'll be awful. It'll either bump and chunk around or it'll produce smell terrible or it'll knock. You'll get all kinds of problems. So you have to use the fuel that they're assuming you're going to use. And here we do better precisely, unfortunately, because we're forming two moles of CO2. And CO2 is the 800-combe gorilla because it's got that huge minus 393.5 in its favor. It's very favorable to form it. It's a very stable molecule. We take 2 times minus 393.5 plus 3 times the water. And then we subtract the delta H of formation of ethane and delta H of formation of O2 is zero and we get minus 1492.4 kilojoules per mole. Therefore ethane is much better than methane if you had to choose because for a mole of gas it takes the same volume and you can go a lot farther with ethane. And propane will be even better and then you go all the way down and you end up using gasoline again. Ethane is superior to methane in terms of the heat released. You get almost twice as much, not quite, as with CH4. Now let's look at acetylene. For acetylene we've got two carbons again but only two hydrogens so we only get one mole of H2O. And again we do the O2 at the end. It doesn't really matter what it is on an exam because this isn't going to contribute to the delta H of combustion. So if you're in a hurry you don't even need to balance the O2 because it's not going to change the answer. For this one then we take again 2 times 393.5 plus minus 241.8 minus, and then this is a positive number so this now gives us extra oomph. You get minus 1083 kilojoules per mole so acetylene is close to ethane, not quite as good. But acetylene makes a much hotter flame. And the reason why acetylene makes a much hotter flame is because it only makes one mole of H2O and H2O has quite a high heat capacity. Or if I can burn something and not make as much H2O then the heat that's released can heat up the rest of the products to a much higher temperature. And it's for that reason that we use acetylene in a torch to do welding and things like that that require high temperature and you won't see anybody using ethane in a torch. In fact it's called an oxyacetylene torch for precisely that reason. Acetylene is quite an explosion hazard, however. Acetylene, if you look at it wrong it says, did you say something and blows up. And so you have to take that into account too. The propensity for something to go wrong as well has to figure in. And then finally if you go to hydrogen we get this binky little minus 241 and it's just not competitive. So sadly while hydrogen is the best environmentally because it only produces water and doesn't produce any CO2 that's a greenhouse gas because it doesn't produce any carbon dioxide it's wimpy because it's precisely producing the carbon dioxide that gives you the energy. So you're kind of in a jam. If you had to choose of these three you'd choose ethane as the best energy density but it's still much, much worse than iso-octane. Okay, let's do a vapor pressure problem. Let's go back to mixtures. Remember we've got mixtures of two things and they both contribute molecules to the vapor and the more volatile one will have more in the vapor. We've got two substances. They're pure, pure compounds A and B and we've measured the total vapor pressure. We've just measured the pressure. We haven't measured how much of each one's there but we've taken a certain number of moles, one mole total and it's either all A, all B or something in between. And based on the data just from the vapor pressure we want to ask the following question. Do A and B form an ideal solution? We have to remember what an ideal solution is. We remember an ideal gas from the ideal gas equation of state. For an ideal solution we have a different measure. Remember we have these mole fractions, chi A and chi B and we start with 100% of B and the vapor pressure is 150 Torr. And then we make 2080 and it's 160.6, 4060, 169.9, 6040, 173.9, 8020, 172.6 and then 100% 170. And we want to know do A and B form an ideal solution? Well, an ideal solution is one that follows Raoult's law at all compositions. That's the definition. If it doesn't follow Raoult's law at all compositions it's not an ideal solution. And Raoult's law says that the vapor pressure is the mole fraction times the vapor pressure of the pure liquid. That's the partial pressure of each. So if I add them up, and I thought the total pressure P, which is the vapor pressure of A in the solution plus the vapor pressure of B in the solution, it has to be a straight line. Therefore it has to go since the end points are 150 and 170, it has to be a straight line in between. Otherwise it's not following Raoult's law and therefore it's not an ideal solution. And remember there are positive deviations from Raoult's law where the vapor pressure is higher than you would predict. And there are negative deviations where the vapor pressure is lower. That means that A and B are kind of sticking to each other. They're sort of sticking and so they aren't bothering to go up into the vapor because they're hanging together. If it's a positive deviation it could be that one of them likes to form hydrogen bonds and pushes the other guy out. So let's get out of here and so the vapor pressure is higher than you would have predicted. Therefore if we make this plot, we're given the data, all we have to do is make this plot and see if it's straight. And if we make the plot, we see that it's not. It's not straight and therefore this is not an ideal solution, end of story. Because it's quite curved. And in fact in this case it's making a positive deviation from Raoult's law because the vapor pressure is higher than we would have predicted from a straight line. And that means that A and B quote, dislike each other. They'd prefer to be separate so they kind of push each other out of the solution and therefore it's not ideal. Okay, another one. Let's do Henry's law. The solubility of CO2 gas in pure water is known to be 34 millimolar at one atmosphere pressure of CO2. Let's ask what is the solubility of CO2 in water under atmospheric conditions? And let's assume that the partial pressure of CO2 in the atmosphere is 380 ppm. I think it's higher than that now, but let's assume the partial pressure is 3.8 times 10 to the minus 4 atmospheres. That's the partial pressure of CO2. By the way, if you're running and you're getting tired, there could be two reasons why you're getting tired. Well, there could be three reasons. The first reason is you're out of shape. That's most likely. The second reason is you aren't getting enough oxygen. So you should really concentrate on breathing in like crazy. And the third reason is you aren't exhausting enough CO2. So you should breathe out like crazy. In fact, it's usually the third reason why you get tired. If you're running and you're running and you're coming to the take and there's somebody on your shoulder and you're winding it into the red and then suddenly a big bear jumps on your back and it's very unpleasant. That's because the pH of your blood is changing. And when the pH of your blood changes, your brain says, that'll be enough of that. Let's ease off. That's the signal. And then the other part of your brain says, no way because I want to win. But that's quite a battle of wills because you're fighting against something that's kind of an automatic mechanism and you have to override it in order to keep going. And there are limits to what you can do. Anyway, let's assume that CO2 follows Henry's law. We know that CO2 can't make hydrogen bonds. CO2 is a non-polar molecule. Polar is a polar molecule that can form hydrogen bonds. There's no way they're going to form an ideal solution. But we still know that if we don't have much of the solute, that it's still a straight line initially before it goes haywire and curved, but that the straight line has a different slope than the actual vapor pressure of the pure material. And that's Henry's law, which we usually write as the concentration in solution is proportional to the partial pressure of the gas. And this proportionality constant here is something different. So it's just some constant k. So the concentration in moles per liter is equal to some constant times the pressure, the partial pressure of the gas in question, above the liquid. Let's have a look then. At one atmosphere pressure, the concentration is 0.034 molar. And from that, we can get the Henry's law constant because we can say it's 0.034 molar at one atmosphere, so Henry's law constant, k, is 0.034 molar per atmosphere. Now if we're going to go up to really high pressures, we have to be careful because it won't follow Henry's law. Because if I keep squeezing and squeezing and squeezing and pushing CO2 in and disrupting the water, just making it go in, then it may not behave the same way. But we're going to be below this because the partial pressure of CO2 in the atmosphere is very tiny. So it will follow Henry's law, and we can use this constant, k. And then we just insert the other pressure. We say the concentration in solution in moles per liter is equal to the Henry's constant, which we figured out, times whatever the pressure is of CO2 in the atmosphere, which we said was 3.8 times 10 to the minus 4. And so we end up with 12.9 micromolar as the concentration of CO2. We have to be a little bit careful here for the following reason. We're assuming that CO2 doesn't react with water, but CO2 does react with water. Over time, we get carbonic acid H2CO3, that's part of the source of your misery when you're sprinting toward the tape, is producing too much of that and making your blood acidic. And unfortunately, I think it's going to be the source of some misery going forward because ocean acidification results from dissolved CO2 reacting with carbonate, which is in the ocean. And unfortunately, carbonate is what all the marine organisms use, like coral and anything with a shell. Carbonate is what they use to make their exoskeleton. As we increase the CO2 partial pressure in the atmosphere, we increase the concentration of CO2 in the ocean. And now we're talking about a separate problem that's nothing to do with the planet warming up. This is a separate problem. And if we consume then all the carbonate ions in the ocean by adding a lot of CO2, millions of tons, then there's less around for these little guys to make their skeletons out of. And here's what the measurements show. Here is the CO2 stops at 2,000. I should get some more data. It's not only going up, not only is it going up faster than linearly, but it seems to be going something like this as everybody in China decides to drive an SUV. If you look at the sea water partial pressure of CO2, that's going up. And if you look at the sea water pH, the pH is going down. And that means that the ocean is becoming more acidic, and that means that these guys are dissolving. When they dissolve, they die. When they die, there's no food for anybody on the planet because most of our food comes from the ocean one way or another. If you simulate what happens to these terrapods, these guys are food for everything from whales to everything else. And if you put them in the pH that we predict we're going to have in 2100 in saline, then their shell dissolves. They won't be able to survive this. They will die. When they die at the bottom of the food chain, everything above them dies too. And then there's nothing there. So seafood may become scarce, and we may become scarce too because that's nature's way. If you swing things way out of balance, you can do that for a while, and then suddenly the pendulum swings back the other way. And the only way it can balance out is if we go extinct, then everything will be hunky dory again, and it'll be paradise. There will be millions of other kinds of animals and we'll be gone, like the dinosaurs. Okay, let's do another one. This is a different one. Back to the good old days. Boy, what would a lazy professor do? You're sitting there and you're thinking, golly, should I think up a new problem, or should I just give them the Van der Waals gas? Because I told them to do it. We've got a mole of a Van der Waals gas. The constants are 5.46 liters squared atmosphere per mole squared for A, the attraction part. And 0.05 liters per mole is B, which is the repulsion part, something to do with the volume of the liquid. And we want to study it at half an atmosphere and 100 degrees C, and we want to know what volume it'll occupy because we're going to do this in a lab and we have to get a container to do it. Well, we have to remember the Van der Waals equation of state. That's not too hard. We've seen that many times. And then we have to ask which variable we're solving for. I think I've told you that if you're solving for A, that could be a variation. The volume's this, what's A? You've got to know B as well. Or what's P? that's all easy because you can isolate them easily. With V, the problem is you can isolate V, but you get a cubic equation and it takes forever to solve it, and it's very prone to error. With N, N is a little bit trickier because N's on both sides. Never guess when the thing is on both sides. At least get everything to one side because if both sides change, when you guess, first this is too low and this is too high, then you guess another one, this is too high, this is too low, it gets very confusing. It's better to have the target be fixed so that you can hit it. So V is on the left-hand side only, and we start with some gas and in the absence of any better knowledge, the gas I choose is always what the ideal gas would predict. I start with NrT over P, I know all these guys, I plug them in, and then I just guess values of V until I hit the target. Let's try it. I always set up a table to make sure I'm not going around in circles. I'm going to set up a table, I'm going to have V, and then I'm just calling it F of V, but all it is is the left-hand side. I put in 0.5 atmospheres for P, I put in 5.46, the number of moles is one, but if it isn't, be careful because it's N squared over V squared, V, and then the number of moles is one minus 0.05 there, and I just plug in. The first, the NrT, the value I want to get, I put in T100 Celsius and so forth, I get 15.31 liter atmospheres. My first gas is NrT over P, P is half an atmosphere, so it's 30.62, just twice this. So I guess 30.62, I shove it in here and here, and I multiply it out, and I get 15.463, 15.31. It's too big. Now how too big is it? Well deliberately making a mistake, and then we will see how to correct the mistake. Here's what I'm going to do. I'm going to say that this is about 17 units too big or so, and so I'm going to subtract the same from this. I'm going to subtract the difference between these saying I want to make this smaller so this comes out smaller. And if I, well it's actually more like 15, I guess, sorry, 15. So if I subtract 0.15 from this, my next gas is 30.47, and then I see that it didn't come down to 15.31. It only came down about half to 15.39. And then I say why is that? The answer is because the pressure is half an atmosphere. And it's basically P times V is the big guy, and then the rest of the guys are small. And since P is half an atmosphere, I have to go down twice as much as I thought. So I still don't have it. It's still too big. So now I say okay. It went down. I'm still eight units too big. So I want to come down 16 units 0.16 from this because it's 0.08 too big. And I see that when I lower it, it comes down by half as much as what I change. And so my next quote gas seems very smart. I come down to 30.31, and on bingo, I hit 15.31 right away. And then I'm done. Usually you can get it with three guesses, and that's why guessing, although it sounds kind of like it's a joke, it's not. It's actually extremely powerful and very fast. And of course, you've checked the answer because you've actually calculated it, so you know it's right, and you know you haven't hit a bad button because you see the trend. It's very robust. Okay, here's a challenge. You set up a problem. I say set up this problem, but leave n unspecified, and you tell me what n is. You know n should be one mole. Leave it unspecified. Guess the n from the ideal gas, and then guess until you get it. Because you can guess for any variable, not just b. Okay, let's do one more. This one is definitely worth paying attention to. Suppose helium gas occurs at 7% by volume in methane, natural gas from fracking. What would be the percentage after one stage of effusion through a tiny orifice into a large evacuated chamber? What would be the percentage of helium after two such processes in succession? We're trying to purify helium and get it away from the natural gas. And as you'll recall, the rate of effusion is a random process, your chance of going through the hole depends mostly on how fast you're going. Because if you've got a big container and a small hole, and you're a little molecule or atom rattling around, if you're going ding, ding, ding, ding, ding, ding, ding, basically you find your way out pretty quickly. If you're a big guy and you're moving around slowly, you're getting hit by all these flies and you're an elephant, it takes you a very long time to find your way out through the hole because it takes you a very long time to go anywhere. And that's why the ratio goes like the square root of the masses because that's how the most probable speed, the mean speed, and the root mean square speed, they all have the inverse square root of the mass and then 3RT, 2RT, whatever on the top. And T is the same for both of them if they're in the same container. So that goes away. So the rate of effusion, R1 over R2 is M2 over M1 to the one-half power, or the square root of M2 over M1. In round figures, methane is 16 grams per mole and helium is 4, and therefore the rate of helium compared to the rate of methane is the molar mass of methane, 16 divided by the molar mass of helium, 4, square root of 16 over 4, square root of 4 is 2. It's a little different from that, but that'll do. That's the rate, but that's not the enrichment because the enrichment depends on the rate and then how much of each guy you started with. If we let the rate of effusion of methane be 1 relatively, and then that of helium is 2, it's only really the ratio that matters. Then we can figure out the percent of helium. The percent of helium is how much helium got out. It's how much we started with times 2, the rate at which it gets out divided by the total, which is the rate at which methane gets out, which is 0.93, it's 93 percent methane, times 1, plus 0.07 times 2 because that's how much helium. I work this out and this number comes to be 0.131 or 13.1 percent. That's the enrichment after one stage of effusion. Then if I do another stage of effusion, I start with a 13.1 and I just do it again. I'll let you work out if you do it a lot of times, there's a slick way to work out the formula without going one after another. But anyway, for now let's just do the next one. We now start with 13.1 percent helium. It effuses out again through the second hole twice as fast. Then we start with 86.9 percent methane because that's what's left. It comes out at rate 1 plus 0.131 again times 2 and this works out to be 0.232. Now after two stages we're up to 23.2 percent enrichment. As we get higher and higher enrichment, it gets harder and harder, unfortunately, to make progress. For example, if the mixture is already 99 percent helium and then we effuse it through the orifice, we enrich it to 99.5. That means to get to 99.9, we still have to do a bunch more stages. If we want 99.99, it's a bunch more. If we want it really, really pure, we're going to get really tired of doing this. That's why if you take any material and you specify that its purity is really high, it's ever so expensive, no matter what it is. Even pure water is relatively expensive. If you say it can't have anything in it, that's a special price. You only specify the purity that you actually need, not higher. We'll leave it there and we'll continue on these kinds of problems on Thursday. We'll just go through them one by one.
UCI Chem 1B General Chemistry (Spring 2012) Lec 12. General Chemistry -- Free Energy and Review Problems -- Instructor: A.J. Shaka. Ph.D. Description: UCI Chem 1B is the second quarter of General Chemistry and covers the following topics: properties of gases, liquids, solids; changes of state; properties of solutions; stoichiometry; thermochemistry; and thermodynamics.
10.5446/19430 (DOI)
Lecture today is the last gasp and condensed phases. Recall we were talking about gases and we were talking about purifying uranium for various uses. And this is a much more efficient way. Chemists love this. Very energy efficient. Boy. You shine a laser light at these gases and the uranium-235 absorbs the light and the uranium-238 doesn't. And so you ricochet them off. Usually you ionize them or you do something and then you sweep everything aside and then you have what you want. You separated the material. Unfortunately there was a collision between science and policy here because these kind of plants can be made very, very tiny. And so you could hide them anywhere. And the government decided maybe we don't really want to do this and popularize this technology because it will be very hard to keep track of who is doing what. And science and technology always has this tension. They made a new kind of bird flu. To see how it worked it's very contagious. There's a lot of controversy about whether they should publish how they made it so that somebody not quite as bright can copy that and make it. Of course scientists would like to publish everything we believe in freedom of information. But you have to be a little cautious sometimes. So here's the summary of gases. There are the simplest form of matter to understand. That's why we had these simple dimple equations that modeled gases fairly well. And an ideal gas is like a mathematical circle. It's something we invent to stretch out the behavior of real gases to all possible temperatures and pressures from zero to infinity. And it can't possibly be true in all circumstances for a real gas. And separating gases from one another is hard work because the atoms or molecules just move around randomly and you're trying to impose order on them. And they don't have any brains so you have to do all the controlling. If you decide that after you read the NOAA report that recently came out that said that it's six degrees Fahrenheit warmer this spring than average and that lots of migratory birds appear to be confused coming back too soon and then there's no food for them to eat and then they stand around moving to the wrong areas where they didn't normally go because it's too hot where they used to go, that type of thing. And you say I got an idea. Let's try to put the genie back in the bottle and capture all that CO2. That is going to be a lot of work. And work in chemistry is synonymous with using energy. And the question is where are you going to get that energy if you're going to try to do something like that? You can't get it by burning more coal. We have the kinetic theory of gases. It starts from four assumptions. Know the four assumptions. Whenever you have a theory you have to know what the assumptions of the theory are, if any, helium gas, because of the Maxwell-Boltzmann distribution, helium atoms go much, much faster than argon, krypton, or xenon. In fact, they go so fast that they achieve escape velocity. And so every helium atom you let into the atmosphere eventually leaves the earth's gravitational field and we leave a streamer of them behind in space. But helium is ever so important to have around. It's a non-renewable resource and it's extremely important. You wouldn't have any MRI without liquid helium. And so we should not be filling balloons and letting them go up as if there's no tomorrow. We should be conserving it like we should be conserving a lot of things that we're using up too quickly. The atmosphere when you look up and you see the waning gibbous and it looks like it goes on forever because you're looking through it. It doesn't go on forever. It basically goes nowhere. This part here is the atmosphere, this little thin layer. It's not as big as people think and you can change its composition by belching all kinds of things into it and then you're going to be standing around saying why do we do that? Well the answer in the early days was nobody knew it was a problem. That's not the case now. What's happening now is a case of colossal inertia and the prisoner's dilemma problem being played out. Okay let's talk about condensed phases. First of all never ever write pv equals nrt unless you're talking about an ideal gas or trying to approximate a real gas as an ideal gas. This equation of state is only for gases. There are no simple equations of state for liquids or solids because liquids and solids have some order and they change a lot depending on what the material is. In fact intermolecular forces play a big role in the behavior of liquids and solids because the atoms are close together. They're bumping into each other constantly or they're locked in place in a solid lattice and they're locked in place by forces. The only forces that matter for atoms and molecules are electrical forces. Gravity in particular has no role to play on the atomic scale because the atoms don't have much mass. So if you think that a liquid condenses because the atoms see each other and attract each other like the earth attracts the moon that's not even remotely applicable. Yes. It's extremely difficult to compress a liquid. You can always compress anything even a solid if you squeeze on it enough. You can crush it. Sometimes you get a different behavior if you take solid hydrogen. Hydrogen is in the first column above lithium, sodium and all the others. All those other ones are metallic but solid hydrogen is not metallic. But if you really, really, really squeeze on it it collapses, it goes down and then it actually conducts electricity. So it becomes a different material entirely. And that's true as we'll see when we talk about phases. Different, the same molecule or same group of atoms can behave differently depending on the phase. Solid CO2 is completely different than liquid CO2 or gaseous CO2, same with ice, water and steam. They have different properties. And this is what I said. The forces are electrical. So the strongest electrical force is a charge and then a dipole and then those fluctuating dipoles that I described to you. When we talked about the Van der Waals A term for attraction, we said the chance that all the electrons would be perfectly symmetrical at all times is very tiny. And so there have to be fluctuations. And once there's a fluctuation then anybody around the electrons can move toward the positive side and there's a momentary attraction. They attract momentarily. I knew I was paying attention to language too closely when I came back on a transatlantic flight from England that was landing in San Francisco. And the pilot said, we will be landing momentarily in San Francisco. And my heart started beating and I started to get up because I thought if we're landing momentarily I might not have time to get off the plane because landing momentarily means... Okay? It doesn't mean landing in a moment. It means landing for a moment. But it's been misused so much. I think if you look it up now they accept either usage. But when I talk about momentarily, having charge, I mean momentarily. Okay. Liquids can flow although sometimes they flow very slowly. You may have to be extremely patient to figure out that something is a liquid. You may have to watch it very, very closely over a long time and eventually liquids assume the shape of the container. And we have a measure of resistance to flow called viscosity. I think you all know qualitatively what it is. Something like gasoline is not very viscous. So if you carry it around in a bucket, it's very likely to slosh over the side of the bucket. Nobody usually carries around buckets of gasoline now because that's very bad for the air. But when I was a kid we would have gasoline and that's how you cleaned your bike chain. As you dunked it in gasoline and you went back and forth and then you oiled the chain, got all the gunk off it and you did that. You were 11 and there was nobody around. No adult supervision. And it was quite a bit of gas. So you could get burned. But you knew that and so you didn't light any matches and you didn't play any games. Okay. The kids who did that weren't around. Those of us still around were cautious. So viscosity, if we look at it, viscosity I guess will give us a clue, some kind of clue, not the ultimate clue, but some kind of clue about the kind of strength of intermolecular forces and liquids. And hydrogen bonding in particular can lead to very viscous solutions. Carbohydrates, sugars have lots of hydroxyl groups that can make hydrogen bonds and therefore if we pour a ton of sugar into water and make syrup we get a much more viscous solution and then we can boil it up and pour it into molds and harden it and then we have candy and various things like that. Okay. Let's predict the viscosity of something. My goodness. Now look at these structures. So intimidating. They are not. Chemists get lazy because they have to draw structures all the time. And if you have to draw a seed, age, age, hours, my wrist is killing me. And it's taking forever. It's taking so long to draw the molecule that it's like reading a novel letter by letter. You go so slowly, if you read slowly, that you can't follow the plot because you're taking too long to read it and you're forgetting what happened. But we have a shorthand and in the shorthand whenever we change direction like that, that means there's a carbon. And if there's one line, there's a single bond between them. And we don't bother drawing the two hydrogens on this carbon or the two hydrogens on this carbon or the three hydrogens on the end because we know the carbon will make a four single bond. We just leave it all off so that we can get on with them. And when you take organic chemistry, you'll be drawing all kinds of things like this very quickly. And if you become an organic chemist, you'll be able to draw these things so fast it's like signing your name because you'll have to draw so many of them to see what's going on. But for now, I'll just tell you that the first one is one propanol. If the OH is in the middle, it's called isopropanol or isopropyl alcohol. That's often used to sterilize things. But this is one propanol. And then we have this with two hydroxyls and then this with three hydroxyls, but they all have three carbons and all we're changing is the number of hydroxyl groups. That does increase the molar mass, but you never ever say, gee, the molecule on the right is heavier. Never. It has nothing to do with it. Don't use terms that refer to gravity. It has to do with hydrogen bonding and electrical forces. The more opportunities we have for hydrogen bonding and hydrogen bonding can only occur when a hydrogen is on what atoms? Oxygen, nitrogen, or fluorine. And fluorine doesn't occur that often. So oxygen and nitrogen are the ones you want to think about. If you see a hydrogen on an oxygen or a nitrogen and then there's another oxygen or a nitrogen around, you say, my goodness, that could hydrogen bond for sure. And that would stick the two molecules together. And then if I were trying to pour them and they were tending to stick together, they aren't going to pour very quickly because they have to unstick to start moving. And the more I have them stuck, the longer that's going to take. And therefore, we would guess that one propanol, which has one hydroxyl group, is the least viscous. And the propylene glycol, which you probably have seen as an antifreeze ingredient, for example, miscible with water, lowers the freezing point so that the water in your radiator doesn't freeze when you go up to the right wood and then break, shatter the radiator. And then finally, glycerol, which is very viscous. And if we look at room temperature, these are approximate numbers, then one propanol is 1.94 milli-pascale seconds. That's also known as sense of voice. That's just the units of viscosity. 48.6 and then about a thousand. You don't use this one then to add to your car radiator. This one is about right. They'll both lower the freezing point, but one of them will be a lot more inconvenient to work with because it'll take you 50 minutes to pour it in. And the customer wants to get moving. And then, of course, they add dyes so that you know if you spill it, that you should clean it up. You don't want to be spilling chemicals around. And if they're colorless, which these are, you can't tell where they are. And so you leave them. So they add dye, usually some green. And then they add other colors to the other fluids in your car. So the guy can call you in troubleshoots and say, what's the color? And you say, well, it's this red stuff. Aha! Then he knows all your power steering is out or your transmission fluid or whatever. If you add colors, though, you have to be sure whatever you add doesn't change the properties of the liquid and what it's supposed to do. No good having a brightly colored liquid that doesn't work as a power steering fluid. This experiment has been going since 1930. Bitumen, which is also known as pitch, hence the phrase pitch black. That's as black as this stuff. It turns out that it is a liquid. And the proof is you pour it into a funnel, heat it up, pour it into a funnel, let it cool, and then you watch it for 80 years. We can't do experiments these days like that very well because the funding agency comes back in three years and says, what have you done? And if you say, well, I've drunk a lot of coffee and I've been watching this thing and it's barely moving, then unless you're a physicist, they say we are going to scram that experiment. Sometimes in physics you have to sit around to watch for a rare event. But you don't want too many people doing that because it's hard to distinguish whether they're actually working. This has dropped eight experiments, sorry, eight drops have fallen here. And you become the steward of the experiment and then when Dr. Mainstone dies, they will have to appoint somebody else to take it over and keep watching. So this becomes one of your tasks is to not do anything, don't touch it, keep at the same temperature, and be sure you're there when the drop actually falls because that's very rare. Solids don't flow. Of course you could say, how do we know? Maybe we should watch them even longer. But it turns out solids don't flow because the molecules or atoms are locked into place in a 3D structure and they can't move until you melt them. Crystal and solids have a repeating structure and they, everything is formed from this repeating structure which we will call a unit cell. And we just move the unit cell in three directions and we reproduce the whole gigantic solid. The unit cell is the smallest piece that has all the parts you need to make the entire solid. Sometimes the unit cell is quite big in the case of macromolecules. Sometimes it should be quite small in the case of something simple like rock salt, sodium chloride, the unit cell can be tiny. And the unit cell has to have the right stoichiometry. Therefore if I have something like zinc oxide, one zinc atom, and one oxygen atom, the unit cell has to come out to be one to one. It could have four of one and four of the other, but it has to have the same stoichiometry as the entire material does because you just make the entire material by translating the unit cell around in space just like a cookie cutter. Boom, boom, boom, boom, boom, you just move it around. We'll talk more about that later. Amorphous solids don't have such a nice structure like that. They could be very long molecules, usually round molecules or atoms or ions can pack very efficiently like eggs in a carton or oranges at the supermarket and they therefore tend to form crystalline solids. But if I have a material that is long like spaghetti, like snakes, and I heat it up to a liquid and the snakes all get wrapped around each other and then I cool it down, they didn't have time to reorganize into the best situations. They got trapped, they got stuck. Oh, this guy is through me and now I've removed all the energy and they're stuck like that and they're all stuck in different places and therefore I have a disordered solid. They have different properties, sometimes very interesting properties. And you can actually make molecules but tend to show this behavior. Usually you have a core like a head and then you put on strings like Medusa's hair, snakes coming out and you throw all these things in and you get something that it is basically an amorphous material that you can use in a car bumper like a star polymer. They specifically make a material to do that, okay, that can move. You don't want a crystalline car bumper because crystals tend to shatter when you hit them. You want something that's more like a rubber mallet so if you back up and you hit something it's not a total disaster, your bumper protects the car from damage, okay, gives a little bit. Usually solids are denser than liquids. What is the major, major exception? Water. Water is really a unique substance and if you, if you, I'm sure you've all done it, you leave something in the freezer and it's too full or even if it's not too full, if you freeze it wrong, if you put in a bottle that is closed at the top, what happens is the top will freeze. Now it's a solid and it can't move. Now the rest of it freezes. It's got nowhere to go and the force is incredible and so the thing just blows up, shatters. Yes. I do that experiment I don't want to add in salt. Did it freeze? It froze, yeah, but normally it didn't explode. It could be that it froze more slowly. You can freeze things if you do it carefully. For example, if you have a long thin tube of liquid, like an NMR tube in my lab and you want to freeze it to store it, you don't just put it in the freezer. You put it in the freezer but you put the bottom in an Eppendorf tube and that has good thermal contact and so the, it freezes from the bottom up and, and then you're okay because the liquid can still move. What you don't want to do is trap the liquid and then have it decide and so it can depend on the shape of the container too, how, if it's going to be susceptible to cold damage. And engineers know that. That's why things have different shapes sometimes. They, they know that fully well. This is a mock up. Obviously, it would be hard to take a photo like this. So what they did is they turned a, a, an appropriately sized iceberg upside down. Pretend that that was on the bottom. But it's realistic. It's realistic. Now you can see why the Titanic crashes because here's what you see. And so you say, well, I'll sail way over here and I'll be safe far away from it. And underwater, if you don't have sonar, you can't see it. It's clear. There it is. And then you run your ship into it. And if you're unlucky, it's like opening a can of sardines, the unsinkable ship. You rip it along the whole length. They had all these different compartments. That's why they thought it couldn't sink. But you just rip a ton of them open and it sinks. It's not unsinkable. Nobody, as the ship comes off and the champagne bottles crashing as this, nobody ever says anymore. This ship is unsinkable. It seemed to be bad luck to tempt fate. Okay. Oh, I did want to point out one thing on, on this. If we have icebergs that melt, they don't raise the level of the ocean much because they're already underwater. And therefore the ocean's already gone up when they, they fall off if they actually melt. But if we have ice on land as on Antarctica, and then that melts and that runs in, then the ocean level goes up a lot. Not a small amount, a lot. As in you can go bathing here, which wouldn't be good. Okay. The strongest forces are between ions. And if we have an ionic solid, it will typically have a very high melting point. Because we have an actual positively charged ion and a negatively charged ion. And they're stuck together. And boy, it takes a lot of energy to pry those guys apart and get them to move around independently. You probably have never seen a molten salt, period. You can take flames and you can try to take table salt and eat it like crazy and nothing happens. It just shows a brilliant yellow light, but it doesn't melt. If you want to melt it, you have to get it much, much, much, much, much hotter. Which you shouldn't do on your own. Magnesium oxide has twice the charge. We can model it as magnesium 2 plus ions and oxide 2 minus ions. And therefore with twice the charge, the Coulombic energy is much, much bigger. And we would expect that magnesium oxide then would have a much higher melting point than sodium chloride. And in fact, if we look them up, sodium chloride melts at 801 Celsius, whereas magnesium oxide melts at 2852 Celsius. And if we take it to the next level and look at thorium oxide, where the thorium is probably best modeled as a plus 4 ion and 2 minus ions, that's 3390 degrees C. Sometimes the trend suddenly changes. You have a high melting point, high melting point, suddenly low melting point. If you see that, you just say, I'll bet that last one is not an ionic solid. I'll bet it's not really best modeled as ions on a lattice. It's doing something else. Something happened. So you can judge whether something is or is not an ionic material that way. You can also dissolve it in water and see if it conducts electricity if it's an electrolyte. Thorium oxide won't dissolve in water, however. So you can't test that one that way. You have to be sure that the salt dissolves, and that can be tricky. Okay. The next strongest force is between ions and dipoles. For example, between sodium ion and water, the sodium ion, when we do dissolve sodium chloride in water and make salt water, the sodium ion is not moving around on its own because it's this big positive charge. And so the negative part of the water tends to sidle up to it. It's attracted to it. So all the oxygens face toward the ion like that and back up to it, and they crowd around it. But of course, they get hit by other waters. They may get knocked off. And at any time, you may have between four and six water molecules loosely bound to the sodium ion. For some metals, the first six waters that go on, that's it. There's one here, one here, one here, one here, one here, one here, and they just basically ride around with that ion forever. Same six guys. This one exchanges because it's only a plus one. Your body transports sodium and potassium around, and it's very important to have the right concentration of sodium and potassium. If you have too much of one or not enough of another, you may either be weak or your heart may stop beating suddenly, which has happened to people. If you eat a ton of salt, which most Americans do, you just put a tremendous load on your biochemistry. Salt was hard to find historically. Plants don't have any salt. You put salt on plants, they die. And therefore, it was rare. So if you put out a big block of salt, all the cows in the field come over and start licking the salt. And they need to have some salt. They need to find some. And it's hard to find. And therefore, you're going to like the taste of salt because you could never get enough. But now that you can get enough, it's like food. You have to be careful because you're actually forcing your kidneys to get rid of salt all day long. Your kidneys are designed to not get rid of salt. They're designed to produce, get rid of water and other waste and keep the salt in your blood. That's what they're designed to do. Now of course, just like a car, you can run your kidneys in reverse. But there's a difference. If you run your car forward all the time and drive it properly, it's going to last for a certain length of time because that's how it's meant to be drive driven. If you shift it into reverse every day and start going like this, like a madman down the freeway, you will find that the transmission doesn't last as long because it's not meant to run that way. That's why health authorities are saying, don't eat so darn much salt. Eat the track of it. Look at it. Processed foods have a ton of salt. Since prokaryotes need salt too, we can make antibiotics just based on capturing salt. And here is one, monencin A. There's the structure. Why is the structure interesting? Because look, I've got all these oxygens and then I've got these hydroxyls. So I've got all these negative things like a little cavity. And then a positive ion like sodium comes along and it gets trapped around it. And now the bad acting bacteria that wanted to use that sodium to run its chemistry can't get it. Too bad, like salt. They feed this stuff to cows by the tongue as far as I can tell, which is not a good idea. Okay, let's talk about dipole-dipole forces instead of ion, dipole, or ion-ion, or hydrogen bonding. Dipole-dipole forces are between molecules that have a dipole, therefore the molecule can't be symmetrical. If the molecule is symmetrical and the dipole is pointing this way and the molecule is symmetrical, then if I turn the molecule around, the dipole would have to turn around since it follows the molecule. But if it's symmetrical, it's the same molecule and therefore the only thing that can be opposite itself is zero and therefore a symmetrical molecule has zero dipole moment. Something like molecular nitrogen has no dipole moment. In liquid chloroform, then, these dipoles move around and they have attractive in red, I'm sorry, it's kind of dim, and repulsive in blue forces. These two positive guys repel each other, but this negative guy is closer. On average, there's more attraction than repulsion because the molecules orient themselves so that that's the case. Therefore, this would probably have a higher boiling point than something that didn't have those forces. And finally, the weakest forces are dispersion forces. Those are the ones that arise from a momentary charge fluctuation. The molecule itself may not have a dipole moment or a charge, but nevertheless, the electrons get off the molecular framework just for an instant or two. And that's enough time for the other electrons, which can also move very quickly to slosh over and you get a momentary attraction. And you get umpteen countless repeats of this, and on average, you get this stuff sticking together much more than if that couldn't happen. These will always occur, but if we have something like a charge or a dipole, basically that's so much bigger that it swamps the dispersion forces. So usually we only talk about the dispersion forces being the main thing if there's no charge and there's no dipole and there's no hydrogen bonding, then we go looking for dispersion forces. And as I said before, you can go back to the material on gases where we introduced the Van der Waals parameter A for attraction, and I explained that for neon in terms of these momentary charge fluctuations. Let's see if we can rationalize differences in boiling points by looking at these intermolecular forces. Here's a practice problem. The two molecules N2, which is harmless, and CO, which is poisonous, but unfortunately odorless, are isoelectronic. They have the same number of electrons. Which should have the higher boiling point and why? Without looking it up qualitatively, who wants to guess? CO, and my argument would be CO has a dipole moment, and if I only knew a little bit, I'd guess that because oxygen is more electronegative than carbon, that the oxygen side of the CO is negative and the carbon side of the CO is positive. And guess what? I'd be wrong because in fact our current Vice Chancellor for Research, Professor Heminger, when he was a graduate student, proved that the carbon side is negative and the oxygen side is positive. And if you draw a correct Lewis structure with formal charges and a triple bond, you have to put the positive charge on carbon, on oxygen, and the negative charge on carbon. And when you look at how carbon monoxide poisons you, it's the carbon side that sticks to the metal and hemoglobin, not the oxygen side. And that would make sense that the carbon side is negative and the metal is a positive ion. Difference between carbon monoxide and hemoglobin and oxygen, oxygen comes on and then comes back off, carbon monoxide comes on and then that's it. And you die bright red like a big red tomato because your hemoglobin is even redder than normal. And that's when you find a body like that, it's bright red like a tomato. Then first of all, you don't stay in that enclosed space very long. And second of all, you check for carbon monoxide poisoning. What are the symptoms of carbon monoxide poisoning? The first symptom is confusion. That's why it's important to be a clear thinker. Because if you aren't, you may not know you're confused. If you're confused in a enclosed space for any reason, get outside. There could be a faulty water heater, could be anything. If you just stay there and say, gee, I'm confused, I can't think straight, but I think I'll just sit here. Or you wait too long and you're so confused you decide not to go out, then you can die. Or if you happen to be asleep, that would be very unfortunate. Okay, we look at this and we say, yeah, N2 symmetrical, doesn't have a dipole moment. Carbon monoxide can and does. We would have guessed the wrong polarity, but anyway, it does have a dipole moment. And we expect the dipole-dipole forces to be stronger in carbon monoxide than the London dispersion forces in N2. And anyway, since they have the same number of electrons, we expect the dispersion forces to be about the same. And if we look it up, nitrogen boils at 77 Kelvin and carbon monoxide boils at 82. Gee, it's not very reassuring because it's not a very big difference. It's almost a coin toss. Well, that's because, in fact, the dipole moment of carbon monoxide is very small. It's about 0.12 db. A molecule like KBr in the gas phase would have a dipole moment of about 10 db. And most molecules have dipole moments between 0 and 10. Therefore, this is on the very low end. Hydrogen fluoride is about 2. The db is a unit used to characterize the dipole moment. If you wonder what it is and you're curious, look it up. Look how much charge separation it corresponds to. How much positive charge, how much negative charge, how far are they apart? That's a good thing to know if you want to characterize dipole moments. Now, we just talked about boiling points. We talked about viscosity. But what about melting points? And here, the point I want to get across to you is that melting points are very, very much more complicated than boiling points. Therefore, if you're given a problem ever on a standard exam and it's about melting points, yes, you look at intermolecular forces, but you look at a lot more than just that. Because solids have structure and you have to know what the structure is. And how the things are packing before you can be sure that it's all down to the intermolecular forces. Shape matters a lot. Round things, or things like footballs even, can pack efficiently in a solid. Funny shaped molecules like H2O can't pack as efficiently. And therefore, for a given amount of intermolecular forces, a solid made out of round things like beach balls will have a much higher melting point than you might expect. So it's not just intermolecular forces, but it also has to do with packing efficiency in a solid lattice. That also influences things a lot in this particular case. If you have a molecule that's round and that doesn't have much in the way of intermolecular forces, it'll have a very, very small liquid range. It'll take forever to melt. And then once it melts, the forces are pretty small, so then it just boils just shortly after. And that means the liquid range is very low. Let's have a look. I drew these out. The long chain one is called N pentane. One, two, three, four, five. And then I just move one of these guys from here over to here, and I move the hydrogen from here over to there. And I have a branch. This is along like a snake. This is a branched hydrocarbon. When they're doing cracking of gasoline, they want to make branched hydrocarbons. They don't want these guys. The car engine won't run very smoothly on those, so there's a whole chemistry of how to do that efficiently. Unfortunately, it involves a lot of energy. The first thing you do with a barrel of oil is you heat the thing up like crazy. And that energy to heat the barrel of oil up to crack it to make kerosene, gasoline, propane, etc. And then you're left with road car, so-called asphalt paint at the bottom. It takes a lot of energy. And as long as you've got lots of oil, you just take one barrel of oil and you burn it. And the other barrel of oil, you crack it, and then you burn that too. You burn all of them in the end. But if you start running low, you're going to be in a world of hurt. If you just run low on energy, even if you have crude oil, you'll be in trouble. And then what did I do here? Well, I did the same trick again. I moved one of these over here on this side, and then I put that hydrogen over here, and then I've got a CH3 here, CH3 here, CH3 here. This is 2-2-dimensional propane. I'm naming them correctly, but I don't expect you to know the name or anything. This is just for information. Don't be over-claimed. I don't want to use an incorrect name, but I don't want you to memorize names of hydrocarbons. Okay, let's try a practice problem with these. Let's discuss the liquid ranges of these three molecules after looking up the data. You'll have the data, we aren't guessing, but then you have to explain the data. Why is it that it's this way and not that way? If you look up the melting points and boiling points, and these all have trivial names, N-pentane, isopentane, and neopentane. Now look at the melting point. The melting point of N-pentane is minus 129.8. The melting point of isopentane is minus 159.9. This one melts at a lower temperature. It's got that tinker toy sticking out. We could rationalize that, but it doesn't pack very well. It has an odd shape. Maybe these guys like snakes can kind of line up. We're guessing, but let's just guess for a while. And then look at the melting point of neopentane. On a cold day in Canada, neopentane freezes. It's that much higher. Now that can't possibly be due to intermolecular forces, because neopentane is symmetrical and doesn't have a dipole moment. And they all have the same number of carbons and hydrogens. So they have the same number of electrons. And it's huge. It's almost 100 degrees different. And the point here is that this anomaly is due to the fact that neopentane is round and can pack into a solid extremely efficiently. And so when you try to heat neopentane up, these round things jiggle around, but they can't go anywhere because there's no free spaces. There's no voids. If you have an odd-shaped thing, it can't pack efficiently. There's a void. So I heat it, it can move and squeeze through. Then these guys can start moving and then guess what? It's melted. This one can't. They all have to go at once. It takes a lot more energy to do that. But then look at the boiling point. This one's the highest, and that tends to be true, these long-chain ones. And this one is intermediate, and this one is now the lowest. Because it has no, once it's moving around in a liquid, we aren't talking about packing. We're just talking about forces, and therefore it boils very easily. So the important thing is be careful not to assume melting points have everything to do with intermolecular forces. This particular problem has made the rounds for 30 years, because I was given that problem to do. It's still around, and people still can't explain it if they haven't studied it. Okay. This is just what I was saying. I've given you the data again. Neither endpentane or isopentane can pack that efficiently, but isopentane has smaller forces, so it has a lower melting point. So isopentane can suddenly pack extremely efficiently, and that's why it has a much, much higher melting point. Very small liquid range. Okay, let's talk about crystalline solids. Let's start with two-dimensional. We'll start with a load of circles, and we'll put them together like anybody's done with pennies. And there is the closest way you can get them to fit until they touch. And this is the way. Bees have worked this out, of course. There's a hexagonal symmetry. There are six closest neighbors to any one central god. And I can tile the entire plane with these hexagons. I can tile the plane with triangles, the square hexagon. I can't with octagons. And if you look at a soccer ball, the soccer ball has facets with six sides, but the soccer ball is round, curved. Therefore, I can tell you that not all the facets have six sides, otherwise it would be flat. And occasionally, if you look at it, you'll find one with five. And when you put one with five, it starts curving down, and then if you know what you're doing, you can make something round with sixes and five. And you can make all sorts of shapes with crystals with different facets. Six, five, and so forth. It gets complicated. But they're very, very beautiful objects, if you understand how they're put together. They're much more interesting than you ever thought. Now, there's only one way to do this here. And you might think if I take marbles, and I put them in, you know, stack them up like eggs, there's only one way to do it as well. That's what I thought. But surprisingly, that's not true. There are two ways to do it with spheres. Not one. There's two, and they're both as tightly packed as possible. Now, here's how it works. On top of the red, I've put a layer of blue ones. You can see I put them right in the divot. Here's the blue one on top of the three reds. You know that's how they would stack up. But then, interestingly, there are some holes in between. So there's a blue one here. There's a blue one here. But here, there's a hole. So if I shine a flashlight through, the light comes through that hole. And there's a bunch of holes along here where there are neither a red one nor a blue one. And it's every other layer. These are covered. These you can see through. Now I have a choice to put on a third layer. And the choice is I can certainly put in this divot, there's three blue ones, I can put another red one right on top of the other red one. In that case, the light still shines through. Or I could cover the holes. In that case, the light doesn't shine through. They both have the same packing, same density, but they're different. Let's see. Now I've put the red one on top of the other red one so we can't see him. And now you can see, here's a blue one behind here, but here's a hole. I'm sorry, I should have picked a darker blue. Here's a hole, here's a hole, here's a hole, here's a hole. But if I do it, and this is called ABA, to tell us that the third layer is the same as the first. Just moved up. They're all in the same position, just a shorthand notation. But we can also put the third layer, I put it in yellow. Now it lights out. No hole. And that's because instead of lining up the yellow with the red, I moved it over one to cover the holes. The best way to do this is to get a bunch of round things and play around with it. And you'll see it quite quickly. And this structure is called ABC, to show that the third layer is different from the other two. The next thing to ask yourself is this, have we covered all the possibilities? And it turns out we're the closest pack in the spheres we have. There are no other possibilities. They're both close packed. They both can make the densest structures we can make with identical spheres. And the ABA structure has hexagonal symmetry. It's just like the 2D case, like what a honeybee might put together. And that's called hexagonal closest pack, or the abbreviation is HCP. And the other one has cubic symmetry and is called cubic closest pack, or CCP. Now here's a question a mathematician would ask you. Suppose I had a crystal made out of four dimensional spheres. How many ways, how many different ways are there to pack them? You may have to think about that a little. You probably can't imagine what a four dimensional sphere looks like. Most people can't imagine the fourth dimension at all. Because for one thing, a surgeon would love a fourth dimension. And why? Because they could see inside you. Everywhere. And they could probably hear everything you were thinking. Just like when we look down, here's the two dimensional circles talking. They can't see inside each other. Hey, how you doing? Fine, how are you? They go each other's way. They can't see inside if they've got an opaque. But the guy in the third dimension looks down on him. He can see all their guts inside everything they've eaten, everything. And if we had a fourth dimension, we could see all of us spread out and see everything. So a four dimensional space is much cooler than what you might have thought it might be. And a four d sphere is much more complicated than you might have thought too. Okay, we'll pick this up next time with Crystal and Solid.
UCI Chem 1B General Chemistry (Spring 2012) Lec 03. General Chemistry -- Last Gas (p) and Condensed Phases -- Instructor: A.J. Shaka. Ph.D. Description: UCI Chem 1B is the second quarter of General Chemistry and covers the following topics: properties of gases, liquids, solids; changes of state; properties of solutions; stoichiometry; thermochemistry; and thermodynamics.
10.5446/19429 (DOI)
OK. Let's get back to where we were. I've got an idea. You know, before you go for a run, you stretch. Make sure you don't get hurt. Let's do a little Neurobics. Let's stretch our minds a little bit. On my count, we're going to start at 150, subtract 7, visualize each number, and stop at the smallest positive number. Ready? Go. Three. Keep going if you aren't done. Now here's the thing. There are several levels of that game, and they're very important to understand. The lowest level is your lips are moving. 150, 143, 136. Wait a second. Where was I? The second level is your hearing things, sort of, in your head. 150, 143, 136, 129, 122, 115, etc. That's faster, but that's still slow. The next level is your just seeing the answer. It's dead quiet. You see it come up just like a lap counter. And the fourth level, of course, is that you never actually do what you're told. The first thing you always do, in any scientific problem or mathematical problem, is you try to make it into an easier problem. Subtracting 7 is difficult, so I didn't do that. I subtracted 10 and added 3. 150, 140, 143, 133, 136. Pretty soon I can see that the last digit is just going 3, 6, 9, 12, etc. Then I can see all the numbers like one long chain, like a snake. Almost see them all at once. Now the bottom. Almost every problem that you encounter is like that in some way. You can get very good at it, and if you do practice, you will get good at it, and if you don't, you'll be hopeless. There's a lot of difference between somebody who can do a cartwheel and the rest of us, when we try to do a cartwheel. And the real difference is not in natability, but the person who's practiced it can do it. The person who hasn't practiced it is hopeless. So you've got to practice. Whenever you feel your mind feeling a bit of frustration, you're getting smarter. Then when you pressure yourself and you're thinking, that's a good feeling. Just don't make it too intense. Okay, let's get on with the work at hand. We're going to talk about partial pressures and the kinetic theory, and I've got some topical things. First of all, here's a challenge problem. If you're interested, find the pressure. Remember we did carbon tetrachloride. We got 30.62 liters there for the volume. So find the pressure for the previous problem so that the van der Waals gas has the same volume as the ideal gas. That's kind of a unique situation that's interesting. And then the second part is find the temperature at which the volume of the van der Waals gas is just barely smaller than the ideal gas. So the pressure is the same. And then the final thing is to look up the boiling point of carbon tetrachloride and see if you can think up any reason why you got the answers you did based on how far away we are from the boiling point of the material. Hint, if you're near the boiling point, the gas is not necessarily going to behave that ideally, because it's about ready to condense into a liquid. OK. Intermolecular forces, we talked about van der Waals, we talked about dispersion forces, they're called. Minute charge fluctuations, momentary charge fluctuations leading to the appearance of two dipoles, which then attract, but some molecules actually have a permanent dipole. For example, water and chloroform. Because of the difference in the electronegativity of the oxygen and the hydrogen, water has a dipole moment. This side is slightly negative and this side is slightly positive. And chloroform, for the same reason, the three big chlorines are big hogs for electrons and they pull all the electrons down this way and this becomes slightly negatively charged and this becomes slightly positively charged. And both these molecules have relatively high boiling points they persist in the liquid. Water in addition can form hydrogen bonds, which is a very strong force compared to the other ones. So that's a special case. But if we have a molecule that has a dipole moment, then we expect that it will have a big value of A in the van der Waals formula, because it should have a big attractive force, because it's a permanent dipole and so they can definitely line up and attract each other under those circumstances. If we compare the role of more electrons, which leads to more fluctuations versus a small dipole moment, it turns out that it's a little bit tricky. So if you just say, well, a dipole is a bigger force than a London dispersion force and I expect this molecule with a dipole to have a bigger value of A than carbon tetrachloride, then you get disappointed because this one that has more electrons actually has the slightly bigger value of A. And this is just the usual case in science. There's a simple cut through which leaves out all the complexity and then there's the real case, which is usually more complex and requires a lot more study to figure out why it is that this is bigger than that, that that's smaller than this and so forth. And that just means that there are different layers like an onion that you have to peel off before you can get very close to reality. If you compare water, water has a smaller value of A, but at least in the liquid, water would have much higher intermolecular forces than any of the other ones. If you compare H2S, which isn't quite as polar as water, so H2S is rotten egg gas, very poisonous, we all find H2S extremely unpleasant to smell. If you smell H2S, even a little bit, you wrinkle your nose and you take off the other way. Why is that? It's very poisonous. The humans who didn't wrinkle their nose and take off the other way are dead. Okay? If a volcano erupts and you say, boy, that smells like hot chocolate and you head toward it, you're gone. Anything that appears in nature that's dangerous like fire or H2S or you name it, you will have an aversion to. But if it doesn't appear in nature, all bets are off. Hcm you won't find around. That's very poisonous just like H2S, but it smells kind of good. And the reason why is nobody ever smelled it. So we don't have any kind of selection against that type of thing. If we go down one from sulfur to selenium, we can see that as we add more electrons, A gets bigger, that's comforting. Then we could try going down from carbon. I went all the way to germanium. If we go to germanium tetrachloride, then we get this bigger value as well. So there are some trends, but it's always more complicated than it seems. Gases aren't very dense. If they were dense, they'd be liquids. Sort of by the nature of a gas, it's not very dense under normal laboratory conditions. And we can measure the density. We can evacuate a container and then we can flood it with gas and with an accurate balance, we can measure the difference in mass. That's not really that big a deal. It's more than you might think, too. So if we know the density as the mass per volume and we know the pressure and the temperature and we assume the ideal gas equation, then we know how much mass takes up how many moles. But that tells us the molar mass. But just measuring the density of the gas can give us a hint what the gas is. Which one? Not necessarily without some ambiguity because some gases may happen to have the same molar mass like N2 and CO. We wouldn't be able to distinguish them. So we start with PV equals NRT and we divide both sides by V and we divide both sides by RT. And then we write the right-hand side first. We have the number of moles per volume is equal to the pressure over RT. And the number of moles is the number of grams divided by the molar mass in grams per mole. So I can put that in and then I can solve for the molar mass and the molar mass is the grams RT over PV. Now, fine. That's a nice mathematical solution and I do not advise you to use it because the problem with this is the units. The units you're going to have to use are going to be very funny, like cubic meters per volume. So if you convert everything into MKS units, you're going to get the answer in kilograms per mole, which is not how chemists usually quote it. They usually quote molar mass in grams per mole. And you're going to have to use funny units, cubic meters, r's and joules, etc. So here, the molar mass is given in kilograms per mole and then only if r is in joules, the volume's in cubic meters and the pressure is in these wimpy units, Pascal's, Newton's per meter squared. The whole thing is awkward. I don't advise doing it. I'll give you an example problem and I'll show you how I always do it. If the gas is a mixture, then the molar mass will come out to be the weighted mean and that might not correspond to any particular gas that you look up in your table of data and you may have to then do some more experiments to figure out what's in there. And that's exactly what chemists did to figure out what was in there. Let's burn out all the oxygen. What's left? Let's make this thing react. What's left? They finally had something left that didn't react with anything. That's how they discovered argon. Okay, let's try a practice problem. So let's suppose the density of air is 1.2 grams per liter at one atmosphere and 25 degrees Celsius. What is the apparent molar mass of air? Well, okay. The first thing we always do when we look at these things is look at the units, especially if the units are given in any kind of funny units. I see degrees C. I write away think, no, no, no. Where is Lord Kelvin? Rolling over in his grave if you use that unit. So we have to convert. And when I convert or when I use a constant, I try to write down as many digits as I can. If I'm given seven digits on a constant on an exam, 8.31447, I use all those digits. It doesn't take me that long to write them down. People killed themselves to get these constants to that accuracy. It's really a crime to round something off too aggressively and then get the wrong answer. Okay, so go ahead and use 273.15 as the conversion from Celsius to Kelvin. Okay, the way I like to do it then is I like using R and liter atmospheres because I have a liter of gas, I have grams, and I have an atmosphere. And so I just go ahead and write down here 298.15 Kelvin, one atmosphere, one liter. I just solve for the, I say how many number of moles would that be? And I plug in the numbers and I find out that I get 4.087 times 10 to the minus 2 moles. But it said that that was 1.2 grams. So 1.2 grams is 4.07087 times 10 to the minus 2 moles. How many grams per mole? Well, take 1.2 and divide it by that and you end up with 29.36 grams per mole. That's the way I prefer to do it because I find that easier than just using the CAN formula and then having messy units all over the place. Okay, but you're free to do it any way you want. The only thing that matters is that the orbiter doesn't crash. You have to get the right answer. If you get the right answer, nobody cares how you got it. If you don't get the right answer, nobody cares what great intentions you have. Okay, if you check on your own, you can verify that this squares pretty well with the composition of air that's about 80% nitrogen, about 20% oxygen, and about 1% argon. I've rounded them off. I say others are much smaller, but it turns out CO2 is creeping up in fourth place. And as I mentioned, the inert gas argon was in fact discovered by comparing oxygen from air with oxygen from a chemical reaction. But there are certain compounds that when you heat them, they produce oxygen and you prepare that pure compound and heat it and you generate a bunch of oxygen gas. And then you compare the properties of that with oxygen gas that you've isolated from air and you find out that there's a difference. So there's something in the air that's not oxygen that doesn't appear to react anything. They couldn't get it to react. They couldn't find out what it was. So they call it argon, Greek for lazy one. It just doesn't want to react with anything. And in the early days, they called these inert gases because they thought they would never react. Then in the 60s, they got seen on to react with something and then so they called them the noble gases because they would react, but not very strongly, sort of like royalty. Okay. So, well, even though argon was inert, chemists knew something else was in there. They just didn't know what it was. If we have mixtures of gases, guess what? They don't care. They all behave independently. So they all just bang against the sides and they behave exactly like the same number of moles of one gas would. And this assumes, of course, that the molecules don't chemically react or do anything, bind to each other in any way. That's what we're talking about. So if we have a mixture of nitrogen and oxygen and argon, that behaves very similarly to the same number of moles of just nitrogen. Not much different. And therefore, we have this concept of partial pressure. The partial pressure of a gas is the pressure due to just that gas alone. Just throw away the other guys, say, how many moles of this gas do I have? What's the temperature and volume? Whatever that pressure is, that's the partial pressure of the gas. It's a simple idea. Throw away the other guys and there you go. Now, here's a practice problem. What's the partial pressure of oxygen in dry air at STP? STP is an abbreviation for standard temperature and pressure. So STP is 273.15 Kelvin and one atmosphere. And if you actually take the time to look up the detailed composition of air, it's 78.084% nitrogen, 20.946% oxygen, 0.934% argon, and 0.039% CO2 due to us adding CO2. It wasn't quite that high before. These are all bivolume, but bivolume, as long as we treat them as ideal gases, the volume fraction and the mole fraction are the same. We don't have to worry. The mole fraction is just the moles of O2 in the sample divided by the total number of moles of gas in the sample. And it's usually given this Greek symbol chi. The mole fraction of oxygen is the number of moles of oxygen divided by the total. And, well, the partial pressure is just the mole fraction times the atmospheric pressure. The mole fraction is 20%, so the partial pressure is 20% of one atmosphere or 0.2095 atmospheres. That's the partial pressure of oxygen. And more generally, if we have a ton of different kinds of gases, the partial pressure of any particular gas is the number of moles of that gas divided by the total number of moles in the container times the total pressure, which if the container is not rigid is just the external pressure. And we can write that as just Na over Nt times Pt, or we can write this as the mole fraction, this divided by that, that's the fraction mole. So that's chi times the total pressure. And that is a mathematical statement of Dalton's law of partial pressure. And in English, we just say the partial pressure of a gas in a mixture is equal to its mole fraction multiplied by the total pressure. It's good to be able to understand it both ways, just as a compact equation and then as a sentence that you can explain to someone else. Okay, let's drive a car. Problem six. A car running under light duty cruise. What does that mean? That means I'm driving very conservatively five miles under the speed limit and never accelerating unnecessarily. And watching the cars go around you as if there's some great hurry to get home and watch TV because you aren't going exactly at the speed limit. The speed limit is a limit. It's not a suggested rate of travel. It's the limit. If conditions aren't perfect, you don't want to go necessarily at the limit. But let's forget that for now. Let's assume our engine is burning iso-octane, which is C8H18, using air. Intake air at atmospheric pressure, iso-octane into a cylinder, compress it and detonate it, make an explosion and then convert that into mechanical energy. Very inefficient, but there you go. So let's assume ideal combustion. The question is, what should the partial pressure of the fuel vapor be in the cylinder? Well, okay. We know the composition of air. It's about 20.946%O2. And let's assume it behaves ideally as an ideal gas. What we need to know then is how much oxygen it takes to burn the iso-octane. Assuming ideal combustion is kind of a code for balance it all to CO2 and H2O. Complete or ideal combustion, hydrocarbon goes to CO2 and H2O. Does it actually do that in a real car? Uh-uh. Usually produces carbon monoxide, very poisonous, and nitrogen oxides called NOx, which give you the brown haze over Los Angeles. Okay? But let's ignore that for now. We have iso-octane, C8H18, plus some number of moles of O2 unknown, giving some number of moles of CO2 unknown, plus some number of moles of H2O unknown. Well, the way you do this kind of thing is you first work with the ones that have to match. There's only two molecules with carbon, this one and this one. This one has eight carbons. This one has one carbon, so Y is eight. That's the first thing you do. Then you look at the hydrogen. There's only two molecules with hydrogen. There's this one with 18, and there's this one with two, and therefore Z is nine. Once you have Y and Z, you put them in. Now you figure out how much oxygen it takes to balance the oxygen, because oxygen is in both the other guys. You don't start with oxygen, you go around in a circle. We balance the oxygen last, and it comes out to be 25 over 2, 16, and 9. This is molecular oxygen, which is 2, so instead of 25, it's 25 over 2, or 12 and a half. One thing to notice is that for every mole of iso-octane or gasoline that we burn, we get eight moles of CO2, which is quite a lot. If we want to burn this at the stoichiometric mixture, for every mole of iso-octane, we're going to have to have 12 and a half moles of oxygen. We aren't burning the iso-octane with oxygen, we're burning it with air, and so we've got to intake a ton of nitrogen and all those other things to get enough oxygen into the cylinder to make it work. One thing you might ask yourself after looking at this is, why don't we just burn the fuel with pure oxygen? That would have a lot of great effects. We wouldn't get any NOx because we wouldn't have any nitrogen in the cylinder. It would burn hotter for sure. Pure oxygen makes things burn extremely hot, but then we'd need a tank of oxygen to carry around. We'd have to isolate oxygen from air, which would be energy intensive. The short answer is the reason we don't do that is the reason we don't pave the streets with gold. It's just too expensive. It looks nice, it works great, but it's too expensive to do it. It's not practical. If we burn air, let's figure out how much we need. Well, we've got to have 12 and a half moles of oxygen, but oxygen's only 20.946% in air. Instead of 12 and a half moles of oxygen, we need 59.68 moles of air per mole of fuel. The total number of moles in there is 59.68 plus one mole of fuel. The mole fraction of fuel is.01648, or a little more than one and a half percent mole percent fuel. When we detonate it, it's mostly air and there's a little fuel. That kind of squares with how you imagine it might be in an internal combustion engine. If you think about it, you don't think that it's going to be 50% fuel or anything like that. If we assume before the compression and detonation that we're bringing stuff in at atmospheric pressure, in other words, we don't have a supercharger or a turbocharger on it. We aren't actually compressing the gas before we put it in, which would give us more power, perhaps, but maybe a shorter engine life, depending how you drive the thing. I think the early subs had a lot of problems. Then the total pressure is one atmosphere. The mole fraction of fuel is 1.6 times 10 to the minus 2, and so it's 1.6 times 10 to the minus 2 atmosphere is the partial pressure of fuel. Final answer. When you tromp on it, the computer controlling the fuel-air mixture doesn't look at the exhaust gas the same way. When you drive conservatively, it tries to adjust it so that there's no O2 left over, but no extra fuel either. That being the most efficient way to go. But if you want more power, you just say, forget efficiency, I want to go, then you put fuel-rich mixture in. The reason why you do that is so that you have some fuel on the way out to make sure that the cylinder doesn't overheat and just blow up or melt. Then your efficiency goes way down. It would be very illustrative for all of you to ride one time with the guy who drives the car to get the estimated fuel mileage for the car for city and highway driving. Those numbers that you never make, 36 and 22 or whatever they are, miles per gallon. They drive the car extremely conservatively. Obviously, if they drive the car very aggressively, the manufacturer goes crazy. It says, what are you doing? You're driving my car very aggressively and making me look bad on mileage. The guy drives the car very, very conservatively, more conservatively than most of you have ever thought of driving. You hardly feel a shift if it's an automatic. Very, very gently. Never push on the accelerator when you don't need to. Then you actually do get that mileage. If you drive aggressively, you also give us worse air quality too because you have fuel-rich mixture coming out. Anybody who runs in the morning can tell whether a car has been driving by in the last two minutes right away. I can tell. No cars on this street. Somebody drove by a little while ago, even if they're gone because there's a difference in air quality. Let's talk about the kinetic theory. We have these empirical laws. A law is a generalization of observations. A theory is a rationale to explain why that is. This is a kinetic theory which is designed to explain those laws. We make some assumptions in any theory. The assumptions we're going to make are four. First, molecules are separated in space in the gas by many diameters. It is a gas. It's nowhere, nothing like a liquid. Number two, the gas molecules collide and move randomly. That's pretty much fine. After all, gas molecules don't have any brains, so they can't plan what they're going to do. Interestingly, no molecules have any brains, and yet big assemblages of molecules do have brains or are brains. Number three, there are no attractive or repulsive forces. We know that's wrong from Vander Waal. Number four, the average kinetic energy of gas molecules is proportional to the temperature. That one's actually pretty good, in fact, and would follow from number three. Know these assumptions. It's always important to know what the assumptions of a theory are, because if any of the assumptions are violated, then the conclusions may not follow. It's very important to ask people what their assumptions are when they forecast an economic model. What are they assuming, and how plausible is that assumption? Or can you verify that that would actually have to happen? Assumption one, well, assumption one is essentially that the molecules have no volume themselves, and that's not going to be true at very high pressure, but this theory is for the theory of gases, gases in the lab, not gases at very high pressure. Assumption number two is fairly accurate. There should be no chemistry occurring, no chemical reactions. They just move randomly. They don't collide and recombine and stick. Assumption number three, as I mentioned, is clearly wrong, because we know that all gases can liquefy and that all gases have repulsive forces, too, from the hydraulic jack. But it's mostly okay for traditional gases, because we don't try to lift a car with compressed gas. We use a fluid, a liquid, to lift a car. And we're going to talk about gases. And assumption three leads to Dalton's Law, in fact. Assumption four is true if there are no forces. If there are no forces, then basically the temperature, the kinetic energy, is the only kind of energy, and that's proportional to the temperature. Potential energy is energy due to position, due to some coordinate. Kinetic energy is energy due to motion. Potential energy is energy like a spring being compressed. But the spring has a force. It's fighting me. If the molecules have no forces between them, there's no springs we can be stretching or otherwise, and so there's no potential energy at all, and therefore the only energy is just the energy of things slamming around. Kinetic energy. And that will be proportional to the temperature. The pressure arises from collisions between gas molecules and the container walls. Gas molecule hits, ricochets, hits here, keeps going, boom, boom, boom, boom, boom, boom. Round and round it goes, and that tends to push the thing out. That pushes the pressure out. Gas is trying to escape. It would like to keep going in a straight line. If you want to deflect it, you have to put pressure on it. Make it change direction. If we pass the volume, and these are moving randomly, then the number density, the number per unit volume doubles because we have the same number, half the volume, so we have twice the collisions with the container. But then we're going to get twice the pressure. So if we have the volume, we get twice the pressure based on this little theory, and that was Boyle's Law. So this theory explains the empirical observation that Boyle made that he generalized the Boyle's Law. That means this theory is on the right track because it's agreeing with experiment. If we increase the temperature, we increase the average kinetic energy in proportion. And with a little bit of math, which I won't go through, we can show that the pressure increases in proportion. So if we increase the temperature, double the absolute temperature, we will double the pressure. But we know that if we keep the pressure constant, the volume would have to double instead. And so if we double the temperature and keep the pressure constant, we will double the volume. That means the volume increases linearly with temperature. And that's Charles's Law. We derive Charles's Law from this simple theory as well. And we can also derive Avogadro's Law from these assumptions as well. The pressure depends on the number of particles, but not the kind of particles. It's proportional to the number of moles, but not the kind of material. Just the number of particles or number of moles in there. Suppose now we ask a more detailed question because now we're proposing this theory, kinetic theory, theory of motion. The question is, what does it look like in there? I'm a gas molecule. Whoa, I'm flying around. Bang! Ow! Ricochet off. Boom, boom, two guys. Now I'm stopped. But I can't be stopped for very long because I get hit by a freight train from behind. Oh, and I'm off again, and then I may get hit by two other guys, and then I'm going really fast. And so the question really is, if we could take a snapshot and stop, look at them all and say, okay, you, how fast are you going? How many meters per second? You, you, you. And we make a histogram. What does it look like? Clearly they aren't going all at exactly the same speed. That's very unlikely. And they can't all be stopped either, that'd be a solid. And they can't all be going really fast, or the gas would be hotter than it is. So there has to be some magic distribution, which is the most likely, sort of like a curve for a class, the most likely outcome. And Maxwell figured out how to make this histogram and derived the function. So very few molecules are moving slowly. You just can't move slowly in a gas because you get hit by somebody. And then you just have to speed up. And you can't be going too fast, or too many of them are going too fast, the gas would be hotter than the actual observation temperature. But if we imagine suddenly that the gas molecules start moving faster and faster and faster and faster, where did all that energy come from to make them do that? Heat. Heat, but we aren't heating it. We're keeping them at constant temperature. Right? Well, no. What I'm saying is that can't happen. If we did heat it, it would happen. We'd get more in the high tail, for sure. But if we just sit there with a container at constant temperature and pressure, certain volume, and just say, look, let's take a snapshot, let's look at what happened. We wouldn't expect to have too many going too fast. Oh, there's a magic distribution that Maxwell worked out. He only lived to be 49. I don't know when this picture was taken, but I think I'm doing better than Maxwell. He liked to drink whiskey. Don't know if that had anything to do with his early demise or not. But he was one of the smartest guys so far. No question about that. And he figured out that it would be this form, the histogram, the number of molecules moving at a speed v, is this spinach under this radical, times v squared times an exponential function which looks like the kinetic energy, mv squared, 1 half mv squared, divided by k times t, kb for Boltzmann, times t, which is a measure of the thermal energy. So we divide the kinetic energy by the thermal energy. We get a dimensionless thing. Anything in an exponential can't have units because an exponential is a power series, right? 1 plus x plus x squared over 2 factorial. And we can't add up things with different units. And here m is the mass of the particle and kb is Boltzmann's constant and t is the absolute temperature in Kelvin. We never use any other temperature. This derivation is really beautiful. And until you see beautiful thought, you may appreciate beautiful art. But you may not yet appreciate beautiful thought because maybe you haven't seen much. But this really is beautiful. But it's a little difficult, so it's beyond the scope of our course. This is why you take other courses so you can get to the bottom of certain things like this. It turns out that there's a relationship between the gas constant and Boltzmann's constant. And they're just related by Boltzmann's constant is per molecule and the gas constant is per mole. So they're related by Avogadro's number. It's a very big 6 times 10 to the 23. And we can then rewrite Maxwell. Instead of using k, we can use r. And the Avogadro's number stuff cancels out here. And then we get a more useful thing where we have this factor here which is unfortunately again kilograms per mole v squared and then kilograms per mole v squared over 2RT. r has to be in joules here. This is again a slightly tricky formula units wise. And I'll go through a couple of problems to make sure that you understand how to handle the units. So here the molar mass is in kilograms and r must be in joules. And then you get meters per second for the velocity. Well with this histogram, whenever you have a histogram, if I have a curve for the class I can say what is the highest grade, what's the lowest grade, what's the average grade, what's the median grade where half the class is above and half is below that value. And what's the most probable grade? Most people got a 60. I can ask all those things. And the mean, the median and the most probable or the root mean square, these are statistical measures that tell you about the shape of the distribution. These are used in statistics for any kind of distribution. So let's talk about the mean, the root mean square and the most probable. Those are ones that we have formulas for that are easy to derive. First of all, the property that this distribution has to have is that the probability of a student having some score has to be one. And that means that the integral of this function has to be unity. Okay? Or all the numbers in the histogram have to add up to the total number of people in the class, otherwise I've missed a person. And it obviously can't be more. Now we take the speed here up to infinity, but of course particles can't go faster than the speed of light as far as we know. But our gas particles are nowhere near the speed of light, so that turns out to be a tiny error since there are no particles up there anyway. We can figure out the average speed, the average of anything is the sum over the histogram of the thing. So in the case of a score, you just take the score times how many people got that score. That's all we're doing here. We're taking the velocity times how many molecules have that velocity, what fraction. And we're adding them all up. And that integral, which is easy to do but I won't do it, turns out to be the square root of 8 RT over pi M. M is in kilograms per mole again. So that's a simple form for the average velocity or the average speed, excuse me, in a gas at a temperature T. We can get the root mean square speed, literally root mean square. Take the square, take the mean of the square, take the square root of the mean of the square, and you get the root mean square. And that's a different integral to do, but it turns out you can do that one too. And you get square root of 3 RT upon M. No pi this time, the other at 8 and pi. And you can get the most probable speed. That's where the slope of the histogram is zero. I'll show you on a plot where that is. And that's easy to do. That requires a little algebra again. And you get the square root of 2 RT over M. And that gives us all our distributions. And here is a picture of what the distributions might look like in meters per second. If I have a heavy molecule like xenon, then I have a much, much slower, much more peak near low speed. And if I have a very light atom, excuse me, not molecule, like helium, I find that I get a very wide distribution of values and that the mean speed is much higher. This is the most probable speed in each case for each of these guys. And you can see that it's not quite symmetrical. There are more guys going fast than there are going slow. So it kind of stretches on the way out. That's the V squared part of that function. These are very fast speeds, though, 1,000 meters per second. Think of that. That's a kilometer per second. You would guess that we'd get pushed aside or that the air would seem very violent. And it doesn't. In fact, it doesn't do anything. The reason why it doesn't really do anything is because it's like a traffic jam on the 405. Only the cars are actually crashing into each other and that's why they're going nowhere. So I'm going 1,000 meters per second, but I'm not going in the same direction for very long before I hit something. And then I'm going this way, then I'm going that way. And on average, I'm going absolutely nowhere unless there's wind, unless there's an actual macroscopic pressure difference somewhere. On the other hand, I do spread out. We do know that if we put a container here that has perfume in it, eventually you'll start smelling it. In fact, if you cut a rose like Mr. Lincoln would be a good one. And you just put it in a vase in your living room on the way out of the door in the morning. When you come back and open the door, the whole house has just a faint, beautiful, rich smell of that wonderful flower. So it's diffused during that time throughout the whole place. And you can change the kind of flower every day depending on how you feel. You can have one that's a little more citrusy, more cinnamon-y, little chocolate, et cetera. Okay. Let's calculate some relative speeds here. Let's compare the most probable speed for molecular oxygen, O2, and carbon-tetra-bromide CBR4 at 100 degrees Celsius. Ooh, Celsius. Never use Celsius. Well, let's have a look. The most probable speed's the top. We had a formula for it. The most probable speed is the square root of 2RT over M. And here I just wrote out all the units for molecular oxygen, 32 grams per mole. I don't want grams because I don't have any grams up here that I can see, convert to kilograms. R, joules per mole per Kelvin. Kelvin go away, joules, moles go away. And then I just leave it. I work out the numbers and I get 440 joules per kilogram to the square root, one-half power. That should be a speed, presumably, if I've done it right. But maybe it's not obvious that it is a speed, but I like to go through this so that I can show you how you can convert it to a speed. Sorry. A joule is a Newton meter because a joule at work is force times distance. And a Newton force is mass times acceleration, kilograms times meter per second squared. So a Newton times a meter is a kilogram times a meter squared per second squared. But we had a joule per kilogram to the one-half power, so we had meters squared per second squared, the kilograms go away, square root of meters squared per second squared, meters per second, sweet. So the answer is, in fact, 440 meters per second since a joule over a kilogram to the one-half power is, in fact, meters per second. On the other hand, for carbon tetra bromide, we plug in carbon 12.01 grams per mole, bromine 79.9 grams per mole, convert to kilograms. So again, we're going to get joules per kilogram to the one-half, we get 136. Molecular oxygen is moving a lot faster than carbon tetra bromide because it's a lot lighter. And the speeds go like the inverse square root of the molecular masses. Obvious, since there it is. Inverse square root. Temperature's the same, that's how it works. And this dependence on the inverse square root explains both diffusion and effusion, both of which can be important. The gas molecules move at high speed, but they don't go anywhere because they keep changing directions. They're like somebody who switches majors three times. They don't get anywhere. Better to select the direction and then go at a moderate rate than go like crazy and then change and reverse gears. Therefore, the net flow of one kind of gas through another one is much, much slower than the individual's speeds. And this is called diffusion. Diffusion is the random spreading out of molecules until their concentration everywhere is the same. Whatever molecule is responsible for the fragrance in Mr. Lincoln, and actually there's more than one, they have a certain molar mass and they diffuse out of the petals of the flower as it heats up and then they spread around the room to some concentration which is quite small, but your nose can pick it up easily since your nose is a great detector. In liquids, if I put a drop of dye and leave it in a glass of water and come back the next day, the whole water will be a dilute color. The dye will just randomly spread around. And if I take a pollutant and I dump it in the back bay, it'll randomly spread around everywhere. And then it'll be a million times more expensive to clean it up than if I had caught it early and just scooped it up and gotten it out of there. Once you let things spread out, you're in trouble. It takes a lot of work then to put the genie back in the lamp. You don't want to do that, especially with pollutants. You want to control them right away. Diffusion is similar but it's the escape of a gas from a container with a pinhole into an area of lower pressure like a vacuum. Like this. Oop, that guy went out. That one red guy. He went out. And the big, heavy, silver guys didn't do anything because they're moving too slowly. They just don't hit the sizes often so they aren't going to get out as easily. Whoever's moving fast goes, he finds a pinhole. Whoever's moving slowly takes forever to get out. But then chemists found they could use this as a way to separate things. If you have a series of pinholes, you eventually get all the fast guys going through. And if they're fast guys or what you want, you have a process to prepare pure fast guys. And the most important aspect of this is in the nuclear fuel cycle. Diffusion can be used for isotope separation. We can't separate uranium 235 from uranium 238 by chemistry because they have the same chemistry. Chemistry is about electrons. Isotopes have different numbers of neutrons in the nucleus. But they have the same electron configuration and so they react pretty much the same. We aren't going to be able to separate these by chemistry. But they have different molar mass. One is 235, one is 238, and therefore they have different rates of effusion. Therefore if I can prepare a gaseous uranium compound and put it through a ton of pinholes, the U235 compound will come through the pinholes first. Then I can gather that up and make a bomb, which was the purpose of doing it. Natural uranium is just 0.7% U235. If we had four stages of effusion using the hexafluoride, UF6, which turns out to be a gas, what kind of enrichment would we get? Okay. The rate of escape through the pinhole will be like the speed, and that's the inverse square root of the masses. So what we need are the masses, not of just the bare uranium atoms, but of the hexafluorides, which are the gases. So we take the ore, we fluorinate it, we put it into this diffusion apparatus, and we find that one of them is 349 grams per mole, one is 352 grams per mole. Therefore the rate of effusion of the 235 isomer versus 238 is the inverse, so the 238 is on the top, the 235 is on the bottom, square root of 352 over 349, 1.0043. That is a miserable number because that didn't change things much. Well, if you do it four times, you get a factor of 1.0043 each time, so you multiply them. And so if you have four stages of effusion, you now get an enrichment by a factor of 1.0173. Well if you start with natural ore, which is 0.7%, and you get this factor, now your enrichment is 0.712%, so it's a little higher. In order to make fuel for a reactor like Santa Del Nofre, you have to get the uranium content up to about 2% to 3%, say 3% uranium 235. That's enough. In order to make a bomb, you need more than 90%. So you can see if you're going to enrich uranium to make a bomb, you're going to have to have a lot of stages of effusion or something in order to do that. And that's usually a big thing that Google Earth can identify and say, hey, what's that thing there that wasn't there before? To make what's called weapons grade uranium, we need 90%. If you have 90% and you have 8 kilograms, you have a very dangerous thing. Why don't you figure out how many stages of effusion it would take to make a bomb? See, it's going to be a lot. And I'll just make a note that centrifuges, which is what the Iranians are using right now, are much more efficient than passive diffusion and diffusion technologies. So with a centrifuge, I put the gases in there and I just spin it like crazy and the U238 goes out more toward the edge and the U235 is more toward the middle. And then I suck up a column out of the middle and then I pump it over to another centrifuge, spin the 238 out, suck up the 235, keep going, keep going, keep going. And at the end it's pure U235. Yeah. Because you have to make it into a gas. If it's uranium metal it just will sit there like a lump. You could make it into any gas, but most metals don't make gases. It's very hard to make most metals make any kind of a gas. You can make nickel tetracharbonyl, you can make uranium hexafluoride. There are a few examples, but usually it's hard to get a metal atom to go into the gas phase. They like to be solid. Problem with a solid is nothing moves and so it doesn't effuse. It just sits there and you can't separate anything. And if you melt it into a liquid again you can't really separate anything. You need to get it into the gas phase in order to separate it. That's why you make it. Without 3% enrichment you just can't produce power. The uranium 235 is the one that produces the power by nuclear fission. U238 just sits there like wet newspaper. So if you want to light a campfire you've got to have some kindling and some matches and stuff that burns. And then if you have some plenty of stuff that burns you can have some wet newspaper hanging around. It won't put it out. If you have too much stuff that burns like a giant can of gasoline and you light it then it blows up. So that's why we bring it up to about 3% to generate power. Our own reactor here because we don't want to have so much uranium we make it higher percentage. 20% is called low enriched uranium. Low enriched uranium is not considered a hazard for anybody making a bomb because it's still too far away from 90%. No worse than ore. If you're a country and you're only interested in power and or research reactors then you can obtain fuel. We'll sell you the fuel. In fact we offered to sell the fuel to Iran and they refused. They said no we want to enrich to make our own fuel. The problem with building an enrichment plant is that you can keep going. And that's why we're a little bit suspicious about what their intentions might be. Okay we'll continue on next Tuesday.
UCI Chem 1B General Chemistry (Spring 2012) Lec 02. General Chemistry Intermolecular Forces -- Gases, Partial Pressures and Kinetic Theory Instructor: A.J. Shaka. Ph.D. Description: UCI Chem 1B is the second quarter of General Chemistry and covers the following topics: properties of gases, liquids, solids; changes of state; properties of solutions; stoichiometry; thermochemistry; and thermodynamics.
10.5446/19424 (DOI)
Good morning. Well, I am really happy today. So this is the first time that I've used electronic homework in one of the classes. And I was so happy when I looked this morning at 9 o'clock and found virtually everybody had engaged with the homework assignments. And so much of learning organic chemistry is actively working problems and actively trying to understand things. That I was really, really excited to see people are coming along with me on this process of learning and it makes me very, very happy. So today we're going to continue our discussion of Chapter 20. And I'd like to introduce organometallic reagents and talk about their reactions with carbonyl compounds and their reactions in general. And then we're going to talk about reactions of members of the carboxylic acid family with hydride nucleophiles and with organometallic reagents. And if there's time, we'll conclude by talking about use of these reagents and these reactions in synthesis. So when we were talking last time, we talked about hydride reagents with ketones and aldehydes. And we said sort of generically, if we have some ketone or aldehyde. Now I'll write it generically just showing our groups that could be alcohol, that could be aromatic, that could be hydrogen. So generically a ketone or aldehyde. And we envision its reaction with some hydride nucleophile. Now remember when I'm writing something like this H minus in quotes, of course there's no reagent that is itself a hydride nucleophile. But these are things like lithium aluminum hydride and sodium borohydride that serve as sources of hydride. And then if we carry out a workup with aqueous acid H3O plus or in some cases you can use water. And again I'll put this in quotes because you can't go and buy a bottle of H3O plus. You could take sulfuric acid and pour it into water to make hydronium ion and bisulfate ion. You could take HCl in water and make H3O plus and chloride ion. And so you'd go to the stock room and ask for one of those. When you do that you get a reduction of the ketone or aldehyde and protonation like so to give an alcohol. Now what I'd like to do at this point is to consider an analogous reaction again written at this point as an abstraction. So again we'll take our ketone or our aldehyde and we'll imagine instead of adding our hypothetical hydride anion we're going to add something that I'll say is R minus with a lone pair of electrons meaning a carbon based anion. We'll talk more about it. Not necessarily something you can get as a free anion and certainly not something that you could put in a bottle on its own. It would be part of an organometallic reagent but again right now we're getting our view from 30,000 feet. And again if you imagine some type of aqueous workup with H3O plus now instead of adding in hydride to our carbonyl compound we've added in in our group the use of primes and double primes and so forth is just my way of representing that there are various groups different or the same. Anyway but again in the view from 30,000 feet the profound thing about this reaction as I've written it is that we formed a carbon-carbon bond. In so much of organic chemistry both the practical aspects of synthesizing useful molecules and the real intellectual beauty of the discipline is the fact that we can create great degrees of complexity, valuable complexity, medicines, analogs of natural products, natural products that are too scarce to get otherwise, probes to probe reactions and probe biology. We can do all of this through chemical synthesis in which we take little molecules that might be able to be purchased and build them up into big and complex and useful molecules that can cure cancer or fight disease or teach us things. So now we come down to the issue of what is our R minus, what is our source of our carbon nucleophile? And the first really, really valuable carbon nucleophiles that were developed were Grignard reagents developed by Victor Grignard. He received the Nobel Prize in 1912 in chemistry for this. And the basic idea is that you take some halide, a bromide, a chloride or an iodide. Fluoride is sort of the odd ball among halogens and if you go down your periodic table to astatine it's not stable, it's radioactive so organic chemists would never work with it, you can't really isolate it. Anyway if we take an alkyl halide such as butyl bromide and we treat it with magnesium metal, if you've done one of these reactions in the laboratory you'll have seen your magnesium metal is kind of bright and shiny and lightweight, it comes as turnings that have been worked off a big block of magnesium with a lathe and you'll put them with your alkyl halide in a solvent. The solvent will be an ether solvent either ether or THF typically although sometimes other ethers can be used. THF is tetrahydrofuran, it's a cyclic ether so it's an ether with a five membered ring and it has lone pairs, it's kind of like diethyl ether with its ears pinned back and either of these work well, the result is that you get a grignard reagent. I started with butyl bromide here and so I'll write the grignard reagent from butyl bromide, we call this butyl magnesium bromide and the ether solvent coordinates to the magnesium, the magnesium doesn't have a complete octet here, we have only four electrons around it, two from the alkyl group and two from the bromide and so the ether solvent, the diethyl ether or tetrahydrofuran will coordinate to the magnesium and help give it the feeling of having a complete octet. Anyway, as I said the broader category of this is a grignard reagent. And you can make these from anything from bromo or chlorobenzene to alkyl bromides to methyl iodide and so this typically one makes the grignard reagent as part of a synthetic process. They're actually stable reagents, you can put them in a bottle, you can buy them but in the laboratory because they react with air and because they react with moisture you would typically go ahead and immediately add a carbonyl compound. So let me show you a typical synthetic carbon-carbon bond forming sequence that one might do in the laboratory. So we might take our butyl bromide and treat it first with magnesium and ether. Now, you'll often see people write a slash in an equation, often that slash is a way of saying the solvent is below the slash or if we're just writing a simple line of equation we might put our solvent below the arrow. Then let's add a carbonyl compound for the purposes of teaching, for the purposes of this example I'll take acetone as our carbonyl compound and finally let's do an aqueous work up and I'll give us, I'll choose an acid here, let's say aqueous HCl as the acid I would choose and the product of this reaction now is a carbon-carbon bond forming an adduct with a new carbon-carbon bond. You wanted to name the compound, we've now formed a six-carbon chain so it's two methyl, two hexanol as our product. So this is very powerful because now we've taken some small compounds that you can buy and we've made a more complex molecule that you might not be able to buy. Many molecules with this type of structure, these types of structures like alcohols with long chains on them are insect pheromones for example so some of these types of synthetic products are used to make traps for insects like Japanese beetles where the pheromone will lure the insect to the trap and then they'll fall in and die. So I want to talk a little bit about the properties of Grignard reagents and organometallic reagents in general. So metals of course are much more electropositive than carbon so any bond between a metal and carbon is either going to be a polar covalent bond or an ionic bond. If you want an index value or chemists like to keep electronegativity values in their head it's a useful way of assessing the degree of polarity of a bond. Magnesium has an electronegativity of 1.3, carbon about 2.5 or 2.55 so you can think of the bond between magnesium and carbon as a polar covalent bond. In other words you can think of this as having a delta minus a partial negative charge in carbon and a partial positive charge on oxygen, on magnesium. Because if you're writing a mechanism and you want to be quick about it you could say well I'll write a non-bonded resonance structure even though I know it's primarily a covalent bond I could write an ionic bond resonance structure so we could think of it as this. Maybe I'll put this in quotes here just to remind us this is sort of our thinking. And so if I'm thinking about this from a mechanistic point of view one way we could think about this I'll take our acetone and our Grignard reagent written generically. One way we could think about this is that our organometallic reagent serves as a nucleophile and of course we draw a curved arrow mechanism we help think about the flow of electrons and bonds by starting an arrow at the available electrons either as a lone pair or in a bond. And then moving to the thing that wants electrophiles in other words from the nucleophile to the electrophile as we did in thinking about hydride mechanisms we can't go ahead and now have five pairs of electrons around this carbon atom so concurrently as the nucleophile moves in electrons move up onto oxygen and so we continue our grammar if you will of writing our curved arrow mechanism now writing a product in which we have our negative charge and if I want to be good organic chemists are rarely good we love to throw away things that aren't necessary in our thinking but if I want to be good I'll draw the magnesium counter ion there. We can also think of this just as we did with lithium aluminum hydride maybe a little more correctly or certainly a little more sophisticatedly we can think of our covalent bond and keep in the back of our mind that it's a polar covalent bond and write a curved arrow mechanism in which we simply go ahead and now take the electrons from that bond move it in like so and again come out to the self same product. So these are good ways of thinking sound ways of thinking about the mechanism of the reaction. So one thing to keep in mind about Grignard reagents and indeed about most organometallic reagents particularly ones in which there's a large difference in electronegativity between the carbon and the metal is that organometallic reagents like Grignard reagents in general act as very strong bases. We can think about basicity in terms of the pKa of the conjugate anion. So if you have butyl magnesium bromide the conjugate anion corresponds to an alkane in other words where in the conjugate acid you have a CSP3 carbon bound to a hydrogen the pKa for such a hydrogen is about 50 that's about at the very end of the basicity scale that's about as basic as you can get for a carbon ion. If you have an alkene now you have a CSP2 carbon bound to a hydrogen the electrons are held a little more tightly in this type of structure. The pKa now is about 44 way of thinking of this is since the electrons are a little more stabilized held a little more tightly in an orbital that has more s character right. The sP2 has 33% s character, sp3 has 25% s character as you hold electrons more tightly the CH bond is more willing to give up H plus and give you a carbon ion. So an alkene is a little bit more acidic than an alkane. These are all compounds I call very weak acids and I usually put quotes around the acid because you would not get any evidence of acidity from the compound say dissolving it in water and testing it with a pH meter and yet in a Lewis acid Lewis base reaction you can think of an alkene say as a proton donor under certain circumstances. Now by the time you get to an alkyne now you've got 50% s character in your CH bond and now these are reasonably acidic. They're still very weak acids. Your pKa is only 25 that's really, really, really weak still. It's not even like water which you think about as an acid forming hydroxide anion. It's still a very weak acid or alcohol forming an acid giving up a proton and forming an alkoxide anion and yet our pKa is about 25 and I'll show you an implication of that in just a moment when we start to talk a little more about alkanes. But the point of this comes back to what I was saying before about carbon, about Grignard reagents being very reactive toward water. A Grignard reagent acts as a base with water and so if you expose a Grignard reagent like butyl magnesium bromide to water the water acts like a Lewis, acts like a Bronsted acid and you get butane and bromomagnetium hydroxide a mixed salt here. So this is a Bronsted acid, Bronsted base reaction if you think about it. We have water acting as an acid on the left half side of the equation. We have our alkane as an acid on the right side of the equation and because the pKa difference is so humongous the pKa of water is 15.7 the pKa of butane is about 50. I don't even bother to write an equilibrium arrow. The equilibrium constant is 10 to the 34th, right? It's 10 to the difference in pKa's. That reaction lies so far to the right that there's just no component to the left on it. And that's true with whether it's with water or an alcohol and so just by comparison imagine for a moment I wrote let's let me pick a particular alcohol. We'll pick ethanol as an alcohol and so now we would get butane and a ethoxy magnesium bromide and of course this would be the same with a carboxylic acid or just about anything that you would normally think about as even mildly acidic. All right well, Gouignard reagents are one of a broader family of organometallic reagents. Another member of the family that reacts very, very similarly are organolithium reagents. And so if we wrote Grignard reagents sort of generically as RMGX that would be a generic way of writing a Grignard reagent. We can write organolithium reagents generically as RLI. Organolithium reagents are formed by reacting alcohol or aryl halides. Again we're talking iodide, bromide, chloride with lithium metal. If I write a balanced equation say for bromobenzene and lithium it takes two lithiums and that makes sense if you think about it right we're carrying out a two electron process here and lithium has one electron so magnesium has two electrons and so a balanced equation becomes that we get phenolithium plus lithium bromide and again organic chemists are awfully, awfully bad about writing products of reaction so I'll put the lithium bromide in parentheses because I might not write it. So typically if I were writing this as say a synthetic reaction and I imagine generating an organolithium compound and say reacting it with an organic compound I'll give you an example of what I might write so I might take bromobenzene or I might take chlorobenzene if I wanted. Treat it with lithium metal. Now organolithium reagents can be generated in ethers and ether can serve to coordinate but they also form clusters and so they actually can be generated in other solvents including hydrocarbons. I'm just going to skip the solvent here because it's much less important than in a Grignard reaction and let's say as my partner since I gave you a ketone before I'll take an aldehyde the aldehyde I've chosen is pivaldehyde that's the trivial name or 2,2-dimethylpropanol would be the IUPAC name and again I'll imagine doing some type of aqueous workup. I'll just write H3O plus here to indicate I haven't specified the acid it could be aqueous HCl it could be aqueous sulfuric acid. One that I personally like to use in my own laboratory is aqueous ammonium chloride which is a very mild acid and very good for workups of reactions like this. Anyway, after our workup the product now has a new carbon-carbon bond like so. Of course because we've generated a stereocenter in the molecule we've generated it as a mixture of two enantiomers. We've generated two different enantiomers in equal amounts. We've generated the racemate. In part because your textbook mentions various different organometallic reagents at this point I want to follow along and in part because I want to remind you of what I think are really useful items and part because I want to tie into this concept of pKa. I'd like to at this point talk about acetylide ions. Can I see I have a question? Why doesn't the magnesium bond to the OH but instead bond to the O2? What's that? Oh, the question was why doesn't the magnesium bond to the OH? It doesn't, well there's no O8, oh you're saying in that reaction because the ethanol has now given up its proton to react with the butyl part so the proton has come off of the ethanol onto the carbon of the butane leaving an ethoxide anion which combines with the MgBr plus component. What was that? Did that look the same thing happened with water? And it did so we had in the case of ethanol we had etomgBr in the case of water we had HomgBr. So we had a very analogous reaction. Another question. In that second equation are we supposed to have a term with you? Ah, great question. In that second equation are we supposed to have two lithiums? This is very typical of how organic chemists will write a reaction. So typically you would see that one might not particularly as you became more used to writing reactions it might be implicit but indeed you would have two lithiums. So you could easily envision writing lithium parenthesis two equivalents or two lithium. And again this is very much part of the shorthand of writing organic reactions particularly when focused on synthesis. Good questions. So will organolethium reagents not be created if we don't have two lithiums? Ah, great question. Organolethium reagents not be created if you had only one lithium. Well now imagine you would what would happen would be you would have one mole of butyl lithium, one mole of butyl bromide, one mole of lithium you would get half a mole of butyl lithium. Now, here is where the fun comes in. If I let that sit at a low temperature and used it quickly I would have a reaction of one mole of butyl lithium, of one half mole of butyl lithium. But if I let it sit or tried to put it in a bottle and I now had that organolethium reagent sitting for a long time with more butyl bromide I would get E2 elimination or because the reagent is strongly basic to give butene and butane or I would end up having SN2 displacement to give octane or both. Great question. So yes, I would definitely use two equivalents. All right, well at this point I want to talk about acetylide anions and sort of follow along with our textbook but also because thematically it fits in. So as I said acetylene alkynes in general are especially acidic while there's still very, very weak acids, pKa of about 25. There's strong enough acids that very, very strong bases can pull off their proton. So for example if I treat an alkyne with sodiumid I get the sodium acetylide anion. Now sodium's a little more electropositive than lithium, lithium has an electronegativity of 1, sodium of 0.9. By the point you get to organosodium reagents they're pretty ionic in the bond so I generally think of these as ionic. So I have to do the NH2 or the NH4O. Great, NH2. NANH2 is sodiumid and if I'm going to balance my equation and as I said organic chemists are usually very bad about this. Ammonia, thank you, thanks very much. Ammonia is the other byproduct of reaction and now we see ourselves very much in the situation of a Bronsted acid, Bronsted base reaction. So we have pKa of about 25 and pKa of about 38 and so a difference of pKa means that equation lies way, way, way to the right, 10 to the 13th equilibrium constant are thereabouts. So basically I throw one mole of sodium amide, one mole of an alkyne and I get essentially all acetylide anion. And I'll write a balanced equation or I'll write a synthetic equation here in which I say take propyne. I treat it with sodiumid NANH2 which you can make by dissolving sodium metal in ammonia with a little bit of iron and it reacts to give sodium amide and for the heck of it, again I'm just trying to give us a range of carbonyl compounds. For the heck of it I'll take 2-butanone and then since I mentioned that I like aqueous ammonium chloride as a source of acid for a workup I'll just demonstrate what I would do in my own laboratory which is to use aqueous ammonium chloride and the product of this reaction is this. It is the alkyne with the alcohol. This is of course racemic. In other words, your textbook points out very nicely that you're going to add your nucleophile from both the front face and the back face of the carbonyl and so we have one enantiomer in which the OH is pointing back and the alkyne is pointing out. We have another enantiomer in which it's added from the back face and now the OH is pointing out and the alkyne is pointing back. We will get equal amounts of these, both of the R and of the S. Although this chapter is focusing primarily on carbonyl compounds, it's also beginning to introduce ideas of organic synthesis and carbon-carbon bond forming reactions. Your chapter reminds you that you've already seen certain carbon electrophiles. For example, you've already seen epoxides. There are lots and lots of types of electrophiles you can generate your compounds with that you can react your acetylides and other carbon nucleophiles with. I'll just point out one example here that brings out a couple of additional points. Butyl lithium is commercially available. It's a common source of a highly basic organometallic reagent that can be used not only as a nucleophile but also as a very strong base. Butyl lithium is a great reagent for pulling off moderately acidic protons. For example, protons from alkynes and also protons from amines like diisopropylamine, which you'll see later. Anyway, butyl lithium would react with our alkyne. Remember our pKa of the alkyne is about 25. Our pKa of butane is about 50. And so it would react again in an acid base reaction to give now an alkynolithium reagent. And so we can use this as well as a way of making anions. And I'll just give you one example or this as well as a way of making carbon-carbon bonds. So just to give you some diversity in your chemicals in the molecules that you see, I'll take say phenyl acetylene and we could envision treating it with butyl lithium. You'll often see butyl lithium written as N-buty. N means normal. Normal is just a fancy way of saying it's the regular, it's the one butyl lithium rather than say the lithium being at the two position of butane which is called sec butyl lithium or being on a tertiary butyl group which is called tert butyl lithium and is a stronger base. Anyway, let's envision using the common reagent N-butyl lithium treating our phenyl acetylene with it. That's going to give us our lithiated phenyl acetylene, our organolithium compound. And just to demonstrate the point of other reactivity, we can picture the reaction say with an epoxide and then again an aqueous workup H3O plus and the product of this reaction is an alcohol just as we've been generating in all of the reactions I've shown thus far. But what's interesting about this is now the alcohol instead of being connected directly to the carbon that had been or directly to the carbon where the nucleophile attacked, it's one over. You can think of this as R and the alkyne lithium reacting with the epoxide and so we're going to draw electrons flowing from the carbon lithium bond into the carbon oxygen bond pushing electrons onto oxygen and opening up our ring. All right, so what we've done at this point is we've really over viewed a basic, a fundamental reaction of carbonyl groups and we've introduced these compounds, these reagents that make for very, very strong nucleophiles, hydride nucleophiles like lithium aluminum hydride in particular to a lesser extent, less reactive sodium borohydride and then various organometallic reagents like Grignard reagents and organolithium reagents. At this point I want to sort of broaden out our thinking and start to talk not just about ketones and aldehydes but more broadly about the reactivity of the carboxylic acid family. And to just put this into context I mean carboxylic acids, essentially all compounds in which we have carbon in the plus three oxidation state. I will get to the several questions in just a moment. Esters being another member of this family, acid chlorides. So I'm going to paint with a very broad brush and later on we're going to get to a more specific understanding of the reactivity of this broad family. So right now I'm going to paint with a very broad brush. I'll include in the family acid and hydrides and maybe to wrap up in main members of the family I'll talk about amides. But before we discuss their reactions with organometallic reagents I saw several questions. I think there was one here, one there. Yes. I was wondering does that last reaction even come up where those lithium carbon bond for electron with the acid the apocyt. Does it have the same amount of acid in the bottom? Ah, great question. The question was when the lithium attacks the apoxide does it attack from the top or the bottom, does it occur with inversion of stereochemistry? And indeed it does although there is no stereochemistry at the center that we formed here you could imagine let's say having two different substituents here like a hydrogen and a deuterium and we would get inversion of stereochemistry. The epoxides are attacked by nucleophiles, by basic nucleophiles at the less sterically hindered carbon. So for example if I had the epoxide with a methyl group called propylene oxide, this one is trivially called ethylene oxide, if I had the epoxide with a methyl group on one side, propolythium, the alkyne would attack the carbon that didn't have the methyl group on it. Does that make sense to you? Another question I saw one young lady. Same question and? Why do we like to use butyl stuff so much? Why do we like to use butyl stuff? Great question. So all of our hydrocarbons ultimately come from petroleum. And so one of the ways in which butyl lithium is made is by first cracking, heating petroleum very hot to get smaller fragments. And one of the fragments that's easily isolated is butene. And the butene can then be taken on to various types of products including butyl bromide for example. So this is one of the reasons that butyl is used. You can buy propolythium but you can buy great big bottles of butyl lithium. Methyl is another common one. So does chemistry rely on fossil fuel? Does the chemistry rely on, oh I love that question. Almost all of organic chemistry ultimately goes back to petroleum. Some of the chemicals that we use as simpler building blocks come from other sources like carbohydrates and modern not ancient plant sources. But yeah almost all of organic chemistry comes back to petroleum. So the seeds that you're sitting in have a plastic that may be poly, I don't know, it's polypropylene or something and a covering that's a synthetic fabric like nylon. All of those have come from petroleum. And so I look at petroleum as much as I hate to pay $4.30 at the pump. When you think about the amount of stuff you're getting, you're getting a gallon of gasoline. This is too valuable to be burning up because there are so many things that you can make from it. But yet you can't get a gallon of anything. You can't get eight pounds or seven pounds of anything for four bucks. I can't get a gallon of beer for four bucks. And yet we go ahead and we burn it. So yes petroleum is incredibly valuable to organic chemists. And one of my dear colleagues' favorite questions, one that I won't be asking you on an exam because it's too open-ended and far too ridiculously complex for you at this point in your sophistication, is to go ahead and write a synthesis of a steroid, let's say cholesterol or testosterone. You've seen in your current chapter some steroids starting with petroleum. So that would be one of her favorite questions. All right, but I want to go now to the reactions of esters and of various members of the carboxylic acid family. And I thought your textbooks presentation, particularly in the reduction section, may have been a little bit confusing because there are a lot of subtleties. And when I think about a subject, I like to think about it in terms of sort of the general rule and then exceptions to it. And there are a ton of little exceptions. And your textbook has picked one and we're going to, they're talking about lithium aluminum hydride with amines and we'll talk about that later. But right now I want to paint with a very broad brush a sort of general reaction of lithium aluminum hydride. Under these strong nucleophiles, these potent nucleophiles, hydride sources, particularly lithium aluminum hydride, just reduces the crap out of everything. Alkyl lithium reagents like methyl lithium just add to everything as much as they can. Ditto for grignard reagents with certain exceptions. So again, a very broad brush, view from 30,000 feet, but we're going to take a specific reaction. We're going to take methyl benzoate here to exemplify our point. We're going to imagine treating it with lithium aluminum hydride. I'm deliberately writing this as a synthetic reaction. We'll talk about what's happening in a moment. And then an aqueous workup with, I'll just write generically H3O plus and you might do this reaction say in THF. And I'll be a good person and write a balanced equation or at least actually I won't write a balanced equation, but I will at least write my two organic products of the reaction. Your organic chemist is typically focused on the big stuff, but I'm going to write this product, benzal alcohol, and the other organic product, methyl alcohol, methanol. And collectively then these two constitute the organic products of reaction. And what this ends up illustrating is a new property that we haven't yet seen called an addition elimination reaction. And we're going to see that this addition elimination reaction goes through an intermediate of benzaldehyde. And to a certain extent, maybe with the exception of amides here, if I took any of the compounds that I'm erasing and treated them with lithium aluminum hydride, you would get a similar reaction of them. All right, so as I said, this is a big mouthful and I like to make big mouthfuls into bite size pieces. So let's think in sort of broad mechanistic terms here. All right, I'm going to think about, I'll write out our benzoate component, I'll write out our methylbenzoate, and I will at least for the moment try to be a good person and write a good mechanism in which I write lone pairs of electrons and try to keep track of my charges. And to keep things simple, I'm going to write, rather than writing out all of lithium aluminum hydride, I'm going to write hydride just as this abstraction of a hydride anion. And the first thing that hydride does is it's a good nucleophile, a potent nucleophile. We've talked about the reactivity in general of carbonyl groups. The carbonyl group is an electrophile. Electrons flow from the nucleophile to the electrophile and on to the oxygen. And I'll try to be a good person and write all of my lone pairs, all three lone pairs of electrons around the oxygen and then two on this other oxygen. Now this is not a stable species, this is not something that you can isolate. It's an intermediate. And so I'm going to remind us of the fact that it's an intermediate by drawing it in a bracket. We have a special name for this intermediate because we've gone from a trigonal carbon, a carbon with three things around it, to a tetrahedral carbon, a carbon with four things around it. I'm going to call it a tetrahedral intermediate. And as I said, the tetrahedral intermediate is in stable. The tetrahedral intermediate can break down. Electrons flow back down from the oxygen. They push out methoxide and now we get a new carbonyl. At this point we've gotten benzaldehyde, the intermediate that I mentioned, and methoxide anion with its three lone pairs of electrons on it. The reaction doesn't stop at this point. Esters are less electrophilic than aldehydes. In other words, aldehydes are more electrophilic than esters. We can write resonance structures for esters or a resonance structure in which the methoxy group donates electrons into the carbonyl and makes it less electrophilic. Electrophils, on the other hand, have less going for them. We have more nucleophile and you can't just stop at this point. It's going to further get reduced. Here's our aldehyde. Here's our H minus again. And again, I'll try to be a good person and put it in quotes. Electrophils flow from our hydride onto the oxygen nailed to give rise to an alkoxide anion. And at this point that's what will sit around in your flask. I haven't drawn the counter ions or anything until you do a workup. And I'll just write this as workup, meaning adding some acid or adding some water. I'll put this again in our 30,000 foot view of H plus. And the product of this reaction is benzal alcohol. And the other product of the reaction is we'll also protonate our methoxide. So the other product of our reaction is methanol. And I'll just put that in parenthesis here. All right, so I want to show you some generalities. I want to show you some analogy in this. And so at this point I'll write essentially the same reaction with just a slight difference on it. Before we could have been thinking about lithium aluminum hydride, I said let's consider lithium aluminum hydride. At this point let's consider methyl lithium. And so I'll take our same ester. I'll take methyl benzoate. But I'll treat it first with methyl lithium. And I'll write in parenthesis two equivalents. I'll try to remind us that we're using a full amount of it. And then secondly we'll treat this with some aqueous acid. And the product of this reaction now instead of adding in two hydrides instead of adding in two hydrogens, we've added in two methyls. That's essentially the exact same thing. And so now we've gotten an alcohol as our product in which we've added in two methyl groups. The reaction's going to go just like on the other one. We went via benzaldehyde. Here the reaction's going to go by way of the ketone called aceto phenone. But just as in the case of the other one, we can't stop at the ketone with one equivalent. Of methyl lithium. The ketone is more reactive than the ester. And so as it now is sitting around, it immediately reacts as well. And so that's our sort of view at 30,000 feet of the reaction of these very, very strong nucleophiles with members of the carboxylic acid family. As I said, there are some exceptions, some differences, but we can kind of catch this general spirit of this on the following equation. And so I'm going to write this. I don't always like the way your textbook presents things, particularly with a lot of abstractions. Because from my way of thinking, it's easier to start at the concrete and then work to the abstraction. For a computer, I think it's very good to start with an abstraction. And it can spit out all the examples. But we've just looked at two examples. So now I'm going to write the abstraction. And I'll say many members of the carboxylic acid family. And I'm going to write, again, this sort of abstraction of nu minus dot dot. So some type of strongly basic nucleophile that encompasses all of the reagents that we've been talking about. So I'll say strongly basic nucleophile that includes, for example, lithium aluminum hydride, RLI, organolithium reagents, RMGX. In other words, all of these species have in common that they have a bond between a metal, relatively electropositive metal, and a highly electronegative species hydride, or I'm sorry, a more electronegative species hydride, or lithium, or carbon. So basically, the generalities of this type of reaction are that in general, we get, and I'll write parenthesis Xs here just to avoid confusion. When you have Xs, in general, you're going to observe addition of two equivalents of your nucleophile, which I guess I've written as nu, plus z minus. So that would sort of be the biggest abstraction. And I guess I'll try to be good and keep my electrons in check, so I'll write a balance loan here. All right, so what we've looked at here is an addition elimination reaction. And we've seen this general principle that when you have something like a methoxy group on a member of the carboxylic acid family, the reaction doesn't stop. Things go on. Now to many students, the first time they see an addition elimination reaction, they find it confusing. And here's why they find it confusing. Here's our, let's say our ester. And we've just added a nucleophile to it, nu minus, to form our tetrahedral intermediate. And that tetrahedral intermediate isn't stable. It breaks down. It kicks out the OR group. In other words, our electrons flow like so to push out our OR group that serves as a leaving group. And the first time people see this, having already been through 51B and learned an SN2 displace, was it 51B or 51A, you learned SN2 displacement? A. 51A, and seen an SN2 displacement reaction, people start to think about this and say, whoa, what's going on here? We don't see an OR group like a methoxy group leave in an SN2 displacement reaction. But this is a little bit different. Here a less basic leaving group is okay. See, in an SN2 displacement reaction, you've got to crowd five things around carbon. You don't have a stable intermediate. That leaving group was perfectly happy attached to the carbon, and yet something's coming in and pushing it out. And it's going over this high energy barrier, this transition state, to make that atom leave. And so that atom that leaves has to really, really want the electrons. In other words, a good leaving group in an SN2 displacement reaction has to go ahead and have a very stabilized anion, or conversely, because stability of the anion means acidity of the conjugate base, conversely a strongly acidic conjugate base. So in this case, it's a little different, because there's nothing bad about the tetrahedral intermediate. We haven't had to crowd anyone in here. It's easy to get to this point, but now it can happily kick out the OR group, and what it gets in return is a carbon-oxygen pi bond, which is very strong. And so there's no problem in getting your tetrahedral intermediate together. It's not pentavalent. There's nothing bad about it. It's very good to go downhill and to break down and kick out the leaving group and get back your pi bond. So what I always like to think about here is in an SN2 displacement reaction, you've got to have a good leaving group. But in the case of this reaction, in addition to elimination reaction, a less basic leaving group is OK. And by comparison, I'd say maybe less than 5 pKa is good for a leaving group in an SN2 displacement or maybe even an E2 elimination. Thoughts or questions at this point? Doesn't it work like a substitution? Indeed. This is a substitution reaction. So the very first step of our methylithium plus methylbenzoate reaction was to substitute the methoxy group for a methyl group and get acetophenone. And then of course we couldn't stop at acetophenone because it's even more reactive than methylbenzoate, so another equivalent of methylithium adds. Indeed, it is a substitution reaction unlike an SN2 substitution reaction. Here you can have a leaving group that's a little bit less acidic like an alcohol or an alkoxide. If you added a water and acid, guess I'm not exactly following. You mean? Oh, you mean in the second step would we? Yes. So in the workup with acid, we would protonate. Indeed. And one more question. What does it mean by a leaving group has less than 5 pKa? OK. What do you mean? Great question. What do you mean by a leaving group has less than 5 pKa? In an SN2 displacement reaction, chloride, bromide, iodide are wonderful leaving groups, pKa of the conjugate acid respectively, about negative 6, whatever number you use, about negative 6 for HCl for the conjugate acid, about negative 8, or thereabouts for HBr, about negative 10 for HI. And you can go a little bit less good leaving group. I can write an equation, I can give you an example of a case where instead of having a very strong acid counter, you know, for the conjugate acid in an SN2 displacement, you could go slightly from negative, you know, negative 6 for chloride into the positive range. I could give you an example as low as 5 for the pKa. Beyond that in an SN2 displacement, it pretty much isn't going to occur unless, like in the case of an epoxide, you have ring strain. pKa of the conjugate acid in an epoxide is 17 for an alcohol, but you've got that roughly 30 kilocalories per mole ring strain associated with the oxirane ring making it pop open. So that's the rare case in an SN2 displacement like reaction where you can actually have what's essentially alkoxide as leaving group, but it's spring loaded. However, in the case of an addition elimination reaction, absolutely no problem kicking out methoxy group or ethoxy group pKa of the conjugate acid 17. Great question. All right. At this point, I want to move on to the final point that I want to make in today's lecture and to bring us to some ideas of synthesis and showing you how powerful organometallic reagents are in carbon-carbon bond forming reactions, but also the process by which organic chemists think about using these reagents and using reagents in general to build up molecules. And so I'm going to give you a little bit of a contrived example here, but it's very much like the type of thinking that people use as they become more sophisticated. Now the example I'm going to give us is to synthesize a particular compound. I've chosen it as an example to illustrate a point, but indeed something very much like it could say be a useful insect pheromone that you might want to make for a trap for say Japanese beetles. So we're going to try to develop a synthesis of 4-ethyl 4-octanol from compounds containing 4-carbon atoms or fewer. There's nothing magical about 4-carbon atoms, but many if you look at commercially available compounds in general most of them are small and you can buy a whole range of different compounds and more big and more complex compounds often are not as available. So you can buy many compounds containing 4-carbon atoms or 3-carbon atoms or 2 or 1. Of course you can buy plant-decontaining 5, but for purposes of this example we're going to say 4 or fewer. And what we're going to do with this is illustrate the way chemists think the process of retro-synthetic analysis and we can call this the process of thinking backwards about how to synthesize something. And the reason retro-synthetic analysis is so powerful, the reason that the process of thinking backwards is so powerful is it's so easy to get caught up in details when you try to look at things from a forward point of view that it's very hard to see how to get there from here, from compounds containing 4-carbons or fewer. Oh well, we're using organometallic reagents, do I use an organolithium, do I use a grignard, do I use an ester, do I use an acid chloride, do I use butylithium as a base, do I use methylithium. So retro-synthetic analysis is kind of like thinking your way through a chess game. We're going to start with big pictures and then work our way to the details. So let me show you how I would think about this particular example and you'll encounter on this week's discussion problems several examples very similar to this that involve processes of thinking backward at various levels of sophistication. Alright, so let me draw out my compound so it is, let's see, 1, 2, 3, 4, 5, 6, 7, 8. So here's my target molecule. Now when I first think about this, I could look at this and say, oh well, okay, he said 4 carbons are fewer and we just learned about addition of organometallic reagents to esters so I could envision adding, taking some ester would have to be a methyl ester of propanoic acid because that's 4 carbons, I couldn't use any more and I could envision forming this bond by adding in butylythium and maybe again for the point of view of view from 5,000 feet or 30,000 feet, I'm just going to think in abstractions of some metal whether it's a grignard or a lithium doesn't matter and again I could think, well here we add in some metal and that kind of catches the strategy but we've got a problem here and the problem is how do we get selectivity? I just said you can't really add one equivalent of a grignard reagent or an organolithium compound to an ester, it won't stop at the ketone. Is that your question? All right, so let me take this same idea and see if we can think backward a little bit. So we know, see here I'm trying to do it all at once and I kind of got myself going here, it's a lot better than saying we're going to think forward but let me think a little bit backwards. We know that an alcohol can be formed by a ketone and an organometallic reagent so we could imagine, so I'm going to use this arrow here, this arrow, this big open arrow means a retrosynthetic arrow, it means a thinking backwards arrow, organic chemists love arrows, curved arrows, equilibrium arrows, resonance arrows, this is a retrosynthetic arrow. So I could envision going ahead and going backward to this ketone and I could envision, let's see did I do that right? Nope, I could envision this ketone, two hexanone and a butyl metal reagent and that would work, I could add butyl lithium or butyl magnesium bromide to two hexanone and that would be okay to make that alcohol but then I'd need a way to make this ketone and oh, well okay, we could make that ketone, we've only learned reactions that form carbon-carbon bonds to make alcohols at this point in this course so I could imagine making that ketone by oxidation of the corresponding alcohol of three hexanol and again right now I'm not going to worry which reagent to use, whether I use chromium trioxide, whether I use potassium chromate, whatever but now I look and I say oh wait and I can think backwards again now to the point of a propyl metal reagent and propanol and at the strategic level we've now broken this molecule apart, we've used the process of thinking backwards to figure out how we can put this molecule together and now having completed our retro synthetic analysis now we're ready to go forward and worry from the strategy to the tactics of okay what reagent do we choose, how do we do our details and so the last thing I'll do in solving this hypothetical problem is to show you the synthesis that I've worked at. So I would start with propanol, I've completed the requirement with each of my three components of four carbons or fewer, I've started with propanol, propanol it's commercially available, it fits the requirement, I'll add in just for the fun of it I'll use propyl magnesium chloride, I could use propyl lithium, I could use propyl magnesium bromide, propyl magnesium iodide, I'll carry out my workup with aqueous HCl, I could use aqueous sulfuric acid, I could use aqueous ammonium chloride, I could probably be lazy and write H3O plus over the arrow but I'm going to go to the stock room and get some chemicals and I'm going to ask them for some HCl. The product of that reaction after workup is 3-hexanol, I now am ready to oxidize my 3-hexanol, you learn lots of reactions last quarter for oxidation, they taught you potassium dichromate in sulfuric acid and water sometimes called Jones reagent, there are many, many reagents based on chromium 6, sodium dichromate, chromium trioxide, there are lots of safer alternatives including alternatives based on bleach but we're going to use reactions that you know so we're going to use potassium dichromate, then at that point we have our 2-hexanone and question. Absolutely, we could use chromium trioxide as an oxidizing agent, lots to choose from, nice in our retro synthetic analysis, not having to worry about getting that right yet and now having the leisure of going and choosing our reagents and choosing our tactics. Finally, to complete our synthesis I'm going to take butylythium and I'll do an aqueous workup and again I'll use HCl, I've written it below the arrow here, written it above the arrow there, doesn't really matter, chemist is going to read it the same way and low and behold I have proposed a rational and selective synthesis of our target molecule for ethyl for octanol and this art of recognizing something in a molecule and seeing where it comes from is going to grow and grow in the course. Right now we've seen an alcohol and we said oh I know how to make an alcohol, I can make an alcohol by adding in two carbon nucleophiles, I can make alcohols by adding in carbon nucleophiles, later on we're going to see all sorts of other families of carbonyl compounds. I will see you on Thursday, we'll start off with a ten minute quiz.
UCI Chem 51C Organic Chemistry (Spring 2012) Lec 03. Organic Chemistry -- Reactions of Organometallic Reagents -- Instructor: James S. Nowick, Ph.D. This is the third quarter course in the organic chemistry series. Topics covered include: Fundamental concepts relating to carbon compounds with emphasis on structural theory and the nature of chemical bonding, stereochemistry, reaction mechanisms, and spectroscopic, physical, and chemical properties of the principal classes of carbon compounds. Organic Chemistry 51C is part of OpenChem. Index of Topics: -1:36 Ketone/Aldehyde Reduction -5:56 Grignard Reagents -12:31 Polarity of Grignard Reagent -16:01 Basicity of Grignard Reagent -19:22 Grignard Reagents and Water/Alcohol -21:32 Organolithium Reagent -25:50 Acetylide Anions -34:07 Making Acetylide Anion -38:29 Reactivity of the Carboxylic Acid Family -44:56 Addition-Elimination Reaction -48:12 Examples of Carboxylic Acid Reduction -53:29 Multiple Additions onto Carboxylic Acids -59:50 Leaving Groups -1:08:27 Synthesizing Example -1:16:54 More Examples of Synthesizing
10.5446/19423 (DOI)
Good morning. Good morning. Oh, this feels good today. This feels like we are at the end of a very long journey, and we've learned so much. And I wanted to start by thanking you for coming along with me on this journey. So today I want to talk about organometallic reactions in organic synthesis. And you know, we get to the end of the course. We've gone through this wonderful carbonyl chemistry, which is sort of the core of synthetic organic chemistry. It's logical. We've learned these beautiful ways of looking at molecules and recognizing various functionality, recognizing beta hydroxy carbonyls and alpha beta unsaturated carbonyls and seeing this beauty of putting molecules together. And we've seen how these types of synthetic reactions, like the Robinson annulation, can be used to build up the types of structures that are in steroids and all sorts of medicines. We've gotten a little bit of a taste of some of the chemistry of amines and some of the chemistry that can give rise to alkaloids and bioactive nitrogen containing compounds. And now I want to come back to synthesis. So we spent a little time talking about sort of natural biomolecule sugars, which brought us in a beautiful refrain on stereochemistry and molecular conformation. Polypeptides, which showed us just a hint, just a taste of not only the structures of biologically important peptides and proteins, but also just a taste of how chemists can build up molecules, even as big as HIV1 protease containing 99 amino acids. And one of my laments in teaching sophomore organic chemistry when I started teaching a sophomore class 20 years ago was there's all this beautiful contemporary chemistry that's going on that really is excluded from the curriculum. And your textbook does a wonderful job of bringing back one facet of this contemporary chemistry. That is the use of organometallic reagents and reactions in synthesis. Realize that the field of organic chemistry is a dynamic field. This is not something that's static. This is not a frozen body of knowledge. This is something that researchers like Johnny and Kim continue to develop new ideas, new reactions, new molecules, and dissolve, unsolved problems. And synthesis is about problems because there is a real need to build molecules. And we've gotten a hint of sort of old style organometallic chemistry. We've seen Grignard reagents and organolithium reagents. We've seen how powerful these are as nucleophiles. And now we're going to see different ways of putting molecules together that in some cases are less, I'll say logical in the sense they don't necessarily exploit natural reactivity in the same way, but they can stitch together what might be non-obvious bonds. So let me start by just mentioning a Grignard reagent here and a Grignard reaction just to take us back. And so if you have an alkohalide, we learn that if you treat it with magnesium metal, usually an ethereal solvent, diethyl ether or tetrahydrofuran, the magnesium reacts. It sticks itself into this carbon-alcohol bond. In the process it's actually going from magnesium metal oxidation state zero to an alkyl magnesium halide where the magnesium has an oxidation state of two. And we're going to come back to that refrain. But right now I want to focus on a traditional organometallic reaction. So if you take some carbonyl compound to ketone or an aldehyde, I'll write it sort of generically as this. It could be acetone. It could be an aldehyde. It could be any other ketone. And then we carry out an aqueous workup. Usually with acid you could use water too if you really wanted to. I think your textbook typically writes it. But something to add a proton to the oxyanion that forms. You formed a new carbon-carbon bond. And if I had to characterize this chemistry I'd say that the Grignard reagent or other organometallic reagent like an organolithium reagent, so I'll put it sort of more general as organometallic reagent acts as a nucleophile for carbon-carbon bond formation. And this is very powerful because building up organic molecules really is a large part of what synthesis is about. Building key carbon-carbon bonds, controlling stereochemistry, controlling regiochemistry, manipulating functional groups as you need them, taking for example a secondary alcohol to a ketone as you needed or taking a ketone to an alcohol or reducing a ketone or an alcohol down to a hydrocarbon. These are all sort of standard transformations and a lot of the main processes that drive the building that sort of are layered on top of this are the carbon-carbon bond forming reactions. Well, I want to introduce now a different concept and I'll introduce it in such a general way that I think it really is more a statement of philosophy at this point than a particular reaction. But imagine for a moment we had something a little bit different. Instead of transferring your nucleophile, your R group, your R minus if you will, to the electrophile directly, in other words just having the metal as something that makes it so you effectively have a carbon ion. Imagine for a moment now you have two R groups on a metal and this is characteristic of the chemistry of transition metals. Really palladium is sort of the archetype of this although we'll see it with copper. And then imagine that we spit out a carbon-carbon bond and so I'll go like this and I'll put parenthesis plus getting your metal back in some form. So this is a little bit different if you think about it in the sense that it's not transferring. The metal is doing something different than acting as a nucleophile or transferring an alkyl group. You could say that the organometallic complex, so this is an organometallic complex because you have metals bonded to or alkyl groups, organic groups bonded to a metal. You could say that the organometallic complex acts sort of like as a template to bring the two R groups together. I'll say it can act as a template for CC bond formation. And in a way this is no reaction in particular. We'll come to particulars and I'll really focus a little bit more on mechanism when we see the Suzuki reaction but this is kind of a concept or a theme. And one thing you'll notice is the idea of a metal acting as a template really ends up being about the metal taking itself out of the two R groups and leaving a bond. And if you notice in a way this is the opposite of this step over here where the magnesium is sticking itself into a bond. And as we approach this chemistry we're going to see two reactions that are the opposite of each other. Oxidative addition which is a metal sticking itself into a bond much like we see with the magnesium here as I said increasing oxidation state from zero to two and then the metal taking itself out of a bond which we call reductive elimination. I'll get on to that more in a little bit. So when I put this lecture together I wasn't sure how much I'd have a chance to cover and initially I figured we might get to cover section 26.3 but I've cut that out. Honestly I want you to get the flavor of some modern chemistry not all of the details. Your chapter starts with some really old organometallic chemistry, organo-couprate chemistry so I'm going to talk about that. We'll talk about organo-couprate reactions and then I want to talk about two Nobel Prize winning reactions. The Suzuki reaction which we do in my advanced laboratory class it's a beautiful reaction and a powerful reaction and the Grubbs or well what's technically olefin metathesis although its name is often associated with Grubbs. The textbook in section 26.3 also talks about the Heck reaction which is a little more conceptually complicated and I decided to drop it out. I didn't want to flood us. I wanted to give us a taste not an entire meal here. Let's start talking about organo-copper reagents. Now we've got a tiny little taste of organo-copper reagents back in chapter 20 and I think that's one reason it's nice to see them again. So we learned and this is I'll just write what I wrote in chapter 20. We learned that we could form organo-copper reagents from reacting an organolithium compound with a cuprous salt. Copper iodide is the salt. Cuprous iodide, copper 1 iodide is the salt you learned about in your textbook and it's fine. So two equivalents of an alkolithium plus cuprous iodide CUI gives you R2CULI plus if you want to balance your equation lithium iodide as I've mentioned many a time organic chemists are bad about writing this all. I'll write plus to show it's both of them. We call this an organo-copper reagent and if I wanted to write the structure of this you could think of it as two R groups on copper with a negative charge on it. Kind of the same theme as I talked about there and you'll see how that theme comes in in the chemistry that I'm about to introduce. Lithium is the counter ion. We call this an 8, a cuprate because when you have a negative charge on a species you call it an 8. So this is a cuprate because you have a copper minus charge on it. And so some of the chemistry we learned about cuprates was we learned they could modulate the reactivity in 1, 4 versus 1, 2 additions. So we learned for example that if you had cyclohexenone if you treat it with say methylithium the methylithium adds to the carbonyl group to give an alcohol at this position. If we treat our cyclohexenone however with lithium dimethyl cuprate CH3 2 CULI so the organo-copper reagent you would get from adding methylithium to cuprous iodide and then you carry out naquious workup. I'll just write H3O plus usually a person would throw dilute acid in. What's really special about the cuprate is that instead of getting 1, 2 addition instead of adding directly to the carbonyl group we get conjugate addition, we get a Michael addition reaction and after workup your product of the reaction is the 3-methyl cyclohexenone. And so already that brought in the concept that copper had special reactivity and it brought in this concept of control. And we see the concept of control with copper in other places as well for example. So again in chapter 20 I introduced another reaction, a special reaction of acid chlorides. See normally if you take an acid chloride or you take an ester with a metal organometallic reagent like an organolithium reagent or a grignard reagent you can't control the reactivity. If I take an acid chloride like benzo-wheel chloride and I try to add one equivalent of methylithium to it to get aceto phenone or one equivalent of methyl magnesium bromide it doesn't work because the resulting ketone is still very, very reactive and so you get reaction to get a second equivalent of methylithium to give 2 phenol 2 propanol and you get other reactions. Same thing with an ester here, very hard to control the reaction to add just one equivalent of nucleophile but we learned a special reaction of cuprate so if I take lithium dimethyl and cuprate I'll write again 1 CH3 2 CULI and then we carry out an aqueous workup. What's beautiful about the cuprate chemistry is that we go ahead and we get a controlled single addition to give aceto phenone and so that gave us a new manifold of control. People have known about copper chemistry for a long time. Organo copper reactions have been investigated since well before World War II where copper was discovered to modulate the reactions of grignard reagents in some of the fashions that we've seen here. What I want to do now is to exploit or discuss another carbon-carbon bond forming reaction that was developed later, I think the 60s that gives us something that's less recognizable in terms of conventional nucleophile electrophile chemistry. In conventional nucleophile electrophile chemistry you can at least in your mind's eyes say well I can see the carbonyl is an electrophile, the organo-cuprate is a nucleophile, I can see putting them together. In the conjugate addition, in the Michael addition reaction you can also the 1,4 addition reaction. You can also say okay we learned that an enone was electrophilic at the beta position as well as the carbonyl position. I can understand putting them together. But now I want to show you another reaction. Now I'm going to draw it in a super analogous fashion so you see what's weird about this. All right so imagine for a moment that instead of taking benzoyl chloride I take 1 chlorostyrine and I subject it to the same reaction conditions. And dimethyl cuprate followed by some sort of aqueous workup with acid. Now you'd look at this if this were a Grignard reagent and you'd say well you know vinyl chlorides aren't electrophiles. We know that while we sometimes can have SN2 displacement by organometallic reagents in the conventional SN2 reaction for an example and a sodium acetylide salt reacting with methyl iodide to get alkylated we know that sp2 hybridized carbons don't participate in SN2 type reactions. And yet something very much akin to what I've written on your left hand blackboard occurs on your right hand blackboard here. Your cuprate reaction, your cuprate reagent does indeed react to form a carbon-carbon bond and that's special and that's weird. I'll write my aqueous workup in parenthesis. Your textbook doesn't include it. Honestly most people would do it to hydrolyze the copper salts but unlike say a reaction where you're generating an enolate as in the first case up on top where it's absolutely essential here an aqueous workup isn't essential. So you know you could say I don't care if I write it too much. Alright so what's happening here? Well I've been hinting at this notion that metals can act as a template so in sort of a general sense we're having some sort of halide. This can be an alkyl halide. It can be an aryl halide. It can be a vinyl halide and we're having some type of cuprate reagent. So I'll write this like so and what we're doing is we're forming a carbon-carbon bond. So as I said this is interesting because we're talking about alcohol, primary or secondary or sometimes secondary. I'll say primary, methyl or sometimes secondary for our halide but also vinyl and aryl in other words a benzene ring. In other words we're doing a reaction not only at things where you might expect the conventional SN2 displacement but also a lot of compounds like this vinyl chloride compound where you wouldn't expect a conventional SN2 displacement reaction. So I'm going to say not SN2. Alright so what's special in this chemistry? What's special in this chemistry is that the copper is mediating the reaction. The copper is facilitating the reaction and I'm not going to go into a detailed mechanism. I'll give you a mechanism for the Suzuki reaction but I want to show you the gist of it. So the gist of it is that copper acts as a template that in addition to having the two methyl groups around the copper like so during the reaction the copper also attaches itself to the vinyl group basically just like magnesium sticks itself into the copper into the alcohol carbon bond informing a grignard reagent. The intermediate here which I'll draw as such maybe I'll put it in a bracket just to remind us that this is not a stable compound that this is only an intermediate. This intermediate forms and what it does now is the copper serves as a template for formation of a bond between the methyl and vinyl group. The copper brings those two together very much like that sort of generalized reaction I wrote in the very beginning. Now as I said this chemistry can occur not just with typical sort of SN1 like alkyl halides but also with things that would or SN2 like alkyl halides but also with things that would never, never, never participate in an SN2 reaction. And so one of the features with vinyl halides is that the reaction is stereospecific. In other words, stereochemistry is retained about the bond of alkyl halides. The example I gave you has no stereochemistry to the double bond but of course double bond come in flavors cis and trans when you have two different groups on the ends of them or two groups on the end one on one end and one on the other. So if I, we imagine for a moment that we instead of having the halogen at the one position have the halogen at the two position and I'll just, just for the heck of it make it a bromide and again imagine that we subject this to a cuprate reagent just to show you some of the diversity of cuprate reagents. Let me give you a vinyl cuprate reagent. So I'll give you divinyl cuprate. So two vinyl groups bound to a copper and then a workup H3O plus. Now what's interesting about this is we started with the trans stereochemistry about this bond. We're going to transfer this vinyl group over to this bond and we retain the stereochemistry. In other words, the product, we started with trans and we've ended up with trans and that's kind of cool and that's kind of, kind of significant. So we're still trans and conversely if I started with the cis alkene and subjected it to the same reaction conditions, I'll just put a ditto mark here for the sake of saving space. Now we would get the other stereochemistry. In other words, the stereochemistry of the alkenyl halide has dictated the stereochemistry of the product. Here were trans or E. Here were cis or Z. Yeah. All right, I kind of want to at this point summarize the cuprate chemistry and I'll just go ahead and since we see a lot of chemicals, a lot of different compounds, I want to just show you maybe what a researcher would do in the laboratory. So let's say for a moment that the goal was to synthesize this compound. These types of vinyl compounds with stereochemistry about double bonds are present in insect pheromones. You can make chemical compounds that will lure and trap bugs by synthesizing their pheromones. These are used to kill Japanese beetles and other sorts of tests. And so let's just take a look at what a person would do in the laboratory. So they'd want to make a cuprate reagent so they'd take a halide like a vinyl halide and they'd treat it with lithium metal. Remember two equivalents of lithium metal is required to react with a halide to give an organolethium reagent. So I would get vinyl lithium plus lithium bromide if I wanted to balance my equation. In a second step, I would add cuprous iodide. And if I wanted to balance my equation, which as I said organic chemists often don't do, we would take two equivalents of lithium iodide and we'd treat it with cuprous iodide to get the cuprate reagent. And the final step, you would typically do this all in one flask. You would make the lithium reagent. You would add the copper iodide to make the cuprous, the organo-cuprate reagent. And now in the final step, we would take our styrenal bromide and treat it with our cuprate reagent. Maybe do an aqueous workup on that. I'll just put that in parenthesis here to get our product. Thoughts or questions? One thing that's bad about cuprate chemistry is of the two vinyl groups on the copper, the two R groups on the copper, you only transfer one of them. So it's wasteful as far as the two R groups on the copper. So it's wasteful as far as the chemistry goes. You waste half of your vinyl bromide in this chemistry. Another thing that's bad about the copper chemistry is copper is a toxic metal and it's expensive. If you're making medicinal compounds, you don't want any metals to be left and you certainly don't want metals sticking in that are toxic. So one of the things that chemists have been trying to do is to make chemistry more efficient, make it go by use of one equivalent of reagent rather than having to use two equivalents of reagent to avoid the use of toxic metals and to avoid having to use a whole equivalent of a metal that's expensive or that's poisonous. And to just have that metal template act as a catalyst. As I said, cuprate chemistry was really developed in the 1960s and it's sort of old organometallic chemistry. And so I want to fast forward us ahead now through what's a really a modern organic chemical reaction, the Suzuki reaction, a modern organometallic reaction that largely achieves the same transformation. The big innovation of the Suzuki reaction, well one of the big innovations of the Suzuki reaction was instead of using an organolithium compound as a metal was to use an organoboron compound as a metal. We've already seen that organoboron compounds are very easy to access. You can access them by hydroboration. You use them all the time in hydroboration oxidation chemistry. Boron is environmentally benign. It's not toxic. Or boric acid, for example, can be bought in the drug store to use as an eye wash. It's not a harmful or poisonous chemical unless you're a cockroach, in which case it's very good for killing them. All right. So the gist of the Suzuki reaction, the other big innovation was to use a catalyst rather than a whole equivalent of metal. So we're going to take something that looks very similar. We're going to take a halide. Often we're talking a vinyl or an aryl halide. In some cases it can be an alkyl halide, one of the active areas of research is making the Suzuki reaction more compatible with more different types of compounds. We're going to combine it with an organoboron compound. And typically the boron has a couple of oxygens on it. I'll call these OR prime groups. We're not going to get into all the details. I'll show you one later on. This is an organoboron compound that's called the boronic ester or boronic acid depending on whether there are alkyl groups or OH groups. So the last piece of the puzzle is a palladium catalyst. Now when people write organometallic reagents or organometallic, I should say reactions, often they want to focus on the big picture. We're going to see that as we work our way through the mechanism. And often there are variations that don't matter a whole lot. So I'm going to write this for now as L sub N M, or perhaps I guess since we're only focusing on the Suzuki reaction, which is always done with palladium. I'll write L sub N P D. And I'll just refer to this for now. I'll give you an example of one in a moment. But I'll refer to this right now as a palladium catalyst. And so the big idea of the Suzuki reaction is that we're going to use the palladium catalyst as a template to combine the R group on the boron with the R group on the halide. And the overall result is we're going to form a new carbon carbon bond very efficiently. In my synthetic organic laboratory class that students take in their junior or senior year, we do a Suzuki reaction. It's a cool reaction. They really enjoy it. And the reaction they do is to take a bromostyrine that's been prepared for them by the teaching assistant in a stereospecific fashion through an elimination reaction. It's prepared by bromination of ceramic acid followed by elimination. And they combine it with an organoboron reagent that they prepare themselves also in a stereospecific fashion by hydroboration with a boron that has a boronic ester that has a benzene group over here. This is called a cataclylborane. And the palladium catalyst that they use, well, I'm going to give you a variant of the catalyst. We use a palladium 2 catalyst, but I'm going to give you a palladium 0 catalyst. Basically, I wanted to simplify some of the, doesn't matter a whole heck of a lot which palladium catalyst to use. And I wanted to simplify things a little bit and sort of align them with your textbook. And so the palladium catalyst that we'll use in this particular example is tetrakis triphenylphosphine palladium. Those triphenylphosphines are ligands on the palladium. They represent the ligands shown over here. Again, we're going to skip over some of the details. When the catalyst is resting, there are four triphenylphosphine ligands around it. When it's doing its thing of bringing the metals together, there are two triphenylphosphines around it. But that isn't so important. We also need a base in this chemistry. And this is typical of the Suzuki reaction. I've sort of written things in a general form here, in an unbalanced equation. And the product of this Suzuki reaction is now just forming a new carbon-carbon bond. So we have the half that came from the alkenyl halide and the half that came from our organoboron reagent with our double bond and our C4H9 group, our butyl group, over there. So this is 1Z3E1 phenyl 1-3-octadiene, if you want to know the name. I'll write a balanced equation, and we'll talk a little bit about how the components form. The other components, the byproducts, if you will, the waste products of the reaction, are the boronic ester now with an ethyl group. So technically, it's a boric acid derivative or a boric acid triester derivative. And the other product of reaction is sodium bromide. And just to remind us that we're using only a little bit, only a couple of mole percent of palladium, only about one mole of palladium for 50 moles of molecule, I'll write that this is a catalyst here. So I will just remind us of that by writing CAT, kind of an abbreviation there. What's cool about this chemistry is it brings us to new types of reaction mechanisms. So it's cool because it's useful. We can readily snap together two halves to make a big molecule, and in a way that you really haven't seen before. That's powerful. But another thing that's cool about the chemistry is that it brings in some reaction mechanisms that you haven't seen before and yet have some familiar themes. So I want to break the mechanism down into three main steps. There's also one minor step that I'll insert when I show you the mechanism in detail. So I'll say three main steps in the mechanism. The first step is called oxidative addition. In oxidative addition, the metal sticks itself into the alkenol halide bond, into the carbon halide bond. The second main step is transmetallation. In the transmetallation step, the other alkenol group is transferred from boron to the metal. Transmetallation, it kind of makes sense. It almost says that. And the third one, the third step, is where the metal acts as a template. And that's called reductive elimination. The metal spits out the carbon-carbon bond. And as I hinted, even though you haven't seen organopiladium chemistry, there's a lot of analogy to chemistry that you've seen. And that's really what I want to focus on, because I think that bodies some of the beauty of this very powerful chemistry. So as I was hinting, the palladium can go ahead and lose a couple of those triphenylphosphine ligands. And so the active carrying catalyst is not the tetra-kiss triphenylphosphine palladium 0, but the bis-triphenylphosphine palladium 0. It's just a ligand dissociation reaction. But don't worry about it. But this then is the, I'll say, the active form of catalyst. And technically, that's going to be the species, as we write the mechanism that we're going to focus on. All right. So this active form of the catalyst can react with the alkenyl halide. So there's our bromostyrine. And as I said, the reaction is called oxidative addition. In an oxidative addition reaction, a metal sticks itself into a bond and increases its oxidation state by 2. We have the carbon bromine bond. We have the palladium. The palladium happens to have a 0 oxidation state at this point. When the palladium sticks itself into the carbon bromine bond, it increases its oxidation state to palladium in the plus 2 oxidation state. I've got to write that a little bit neater. I'm not doing a good job at being neat here. All right, so we have two triphenylphosphines, pH3P2, palladium. Now the palladium has the alkenyl group bond bound to it and the halide group bond bound to it. And even though this reaction involves palladium, even though you haven't seen organopalladium reactions before, this reaction is just like the formation of a Grignard reagent. In a Grignard reagent, magnesium starts at oxidation state 0. You add into the alkyl halide bond. Now you have the alkyl group and the halide group bound to the magnesium and the magnesiums at the 2 oxidation state. Even the notion of ligands isn't very different. When we talked about Grignard reagents, we said you have to form them in an ether solvent because the magnesium needs those ether oxygens as ligands on it. Well, palladium likes ligands that have more diffuse lone pairs and can participate in other types of interactions, pi back bonding interactions. And so as a result, you have phosphorus as a ligand rather than oxygen. All right, that's the oxidative addition step. So here I'm going to again write our organopalladium intermediate. And now a step occurs that's not super important as far as this mechanism goes, but it's facilitating the transfer to the boron. We have sodium ethoxide as a base. In other words, in terms of the big concepts, it's not as much of an issue of this templating process. It's more of a mechanistic detail. A ligand exchange reaction occurs. That means ethoxide does basically what you could think of as an SN2 displacement and kicks out bromide. I'll write this on the next line because these structures are pretty big. So we're going to just replace the bromine with an ethoxy group. And if I wanted to balance the equation, I suppose I'd say that sodium bromide is also a byproduct of this reaction. Okay, now the next main reaction, the transmetallation reaction. And so at this point, we're going to transfer that R group from boron onto the palladium. In a way, it's like another one of these SN2 displacements sort of like reactions I talked about. Okay, so here's our palladium species in the cycle. And here's our organoboron compound, our boronic ester. And our structures are so big that I'm going to now move to the other blackboard. So I'll draw an arrow, and we'll continue our arrow over on the next board. Okay, maybe I will give a name here. As I said, our step is transmetallation. So I'm going to write TRA and SMETALLATION. We're going to transfer the ligand from the boron, which acts like a metal to the palladium. So we still have our styrenal group on the palladium. And now what we've done is transfer our alkenal group from the boron to the palladium. And again, if I'm going to balance my equation, the byproduct of this reaction, the ethoxy group comes off the palladium and onto the boron. Boron really likes to be bound to oxygen because boron has a vacant p-orbital. Any atom that has lone pairs on it is a friend of boron because those lone pairs donate into the boron. And so this ends up the ethoxy group that we transferred before in the ligand exchange reaction ends up facilitating the transmetallation reaction. The final step is the reductive elimination step, the step in which the metal is acting as a template. And so we have our species here, pH3PPD styrenal with our alkene group. And now in the reductive elimination, it's the mechanistic reverse of the oxidative addition. As I've been hinting at again and again in our talk with the copper and other things, now we're going to take the palladium out and form a bond between these two carbon groups. And the overall result then is going to be our, I should write it a little lower so that you can see it well. Now we're going to have our alkene, our diene, our 1Z, our 1E3, our 1Z3E1 phenyl octadiene. And we get back our palladium catalyst and it's dropped to the zero oxidation state. And this is really of course the hallmark of a catalyst. The catalyst goes through the reaction again and again and again so the catalyst is available now to react with another molecule of alkenyl halide to have another ligand exchange occur, to have another transmetallation occur, and finally to undergo reductive elimination again and again and again dozens and even hundreds of times in the catalytic cycle. So let's take a look at how we might use this Suzuki reaction in organic synthesis. And I'll just pose a sort of a sample question here. Let's say I was thinking about how we synthesize this molecule. And I'll say let's synthesize this molecule where we have a methoxy on a benzene linked in a meta fashion to a transalkenol group connected to a C5H11, a pentenol group. So let's say synthesize this compound from compounds containing seven carbon atoms or fewer. And if you look at this, of course I've deliberately kept this kind of analogous because you're just beginning to learn this chemistry, but you might look and say, oh, okay, this doesn't look that different. In other words, we kind of could see how this piece could come from an organoboron compound and this piece could come from a halide and it would all be chemistry that we know. So if I draw my retro synthetic arrow downward and think about things going backwards, I could say, imagine that we formed this bond over here. And imagine we did so breaking the molecule into two convenient halves, each of which had half the molecule. So I could have three bromomethoxybenzene as one half and I could have a boronic ester as the other half. Like so, and I could bring these two halves together so I guess I'll put a plus sign and say, oh, I could see how I could do that by a Suzuki reaction. And then you might say, well, look, he said seven carbon atoms or fewer. And I know we've got too many here because I've got six carbon atoms on this boron piece and seven carbon atoms here. But we've learned the hydroboration reaction. We've learned that it's stereospecific. And so you'd say, I could imagine forming this bond here by hydroboration and we could think backwards some more and say, okay, if I hydroborated one heptine and reacted it with catechol-barane, I already have hinted that that's a readily available organoboron compound. It also conveniently contains fewer than seven carbon atoms. Now I could imagine hydroborating heptine in a stereospecific fashion to give us the trans compound combining it with my bromoyaromatic in a Suzuki reaction. And I could put this all together in a forward sense. So in a forward sense sort of solving our synthetic problem, I'll start with heptine, hydroborate it with catechol-barane. You just mix them together, heat them typically if you really want to make the reaction go quicker. That gives us our C5H11 alkenol-barane. Like so. Then I could imagine combining that boron compound with the catechol-barane and our bromomethoxybenzene, which we won't talk about how to make. But fortunately I've given you a chemical supply house that provides chemicals up to seven carbons. You know how to make it from your amine chapter, but you don't need to because I've given us a nice chemical supply house and we'll take our tetra-kiss triphenylphosphine palladium catalyst. And sodium, I'll write that it's a catalyst over here just to remind us we're only using a little bit in a full equivalent of sodium ethoxide. And the overall result now is that we've synthesized our target molecule. And because of the power of this chemistry, in 2010 Suzuki won the Nobel Prize for this along with Nagishi and also with Heck who invented the Heck reaction that we're not going to talk about. So this is really powerful and useful chemistry for forming carbon-carbon bonds. So one of the journals I like to read is the Journal of Organic Chemistry. Journal of Organic Chemistry is where people publish contemporary organic chemistry research. And there are usually pictorial abstracts in the journal so you can see what's going on in the article. You can learn more about what's going on before you read the entire paper. And it seems that I can't pick up a copy of the JOC, of the Journal of Organic Chemistry these days, without seeing at least a couple of examples of the reaction that I'll show you next, the reaction of olefin metathesis that won Bob Grubbs and Dick Schrock the Nobel Prize in 2005. So the olefin metathesis for a long time had been an object of curiosity, just a weird reaction. And then organic chemists, notably Grubbs and Schrock, started to try to exploit and to understand the chemistry. And here's what we have today. The gist of the chemistry, I'll write it sort of in a semi general terms, but not a fully general terms, because there are so many variations. The gist of the chemistry is that we have two alkenes, the same or different depending on some subtle issues, and a ruthenium catalyst. And I'm going to write out the structure. We'll show you a little bit of a flavor of the mechanism of it. So I'll write this again in sort of the general way we did when we started to talk about the Suzuki reaction. LN, meaning ligands, on the metal ruthenium, where the metal ruthenium is bound to an alkene group. And again, I'm going to write this as R. And when you have a carbon that's double bonded to a metal, you call it a metal carbene. And so this is called a ruthenium carbene catalyst. The catalyst that these days is used is called Grubbs catalyst. After Bob Grubbs, and because this is such an active area of research in his laboratory, there's a first generation Grubbs catalyst, a second generation Grubbs catalyst, a third generation Grubbs catalyst, as well as Grubbs-Hoveta catalysts and other variations of it. But the main thing, the main feature of the Grubbs catalyst of the ruthenium carbene catalyst is you have a metal double bonded to carbon. And what this metal does is it participates in a very amazing partner swapping dance. And in this partner swapping dance, the metal swaps partners with the alkenol groups. And ultimately, the alkenol groups swap partners with each other. And again, writing this sort of in a generic fashion, again, there are sort of various variations on it, we get a new alkene generally as a mixture of cis and trans isomers in which the two original alkenes have now joined to each other. They can be the same or different arena molecule, and it sometimes depends. And the other piece of this partner swapping in the way that I've written it is that you get a molecule of ethylene. And typically, since ethylene is a gas, it goes away and you basically now kept the main parts of the molecule together. Let me give you a specific example because it's a little hard to absorb in the vast generality. If I take the molecule 1 hexene like so and I treat it and I'll show you the Grubbs first generation catalyst, honestly, for your purposes, that's all you need here. The ligands on the metal, we've already seen ligands of halogen on a metal. We've seen ligands of phosphorus on the metal here. We're now seeing a ligand of a carbene on a metal. The Grubbs catalyst has a couple of chlorines on the metal. It has a phosphine. And typically, the phosphine is tricyclohexylphosphine, and there are two of them bound to the ruthenium. And then I'm going to draw out the first generation Grubbs catalyst has a benzene group over here. We only use a little bit of the catalyst. So that's going to swap partners, but it'll go away. It'll basically get swapped out of the catalyst in the catalytic cycle. So I'll remind us this is a catalyst. And the overall product of the reaction then is we're going to join our two hexenes together and blow out a molecule of ethylene, which is going to give us a molecule of 5-descene. So if you can count to 10, I'm just drawing a 10-carbon chain here, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10. And I'll say it's a mixture of cis and trans isomers. Typically, when the Grubbs reaction goes in trouble accurately, and I'll show you an example of that at the end, you just get the cis isomer because of the constraints of the ring. And typically, if you have just two-alcohol chains, you get a mixture of cis and trans, although controlling the stereochemistry is a key issue. So we have our 5-descene plus ethylene. And I think what really marked Grubbs's genius here and Schrock, and even before that, I think his name is Chauvin, as well as Tom Katz, who was sort of the fourth man on the Nobel Prize, who almost won it. I think what marked all of their genius in looking at this reaction is the idea of saying, wait a second, I haven't seen anything like this sort of partner-swapping before. And recognizing something's unusual, whether it's in chemistry or if you're going on to become a doctor or a medical researcher, whether it's in medicine or whether it's in pharmacology, and saying, wait a second, this doesn't fit the mold of what I've learned. Recognizing that is the grounds for big discovery. If you're in the area of understanding, sort of basic science, then you say, oh, I want to learn about it because I've never seen anything like this. If you're in an applied area, and synthesis is a little bit basic science and a little bit application, if you're in an applied area, you say, oh, wait a second, maybe I could use this discovery to do something. Maybe I could figure out something useful as an application from this. So I want to show you the gist of the partner-swapping mechanism. And then maybe we'll look at a couple of applications in synthesis. So the gist of the partner-swapping mechanism is that you have your ruthenium carbene, which I'm just going to write as I did in the very beginning, LNRU double bonded to an alkenol group. And your ruthenium carbene reacts with another alkene to give a metallocyclobutane. I can draw arrows like this, like a cyclo addition reaction. I think that's fine for how we're going to think about it. A lot of times when you think about organometallic chemistry, one's focusing more on process than on mechanism. In other words, in SN2 reactions, you're thinking very much about the mechanism, or E1 or E2. In organometallic reactions, you're thinking a little more about a process. In other words, we're not worrying exactly how an oxidative addition occurs. We're just looking and saying it occurs. OK, so now we do the exact same thing in reverse. In other words, this is a sort of a cyclo addition reaction. Now we do the reverse, and we end up going to LNRU double bonded to a CH2 group. And the other product that we've blown out of the reaction is our alkenol group. And I'm not worrying about stereochemistry here, so that's our alkenol group. If you don't like my writing the hydrogens in here, I tell you what, I can write it like this if you prefer. But basically, I'm not fussing on whether it's cis or trans stereochemistry. OK, now the partner swapping continues. And in the second step, so we've blown out half, and now we have a carbene where we have our ruthenium bound to a methyledine group, a CH2 group. And now in the partner swapping, we have another molecule of our alkene coming in. And again, we're going to make a cyclo addition reaction, like so, to give a metallocyclobutane, like so. And now we do the reverse of the cyclo addition reaction, and we blow out a molecule of ethylene, and we get back our carbene. And the cycle continues over and over and over again as we drive the reaction blowing out ethylene and driving the chemistry forward. So as I hinted before, this reaction often is used when two alkanes are in the same molecule to make a new ring. We've seen lots of rings. We've seen rings in steroids, other sorts of rings. And the ring closing metathesis, as it's called, or RCM, is a particularly powerful way of making rings. And so I'll diagram this sort of in a generic fashion first, where we have two alkene groups connected by some sort of tether. And we subject this to our catalyst. And again, I'll use our first generation Grubbs catalyst. Again, the details are something of which catalyst you'd use and which circumstances probably go a little beyond the scope of the course. And the overall result of the process now is we swap partners on the two ends of the ring like so and form a new ring with an alkene in it. Your textbook gives a nice example. And then I think maybe I'll take one minute to show you an example of our thinking process. So your textbook shows the synthesis of a pyrrolidine ring in which it starts with diallolamine that has a tassel group on nitrogen. It subjects it to the reaction conditions. And we form a five-membered ring. And I think that's kind of a nice starting point for the sort of problem that I think you should be able to solve and to think about. So let me show you maybe a thought process. Let's say I want to synthesize the cycloheptene with an alcohol there and a double bond. And let's say just to put some constraints on it, I'll say from compounds containing four carbon atoms or fewer. And just to give us maybe a little hint, I'll say using olefin metathesis. All right. Now you look at this molecule and you look at the example on that blackboard. And you say, oh, OK. I can kind of see my way back. This is retrosynthetic analysis. And I've given you a big glaring hint. You say, I can see my way back to a compound in which I have, since we're forming a seven-membered ring, we're bringing together 1, 2, 3. And 1, 2, 3. I can see 1, 2, 3, 4. 1, 2, 3, 4. If I just imagine bringing these two partners together, you say, I can see that. And then you look, you say, well, we still got a lot of carbons in here. And you say, wait a second. OK, I'm thinking back to my organolithium chemistry. And I know that I can go ahead and add in to, say, an ester group two equivalents of an organometallic compound like an organolithium compound. And I can choose any sort of ester like this. And now you put this together. And you say, OK, I can go ahead. I can do this. I can go ahead and say, I will take, let's say, maybe I'll make my organolithium compound just for the hell of it. I suppose my parameters didn't require this. But I will take, let's say, my bromocompound. I'll take my bromolkein with two lithiums. And this kind of ends up being a refrain for all the things we've done in the class. We make an organolithium reagent. We take our ethyl ester. That's going to be the top two parts. And we treat it with two equivalents of the organolithium reagent. So I'll just say organolithium reagent for emphasis two equivalents. And then I do in a separate step an aqueous workup. And that's going to take us over to our building block. And now that's taken us all the way. And I just subject this to ring closing metathesis, which I write as RCM. And I have product. And it's that type of thinking that can lead you on. Last question. Now, we use magnesium bromide. Could you use magnesium? Someone answer. Yeah, we could go ahead and make a grignard reagent. And so here we've gone in the course all the way from grignard and organolithium chemistry through carbonyl chemistry through amine chemistry through the Grubbs reaction to build really complex molecules from simple building blocks. You guys are the greatest. Knock them dead on the final. I will see you on Tuesday. Wow me. I want to be wowed.
This is the third quarter course in the organic chemistry series. Topics covered include: Fundamental concepts relating to carbon compounds with emphasis on structural theory and the nature of chemical bonding, stereochemistry, reaction mechanisms, and spectroscopic, physical, and chemical properties of the principal classes of carbon compounds. Index of Topics: 3:52-Grignard Reagent 7:01-Organometallic Complex 12:47-Organocopper Reagents 23:05-Organocuprate Mechanism 25:17-Stereospecificity 32:02-Drawbacks of Copper Chemistry 33:55-Suzuki Reaction 42:48-3 Main Steps to the Suzuki Mechanism 55:37-Using the Suzuki Reaction in Organic Synthesis 1:03:00-Olefin Metathesis 1:11:16-Partner Swapping Mechanism 1:15:20-Ring-Closing Metathesis
10.5446/19422 (DOI)
Good morning. Good morning. Well, so I just looking at the the quizzes and Johnny and Kim Xerox the wrong one. So we're, don't worry, we're going to do them at the end. So just, oh, you want it sooner? I can give you the wrong, wrong quiz. I've got the wrong one, but it's harder. No. No. All right. So hang in, hang in there till the end. Save your, save your adrenaline. Johnny and Kim are off, off running as fast as they can and we'll be back with lots and lots of copies of the newer correct quiz. All right. So what I want to do, what I want to do today is to talk about chapter 28. And chapter 28 is on amino acids, peptides and proteins. So beautiful chapter, beautiful topic, fantastically important. Follows on the heels of carbohydrates. The main classes of biomolecules are sugars, proteins, nucleic acids, and then you throw a few lipids and secondary metabolites like alkaloids and so forth on top of that. And chapter 28 is a wonderful chapter in the sense that it tries to cover everything. And the result of course is given the limitations of the course. If I don't cut it down, we will cover nothing. And so what I've decided to do is really focus on amino acids and particularly peptides from the point of view of synthetic chemistry and not even so much the synthetic chemistry of amino acids. There's some cool chemistry on the Strecker synthesis. There's some interesting stuff in the chapter that overlaps with your biochemistry class on isoelectric points and other aspects of amino acids and peptides. And some of this you'll get in your biochemistry class. But I really wanted to give you my own perspective on this topic. And what I see is really some of the beautiful and profound aspects. So let me start with a simple amino acid structure and then a simple peptide structure. And so maybe for regular amino acids, meaning sort of typical amino acids, maybe the amino acid alanine is sort of the archetype. It's an amino acid and people, because the amino group is at the alpha position, call these alpha amino acids. And as I said, this particular one is called alanine. It's the smallest amino acid with a side chain. Now, amino acids of course have amino groups and they have carboxy groups and so they can be connected together end to end. And when you connect them together end to end, you get a peptide, small collections of amino acids containing up to about 40 amino acids end to end or typically referred to as peptides. Larger ones, often in nature, polypeptides have folded structures and are typically referred to as proteins. There's not a hard and fast definition of where the boundary is between peptides and proteins, but usually the emphasis would be unfolded structures of biological origins for proteins. So I want to draw out a simple tripeptide and I've just arbitrarily taken three amino acids. The first one is phenylalanine, the second one is isoleucine and the third amino acid is leucine in this chain. So we call this a tripeptide because it's composed of three amino acids. So a tripeptide or a tripeptide and the particular name of this tripeptide if you want to get technical would be phenylalanine isoleucine, P-H-E-N-Y-L-A-L-A-N-Y-L isoleucine. All one word, not super important how you name polypeptides. Polypeptides have attracted the attention of chemists for organic chemists for so, so long because these are the molecules of life and because organic chemistry really is the science of life and its molecules and some of them are remarkably, remarkably powerful. So for example, the polypeptide oxytocin was first elucidated, the structure was first elucidated and then in a tour de force effort it was synthesized by Vincent de Venyod in 1953 and he immediately, I mean timescale of Nobel prize has immediately won the Nobel prize for it by 1955. So it's a NONA peptide. That means nine amino acids and it contains a disulfide bond. I'll just give you a cartoon of the structure but I want to talk about it. So I'm not going to even draw out all the nine amino acids in it. The N-terminal amino acid, the back end, so this is called the N-terminus, is assisting. Sistine is like alanine but with a sulfur instead of a CH3 group then you run through another four amino acids and then the molecule snakes back on itself. Whoops, let me get the structure right here. And again, I'm sort of giving an abbreviated cartoon of the molecule. We have another cysteine, so another CH2S and the sulfurs can link together to give disulfide. Sulfur linkages, if your hair gets frizzy or if you uncurl your hair with a curling iron or with straightening solution and then it locks back in with curls in it, it's sulfur linkages in your hair that actually lock in that structure because of course hair is protein. Alright, and then we continue through another three amino acids and I'm not going to again draw it, I'll just say three AAs to the C-terminus of the structure and it happens to have an amide group here and so I'll just write over here C-terminus. So this peptide, in addition to having this fantastic historic importance of being this sort of milestone in synthetic chemistry and a real mark of achievement of what organic chemists can do, also has remarkable biological properties. This peptide is produced by your pituitary gland, it's involved in uterine contractions, in pregnancy and in birth, it's involved in lactation, but incredibly this is also involved in emotions and pair bonding. In other words, love. You know, you say, oh I'm in love with a person and it's that person and it's you. In the end it's chemicals in your brain, I mean this is really scary. You know, it's not you, it's the lack of oxytocin I feel for you, oh my god, what a deal breaker. There's fascinating literature, I don't want to get started out there, on differences in monogamous behavior among different species of voles, you know, these little creatures that run around on the ground like mice or shrews, and the prairie voles are monogamous, they participate in pair bonding, they hook up for life with a partner and it turns out that ties into oxytocin and a related hormone vasopressin in its receptor levels. So this is incredibly powerful stuff. I'll give you one more example, because this is a cool example of the types of things that we can synthesize right now. So the virus HIV, it was horrible, horrible stuff, the AIDS virus, and one of the enzymes that's essential for its life cycle is called HIV1 protease. And it's a 99 amino acid Polly peptide protein, it cuts the other proteins that are needed for the life cycle of the AIDS virus, it's what these powerful drugs against AIDS, the HIV protease inhibitors, work against their molecules that fit into this enzyme and gum it up so it can't cut the proteins that need to. And this protein has been synthesized, it's a dimer by the way, meaning two halves come together non-covalently, but this protein has been synthesized chemically in the laboratory and what's really cool, okay, she'd say, well great, nature can make this thing too. What's really cool is chemists can make the mirror image of the protein and have used that to discover drugs, which is really, really cool, where you can go ahead and then use biological techniques to get a peptide that interacts with the mirror image and then you make the mirror image of the peptide that interacts and you've got something that's biologically is functional, but doesn't break down. Anyway, incredibly cool stuff, I'm just going to give you a little bit of flavor of things. So there are 20 common naturally occurring amino acids. People often refer to these as 20 natural amino acids. Natural is a little bit of a fake word here because you can find others in nature, but there are 20 that are regularly coded for in the proteins in your body. I'll leave it to your classes in biology to insist that you memorize all of them or memorize the three-letter codes, just like what we did with the sugars where I focused on a few sugars. I'd rather you know a few of them. I'll put up more than I think you should know, but I want to show you some principles here and show you some of the variations. So a lot of the amino acids have nonpolar side chains. So for example, we already saw alanine with a methyl group and that's kind of the archetype for amino acids is to have a side chain. If you have an alkyl group as the side chain, you describe it as a nonpolar amino acid, right? You've got a greasy side chain. Grease and hydrophobic interactions, the desire to get away from water, a big factor in protein folding. So typically you have more of these hydrophobic amino acids on the inside of proteins. There are all sorts, not all sorts, but quite a number of different alkyl side chains. So for example, alanine is a methyl group, valine is an isopropyl group, phenylalanine is a benzoyl group, lucine is an isobutyl group. So let's draw out a few of these, leucine. All right, so there are a couple of hydrophobic, a couple of greasy amino acids that are sort of oddballs in structure. Glycine is actually the smallest of amino acids. So glycine is the only one that doesn't have a side chain. So all of the other amino acids have a side chain. They all have the same direction of the side chain, cysteine because of the coningold-prelog rules. They're all, by the way, S stereochemistry. So I'll write S here with one exception, the amino acid cysteine because of the higher coningold-prelog priority of sulfur ends up being R, even though the chain points in the same direction. So this is glycine. So glycine, of course, is achyro. We don't have a stereogenic center at the alpha position. The other sort of oddball among the nonpolar amino acids is the amino acid proline. Technically, proline gets called an amino acid, but that's not particularly important. What is important is that the amino group in proline is a secondary amine rather than a primary amine. This gives rise to some interesting structural features in proteins. Proline, in particular, has a tendency to turn back on itself, for example, because you can get cysts and transconformations about the amide group that it forms. All right, so that's kind of a selection of some of the hydrophobic amino acids. I want to show you some of the polar and charged amino acids. So the amino acid serine, for example, has a hydroxy group. One of the reasons that we're doing this right now and why you're writing these out is that unless you go ahead and really see things, unless you actually write and think about them, all of this just ends up structures in black and white. If you can't read my writing, serine is just like alanine, but it has an alcohol group. It has a hydroxy group off of the methyl position. There's threonine as well, which has an extra methyl on there, but I won't write it out for you. So I talked about cross-langus from sulfur, and they're one of the important things in protein structure. So the amino acid cysteine is just like serine, but it has a thiol group. It has a sulfhydro group, and thiol groups oxidize very well. They oxidize very easily and form disulfide cross-lanks, and so this ends up, as I mentioned before, with hair and so forth giving structure to proteins. Not all of the amino acids have side chains that are neutral in water at physiological pH, and again, I will leave it to you and your biochemistry classes to discuss more the charge of amino acids at various conditions, but this amino acid is glutamic acid. You may have heard of it in terms of monosodium glutamate, MSG in your food and Chinese restaurants. It's the salt of it. It gives a meaty flavor to things. And of course, in water, at neutral pH, the carboxyl group, right, carboxylic acids have a pK of 4 or 5, so in water at neutral pH, you're going to have the carboxyl group deprotonated, even if the amino acid is part of a polypeptide, where the amino group and the carboxyl group of what's called the main chain are part of the polypeptide. The side chain is going to be deprotonated. So glutamic acid is an acidic amino acid. There are basic amino acids, but I want to show you its sister. It's an ill-named sister, I might add. Another polar amino acid. So we have a primary amide group here. This is called glutamine. Glutamine is just like glutamic acid, but with an NH2 group instead of a carboxyl group with an amide group. Now, to me, that doesn't make any sense. Glutamine isn't an amine. An amide group isn't an amino group. It's not basic. It doesn't behave like an amino group, but that's its name, and we call it that. There are amino acids with real amine groups here, lysine being one of them. Another basic amino acid. And I'll give you one last amino acid. As I said, I'd say this is more than I would expect you to know unless you're a practitioner of the art, but you've seen now examples of all of these functional groups here. And so I think this is a really, really nice introduction to amino acid structure in polypeptide. So lysine, of course, at physiological pH, remember your pKa's, side chain of lysine, it's an amine, pKa's going to be about 10 or 11, so it'll be protonated at physiological pH. Arginine is the last one I'll show you. Also has a basic side chain. It's got a guanidine group. Arginine is even, A-R-G-I-N-I-N-E. Arginine, the side chain's even more basic than an amino group, and so it's going to really be protonated at physiological pH at just about any pH you can imagine. All right, now. As I was saying at the beginning, what I think is just fantastic is the progress that chemists have made in the chemical synthesis of peptides and proteins. And if you think about it, the way in which one can investigate biological function, for example, the function of oxytocin or the function of vasopressin, is to make molecules that have similar structures and say, what does this group do? What does the cysteine group do? What happens if we rearrange the structure? And so the chemical synthesis, in addition to being a way of initially proving structure, also ends up being a tremendously powerful exercise in investigating biology. Now, the conundrum, if you look, let's take a simple dipeptide. And so if I draw out just a simple dipeptide, I'll say R2 for just a generic side chain and R1 for just a generic side chain. Again, that could be anything. It could be phenylalanine. It could be isoleucine. It could be leucine. So if we look at this basic structure, you say, okay, well, it's pretty obvious that the main bond in a polypeptide is an amide bond. You can say, okay, it makes sense if we were to think about how to make this molecule. We'd look at that bond and say, we've learned a heck about making amide bonds. We've been talking about carboxylic acid since the beginning of the course in Chapter 19 and then some more about it in Chapter 22. We'd look and say, from a strategic point of view, this is really simple. You'd go and say, all right, we just have to envision making that amide bond and you know in the abstract in the view at 20,000 feet that we can make an amide bond by the reaction of a carboxylic acid and an amine. And now the problem begins. Well, how do you actually, how do you do this? We've learned lots of chemical reactions. We've learned that under the right conditions if you go ahead and mix a carboxylic acid and an amine maybe with a coupling agent, you learned about DCC, for example, you say we've learned ways of making amide bonds. You look at this and you say, yeah, okay, maybe somehow we could envision putting this together. But obviously you've got fantastic problems here. You've got two different carboxyl groups, two different amino groups. Even if I threw together one amino acid and the other amino acid with something to make the carboxyl group react with the amino group, you've got a molecule could react with itself. You could get a molecule with two R1s in it or two R2s in it or an R2 at the end at the C terminus and an R1 at the end terminus or the molecule could continue to build a polymer and you get three or four. In other words, you'd get an unholy mess no matter what you do. And we've been talking for the entire class about how organic chemistry is all about control and how organic chemists seek to control how reactions occur and that really boils down to being the essence of the synthesis of peptides and proteins. So imagine for a moment, I'll show you the answer and then we can talk about sort of the whys and so forth. Imagine for a moment, we took one of our components and we were to tie up, we were to protect the amino group here. We've already learned about the concept of protecting groups. You've learned, for example, when you have an alcohol that you don't want to react as an alcohol, you can mask it. You can protect it as a TBDMS ether, a tert-butyl dimethylsilate ether group. And you've learned that carboxylic acids don't react like carboxylic acids when they're part of an ester group. So you can envision protecting the carboxyl group as well. And so by being able to selectively protect, to tie up the amino acids, you can achieve this element of control. The groups that are widely used for these types of protection reactions are various esters including benzyl-like esters, benzyl and benzyl-related esters for the carboxyl group. And the T-Boc, tert-butoxyoxycarbamil and other carbamate groups for the amino group. Let me show you a specific example of just a standard way of putting together a peptide. And we'll make valoalanine by this. So imagine for a moment now that we put on valine. The textbook will talk in more detail about how these protecting groups can be introduced. I think in the time we have, I'll simply say it's very easy to take the amino acid valine and react it with a reagent like di-tertbutyldicarbonate to go ahead and put on a Boc group on the N-terminus of it. And by various esterification processes, one can go ahead and put on a benzyl ether or a related group to a benzyl ether on the C-terminal group. And I think I said we're going to use valoalanine here. So I will just go ahead and point out that this is BN, is used to abbreviate benzyl group. And we've learned about reagents that can react with a carboxyl group and render it more reactive. So for example, the reagent DCC, I'll show you it in just one second, can go ahead and can activate this carboxyl group and then allow it to react with this amino group. So the overall product of this reaction, and I will now start to use shorthand for these very big molecules, the overall product for this reaction then is the Boc amino valine on the N-terminus, O-benzyl ester on the C-terminus. And I haven't drawn the byproduct of DCC. All right, so just to reduce things, we're going to have to reduce things to a lot of our groups. Let's imagine for a moment that this carboxyl group is the carboxyl group on that carboxylic acid, that Boc valine carboxylic acid. DCC is a diametry agent. We talked about it briefly. Your textbook gives a mechanism for its reaction. It's really not the best way of writing the mechanism, but I think many students would think of the mechanism in the way your textbook writes it. Suffice it to say, cyclo DCC, dicyclohexyl carbodi-imid can react with a carboxyl group to give an activated carboxyl group. And the structure that I'm drawing here looks awfully fancy until you think about it. I'll abbreviate those cyclohexyls as CY. The structure looks awfully fancy until you think about it. And then you say, wait a second, for the longest time he's been saying double bond to nitrogen is very similar to a double bond to oxygen. So this structure, this intermediate, this oacyl urea intermediate, I'll just abbreviate it as INT, is basically like an anhydride. In other words, we have a carbonyl with an electron withdrawing group on the oxygen. And so the amine partner, which in this case I will just abbreviate as R prime NH2, now can act that of course being the CBC ester of alanine there, or rather the benzoyl ester of alanine, alanine benzoyl ester, can react. I won't take us through all of the steps of the mechanism, but suffice to say the first step of the mechanism is the amine, a nucleophile, can attack the carboxyl group of the oacyl urea intermediate. Electrons kick up on the oxygen, electrons kick down, they kick out what ultimately is disyclohexyl urea after some proton shuffling. And so the product of this reaction is the amide plus the byproduct disyclohexyl urea. And as I've been emphasizing in this class, organic chemists are very bad about writing byproducts of reaction because they're typically focused on the main product. The byproduct is called DCU disyclohexyl urea. So DCC, by the way, was the first major coupling reagent that was invented, but it wasn't the last. It's actually terrible stuff to work with. It reacts with the proteins in your body to functionalize them, which sets your immune system on guard against them, which means that after working with it for a while, you'll start to develop terrible, terrible rashes, which is why Johnny and Kim, even though they will synthesize peptides in the laboratory as part of their research on cancer and Alzheimer's disease, never worked with DCC. All right. So here we are at our peptide. And I want to draw out the structure again and talk about what can happen to this because now we have a peptide. We've synthesized a peptide in which our C and N terminus are protected with protecting groups. The benzyl group on the benzyl ester group on the C terminus, the Bok group on the N terminus. The Bok group is labile to acid. That means that a strong acid can take off the Bok protecting group and return to you in a mean, or technically in a mean salt that can be deprotonated. The benzyl group is labile to, among other things, hydrogenalysis. It's also labile to very, very strong acid, like hydrogen bromide and anhydrous acetic acid. So if we take our dipeptide and we carry out two deep protection steps on it, a hydrogenal, a, we'll start with a trifluoroacetic acid, deep protection step. This is TFA. I'll write this in parentheses. Trifluoroacetic acid is a pretty strong acid. It's right on that cusp between weak acid and strong acid, not as strong as HCl, not as strong as sulfuric acid. Its pKa is about 0.23. So it's way, way stronger than a regular carboxylic acid due to the inductive effect of the trifluoromethyl group. And then if we carry out a hydrogenation with palladium on carbon, we can remove both of the protecting groups. And so I'll just remind us. I'll say BAC is able to be removed with strong acid. EG, for example, TFA. And the benzoyl group is able to be removed by hydrogenalysis or very strong acid. And so I'll just remind you that the hydrogenal acid is able to be removed with strong acid. And so I'll just remind you that the hydrogenal acid is able to be removed with strong acid. And as I said, by very strong acid, I mean, for example, hydrochloric acid, HCl, and dioxane, hydrogen chloride, and dioxane, or HBr and acetic acid. All right. So the overall result of this is that we have now removed both of the protecting groups to give us just the free peptide, like so. In other words, we have hidden one carboxyl group, hidden one amino group, brought together the other carboxyl group and the other amino group and coupled them together. Now I'm lying to you just a hair about this, because I haven't used a base. Technically, we'll still be the TFA salt. I'll say it's still the TFA salt at this point. But honestly, if you wanted the free base, you could just go ahead and add a base anyway. So technically, still the TFA salt. All right. I want to show one thing. We're kind of taking a trace through mechanism here, but sort of mechanism light and getting kind of a summary of how things work. We've taken certain mechanisms in the course and worked them over in gruesome detail, like acetal formation and acetal hydrolysis, which came back to us in sugars. We're getting others where we're getting the general gist of it. Let's talk about the Bokk deprotection mechanism. So, OK. So here you have your Bokk group, like so. Oops. Now, in strong acid like TFA, you can protonate all the different positions in the Bokk group. And the easiest way to think about taking off the Bokk group is if we protonate on this nitrogen here. So I'll write this sort of as a transient intermediate. If we protonate on this nitrogen here, now we're all set up to lose a tert-butyl carbocation. And so if we just go ahead and pick out electrons, we're going to fragment this molecule into carbon dioxide. Carbon dioxide is very stable. And tert-butyl carbocation, and an amine, like so. And then, of course, as I was hinting at over here, your amine, I'll just draw this down here, with more TFA, we'll go to RN8, and RN8 will protonate to give the ammonium salt, like so. All right. So I want to point out a couple of amino acids that are special. We've already seen them. So we saw, for example, with lysine, you have an extra amino group. And we saw with glutamic acid that you have an extra carboxyl group. And so in these amino acids, and in several of the other functionalized amino acids, amino acids with acidic and basic and polar side chains, additional protecting groups are needed. And suffice it to say there's chemistry to put on these protecting groups. So I want to stop at this point talking about the details of protecting groups, and come on a little bit more to the theory of what we do. So, okay, so the general gist of things is we're going to build our peptide amino acid by amino acid, starting at the C terminus and working to the N terminus. Okay. In other words, you could imagine with the valolalanine that we made, if we had, for example, only taken off the buck protecting group off of the amino terminus, we could then go ahead and couple in another amino acid, say phenylalanine, another amino acid, say phenylalanine, to make a tripeptide. We would introduce that phenylalanine by having a buck group on the amino terminus, on the amino group, and a free carboxyl group, and again, carrying out a DCC coupling reaction. And so this is the type of technology that allowed Vincent de Venho to build up, to synthesize the nonna peptide oxytocin back in the 1950s, and ultimately really create the beginning of a revolution. Now, another huge advance came along with an idea that Bruce Merrifield introduced in the 1960s, and his colleagues thought he was crazy for this, but he won the Nobel Prize in 1984 for what he did. And his idea was to go ahead and connect the polypeptide to a solid support. In other words, to make the C terminus of the polypeptide instead of just a protecting group, a big plastic bead. And so let me show you the gist of modern solid phase peptide synthesis, and then we can run through a few of the details. So imagine for a moment that we have a polymer bead, polymer plastic polystyrene. I'll show you the structure in a moment. And it's not exactly what Merrifield initially used, but imagine for a moment that the polymer is basically a big benzal alcohol, and that you have an OH group on there. And then in the first step, we couple one amino acid. I'll call it sort of in the abstract, we'll just call it R1 for our side chain, and we'll say that we have a protecting group on the nitrogen. So this would be like a BAK protected amino acid. And so now we have our amino acid with our protecting group. I'm just calling that PG onto the resin, and I'll abbreviate the polymer with this big ball here. All right, now imagine for a moment that we deep protect. In other words, we carry out a reaction like the TFA reaction to remove that protecting group. For example, to remove the BAK group that was introduced. At this point, you're going to have the amino group here, the free amino group connected to the first amino acid, connected to the resin, which I'm abbreviating as a circle. Now imagine for a moment that I couple in the next amino acid, so I'll say I'll couple, and we'll call this R2 on an amino acid again with a protecting group, which I will call PG. And I think I'll move down to the blackboard here to show you what we've now got. So now we have R2 connected, and now we have our protecting group. And imagine for a moment that we again deep protect. And now I'm going to shorten things and right deep protect this step one in couple. And I'll show you our third amino acid. You notice that we're starting at the C terminus, and we're building up toward the N terminus, so I'll call this R3. And our structure is getting so big that I now have to go to the other blackboard. And at this point, we're at a tripeptide where we're at a tripeptide. Now attached, and I've gone from the N terminus to the C terminus here with our third residue, our second residue, and our first residue. And finally, imagine if in the abstract we cleave from the resin and we deep protect. I'll say cleave and deep protect because they're sometimes done at the same time. And the result of all of that now is that we have synthesized a tripeptide. And the operation is so simple once you work out the chemistry that it can be done on a machine repeating these operations one after another, after another, to build up polypeptides and even very small proteins purely through chemical synthesis. And this was what got Merrifield the Nobel Prize. It was this recognition that you could do this and the achievement of doing it. And so while the work of synthesizing an oxytocin, aenonopeptide, was a fantastic tour de force, this opened the job to make things trivial to make molecules of that size. And one of the beauties of this is you really need the chemistry to work cleanly. And so you can use a huge excess of reagents for equivalents of each amino acid to drive the chemistry. Question. Why is this synthesized from C to N? Ah, great question. Why are we going from C to N? And that question is particularly profound when it is counterintuitive when on the ribosome you synthesize it, or the ribosome synthesizes the protein from N to C. It turns out that there are reactions that occur. If I try to activate, let's even assume I had this protecting group and I tried to activate this carboxyl group with DCC, there are reactions that occur that will ephemerize this stereocenter in chemical environments with vigorous activating agents like DCC so you will get a mixture of diastereomers. So in general, like all the time with certain very special exceptions including something called native chemical ligation that may give rise to the next Nobel Prize in this area, with certain exceptions, with virtually no exceptions I should say, we always go from C to N, the opposite of the way of the ribosome. All right, I want to show you a couple of last bits of the genius that was involved in all of this chemistry. So one of the pieces of genius is really very simple. It's the polystyrene. So polystyrene is a polymer in which you have a zigzag chain of polyethylene with benzene rings attached, like so. You make it by polymerizing the alkene styrene, linking the molecules together one after the next after the next. Now, styrene is styrofoam. If you've ever taken styrofoam peanuts and put them in any organic solvent like acetone, they form a big group. If you do this with a styrofoam cup that you bring into lab and you put a little acetone in there, it just melts. It just dissolves technically. So Merrifield's bright idea, one of his bright ideas, was to link together two chains with a little bit of divinal benzene and cross-link the polystyrene into a big network, like so, so that the chains all link together and the molecule would swell up but it wouldn't dissolve. And then he used the benzene ring and functionalized just a few of the benzene rings on the polystyrene to put on the protected amino acid with the protecting group. And that was one real piece of genius here. And so the chemistry that I've sort of been outlining here really can be thought of as, I'll write this as Bok, let's say for the one that we could synthesize, Bok-O-Polystyrene. And then we can follow with a series of deprotection and coupling steps where we use TFA, trifluorocytic acid, to deprotect the amino group. And remember I said, well, your amino group technically is still protonated. So you can add a base like diisopropyl ethylamine or triethylamine to deprotonate, IPR2-NET to deprotonate the amino group that's now liberated. And three will couple in the next amino acid. And so I'll say Bok-Phe, Phe is the abbreviation for phenylalanine. So I'll say Bok-Phe-OH and DCC. And now we can get Bok-Phe-Veo-OPS and we can repeat and repeat and repeat to build up the polypeptide chain, one amino acid after the next, after the next. So I think leave you with, well, let me go ahead and I'll just say repeat. And let's say I did this this time with alanine. So again, we shorthand a lot of stuff here. So let's say I go ahead and do this with, let's say, leucine. So repeat and now we go Bok-Lu-Phe-Veo-OPS. And now if you imagine we use a very, very strong acid, now we can get a tripeptide. And if we had continued on the resin, we could have gone up to tetrapeptide. All right, the final innovation that I want to show you, and this is realized, this is standing on the shoulders of giants for many years who've made this chemistry possible to a point where it is now routinely possible to make peptides and small proteins. So one of the last innovations was Merrifield's initial chemistry was kind of nasty. And by nasty, I mean that that last step of deep protecting, of getting rather cleaving from the resin, getting the amino acid off of the resin, getting the polypeptide, I should say, off of the resin required super, super strong acid. HBR hydrogen bromide and acetic acid is one of the reagents used, just nasty stuff. Anhydrous hydrofluoric acid, anhydrous HF eats through glass, burns through skin, burns to your bone, does horrible, horrible stuff. And so the last innovation that I'll introduce was a base labile protecting group, the FMAC group. And the FMAC group is a big, big, big aromatic unit. It stands for, it's in the same family as the BAC group. It's a fluorine methyl, that means CH2, oxycarbonyl. And the FMAC group is cleaved with a base such as papyridine. So I'll say a mild amine base. And so the FMAC group, if you treat it with papyridine, the base can pull off a proton here, kick out an alkene over here, kick out an oxygen, and ultimately kick out carbon dioxide. So when this occurs, now you end up with the BH plus, the protonated base, plus the group that came from the fluorine group, which eventually reacts with some more base, plus CO2, plus the amine. And so putting all of this together, I'll just show you an example of a modern solid base peptide synthesis and then we'll wrap things up. So in a modern peptide synthesis, what's done is the polystyrene is linked to a much more acid-label linker. And this might be a good final exam question to go ahead and explain why this linker here is much more labile to acid. And now you have your first amino acid. Oops, that's a wedge here. And so now we go ahead and I'll call this R1. And so we go ahead and we deprotect with papyridine. And then we just abbreviate that as PIP. And then we couple. And as I said, typically nowadays people don't use DCC, but I will write DCC. So here's our F-Moc protected second amino acid R2. And so now you build and build and build. And this linker here is called a Wang linker. And so I will write O-Wang PS. And finally, after building and building and building, you'll cleave with papyridine. And I'll just say repeat, repeat, repeat. And then you finally cleave with papyridine. I'll write that as PIP. And then you do TFA, which cleaves the peptide off the Wang linker to give your peptide. All right. Well, on that note, we're going to take a moment to pass around the quizzes. One minute to finish up writing, and then you can put away your notebook.
This is the third quarter course in the organic chemistry series. Topics covered include: Fundamental concepts relating to carbon compounds with emphasis on structural theory and the nature of chemical bonding, stereochemistry, reaction mechanisms, and spectroscopic, physical, and chemical properties of the principal classes of carbon compounds. Index of Topics: 2:49-Amino Acid Structure 5:55-Examples of Polypeptides 12:18-20 Common Amino Acids 17:03-Polar & Charged Amino Acids 22:35-Chemical Synthesis of Peptides and Proteins 27:49-Protecting Groups 31:54-DCC 40:07-Boch Deprotection Mechanism 42:44-Special Amino Acids 43:33-Additional Protecting Groups 46:42-Modern Solid-Phase Peptide Synthesis 54:20-Boch Opolystyrene Example 59:54-Fmoc Group
10.5446/19421 (DOI)
Good morning. Good morning. So today I'd like to continue our discussion of the structure and stereochemistry of sugars. We're going to then talk about reactions of sugars. And we're going to come back at the end to look, if everything works out, how a meal fisher originally determined the structure and stereochemistry of sugars in what really was a tour de force work. And I'll just give you a teeny, tiny taste of the flavor of the chemistry and the logic involved. So I mentioned fisher. And last time we introduced fisher projections, this way of drawing sugars that really pervade sugar chemistry. And it's a very, very useful tool for quickly thinking about structure and stereochemistry. And so we're going to use that along with Haworth projections and other projections in today's talk. So I want to start by just giving an overview of how we can look at some stereochemistry of sugars. I'll take some very simple, very small ones. We've talked about glucose. Glucose is an aldohexose. We've talked about galactose. Galactose is another aldohexose. These are six carbon sugars. At this point, I just want to start out to give you the simplest thing where we can get all the stereochemical relationships. And so I want us to look at various tetroses. Tetroses are, of course, four carbon sugars. And specifically, aldotetroses are sugars where the one position is an aldehyde. We'll later see keto sugars where you have not an aldehyde but a ketone group. And all of these are carbohydrates. All right. So to give some flavor of stereochemical relationships and maybe harken back to 51A, let me draw out the four aldotetroses. Now, four I'm going to qualify because you could also say it's two depending on whether we're counting enantiomers. So let's start with the natural isomers. So this sugar, this four carbon sugar is D3-os. And remember, all of the D sugars, by definition, when we draw a Fischer projection this way, all of the D sugars have the hydroxy group at the carbon next to the bottom position. The bottom stereocenter have that with the OH pointing off to the right. Remember, this representation has the backbone curving backwards, snaking backwards in a series of zigzags. And so this means this OH is pointing out of the board. This hydrogen is pointing out of the board. This CH2OH is pointing back. And this remainder of the chain is pointing back. And then in this representation we continue to point the aldehyde group further back. And so this hydrogen is pointing out. And this OH is pointing out. Now, what's nice about the Fischer projections is we can rapidly lay out all different structures and compare them. It's quicker and easier and more intuitive than zigzag structures. And so I'm going to draw another D sugar, another D aldotetros. So it's still going to be D. But now instead of having this, so that means this hydroxy group is still off to the right. But now instead of having this stereocenter with the OH off on the left, we're going to have it off on the right. And this one here is called D erythrose. And of course these two molecules here are diastereomers. We talked about diastereomers last time. We talked about, for example, glucose and galactose. Those are diastereomers that differ at one stereocenter. That's, we have a special name for a stereoisomer that differs a diastereomer that differs at one of many stereocenters. We call that an epimer. And then we also talked about stereochemistry at the carbonyl carbon in the cyclic form in the anomeric carbon where you could have either the beta or the alpha stereochemistry. And we had a special name for that, anomers. So we saw beta D glucose and alpha D glucose. Those two diastereomers, in addition to being a type of epimer, you would also refer to them as an anomer. Anyway, these are just generic diastereomers and epimers, I guess you would say. Now, imagine for a moment that I flip all of the stereocenters in the molecule. I invert them. And so we go like this. And again, I can very rapidly represent this for our 3-O's example. So now, for the 3-O's, I flip this stereocenter on the bottom. So that by inherently is now going to be an L sugar. And if I flip the other stereocenter like so, so now I've made the molecule that's the mirror image or more specifically the non-superimposable mirror image. I have represented the enantiomer here. And of course, that means this compound I've drawn is L3-O's. Sometimes the L sugars are referred to as the unnatural sugars and the D sugars as the natural sugars. Wait, shouldn't it be all erythros? Because the O H on the left, like the second? No, because erythros, so okay, so good question. This is why we're going through this with some care. So here, if I now go ahead and make this L sugar, this is the enantiomer of, whoops, that's supposed to be an aldehyde, so we're going to make that CHO. So this is the enantiomer of erythros. And so this is L erythros. I saw another question. So the bottom part of the structure is the L. So this is the S stereocenter, right. Now one thing that's interesting and we'll get to this when we talk about the Fisher-Proof of stereochemistry is until many years after the relative stereochemistry, the diastereomers of sugars were determined, people couldn't tell which enantiomer was which. And so arbitrarily it was chosen, eventually it was discovered what was real. But all of these relative stereochemical relationships in the terms D and L apply regardless of whether D is R as we saw it was or whether D is S. Other questions at this point. So we would say that L3O is the enantiomer of D3O. L3O is a diastereomer of L erythros and L3O is a diastereomer of D erythros. So that gives us sort of a basic introduction or reintroduction to stereochemistry and shows us how we can use these Fisher projections very nicely and quickly. So I want to take us through a few other forms, a few other ideas in sugars and then we're going to come back to some reactions of sugars. So again there are two different diastereomers of erythros, of aldotetroses and then there are four of aldopentoses and eight of aldohexoses. And we're not going to learn or think about every sugar but I'll give you a few as an example here. So I think in terms of the aldopentoses, I'll write aldopentose, five carbons sugars, the one that's got to be the most important is ribose. And ribose happens to have all of the OH groups on the same side in the Fisher projection. I will write D ribose. Why is ribose important? It's in RNA, deoxyribose is in DNA, deoxygenated at the two position. And so this is a tremendously, tremendously important sugar. Now we've learned to go ahead and think about the, well let me go ahead and I'll do this on this board here. We've learned to recognize that sugars have a cyclic form and generally even though I've been drawing them predominantly or been drawing them as the free aldehyde, remember we talked about how the cyclic form, the hemiasatel and the aldehyde form rapidly interconvert. We said glucose for example is only.003% of the open form. Ditto for ribose and water, ribose is predominantly the closed form. And there are two different structures, two different isomers that exist. One of them is a six-membered ring isomer. And this is, and we're not going to focus, remember I said, this squiggly line means mixture of alpha and beta. Beta is up, alpha is down. We're not going to focus on that stereochemistry. That mixture of alpha and beta anomers will exist in equilibrium. One with the OH up, the beta and the other with the OH down. That stereocenter isn't fixed, it's labile. But we will focus on the others. And if you just imagine picking up the molecule and laying it down, you can see in our Haworth projection here that our OHs are going to go down. And maybe the only one that's tricky in one's mind eye to convert this Fisher projection to the Haworth projection, maybe the only position that's tricky is that next to the bottom one. And so just imagine in your mind's eye, we're going to rotate, rotate and rotate like that. And now you say, okay, so we bring this OH down here, the CH2 comes here and the hydrogen comes here. And so if you can do that rotation in your mind's eye, you pick it up and you say, okay, actually we're going to, I'm sorry, for this one, we'll do that next for the furanose form. For the puranose form, we're just fine because we just cyclized on this oxygen. So we bring this oxygen around to that hydroxy group and so we have 3OHs pointing down. So I was getting ahead of myself. Okay, so here's the Haworth projection for the puranose form. And in solution, ribose exists in water. It exists as 76% of the puranose form as a mixture of alpha and beta animers. But the other form that it exists in is the furanose form. The furanose form is the five-membered ring. It's the one that when you see DNA either in the chapter or in your biochemistry courses, you think DNA and RNA, I guess more specifically. So we're going to draw the puranose form. So the puranose form is going to be cyclizing not onto this oxygen to make a six-membered ring, but onto this oxygen to make a five-membered ring. So now, and I guess I'll raise this up a little bit to give me room. So now we'll draw the Haworth projection of the puranose form. So if we look at that, we're going to cyclize on this oxygen. Well, that's still going to, as we pick this up, see my fingers here, they're pointing out. I'm just picking that up. These two oxygens are going down. Again, I'm going to leave our stereochemistry unspecified at the anomeric position because we'll have a mixture of alpha and beta animers. Now, as I said, to get over there, we're going to cyclize on this oxygen, so we'll just bring this oxygen down, rotate this CH2 up, rotate that hydrogen over. We're just rotating about a bond as a mental operation. So when you do that, that puts this CH2 OH up and the hydrogen down. So that's the puranose form of ribose. The puranose form, boy, I can't talk today. So let me write puranose form and puranose form. And this is 24% ad equilibrium. And you should be proficient enough, and of course this is ad equilibrium in water. And you should be proficient enough to do these operations in your head that I've just done. Now, the best way to train yourself is to begin by working with models, plastic models are a great way to go. Dig them out from 51A. Computer models are a great way to go. And I've given you those tools to start with a little bit of imagination. Remember, I gave you glucose, just a little bit of imagination in rotating in pymol. That structure I gave you for glucose will allow you to see this relationship. Or, of course, you can just edit it and put in the hydroxy groups in the right place and delete it. But I've given you that linear form which is representing our fissure projection. I've given you a cyclic form that represents the Hallworth projection of the Pyrinose form. So as you work through these, you will become better at seeing the relationship in your head. All right, all of the sugars that I've drawn thus far, all of the monosaccharides that I've drawn thus far are aldo sugars, aldotetroses, aldopentose here, and aldohexose. Let me show you a keto sugar. So remember, keto sugars are based on ketones, so we call them ketoses. And I'll show you a ketohexose. And my philosophy has been to teach you some important ones. We're not going to become sugar chemists. We're not going to master all eight diastereomers of the aldohexoses and then all of the various possible ketohexoses. But let me give you one of them that you will know of by name. And again, I'm going to draw it as a fissure projection. And so this looks very much like glucose, except remember, glucose had an aldehyde up on top and had a hydroxy group off to the right at the position number two. Here we have a ketone group. We don't have stereochemistry at this position, but I have to draw the carbonyl somewhere. So we have three stereocenters. This sugar is fructose, or more specifically, defructose. You've of course heard of fructose, right? You've heard of it in the fruit sugar. It's in fruit. You've heard of it alas in high fructose corn syrup, which is produced by hydrolysis of starch. High fructose starch from corn. Corn is very starchy. Starch is a big polymer of glucose. And upon acid treatment, glucose can isomerize to fructose. Maybe I'll give that to you as a mechanism at some point. That'd be a good exam problem. Anyway, so coming down to fructose, so okay. So fructose is a ketoisomer, and fructose exists in a pyranose form, and it's 60% in the pyranose form. And again, all of this is at equilibrium in water. That would be cyclized onto this hydroxy, this hydroxy going to form an acetal with that carbonyl. And it's 40% in the pyranose form. That would be with this hydroxy cyclized onto that carbonyl. Now remember, we've had this theme that aldehydes are more reactive. They're less stable than ketones. And we see this in the sugars very nicely. So glucose, there's very, very, very little of the free aldehyde in solution, 0.003%. Fructose, there's still not a whole lot of the free ketone in solution, but there's a good bit more. There's about 0.25% of the ketone in solution. I'll say open form. Open form, by open form, of course, I mean the ketone. All of this is an aqueous solution. So I'll write in water. And to me, in my mind's eye, that kind of gives me this feeling about stability. We saw this with aldehydes and ketones. Acetone in water is stable enough that you have very little of the geminal diol. Acetone in water has about 50% as the geminal diol in water. The aldehyde is much less stable because you don't have two electron donating alko groups. And we see this here as well, that you have about 100 times more of the keto form, of the open form of the carbonyl form in fructose than you do in glucose. And so again, that sort of says, yeah, aldehydes are a lot less stable, a lot less happy than ketones. All right. This introduction to sugars, and indeed this whole chapter is only going to be an introduction, this really sets us up to introduce some chemistry of sugars. And the first chemistry I think I want to introduce is the hydrolysis of glycosides. We started, we looked at lactose as a sugar. Your body, if it does break down sugars, breaks it down into the monosaccharide units. Some people end up not being able to digest milk, meaning they don't have the enzymes to help break that glycosidic linkage to break it down. And then you have bacteria do it for you in the wrong place in your body and give you gas. All right. So I don't want us to start with a big sugar, but I want us to see another sugar. And so I'll show you another disaccharide here. So remember I mentioned starch would be one that we can break down as well. But I'll show you a simple one. And we'll use one glucose unit and one fructose unit. This is of course the one with one glucose unit and one sucrose, one fructose unit is sucrose. So another very, very important sugar. And in many of the glycosides you have an alpha linkage between the sugars. So starch has alpha linkages and cellulose has the more stable beta linkage. So alpha means down. So here we have our glucose unit. And now I'm going to connect to another ring. And that ring is going to be a fructose unit. And so we have a pyranose ring, a five-membered ring. And I'm going to go ahead and put in all my parts of fructose here. So I have a CH2OH group. Here's our anomeric position. I have an OH group off of this position going down. Remember people often do a little broken line to show it's in back. And then I have a CH2OH group going up there. So that's a glucose unit linked by a glycosidic linkage. We call this oxygen a glycosidic linkage. Glucose linked by a glycosidic linkage to a fructose unit. Now acid catalyzes the breakdown of glycosidic linkages. And so if we treat sucrose with acid in water, I'll write this as H3O plus. That would of course be a strong acid dissolved in water. HCl is widely used, although sulfuric acid in water could be used as well. Remember, consulfuric acid dehydrates sugars. But in water you don't have that. And if we go ahead and we treat our sucrose with strong acid, for example, boiling it up in 6 molar aqueous HCl, which is popular as a good way to hydrolyze a variety of different compounds, we hydrolyze the glycosidic linkage and get our self one glucose unit like so and one fructose unit like so. Oops, and I have dropped. Oops, I have in fact made a boo-boo in this structure here. And I want to correct this right now. So at this position, at this position we have a hydroxy group. At this position we have a CH2OH group. So just to correlate this with the structure on the other blackboard starting from the top, our one position, our two position, that was the ketone, it's now an acetal. Our three position, that's the hydroxy in the middle, our four position, our five position, that's that oxygen off on the bottom right next, you know, this position over here. And the last one is our CH2OH. All right, so let me finish correcting this structure. And so here's our structure of fructose. Now I've drawn this initially as the beta anomer here. And I've drawn this initially as one anomer. And I've drawn this eventually both of them equilibrate to a mixture of alpha and beta anomers. So I've drawn this initially as one anomer. All right, one of the things about these molecules, one of the things about organic chemistry in general is that molecules behave as their functional groups do. And if you look at the molecule of sucrose, you will see embedded in the structure two acetal linkages. So you will see an acetal group over here and an acetal group over here. And we know what acetals do in aqueous acid. They hydrolyze. And we know the mechanism for that. The molecule's bigger, but the chemistry is the same. And so the mechanism for this is going to involve, and I'll just sketch this out briefly, the mechanism is going to involve protons going on to oxygen, pushing apart to give an oxocarbenium ion, a leaving group leaving. And then it's going to involve attack by water. So let me summarize that. Here's our fructose molecule. And so we're in aqueous solution. And so we can imagine protons go on, protons go off in aqueous solution. And so the proton, all the different oxygens. But since we're breaking the anomeric linkage, since we're breaking the glycosidic linkage, the point at which we're set up to break that linkage is when a proton goes on to the glycosidic linkage oxygen. And so I'm going to walk you down that productive pathway, like so. In other words, oxygens, protons can go on and off other oxygens, but this particular pathway happens to lead us somewhere, and so I will show you that one. So we protonate this oxygen like so. Now, that's very good because that sets us up for this oxygen to leave and for us to form an oxocarbene ion. You saw it. You got it in your head there? In other words, we push in with that lone pair of electrons. It pushes out, pushes electrons onto the oxygen. And now because our sucrose molecule is so bloody big, I'm going to have to take us across to the other blackboard. And so I guess let me continue here to get us to the other blackboard. I will show an equilibrium arrow, and then we'll just swing over here. And now use your imagination, and we have a molecule of glucose. Told you you're going to see a lot of glucose. And we have the oxocarbene ion from fructose, and so I'll draw that here. And now to complete our equation, the oxocarbene ion isn't stable. And so to complete our equation, water can attack, and I'll shorthand things, and we can lose a proton. And I will simply say here's our fructose structure. And so we can do it from the other opposite direction. Thank you. Yes. Okay. And so it has been very aptly pointed out that you can do it by using this oxygen to push out fructose. Now here's why I did it the way I did it. My way is a little more right, a little more real. Just as the aldehyde is less stable than the ketone, the oxocarbene ion from an aldehyde is less stable than the oxocarbene ion from a ketone because of that electron donation of the alkyl groups. And so I pushed to give the better oxocarbene ion, but at your stage and at your learning, yes, absolutely we could go either way. So that gives us kind of an introduction, and we can see lots and lots of other chemistry. For example, and I'm not going to take you through the details of the mechanism because I expect at this point you should be able to go ahead and do this mechanistically. You've now had both this little review of oxocarbene ion chemistry as well as all the acetal chemistry, but I want to show you a fundamental reaction. If you take acid and a sugar, so here in the previous example we saw a hydrolysis of a glycosidic linkage. Now I want to show you a formation of a glycosidic linkage. Call it a formation of a glycoside. If we take an acid and use an alcohol as solvent, so you've got lots and lots of alcohol, CH3OH or ethanol, I'll do this with methanol. And again, of course, you can't go to chemstock room and buy H plus. That means you do this with HCl or H2SO4 in methanol. Now by the exact same type of chemistry, we can form a mixture of the beta and alpha glycosides. So we can form a mixture of the beta and alpha glycosides. So on the right, on the left, I have the beta methyl glycoside of glucose. On the right, I have the alpha methyl glycoside of glucose. And of course, both of these form by protonating the hydroxy group. So you kick out to give the oxo-carbenium ion like so. And then methanol can attack from either the beta phase to give the beta-anomer attack and loss of a proton or from the alpha phase to give the alpha-anomer. So in your mind's eye, protons go on, protons go off. All different positions of the molecule. But if we protonate on this hydroxy, we can push it out with the lone pair to get the oxo-carbenium ion. And now we're in alcohol. We have a huge excess of alcohol. And alcohol can attack from one phase or the other. So you're kicking up the hydrogen that, oh, the methanol? The methanol is, oh, attacking at the carbonyl. So I was only showing it from one side or the other. So methanol attacks the carbon. We form a new carbon-oxygen bond. At that point you have protonated methanol. You lose a proton. We're in this vast sea of methanol. Protons go on. Protons come off. So you're always pushed up. Thoughts. Your mind's engaging with this, right? You're figuring the mechanism in your head. And this is good. This is good. Because ultimately what you're doing is working through and wrestling with the motion of electrons and the formation of bonds here. Can we reform the glycosidic linkage with the syn? Can we reform the glycosidic linkage? The syn mechanism, like the OH gets protonated and gets dehydrated. Ah, in other words, can we go back? Yes. Can I mix two molecules of glucose, for example, or a molecule of glucose and a molecule of fructose and go back? In theory, great question. Really important. And a contemporary super, super important problem in sugar synthesis. Now the problem with going back is we're always dealing with an equilibrium. We took out, we added water in the hydrolysis direction. You want to take water out. And the problem is the things that take water out also react with the other hydroxy groups. Puricylpheric acid is great at taking water out. However, puricylpheric acid also ends up reacting and hydrolyzing the sugar. So yes, when people want to reform glycosidic linkages, they do this by something very special. It's the same idea. Rather than having a hydroxy group at the anomeric position, they make the hydroxy group into a good leaving group, something that won't go back. And then the reaction goes. They can use chloride at that position. They can use various derivatives of sulfur that often get used. It goes beyond the scope of this course, but there's a beautiful and rich sugar chemistry. And we're just getting, pardon my horrible pun, a tiny little taste of sugars here. All right. So I want to continue with our taste of sugars talking about some reactions. So in these two examples, the hydrolysis of sucrose and the formation of a methylglycoside, we saw that all we're getting is the behavior of aldehydes, hemiacetals, and acetals. Even the anomerization was just acetal behavior. Sugars also have lots and lots of alcohol groups. And we've learned lots of chemistry of alcohols. Your textbook chose to give you a few examples, and I'm going to take you through those. There's also some nice examples in the homework problem, but there's plenty more rich chemistry of sugars. All right. Think way, way back to 51B. And you learned the William Sinether synthesis. You learned that if you took an alcohol and a suitable base, and I'm deliberately being dicey here because there are lots of bases and lots of conditions, and I'll give you one for sugars in a second. And an alcohol halide, I'll call it R prime X, suitable for SN2. Now what do I mean by suitable for SN2? Well, methyl is great. Methyl iodide, methyl bromide are great at SN2 reactions. Allyl benzo, very, very good. Allyl is double bond. It's a propenal halide. Benzene CH2 halide. Those are all really good. Ethyl OK as well. By the time you get to branch like isopropyl, not so good in the William Sinether synthesis, you go ahead and get an ether. Well, sugars can do the same chemistry. And again, with a suitable base, some of the base chemistry is a little special for sugars. I'm going to give you an example that actually is basically one of your textbook problems and is very, very close to things that you've seen before in the William Sinether synthesis. Suffice it to say there are many bases. So let me take our good friend glucose here. And I'll take it as a mixture of alpha and beta anomers. And we're going to treat it with a strong base sodium hydride. And I'll put in parenthesis XS. And I'll give us benzo bromide or benzo, let's say benzo chloride as a halide. And again, we'll use an XS of that. Normally, unless I indicated otherwise, even if I didn't write XS, I would mean that you use plenty of it. Basically, your sodium hydride can pull off all the different hydroxy protons, making them into alkoxide. Sodium hydride is a very strong base. And your benzo halide is a good alkylating agent in SN2 alkylation. So one can go ahead and cleanly and chemists abbreviate the CH2 benzene group as BN. So you can cleanly SN2 alkylate all of the exposed hydroxy groups. And this is a beautiful example not only of the chemistry of sugars but also of the fact that basically all the stuff you learned in 51A and 51B still works even in much bigger and more complicated and biological molecules. Now again, not trying to get too diverse, not trying to show you too many different reactions, I'll keep the things that are in your chapter. So another reaction you learned, in fact, that we learned just back in the quarter, the earlier in the quarter, was that you can make an ester by reacting an acid chloride or an acid anhydride with an alcohol. And so if I take some alcohol, ROH, and I take, I'll write it out here, acetic anhydride or acetyl chloride and we take a suitable base like pyridine that our alcohol reacts to give an acetate ester. And sugars have lots and lots of alcohol. And another reaction that works very, very well is to make esters, particularly acetyl esters because acetic anhydride is small and it's highly reactive. And so again, I will take our good friend glucose. You could do this with galactose if you wanted. You could do this with mannose. You could do this with ribose. But if I take our good friend glucose and I treat it with acetic anhydride, which I'll abbreviate as AC2O, that's just that structure up there. And pyridine, which I will abbreviate Pyr, remember pyridine is the heterocyclic base that's less basic than triethylamine because the lone pair of electrons is in an sp2 orbital and held more tightly. It's a very mild base, albeit somewhat toxic. Now we get the acetate will abbreviate that OAC. Remember that's just an abbreviation for that. And so we can make the acetate of glucose. All right, so we've seen chemistry of alcohols. We've seen chemistry of hemiasatals and acetals. Let's focus in on some chemistry of aldehydes. So the aldo sugars have an aldo group and if it's not tied up, if it's in a hemiasatal, that aldehyde group is available. And so just to refresh, we learned that aldehydes are very easy to reduce when we were talking about ketones and aldehydes. We learned, for example, that sodium borohydride, NABH4 is a wonderful mild reducing agent. Now one of the things about sugars and solvents is, you know, like dissolves like. Generally sugars like to dissolve in polar solvents. Water, methanol, things like that. They generally are not so soluble in things like tetrahydrofuran, which is much less polar. So methanol, water, great solvents for sugars. So I'll show you a reduction of a generic aldehyde with methanol to RCH2OH. We add hydride anion and then protonate the resulting alkoxide to give the alcohol. And so it shouldn't surprise us that sugars have some similar chemistry. And so I will take a sugar. I'll get away from my friend Glucose here. We'll come back to him in a moment. So I'll take a different sugar. One that you will have unbeknownst to you probably have heard of. Who's chewed sugarless gum here? Okay, if you look on the back of sugarless gum, you will often see that it contains sorbitol and mannitol. Now this sugar is called mannose, or more specifically D-mannose. Mannose is the same as Glucose except it's epimeric at the two position. If we take D-mannose and we reduce it with sodium borohydride, there are of course other reducing agents including catalytic hydrogenation, which is probably how this is done industrially. So if we reduce our D-mannose, we get D-mannitol, M-A-N-N-I-T-O-L. Kind of makes sense as a name. Mannose goes to mannitol. Doesn't make any sense why the common name for the alcohol you get when you reduce Glucose is called sorbitol, but you will see that on your gum there is a mixture of sorbitol and mannitol that is a mixture of epimers at this position. All right, so all of this chemistry we're seeing here really is very familiar and in the back of your mind's eye and the back of your head can be this little footnote. Glucose exists in equilibrium between the Pyrinose form and the open form. Even though there's very little of the aldehyde form because of that equilibrium, the aldehyde can form, be reduced, more aldehyde forms by Le Chatelier's principle, it's reduced, and eventually all of our Glucose or all of our mannose is reduced to sorbitol or mannitol. All right, so other chemistry and this will set the stage for talking about sugar structure determination. So when we talked about aldehydes, we learned that aldehydes were very easily oxidized by mild oxidizing agents. Even for example, silver oxide, AG2O in aqueous ammonia NH4OH or aqueous NH3, however you like to write it, ends up oxidizing the aldehyde to a carboxylic acid. And you can do this selectively in the presence of alcohols. So it shouldn't surprise us that you can go ahead and do this same chemistry with sugar aldehyde. So for example, I'll come back to my friend Glucose here. I just needed to pick some examples for today's class. So I'll take Glucose, works with all the sugars in which you have a free aldehyde group. And so if I take Glucose and I expose it to these conditions, so I'll write D Glucose over here. And we expose it to the same conditions and just to save on writing, I'll write a ditto mark. Now we get the corresponding carboxylic acid. And this has a much more sensible nickname. This is called D Gluconic Acid. Wouldn't expect you to know all of these names, but they're kind of fun to roll off the tongue. All right. When one does this reaction in the laboratory, and it's often done as a laboratory demonstration of this property, what happens is the silver gets deposited on the flask because you're going from silver oxide. It's acting as an oxidizing agent. You're going to silver metal. It's getting reduced. The silver metal gets deposited on the flask and it makes a beautiful mirror of silver. The whole flask in about 10 minutes of shaking becomes a bright silver mirror. Well, nowadays there are lots and lots of good ways to tell sugars apart. But back in the 19th century, people had only chemical reactions and only properties. And so it was noted that some sugars, like glucose, reacted with silver oxide, silver nitrate, pneumonia makes silver oxide, reacted with silver nitrate and pneumonia to give a bright silver mirror and others like sucrose under the same conditions. I'll just put ditto. Go to no reaction. You don't get a bright silver mirror. And so it really, really stands out. The sugars that reacted were called reducing sugars. So glucose is a reducing sugar. Sucrose is not a reducing sugar because it doesn't react in this reaction. And this became a common classification. If a sugar has what basically is a free aldehyde group, in other words, it's a pyrinose or a furinose in equilibrium with an aldehyde, then it reacts. If, on the other hand, like sucrose, all of the aldehyde groups are tied up by an acetal linkage and sucrose is just one aldehyde group, then it doesn't react. And that would be called not a reducing sugar. And so this test, this silver mirror test, got called the Tallins test after the inventor for reducing sugars. All right. So one of the themes, and we'll see this for the rest of today's lecture, one of the themes of organic chemistry historically has been what's the stuff of life made of? What are the molecules that make up the food that you eat? What are the molecules that make up your skin, your hair? We now know starch and cornstarch and wheat bread is an oligosaccharide. We know that it's made up of glucose units. And we know that the proteins in your hair and your skin and your arm are all made up of amino acids. But the end of the 19th century, the beginning of the 20th century, this was when people discovered that. And so the chemistry we're seeing now and some of these questions like categorizing is a sugar, a reducing sugar or not, is part of that understanding. So I want to show you a couple of more reactions and go somewhere with it. So I'll give you one more, two more reactions of glucose. Now, aldehydes are very, very easy to oxidize. And so there are lots and lots of oxidizing agents that can oxidize or reducing sugar. And the another one is bromine. Another one is copper, copper 2 or copper 1, I forget now. That's the felling test for sugars. But bromine is another one from your textbook. And so I'll just show you that. Bromine can also take glucose to gluconic acid. So just as we did with the Tallins test. Now I want to show you another one. And then we're going to go somewhere. So again, I'll take my friend glucose. And now we're going to treat it with a different oxidizing agent. This is a really neat reaction. We won't talk about how this occurs. We're going to take this with nitric acid in water. Your textbook doesn't mention heat, but usually you do this with boiling waters, in boiling waters you do it at 100 degrees. Nitric acid is a good oxidizing agent. It's not surprising that the aldehyde group ends up getting oxidized to the acid group. And it's probably not surprising since we've seen lots and lots of conditions that don't touch alcohols but do touch aldehydes. It's probably not surprising that the remaining alcohol groups in the molecule remain intact with one exception. And that is the primary alcohol group also gets oxidized to the carboxylic acid. And so now we've transformed glucose at the top end and the bottom end. And again, things have funny names. This compound here is called deglucaric acid. And again, I wouldn't expect you to know this. These names just are fun to say. What is fun, what is interesting of course and what we want to pick out and picking out the deforest from the trees here is that it is a diacid. That is a molecule with two carboxylic acid groups in it. And it's sometimes quite migrating to sum up the place you All right. So I want to now take us back to the beginning of the lecture. Now at the beginning of the lecture we started with the aldotetroses. And I drew out the structure of the two d-aldotetroses. And I know people say organic chemistry is about remembering things. It's not. It's about thinking. We've seen mechanisms, protons. But now I'm going to ask you to do something. I'm going to ask you to forget something. Forget which aldotetros is which. And more, get into the way back machine. When we didn't know which aldose is d3-os and which aldose is d-erythroses. Get back into the way back machine when we didn't have IR spectrometers and NMR spectrometers to look at things like functional groups and coupling constants. People could burn molecules and measure how much carbon dioxide was produced and how much water was produced. You could figure out the empirical formula that way. And people knew the colligative properties of matter and could knew the freezing point depression and could figure out the molecular weight that way. But you couldn't directly ask questions of stereochemistry like you can now with an NMR spectrometer telling you a cis-alkene from a trans-alkene. And come back to the roots of organic chemistry where the question is what is the stuff of life made from? And put yourself in the laboratory of Emil Fischer who won the Nobel Prize in 1902 for his work with sugars. His name permeates not only the Fischer projection but the Fischer esterification and also a synthesis of proteins, of peptides that interested him after he tackled sugars. He was going after all of life. He also got some of the nucleic acid bases. And so now we look at what you could do then and you go back to the time of Louis Pasteur and Tartrate and optical activity and Labelle and understanding that carbon was tetrahedral and understanding the origins of optical activity and only being able to measure whether light is rotated, plane polarized light is rotated and how much it's rotated and melting points in formulas. And you ask what are the structures of all of the eight aldohexoses before I should say diastereomeric aldohexoses because of course being thrown in anti-immers there are 16. The four diastereomeric aldopentoses and the two diastereomeric aldotetroses. And we'll just ask the simple question for the aldotetroses. Fischer extended this all the way up. So let's look at what you could do. All right, when you take one aldotetros and you treat it with nitric acid and water and heat at 100 degrees Celsius you get an optically active diacid. The diacid now draw the structure in just a second is called tartaric acid, the diacid in which you oxidize the upper and lower position. And when you take the other aldotetros and you subject it to the same you get an out, you get a diacid that doesn't rotate plane polarized light. This is optically inactive. All right so let me go ahead and draw using Fischer projections. Oh yeah, ditto mark. Same conditions. All right so let me write the two structures here of two diacids. Which of these molecules has a plane of symmetry in it? The one on the right. There's a plane of symmetry here. Molecule that has stereocenters but has a plane of symmetry is a mesocompound. It's optically inactive. And with two carbons on either end, four carbon diacid and two hydroxies in the middle is called tartaric acid. The structure on the right then is meso tartaric acid. The structure on the left is optically so I'll write optically inactive up here for the one on the right. The structure on the left lacks a plane of symmetry. It's optically active. I'll write optically active over here. And this particular molecule is called d tartaric acid. It's found in grapes. It's the structure that Pasteur was able to resolve enantiomers from. Okay so now we have a little logic problem. Your textbook gives you tons of logic problems. I've tried to cut them back on the homework a little bit because I think they go a little nuts on it. This is the history of sugar chemistry they're giving you. All right so that means if the one gives an optically active product, the structure of that aldotetrose had to be this. And so this, the one that was called threose, then fissure nu was this structure. And the one that was called erythrose, fissure nu was this structure. And that's pretty smart. All right now I will show you the real genius bootstrapping of fissure and we'll introduce one last reaction. And that is the way that fissure could bootstrap himself up to all of the aldohexoses starting with very small molecule. And so what I'll introduce finally is the Kiliany fissure synthesis. Your textbook introduces the bold degradation, the opposite, and I'll let you read about this. But I want you to see the forest from the trees. All right so how do you bootstrap yourself up? How do you build up the sugars and then hence how do you go ahead and puzzle out all the stereochemical questions of the aldotetroses, the aldopentoses, and the aldohexoses? And ultimately how do you really answer what the stuff of life is made of? Now fissure started with deglyceraldehyde. And all the chemistry now you have, in fact you have all the chemistry you need to get up all the way to the aldohexoses although you won't. If you take an aldehyde and you treat it with hydrogen cyanide we already learned what happens. You form a cyanohydrin and you do so in a non-stereo specific fashion. In other words you get both diastereomers so we formed a carbon-carbon bond. We've introduced a nitrile group. Now we've learned lots and lots of chemistry of the nitrile group. We learned that the nitrile group was in the carboxylic acid family. We learned that under the right conditions you could with, for example, aqueous acid hydrolyze the nitrile group to the carboxylic acid group. We also learned various conditions for reduction of nitriles and one of those conditions is catalytic hydrogenation. So imagine now that we go ahead and we carry out catalytic hydrogenation with hydrogen and palladium. It becomes a catalyst but you can attenuate the reducing ability of palladium by poisoning it with a heavy metal. You learn this in the reduction of alkynes with lindlar catalyst. Palladium can be poisoned by metals like lead and barium, heavy metals that reduce its ability to hydrogenate that attenuate it. And so if we have palladium on barium sulfate and you do this in water you end up reducing the nitrile groups down from the nitrile slash carboxylic acid oxidation state, that plus three oxidation state, to the aldehyde oxidation state. Remember carboxylic acids are plus three. It's the highest oxidation state you can go without getting to the carbon dioxide oxidation state. So you reduce the triple bond to a double bond and you get, now come to your question mark here, what will inherently be your implicit question mark in a second. And so you bootstrap your way up one carbon to erythrose and threose, or threose and erythrose as I've written them on this blackboard. And so Fisher could start with one molecule at the time he didn't know the absolute stereochemistry but he could start with a molecule of deagolous or aldehyde and convert it to erythrose and threose which he could then tell apart by their optical rotation properties upon oxidation. And he could bootstrap himself up to the pentoses and so forth. So the one question here you probably have is wait a second, where did that nitrogen go? Well the primary imines are not stable and so in water under the conditions, your textbook shows acid that's fine too but honestly in water they hydrolyze. In water the imine hydrolyzes to the aldehyde and so the sequence of cyanohydrin formation followed by partial reduction bootstraps you up a level. All right well I think this is where I would like to end up. We have now had all of the basics of sugar chemistry. You'll get some more exposure through the homework. We'll finish off our final week talking about the chemistry of peptides and the chemistry of organometallic reactions and we'll just get a little taste of that chemistry from chapter 28 and chapter 26.
This is the third quarter course in the organic chemistry series. Topics covered include: Fundamental concepts relating to carbon compounds with emphasis on structural theory and the nature of chemical bonding, stereochemistry, reaction mechanisms, and spectroscopic, physical, and chemical properties of the principal classes of carbon compounds. Index of Topics: 1:40-Aldotetroses 9:16-Aldopentoses 11:40-Ribose 18:02-Ketoses 22:47-Hydrolysis of Glycosides 36:34-Formation of Glycosides 43:51-Alcohol Groups in Sugars 48:05-Making Esters 51:03-Reactions of Aldo Sugars 55:32-Sugar Structure Determination 59:12-Reducing Sugars 1:00:07-Tollen's Test 1:05:26-Which Aldotetrose? 1:15:24-Kiliani-Fischer Synthesis
10.5446/19420 (DOI)
All right, give yourselves a big hand. We've done five quizzes in the class. We've got one last one to go, which is sort of a bonus in the sense that I dropped the lowest quiz. We've also gone through what I consider to be some of the most intellectually challenging material of the course. We brought in ideas of mechanism. We brought in ideas of synthesis. And now we're kind of winding up the course. And I want to cover some topics that are, I think, more interesting and in some ways bring back some old themes and bring in some new themes as well. So we're going to spend today, and we're going to spend Thursday talking about carbohydrates. And carbohydrates, in one way, is a very old topic in organic chemistry. Carbohydrate sugars are central to so much of life. They are, of course, the sugar that you put in your coffee. They are the glucose and fructose that make up that sugar. They are the components of starch and cellulose. In other words, paper on your desk and the cornstarch and so forth and potato starch in the vegetables that you eat. The backbone, along with phosphate, sugars, ribose, or the backbone of DNA, they're attached to many biologically active natural products. Sugars coat the surfaces of your cells. Your blood types are determined by which types of sugars. You have on the surface of your blood cells, and in turn give you antigenicity, give you an antibody response to getting the wrong sort of blood type if you get an infusion. So sugars are fantastically important. We are coming back to an old theme that you learned in 51A, and that's stereochemistry. I think the toughest thing about learning sugars isn't the stereochemistry. It's the different representations and interrelationships. We're going to spend some time today talking about structure and stereochemistry of sugars. I spent last night and this morning making some special tools for you to help understand some of the representations that are often used. Personally, I'm a big fan of plastic models. For the Darling models you used in 51A and maybe in some of the so-called dry labs associated with your course, and I recommend you bring them back to learning this chapter. Oh, no, I see tears here from the models. You can also use your computer. I will let you use models on the final exam, so it's useful to have them, plastic models. So it's useful to have them complement things. All right, I want to start with literally a simple sugar with sort of the most fundamental or maybe the most common sugar, and we're going to draw it in a chair conformation. The sugar that I'm drawing here is glucose. It's kind of easy, I like it, because when I draw my chair like so, all of the substituents are in the equatorial position, so it's very easy to remember the structure of glucose. Now sugars have an aldehyde group, and we're going to talk more in a second, but for the most part they exist as cyclic HMI acid towels. I'm going to draw, we have another stereocenter for a cyclic HMI acid towel, and I'm going to draw that hydroxy group at this position, at the one position that we'll learn is called the anomeric position. I'll draw it equatorial. This molecule is called beta D glucose, and so it's a member of the class of carbohydrates I guess if you go to the gym you might call them carbs of course, it's a nickname. Its molecular formula is C6H12O6, and if you think about it, then the reason it gets its name as a carbohydrate is that the formula is carbon plus H2O, and literally if I take some sugar, if I take some table sugar, and I take sulfuric acid which is very dehydrating and can yank all the water out and carry out a whole bunch of reactions. If you've ever seen this done, you just put it in a beaker, pour in, put some sugar in a beaker, pour on some consulfuric acid, and this big snake of carbon comes out of the beaker, this big rod of frothy carbon and sulfuric acid along with a little bit of smoke and so forth. Anyway, I'm not going to do that demonstration here in part because it's kind of hazardous, but it's a lot of fun. Aldoes is a member of a class of carbohydrates, a broad, broad class of carbohydrates that we call aldoes. The reason we call it an aldose is that when we go ahead and unwrap the structure, when we break up the hemisetal at the one carbon, you get an aldehyde. There are also sugars where if you break up the hemisetal, you get a ketone, and those are called ketosis. We'll talk about those later. Glucose is a six carbon sugar. We number it from this position, one, two, three, four, five, six, and so glucose is called an aldohexose, hex is six. I guess to be consistent, I will write an aldose to indicate it's one of many, many. There are a bunch of other things things get called because glucose has a six-membered ring containing an oxygen in the closed form, in the hemisetal form. We call it a pyranose sugar. Pyran is a six-membered ring containing an oxygen atom. Tetrahydropyran is a saturated six-membered ring containing an oxygen atom. Glucose is a derivative of tetrahydropyran, so we call it a pyranose. The other important ring containing oxygen is a five-membered ring containing an oxygen, the aromatic compound with double bonds, and it is called furan. If you have all hydrogens on the ring, if the ring is fully saturated, you call it tetrahydrofuran. We've seen that THF is the solvent, and so there are other sugars that have five-membered rings in them that you would call a furanose or a furanose form of the sugar. And I guess as long as we're talking about names here, we would also refer to glucose as a monosaccharide. Glucose, of course, means one saccharide, well, sugar. I want to give us some contrasts in structure and in stereochemistry by drawing a disaccharide at this point, and it's going to introduce some basic concepts here. So we're going to start with drawing another pyranose form of a ring. We're going to have two of these linked together, so two chair cyclohexanes. And I'm going to go ahead and draw everything the same on this ring as I did for glucose, except at the four position, I'm going to, instead of having the hydroxy group in the equatorial position, I'll put the hydroxy group in the axial position. We're going to make molecule with two sugars in it. It's one that you might have consumed this morning. One that actually is good for you. Well, maybe I guess all sugars are okay in moderation. Okay, so we're going to link to another ring here. And this ring we'll have as a glucose type ring, like so. So here's our disaccharide. Disaccharide is lactose. I guess my drawing isn't the prettiest in the world. I'm always delighted when I look at people's notebooks and see they're drawing so much prettier than mine. So lactose is a disaccharide. And I think there are a couple of interesting take home messages that we get from this. First of all, sugars can be linked together, one to the next, to the next. Much for example is a long, long chain of sugars as is cellulose, basically a polymer of almost infinite length. Now you might look and say, well, it's a little different looking than glucose. I mean, we basically formally removed one water molecule. So if you write out the molecular formula of lactose, it's C12H2O11. And so you'd say, well, we don't have the same ratio of carbon to hydrogen as we had because we've connected in glucose. But if you notice, it's still carbohydrate. It's still effectively carbon plus H2O. And in this case, 12 carbons plus 11 H2O's. In the case of glucose, 6 carbons plus 6 H2O's. So if you look at our lactose, as I said, we have two units in it. We have our glucose unit. And now we have another sugar unit in it. This is a galactose unit. So galactose, let me draw out galactose and glucose in just a second. But I just want to make one last point. We have a linkage from the one position of glucose, right? So this is the one position. And then to the four of the one position, I'm sorry, of galactose, and that's the four position of glucose, right? We number our way around the ring, 1, 2, 3, 4, 5, 6. And so we call this a 1 to 4 glycosidic bond, glycosidic linkage, or glycoside bond. I want to draw out the units, the subunits here in galactose. So I'll draw out the two sugar units. I'll redraw glucose again. It pays to practice a little bit in your drawings. And I've got to say I'm no artist as far as cyclohexane rings go. Basically, the theory is you're going to be making parallel lines for the equatorial bond for this OH group is parallel to the CO bond for this one. The equatorial bond to this OH group is parallel to this one. As I said, I'm not much of an artist, but I can get my ideas across competently. All right, so galactose, so this is glucose, or more specifically beta-D glucose. We'll talk about what that D means in a second. And now we'll draw galactose, more specifically beta-D galactose. I'll talk more about that beta in a second. All right, so everything is the same over here except as I was indicating when I drew our molecules, now we have a different stereochemistry at the four position. So two isomers that have the same connectivity, all of the same atoms connected together in the same way, but just differ in the stereochemistry of one position are diastereomers. They're stereoisomers that are not enantiomers. Remember when you learned about stereochemistry, you learned about enantiomers, compounds that are non-superimposable mirror images. You learned about diastereomers, stereoisomers that are not enantiomers, and then you learned about constitutional isomers, molecules that have different connectivity, different arrangements of atoms. All right, at this point I want to draw another structure and I'm deliberately proceeding reasonably slowly and methodically here because I think it really takes some time to bring all these ideas into your head and to dust off the cobwebs on some of the stereochemistry and structure that you learned back in 51A. So I'm going to draw a different structure here. We're going to do everything the same as glucose with one exception. I'm going to now, instead of having our stereochemistry at the one position be equatorial instead of having the hydroxy group at the one position be equatorial, I'm going to have our hydroxy group at the one position be axial. Now this is alpha D glucose and in the convention of organic chemistry you have beta as the up position, the top face of the ring, alpha as the bottom face of the ring. So the OH is pointing down to the bottom face as we've drawn it at what we call the anomeric carbon. So the carbon that makes up the hemiasatow is very, is occupies sort of a privileged position if you think about it because unlike all the other positions your stereochemistry there depends just on how you've closed the hemiasatow whether you've closed it so that the OH group is equatorial or axial. And so because of this very special diastereomeric relationship in sugar chemistry we often have yet another word for diastereomer involving the hemiasatow to labile position so we call it, we give it a special name as I said this is the hemiasatow position and so we call this ananomer. So just as we would say that beta D glucose and beta D galactose are diastereomers we would say that alpha D glucose and beta D glucose are anomers they have a special diastereomeric relationship to each other. They're still diastereomers but they're a special type of diastereomer that often gets called ananomer. So I'll write that down. Okay. So most diastereomers are stereochemically stable in other words if I have a bottle of lactose and I go away and go away for a long time and travel around the world and come back I still have a bottle of lactose it would never become a bottle I'm sorry if I have a bottle of galactose it would never become a bottle of glucose. If I have an aqueous solution of galactose it is stable as galactose. But this is not the case for anomers in which you have a hemiasatow. We've already learned that hemiasatows are not stable compounds they are in equilibrium with aldehydes. Now in the case of cyclic hemiasatows we learned that they tend to favor the closed conformation. In the case of glucose that's really, really, really strongly a preference and nevertheless at equilibrium you have a teeny tiny bit of the aldehyde form of the open form. In other words alpha and beta D glucose can interconvert in water and exist in equilibrium. So I'll write this as an equilibrium I'll say in water because in the solid state the crystal lattice keeps them stable but in water you have all sorts of chemistry occurring involving carbonyl groups and so the alpha and beta forms of D glucose can interconvert at equilibrium you have a 36 to 40 to 64 ratio. And I want us to think ourselves through this interconversion process and I'm going to sketch it out here in our mind's eye. So I'll start with alpha D glucose. We're not going to write a detailed mechanism. I think by this point I'm hoping that you are on top of carbonyl chemistry enough to be able to work through the mechanism. Remember in the case of a cyclic hemiacetal catalyzed by acid or by base but we'll think acid and even in water you have a little bit of acid you have 10 to the negative seventh molar H3O plus in neutral water. You can protonate all your oxygen atoms. If you protonate this oxygen atom you can open the cyclic hemiacetal and so I'll write a tautomer here. I will write the isomer in which we've opened this linkage and so now we have our aldehyde. Everything else is the same. So we've just opened our linkage here to form the aldehyde. Remember mechanistically you can think of protonate on this oxygen, push electrons down, kick out that oxygen. Now you have an oxocarbenium ion, take off the proton. All right now if we imagine rotating about this bond here like so and I'm just going to say we're talking equivalent structures here. Generally when you rotate about a bond you don't think about a structure as being different you think about it as being a related as just being a rotomers. So I will rewrite rotating about the bond here like so. So all I've done differently now is rotate about the bond to the aldehyde. And now if you imagine closing up the structure here so we've started with alpha D glucose. We've envisioned opening it to form the aldehyde. At equilibrium here you have about 0.003% of the open form at equilibrium. And now if you imagine just re-closing this we've gone to the beta form. We've gone from the alpha anomer to the beta anomer. Question. Can you do that for lactose? Great question. Yes and no in the linkage. So the question is very, very good. And I'm glad you asked it. Okay. Oh lactose, not, yeah lactose, right. Absolutely very good question and I am delighted, delighted that you asked it. So let's go back to our lactose structure. Alright, in our lactose structure there are two types of anomeric carbons, two types of carbons at the one position. There's this carbon which has a hemiasatal and then there's this carbon here which has an acetal. Remember a hemiasatal has a hydroxy group on it. An acetal doesn't have a hydroxy group on it. And so the hemiasatal form absolutely can equilibrate. And so the structure that I drew for lactose that's in your milk and whatever you drink in the morning on your cereal, cream in your coffee, the lactose that's there, the lactose that's in your ice cream has an equilibrating mixture of the beta and alpha anomers in the glucose unit. However, unless you have strong acid and by strong acid now I don't mean neutral water or a little bit of dilute HCl but unless you have a very strong acid that can break apart an acetal, boiling HCl solution or boiling acid, the linkage, the beta linkage off the lactose unit is stable and doesn't undergo interconversion. So I will write stable over here and when something interconverts we say it's labile for this position. Good question, good thought. Other good questions? Can a galactose have a carbon one like a steric shift and if so like a wool type molecule because? Can galactose, so the galactose unit, this subunit here at carbon one free galactose, absolutely. Okay, great, another great question. So, and I want somebody to answer for me here so we saw that we had, I drew the beta compound, what do we call this form of galactose? Alpha. So this is alpha D galactose and I'm going to tell you something else right now. So it's really good to have a few pieces of core knowledge that you keep in your head because you use those. We've done this with, when we talked about pKa's I talked about, yeah I know the pKa of a ketone, call it 20 whether it's a ketone or an aldehyde, know the pKa of an ester, know the pKa of LDA. That core knowledge is very useful because you can build on it. There are lots and lots of different monosaccharides. I do not, in my own head, I'm not a practicing sugar chemist, keep all of the structures of all the different monosaccharides. I could if I wanted to but it's just not useful for me. But glucose and say the one diastere, one diastere or galactose are useful things to know because it's something that you can hold on to and then you can build on it. So when you see various other sugars, you see tallows or something, you can understand relationships to them. Other questions at this point? Yeah? Why is it that if you change the position at the one group, if you change the stereochemistry at the one position, it's not a different sugar and if you change it at the four it is. The same basic idea because alpha and beta D glucose are labile because they interconvert. We'd say they're rapidly interconverting, they're interconverting, they're the same basic molecule. But for ones where you have stable diastereomers, then you'd say they're different. They're very, well I mean they're both different but there's this question of time scale. If I put beta D glucose into a bottle and come back, I have a mixture in water of alpha and beta D glucose. So they're different but they're not that different. They interconvert. So that's why we categorize them. And actually let me build on that a little bit. So beta D glucose has an optical rotation. Optical rotation means the amount that you rotate plain polarized light. If you've ever taken a parapolarized sunglasses and crossed the lenses, you know that when you get to a 90 degree angle light doesn't come through or if you ever have a parapolarized sunglasses and you put them over if you have an LCD watch or an LCD, maybe even the LCD screen on your phone or computer and you rotate it, you will black out because you have polarized light in many of these sorts of devices. It will go black at one angle and at a right angle it will be completely transmitting or fully transmitting of light. It's the same type of thing with sugars. They rotate that polarized light and this is one of the characteristics of optically active molecules and molecules where you have a single enantiomer and they're stereochemically active. And the degree to which glucose rotates plain polarized light is called the specific rotation and if it's used traditionally the sodium D line, that bright yellow line, if you've ever been the east coast you've seen lamps on the, you've seen lights on the highways there. Those bright yellow lights are called sodium lights. That's a 522 I believe nanometer light. Anyway, that one is often used and you rotate it by 19 degrees. Now alpha D glucose is a different stereoisomer and so it rotates plain polarized light. To a different extent the optical rotation of alpha glucose is 112 degrees. They call it specific rotation if you want to be exact in what you're calling this rather than optical rotation but optical rotation I think is a little easier to understand. Now what's cool about glucose and this comes back to your question there about why we don't consider them different molecules or we consider them different but not that different is if I go ahead and take my solution of beta D glucose with a 12 degree optical rotation, a 12 degree specific rotation and I let that solution sit. You can see the glucose inter converting from the beta isomer to the 36 to 64 mixture of beta and alpha because the rotation changes with time. It goes so upon standing we'll say both of these end up going to 53 degrees rotation, 53 degree specific rotation because the two anomers are inter converting. We call this process muto rotation. Muto is changed so basically that's a fancy way of saying changing rotation and it's going to be catalyzed by a little bit of acid or base but as I said even neutral water has acid and base in it. 10 to the negative seventh molar hydroxide, 10 to the negative seventh molar hydronium ion. So in other words the catalyst would just speed up the process. Thoughts or questions at this point? I want to talk about how we represent sugar structures and there are sort of four different notations for drawing. Is the fact that we're dealing with a flat blackboard and yet you're talking about molecules that are rich in stereochemistry and so thinking about understanding, communicating and inter relating stereochemistry is really critical when we think about sugars and their structures. So we've been drawing the chair form of beta D glucose and so I'll draw that again because we're going to start to compare and so here we go. Here's our beta D glucose and at this point I want to remind us of something. I want to remind us of where our hydrogens are. Not the hydrogens of the OH groups but the hydrogens that have been implicit in the molecule. So of course even though all of our groups on the cyclohexane ring are equatorial except if you have alpha glucose in which the alpha D glucose OH is axial we have hydrogens. So in beta D glucose we have an axial hydrogen and at the two position we have another axial hydrogen and ditto at the three position and the four position, the position that galactose had an axial hydroxy group, we have an axial hydrogen and finally at the five position as well. So in a way we have five stereogenic centers in the molecule, the stereogenic centers at positions 2, 3, 4 and 5 that are fixed, the one at position 1 that's labile and of course position 6 being a CH2OH group you have two hydrogens on the carbon it's not a chiral carbon. So there are other ways that we can represent the structure here so again I'll just write beta D glucose to remind us of the structures. I'm going to be writing for all of these. So there's another way of representing the structure that doesn't try to represent the conformation of the ring. Remember writing a cyclohexane ring, writing a six-membered ring and the conformation that I've written there is a projection. If you physically take a plastic model of cyclohexane in a chair conformation and hold it in front of a light source like an LCD projector and let the physical model project on the screen and tilt it into just the correct angle you will see all of the bonds project on the screen like this. It's still a six-membered ring but that's the projection that's why we write it that way to think about and to communicate stereochemistry. If we choose not to try to represent the shape of the molecule you can still communicate the stereochemistry. So one of the ways that people do it is just to do a flat ring and again it's sort of tilted. We're going to go ahead and use wedges to represent what's coming out of the board at us so we sort of have our ring tilted like this but we're just representing a planar structure. And now you can think about it, we can simplify things. We can write our anomeric OH up and the hydrogen down. So obviously this is a more stylized representation. It's not trying to capture the physical structure of the molecule. We can take our next position, remember we have our hydrogen down, our OH up. We can take our next position, we have our hydrogen up and our OH down. So we can represent that like this. We come to our next position now, the hydrogen's down, the OH is up. So we can represent that like this. Position four, hydrogen up, OH down and finally position five and we have hydrogen down CH2 OH up. We call this representation a Haworth projection and you'll see it used liberally in your textbook. So those two projections kind of represent the cyclic structure of the molecule and they catch all the key stereochemistry but they also require a little bit of artistry to represent and there are ways of representing the structure that may be involved less artistry. We imagine opening the structure, we imagine opening the structure to an aldehyde at this position and now we want to get all of our stereochemistry just in a zigzag structure of the molecule. So I can imagine going from one end to the other, we have six carbons and an oxygen on the end so one carbon two, three, four, five, six and let's make, let's start with the aldehyde carbon here. Remember I'm just opening the hemiasatal structure so that's going to be the aldehyde and now our chain zigs up. So in looking at the chain at this point the OH is going to be coming out at us, the hydrogen is going back so in our zigzag structure we're going to represent this as our OH coming out, our hydrogen coming back. It's important to be able to visualize these relationships and it can also be very hard to do this the first time around because you're having to train your head to really recognize three dimensionality embodied in a two dimensional drawing. Okay, our next position on the chain we've zigged down, the OH is again coming out at us and the hydrogen is coming back so we're going to represent that over here, OH, hydrogen going back. Now you almost want to continue to walk around and look at this molecule from over here like I'm doing. Now that OH is coming out and the hydrogen is going back as we come around the chain. Now we continue along here, you have to sort of position your eye from back here and say okay now that OH is going back so we sort of follow it our way, you've unwrapped the chain, you're visualizing from here that OH is going back, that hydrogen is coming out and this is just our CH2OH group. And so what I've done here in part because I'm used to seeing molecules like this is I've unwrapped the structure, drawn it in a linear fashion as the aldehyde and honestly when I think about lots and lots of stereochemistry in organic molecules the structures that I think about are linear zigzag structures like this and cyclic structures like that. What's that? The hemiasatel, yes so can I point to the hemiasatel? Is that position one? And so we just imagine this interconversion of the hemiasatel and the aldehyde. However this open form is present.003% amidst the closed form of the molecule and the closed form is a 64 to 36 ratio of the beta and the alpha anemars. Other thoughts and questions? Alright now the one that I am not in love with for a representation of molecules of sugars but that has been used traditionally to such an extent that it is absolutely integrated into almost all textbooks who discuss sugars is what's called the Fischer projection. In a Fischer projection what we're going to do is represent the molecule in a straight line and we're going to represent it so it curves backwards but we're going to show it as linear. We'll put the aldehyde group on top traditionally and now we're going to look down this way so you can sort of see alright as we do this we're going to get CHO here and then OH and H we're basically siting down this position here. I'm going to help you out with this some more in just a moment. So we're siting down this position here but the key thing in the Fischer projection is we're basically wrapping the molecule on itself. So you would have to imagine as we continue we're going to go ahead rotate about this bond 180 degrees bringing it down that's going to throw the OH pointing out pointing back on the other side. So we're going to rotate 180 degrees like so. Now that's hard to see for me the way I see this is really the relationship. I can easily see the relationship between the cyclic structure and this acyclic structure. I just sort of walk around in my mind looking at it and it helps to train yourself with models and we'll come to that in a second plastic models are the best but computer ones work. The Haworth projection is perfect for converting to the Fischer projection because the Haworth projection you say the molecules already wrapped on itself. Here's the molecule and remember that's just an aldehyde so we're going to ignore stereochemistry there. I'm going to pick that up. This OH when I pick it up is going to go off that way. This OH is going to go off that way. I take the structure I pick it up. Here was the OH I bring it vertical that OH is that way. I take the structure and here was this OH I bring it this way that one's pointing to the left. We can continue around like so and now the only point that gets confusing is over here. Let me draw how glucose is drawn first and then I'll show you how we get over there. The last position doesn't map well and I'll show you why in a second. Here's our last position. In fact for all of the D sugars they have this stereochemistry at this position at the position that's next to the terminus of it. So D at this position they didn't know it when they first started Fischer started to study the stereochemistry of the sugars but the D means this stereochemistry and it means R stereochemistry. For R and S at this position. Alright here's our Hallworth projection again. I want to show you what I see when I go ahead and do this. Let me draw this on this blackboard here. We look and we say OH OH OH OH. Now we come down to this position. Remember I picked up this ring. We're curving back on our self. We picked up this ring. It's like this. I brought it like this. So we have this high OH over here. This second OH the one at the three position here. The one at the four position over there. Now we come to the five position. If I pick this up and look at it what I have over here is now I have a carbon but I have the OH continuing down and I have a hydrogen and I have a CH2OH over here. In other words I pick this up. I look. I say how does it go? Okay well now when I pick this up that hydrogen is off to the right. The CH2OH is off to the left. The oxygen is down when I pick this up. But now you say okay how do we get from there to there. You can just imagine that you rotate about this bond. So you rotate like so, like so, like so. You move those three atoms all in a circle. You're rotating about this bond. Everything's the same until we get to the bottom position and its representation. And now we've rotated so we've rotated the OH over to here. We've rotated the hydrogen over to here. And we've rotated the CH2OH over there. And that's hard to see. It's easy to see with physical or computer models. It is hard to see in your head for the first time particularly representing seeing this representation. So this representation is the molecule, the sugar molecule wrapped around a cylinder here. It is taking that Haworth projection and wrapping it. And so one of the things that I did in trying to help you get ready to see this is I set up some stuff and we can pop our computers here at this point because I'm going to go ahead and you're welcome to play along. Johnny and Kim and I will be able to help you with this in your discussion section or in your office hours if you like. But I've set up a tool for us here on the website. And I just set it up in PyMol. So if you remember back to week three we had PyMol and we had some exercises and you downloaded PyMol onto your computer and I said well use it later. I want to use it later in the course. So now is later. So I've made some molecular models for you. And what I've done is I've started with those drawings that I just made on the blackboard. I started with the chair conformation of cyclohexane for glucose. I started with the Haworth projection. The zigzag structure that I just draw drew and the Fisher projection. And what I did for you last night was I created molecular models of each of these. So here for example is the chair conformation of beta D glucose. And remember what I talked about with the idea, whoops, let me kill the, oh I guess that is as killed as it, ah okay. That'll go a little better. How's that? Okay. Remember I talked about projections and this goes right back to our very beginnings. So there's the six-membered ring. And you go ahead and rotate it like so. Your chair emerges. I've linked, by the way I've linked Firefox in my computer so that PDBs download and open automatically in pi mole. So okay if you want to go ahead remember show can show the sticks here. And so that can show your structure in sticks. I just went to show in sticks we can get our structure. Okay I'm going to bounce back. I want to show you what I laid out for you right now. So okay so the Haworth projection should just pop up if it doesn't. Alright so there's, so I've made an unnaturally flat cyclohexane, an unnaturally flat sugar molecule and so now when you start to look, so there's our Haworth projection. Pretty much just as I've drawn it. And I'll show you a couple of other things here. I'll show you what I laid out and then I'll show you how I use these tools to think. Okay I'm going to show you the open form, the zigzag form. So there's our zigzag form that I just drew out on the blackboard for you. You can get a good look at it. You can see all your stereochemistry on there. Now the last thing I laid out for you was the Fisher projection with unnaturally flat, actually the next to the last thing I laid out was the Fisher projection. So I'm just going to move the aldehyde to the top and so that's the Fisher projection. All right so let me see if I can get our Haworth projection next to our Fisher projection. All right so remember what I said about rotating the structures. So here we go. All right so that's our anomeric carbon of the Haworth projection. That's our two carbon and you'll notice the hydrogen's off on the left, the OH is off on the right. This is our three carbon, you'll notice the OH is off on the left, the hydrogen is off on the right. We'll continue around. I'm going to rotate my Haworth projection so now we come to the four carbon and now you notice the OH is off on the right, that's the four carbon here and then I'm going to continue to rotate here and now this is the conundrum I mentioned so now we're at the five carbon and so the five carbon we have here, the hydrogen off in the cyclical area in the cyclic form, the CH2 off on the left and the oxygen that's off and you just have to imagine rotating about this bond here which is going to bring that hydrogen there, the CH2OH down and this OH here. I'll do this in the Haworth projection here like so as best as I can because of course the carbon is tetrahedral. And so there we go, now you can see our five position, the hydrogens off to the left, the OH oxygen, the oxygen that was the anomeric acetal is now off to the right. Alright, last thing I've done for you to give you some tools, see these structures, and this is what I was saying before, glucose is really an archetype of all the sugars. If you can master glucose you can master all the other sugars in your thinking and if you can understand these structures. So you have one sort of tool here, one sort of toy. Okay, the other thing I've done for you is PIMOL's native file format, PDB is sort of an interchange file format, it's also one that I've linked so my computer opens it in PIMOL when I download it in Firefox. PSE files are the native format for PIMOL so they contain all of them so I made a composite structure and I want to show you how to use this on your own. So here's a one I call glucose composite, it's just going to go to my downloads window. Alright so there's my glucose composite and I want to show you what's in here. So there's glucose in the chair form, if I click on the right here and I close the chair form there's my Haworth projection, if I click again on the open form there's the open form, if I click on the fissure projection there's the fissure projection I can just rotate it up. And so these tools or plastic models should help you visualize this stereochemistry and really, really internalize it. Now the last thing I want to do is just come back to our drawings and I just want to play off of these drawings that we had here. Okay so let's come back, this is our fissure projection of glucose. Alright, what I want to do now is to come back and show how handy these structures, these fissure projections are for visualizing other stereochemistry. Now remember we said galactose was identical to glucose except in the fore position. So now I look at galactose and I say alright I know how, if I know the glucose structure all I need to do to make galactose from the fissure projection of glucose is to change the stereochemistry at the fore position. 1, 2, 3, 4, all I do now is swap those two substituents and this structure is beta D, well I'm sorry actually technically because we're not showing the cyclic structure I should say this is D glucose and so technically this is not beta or alpha but it is regardless D galactose. Alright so the main point is we go through a lot of work to get to the fissure projections but once you're at there you can say oh I can immediately start to interrelate all my structures and we know that there are eight D sugars. There are eight D sugars because the D indicates the position at five is always fixed and we can permute the positions 2, 3 and 4 to come up with the other stereoisomers. I'm not going to bother to ask you to know them but they are allose, altrose, they have cool names, glucose, mannose, gulose, idose, galactose and tallose. So these are the eight diastereomeric D sugars. Alright well I think that wraps up what I want to say about the introduction to the structure in stereochemistry and sugars. We will pick up next time talking from the four carbon sugars on up and then move into reactions of sugars.
This is the third quarter course in the organic chemistry series. Topics covered include: Fundamental concepts relating to carbon compounds with emphasis on structural theory and the nature of chemical bonding, stereochemistry, reaction mechanisms, and spectroscopic, physical, and chemical properties of the principal classes of carbon compounds. Index of Topics: 3:12-Carbohydrates 8:39-Lactose 12:47-Subunits of Lactose 15:38-Alpha-D-Glucose 18:04-Anomers 21:51-Interconversion of Glucose Anomers 25:29-Interconverting Lactose? 28:26-Forms of Galactose 32:15-Optical Rotation 37:25-Chair Representation of Glucose 39:11-Haworth Representation of Glucose 42:40-Open Form Representation of Glucose 46:56-Fischer Projection 51:15-Converting Haworth Projection to a Fischer Projection 53:48-PyMOL Demonstration 1:02:49-Using Fischer Projections to Make Different Sugar Molecules 1:04:32-8 D Sugars
10.5446/19419 (DOI)
Good morning. Good morning. So I'd like to finish up chapter 25 today on the chemistry of amines. And as I said before, chapter 25 is a little bit of a hodgepodge because we've already seen a lot of chemistry of amines, but there's some really beautiful and some really useful chemistry that we're going to see. And some of it, because we're on the quarter system, harkens back to some of the aromatic chemistry that you learned at the very end of the 51B course. So that very last part of the 51B course. And so we're going to review a little chemistry from that and put it all together. So when we were talking last time, we were talking about alkylation of amines. In other words, treatment of amines with alkyl halides. And I said that the basic thing about amines is it's not easy to control their alkylation reactions. We know amines are nucleophiles and we know alkyl halides are electrophiles and that primary alkyl halides and to a lesser extent secondary alkyl halides participate in SN2 displacement reactions. But at the same time, what we would think would be an obvious reaction of mixing an amine and an alkyl halide doesn't lead to controlled monoalkylation. You get proton exchange and you get a mixture of mono-dye and trialkylated compounds. It's kind of sort of possible to take an alkyl halide and treat it with a huge excess of ammonia and get a primary amine although often in practice chemists use other procedures because you do get overalkylation. But in general, taking a primary amine and treating it with an alkyl halide gives a mixture of products. Now on the other hand, we can control this reaction if we want heavy alkylation. So just by way of repeating what I was just saying, if we take benzolamine and we treat it with methyl iodide, right, methyl iodide is a great alkylating agent. Primary alkyl halides are very good at SN2 displacement reactions. But methyl halides, methyl bromide, methyl chloride, methyl iodide are especially good. Also, other sorts of compounds like benzylic halides are very, very good, allylic halides as well. And so if we treat benzolamine with methyl iodide, we end up with a mixture. And this was what I was talking about last time, a mixture of mono dye and trialkylated products. So in other words, we don't just get the, just for the sake of clarity, I'll say we don't just get not just the monoalkylated product where I've drawn, say, a single methyl group and technically we would have it as the ammonium iodide salt NH2I minus. Now one of the things about organic chemists is we really like to control what's going on. A lot of organic chemistry focuses on synthesis. It focuses on making stuff, taking a reaction and figuring out how to take charge of it, how to make it useful. And so one of the things that one can do is to drive this reaction by use of an excess of methyl iodide. And I'll show you where we're headed with this in just a second. But we can drive this reaction to with an excess of methyl iodide. And you need a base to pull off a proton because every alkylation gives you an ammonium salt. So I'll just write out this equation and then we're going to do some play with molecules of this sort. So instead of getting a mixture, if I take benzolamine and I treat it with methyl iodide, so I'll say excess, later on you'll see me write it as excess because chemists like shorthand. Excess methyl iodide, and you really need a base in there. I think your textbook kind of neglects it. It's not super important until you go into the lab and actually try to make the chemistry work. But you need a base to pull off the proton. So typically you would do this under heterogeneous conditions with, say, solid potassium carbonate in there. And this would give you the trialkylated product, benzol trimethylammonium iodide. So iodide is the counter ion. If you ever look at your eye drops or nose drops or other sorts of products that are liquids that you put in your body, particularly in your eyes or contact lens solution, you'll often see on the back of it benzol trialkyl ammonium salts. These types of salts have antibacterial properties. They're surfactants. They're soap-like molecules that disrupt the membranes of bacteria. And so this helps keep nasty things from growing in your contact lens solution or whatever. So this is part of a broad class of what we would call quaternary ammonium salts. Quaternary just means, remember, we talked about amines and we said there are primary, secondary, and tertiary amines depending on the number of substituents on nitrogen. Quaternary means there are four substituents. And of course it's a salt because by that point you have a charge on the nitrogen. Let's see a question. Yeah, would it be possible for CH3I to add on to the benzene ring? Ah, okay. Another good question here. Would it be possible for methyl iodide to add on the benzene ring? So one of the distinctions I've made, we think about nucleophiles and we think about electrophiles. And one of the distinctions I've tried to make in the class is the distinction between things that are slightly nucleophilic and things that are very nucleophilic and then things that are slightly electrophilic and very electrophilic. So methyl iodide is slightly electrophilic. You need a nucleophile with a relatively available lone pair of electrons to attack it. We often use pKa as a surrogate for thinking about nucleophilicity when you're comparing elements of the same type like nitrogen over a series like an aniline nitrogen pKa of the conjugate acid 5 and say this nitrogen pKa of the conjugate acid 10, it's a relatively good comparison to say benzolamine is much more nucleophilic than aniline. When you're comparing atoms of different types, the comparison is a little bit more loose and yet still you can use this general idea that benzolamine has a pKa of the conjugate acid of 10, it's relatively nucleophilic. Benzene of course is not at all basic, it'll protonate in sulfuric acid but it's not a very strong nucleophile at all. So most of the electrophiles that react with benzene are cations or else they're very good electrophiles like halogens and we'll talk more about this at the end. So methyl iodide is in no way a good enough electrophile to do electrophilic aromatic substitution on benzene. Another example that's perfect is say formaldehyde, formaldehyde is not a good enough electrophile, we talked about aldehydes and protonated aldehydes, formaldehyde is not a good enough electrophile to react with an aromatic ring, I'll take phenol as an example, hydroxy benzene which we'll see later on. But if you have acid present, the formaldehyde can protonate, you can get an oxacarbenium ion and that's a good enough electrophile and that in fact is a basis for the synthesis of polymers particularly bacolite that can be done either with acid or base. So this having this notion of things that react with benzene, generally very hot electrophiles, carbocations, tert-butyl carbocation undergoing a Friedel-Kraftz reaction, tert-butyl chloride and aluminum chloride or an acylium ion, an acid chloride and aluminum chloride, those are the sorts of electrophiles that attack the benzene ring and we'll get to talk about some electrophilic aromatic substitution in a second. Alright, I want to show you an example and I think this is going to bring us back to some concepts of stereochemistry and conformational analysis. I want to introduce us now to the Hoffman degradation, your textbook introduces it at this point. This reaction used to be fantastically important back before techniques like NMR spectroscopy. So when I say that chemists took 50 years to determine the structure of morphine before NMR spectroscopy or IR spectroscopy, they were carrying out chemical degradation reactions and combustion analyses to figure out what molecules they were producing and hydrogenation and measuring how much hydrogen was up taken. So the Hoffman degradation which I'll show you now used to be a very important reaction. The reason I'd like to teach it now is for concepts of mechanism, stereochemistry and conformational analysis, the latter of which is going to tie into our discussion of sugars. So if we take an amine and I'm just taking sort of the simplest, stupidest amine I can think of here, I'm taking ethylamine and if we treat it with an excess of methyl iodide, so here I'm writing it as excess, just a little abbreviation, and potassium carbonate, some sort of base to keep pulling off protons after the SN2 alkylation so you can go on smoothly to the next step and the next step until you completely alkylated the amine. You would get ethyl trimethylammonium iodide. This is what we would call an exhaustive methylation just like I've written here. As part of the Hoffman degradation it happens to be called the Hoffman exhaustive methylation. Alright, if we now take our, I'll show you the overall sequence and then I'll talk about how it works. If we now take our ammonium iodide salt, our ethyl trimethylammonium iodide and treat it with silver oxide in water, AG2O is silver oxide, we replace the iodine with a hydroxide, we replace the iodide with a hydroxide, I'll tell you how that occurs in just a second. Of course hydroxide is a good base and now we have ethyl trimethylammonium hydroxide and if we heat this material, so I'll just write an arrow with a delta here so now you go ahead, you boil up your solution, this compound's going to break down to three components. Ethylene, I'll write it like this, if you're not comfortable writing it like that just write it like this here, ethylene plus trimethylamine and organic chemists hate to balance equations so I'll put this in parenthesis water as the product. I want to show us how we get to this point. So first let's take a look at the silver because silver oxide is a reagent you've seen before as an oxidizing agent, a mild oxidizing agent that can allow oxidation of aldehydes up to carboxylic acid. So let's look at what L-silver oxide can do. So in water a lot of metal oxides are basically an equilibrium or equivalent to the hydroxide so if you think about it you can think of a hydroxide as of an oxide as a hydroxide without water. I mean you can think of it as silver oxide plus H2O is equivalent to or is an equilibrium with two molecules of silver hydroxide. Now the main thing about silver, silver absolutely loves the halogens. Silver precipitates out with chloride, bromide and iodide to form silver chloride, silver bromide, silver iodide. It's a very pretty reaction particularly iodide because silver iodide is a pale yellow solid so just like the iodiform reaction I talked to you about before we can generate a pale yellow solid but the real gist of this is when we treat our alkyl ammonium iodide, our ethyl trimethylammonium iodide with silver oxide in water, I'll write it as silver hydroxide so I'll write this sort of in quotes as silver hydroxide. You end up precipitating out silver iodide and getting the trimethylammonium hydroxide salt. That's just a sort of if you think back to it it's sort of your standard inorganic reaction back from G chem days where you would mix two different species, two different salts together and you would end up with a precipitate of one salt in Le Chatelier's principle driving the reaction. Okay but the main thing that's occurring in the real organic chemistry that's occurring in this process now is the last step, the elimination step that sometimes referred to as the Hoffman elimination. Alright so the Hoffman elimination involves just an E2 elimination, hydroxide is pulling off a beta proton and kicking out the trimethylammonium group. So I'm writing this with ethylene as our example for starters because it's nice to see the geometry here and it's nice to see how this can occur. So there's our ethyl trimethylammonium iodide and you can think of your hydroxide here, I'll write it as OH and I'll be a good person and put in all my lone pairs of electrons and so forth. You can think of hydroxide as acting like a base, pulling off the beta proton, pushing the electrons into the bond between carbon and carbon and spitting out trimethylamine and when all is said and done here at the end, I'll just write an arrow, we go to HOH water of course plus ethylene which I'll write like this plus trimethylamine. So this is the basis of an E2 elimination reaction. I guess technically my word an E2 or semi-redundant because E2 means elimination bimolecular. But the big thing that's important in the E2 elimination is that you have an anti-periplanar relationship. In other words, as you look down the bonds, you go in a zigzag relationship or if you do a Newman projection, think back to Newman projections in your first quarter, you have a relationship where the hydrogen is opposite the leaving group. So I'll write anti-periplanar relationship. And that's really one of the requirements for an E2 elimination is this geometrical relationship. Question? Yeah, for the Hoffman degradation, why can't we start off with NaOH and instead we use K2CO3? Why couldn't, ah, you could use NaOH. So the question is why do we have to use potassium carbonate here? And I think the answer is you really could. The nice thing about the conditions, you're trying to minimize SN2 displacement on methyl iodide. Hydroxide at that point is a little bit better nucleophile so you'll kill some of your methyl iodide. But if you were to try this reaction, say with potassium hydroxide and methyl iodide under the right conditions of solvent, you could probably get it to work. It might not work quite as smoothly. One of the beauties of a lot of this really ancient chemistry is a lot of it works really cleanly and easily, meaning you just mix some things together by a general, really a recipe here, and the chemistry works. And that's cool because when you're trying to figure out what's going on, knowing this chemistry goes in the same way, whether I have an ethyl group, whether I have a propane group, whether I have morphine, or whether I have cocaine is really, really cool and really valuable. Now here's the cool thing about this E2 elimination, and this actually brings us to some stuff I wanted to talk about. One of the cool things about this chemistry is that you get regiochemical control and you get regiochemistry that's different than other eliminations you've seen before. You know that controlling regiochemistry is important. When you take 1 butene, you learn back in either 51a or 51b, that when you take 1 butene, you could go ahead and control the regiochemistry of addition of water across the double bond, depending on whether you use an oxymercuration reduction system to give reaction sequence to give the so-called Markovnikov addition or a hydroboration oxidation sequence to give the anti-Markovnikov addition. You also learn that in general, E2 eliminations, if possible, prefer the more substituted product. For example, if I have one methyl, one iota, one methyl cyclohexane, and I treat it with potassium hydroxide and I heat it up, we get as our major product, the more substituted alkene, and our minor product, we get the less substituted alkene. And that's sort of a hallmark of a typical E2 elimination. In the transition state for a typical E2 elimination, you start to feel the greater stability of the more substituted alkene, and so in general, you end up with the more substituted product being favored over the less substituted product. But what's cool about the Hoffman degradation sequence is if we take the same basic molecule except instead of our leaving group being an iodide, it's going to become a trimethylammonium. We get the other regiochemical preference. In other words, if I subject this molecule, this one amino, one methyl cyclohexane, first to excess methyl iodide and potassium carbonate, then to silver oxide and water, and then to heat, now our main product is the less substituted alkene, and our more substituted alkene is very, very minor. The selectivity is huge on this. We get a relative ratio of 99 to 1, 99%. This is our major product. And that's really, really cool and really significant. It's the same element of control that you were getting emphasized in the hydroboration, oxidation sequence that you were getting that I've emphasized in talking about chemists in synthesis. So I'm going to just sort of summarize this and then we'll talk why. So I'll say that conventional E2 elimination, and I'll say generally because I can always find some type of counter example. So I'll say generally gives the more substituted alkene. And then I'll say the Hoffman elimination has, I'll say special steric and stereochemical requirements. And I'll say that these requirements often lead to, I'll say that these requirements often lead to, I'll say often leading to the less substituted alkene. All right. Let me give you, before we go on into other examples, I want to show you my theory. My thinking on the rationale for the difference we're seeing on the upper right hand black board there. All right. So here's our iodide, the first example from the black board. You have a methyl group here. You have the iodide in the axial position. You require the hydrogens to go ahead and have an anti-periplanar relationship. And if possible, you favor the more substituted double bond. So here's hydroxide. We're using potassium hydroxide. I'll just draw in one lone pair here. And so we push our arrows like so that's going to lead to E2 elimination to give the more substituted alkene. Now by comparison, here's our example with the cyclohexyl trimethylammonium iodide. Now trimethylammonium is isostructural with the tert-butyl group. So the tert-butyl group back from 51A, remember how big the tert-butyl group is? The tert-butyl group wants to keep out of the way of everything. If it can avoid it, it doesn't want to be axial on a cyclohexane ring. If it can avoid it, it doesn't want to be ghost of things. It wants to keep out of their way. So it's not great to put a methyl group axial on a cyclohexane ring, but it's a lot worse to put a tert-butyl group axial and by the same dent, it's a lot worse to put a trimethylammonium group axial. So our trimethylammonium group prefers a confirmation where it's equatorial. Now let me just do one thing here and I'm going to redraw this molecule and draw it in the hydrogen and now think about our elimination. Actually, I'll give it its own blackboard because I want to have a little bit of room here to make my point. All right. So here's our methyl group. We have a hydrogen here and two more hydrogens on it. I'll just write it as CH2. Here's our trimethylammonium group like so. Here are our hydrogens like so and like so are axial and are equatorial hydrogens. Which hydrogen is antiperiplanar? Which one has a zigzag relationship to that trimethylammonium group? Which one? Which one? The one on the CH2? The one on the CH2, yes. So here's our zigzag relationship. So here we have a Gauss relationship, not an anti-relationship. And here we have an antiperiplanar relationship. And so our hydroxide can come in like so, kick, kick, kick and do our E2 elimination. Now the reason I hedgeed, the reason I qualified my statement over here often leading is I was going to give you a counter example and it involves some really cool confirmation stuff but I decided all right, I'm not going to. It's a beautiful example where you've got an antiperiplanar relationship that leads to the more substituted alkene. For your purposes and your textbook shows a few additional examples, you can think yeah, generally less substituted alkene but just keep in mind the steric and stereochemical requirement. I'll show you one more specific example for comparison and then I'd like to move on to some aromatic chemistry. All right, just kind of a simple example. Again, harkening back to E2 elimination that you learned back at 51A or 51B. So we'll take 2-bromobutane by example here. We'll treat it with a strong base. Remember our favorite bases, we often like sodium ethoxide and ethanol because you can generate it by throwing sodium metal into ethanol. They react to give sodium ethoxide and hydrogen. Secondary alcohol halides and strong bases tend to give elimination. You don't get a Williamson ether synthesis. And so you get the 2-butene and the 1-butene. So I'll write 2-butene and I'll write parenthesis mixture of cis and trans. I'm not going to break down what, which amount you have of which. And then the 1-butene. So you get the more substituted alkene and the less substituted alkene. And in general reactions like this favor the more substituted alkene. It's not 100% preference, but it's a good preference. In this particular example, we have an 81% to 19% ratio. In other words, it's four parts of 2-butene to one part of 1-butene. Now by comparison, we take 2-amino-butene and we subject it to the same types of conditions. In other words, we go ahead and we take 2-amino-butene. We treat it first with excess methyl iodide and potassium carbonate. Then we treat it with silver oxide and water and then we heat it up. So it's our Hoffman, whoops, it's supposed to be a delta to indicate we're heating it. And we get vastly, vastly predominant the 1-butene. So our 2-butene, which again I will write sort of with a squiggly line, is 5%. And our 1-butene now is 95%. So a very, very big preference for the less-substitute alkene. So in a way, this is sort of the antithesis, the opposite of your oxymercuration reduction, hydroboration, oxidation control, in that now you're going the opposite way and you're exerting regiochemical control. Thoughts or questions at this point? Oh, okay, why do I draw it like this? This means stereochemistry. Squiggly line means stereochemistry unspecified. So this is equivalent to trans plus cis. And we often use a squiggly line. So for example, if I'm going ahead and saying, let's say, pentane diol and I don't want to specify the stereochemistry of it, 1, 2 pentane diol, that could mean either cis isomer, trans isomer, a mixture of isomers. It could mean a mixture of the trans as the RR and SS and anti-immers. So it basically is sort of all encompassing. So if we were to remember once from the Hoffman elimination, would that be anti-periplanar attack? Okay, if you're going to remember good question because this is confusing for students and also, as I said, the Hoffman elimination is not that important. If you're going to remember one thing from the Hoffman elimination, I'd remember two things. Okay. One of the things I'd remember is anti-periplanar attack. Always wants anti-periplanar attack. That's the stereoelectronics. That's how your orbitals line up. Then the simple rule is generally it's going to give you the less substituted alkene, but because of the reasons for it, you can. I could come up with an example where you had the more substituted alkene. And your textbook doesn't even touch on it. So it's kind of a little bit advanced. Other questions? All right, I want to take us back to aromatic chemistry because the aromatic chemistry of amines is super important. It's really the basis of all commercial organic chemistry and it's something that you didn't get in Chapter 18. So by way of refresher, electrophilic aromatic substitution is a great way to introduce substituents onto benzene. You can get simple benzene compounds, benzene and toluene and naphthalene and xylene, which is dimethyl benzene. Toluene is methyl benzene. You can get them all from petroleum. They're present in crude petroleum and so petroleum is a great source, a great feedstock. So if we take toluene, the other chemical that's a great feedstock for all of chemistry is, well, two chemicals, is nitric acid and sulfuric acid. These are readily, readily available, earliest sorts of chemical industry in the U.S. And so taking a benzene compound and treating it with nitric acid, sometimes with sulfuric acid, gives rise to nitrobenzene, electrophilic aromatic nitration. You learned about that before. And then if you reduce the nitro group, for example, by catalytic hydrogenation with hydrogen and palladium on carbon or by zinc, by tin and HCl reduction or by iron and HCl reduction, there's a zillion ways to do it. You can get the amine. It's para-amino toluene, but it's called toluidine or p-toluidine, if you want to know the trivial name. I'm not going to write it down because that's one that sort of, aniline you should know, toluene you should know, phenol you should know, hydroxybenzene. P-toluidine's kind of one for people in the know. Okay, here, I want to show you now, though, some cool chemistry of this. And this will get us into some new places, both mechanistically and synthetically. So let's take our p-toluidine and we're going to treat it with sodium nitrite NaNO2 and an acid. Your textbook always uses HCl and that's largely fine. I'll make some distinction about using HCl or HBrH2SO4 or fluoroboric acid and give you a little bit of subtlety. And you want to keep this cold because the product that we're getting is not very stable and it can blow up. And what you get out of this is an aryl diazonium salt. The diazonium salt, of course, is the triple bond to nitrogen. And the reason this isn't very stable is this is one step away from releasing molecular nitrogen and molecular nitrogen into is the world's greatest leaving group. Now I'm going to get into some chemistry that shows us what happens when the nitrogen leaves and it's largely SN1 type of chemistry, nucleophilic displacement, unimolecular carbocation chemistry. But I want to show you first this diazonization reaction. So I'll write this out as diazonization. All right, there's a lot of chemistry going on here and a lot of it's just simple acid base chemistry. Sodium nitrate, nitrite rather, is the sodium salt of nitrous acid and I'll take us all the way back to freshman chemistry and write a Lewis structure of the nitrite anion. And I'll even remember to put in my charges. And if we just protonate the nitrite anion, I'm not going to show you curved arrows, but if we imagine H3O plus, right, H3O plus is the strongest acid that can exist in water in H2O. The textbook writes HCl and write curved arrows, probably not quite as correct. Anyway, if you go ahead and write this out now, you know that you'll have an equilibrium where you'll get nitrous acid, HONO. This is again sort of freshman chemistry. Now if we imagine another proton going on to the molecule, protons go on and off in strong acid, one of the places the proton can go is onto the OH group. You saw this in electrophilic aromatic substitution. Think all the way back to the mechanism of nitric acid and sulfuric acid to generate the NO2 plus the nitrosonium ion. So let's go ahead and we'll write a protonation H3O plus over the arrow to now protonate the oxygen. I'll be a good person. Remember all of my charges and lone pairs of electrons. And now imagine water leaving. This is all inorganic chemistry right now. Imagine water leaving with its lone pair of electrons. And so I'll write one last equilibrium here. I'll write this up and down just for the heck of it. And I'm going to go ahead and just take us to the more substituted, the more important resonance structure. If you don't like the resonance structure that I'm writing, you can write the one in the textbook. I'm going to give everyone a complete octet here. So we'll just push out the water. So this species here is called the nitrosonium ion. All right. Now the main thing is even though this is an inorganic species, even though it looks very different than a lot of the species you're seeing in organic chemistry, basically it's the same gist of what we've seen of a lot of other positively charged compounds. They tend to be electrophilic. We can push arrows and form bonds that give rise to new bonds to them. So let's do this. And I'm going to use the abbreviation for arrow and write AR. Arrow is sort of generic aromatic. And so I'll write AR and H2. In this case to represent toluidine, but of course it could represent aniline. It could represent any other amino group on a benzene ring. So here's our amino group. So just as water left, and I guess I can even balance my equation here and say H2O, just as water left, we can have the amine attack. And so I will write my nitrosonium ion like so. And now we just imagine what really is the reverse of that reaction there except with nitrogen attacking. In other words, a lone pair comes in, we push up electrons onto the oxygen. You can think of this as a series of equilibria if you like. I think I like to. All right. We are in acid. In acid, protons go on. Protons come off everything with a lone pair of electrons. So what's going to happen at this point is we're going to swap some protons around. We're going to tautomerize. Your textbook probably writes chloride as a base. I think it's probably a little bit more reasonable to write water as a base. So I'll just write H2O. And I can give you a curved arrow here. I'm not going to give you curved arrows for absolutely everything. So I'll give you a curved arrow. We'll put our electrons onto the nitrogen. Now this compound here, it's not stable under the conditions. We're going to tautomerize it. The very end I'll show you another compound of this class that's stable. We call this compound a nitrosamine. Just an amine with a nitroso group on it, hence nitrosamine. Nitrosamines when you have a hydrogen on them, when they're from primary amines, let me write this more clearly. When they're from primary amines, they're not stable and they tautomerize. But on the other hand, secondary amines give stable ones and those are nasty compounds. They're nasty carcinogens. Question? This one. This one. That's the nitrosamine. That's our neutral compound. All right. We're in acid and we're going to continue to tautomerize. And again, one of the beautiful things about really seeing things from a point of view of curved arrows is you can start to see in many ways this is like a ketototomer here. In other words, we have, well, it's not a carbonyl. It's a nitroso group. And here we have an alpha hydrogen. And so we can imagine swapping protons around. So in this particular mechanism, here's our nitrosamine. I'll start with this again. And we're going to tautomerize. Protons go on, protons go off, all different positions. So just as we've tautomerized, just as we've tautomerized carbonyl ketones and aldehydes, we can tautomerize here. First step in the tautomerization in acid is going to be putting a proton on, protons go on and off all your lone pairs. So I will go ahead and put on a proton here, like so. And just like we, well, not just like, but I will show you there's a second resonance structure that I can write here. If you just imagine pushing in this lone pair of electrons and pushing up electrons onto oxygen. And by this point, you should remember that different resonance structures aren't different molecules. They're just different representations of the same thing. I could write one, I could write the other, but it's really easy to see where we go from here if we look at the next one. Just imagine at this point losing H plus. Maybe for the sake of balance, I think, since we're just doing tautomerization, I'm actually going to write plus H plus here. I'm giving you a little bit of a shorthand of the mechanism. Of course, water is supplying H3O, hydronium ion is supplying H plus. I'll write minus H plus. Of course, water is acting as a base for taking off that proton. And so now we just imagine that proton coming off like so. And now we're going to continue our chemistry. Was there a question? Ten electron. Oops, thank you. Thank you. So we have electrons on nitrogen. All right. So let's continue with our species here and imagine putting on another proton. In other words, we just have H3O plus transfer a proton onto here. Just go on protons, come off every lone pair of electrons. And now the final step in this whole sequence, remember, we're headed toward the diazonium ion. The final step in this sequence is just that the nitrogen pushes in its lone pair of electrons, kicks out water. And so we go ARN triple bond N with a positive charge on nitrogen and a lone pair of electrons plus H2O. And so we have our diazonium ion over here. All right. In a way, what we've done is just review a lot of carbonyl chemistry because basically everything that you've seen here, it's a steppy mechanism, but everything you've seen here is carbonyl chemistry with heteroatoms with nitrogen and oxygen just pushing some protons around and kicking out leaving groups. Where I want to go, I don't want to dwell on the mechanism. I think it's worth seeing, I think it's worth thinking through, and I think it's worth taking a few moments on your own after class to think through it. But where I want to go right now is what we do with these diazonium salts because it's a gateway to all of aromatic chemistry, to the earliest drug chemistry, to dichemistry before that, and in some cases, dichemistry is drug chemistry. All right. So here we are at our diazonium ion derived from talyuodine, the one that we got from nitrating benzene, reducing the nitro compound and diasatizing with sodium nitrite and HCl. And I said you want to keep that cold because it can explode. All right. The main thing is that if we heat it up, we end up losing nitrogen and we can get a carbocation. And I want to talk about that carbocation. We can get a carbocation. Carbocations are not stable species with very few exceptions, they're not things that you could put in a bottle, they react right away. So I'll say an arylcarbocation. I don't think you've seen one before. I'll tell you a little more about it in a second. But the main thing, it doesn't stick around very long and any sort of nucleophile NU reacts with it to form a bond. I'll write this sort of as generic NU plus. We'll go through specific details in a second. But the point is that it reacts with nucleophiles. It does not want to stick around. The thing is, remember, of course, what you have here before, think about valence. You have a hydrogen on this carbon. You have a hydrogen on this carbon. All you've got on this is this nitrogen and it takes away its lone pair. It takes away its pair of bonding electrons and leaves that poor carbon without anything on it. It leaves it trivalent with a broken heart and an empty sp2 orbital. Now it's pretty bad to have an empty sp3 orbital. Sp3 orbitals, though, are higher in energy. You have more p character. It's really, really bad to have an empty sp2 orbital because you just want to have electrons in there getting stabilized. So what reacts as a nucleophile? Well, anything that's around can react as a nucleophile. This is SN1 chemistry. The case, in some cases, you'll add some copper and it's a little bit more complicated then. But basically, I'll write this as SN1 reaction where nitrogen leaves and it's replaced by a nucleophile. So if we do this reaction in water, and I'm going to go ahead and make a slight tweak to the conditions. You don't absolutely have to do this, but for the most part, acids are interchangeable in the basic reaction they undergo. I'm going to go ahead and do the same diasodization chemistry with sodium nitrite, but I'll use sulfuric acid because sulfuric acid's a little bit less nucleophilic for its counter ion than hydrochloric acid. So I'll write H2SO4 and I'm going to remind us that you always do this reaction initially in an ice bath if you want to keep both of your hands. So we're going to write 5 degrees Celsius, you know, whatever temperature your ice bath will keep it. And then we're going to heat it up. Of course, this is in water, so I'll write H2O. Basically you do this in dilute aqueous acid. The product of this reaction is creosol, it's P creosol. That's just paramethylphenol if you don't want a trivial old name for it. What's happening is the water is being your nucleophile. You get OH2 plus, and of course in water protons go on, protons go off. Point is that we've taken a benzene ring that had nothing on it. We nitrated it and now we've gone ahead after the reduction, the diazonization and the breaking down of the diazocompound, we've introduced a hydroxy group into the benzene. We've accessed phenols. And this is really the start of this wonderful, wonderful gateway of electrophilic aromatic chemistry that you get into here. The whole family of chemistry, and a lot of this is borrowed right from your textbook. So with a few subtle tweaks, you can substitute just about anything on there. I'm going to do this all with our toluidine example. So go ahead, and again your textbook uses HCl for everything, and I think that's fine. If Johnny or Kim were to go into the lab, I'd probably say use sulfuric acid here, use hydrochloric acid here, use hydrophoromic acid. So I'll show you how we do it in the laboratory. All right, to introduce a chlorine to the ring, right where the nitrogen is, you go ahead and you do this with copper chloride. Now you'd say, well, why don't I just let the chloride reactor add some more chloride? You probably could, but chloride's a little bit less nucleophilic than some of the other ions. It doesn't trap the carbocation as well. You get mixtures of phenol and the chloride. Copper chloride mediates the reaction. You can think of it just as SN1 chemistry, but there's really some involvement of organometallic intermediates. Anyway, we're not going to fuss with the mechanism. I want to show you about five different beautiful reactions. So going ahead using copper chloride introduces the chlorine here when you allow them to react. They call this the Sandmeyer reaction, and again, a lot of this is really, really old chemistry. Of course, organic chemistry works at any time, any place, and Mars on the moon, on Earth, all the same way. It works in the 19th century. It works in the 20th century. So I want to show you some more variants of this. A lot of this is just straight from your textbook. It's just some cookbook. All right, same conditions. Another variant of the Sandmeyer reaction, sodium nitrite. In this particular example, I'll use HCl as well. Chloride just isn't that good a nucleophile. Sodium nitrite, HCl, five degrees. Of course, this is all aqueous. Copper cyanide, cupra cyanide, Cucn is a way of mediating the introduction of a nitrile group, a cyanogroup, like so. That's cool. We formed a carbon-carbon bond reaction. The other way you would learn to do this was Friedelcraft's alkylation and Friedelcraft's acylation. There's lots and lots of other things you can do with this as well. All right, introduce a bromide. To introduce a bromide, same thing. Sodium bromide's a reasonably good nucleophile, but copper bromide's even better. You don't want to mix up your bromide and chloride. So again, your textbook, I think, says HCl, but I would use HBr here. They're both available. You basically want to keep your ion separate. So copper bromide, these are all examples. Cupris bromide, CuBr, these are all examples of what generally fall under the broad heading of the Sandmeyer reaction. And it's a great way to get into some aromatic chemistry. All right, let's put the emergency handkerchief to the test. Now put it to the laundry. All right. So a couple of more reactions on benzene chemistry. Basically, you can put almost anything you want, almost any sort of atom you want, except alkyl groups in this way. So give you another example. I'm not sure if this one's in your textbook, but it's the same basic gist. And then I want to show you one that's really important we'll use. All right. I want to put in fluoride. A lot of drug molecules contain fluorine in place of hydrogen. It gives them better biological properties. Chemistry that introduces this pretty well is fluoroboric acid, HBF4. So again, we're just taking strong acids in sodium nitrite. HBF4 and sodium nitrite. And again, we'll do this at 5 degrees Celsius, and then we're just going to heat it up. This basically serves as a source of fluoride ion. So I'll write fluoroboric acid. It's a strong acid that serves as a source of F minus source of fluoride ion. And the overall result is that you get the fluorobenzene out of here. All right. You've put in absolutely anything here. Now I want to show you how to get rid of it, and why we'll see in a second. All right. Same thing. I'm doing all of these examples with toluidine, but you could do them with benzene. You could do them with aminonaphthalene. You could do them with trimethylbenzene. All right. That carbocation can be reduced. It can take up hydride. And a reagent that allows this to occur is phosphorous acid, H3PO2. And so if we go ahead, we do the same chemistry. Non-nitrite diazatization with acid. Your textbook uses HCl. That's fine. I would probably use H2SO4 here because I want a non-nucleophilic counter ion. Again, 5 degrees Celsius. H3PO2 ends up being like a source of hydride. It's kind of, it's something that kind of like we saw in the Canizaro reaction. Remember the Canizaro reaction from discussion? Where a hydride gets pushed off an atom by an oxygen pushing electrons down. It's kind of the same gist here with phosphorous acid. And here's the cool thing. I'm not writing anything. We've replaced the nitro group with hydrogen. We've reduced it. So we've done diazatized and reduced. Okay. I want to show you why all of this chemistry has me and your textbook so excited and why it's the gateway to so much good aromatic chemistry. All right. So I want to come back to something straight out of last quarter. And I'll write what really is a very trivial problem. No, it's the wrong type, Johnny. Thanks. It still works though. Does it? I will try it. I will try it. Thank you. We will try. One way. I wave the white flag of surrender. All right. One way or another. We'll model through. We always do. All right. All right. The first. Now, the honest to goodness truth is a ton of simple aromatic compounds. Phenolides are available. Benzene, toluene, these are things that come from petroleum. We learned how to get to aniline. Phenol is easy to get to. So I'm going to do a typical sort of problem I do. Synthesize this molecule from benzene or simple, probably the sort of thing I'd put on the final, or simple monosubstituted compounds. Simple monosubstituted aromatics. All right. This is a great time to review chapter 18. Remember all those good concepts of resonance and stabilization of carbocations and electrophilic aromatic substitution and reagents to carry this out. If you think back, you'll remember OH is an ortho-paradirector. If you think back a little more, you'll remember in electrophilic aromatic substitution you go through a carbocation and that it is the oxygen is stabilizing to that carbocation. So OH is an ortho-paradirector and it's activating. You'll also remember that electrophiles like chlorine undergo electrophilic aromatic substitution. So if I take phenol and I treat it with chlorine, sometimes, and your textbook will use the iron trichloride ferric chloride as a catalyst. To tell you the truth, the choice of whether you use a catalyst is a little bit dependent on how good a nucleophile your aromatic is. If you have something that's activating, you may not need a catalyst. If you have something that's deactivating, you might need a catalyst. I'll put ferric chloride in brackets here to say I might not use it if I don't need it. I think your textbook or sapling. The sapling I think doesn't and your textbook does in activating cases because as I said, if you don't need a catalyst, you don't need it. Point is that's a relatively simple operation. Phenol is a readily available organic compound. You've done electrophilic aromatic chlorination. Phenol is an ortho-paradirector. In general, para predominates over ortho. So in general, you can get mostly the para compound and that's good. We will try Johnny's eraser. See which one is better. All right. But remember, chemists are control freaks. We want to be able to do what we want to do and we want to do it the way we want to do it because different compounds are useful. You may make a drug with a parachlorophenol compound as a building block, but you may want the metachlorophenol building block. And again, synthesize this molecule from simple compounds. Same criteria there. All right. So now we have a problem. No matter how we slice it, so the problem is we already know that the OH is an ortho-paradirector and it's activating. Phenol is also an ortho-paradirector. And so we're kind of stuck if you look at this. You say, well, I can't go ahead and just directly chlorinate it. But now you think, wait a second, wait a second. We know a group that's a meta-director. What's a meta-director? It's an O2. The nitro group is a meta-director. And so we get this idea in our head. If we could take nitrobenzene and chlorinate it, it would go meta. And then we can draw upon all this other chemistry to get the control that we wanted. So imagine now you take your nitrobenzene, you chlorinate it. At this point, I probably would use ferric chloride. And this is something that maybe Johnny or Kim would worry about more in the lab when to use it. You might literally set up the reaction and monitor it by TLC and see whether you need the catalyst. So nitro is a deactivating meta-director. And so you can meta-chlorinate it. And now you say, all right, I can see my way to the rest of this. I go ahead and I hydrogenate. We can do H2 and palladium on carbon. That gets us to the aniline. And then I can take the aniline and I can diazatize. And I'll use sulfuric acid. Again, my personal preference and I think the general experimental preference, I will diazatize to make the diazonium salt. And then I'll treat with phosphorus acid H3PO2. Oops. I'm getting ahead of myself here. That's the next example I want to give. I will then heat it up in water. I'll say delta water. Of course, you're running the whole reaction in water. So basically it's just heat the thing up. And so at this point, you get the phenol and the chlorine. Yeah. Question. Okay, let's try one more example. I want to really give you a scope. This next example happens to be a problem in sapling, so you'll enjoy paying attention to this. And again, starting with simple stuff. Synthesize 1, 3, 5 tribromobenzene. Now you'll look at this and you say we really are in trouble. Bromines and ortho-paradirector. I can start with benzene and brominate it, get bromobenzene, but if I dibrominate it, I'll get mainly parabromobenzene, very little orthobromobenzene. I can't get one. Remember, ortho is three, right? So orthodibromobenzene is with two bromines here. Paradibromobenzene would be with two bromines here, but there's no way to get over to this. And so now you really need a spark of inspiration. And I'll just remind us Br is ortho-paradirector and slightly deactivating. Now you need a flash of inspiration. The flash of inspiration is the amino group is a very good ortho-paradirector, and it's deactivating. And so here's your flash of inspiration. Your flash of inspiration is to say, okay, we've been down the road a zillion times with aniline. And I can go ahead and I can brominate it. And one of the nice things about bromination and chlorination is you get a lot of control. That is, you can put in one bromine, you can put in two bromines, you can put in three bromines because bromination is deactivating. So in general, you have control. If you just use a little bromine and keep it cold, you won't go, you'll get a monobromo, you put in more bromine, you'll get a dibromo, more you'll get a tribromo. So we imagine treating this with excess bromine, maybe with iron-tribromide catalyst. Honestly, in the case of aniline, you probably don't need it. I think sapling doesn't use it. I think your textbook does. Johnny and Kim would go into the laboratory, add some bromine, monitor by TLC. If the reaction goes, they would probably not add a catalyst. If it's sluggish, they'd probably add some iron-tribromide as a catalyst or they'd heat it up. Point is you can go ahead and brominate once, para, twice, or though, three times, or though again. And now you look, you say, all my bromines are where I want. And you say, oh, wait a second. I know how to get rid of that nitro, that amino group. We just diasotize and reduce it off with phosphorus acid. So if I go NaNO2 and you can use HCl or sulfuric acid, honestly, it doesn't matter. 5 degrees Celsius, H3PO2, we get the 135-tribromo compound. We've achieved this concept of control. All right, I want to mention two things, one of which is we've been focusing on alcohol, on aromatic amines. So the big thing about aromatic amines is you can isolate the diazonium compounds. They're not very stable. You don't want to let them warm up to room temperature in general because they'll release nitrogen, which makes for volume. It'll release heat, which means they blow up. So you want to keep them ice cold. You want to use them quickly. But we get this carbocation that's really not very happy. Now if you go ahead and do things with alcohol amines instead, you have a very different chemistry. Alcohol-diazonium salts are unstable. So there's really not this beautiful controlled chemistry. You end up getting into carbocation chemistry in a very uncontrolled fashion. So if I take cyclohexalamine here and I subject it to these same conditions, NaN02 sodium nitrite HCl, even if I keep it cold, the problem is you never really have any lifetime of the diazonium ion. So I'm going to go ahead and say not stable. It forms transiently, but it gets us into carbocation chemistry. Basically, as soon as it forms, the nitrogen leaves with its lone pair of electrons and you get all E1 and SN1 products. And so that kind of leads you nowhere as far as useful chemistry go. Secondaria means, of course, remember if you think back to the mechanism, secondary means you can't atomize. So secondary means, secondary means form nitrosocompounds. I'll say more specifically nitrosamines. So let's take dimethylamine. I'll just take the simplest example and we'll treat it with the same conditions. NaN02 and HCl. This is a nitrosamine. I'll write out the resonance structure of it. Now nitrosamines are really, really bad actors. They're carcinogens, they react with DNA, they mess up your DNA. And so this is why hot dogs and cured meats that have nitrites in them are often bad for you, particularly if you grill those cured meats because it makes nitrosamines that, well, the meats taste really good, but it messes up your DNA and gives you cancer. All right, the last thing I'll have you read about, there's some very nice dichemistry that's written about using electrophilic aromatic substitution on diazoniums that's very beautiful. Just take a look at that. It'll be really nice for you to read about it. We'll pick up next time talking about the following chapter. We'll pick up talking about, I think it's chapter 28 at this point.
This is the third quarter course in the organic chemistry series. Topics covered include: Fundamental concepts relating to carbon compounds with emphasis on structural theory and the nature of chemical bonding, stereochemistry, reaction mechanisms, and spectroscopic, physical, and chemical properties of the principal classes of carbon compounds. Index of Topics: 2:13-Alkylation 10:19-Hofmann Degredation 14:56-Silver Oxide and Water 16:43-Hofmann Elimination 17:18-E2 Elimination 24:29-Conventional E2 Elimination 26:47-Elimination Example 31:29-2-bromobutane Example 36:39-Aromatic Chemistry 40:21-Diazotization Reaction 52:12-Diazonium Ion Reactivity 55:29-Dizonium Salt Reactions 1:05:05-Synthesis Examples 1:18:27-Alkyl Diazonium Salts are Unstable 1:19:53-Nitrosamines
10.5446/19417 (DOI)
Good morning. Good morning. So today we finish up chapter 24. And as I said last time, chapter 24 really brings us just to the height of a lot of aspects of organic chemistry. It gets us thinking about mechanism. It gets us thinking about synthesis. It gets us thinking about retro-synthetic analysis. The work in chapter 24 is the basis of a lot of synthetic organic chemistry. It was the enabling technology that allowed chemists to make steroids for the first time. Chemistry made the New York Times for helping in the war effort back in World War II, being able to synthesize cortisone that was needed as an anti-inflammatory. And this is really your entree into that beautiful chemistry. So what I'd like to talk about today is the material in chapter 24 that we didn't talk about. And I'm doing things in a slightly different order that I see as more logical. We're going to start by talking about the Robinson annulation reaction that builds upon the ideas from the last lecture. And then we're going to move into related carbonyl chemistry of the Claisen reaction. Now normally when I start I don't recap, but I'd like to recap three reactions that we learned last time. And in a moment you'll see why. So we learned about the Michael reaction, sometimes called the Michael addition. And your textbook has taken a lot of the color out of things by calling everything a reaction. And I've kept with that in my titles here. But you'll probably hear me and other people referring to it as Michael addition. So in the Michael reaction the example that we had, we had several of course, but one of the examples that we had, which is fine, we took something that was going to make a nucleophile, not too basic a nucleophile either. I said that typically we're talking about things where the conjugate acid, right? So this is a conjugate acid of an enolate. Where the conjugate acid of an enolate is not too basic, where it's only moderately basic. This particular example, ethyl acetoacetate has a pKa of 12. And I said generally less than or equal to 15 pKa, we go through Michael addition. And generally greater than 25 we go through one, two addition. By the way, another name for Michael addition or Michael reaction is one, four addition. So in a Michael addition we generate an enolate or generate a nucleophile of some sort. And we have an alpha beta unsaturated carbonyl compound very, very broadly defined. Alpha beta unsaturated ketone, alpha beta unsaturated ester, even other things in the broad carboxylic acid family like an alpha beta unsaturated nitrile. And in the presence of something that allows us to make an enolate here, in this case one of our two favorite bases we've been seeing again and again is sodium ethoxide in ethanol. We end up with a 1, 4 addition of the enolate to generate a new enolate. This is all in your notes before for the mechanism so I'm not going to rewrite it out, but I want you to at least process things in your head. So we end up with a conjugate addition of the enolate to generate a new enolate and then protonation to give a ketone. And we see we get a 1, 5 carbonyl compound. So that was one of the things we learned last time. Another reaction we learned last time was the aldol reaction and we learned it in lots and lots of different forms. I started off by teaching the directed aldol reaction. I said chemists like to have control and so in a directed aldol reaction we specifically make an enolate first and then allow that enolate to react with a ketone or aldehyde. So the example that I gave was cyclohexanone, one of the several examples. And we treat it with LDA and THF. LDA is a very strong base conjugate acid diisopropyl amine has a pK of 40. And then we add in the second step we add a ketone or aldehyde. And I said this is a very general recipe and I used isobuteraldehyde in this particular example, 2-methylcopanal. And then we carry out an aqueous workup and I wrote in one case I wrote aqueous ammonium chloride in another case sort of generic H3O plus what you'd get from throwing an acid into water like HCl in water. And so the product in this case was a beta hydroxy carbonyl compound. And the last class of reactions we learned really was a variation on the aldol reaction. So aldol reactions can occur under many, many conditions. They can occur with strong base like lithium diisopropyl amide, they can occur with a weaker base, a moderately strong base like sodium hydroxide. And so the other example, these are all sort of archetypes, was the aldol reaction with dehydration. That's where we lose water in the end. So here the mechanism is you generate an enolate, it adds into the carbonyl compound on workup you protonate the aldolate, the oxyanide. So aldol reaction with dehydration generally occurs under conditions where you mix components together either an aldehyde and base, an enolizable aldehyde and base or a ketone and a nonenolizable aldehyde in which case you have a crossed aldol reaction. And the example that I started us out with was the parent aldol reaction. It was acid aldehyde with a base and I said historically calcium hydroxide had been used but we'll just think of this with sodium hydroxide and heat for this reaction. And actually if you do this it gives kind of a mediocre yield, a 50% yield. And so this reaction, the aldol reaction with dehydration is very similar to the aldol reaction here, you in an equilibrating conditions generate an enolate. That enolate reacts with another molecule of aldehyde to give a beta hydroxy carbonyl compound but under these equilibrating conditions you generate another enolate that then undergoes elimination of hydroxide. So mechanistically those are things you've all seen before. Oh by the way just while I'm on this topic of color, so you'll also hear this reaction referred to as the aldol condensation. A condensation is a reaction where you lose a small molecule. So when you have put two molecules of acid aldehyde together here we're losing a molecule of water so it's a condensation reaction. The Claisen reaction which we'll learn about later, you're losing a molecule of alcohol which is why it's sometimes referred to as the Claisen condensation. Alright, so I want to put these three different reactions together now in sequence, in the sequence I've talked about. And the reaction we're going to learn about is the Robinson annulation. And I'll start with a specific example of this particular ketone 2-methylcyclohexane 2,4-dione. Now say in general we can say, let's say in general a ketone or a 1,3-dicarbonyl compound. And we're going to mix it with an alpha-beta unsaturated carbonyl compound. In other words, something very much like this over here. I'll start out, and this is kind of the archetypal example. I'll start out with this ketone. I suppose it's IUPAC name is 3-butene 2-one. Every practicing organic chemist who does a Robinson annulation will call this methyl-vinyl ketone a nickname because you have on one side of the ketone a methyl group. And on the other side a vinyl group. If you really want to sound in the know you could call it MVK. Anyway, this is an archetype for an alpha-beta unsaturated carbonyl compound. I'll write that in shorthand, alpha-beta unsaturated. And I'll say more specifically an alpha-beta unsaturated ketone because we're going to need that. Okay, and again we're going to mix this with some base. Honestly base in the real Robins, you're going to kind of get a baby exposure to the Robinson annulation. In the real Robinson annulation, base is kind of a sticking point and it's not always as easy as you just mix things together with the first base you try. We're going to in this particular example use sodium hydroxide in water, sort of one of our favorite conditions, but I'll say a suitable base here. We have time, I'll even give you an example of an acid catalyzed Robinson annulation reaction. But okay, here's the real beauty. So we mix these two components together, our carbonyl compound, ketone or 1,3-dicarbonyl compound, something that can form an enolate and an alpha-beta unsaturated carbonyl compound, something we've seen as a Michael acceptor in the presence of base. And these two components come together in a series of reactions to form, whoopsie, these two components come together in a series of reactions to form a cyclohexenone. And you look at that and you say, my God, how did that occur? Obviously there's a lot of chemistry going on here. This particular ketone happens to be important, it's called the Veylen-Mischer ketone and it's used as the basis for the synthesis of some synthetic steroids. Synthetic steroids are the basis not only of cortisone as I mentioned before, but for example birth control pills. So these are very important compounds. Okay, so what's going on here is we're going, oh yeah, and so let me, since I've been writing all of these archetypes, a ketone or 1,3-dicarbonyl and alpha-beta unsaturated ketone, let me write out the key thing here. The key thing is that we're forming a cyclohexenone. In other words, the key thing, the new feature that we've added is a six-membered ring containing a carbonyl group, hence cyclohexenone, but it's also a double bond, so a cyclohexenone. Alright, so what's going on here, we're going to break this out in just a moment, is three different reactions in sequence. So the first reaction is a Michael reaction or Michael addition. The second reaction is an Aldol reaction, and the third reaction is a dehydration. If you want to remember something, just come up with a crazy way of remembering it, and you look at this and you say, how in hell does that occur? That's crazy. That's mad. We're just going to go ahead and remind ourselves, MAD, the Robinson annulation is a mad reaction. Alright, but I'm not mad, so I will show you how this occurred. Alright, rather by now we have written curved arrow mechanisms for every one of those reactions I just erased. We've written a curved arrow mechanism for a Michael addition. We've written a curved arrow mechanism for an Aldol reaction, and we've written a curved arrow mechanism for the base-promoted dehydration. So I'm not going to write out the curved arrows, I would expect you to be able to do this, but I am going to think us through all of the intermediates. So we have an acidic carbonyl compound, or cyclohexane dione. We have a base, the most acidic thing is the cyclohexane dione. So what we end up generating first is an enolate. We're under equilibrating conditions, so reactions, so I guess I will write here to help us keep track. So we're going to generate an enolate, and I am like so, and that's going to act as a nucleophile in our Michael addition reaction. We talked last time about different representations and keeping resonance structures straight in your head. If it's hard for you to think about pushing all those arrows, the arrow down from the carbonyl from the double bond to the alkene, then just go and think of the other resonance structure here. If you want to go ahead and think about it this way, we can just say, well, I'd rather think about this resonance structure. I don't generally draw this resonance structure because it's a more minor resonance structure. The more major contributor has the negative charge on oxygen, but this is a fine resonance structure as well. Regardless of how you want to think about your resonance structures, in the Michael addition reaction, your enolate is going to add to the alpha-beta unsaturated carbonyl compound to give you a new enolate in the second step of the reaction. And you've seen that, you've drawn your curved arrow from the nucleophile, from the source of electrons to the electrophile, to the beta position of the Michael acceptor. We saw that yesterday on Tuesday. Now under equilibrating conditions, we have water. If you did the reaction sodium hydroxide in water, you'd have ethanol. If you use ethanol, another perfectly good solvent, sodium ethoxide in ethanol, or you can even mix it up and do sodium hydroxide in ethanol. Protons go on, protons come off. PKA of a ketone is on the order of 20, which means the enolate is pretty basic. PKA of water is on the order of 15.7. PKA of an alcohol, if you're using an alcohol, would be 16 or 17. Protons come on, protons go off. And so such ends are Michael addition reaction. Where now you formed a product that has formed another, that's a 15-dicarbonyl. And remember, we've learned that you can recognize a Michael addition product because there's a 15 relationship. One, two, three, four, five. It's a 15-dicarbonyl compound. All right, that's our Michael step. We've learned that the aldol reaction can occur in intermolecular fashion and intramolecular fashion. And we've learned that in equilibrating solvents, in hydroxylic solvents like water or like alcohol, protons come on, protons go off. Every possible position here can form enolate. Some of them don't lead anywhere. In other words, every possible alpha position can form enolates. Some of them don't lead anywhere. Protons come off, protons go back on. Some of them do. I'm going to generate the enolate that's going to take us on in our next step. So we can imagine if you want to write a curved arrow mechanism, your base, your hydroxide, pulling off the alpha proton, pushing in electrons to form a double bond, pushing up electrons onto the oxygen to form an enolate. Now that enolate is poised to form a six-membered ring. And we said six-membered rings like to form. We've seen aldol reactions occur intramolecule to form six-membered rings and five-membered rings. So in our next step, that enolate attacks the proximal carbonyl group to give an aldolate like so. And again, I'm not drawing curved arrows. You should know by now how to draw your arrows down from the oxygen to form an oxygen double bond, oxygen carbon double bond, from the double bond into this carbonyl carbon and up onto the oxygen to form this aldolate. In aqueous solvent, protons go on, protons come off. So the last step, we have lots of protons, whether we're in water or we're in alcohol as our solvent. The last step is protonation and thus our aldol reaction has proceeded. Whoops. The last step is dehydration. By now we should be pretty well set up to see it. And the reaction conditions, protons come on, protons go off in all different positions, but if we pull off the proton next to the carbonyl here, we're set up to form an enolate that can undergo elimination. And elimination is going to give us a stable conjugated enone. So again, I'm just going to go ahead and draw intermediates, not curved arrows. And so you can imagine forming this enolate like so. And then the enolate pushing electrons down and kicking out hydroxide to give us stable alpha, beta and saturated carbonyl compound. And so this reaction actually in many, many cases works pretty well and the two components come together in 50 or 60 or 70% yield to give a new cyclohexenone. Thoughts or questions at this point? Stereochemistry. Ah, great question. What's our stereochemistry? This compound is chiral here. What do we get? One enantiomer, the other enantiomer, the R, the S. Both of them, in the absence of something chiral to direct the reaction, we get as much of one enantiomer as the other. And one of the big areas of organic chemistry these days is being able to direct chemistry to get a single enantiomer. Why? The steroid hormone receptors in your body are all handed. If you want a birth control or you want a birth control drug or an anti-inflammatory, you want the handedness of the drug that's going to fit into the receptor properly. You don't want to be taking twice as much drug where half of the drug can be inactive or can be have a bad effect. In the case of the drug phyllidomide, which was given for, I believe, morning sickness, in pregnancy in the 50s, the children ended up being born with birth defects. Many other drugs have had this various bad effects. In this case, the enantiomer of the desired drug causes birth defects. So what's a cutting edge area of chemistry is being able to make just one enantiomer. It turns out that in this particular aldol reaction, the amino acid proline can catalyze this to give as a base, well, actually through an enamine pathway, which I might give you in the discussion section, to go ahead and generate just one enantiomer preferentially. So remember when you read about CBS reagent for reduction, and I said this is just giving you a taste of this whole area of asymmetric synthesis. Likewise, in the asymmetric synthesis of the Veylen-Mesheur ketone and related ketones, a little taste of it is that a use of a chiral base, or in this case a chiral amine, can give rise to a single enantiomer. Good question, very important, and this becomes more important when you have multiple stereocenters in the molecule. So imagine for a moment now, let's say for a moment that we had a second methyl group at this position. I'm not going to draw it in. Then you'd be saying, wait a second, now we can get two diastereomeric products. I wonder which one forms. Then you might think, well, let's see, one methyl can go equatorial, maybe we'll have thermodynamic control, and that kind of gets beyond the scope of the course. But very, very big and important ideas, and you're just getting a tiny taste of them in this introduction to one in this part of carbonyl chemistry that, as I said, is sort of a gateway to tons and tons of really important organic chemistry. All right, I want to, since this is such a big thing, I want to give us another example. Many but not all of the examples do involve 1,3-dicarbonyl compounds because quite frankly it's easier to generate the enolate to do the Michael reaction when you have a 1,3-dicarbonyl compound. So I'm going to give us in a forward sense another 1,3-dicarbonyl compound, a beta-ketoester. We're going to see this beta-ketoester later in today's lecture. What I want us to see is a Robinson annulation with a slightly different ketone and get a little faster and a little better at our thinking our way through this reaction. So I'm going to start by drawing the Robinson annulation product. Now in this case I am choosing specifically not to use sodium hydroxide. Why don't I want to use sodium hydroxide? Why am I using sodium ethoxide? We have an ethyl ester in the molecule and if we were to go ahead and use sodium hydroxide we would attack and deac and lose and saponify the ester group and then end up with the carboxylic acid which would actually decarboxylate under the reaction conditions. So in general if you have an ethyl ester you want to use sodium ethyl ester, you want to use sodium ethoxide in ethanol. If you had a methyl ester say you'd want to use sodium methoxide in methanol. And our Robinson annulation product is this and again it's a cyclohexenone and I want us to think it through now a little bit faster. I want us to learn how to see these reactions forward and backwards. So let me show you how Johnny and I and Kim probably look at this and take it apart retrosynthetically. So Johnny and Kim and I look at this and say ah this is a cyclohexenone and I know cyclohexenone can come from Robinson annulations and I know that in this reaction we can break, we can think backwards about forming the alpha beta unsaturated bond but also the bond that's between the third and fourth position so the beta gamma bond to the carbonyl of the cyclohexenone. So we can break this molecule apart in one giant retrosynthetic step and say oh this had to come or could come from this ester and this enone. That's a big bite. That's a big bite to take in one mouthful. I want to show you how to break this apart retrosynthetically in two smaller bite size pieces. Alright so breaking this apart in two smaller bite size pieces. We've seen that alpha beta unsaturated carbonyl compounds can come from an aldol reaction and a dehydration. So I can look at this enone. I can look at this alpha beta unsaturated ketone and say this part of the chemistry has to come together. Remember mad reaction, right? So this part of the chemistry can come from an aldol and a dehydration. So when I take that backwards retrosynthetically I say oh the immediate precursor to that could have been this. Other words I will write alpha beta so I'm going to write here cyclohexenone. This is my clue when Johnny's clue and Kim's clue that the retrosynthetic chemistry involves a Robinson annulation. But if you can't do that go and look at this and say oh well this is my clue if I can't yet be at that point you say oh this is my clue that this could have come from an aldol reaction so I say oh this is an alpha beta unsaturated ketone. And now you look at this next component and you say oh this is a 1,5-dicarbonyl compound. If I can number to either carbonyl it doesn't really matter. This is a 1,5-dicarbonyl compound that could have come from a Michael addition so there's the M in our MAD. And so we again go backwards and now we're at this particular precursor and our enone is in. Take yours in a sec. I want to see if other people have questions. I hear a lot of mumbling and this is good. I want to hear noise. You should be talking about this right now. So does a Michael addition always add from an alkene to another alkene or can it just add from a negative charge of carbon and acid? So this is the same question you asked before in a different form. So basically in our Michael addition whether you think of your enolate like this or whether you think of it like this it's the same thing. So yes if you're thinking about like this it's from an alkene but remember it's both at the same time. So I think that and this should be at this point in everyone's development here this should be something you're wrestling with. You actually have to actively wrestle with this chemistry to make it make sense to you. You have to be thinking and saying I'm not sure on this I don't understand so this is good. So this is exactly the questions you want to ask. Now I'm going to give you one of the questions that I like to ask. Here's the following from simpler compounds. And again I'm taking real examples that have been done in the laboratory and some of the molecules have some complexity and some personality to them. So here's an example of a real compound that can really be synthesized in the laboratory. And I want to show you my thought processes on this. It's the same thought process that I outlined on the upper part of that blackboard. I said okay I look at this molecule and I say I see a cyclohexenone and I'm going to think backwards and I know in the Robinson annulation immediately cyclohexenone says to me Robinson annulation Robinson annulation and so I look at this and I say okay in the Robinson annulation we form the alpha beta unsaturated bond and we form this bond over here and so I look and I say alright thinking backwards where does that get me? Well that's going to get me. So this ketone here, yeah this is hard the first time around. That's going to get me to this ketone over here. That's going to be this half of the molecule. And it's going to get me to this enone like so. Happens to be the same enone we just used over in that example. And I want to work this through now in the forward sense. And by the way there's a little secret here. So I sort of was a little hedging to you and I said you know cyclohexen, ketones in general can without being part of a 1,3-dicarbonyl, can do Robinson annulation, plain old cyclohexenone, plain old acetone, can do a Robinson annulation but often you're going to get a lot of aldol reaction and other stuff going on. There's something special about this ketone. It's even a little bit more acidic than a regular ketone. Remember I said regular ketone pKa20. What's special about the alpha position of this ketone? Close to the benzene. It's more specifically that proton when you pull it off you're going to get an anion that's both an enolate and benzylic. So it's a little extra acidic. Instead of being pKa20 it's going to be a little less, maybe pKa17. So a little bit better in the Michael reaction. All right so to run the reaction in a forward sense now really this ends up being kind of a one note at this point once you see the secret. To run the reaction in the forward sense we take our ketone plus our enone and we mix them together with some base. I'm taking a real example from a real experiment. The authors of this experiment use sodium hydroxide and ethanol. If that bugs you just in your own mind I'm going to write or NaOET over here. It's not going to matter. The reason they used ethanol is organic compounds generally with lots and lots of carbon and lots and lots of grease don't generally dissolve in pure water unless they're very small. And so it's generally good to have an organic solvent and ethanol is a good solvent for organic compounds. The reason they use sodium hydroxide is you can go into the lab and open a bottle of sodium hydroxide and it doesn't hurt to have some hydroxide around. But if that bugs you because it's not the one I always use just go ahead and write sodium hydroxide and ethanol should work just as well. Anyway the product here same thing now I've been writing over and over if you're feeling too lazy just write PDT. And there's your product of your Robinson annulation. As I said with the Robinson annulation there's a lot of chemistry occurring and often the details end up being condition dependent. In fact when I look in a graduate level textbook I can find you a dozen different conditions that have been used for Robinson annulation. I don't want you to know all of them but I want to show this to you for one set of principles here. And this is an acid catalyzed example and I wouldn't expect you to be able to use these conditions. In fact they're kind of specialized but what I do want to do is just show you something in mechanism that ties into something that we talked about early on. Again this is a real example. So this particular example is a cyclohexanone. It's two methyl cyclohexanone plus methyl vinyl ketone plus 3 propane plus 3 butene 2 own MVK. This particular Robinson annulation if you wanted to write it on paper and you wrote it the same way I did there you'd be fine. In practice you actually get a pretty crappy yield that way if any product. And so in practice this one experimentally was done with sulfuric acid and benzene at reflux. Again as I said you wouldn't be expected to know that but I want us to look at the mechanism because it ties into something that I talked about before. And the point that I really wanted to make is that we're getting acid catalyzed chemistry here. So you're getting an acid catalyzed Michael reaction. I want you to think about that for a moment. Remember early on when we started introducing the chemistry of enols and enolites I said enols are more nucleophilic than regular alkenes but they're not super nucleophilic they only react with really good electrophiles. And so under acid conditions we enolize at all different places. And so let me show you acid catalyzed. I just want to show you the gist of the acid catalyzed Michael reaction. So in sulfuric acid protons come on, protons go off, you generate an enol. Just a little bit of it. Protons come on, protons come off, you generate a protonated ketone. Again transiently and in small amounts. Now here's my point. Enols aren't super good nucleophiles. They're only moderately nucleophilic. Enols aren't super good electrophiles and alpha, beta and saturated ketones aren't super good Michael acceptors. But by the time you protonate the carbonyl now you've really souped things up. And so at this point you go ahead and now you're really nucleophilic and so you go ahead and like so and I'm not going to write out the whole mechanism in detail. But at this point you carried out an acid catalyzed Michael addition reaction here and then you atomized over to the ketone. Now all of the reactions we've talked about can happen in this acid catalyzed manifold. So that's our acid catalyzed Michael. You can have an aldol in an acid catalyzed manifold. So just imagine to atomizing the product that I had written over there before. So now imagine to atomizing, imagine enolizing and imagine protonating the carbonyl and again you should be able to work this out on your own. In fact I think there may be a problem along these lines in the textbook. Okay, so you can see just as before you can protonate, you can generate an enol and again you're set up for an intramolecular reaction. So again we're going to push electrons like so in the acid catalyzed manifold. And again I'm not writing out a super detailed mechanism. I'm just sort of sketching things out for you. Alright so that's our and then of course you pull off a proton. You're an acid, you're in sulfuric acid and benzene protons come on, protons go off. So now that brings us over here. So if you want just for the hell of it I will write out my product over here and if you want just for the hell of it I will write out my product over here. But again you should be able to go ahead and work through this on your own. Alright so the last step and this one I know you can do because you've been doing it back. I think it was in chapter 8 where we were doing acid catalyzed dehydration of alcohols to generate alkenes and I think it's also problem 24.4 if I remember correctly. Alright so under these conditions again strong sulfuric acid protons go on, protons go off everywhere in the molecule. You can protonate your OH group. You can protonate your hydroxyl group. It becomes a leaving group, leaves with its electrons kicking out water and so now again in this sort of sketch of a mechanism that sets us up for carbocation formation that's a positive charge over here and then that sets us up for loss of a proton so I'll just write minus H plus. Alright so the big picture here is not those reagents. Those reagents happen to be for this particular reaction. The big picture here is that this manifold of enolate with a Michael acceptor or enol with a protonated Michael acceptor. Enolate with a carbonyl or enol with a protonated carbonyl. Dehydration by an E1CB mechanism remember that's what I called it when we talked about a Michael we talked about the aldol dehydration under base conditions. It's elimination unibolecular conjugate base. That means you pull off a proton and then do an elimination or elimination by way of forming a carbocation. Alright that's what I want to say about the Robinson annulation. Any thoughts or questions at this point? Somebody needs to answer this question why in this reaction does the double bond go here and not let's say over here. Somebody needs to answer that question. They're both unsaturated so in one case you imagine dehydrating conjugated yes. So all of these Robinson annulation conditions we're learning about are under thermodynamic control and even if you go ahead and have a reaction occur and say give the beta gamma unsaturated compound transiently thermodynamically the thermodynamic product the deepest energy well is the alpha beta unsaturated compound. Protons go on, protons come off, you reprotonate, you get a carbocation, you deprotonate to the more thermodynamically stable alpha beta unsaturated carbonyl compound. And of course really this Robinson annulation chemistry because it is under thermodynamic control is much more subject to sort of the whims of thermodynamics and the whims of side reactions than say where I started us out in the directed aldol chemistry where I said dammit, we organic chemists want to take control ourselves we do that by generating the enolate that we want reacting it with the carbonyl compound we want in the place we want. It may or may not be the kinetic product, it may or may not be the thermodynamic product but we've controlled that reactivity. Alright I want to take us now to some more very very old chemistry the Claisen reaction or Claisen condensation. So we've been seeing all of these 1,3-dicarbonyl compounds we saw Melonic ester, we saw Acetoacetic ester, right diethyl malonate, ethyl thrioxotubutonate, we've seen Acetyl acetone so we've seen that these 1,3-dicarbonyl compounds and of course we saw cyclohexane dione and we saw a carboethoxycyclohexanone. These 1,3-dicarbonyl compounds come from somewhere and it turns out they come from some other chemistry that's also really beautiful and really simple once you understand it. So if we take ethyl acetate and we treat it with sodium ethoxide and ethanol first, so I'll write 1 to indicate we're doing that in a first synthetic step and then we carry out an aqueous workup with some aqueous acid that means some dilute HCl, you're not cooking things together you're just throwing it in before shaking things in a separatory funnel. You get ethyl acetoacetate, you get ethyl thrioxobutonate. So this reaction involves more carbonyl chemistry of the precise sort that we've seen before. Under these conditions you can form an emylate, you don't form a lot of it, remember ethanol, PKA conjugate acid, PKA of the conjugate acid of sodium ethoxide, conjugate acid is ethanol, PKA about 16. Ethyl acetate is an ester PKA 25. So you have this equilibrium and it's sort of right at the edge of where I said equilibria kind of count. You have this acid base equilibrium with the enolate plus ethanol, that equilibrium lies way, way, way, way, way to the left. Again I'll write our PKA here, PKA 25, PKA 16 or 17, your textbook use is 16 so I'll use 16. It's nine orders of magnitude, equilibrium constant, 10 to the negative 9 to the left and it's just right on the cusp. I said 10 to the 10th, 10 PKA units difference is sort of right where these equilibria can become significant. So you're set up to generate an itsy bitsy, ency little bit of the enolate and you have plenty of ethyl acetate sitting around so that ethyl acetate can react with that itsy bitsy, ency bit of enolate. And of course what do we have? We have our enolate is a nucleophile, our ethyl acetate has carbonyl in it, it's an electrophile. Electrons flow from the nucleophile to the electrophile, by now we should be used to pushing our arrows this way, if you need a little crutch, write the other resonance structure of the enolate, electrons flow from the enolate to the ethyl acetate to give rise to a tetrahedral intermediate. Remember tetrahedral intermediates are unstable, they break down, our oxygen kicks back in, our carbonyl carbon oxygen double bond is very strong, we can expel a leaving group, our ethyl oxide leaves, we get our product, well kind of sort of. See our ethyl oxide is good base here, pKa of about 16 for the conjugate acid and our 1,3-dicarbonyl compound is reasonably acidic, pKa of ethyl acetate is 11 and this is really the kicker in the chemistry, this is what drives this chemistry, I'm not going to write the hydrogen lone pairs here, this is what drives the chemistry, our equilibrium lies now way to the right to give rise to your enolate, I'll write one resonance structure if you prefer to write another one you can, plus ethanol and again I'll write our pKa of 16, so that equilibrium lies five orders of magnitude to the right, that last reaction drives this chemistry and you notice in this case our chemistry is actually stoichiometric in base because at the end of everything we've used up one mole of sodium ethoxide and generated one mole of our enolate of ethyl acetoacetate, so this chemistry requires a full equivalent, the aldol reaction in theory you could get away with just catalytic base. Absolutely, at the end of the reaction we're not done yet here, I've just given you the mechanism for the conjugate addition, at the end of the reaction you add acid, literally the way you would do this chemistry would be to take some sodium ethoxide, put it in a flask or take some ethanol, throw in some sodium to generate sodium ethoxide, throw in some ethyl acetate, boil it up for a while, after you've boiled it up for a while until the reaction has gone to completion, you'd let it cool to room temperature, maybe even put it in an ice bath, add a little dilute aqueous acid and do a liquid-liquid extraction or distillation to isolate your product. So some students look and they say, wait a second, we're adding acid, why doesn't the ethyl ester hydrolyze, well there's a big difference between cooking, between heating and for a long time letting an ethyl ester sit or an ester sit with acid, that'll hydrolyze it, but if you don't heat it or you just let them come in contact for a short time, that doesn't hydrolyze your ester. Alright, so one of the things that I always like to do is integrate particularly in this chemistry that is so rich and so full of relationships and synthesis. I like to talk about how do you synthesize molecules, how do you recognize them. So I'll give you a typical problem and show you my thinking on it and show you some of the beauty of this chemistry. So let's go ahead, give us a little diversity here, I'll make the methyl ester. Alright, so let's synthesize this methyl ester from simpler compounds. You can even name it, what's it going to be, 1, 2, 3, 4, 5, 6, so it's 2 ethyl, 3 oxo, methyl 2 ethyl, 3 oxo hexanoate. Alright, so synthesize methyl 3 ethyl, 2 ethyl, 3 oxo hexanoate from simpler compounds. Alright, so I look at this compound and I say alright, we've now learned a new clue. We've now learned a new retro synthetic clue that we've learned that when we see a beta di carbonyl compound, we can cleave the bond between the alpha carbon and one of the carbonyls in a Claisen type reaction. So I look at this molecule and say ah, retro synthetically, I'm going to split it back to this, well it doesn't matter right now when I'm thinking retro synthetically, some sort of group there that's going to leave and this, that's methylbutanolate and then I'll look and say oh, okay, wait a second, these two are the same thing, they're both four carbon, carboxylic acid family compounds and so I'll say alright, I've got a synthesis of this. We've been talking about Claisen chemistry, I'll just take methylbutanolate, treat it with oh, it's a methyl ester, I better use sodium methoxide and methanol so I don't transesterify, if I were to use sodium ethoxide and ethanol, I'd transesterify and get some or all of the ethyl ester and then I go ahead and after cooking it up, I'll carry out and make this work up and that's going to take me to my desired product. Another example of a plasma generator. All right, this is where this chemistry really gets beautiful and where this chemistry really gets rich. When different people can look at things the same way in different ways and both come up with right answers, that's profound because ultimately building molecules is a chess game. It's this set of many different right moves that can be used to put together a molecule. And so one person can look at the alpha, beta unsaturated carbonyl compound I've drawn here and say I'm going to break this bond between the alpha carbon and one of the carbonyl. And another person can go ahead and look at the same molecule and say I'm going to break that other carbon, I wonder what happens. Now not every move ends up being a right move. Sometimes you get problems and that's where you think through in the forward sense. But this particular example happens to have two right moves to it because I break that bond retro synthetically and now I come back this way and I say where does that lead me? Okay, well I've got this forepinone, I've got this ketone here and it's got two symmetrical alpha carbons and I can imagine another methyl group here. I could do a different sort of clasin reaction where I take dimethyl carbonate, sometimes I'll write OME, sometimes I'll write OCH3, they're of course interchangeable and I'll take sodium methoxide, they're just different ways of writing the same thing. I'll take sodium methoxide in methanol and aqueous acid, okay does that make sense? Let's see I guess well there's only one component that can form an enolate. There's only one type of enolate that can form whether I enolize to the left or the right it's the same thing. Enolate can attack this carbonyl compound and ultimately then the same chemistry form a tetrahedral intermediate, kick out a methoxide, now we have a 1,3-dicarbonyl, the 1,3-dicarbonyl is more acidic, the methoxide pulls off the proton and I've come up with a reasonable synthetic root, a reasonable alternative synthetic route to the compound that I asked the question about and that's beautiful, that's profound. We call this reaction a cross-clasin reaction, clasins in name so I'm capitalizing it or at least trying to. Just like in the crossed-aldol reaction where we talked about one enolizable component generally a ketone reacting with another nonenolizable component generally an aldehyde, one can have a cross-clasin reaction. Let me give you another example, it's an example I mentioned earlier it's the one we used in our Robinson annulation so I thought it would be cool. So cyclohexanone, simple compound, treat it with soda, this is just a riff on the example above, treat this with sodium ethoxide in ethanol and then treat it with diethylcarbonate. Now diethylcarbonate is the diethyl ester of carbonic acid, dimethylcarbonate is the dimethyl ester of carbonic acid, they're in the same family, carbon's in the plus 4 oxidation state, one higher than a carboxylic acid so it's two higher than a ketone, three higher than an aldehyde. Same thing, anqueous acidic workup generates our enolate, enolate attacks the diethylcarbonate, it generates the 1,3-dicarbonyl and ethoxide, ethoxide pulls off the proton, regenerates a stable enolate, after aqueous workup you protonate the enolate and the reaction gives you your product. Alright this business about generating a stable enolate is really, really important, this is the thermodynamic driving force behind the Claisen reaction and I'll show you how important it is. If I go ahead and take something that can't form a stable enolate, so I'll take ethyl isobuterate, ethyl 2-methyl propanoate and again I'll envision cooking it up with our favorite condition, sodium ethoxide in ethanol followed by an aqueous workup. You might think oh wait a second, okay that's just like all these other examples that I've been tossing up on the blackboard and you might think okay we envision generating the enolate, enolate adds in, we get a Claisen condensation, we get a 1,3-dicarbonyl compound. But we have that problem, no acidic alpha proton and that thermodynamic driving force is necessary for the reaction, there's five pKa units, remember every order of magnitude, every factor of 10 in equilibrium constant at room temperature is worth 1.36 kcal per mole. So 5 times 1.36 we're practically up at close to 10 kcal per mole of driving energy for that reaction. Carbon-carbon bond is on the order of 80 or 90 kcal per mole, a carbon-hydrogen bond, similar sort of strength, 100 kcal per mole they're about. Right is we're at an energy difference that's about a tenth sort of forming bonds and without that energy we just can't drive this equilibrating chemistry. So to show you what that means, that means that if I tried to do the reaction, if I mix the product under the reaction conditions, this is an equilibrium, this reaction goes backwards. In other words, if I take this hypothetical product and I somehow manage to make it, there are other ways to make it, and I treat it with sodium ethoxide in ethanol, we end up breaking this product apart to two molecules of ethyl, of ethyl-ice butyrate. It's the reverse of a Claisen reaction and we call it the retro-Claisen reaction. I'm going to leave it to you to work out the mechanism. I just got the homework problems up from the textbook on Chapter 24. One of the problems about two-thirds or three-quarters of the way through, I think involves a retro-Claisen. I just looked at it very quickly. So you want to think about the mechanism there. And I'll give you this reminder hint that the mechanism, any mechanism in reverse is got any reverse reaction, any reaction in reverse goes through the same mechanism in reverse. Remember, that's what we call microscopic reversibility. So if you can write the mechanism for the Claisen reaction in a forward sense, you can write it in the reverse sense, just start at the last step. Obviously, you don't have that deprotonation, but start at the breakdown of the tetrahedral intermediate and envision adding a nucleophile to that, envision adding ethoxide to that and push some arrows and you'll be right back at your reactants. All right, we saw that the Aldol reaction could occur intramolecularly and we saw that five and six-membered rings were particularly stable. The same with the Claisen reaction, except it gets a special name, the Dieckmann reaction, the EIECK, MANN reaction, also called the Dieckmann condensation because again, we're spitting out a molecule. So I'm going to take the diethyl ester of the seven-carbon dicarboxylic acid. I want to show this to you in the forward sense. We'll see this in the reverse sense in a moment. So one, two, three, four, five, six, seven. And we'll envision treating it with our now favorite conditions of sodium ethoxide in ethanol and aqueous workup with some acid. And the product of the reaction is this ethyl ester. Same ethyl ester we used in our Robinson annulation reaction. The mechanism, just the Claisen reaction. Often, when students see rings for the first time in intramolecular reactions, they get freaked out. So let's go ahead and do sort of an abbreviated version of the mechanism. Okay, we're under-equilibrating conditions. We generate a teeny-eeny bitsy-bitsy bit of enolate. I'm getting punchy up here. We generate a teeny bit of our enolate. Our enolate can react intramolecularly. We push our arrows, push our arrows up onto the oxygen, forms a six-membered ring. Our intermediate, our tetrahedral intermediate is a six-membered ring. Six-membered rings generally are good things. They generally can form easily. A tetrahedral intermediate can break down, kicking out ethoxide. Remember you can generally kick out anything up to about and including 25 pKa as a leaving group from a tetrahedral intermediate. Remember it's different than an SN2 displacement. That pKa of 25, which I said was kind of the cutoff, we saw that in a heliform reaction. That also plays in the retro-clasin reaction. So there's one step. When you write out that mechanism, you're going to have to do and say, I don't know about that step. You're kicking out a leaving group with a pKa of a conjugate acid of 25. So our tetrahedral intermediate breaks down plus ethoxide. Not going to draw in all my lone pairs of electrons. And that final step, that equilibrium that lies way, way, way, way, way to the right, pulls off the proton, generates our unilate. If you don't like the way I draw my unilate, draw the negative charge on the alpha carbon. All right. So let's think about what we just saw. Here's our product. We use that product in a Robinson annulation. We use that product to make something very complicated, from something a lot simpler. We've now seen how to make that product from simpler, to make that reactant from simpler molecules. We've seen it in two different ways. For that matter, we also saw how to make our alpha beta unsaturated carbonyl compounds. Those are made by an aldol reaction with dehydration. So your MVK, you can make it from an aldol reaction with dehydration. Okay. But what about this one? Well, remember, this is our retrosynthetic analysis that we've been learning about. It's a 1,3-dicarbonyl compound. The way we see it over here, you break it apart retrosynthetically, like so, to this diester. And if you count, that's just 1, 2, 3, 4, 5, 6, 7. 1, 2, 3, 4, 5, 6, 7. That's just that. And so you can see one way to break it apart. But you can also see a second way to break it apart. We saw that way just a moment before. That way of breaking it apart breaks it apart to cyclohexanone and diethylcarbonate. And that's really the beauty of being able to recognize these relationships. And so let me end with a very simple problem. Simple. I was being lazy. I figured, all right. The problem that's analogous, because we've seen so much chemistry in these past two lectures and in the past four lectures that your heads are probably spinning right now. And that's OK. When you work the problems, that spinning is going to stop. Things are going to crystallize in your head, and you have to work the problems. All right. So here's a sort of noic exam problem. I didn't say it would be an exam problem. I just said it's the sort I always like to ask. You've seen three of them today. I think it's three. Synthesize this compound from simpler molecules. I'll say compounds. All right. Well by this point, I don't think I can fool you. This is just an analogy to what I've written over there. And of course you have it up on the blackboard. So 1,3-dicarbonyl compound. We can split it apart in two ways. We can split it apart at this bond here. And I just need to be able to count correctly. 1,2,3,4,5,6. Usually at this point in the class I'll miscount. So I've got to make dimethyl adipoate. The dimethyl ester of adipic acid. You could make that from cyclohexene if you wanted. And we'll treat it with sodium methoxide and methanol. Are you sodium methoxide? Because I have the methyl esters. I don't want to hydrolyze them with sodium hydroxide. Suponify them if you want to be technical. I don't want to go ahead and transesterify them. We carry out an aqueous workup because we've got to protonate that anion. There's our product. And we also know, and I'll draw a real long arrow onto the other blackboard, we also know that we can form that bond. And so we say, oh, wait a second. We can do a crust clasin. We take cyclopentanone. We'll take our favorite base, sodium methoxide. Now I'm making life a little easier for you. I've done these reactions myself. And I've often done these reactions with sodium hydride as a base. But there are about a bunch of bases you can use. And I'll make it simple. We'll use sodium methoxide and methanol. I've used sodium hydride and dimethyl carbonate as solvent. Aqueous acid workup. Same old, same old. We haven't seen a lot of variation there. And bing. Two different ways to the same product to write answers. All right, we will pick up next time with, I think, our quiz next time. Is that right, Johnny? And talking about chapter 25. Have a good day and good weekend.
This is the third quarter course in the organic chemistry series. Topics covered include: Fundamental concepts relating to carbon compounds with emphasis on structural theory and the nature of chemical bonding, stereochemistry, reaction mechanisms, and spectroscopic, physical, and chemical properties of the principal classes of carbon compounds. Index of Topics: 1:40-Michael Reaction 4:19-Aldol Reaction 5:54-Aldol Reaction with Dehydration 8:32-The Robinson Annulation 13:13-Reactions Involved in Robinson Annulation 26:15-Robinson Annulation Example 28:11-Retrosynthesis Example 33:55-Synthesizing Examples 39:55-Other Conditions 41:11-Acid-Catalyzed Michael Reaction 43:30-Acid-Catalyzed Aldol Reaction 45:18-Example Problem 50:00-Claisen Reaction 53:21-Claisen Reaction Mechanism 57:59-Synthesis Example 1:04:27-Crossed Claisen Reaction 1:08:46-Retro-Claisen Reaction Mechanism 1:11:04-Dieckmann Reaction 1:17:41-Synthesis Example
10.5446/19416 (DOI)
Good morning. Good morning. Hey. All right. Well, we now start chapter 24, and we really come to what I think is the pinnacle of organic chemistry in terms of reactivity, mechanism, synthesis, retro synthetic analysis. And this is the carbonyl chemistry of various types of carbonyl condensation reactions. The aldol reaction, the Michael addition, the Claisen condensation, the Robinson annulation reaction, the intramolecular Claisen called the Dieckmann cyclization, the intramolecular aldol reaction. This putting together the reactivity of carbonyls that we learned about is electrophiles and the reactivity on the alpha carbon is nucleophiles and being able to assemble some very complex and important and beautiful molecules as a result of this. There's also a lot to think about. And so what I'd like to do is to start talking about the aldol reaction, which really lays the groundwork for all of these carbonyl reactions. And indeed, even some of the sugar chemistry you'll be learning about later on in chapter I think 28 or 26, I guess. All right. So in the aldol reaction in general, what happens is an enolate reacts with another carbonyl compound. So you have a carbonyl compound and I'm going to write this very, very generically. A carbonyl compound with an alpha hydrogen and honestly we're talking about just about any of them, both the ketone or aldehyde family, but also the ester family. Honestly, even though I've written this as carbonyl X, I said in this broad ester family and this broad carboxylic acid family, you have carboxylic acids but also nitrials. And so the chemistry I'll talk about today even is applicable in certain cases to nitrials. But the main thing is we have a carbonyl compound with an alpha hydrogen. And we have some sort of base and we'll be talking a lot about bases right now. I'm just giving this sort of as a generic cartoon. And under some conditions we get an enolate and we allow that carbonyl compound to react with a ketone or aldehyde, sometimes all mixed together, sometimes done in sequence. We'll talk more about specifics in a moment. And the enolate, let me draw my negative charge here, the enolate of course is nucleophilic at the alpha position, the ketone or aldehyde is electrophilic. And so we form a bond between the enolate and the ketone or aldehyde. And in the most generic form then, the initially formed product is going to be an aldolate and under some conditions, sometimes as part of the reaction condition, sometimes in a sequential separate step, proton source can become available or we can add a proton source. And I'm writing this very generically as H plus. Could be added acid. It could even be alcohol or water in the reaction mixture. We'll go through details in a moment. But whatever your proton source is here, again very generic, so I'll write proton source. Whatever your proton source is, we protonate the oxyanion of the aldolate and the overall result is an aldol product. And you can recognize an aldol product because it's a beta hydroxy carbonyl compound. Later on I'll also show you aldol products that are alpha, beta unsaturated carbonyl compounds. All right, so that's sort of the overview at 5,000 feet. I now want to go to a very specific example. I love the aldol reaction. I love it intellectually because there's so much to think about mechanistically, synthetic. I also love it because it's beautiful to do synthetically in the laboratory. And so I'll give you an example that I use in my Chem 160 laboratory class. I wanted a simple sort of cookbook aldol recipe for my students. It's the first day of laboratory. This is an upper division laboratory course. I urge you to take it. It's a lot of fun. And the first day, all in one day, they do an aldol reaction and purify the product by one of my favorite recipes, which is basically you take some LDA and THF. You talked before about how often you will make your own LDA by reacting butyl lithium, a very, very strong base with diastropoplamine, somewhat less basic, but still very strong and sterically hindered base. Organic chemists often cool things with dry ice. Dry ice is negative 78 degrees Celsius, which is why you'll often see that otherwise odd-sounding temperature. Then in a separate step, one adds the carbonyl compound, so you generate the enolate at negative 78 degrees. The carbonyl compound that I chose for my Chem 160 students was benzophenone. Ph is just a benzene ring, a C6H5 unit. Benzophenone is just a simple carbonyl compound. And then the source of aqueous acid that I like to use is aqueous ammonium chloride. Just a mild acid, right? NH4 plus is acidic, so I'll write this in parenthesis as H3O plus. You could write either underneath the arrow. But this is sort of my favorite cookbook, what's called a directed aldol reaction. Directed meaning we're first generating the enolate. We're then in a separate step adding a carbonyl compound and isolating the product. So I'll write directed aldol reaction. Capitalized aldol here is a title, but aldol is a word. It's not a proper noun. So if you're just writing it, you wouldn't capitalize it. Aldol, which we'll hear about at the end of today's lecture, is actually somebody's name. All right. So the aldol product that you get in this specific example that my students in Chem 160 get and then recrystallize, beautiful, beautiful white crystals, great yield. It's just a fun laboratory experiment to do. But it is this beta hydroxy ester. All right. I want to give you another example. This particular recipe for directed aldol really just works and works and works. I'll give you another example just so we can see some of the diversity. Here we generate an enolate of an ester. We reacted it with a ketone. Just for variation, say let's take cyclohexanone. LDATHF. I know you stress over what to write on exams. Here I'm not writing the temperature. It probably doesn't matter whether I do or don't. I'm writing THF. Probably doesn't matter whether I do or don't. Don't stress too much. But very important, we're going ahead first, number one, generating the enolate. Two, and this time I think I'm going to use an aldehyde and this generic in this specific example, let's use isobuter aldehyde as our carbonyl compound, 3-methylpropanol. And we'll do an aqueous workup. And here I'll be a little more generic and just write H3O plus also OK to do. H3O plus could be aqueous ammonium chloride. It could be dilute aqueous HCl or dilute sulfuric acid. And in a very, very typical situation you would then extract your product into an organic solvent and dry it over Pimag sulfate and filter it and concentrate it. And here's our aldol product. Another beta hydroxy carbonyl compound. In this case our enolate was generated from a ketone. In the previous case from an ester. In this case our electrophile was an aldehyde. In the previous case a ketone. All right. What I want us to do at this point is to learn to recognize the aldol synthesis. And so I want us to get in the habit of learning to think backwards. We've talked about retro synthetic analysis before. It's a very important skill to be able to see backwards. And so I'll write out a sample problem showing the type of thought process. All right. So this is exactly the sort of thing that students in organic chemistry and research encounter all the time. They're making a complex molecule like a natural product and they need to make it from stuff you can buy. And so I'm going to phrase this as synthesize and I'll draw out the compound here rather than naming it. But you can figure the name of it if you like. See the one I've chosen for this particular example is this molecule. And I'm going to synthesize this molecule from simpler compounds. Why because generally as you build up bigger molecules with more functional groups there's more complexity. Chances are they're not available but simple stuff is available. You can buy it. On the exam I gave you a sort of a restricted chemical catalog of four carbon atoms or fewer. That's sort of an artificial example. But it's basically what people deal with. There's a bunch of stuff you can buy. Psyche, ketones, alkynes, alcohol halides, alcohols, alkenes, alkanes. Go ahead use anything you like to make this. Now let's focus on the thought process. And remember the big thought process that we use, this real height of thinking, Nobel Prize winning thinking, E.J. Corey type of thinking is the idea of thinking backwards. Retrosynthetic analysis. We use this type of open arrow to show retrosynthetic analysis. And the beauty of being able to think backwards is it liberates us from conditions, from reagents, from details. What oxidizing agent do I use? What base do I use to see the entire big picture? And the big picture here is we have a beta hydroxy carbonyl compound. This is the alpha carbon, this is the beta carbon. So this is a beta hydroxy carbonyl. And when we see a beta hydroxy carbonyl compound immediately that should clue us in. The bond between the alpha and the beta carbon can be made by an aldol reaction. And so I look at this, maybe I draw a little squiggly line here to remind myself. And then I look and I say oh wait a second we've got this ketone on the left. Three methyl two butanone. And we remember on the right here that this alcohol was part of a carbonyl compound before we formed the bond and added a nucleophile. In other words that came from a ketone acetone. And so that's the retrosynthetic analysis. That's the act of thinking our way through the problem. Now we just go on and say all right what do we need to do? We need to generate the enolate of three methyl two butanone and then we need to allow it to react with acetone. It's a directed aldol reaction. Now we can worry about details and we think back wait a second, wait a second, wait a second, alright is this going to work? There are two enolates that can be generated when a base pulls off an alpha proton. We can pull off an enolated proton at the three position or we can pull off a proton at the one position. Then we think back to regiochemistry and kinetic enolates and say ah we're in good shape here. We remember that when we treat a compound where you've got a less sterically hindered position like a methyl group and a more sterically hindered position like an isopropyl group, the LDA, this bulky base, preferentially pulls off the more accessible proton to give you the kinetic enolate, to give you the enolate on this side. We then add our acetone and we carry out an aqueous workup. In practice typically you might add the acetone at negative 78 degrees and then allow the reaction mixture to warm up to zero degrees before quenching it with some mild aqueous acid like ammonium chloride or acetic acid or dilute HCl. If you use something like HCl you're not going to let the reaction get hot, you're not going to stir it with it a long time, you're just going to add a little dilute HCl and immediately do your liquid-liquid extraction. We'll come back to why that's important in a moment and later on. Alright I like to start by teaching about the aldol this way and I like to do the aldol reaction by the directed aldol procedure because it is so intuitive. It's this mindset of taking control. It's the idea I'm going to make the nucleophile I want, I'm going to add the electrophile I want and darn it that nucleophile is going to react with that electrophile the way that I want. Now historically that's not the way the aldol reaction was developed and up until just before the 1970s LDA really wasn't on the scene as a base and a lot of organic chemistry was and continues to be done by mixing together some moderately strong base. LDA is a very strong base and some carbonyl compound or carbonyl compounds. Now the original aldol reaction was actually discovered at the beginning of the 19th century and I'll show you that reaction. Chemistry the beautiful thing about chemistry is of course it works across all time, all space and all place. Works on Mars, works in the 15th century and it will work in the 25th century. So, the original aldol was acid aldehyde with a base and your textbook also makes reference to this. I'm going to be a little dicey about the base on the blackboard. I'm going to write hydroxide. Now the big secret according to my recollection and I read about this a while back so I may be fuzzy. I think the base that was used originally was calcium hydroxide. Organic chemists for the most part don't use a lot of calcium salts or calcium metal in synthesis these days. Sodium hydroxide is a lot more common base. So your textbook and probably I am not going to write out CAOH2 because you probably are never going to see it again but the principle is the same. The reaction happened to be done in water. Acid aldehyde is a small molecule. Water dissolves small organic molecules right. It's got one oxygen atom for two carbon atoms and it was done at a cold temperature at 5 degrees Celsius for 4 to 5 hours. And the product of this reaction in about 50% yield was the aldol product of bringing together two molecules of acid aldehyde. Wow. And this compound is called aldol, trivial name. Now you think about it, you think about it and I've already said a lot of the ethyl compounds sort of bear the name of things. When you go and you get a glass of Scotch it contains alcohol that's ethyl alcohol, ethanol. When you go ahead and you get a bottle of ether that's diethyl ether. So it kind of makes and we talked about acetoacetic ester right, it's the ethyl ester. And so it kind of makes sense that the archetypal aldol is the aldol of acid aldehyde, the two carbon unit and the product is called aldol. As I said, not a proper name doesn't get capitalized. All right, so what's going on in this chemistry? Well, you should now be on top of things enough to write out all of these mechanisms. I'm going to go through it again just in case you're a little bit rusty. All right, so in this first step and this unlike the directed aldol is a big gommish. It's just acid aldehyde and base sat together in a bottle of water for four to five hours and then worked up. So first step, hydroxide anion pulls the alpha proton, one of the three alpha protons off just as we've seen before to generate and enolate anion. All of these steps are equilibria and so I'll write an equilibrium arrow. In the directed aldol we're taking a little more charge and basically because things are occurring at very low temperature and we're using a very strong base they're irreversible but here for the most part all of our steps are equilibria. So we generate our enolate. I'll even be a good person and write in water. All right, second step in this big gommish. Now we have plenty of aldehyde. It's just floating around aldehyde and hydroxide and enolate. Our enolate is nucleophilic at the alpha position. Electrons flow from the enolate down from the oxygen to the alpha position attacking the alpha carbon. Remember we have two resonance structures for the enolate. I generally prefer to draw the major resonance structure but in the back of your mind is also this resonance structure with negative charge on the alpha carbon and so this flow of electrons is just embodying bringing that charge to the negative carbon. It's not to the alpha carbon. It's not at one position or the other. It's at both positions at the same time but I can only draw one resonance structure at a time. Electrons flow up onto the carbonyl and this gives rise to the aldolate. Now in the last step of the reaction we're in water. In water we're in alcohol. Protons go on. Protons go off. We have lots and lots of water present. So we have this mass action driving the reaction. We pick up a proton. We regenerate our hydroxide. As you can see hydroxide is a catalyst for this reaction. It's consumed in the first step but recreated in the last step and so it's catalyzing the reaction bringing together the two components. All right. One of the things that's confusing in learning the aldol reaction is often the exact course of the reaction ends up affecting the products. The products form depend on the exact course of the reaction. Particularly in the non-directed aldol reaction where we're just mixing things together, typically we have a series of equilibrations occurring. And as the chemistry goes we can drive things further and further downhill thermodynamically. So one of the features of the aldol reaction is that higher temperatures in longer times tend to lead to dehydration. And by dehydration I mean the loss of the beta hydroxy group and alpha hydrogen. Let me show you what I mean. So let's take the same aldol reaction and we'll take acid aldehyde and a base. As I said these days people tend to use sodium hydroxide for the aldol reaction. If you're running it under equilibrating conditions it tends to be run in water or in alcohols like ethanol. And so I'll say water. And let us say heat. In other words now instead of cooking the thing or letting the thing go for four or five hours at five degrees Celsius, remember chemistry is very slow at cold temperatures in general. In general reactions go about two or three times faster for every ten degrees Celsius. So you go up from five degrees up to fifty or a hundred degrees and reactions that might not otherwise occur can occur very quickly. And the product of this reaction now is three butene al. Is two butene al. Alright so what's occurring here? Everything that's occurred before is occurring but now we're getting another reaction in addition occurring as a result of the higher temperature or longer reaction times. And this is what we call an E1CB mechanism. It stands for elimination concerted base. Let me just show you what I'm talking about here. It's in this mechanism. Alright. So here's our hydroxide. Here's our beta hydroxy carbonyl compound. So under these reaction conditions you can again pull off an alpha proton to get an enolate. And now in a second step we can spit out hydroxide. So our enolate kicks back. We push out hydroxide. So a lot easier to think about if you remember the resonance structure in which we have a negative charge on the alpha carbon. And that resonance structure you can just think of it as directly eliminating. As I said I prefer to write my enolate this way but you can think of it just as well. Like that. Ah, great question. What we need to make alcohol a good leaving group. So we see two different themes in organic reactivity. One is the theme of leaving groups in SN2 displacement. In SN2 displacement reaction a good leaving group has to be a very, very weak base. Its conjugate acid has to be strongly acidic. Abramide, iodide, all are good leaving groups. HCl, HBr, HI all have pKa's in the negative. In general in an SN2 displacement reaction a leaving group is generally going to be a very strong acid for the conjugate base. I draw a cut off right at about positive 5 for the pKa because I can give you examples where you have acetate as a leaving group and that's about it. SN2 reaction you're going through this trigonal bipyramidal transition state. Carbon cannot have 10 electrons around it and that nucleophile is coming in the leaving group is leaving right at the same time. It's a bad reaction. It's a difficult reaction. It only occurs with a good leaving group. Then you have the other class of reactions with leaving groups and that's the reactions we saw in carbonyl compounds with say ester hydrolysis where now we can have a leaving group that has a pKa of let's say 16 or 17. A nucleophile adds to a carbonyl. We get a tetrahedral intermediate and that tetrahedral intermediate kicks out ethoxide, methoxide, hydroxide in this type of chemistry. The addition elimination chemistry manifold allows much more basic leaving groups, much less good leaving groups, leaving groups with weaker conjugate acids to leave. This falls into that exact same manifold because you are dead right. Hydroxides are leaving group here. pKa of the conjugate acid 15.7. But it's not going through that manifold where you have to fit 10 electrons only transiently around the carbon. You cannot get a stable species with 10 electrons. But you can get a stable species with a negative charge on adjacent atom. Everyone's happy it has 8 electrons. You push everyone still has 8 electrons. Same idea as the breakdown of a tetrahedral intermediate on say an ethyl ester. It's all right in you here and we can push out ethoxide happily. Really, really important principle and I'm glad you asked other questions at this point. Great question, great principle. Couldn't the alkene form in between the alcohol group and the carbon and we can just give us that? Couldn't the alkene group form where? Oh, in between the alcohol and the alcohol carbon. That's what we're doing. Oh, could we write the mechanism this way? Yeah. Absolutely. Yes, and this are just two pictures of the same thing. Remember in your mind's eye you have both resonance structures. All right, let me give another example. So I was playing with acid aldehyde there in that example. And all sorts of other aldehydes work. So I'll just take a specific example. This may have been from your textbook. It just shows you the sort of conditions. The acid aldehyde example and in the end because of some reactivity isn't the best example as far as yield and principles of reaction go. But I want to give you a very specific example. Just take butyraldehyde, sodium hydroxide at 80 to 100 degrees Celsius and this is a real example from the laboratory. You would never be expected to know the exact temperature, the exact time. But this reaction happens to run over three hours. And I want us to look at the product for a second because we're going to have to learn how to visualize these sorts of products. And so here's the product of reaction. If you want to name it, it's 3 ethyl 2hexenol or 2 ethyl 2hexenol rather. But the trick in recognizing these types of compounds is to be able to say ah. In my mind's eye, I can see that this double bond of this alpha beta unsaturated carbonyl compound must have come from an aldol reaction. And when you look at that, you say oh, okay, I can see this half had been one molecule of butanol and this half here, 1, 2, 3, 4, had been the other half of butanol. Let's try another example. And I'm going to phrase this as a problem. Let's just as I phrased the previous one. So let's say synthesize and I'll draw this compound. I won't name it. Let's synthesize. I think this one actually may be an example from your textbook but it's a nice example so I figured I'd use it. Let's say synthesize this molecule and again we're going to say this broader thing from simpler compounds. Take a moment for yourself to go through the retrosynthetic analysis and split the molecule apart just like we envision here splitting this molecule and working backwards with a retrosynthetic arrow to two molecules of butanol. Got it? What's the carbonyl compound that generates this? I can hear you saying it. The word, the casual name for this is propyophenone so we're going to do the same thing. If you want the formal name it's one phenopropanone. So we'll split it apart. Our clue is that it's an alpha, beta unsaturated carbonyl. And split it apart into two halves and recognize that it comes from two molecules of propyophenone and that's not the answer yet. That's the thought process. That's the showing our work. That's the thinking on this. So now we've learned about one set of conditions for the aldol reaction with dehydration. And so basically we'll just take our propyophenone and our favorite sodium hydroxide. Honestly you could use calcium, pardon me, potassium hydroxide interchangeably. Here is a solvent or water alcohol mixtures and heat. And it's this art of thinking backwards that is just so incredibly valuable and so incredibly powerful to be able to look at a complex molecule like that and see how it comes together. All right. Well we've been having some fun with chemistry that basically works well. And what often means working for organic chemists is giving one thing. It's this notion of control. Either I want the beta hydroxy carbonyl compound or I want the alpha, beta unsaturated carbonyl compound. But I don't want both. Either I want this component to be the nucleophile or I want that component to be the nucleophile. But I don't want both because I'll get a mixture. And of course as one starts to have mixtures of things you have problems. So for example if I mixed propanol and butanol together with sodium hydroxide and water and heat, my goodness. Well I could have the propanol be the nucleophile. I could have the butanol be the nucleophile. I could have the propanol be the electrophile. I could have the butanol be the electrophile. Even if under these conditions I didn't get any beta hydroxy carbonyl and all of my beta hydroxy carbonyl compound went to alpha, beta unsaturated carbonyl, I'd have 4 different alpha, beta unsaturated carbonyl compounds. I'd have compounds with propanol and propanol, compounds with propanol and butanol, compounds with butanol and propanol, compounds with propanol, with butanol and butanol. So in many circumstances, if you just mix together different aldehydes and base, you get a mixture of products. But there is one special type of case where you can control mixtures of compounds. And the generalities are if you have a ketone, an enolizable ketone, obviously it's got to be enolizable, just like propyophenone. And you have a nonenolizable aldehyde, like benzophenone. See, the thing that's special about aldehydes is they're more electrophilic than ketones. So there's only one species in that mixture that can generate an enolate because benzolyde can't generate enolate, doesn't have any alpha protons. And although there are two electrophiles, a ketone and an aldehyde, an aldehyde is the better electrophile. So if we take these two components under the same conditions, sodium hydroxide and water and heat, and as I said, you could have potassium hydroxide, you could have a little ethanol in that mixture to get things to dissolve. But the main point is under these type of conditions now, we get a product and that product has the acetone acting as the nucleophile and the benzolyde acting as the electrophile. In other words, even though we haven't had that precision we talked about initially with the directed aldol with LDA, which you could also do for a reaction like this, darn it, I'll make that enolate of acetone with LDA, then I'll add it into benzolyde and then I'll do the elimination separately under some other conditions. But even without that, we're able to take charge. We have a special name for this reaction. We call this reaction the cross-aldehyde reaction. By cross I just mean that we have two different components, one of them is a ketone that's enolizable, one of them is a nonenolizable aldehyde, and honestly there's some variation that one can have. For example, you don't have to have a ketone, anything that you can make an enolate of reasonably well is okay. In general, ketones are good. In general, remember the PKA, I said if you want to keep two numbers in your mind, keep two PKA's in your head, 20 for a ketone and 25 for an ester. And you can go ahead and say an aldehyde is just about the same as a ketone. So an enolizable aldehyde, if you only want to keep two numbers in your head, you can say close enough it's 20. Okay, so acid aldehyde's more like 17, but that's close to 20. For an ester, that same PKA is going to be about the same PKA for a nitrile and other compounds for the alpha proton. But you get a special circumstance if you put two esters together we already saw last time that diethyl malonate, for example, and ethyl acetoacetate are extra acidic. And so you can take a compound like diethyl malonate which now is extra acidic and the same gist of the conditions, you can go ahead and take this very enolizable, remember PKA 13 for diethyl malonate, acetyl acetone, 9 ethyl acetoacetate, 11 diethyl malonate, 13. You want to keep one number in your head, just keep in 10 or 11 for all of these 1, 3 di carbonyl compounds. Extra acidic, I'll get to your question in a second. Now, let me give us just for the sake of some diversity, a funny looking aldehyde, it's called furforal. When you learned about aromatic compounds, you learned about benzene but then you probably also read about all the five-membered ring aromatic compounds, furan, all the fundamental ones, furan, pyrrole, and thiophene. For the most part, all of those rings like the furan ring behave very much like the benzene ring. So this is just another compound like benzaldehyde. Imagine mixing this highly enolizable 1, 3 di carbonyl compound, PKA 13, and furforal and some base. The only difference is I don't want to use sodium hydroxide, I don't want hydroxide anywhere because I have ester groups. If I use hydroxide, I'm going to hydrolyze my esters and get carboxylase. So I'll take sodium ethoxide in ethanol, another favorite solvent base combination. You can just make it by throwing in sodium metal into ethanol, very easy base to make. Heat it up, if you like, I'll write delta here just to show you can heat it up. And even though this looks very different, it's all the same principles we just saw. It's an alpha beta unsaturated carbonyl compound. In this case, an alpha beta unsaturated 1, 3 di carbonyl compound with a formed from a nonenolizable aldehyde and an enolate of a highly enolizable component. Question? Can the aldehyde reaction form both E and Z components? Great question. Can the aldehyde reaction form both E and Z components? Yes and no. So for the most part, under these conditions, the aldehyde reaction is thermodynamic. All different products are forming and we're going to the lowest energy product. Particularly when you have something big like benzene, the Z is much higher in energy because of steric interactions and so you get virtually none of it. And so in this case, we're going to get, you know, so little that you wouldn't detect it. In cases where you had two things that were very close to equal in size, a methyl group and an ethyl group, yeah, the answer is yeah, you would get both the E and the Z. So under some circumstances, you might. But for the most part, it's pretty selective. For most of the examples you'll see, it's pretty selective for the E geometry, for the trans geometry. Now if your molecule has two carbonyl groups and they're in the right relationship to each other, an aldol reaction can occur within the molecule in what we call an intramolecular aldol reaction. So in general, five and six-membered rings are particularly stable and particularly easy to form. Three and four-membered rings have substantial ring strain. Seven, eight, nine-membered rings have some other strain associated with them. So in general, if the reaction can occur in a way that gives rise to a five or a six-membered ring, it will. So let's take a look at this one, three, that this di carbonyl compound. It's hexane 2,5-dion, six-carbon chain with two carbonyl groups. Treat it with sodium hydroxide in water and heat, our favorite aldol conditions. And the product of this reaction is this cyclopentenone. Now first time that most students see this chemistry, they look and they say, whoa, this looks completely different from everything I've seen before. But think about it. It's an alpha, beta unsaturated carbonyl compound. You can look at it and say, oh, wait a second. I learned these things form by way of an enolate and a ketone. Let's see, where does that get me back to? That gets me back to that, oh, that's this. So what's happening? Under the conditions of the reaction, you're forming enolates at every possible position, all four of the enolizable sites. This methyl group, the methylene group here, the methylene group there, and the other methyl group. Some of those enolates just form reversibly. Others, where it's enolized on the methyl group, can go on to react. And so in this particular reaction, what's happening is when this enolate forms, it can reach around, attack over here, and that takes us over to this aldolate. And then the same things we saw before, the aldonate, again, we're in equilibrium. Protons are going on. Protons are coming off. The aldolate can protonate. If we form an enolate over here, it does happen. Reversibly, protons go on. Protons come off. You can enolize here. Nothing happens. But when you form the enolate on the other side, like so, now we're all set up for that elimination. We spit out hydroxide, and we get into this thermodynamic well of the alpha, beta, unsaturated compound that has, that's conjugated. Thoughts or questions? Absolutely. So we generate some of this enolate. We generate some of this enolate, and it's all reversible. So absolutely, this enolate forms, but if it reacts, it forms a three-membered ring. That's two strain, 27 kilocalories per mole of ring strain are thereabouts, so it never cycleizes. PKA of the ketone is about 20. So think about it. Most of our species is the ketone. We get a little bit of this enolate, a little bit of that enolate. The enolate that can react does. We keep generating more and going down this thermodynamic well until we've eventually all made the alpha, beta, unsaturated ring compound. All right, let's take a look at a couple of other examples of the intramolecular aldol reaction. We'll just have some fun here. So we did a six-carbon diketone. Let's do a seven-carbon diketone. One, two, three, four, five, six, seven. We'll take this seven-carbon diketone, same conditions, our same sort of universal aldol conditions. And what do we get here? You go through the same thought processes, and you get the six-membered ring. In general, five and six-membered rings can form. Let's say they are favored. In other words, in general, we don't form four-membered rings. They're too strained. In general, we don't often form seven-membered rings. Try one more example here. So now we've done a six-carbon chain, seven-carbon chain. Let's take an eight-carbon chain. These are real examples taken from real experiments that have been published. This particular example just used potassium hydroxide in water instead of sodium hydroxide in water. No particular difference. Now, I said seven-membered rings don't like to form. So now, remember, we can form all these different enolites. We can enolize on this side. We can enolize on that side. If we start to enolize toward the methyl group here, and you imagine cyclizing, that'll form a seven-membered ring. As I said, seven-membered rings have a certain form of strain associated with them with eclipsing and transannular interactions. They don't tend to form. But if we enolize on the more substituted side, all of our enolites form. Now, when we envision cyclizing, now we can form a five-membered ring. And that ends up being the product of this reaction. Now, this process of thinking backwards, again, just apply it over here. Look at this. Think backwards. We have an alpha, beta, and saturated carbonyl compound because you'd look. And you'd say, okay, everything that he said in class makes sense. And then I get this problem on a test or an exam or a quiz or a homework and I look at it. And how do you see it in the other direction? So in other words, if you say, oh, how do you synthesize this molecule from something that's less complicated that doesn't have a ring, you say, oh, wait a second. It's an alpha, beta, unsaturated carbonyl. I bet it could come from a dicarbonyl compound. You look and you say, ah, okay, thinking backwards. We have this. And you say, wait a second. Now you just go ahead and you unwrap that. And you say, oh, what's that? That's just 1, 2, 3, 4, 5, 6, 7, 8. Keep trying to keep your carbons. That's just that. Thoughts or questions at this point? You can have diketones. You can have dialdohides reacting in this manifold. It's really pretty cool. All right. This brings me to the second topic I wanted to talk about, the Michael addition. In textbook calls it the Michael reaction. You'll hear it referred to as both ways. That's just a fancy name for the addition of a nucleophile to the beta position of an alpha, beta unsaturated carbonyl compound. We've already seen that ketones and aldehydes are very fundamental compounds. Now we've seen even alpha, beta unsaturated carbonyl compounds are very fundamental compounds. And it turns out that alpha, beta unsaturated carbonyl compounds have special reactivity of their own. So let me draw sort of a generic alpha, beta unsaturated carbonyl compound. This could be an ester. It could be a ketone. It could be an aldehyde. And there are sort of two general features of the reactivity. The carbonyl, as we've learned with carbonyl compounds, is electrophilic. So it's electrophilic at the carbonyl carbon. But, and you've seen this reactivity already in cuprate chemistry, but it's also reactive at the beta carbon. In other words, it's also electrophilic. Now when we talked about cuprate chemistry, we said we can think about the reactivity in terms of resonance. As did we say when we talked about carbonyl chemistry. So in general, what we've said is, all right, you have some carbonyl compound and we can recognize that this is the most important resonance structure. But we also know that oxygen is more electronegative than carbon. So even though they have a covalent bond between the oxygen and the carbon, the sharing of electrons, you share electrons in the covalent bond, you don't share electrons quite equally. The electrons spend a little more time near oxygen and a little less time near carbon. And so we can write a second resonance structure, a minor resonance structure that reflects that reactivity. It's a minor resonance structure because the carbon doesn't have a complete octet. It's really not a very good resonance structure. It just represents a small fraction, a small fraction of the picture, the molecule. Remember, resonance structures aren't one. They aren't the other. It's not oscillating between them. It's both at the same time. But now with the double bond, we can write yet another resonance structure. Also a minor resonance structure. So I will write another minor resonance structure. And collectively, this picture of these three resonance structures really make up a more complete picture of the reactivity of the molecule. All right. So the implications of the second resonance structure there is that the beta carbon can also react with nucleophiles. And if I had to generalize it, I'd say what we could say is that strongly basic nucleophiles in other words, nucleophiles let's say, well, I'll tell you in a second. But let's say in general, strongly basic nucleophiles, I'll say tend to react because this is all about tendency. So tend to react at the carbonyl carbon. And I'll say moderately basic nucleophiles tend to react at the beta carbon. So I'll say moderately basic nucleophiles tend to react at the carbonyl carbon. Now what do I mean by moderately basic? Probably let's say the conjugate acid, let's say, has a pKa of oh, let's say less than or equal to 15. And these are generalizations and tendencies. What do I mean by strongly basic nucleophiles? Well, let's say the conjugate acid tends to have a pKa of let's say greater than or equal to 25. And I'll deliberately leave that region in the middle from about 15 to 25 a little bit vague. That region includes the enolates of ketones and aldehydes. And to some extent they can react in two different ways. So let me give you then a concrete example of the Michael reaction. We call the second manifold the Michael reaction. And I think I borrowed this example from your textbook just because it's a nice example and you get lots and lots of chemistry today and so I don't want to overwhelm you too much. Let's envision cyclohexenone and its reaction with ethyl acetoacetate under basic conditions. Let's say with sodium ethoxide in ethanol. I've chosen sodium ethoxide in ethanol because I want to generate the enolate. Sodium ethoxide is a good enough base to generate the enolate of a ketone or aldehyde but it's specifically a good enough base to quantitatively deprotonate ethyl acetoacetate. Remember pKa of about 11 for ethyl acetoacetate, pKa of about 16 for ethanol. So that equilibrium between sodium ethoxide and ethyl acetoacetate lies way to the right. The product of this reaction is that. All right, that is a lot to swallow mechanistically and so let's think about it, what's happening. So we're generating the enolate. I won't write the mechanism for that because by now you've seen this many times. We generate the enolate. The enolate can add in to the beta position of the alpha beta unsaturated carbonyl compound. So we push electrons on up onto the oxygen. We have our negative charge on the oxygen. And now we have lots and lots of ethanol present. Protons go on, protons go off. So we're just going to protonate our enolate to give our product. Thoughts or questions at this point? Okay, I again want to come back to this idea of seeing it because it is amazingly funny when you're sitting and looking at things in the forward direction and you say everything seems to make sense. Okay, I kind of understand this. We've got protons coming on, protons coming off. We've got sodium ethoxide as the base. We have ethyl acetoacetate. Ethyl acetoacetate is pretty acidic. We generate that enolate. We've got this Michael acceptor, this alpha beta unsaturated carbonyl compound, sodium cyclohexenone. I know it's electrophilic at the carbonyl compound. I know it's electrophilic at the beta carbon. And I know that our nucleophile isn't so basic. It's just moderately basic. So we add to the beta carbon. Oh yeah, we generate an enolate. Okay, we're in ethanol. That enolate can protonate. I get the ketone. And then you look at this in a completely different way. And I go ahead, whether on the blackboard or God forbid, on a quiz or a test. And I write something like that and I say, how do you make it from simpler compounds? And of course, I don't write that exact compound because organic chemistry isn't about memorizing. It's about thinking your way through stuff. And you say, what the heck? How in the heck can I see that? And then you think, okay, wait a second. We've been learning relationships. Today we've learned two of them thus far. We've learned about beta hydroxy carbonyl compounds and a light bulb goes on. You say, oh, I see a beta hydroxy carbonyl compound. He can't fool me. Nature can't fool me. I can make it from an aldol reaction. You see an alpha beta unsaturated carbonyl compound. And you say, oh, nature can't fool me there either. I can make that from an aldol reaction with dehydration, even if it's an intramolecular aldol or a crossed aldol. And so now we have a new nemesis here. We have this thing. And you look at the relationship and you say, oh, okay, what's our relationship? It's further apart. It's harder to see. It's a 1, 2, 3, 4, 5, 1, 5, di carbonyl compound. Now you just look at that relationship and you say, oh, I already know the trick. In a 1, 5, di carbonyl compound, I envision a retro synthetic analysis where I break the bond between the 4 and 5 carbon, between the 3 and 4 carbon. You say, ah, I go ahead. I break that bond. And you see backwards and you look and you say, oh, wait a second, that could have come from these two components. And you don't worry about reagents or conditions yet in your retro synthetic analysis. Now the other beauty of retro synthetic analysis is that you can see other things and other relationships and this is the genius of organic synthesis. Because you look at this compound and you might say, oh, okay, I see a 1, 5, di carbonyl compound too, but I see it that I'm going to number like that. And you look and you say, oh, I'm going to break the bond between the 3 and 4 carbon. Like so. And I'm going to apply all my smarts about it being the bond between the 2 and 3 carbon that was the alpha, beta unsaturated one and the 4 carbon that was the nucleophile. And you think about it and you say, oh, I see this as my synthetic precursor. And you look at that and you say, here's another route by which I could possibly generate that product. Now that compound doesn't look so simple. I broke the first one into two parts and here I've only broken it into one and it looks kind of complicated. But then you think again and you say, wait a second, I could see this component coming from a crossed aldol reaction. Perhaps I don't know if this is going to work, so I'm going to write a big question mark, but this is the thought process. I could see this component coming from a big crossed aldol reaction where now I have a ketoaldehyde and ethyl acetoacetate and maybe, I don't know, maybe I could condense ethyl acetoacetate in a crossed aldol reaction with this ketoaldehyde, this 1, 2, 3, 4, 5, 6, this 5-ketohexanal to first make this component and then maybe I could carry out an intramolecular mycola addition and that is the beauty of organic syntheses. There's many ways to put together complex molecules. See you on Thursday.
This is the third quarter course in the organic chemistry series. Topics covered include: Fundamental concepts relating to carbon compounds with emphasis on structural theory and the nature of chemical bonding, stereochemistry, reaction mechanisms, and spectroscopic, physical, and chemical properties of the principal classes of carbon compounds. Index of Topics: 1:28-Enolate Formation 3:56-Aldol Reaction 11:44-Retrosynthesis Example 18:40-Original Aldol 21:32-Aldol Mechanism 26:45-Features of Aldol Mechanism 35:25-Aldol Example 38:21-Synthesis Example 43:16-Stereochemistry 46:46-Crossed Aldol Reaction 52:48-Intramolecular Aldol Reaction 1:01:10-Retrosynthesis of Intramolecular Aldol Reaction 1:03:16-The Michael Reaction 1:05:34-Resonance Structures 1:08:27-Strongly Basic Nucleophiles 1:12:52-Michael Reaction Mechanism 1:16:35-Retrosynthesis Example
10.5446/19414 (DOI)
Good morning. So I'm excited today. We begin the second half of the course today, which, of course, means yesterday's lecture won't be on the midterm. So OK, the usual question. But no, seriously, I'm excited because now we get on to the topic that I hinted back way in lecture two. I said that basically the bulk of this course is covering carbonyl chemistry. And even beyond lectures the six weeks of the class, we continue with the theme of carbonyls in the very end of the class where we talk about carbohydrates and about peptides and proteins. But we've been talking for the past essentially five weeks about the electrophilicity of the carbonyl group. And now we're getting into this second half of carbonyl compounds, the fact that they're nucleophilic at the alpha carbon under the right conditions. So back in our first week I drew a diagram sort of like this. I said, OK, here's some generic carbonyl compound, not necessarily a ketone or aldehyde. We could mean an ester. And the general gist of it is that the carbonyl compound is electrophilic. It can react with nucleophiles. And now we come to this second half and so I'll say now we bring in this notion that the alpha carbon under the right conditions can react as a nucleophile. In other words, it can react with electrophiles. And we're going to be exploring this idea extensively over the next four lectures. We're going to be spanning this idea from chapter 23 in your Smith textbook to chapter 24 and discovering the richness of the chemistry of enols and enolates, which are the intermediates by which we have this reaction. OK, so we talked before about various aspects of carbonyl compound structure and we said we talked about the reactivity of a carbonyl compound. We talked a little bit about in water equilibrium with a hydrate species and we said that, for example, in acetone there's very little of the hydrate and typically it's not a big factor in the behavior. In other words, if I took an NMR spectrum of acetone in water, I wouldn't see the hydrate because it's just a minuscule amount of the compound. Well there's another minuscule amount that can be present that's very important in reactivity and that is the enol totomer. So I'll write in equilibrium where we have, and let's just take this as acetone right now. I'll go through with various examples, but let's just pretend you have acetone or some ketone or aldehyde, let's say. And so we have this equilibrium where we have another species and now the species is obviously very different. In other words, you have the carbonyl compound and then you have a species that has a double bond and an alcohol and that's why it's called an enol because en means a double bond and ol means alcohol. And so we refer to this as the keto totomer and this as the enol totomer. Now totomer means an isomer where you've moved hydrogen around. And so you notice of course if this is acetone here, we have three hydrogens attached to this carbon and then in this particular enol of acetone we would have two hydrogens attached and one here. So that's the same formula, it's the same molecular formula and yet a different arrangement of atoms. Totomers are a type of constitutional isomer. Remember we've learned about stereoisomers and then we've learned about constitutional isomers. And by constitutional isomer I mean we have a different connectivity. Stereoisomers have the same connectivity. Now as I said, the enol totomer is in equilibrium with the keto totomer and that equilibrium lies way, way to the left. I'll tell you just how far to the left in just a moment but I wanted to introduce our players. Now if we imagine pulling off the hydrogen of the enol totomer, in other words deprotonating, removing that hydrogen with a base, we get what we call an enolate anion. And I'll be sort of semi-generic here. In other words we could be acetone, we could be something else but I want to show you that there are two substituents attached to the carbon of the double bond there to what we call the alpha carbon. And the enolate anion can be thought of as having two different resonance structures so we can envision one resonance structure where we have our negative charge on the oxygen and a second resonance structure where we simply move these electrons down and move the electrons onto the alpha carbon. Remember we use a double headed arrow, not a reaction arrow, not an equilibrium arrow but a double headed arrow to indicate resonance structures. And I will very explicitly draw my lone pairs and draw my negative charges like so and just to be a good person I'm going to put this in brackets to remind us, to help remind us that these are two pictures of the same thing. It's not one, it's not the other. Unlike the Keto and enol totomer, they are not two distinct species that you can identify distinctly. They are one and the same at the same time. And so I will write resonance structures here to remind us of this. And I will also remind us that since this is the anion of an enol, we call it an enolate anion. All right and these two sets of variants on the carbonyl, the enol totomer and the enolate anion are going to be occupying our thinking for the next couple of weeks, for the next four lectures as we explore the reactivity of carbonyl compounds and specifically their ability to react as nucleophiles at the alpha carbon. All right, in terms of understanding reactivity and this reactivity as nucleophiles, I think the enolate is a very obvious place to start. So if I draw the structure of an enolate like so, and again I'm keeping it kind of generic, you could think of this as acetone enolate or you could think of it as some other enolate but in fact this is pretty much universal behavior of enolates. And we imagine some electrophile, now again in the spirit of keeping things generic, I'm going to write it as E plus. That doesn't necessarily mean we have a positively charged species. You've seen positively charged electrophiles, you've seen carbocations in the past, protons or H3O plus of course are cationic electrophiles. But by the end of today's lecture you'll also be seeing methyl iodide and SN2 type alkylating agents acting as electrophiles. So here in very cartoony, very loose fashion, I'll write E plus in quotation marks. And the reactivity at the alpha carbon as a nucleophile can be thought of as bringing our electrons down from the oxygen, bringing our electrons over from the double bond over to the atom bearing the positive charge. I guess technically if I want to do this right my arrow should end up at the atom and again this is sort of an abstraction of an atom. And so if I want to complete my drawing that constitutes our reaction. Now if you're not comfortable with moving all of these curved arrows around, realize that this is just the representation that this first part of moving electrons down and moving these electrons is just the embodiment of how we get from the resonance structure on the left to the resonance structure on the right. In other words when I'm interconverting these two resonance structures in my mind's eye I'm bringing these electrons down and bringing these electrons onto the alpha carbon. But I don't necessarily need to draw that out because by this point in my course and by this point in your thinking you should be comfortable enough with that operation in your mind. So that constitutes the reactivity of enolates and I just want to take a moment before I take questions to talk about the reactivity of enols again over viewed in this very, very generic fashion. So in the case of an enol this minor species that's present in equilibria with ketones and aldehydes and to a lesser extent with other carbonyl compounds. We can imagine here's our enol and again I'll have my generic electrophile E plus and we can imagine electrons flowing down from the oxygen into the carbon-oxygen bond giving rise to a carbon-oxygen double bond concurrently with electrons flowing from the carbon-carbon double bond to the electrophile. And if we continue with our grammar of electron pushing, our grammar of the curved arrow, now that's going to leave us with a protonated carbonyl and a bond to our electrophile and now we can imagine losing a proton. Again I'm talking very much in abstractions here so I'm not talking about a proton just popping off but a proton being taken off by base and so at this point we can imagine going ahead and getting to and I'll write that proton in quotes because again one would envision something taking it off so we can envision getting to the carbonyl compound that's reacted at the alpha position. Question? Can the negatively charged carbon also grab the electrophile to form the same product? Can the negatively charged carbon? Absolutely, it is one and the same. Whether I write this reaction as a flow of electrons like such or whether I write the reaction as I guess again technically to be correct since it's a resonance structure I'm going to write it in the exact same geometry because the two resonance structures share a geometry. If I want to think about it like this, this is the self same thing. It is the exact same way of writing this and so these are not really different. They're just different ways of representing the same thing and as one moves in their understanding of organic chemistry you go from sort of needing to explicitly write that latter one out to recognizing that the one image embodied in the former which happens to be the major resonance structure the one image embodied in the former ends up being enough for us to think our way through. Other questions? All right, let's move on to some specifics. So this provides an overview. This provides a very generic introduction to the chemistry of enols and enolates and now let's talk a little bit about some specifics about the prevalence. Of all the carbonyl compounds with the exception of di carbonyls which we're going to talk about very soon in a lecture or so with all the carbonyl compounds, aldehydes and ketones are the most inolic with aldehydes being a little bit more inolic than ketones. Your textbook just gives sort of a generic answer that there's less than 1% enol present for a typical carbonyl compound but it's a lot less than 1%. There's very little enol. So acetone is an equilibrium. If you spray acetone on your glassware you're spraying mostly acetone but you're spraying a little bit of acetone enol. It's an equilibrium and the position of that equilibrium, K is equal to the equilibrium constant is equal to 1.5 times 10 to the negative 7. In other words there's less than one part in a million of acetone enol present at equilibrium. Cyclohexanone in general, more substitution makes for a more stable double bond. We learned this in the chemistry of alkenes that in general when you put alkyl groups on a double bond it's more stable. So cyclohexanone exists in equilibrium with the enol and it's a little bit more enolic than acetone. The equilibrium constant is 5 times 10 to the negative 5. Again just a hair more than one part in a million whereas before I guess we had a hair less than one part in a million. As I said in general aldehydes are a little bit more enolic than ketones. That's not necessarily surprising. Remember the aldehyde carbonyl group is pretty darn unhappy as a carbonyl group. It's only got one alkyl group donating in. We saw this when we talked about the chemistry of hydrates and we said that acid aldehyde exists about 50%, about half hydrate and half as the aldehyde form in water whereas acetone is vastly predominantly the ketone form, not the geminal diol. So similarly we see that acid aldehyde is a little bit more enolic than say acetone which would probably be the best comparison. So in acid aldehyde you again have an equilibrium, again that equilibrium lies way, way to the left but now you have just a hair more of the acid aldehyde enol. The equilibrium is at 2 times 10 to the negative 5 for your equilibrium constant. So compared to acetone, a couple orders more, orders of magnitude more. In spite of being a minor equilibrium component, the reactivity of enols is very important in the reactivity of carbonyl compounds so that makes sense even if you have a little bit of something when it reacts more gets generated and so a reaction can proceed and proceed and proceed. Being small doesn't mean you're unimportant. So we can take a look at how enols and ketones, keto and enol totomers, interconvert and look at the mechanisms of formation. Another question? Yeah. So does formaldehyde has more enol form because it's on state form? All right. Who wants to answer this question? No one. Enol form of formaldehyde. I mean, sorry. Can't. No alpha carbon on formaldehyde. Sorry. Not formaldehyde. Acetaldehyde. Acetaldehyde. Acetaldehyde has more like a enol counterpart than acetone. Acetone is more stable. That's a very good way of thinking about it. Whenever you have an equilibrium, you're comparing the energy of a ground state and a product. And so the bigger the difference in energy, the bigger the equilibrium constant, the bigger whether it's positive or negative, whether it's greater than one or less than one, depending on how the energy difference goes. So anything that either lowers the energy of the reactant or raises the energy of the product makes that equilibrium constant greater in magnitude, whether it's in one direction or the other direction. So when we talked about acetone versus cyclohexanone, they're both ketones, but we're lowering the energy of the enol by making the double bond more stable. So here's the acetone enol. Here's the cyclohexanone enol. In the case of acetaldehyde versus acetone, now you can think of it as we're raising the energy of the reactant because acetaldehyde is higher in energy, it's less stabilized relative, and it's always a question of reference frame. But that's a good way to think about it. So later on we're going to see things that provide a lot of stabilization of the enol, specifically conjugation. All right. So that's talking about reactants and about products. About keto and enol tautomers, let's now look at how we get from the keto tautomer to the enol tautomer. And this reaction can be casually catalyzed by either acid or base. I want to start off by talking about acid catalyzed enol formation. And I'm going to write out the mechanism very slowly and carefully, very meticulously, because I think this really is important to think your way through. We've already seen on the quiz how important mechanism is in clarity, in expression, and thinking on mechanism. The mechanism on the quiz was kind of long and complicated, involving many steps. The mechanism of acid catalyzed enol formation is relatively simple and easy. If you have an acid, hydronium ion, for example, protons go on and off everything with lone pairs of electrons. The carbonyl of acetone or the carbonyl of a ketone or the carbonyl of an ester is weakly Lewis basic. We have a D-Bronsted basic, and so you have an equilibrium where you can protonate the carbonyl. If we're looking at hydronium ion as catalyst, hydronium ion has been consumed in the first step of this reaction. Now we're going to recreate it in the second step of the reaction. I'm going to again draw our protonated acetone. And now I will explicitly draw in my alpha hydrogens, because we're going to use them very often when you're writing a mechanism or thinking about a mechanism. You will write different parts of a molecule at one time. So here's our water, here's our alpha proton, and now water is weakly basic, very weakly basic. Water can pull off the alpha proton. We just push our electrons up on to the oxygen, and again we have an equilibrium. And I will be very, very explicit and try to draw in all of my relevant hydrogens here to help keep us on track. And I will try to remember all of my lone pairs and all of my charges, so I'm not a bad person. And here we go. That's an example of how we go from the ketototomer to the enolotomer. Answer questions at this point. Is water able to pull off the hydrogen? So you mentioned the term addition elimination. Now we've seen addition elimination in acid chlorides. That's where a nucleophile adds to a double bond. We kick up a lone pair of electrons, it comes back and pushes something out. Nucleophile like an amine adds to an acid chloride. We kick electrons up onto the oxygen, they kick back down, kick out the chloride. So this reaction mechanistically is an acid base reaction. And the only thing that's maybe surprising or confusing to you is the fact that we're continuing to push our electrons all the way up. Now technically, technically I could go ahead and stop at this point. But of course if I stop at this point, I recognize in my mind's eye, well this is a really, really funny resonance structure, a really unimportant bad resonance structure of that. And so we just keep pushing. And of course protons come on and off all different acidic positions in acid base equilibria. And so the proton, whoops I forgot my positive charge, so much for being a good person over here. So the protons can come on and off the oxygen, then we head in the reverse pathway and guess what? This is the time your equilibrium partitions back. In other words, when you have an equilibrium like this. So here's our energy, here's our reaction coordinate. When you have a reaction like this where we're going from reactant, from our acetone plus H3O plus to our protonated acetone and then to the enol. Well technically if I'm writing this out correctly, this is acetone, protonated acetone plus H2O. What's happening in our mechanism is first we're going uphill to an intermediate and then we're coming down to our product, to our enol that's higher in energy. So when you're at this point at the intermediate you can partition back, you can partition forward, it goes both ways. Most of the time it actually ends up going back down and ultimately of course it's the difference in energy between our product and our reactant that determines the position of the equilibrium. Here's another question. It does indeed take the H from the oxygen and the mechanistic reverse of this step is taking the H from there. Most of the time it takes the H from there. Some of the time we go forward and it goes in the other direction or should I say, well it's not technically the partitioning, it's not going to be most of the time, it's going to be half and half because most of the time we're not forming this intermediate. So technically it can be a little more one or a little bit more of the other. But the point is that heads us back. Sometimes we pull off this proton and it heads forward. This proton is acidic. Other question. Can the water also perform a nucleophilic attack on the electrophilic attack? Can the water also perform a nucleophilic attack? Great question. This is what's so profound. This is why people can find organic chemistry confusing. Because yes it can and yes it does. And we saw that. We saw, we talked about acid catalyzed hydrate formation, acid catalyzed geminal diol formation. So in your acetone and water with a little bit of acid, honestly even without a little bit of acid because water has hydronium ion, 10 to the negative 7th molar, in your acetone and water there is this gamish, this mixture of acetone, the main component, and then a little bit of the hydrate and even less of the enol. So absolutely. And so keeping this in one's mind. Oh yeah. This is the pathway we're thinking about now because this leads to the good stuff we're going to see over the next four lectures is often confusing to initial to beginning students. Great question. Very important because this is the part of understanding it all. And you look at this mechanism here. This manifestation of catalysis and realize what this means for the uncatalyzed mechanism. It means that in the uncatalyzed mechanism you're not actually changing the difference in energy. You're trying to draw this curve for the uncatalyzed mechanism between acetone and acetone enol at the exact same level. You're not actually changing the difference in energy between acetone and acetone enol. What we're doing is providing a low energy pathway that's not accessible without acid. In other words, there is hypothetically a one step mechanism that converts acetone to acetone enol. But the energy barrier is much higher. So when any acid is present, that includes that 10 to the negative seventh molar H3O plus hydronium ion in pure water, acid can catalyze this reaction. Now, the other thing, and I've been beating on this, beating on this like a dead horse. And the other thing that's important is reactions proceed through the reverse reaction, proceeds through the exact same mechanism. When cyanohydrons form by adding cyanide to a carbonyl to give an oxyanion and then protonating the oxyanion to get the alcohol, we learn that cyanohydrons break down under the same conditions by deprotonating the oxygen to give an oxyanion and then kicking out cyanide. When enols form by first protonating the carbonyl to give a protonated carbonyl compound and then deprotonating the alpha carbon to give the enol, that means that the reverse pathway proceeds backwards by the same mechanism. And so we can write, and you should be able to write in your sleep, the reverse mechanism, we simply go ahead and start with the enol and hydronium ion. Protons flow, the proton goes to the alpha carbon, electrons flow down from the oxygen and then in the second step, that's the step in going from our intermediate water back to our acetone. Now water just acts as a base and pulls off the protons on the carbonyl. Electrons flow from the lone pair on water to the protons, electrons flow from the bond back onto the oxygen. Those are questions. All right, let's see where this gets us in terms of some reactivity. And then we'll get to enolates, which get really funny. All right, I'm going to take probably the simplest reaction that I can think of and that reaction is going to be deuteration. So let's take cyclohexanone as a variation here. And we'll envision dissolving it in D2O, I'll put parenthesis as solvent. D2O is just heavy water, it's just deuterium oxide, it's just the isotopamer of water with deuterium. Every glass of water you drink contains zillions of molecules of deuterium or zillions of deuterium atoms, one out of every 7,000 hydrogen atoms is deuterium at natural abundance, meaning in your proteins, in your lipids, in your carbohydrates, there is a miniscule amount of deuterium and one can by electrolysis or distillation concentrate the deuterium to get pure D2O. If we treat our cyclohexanone with D2O and a little bit of catalytic acid, I'm going to get away from H3O plus and D3O plus for a second to remind us one actually has to go into the laboratory and get a real compound. I've written DCL, DCL is just hydrochloric acid made with deuterium, so it's a strong acid, it dissociates in D2O, what will happen is you will replace all of your alpha protons with deuterium. This is kind of cool, you can see this for yourself, if you ask your lab TA to give you some cyclohexanone and some D2O and a little bit of DCL and you dissolve your cyclohexanone in D2O, you would be able to take an NMR spectrum and you would see the alpha protons, the hydrogens next to the carbonyl at about 2.5 parts per million and as the reaction proceeded, the peak in the NMR from those hydrogens, the peak at 2.5 parts per million would disappear as those hydrogens were replaced by deuterium. All right, so how does this occur? Well it's the exact same mechanism that we saw before, just repeated over and over again, I'll write this in abbreviated fashion, we can envision that in D2O, we protonate the D2O with DCL, remember when you pour HCl into water you have H3O plus and CL minus. The D3O plus is just like H3O plus in its reactivity, you can put a deuterium onto the carbonyl to give a protonated or in this case, deuterated cation and now in the second step of this reaction, of course if I'm balancing my equation, in my second step of my other product is D2O, in the second step of the equation just as we have pulled the protons off the alpha position of acetone with H2O, alpha protonated acetone, now the D2O can pull off our alpha protons and so again we have an equilibrium, now we take ourselves to the enol plus if I want to balance my equation D2OH plus. Alright, I think I will continue on the sideboard here. Alright, so one thing I should point out is we have lots and lots of D2O present. Here is 55 molar, deuterium is practically the same as water D2O is going to be essentially 55 molar. Protons, as I've been saying again and again, go on and off every protonated species. In other words when we have D2OH plus and lots and lots of water so I will write plus excess D2O, you have an equilibrium and of course mass action drives this equilibrium and so you will get a little bit of H2O HOD plus D3O plus, in other words basically you have got tons and tons of D2O, your water just spreads out, your protons just spread out to make little bits of HOD. If I do a reaction with 55 molar D2O and I have one molar solution or a tenth molar solution of ketone as my protons go in I get this little bit of HOD in this mass of D2O and D3O plus. All right, let's continue our mechanism here so we have our enol with a deuterium on it and we have lots and lots of D2O and a little bit of D3O plus. We can protonate our enol. I'm just writing the same mechanism as I wrote before without the curved arrows and without filling in all of my lone pairs of electrons and now we can have further proton, further deuterine transfer and you can envision this mechanism just continuing. We form the enol, we protonate the enol with deuterium, we form the enol some more, we protonate with deuterium and eventually we've washed out all of those enolizable alpha positions and now we have the fully deuterated molecule. Organic chemists are terribly bad at balancing equations but if I want to write a balanced equation I would write that our ketone plus 4 D2O goes with catalytic DCL in D2O solvent goes to the fully deuterated ketone plus 4 HOD in lots and lots of D2O. One of the other properties of carbonyl compounds is that their alpha proton is acidic. So for example in acetone the alpha proton has a pKa of about 19 and that's interesting because if you think about it, if you think about say a regular methyl compound or a regular alcohol compound the pKa is about 20 and in other words the pKa of an alkane is while nominally acidic, very weakly acidic, it is very, very, very weakly acidic. It's only acidic in the sense that you can think of its conjugate base as being a very, very, very strong base and yet by the time you get over to acetone putting that carbonyl there shifts by 31 orders of magnitude the acidity of that proton. It shifts the equilibrium massively because when I think of the conjugate base of acetone I don't just think of this, I think about that special resonance stabilization that we get as the enolate. And you can see how picturing these two resonance structures together, the structure on the left is really very inadequate to explain this stability. The structure on the right explains it beautifully. We have a negative charge on the oxygen, we have oxygen as electronegative, we know alkoxide has or alcohols are reasonably happy to lose a proton. They're weak acids but they're not very, very, very weak acids. pKa of an alcohol is 16 or 17, the pKa of an alkane is 50, that oxygen does a heck of a lot and with acetone with our pKa of 19 we're getting a lot of stabilization from this resonance structure. In other words, this is the major resonance structure. This is the one that's important in determining the reactivity and this one is the stability and this one is the minor resonance structure. Now more generally the carbonyl group provides stabilization and your textbook gives a number of compounds and I'll give you these compounds and then I want to give you a generalization that I keep in my own head. So your textbook gives you acid aldehyde with a pKa of 17 and it gives you ethyl acetate with a pKa of 25 for the methyl group and acetonitrile with a pKa of 25 and dimethylacetamide with a pKa of 30 for the alpha proton. And really the numbers that I keep in my head, these are a lot of details but the numbers that I keep in my head are as follows. I keep in my head two numbers for all of this, that the alpha protons for the ketone and aldehyde family are about pKa20. 20 is good enough. Yeah, I'll keep in the back of my head aldehydes are a little bit more acidic. I'll keep in my mind that 20 is typical for say cyclohexanone, that acetone is 19 but those details are small. Those are unimportant. The other big picture while aldehydes and ketones are about pKa20, in general the carboxylic acid family, esters, nitriels, even amids, even carboxylic acids under the right conditions you first remove the acidic proton so it's a carboxylate and then you remove a second proton. In general, a good number to keep in mind is about 25. Yeah, there are some variations but it's not as super important as keeping these pictures in mind. And one of the pictures from this is in general ketones and acid and aldehydes are less acidic than water. In other words, hydroxide will take off only a small amount of the protons, only an equilibrium concentration. Ethoxide will pull off only an equilibrium concentration but stronger bases, those can pull off protons quantitatively. Since the alpha protons, ketones and aldehydes are acidic, it shouldn't surprise you that base can also catalyze enol formation. So let's come back to our acetone molecule as our sort of archetypal ketone and now let's envision hydroxide as a base. I could do this with alkoxide too but some sort of moderately strong base, not super, super strong. We'll talk about super, super strong in a moment but something like hydroxide or an amine like triethylamine. We can pull off the alpha proton. The alpha proton is weakly acidic. Remember pKa of 20 is the number you want to keep in your head so we have an equilibrium here with the enolate. But that equilibrium lies slightly away from the enolate and so we can protonate. In other words, you generate a little bit of enolate but you don't generate the enolate quantitatively and so we can protonate. If we protonate back on carbon, we're headed back in the same position. We're headed back to the start of the reaction if you protonate on oxygen on the other hand. Just as in our acid catalyzed enol formation, hydroxide here although it's being consumed in the first step is being recreated in the second step and so it is not being taken up or destroyed or created in the reaction overall. It is acting as a catalyst. Similarly, we're not changing the position of the ketoenol equilibrium. We're only creating a lower energy pathway to allow the ketone and enol forms to interconvert. Would there be more enolate in the solution than enol since the solution is basic and the water can be like protonated by a base? Good question. If you're working your equilibria, technically yes. In this particular example, that is an astute question. In this particular example with these particular pKa's, technically you're right. There will be more enolate than enol present. If you want to come to an example where now you have very little enolate and the equilibrium still goes, substitute in this reaction as base triethylamine because now, remember we said that for acetone we're going to have 1.5 times 10 to the negative 7 as our equilibrium constant so there's not a lot of enol. We're having our pKa for acetone of 19 which means you actually do have one in a thousand or one in 10,000 enolate, one in a thousand. If you substitute triethylamine pKa about 10 or 11 for the conjugate acid, you'll still catalyze this reaction but now you'll have very, very little of the enolate. Do you use a Dean Stark apparatus? No need here. We're not actually trying to change the position and okay, could one? Now you're asking a smart question. Can one drive this reaction and the answer is you can't drive it by removing water because the reaction is unimolecular overall. There's no net change in the molecule. It's an isomerization. So the way to drive the reaction to the enolate is to go ahead and to use a very strong base. Unfortunately, there's very little one can do to try to generate the enol as an isolated species although there's an Israeli chemist who actually is focused on stable enols because another thing about organic chemists, in addition to being very bad at balancing equations, is if someone says it can't be done, enols are unstable, you can't make a stable enol, you can bet you an organic chemist will go out there and say, how do I make a stable enol? We'll see some stable enols that are very special enols but for a regular one. All right, so where is all of this leading? Let's go and do some enolate chemistry. So just like with DCL and D2O, if I take cyclohexanone with catalytic sodium deuteroxide, just the deuterium analog of sodium hydroxide and D2O as solvent and I let it sit, again you can do this for real in an NMR tube, Johnny or Kim could go back to my laboratory and do this right now and show you those alpha protons would wash out and be replaced by a deuterium. Similarly, if I imagine for a moment that I had something that had chirality at the alpha position, let's imagine for a moment that I have this ketone where I have a methyl group and let's say that I have just the SN anti-emur and I treat this ketone with let's say sodium hydroxide since we're talking enolate chemistry, sodium hydroxide in water. Then what will happen will be I'll lose my enantiomeric purity. I will get a mixture of the two enantiomers. I will get the racemade. I will get an equal mixture of the R and the S. What's happening here in this latter example? We're forming little bits of the enolate repeatedly. The enolate is flat. The enolate loses its chirality. What am I doing here? I will say that we go via this. In other words, you can picture in your mind's eye the base pulls off the alpha proton. We get the enolate. The enolate is flat. We have no chirality to the enolate. If a proton comes from the back, we get the original enantiomer. If it comes from the front, we get the new enantiomer. So our compound racemises in aqueous base. In addition to being bad at balancing equations, in addition to wanting to do what can't be done, organic chemists are control freaks. We want to control the molecules and make them do stuff. Often we want to do stuff to make stuff that's useful, like new medicines. Whereas weak base doesn't make a lot of enolate, a strong base does. We can use that. If you have something like cyclohexanone in a base, I'll write it as B minus, let's say, a very strong base. In other words, pKa of the conjugate acid, much greater than 20. Then we have an equilibrium that lies way, way, way to the right, often so far to the right that we can just ignore the left arrow to give us the enolate anion and our protonated acid. The base that's extremely valuable to organic chemists is diisopropyl amide anion, or more specifically, the lithium salt, lithium diisopropyl amide. For those of us who are control freaks, for those of us who want to make molecules do stuff, this base is really good because it's a strong base. PKa of the conjugate acid, the PKa for diisopropyl amine is about 40. I'll write PKa, I, P, R, 2, and H is a nice shorthand, and I'll say tilde approximately 40. Remember, we're comparing. I said if you want to keep one number in your head, keep 20 for the PKa of cyclohexanone, for the PKa of a ketone, that's actually the PKa of cyclohexanone to within a unit, but again, just keep that number in your mind. The other thing that's really important about the diisopropyl amide anion is it's big. Those diisopropyl groups, and there are two of them, are bulky. They get in the way. In other words, lithium diisopropyl amide is a good base, but not a good nucleophile. And again, I'm going to come down to this confusion in organic chemistry students when you're starting out. Oh my God, there's all this stuff to know. How do I know that this compound, like cyanide, is acting as a nucleophile? How do I know that diisopropyl amide is acting as a base? Well you start to learn these patterns. The very bulky ones are better at pulling off protons, the little bitty ones, and cyanide is just a little bullet, is better as a nucleophile. So the reaction here lies so far to the right that our lithium enolate, I won't even bother to write the reverse arrow. Our lithium enolate is essentially formed stoichiometrically, and of course the other component in this reaction is diisopropyl amine. So we have an acid base reaction. Weaker acid plus stronger base reacts to give weaker acid plus weaker base. How do you know where that equilibrium lies? You just look at the pKa's of the acid. Okay, we've got the weak acid pKa40 on the left, we have a strong acid on the right. And remember, the other number I like to keep in mind is about 10 orders of magnitude. In other words, if you've got things within a pKa range of about 10 units, I'd say, yeah, you've got a little bit of an equilibrium. But you go to 20 units apart and it's like, bam, that reaction goes essentially all the way. Often, when organic chemists are writing out synthetic reactions, we'll write in a little bit of shorthand. For example, I will say LDA, it's widely used in tetrahydrofuran as a solvent in order to minimize its reaction as a nucleophile and minimize equilibration processes. Often you'll do these reactions at negative 78 degrees Celsius. That's the temperature of a dry ice bath, which makes it particularly popular. For early on, I said that E plus is sort of an abstraction, I said you'd see methyl iodide. So you can envision a reaction like this. In the first step, we add cyclohexanone to LDA at negative 78 degrees. In the next step, we drip in methyl iodide and allow the reaction to warm up, maybe perform an aqueous workup on it with a little bit of acid. And we've methylated our cyclohexanone. What's happening here? Same thing we saw with protons. We've generated our enolate stoichiometrically. Here's our methyl iodide. Whether it's a proton, whether it's methyl iodide, we have a good electrophile. Transplow from the alpha carbon to the methyl, to the electrophilic methyl carbon, and we do an SN2 displacement to give the methylated cyclohexanone and iodide anion. Most of the time, organic chemists don't go ahead and buy lithium diisopropyl amide. We typically make it by acid-base chemistry. N-butyl lithium is widely available. It's the most common alcohol lithium, widely used. You can mix it with diisopropyl amine. NTHF, if you like, before you add your cyclohexanone and you pull off a proton, you get butane plus lithium diisopropyl amide. And again, I'm now getting into writing things in shorthand, so I'm not writing as many lone pairs of electrons here. And this, too, is an acid-base reaction. N-butyl lithium is very, very strongly basic. The pKF and alkane is about 50. PKF, diisopropyl amine, we already said is 40. That equilibrium lies way, way to the right. You might ask, why don't we use butyl lithium as a base? Comes back to what I was saying about sterics. If I use butyl lithium, the main reaction, the only reaction that you would detect, that you would write on, say, an exam if you want to get down to the brass tacks of being an O-chem student, would be addition of the butyl lithium to the carbonyl. Not sterically hindered enough to not add. We go to the lithium diisopropyl amide with those big isopropyl groups, and now it's much more basic than nucleophilic. The butyl lithium toward a carbonyl is much more nucleophilic than it is basic. Let's have some fun now with variations among enolates. So imagine we have our methylcyclohexanone, and we treat it with base. Now we can get two different enolates. We've got two different types of alpha protons. We've got alpha protons that are opposite the methyl and alpha protons that are next to the methyl. In other words, we can get this enolate, or we can get this enolate, the less substituted enolate or the more substituted enolate. Now in general, we know that more substituted double bonds are more thermodynamically stable. And more substituted enolate is what we call the thermodynamic enolate. It's lower in energy. Among an equilibrium between the two enolates, it would form. But we also know that size matters. We have a bulky side of the molecule, we have a non-bulky side of the molecule. The base, particularly a sterically hindered base, needs to get in to pull off a proton. It's going to grab the easier one if it's bulky. So the enolate that is less substituted is often referred to as the kinetic enolate, the one that forms first, the one that is easier to form. So we can go ahead and think of it as these protons are more accessible to base. Now this proton is technically a little bit more acidic. So I will write here, just for comparison, more substituted enolate, more thermodynamic and thermodynamically stable. So let's take a moment to play with this notion because as I said, organic chemists love to control reactions, love to control reactivity. It's important because when you're making molecules for medicines or for drugs, you need the molecule that you want. And I'll take a couple of examples from your textbook here because they're good examples. If we take our methylcyclohexanone and we treat it with LDA and THF at negative 78, you may see it written just as LDA, you may see it written as LDA, THF, you may see it written as LDA, THF negative 78, and we treat it with methyl iodide, we deprotonate to form the kinetic enolate and we end up with the 2,6-dimethylcyclohexanone. So I'll write via the kinetic enolate. Borrowing an example from your textbook, which if you want to ask questions about after class, I will tell you some of the subtleties of, but if you treat with a weaker base that can equilibrate, your textbook uses sodium ethoxide in ethanol and basically the way I will write this is to mix sodium ethoxide, methyl iodide in ethanol, then because we're under conditions where we're thermodynamically equilibrating our emulates, your predominant product, your main product is going to be the 2,2-dimethylcyclohexanone via the thermodynamic enolate. And so this is a taste of the type of control that organic chemists can get. And I'll write this as major product. Right here, if I do this reaction with LDA, this is the major product. In other words, I'm going to get 99 parts of this and one part this. Technically this is the major product. I'll probably get about 80 parts of this and 20 parts of that. So there's one question, but I want to wrap up with a couple of last points about stereochemistry and stereoisomers at this point because I think it's pretty and I think it's cool and I think it's intellectually deep and I think that a lot of this is what organic chemistry is all about. So technically I'm lying in that structure, maybe to be more precise, I'm telling you half a story. And the other half of the story is when I draw this structure, I'm living in flat lands. Each of those carbons with the methyl group is a stereogenic center. And so we have different types of species that we can get. We have the species, the stereoisomer to be more specific in which the two methyls are on the same side of the ring. We have the cis stereoisomer. We have the stereoisomer in which the two methyl groups are on the opposite side of the ring to transstereoisomer. And so when we form our enolate, and now I will specify my methyl stereochemistry, if our methyl group adds from the back, we get the transstereoisomer. And if our methyl group adds from the front, we get the cis stereoisomer. And there's one more level of subtlety. And I'll show you that, and then that's going to wrap up today's lecture. So imagine for a moment, I take this compound, and almost invariably it's going to be racemic if I haven't specified otherwise. And so I treat with LDA in THF at negative 78 degrees, and then I treat with methyl iodide just as I've done. And you'll get a mixture of the cis and trans compound. And of course, the trans compound is going to be the racemic. In other words, we generate our enolate and the methyl group, if it adds opposite the methyl group, depending on whether this methyl group is out or back, we're going to get the racemic compound. In the case of the cis, the cis compound, if it adds from the same face, the cis compound is a mesocompound. So in other words, whether I draw it like this or I draw it like this, this is just the self-same thing. All right, well that gives us a taste of the richness of stereochemistry as well as a beginning on this notion of control. And you can see, even though we've talked at this point about control of the regiochemistry of addition, we've only seen that there is still a depth and richness to the stereochemistry of addition, and that will go largely beyond the scope of this class. Thank you.
This is the third quarter course in the organic chemistry series. Topics covered include: Fundamental concepts relating to carbon compounds with emphasis on structural theory and the nature of chemical bonding, stereochemistry, reaction mechanisms, and spectroscopic, physical, and chemical properties of the principal classes of carbon compounds. Index of Topics: 1:16-Reactivity of Ketones 3:02-Enols 6:36-Enolate Anion 9:47-Enolates and Electrophiles 16:49-Equilibrium Between Tautomers 23:07-Acid-Catalyzed Enol Formation 29:18-Energy Diagram 37:51-Multiple Additions 46:41-pKa of Alpha Protons 53:05-Base-Catalyzed Enol Formation 58:56-Stereochemistry 1:03:42-LDA 1:11:28-Kinetic Product vs Thermodynamic Product 1:17:56-LDA and Stereochemistry
10.5446/19413 (DOI)
Today we're really in the heart of the chemistry of the carboxylic acid family. Last time after talking in sort of generalities about their chemistry we introduced the most reactive members of the carboxylic acid family. We introduced acid anhydrides and we introduced acid chlorides and we talked about their chemistry. Today we're going to focus on all of the remaining members of the family. We'll talk about some of the chemistry of carboxylic acids that we haven't seen before. We'll talk about the chemistry of esters and we'll talk about amids and nitrials. And these are all less reactive than acid chlorides and anhydrides. So if I wanted to make some generalization here's a generic ester structure. Here's a generic carboxylic acid structure. And what I would say is in general these structures are less reactive. These functional groups are less reactive to nucleophiles than acids and acid chlorides. And acid chlorides and anhydrides let's say. And so let me maybe start with an example that shows a similar type of reactivity but it's a much less great degree of reactivity. Let's look at the reaction of a simple ester and I think for today for all of our examples I'm going to be giving very small and simple compounds just because we're going to be writing out a lot of structures. So let's take a look at the simplest typical ester methyl acetate. The reason I say typical ester is formates are a little different formic acid although it's a carboxylic acid is a little more reactive but acetates and propionates and various other acids all are kind of the same. And let's take ammonia. Now when we were talking about nucleophiles before we talked about species like ammonia and hydroxide as basic nucleophiles. These aren't super basic nucleophiles like Grignard reagents and hydride reagents but they're not things that are base only in name. And ammonia is a good enough nucleophile that it will react with esters and so we undergo a reaction to get acetamide and the other product of the reaction is methanol. So we call this reaction an ammonolysis meaning a lysosacleavage by ammonia. We've already mentioned the term hydrolysis cleavage by water. Now what I really wanted to be I've been trying to keep everything simple up here what I really wanted to draw up here was an aminolysis. These names don't matter a whole heck of a lot. An aminolysis would be within a mean like R with say a general structure of R and H2 or even a secondary amine although they're much less reactive so there's a primary amine. But I'll show you since I'm trying to keep all of our drawings simple today I'll show you an ammonolysis instead of an aminolysis. And the mechanism for this I'm not going to write it out in gory detail because you've seen all of the principles with acid chlorides and anhydrides. The ammonia is a nucleophile it has a lone pair of electrons on it. It can attack the carbonyl even though the carbonyl of an ester is not nearly as electrophilic as the carbonyl of an anhydride or a chloride that has a good electron withdrawing group pulling away electron density. It can attack. We excel methoxide we transfer a proton if you want more detail you can see your textbook for a mechanism for this reaction. But the general gist is that the carbonyl of an ester group is sufficiently electrophilic to react with a basic nucleophile like ammonia or later on I'll show you hydroxide. Now for all intents and purposes the electrophilicity of the carbonyl group of an acid is really very similar to an ester but there's one big, big difference. A carboxylic acid has an acidic proton so whereas the first thing that happens when you mix an ester with ammonia is that the ammonia attacks the carbonyl it's not a fast reaction it'll occur over hours of time. This is the reaction of Windex when you clean fingerprints off of the window because grease the oils in your skin are esters of glycerol they're triesters you've heard of triglycerides. Windex has ammonia and that ammonia is cleaving the ester groups to break them down to smaller pieces fatty acid, amides and glycerol so that's ammonalysis. Now if by comparison I take acetic acid and I mix it with ammonia you might think well it's going to be very similar but acetic acid has one thing that's very different than methyl acetate it's got an acidic proton so if I mix acetic acid and ammonia you get a salt you get ammonium acetate and for the most part you don't get nabbed. Now I say for the most part because under the right conditions if you heat the crud out of ammonium acetate if you heat the crud out of acetic acid and ammonia at high temperature you will eventually get some acetamide out of there. This is not a what I would say useful reaction a reaction that synthetic chemists would typically use to make an amide but you will get some but the first thing that will happen and the thing that would happen under typical conditions would be salt formation not amide formation. Can you make the alcohol group a good leaving group by protonating it? Can you? Ah you're getting ahead of me. Can I make the alcohol group a good leaving group by protonating it? The answer is yes and sit tight in your seat. Alright so we already talked about the concept of pKa and we talked about the concept of pKa specifically of the conjugate acid. We said that the pKa of the conjugate acid of ammonia or the conjugate acid of an amine was about 10 or 11 and that's a typical sort of moderately basic compound kind of the same pKa as hydrosyanic acid. Cyanides another species that as you just encountered on the quiz is a reasonably good nucleophile. Now by contrast if you go to something like water then you have something that's much less basic much less nucleophilic. The pKa of the hydronium ion of the conjugate acid of water is negative 1.7. Water is very weakly basic. It is basic but sort of in name only. So as I mentioned in our previous discussion of esters if I just mix an ester and water you have no reaction and I also mentioned that that's fortunate for you because all of the lipids in your body all of your cell membranes are made up of esters and so if they cleaved at 37 degrees Celsius if they underwent hydrolysis at any appreciable rate you'd be in trouble. Now by similar token and again I'm using methyl acetate I'll use it a lot today just because it's a nice example and then I'll use acetic acid sort of in acetamide sort of as counter points but of course these could be any esters and any acids. So by very similar token if I mix methanol and acetic acid again the carbonyl is moderately electrophilic for an ester it's moderately electrophilic for an acid but water and alcohols are very weak bases and very weak nucleophiles. And remember when we're scanning over pKa's and I'm tossing out numbers like negative 2 or negative 3 for the pKa of the conjugate acid of an alcohol or negative 1.7 for water and positive 10 we're on a log scale. In other words we're scanning over 12 orders of magnitude what is that 10 to the third is a thousand million billion trillion orders of difference in basicity a trillion orders of magnitude or a trillion times different in reactivity to a first order approximation as nucleophilicity tracks with basicity. If a reaction of ammonia and methyl acetate takes a minute roughly then you know ball park it you're going to say a trillion minutes for the reaction of water and methyl acetate or a trillion minutes for the reaction of methanol and acetic acid. I don't know about you I know for me I don't expect to be around here a trillion minutes from now so they're not going to react. All right so no reaction. All right so chemists love to make stuff happen they love to make what they want to have happen happen. And so if you want acetic acid to react with methanol as was alluded earlier you do something that can protonate the carbonyl group. That's going to make the carbonyl group like a trillion times more electrophilic. In other words you protonate it in the presence of a very strong acid. So I could write that if I take acetic acid and I mix it with methanol in the presence of sulfuric acid I get methyl acetate and I get a molecule of water. So then chemists as I keep repeating are very bad at balancing equations but it's really important to keep this in mind because this reaction is an equilibrium. And so if I go ahead and just mix them and don't have a lot of methanol just a little bit of methanol I'm going to have an equilibrium in the middle. Sulfuric acid and methanol for all intents and purposes is similar. I got to have a lot of methanol or I've got to do something to soak up the water. And sulfuric acid actually really likes water so that's one of the ways to make it hang on to drive the reaction is just to use more than a little pinch of sulfuric acid. Question? The H2SO4 is indeed a catalyst and technically you don't need to use a whole mole equivalent. In practice sulfuric acid often is used in a reasonable quantity for exactly the reason I said because it tends to bind to the water it helps drive the reaction as well but it's not consumed by the reaction. So in fact chemists when they write a reaction like this will often show solvent and reagents with an arrow and so you'll often see this written as sulfuric acid sometimes you'll see it written as a catalyst you know with parenthesis cat and often you'll see methanol just indicated it's the solvent. Now with acetic acid I might use as little as possible but if I have a valuable carboxylic acid I'm probably going to use a whole big splash of methanol a whole pot of methanol a whole flask full of methanol for a couple of grams of acid. And so here's our product of the reaction. Now this reaction's been known for a long time it was discovered or invented by Fisher and so it's called a Fischer esterification. Sometimes people will use sulfuric acid for the reaction sometimes they'll use another strong mineral acid like hydrochloric acid. Ironically in the laboratory if I want dry hydrochloric acid in methanol not in water so I don't want to go to a bottle in the laboratory in the stock room and get HCl with water in it one of the ways I'll do that one of the ways I'll get anhydrous HCl in methanol is to throw some acetyl chloride into my methanol it'll react to give HCl in methanol and methyl acetate and those all will be just the methyl acetate I might not pay attention to and then I might use this as a reaction to take a big valuable carboxylic acid and make a methyl ester out of it so this is often how we roll in the laboratory. Alright let's take a look at the mechanism of the reaction. So in acid protons go on and off all different lone pairs any lone pair that's weakly basic is going to get protonated it's an equilibrium. If I throw sulfuric acid a strong acid into methanol it dissociates it protonates the methanol so my strongest acid in methanol is protonated methanol it's the leveling effect you learned about in general chemistry. So protons go on protons come off when the carbonyl gets protonated the carbonyl goes from being moderately electrophilic to being very electrophilic. We show the flow of electrons by drawing a curved arrow from the electrons to the hydrogen representing the formation of a new bond electrons flow back on to the oxygen atom we have an equilibrium we generate protonated acetic acid plus methanol I'll put my electrons I'm not always good about writing my lone pairs but I'll put my lone pair of electrons back on to the oxygen where they belong. Now this process the protonation of the carbonyl has made it into a good electrophile now it's ready to react even with a relatively weak nucleophile like methanol. Electrons flow from the lone pair on methanol to the carbonyl carbon atom we start to form a bond but concurrently because we can't have 10 electrons around the carbon concurrently electrons flow up on to the oxygen atom so we get an OH group here and we get a methoxy group with a proton and a positive charge on it and another OH group and I will try to be as good as I can about keeping track of all of my lone pairs of electrons so we form the tetrahedral intermediate and in strong acid protons go on protons come off protons go on and off every lone pair of electrons and so you can think of it as a proton being directly transferred among there I probably think of this more as being mediated by solvent I'd say that's a better way to think about the process and so in our equilibrium we have lots and lots of methanol around protons flow on protons flow off I will draw a curved arrow representing the flow of electrons back to the methanol doesn't matter which side I write the proton on which side I write the lone pair of electrons on I'm representing a tetrahedral oxygen atom and oxygen atom with four substituents equally disposed about it I guess you'd call it trigonal parameter for the geometry of the oxygen. Alright so that sort of takes us to an uncharged tetrahedral intermediate and this looks a heck of a lot like a geminal diol if you think about it and the common theme in all of this chemistry that we've talked about is these types of tetrahedral intermediates these types of geminal diols are not generally stable. The end of last lecture at the end when we were talking about acetals or in the previous lecture Hemiacetals I mentioned glucose a cyclic example that was stable we'll see a tetrahedral intermediate that's stable on the discussion section where you actually have it as a low energy species but in general tetrahedral intermediates are not stable they're not something that you can isolate or put in a bottle they're just a high energy species a stable stable enough that it's in an energy well stable enough that it can sit around for a microsecond but not stable enough that you could put it in a bottle and so our reaction continues in strong acid protons come on protons go off you put a proton back on the methoxy group we're just on the backwards pathway and so I'm going to continue forward protons come on and off every lone pair of electrons and so now we've protonated one of our OH groups it doesn't matter which one gets protonated they're both equivalent remember we're just tetrahedral about this oxygen now just as we had the attack we can have a breakdown now with the expulsion of water electrons flow down from the oxygen we can't stop at that point because that would force us to have 10 electrons around carbon carbon can't accommodate 10 electrons and so we're going to break down actually I am going to good person and write this mechanism on different lines so give me a moment here I'm just going to continue to balance here and so I will write the breakdown of this tetrahedral intermediate in the next step all right so as I was saying electrons flow down from the oxygen they flow back onto the oxygen this gives us a molecule of the protonated methyl ester and we have expelled a molecule of water and our final step is the very reverse of the first step of the reaction in the first step we put a proton onto a carbonyl in the last step we take a proton off of a protonated carbonyl we're in this vast sea of methanol remember this is an equilibrium reaction if we don't have a lot of excess methanol you're going to get only partial conversion to the ester so we have a ton of methanol floating around our methanol which in protonated form served as the catalyst is now going to accept a proton our protonated methanol at the very first step of the reaction was consumed our acid catalyst was consumed in the very last step it is regenerated and so those six steps constitute the mechanism for our fissure esterification they constitute the mechanism for ester formation thoughts or questions? so your question is why does it protonate this oxygen? why is this oxygen protonated? why is this protonated? because when we push electrons down over here it ends up with a positive charge on the oxygen now remember in the back of your mind when you see this structure as we just saw in the quiz there are multiple contributing resonance forms so that is one resonance form think in your mind for a second about two other resonance forms you can picture another resonance form in which the positive charge is on this carbon and a third resonance form in which we have a double bond to this oxygen single bond to this oxygen and a positive charge on this oxygen and collectively all three of those resonance structures make up a picture of the actual species just as in your oxo-carbenium ion I asked you to draw one structure although it was fine if you drew two resonance structures or it was fine as a matter of fact if you draw any of the three resonance structures any of the two resonance structures so we are just thinking about one of the different pictures that are present in part because if you look at this it is already a long mechanism and so you are sort of holding in the back of your head all of this relevant stuff all right any other questions that I want to talk about the reverse reaction the hydrolysis of esters remember fissure esterification is an equilibrium so if I take and again I am keeping my whole lecture really really simple with simple small molecules if I take methyl acetate and I treat it now with water and sulfuric acid I am going to hydrolyze it to acid acid plus methanol just the reverse of the reaction I could write it like this I could write it like this saying I am treating it with sulfuric acid in water it is all the same thing and since this is so identical to what we just saw at this point you should be able to write a mechanism for acid catalyzed ester hydrolysis I will leave that to you it is identical to the mechanism that I just wrote up but in reverse and you can figure that out all right I want to move on to a little bit of other chemistry of esters carboxylic acids and then talk about amides and nitriels and again I will keep our keep things kind of simple and general esters as I said are moderately electrophilic they react with strong nucleophiles if I treat an ester with sodium hydroxide potassium hydroxide for most intents and purposes these are equivalent in water I get the carboxylate salt I get the alcohol you call this reaction saponification it is a reaction that mankind has been doing for hundreds of years before we had organic chemistry it is the making of soap when you take a fat which is a triester of glycerol 1, 2, 3 propane triol with 3 long chain carboxylic acids esterified on and you stir it with sodium hydroxide that's Lai Drano the sodium hydroxide hydrolysis saponifies the glycerol esters to get the sodium salts of the carboxylic acids that have greasy tails and polar head groups and like both water and grease which is very good for getting clean in the shower makes my cells so reaction here same same principle as we saw in the aminolysis I kind of wanted to when I was talking about this and thinking about where to present it I kind of wanted to present it after we did the water the acid promoted hydrolysis but mechanistically it's right up there with the aminolysis and aminolysis we talked about in other words here's our ester group hydroxide is a strong is a good base a moderately strong base relatively strong base it's a good enough nucleophile it attacks our carbonyl I'll give you a little bit of an abbreviated mechanism here only showing relevant lone pairs we get our tetrahedral intermediate our tetrahedral intermediate is going to break down it kicks out the OR group and again I'm just skipping a few lone pairs here this gives rise to the carboxylic acid plus the alkoxide and the alkoxide is basic and so the alkoxide reacts to form the carboxylate and again I'm not going to write out every curved arrow and every step in painful detail but the carboxylate reacts to give you the alkoxide salt and the to give you the the alkoxide reacts to give you the carboxylate salt and the alcohol and in a preparative sense if I carry out this reaction in the laboratory and I want to isolate my carboxylic acid a very common laboratory procedure to saponify an ester with sodium hydroxide then wash the aqueous layer that contains the carboxylate salt to remove the alcohol and any unreacted ester to extract it with ether to wash it with ether and then very commonly in the laboratory you will acidify with some strong acid in water like HCl or H2SO4 and isolate from there the carboxylic acid sometimes in the laboratory it will precipitate out alright so that gives us a little bit of an overview of carboxylic acids and of esters and now I want to move on to the last members the last main members there are plenty of other members in the carboxylic acid family but I want to move on to the last main members of the family on to amids and nitriels amids I'll write them in general form with two R groups here that could be two hydrogens in which case we have a primary amid a hydrogen and an R group which case we have a secondary amid or two R groups in which case we have a tertiary amid nitriels look very different and yet in some ways are very similar both of these compounds are generally less reactive toward nucleophiles than esters and I think it's kind of easy at least to compare an amid to an ester we already saw this in the IR the stretching frequency for the amid carbonyl is lower there's less double bond character the nitrogen of the amid is less electronegative than the oxygen of the ester the nitrogen of the amid is better able to donate in electrons by resonance to the carbonyl making it less electrophilic and so a general principle is that amids and nitriels generally react less quickly and so if I tried to try to epitomize this with a reaction and again I'm going to write very simple compounds so I will write a set of my but again this could be any amid if I imagine treating it with sodium hydroxide in water like we did with our ester in saponification how would I epitomize this I'd say long time or heat to make it react so let's say delta or long time would be how I'd describe this and again we get hydrolysis we get cleavage by the sodium hydroxide to the carboxylate salt and in this case since we have a primary amid to ammonia now what do I mean by long time well actually the drain oh is which I mentioned for ester cleavage is a good example when hair hair you know you get your drain clogged up with hair is made up of protein which are polyamids when I throw drain oh down the drain it doesn't clog the unclog the drain instantly the drain oh sits with the hair and the grease that are down the drain for a number of hours before it unclogs it in the laboratory if you want to speed this reaction along you could boil your sodium hydroxide with an amid but unlike my comment about trillions of seconds for the water promoted hydrolysis of an ester the reaction occurs even at room temperature at a reasonable rate on the laboratory time scale and again nitrials maybe a hair less reactive than amids I know that that problem comes up on your sapling and but honestly I don't think of them personally as being very different so I can say sort of ditto if I take acetonitrile and treat it under these conditions with sodium hydroxide in water maybe with heat or a long time you know a few hours I'll get again sodium acetate plus ammonia all right by by now you should be reasonably strong in your mechanistic understanding of carboxyl compounds and maybe I'll just give you a quick quick abbreviated tour of some of the mechanisms here your textbook has them in more detail if you want but all of the principles that you can think about are similar hydroxides a reasonably good nucleophile it's it's basic it can attack we can kick up form a tetrahedral intermediate and in part in part here I really don't want to lose the forest from the trees this is the gist of this mechanism your textbook writes the next step in the mechanism as kicking out NH2 minus I think it's okay to think about that the realities maybe a little bit more complicated in some cases one can see died deprotonation occurring but I think I think in terms of your thinking right now it's fine to think about this anyway so that gives us our carboxylic acid and our amide anion the amide anion is very basic you can think of it as pulling off a proton on the carboxylic acid to give you the carboxylate plus ammonia remove the Click it 그 And for nitriels, again, I don't want to get fantastically into a whole lot of mechanism here. And so maybe I'll just sort of start us out here on the mechanism. There's a lot of proton shuffling that's going on. But the gist, remember the theme that I talked about in carbon nitrogen double bonds is basically in very many ways they're like carbon oxygen double bonds. And in a similar way, carbon nitrogen triple bond is very much like a carbon yield or a carbon nitrogen double bond. And so if you look at acetonitrile, you can think of it. So now we're looking at the hydrolysis of nitriels. You can think of this as being very similar. In other words, hydroxide adds, we kick in electrons. You get a negative charge on nitrogen. We're going to shuffle some protons around. I'll say minus H plus, in other words, you can think of this or I guess first we're going to put on a proton here. So I'll say plus H plus. Of course, that's not plus H plus. That's water going ahead and protonating. You can think of this as minus H plus as the next step. Again, we've got sort of a lot of tedious proton shuffling in the mechanism at this point. And I'm abbreviating things a little bit. One thing to keep in mind, again, this theme that I mentioned where carboxylate, where nitrogen, oxygen, nitrogen carbon double bonds are very similar to carbon oxygen double bonds. And so this structure here is really just like the analog of a carboxylate. In other words, there are two resonance structures here. And again, I'm kind of abbreviating this. And so we have two equivalent resonance structures. And then the last step you can think of is just that we're going to pick up a proton. And I'll draw this explicitly. It's nice to be able to pick and choose the resonance structure that you want when you're writing a mechanism. And so I'll just say our last step here is going to be protonation. In some cases you can stop your nitrile hydrolysis at the primary amide. In other cases the amide is going to go on further all the way to the carboxylate. All right, just as esters can be hydrolyzed by aqueous acid, amides can be hydrolyzed by aqueous acid, nitriles can be hydrolyzed by aqueous acid. If I take some amide, I'll write this as RCO NR2 prime. And I cook it up with acid H3O plus in water. Maybe heat that a little bit. And again, of course you can't go to the stock room and get a bottle of H3O plus. It's going to be sulfuric acid in water or HCl in water. You'll get the carboxylic acid and the corresponding ammonium salt. So if I took acetamide as just an example, since I was using acetamide in the previous panel and I talked about trying to stick to small molecules, and let's say I cook that up with sulfuric acid and water, maybe a little bit of heat boiled it up, you get the ammonium salt, the ammonium in this case, bisulfate HSO4 minus and the carboxylic acid. And this is a reaction that's done in the laboratory with proteins. If you want to break down a protein into individual amino acids, for example, if you want to extract the amino acid proline from hair clippings, and this is a procedure in organic syntheses, you can take 6 molar hydrochloric acid, that's about half the strength in the bottle, boil your hair or boil your protein with it for a number of hours and it will break down to the individual amino acids. So it's a very standard way to hydrolyze amides. And again, I've just given acetamide as an example to keep the structure small here. Do the same thing just for comparison with acetonitrile for the sake of simplicity, I'll just write ditto marks here and you get the exact same products, you get the corresponding acetic acid and the ammonium bisulfate salt. And maybe since all of this is really, really, really analogous to ester chemistry, all the things we covered, maybe I'll say write as an exercise on your own, write a mechanism for let's say the acid-promoted nitrile hydrolysis. Okay. Quick question. Yeah, so for the blackboard on the left, can the OH group just perform a nucleophilic attack on the carbonyl? Yes, yes, yes, and I was only starting us out on the nitrile hydrolysis. So in the cleavage of the nitrile bisodium hydroxide to the corresponding amide, yes indeed, you first, to the carboxylic acid, the first step is the hydrolysis to the amide and then it continues on. Oh, okay. So, and sometimes if you're careful, you can control it and stop it at the amide stage. All right. The last couple of minutes that I would like to take here, I want to talk about a few sort of synthetically useful reactions and kind of wrap up our carboxylic acid chemistry. So, we haven't really talked about where acid chlorides come from and basically acid chlorides are high in energy and so you make them from other highly reactive species. Acid chlorides, indeed, remember when I started out, I said every member of the carboxylic acid family can be interconverted by some chemistry or another and so I'm only giving you a little bit of a smattering here but making an acid chloride is a very useful reaction. Treating a carboxylic acid with thionyl chloride is a great way to do it. There are a few other species that are also used for this but thionyl chloride, SOCl2, is particularly popular and the products of the reaction are the carboxylic acid chloride plus if we're going to write a balanced equation, sulfur dioxide and HCl hydrogen chloride gas which generally bubble out. So, I don't want to go into full detail on the mechanism and again I'll leave it to your textbook to do this but I do want to bring out a theme that highlights this chemistry. Thionyl chloride is kind of a sulfur acid chloride. It's kind of a double acid chloride of sulfur. Indeed, this is very similar to another species, phosgene which has a carbon here which also does this reaction. It's a very reactive molecule. It's extremely electrophilic. You've got two chlorines pulling electron density away from sulfur. Through the same types of chemistry that we saw for acid chloride reactions, carboxylic acids can react with thionyl chloride to give an intermediate that looks like a funny anhydride. And this is a theme that you should pick up on in seeing the forest from the trees in this chemistry. And that is that all of these species where you have a carbonyl with an ester linkage, where you have a carbonyl with an ester like linkage to another electrophilic species, the carbonyl becomes super electrophilic. And nucleophiles can attack, even not very good nucleophiles, can attack at there. And this theme, forget the details now, look at the theme. We've kicked out chloride already. That's one of the byproducts. Chloride can come in, form a funny looking tetrahedral intermediate, and that intermediate can fall apart, kicking back, kicking out sulfur dioxide so we get our acid chloride, sulfur dioxide, and chloride anion. And when you write a balanced equation since a proton was lost at the very beginning, you get HCl. All right. That same theme reemerges in other carboxylic acid chemistry. Remember, this is the theme of the anhydride. This is the theme that when you have something electron withdrawing on the carbonyl, it makes it into a good electrophile. And so your textbook gives you another reagent, which in various forms and variations is quite popular for forming esters and amids. We will see it again in the very last lecture when we talk about the chemistry of amino acids, peptides, and that reagent is DCC. And the general idea is acid chlorides and acid anhydrides are generally species on the way to somewhere. They're generally things that you're making to use. Esters and amids are widely valuable, important compounds. They're stable enough to be in drugs. They're the proteins and peptides in your body. And they're molecules that are a lot of interest. And so being able to take a carboxylic acid and an alcohol and make an ester is an extremely valuable operation. Being able to take a carboxylic acid and an amine, I'll write it as a primary amine, although it could be a secondary amine or ammonia for that matter, and make an amide. That is an extremely valuable operation. And a reagent that often gets used for this is called DCC. They're variants of it. But what this reagent is is dicyclohexyl carbodiimid. The carbodiimid functionality is another member of the carbon dioxide family of molecules. And carbonic acid and carbon dioxide are essentially like a double acid, a double acid, carboxylic acid. Carbon's in the plus 4 oxidation state here. The carbon nitrogen bond is electrophilic. And the carboxylic acid in the above case can add to the carbon nitrogen bond. And here's where this theme comes in. So here's our cyclohexane ring. The CC is cyclohexyl carbodiimid. So we have a cyclohexane ring. And here's the big picture. Here's the big idea. The carbodiimid reacts in exactly the same way. We see thionyl chloride. It reacts to make something that looks a heck of a lot like an anhydride. Because remember, the carbon nitrogen double bond is very similar to the carbon oxygen double bond. And a nucleophile can come in just as we have seen time and time again with all of the chemistry we've been seeing today. A nucleophile can come in. And I'm just going to abbreviate CY for cyclohexane. Our nucleophile can come in. And we can kick back and kick out. And eventually, basically, end up giving rise to our acyl nucleophile. Our acylated nucleophile above and dicyclohexyl urea, which is a byproduct of this reaction. So DCC is a very useful reagent for making esters and amides. All right. The last thing I want to do, your book, your textbook has nicely kind of picked and chosen a few additional key reactions. And I'd like to remind you of these, although I know that you also will be able to learn about them from the readings. And these reactions basically fit in the broad theme that we've seen. Lithium aluminum hydride is a super, super good hydride nucleophile. It can push hydride into practically any double or triple bond between carbon and any sort of electronegative atom. It can push it into a carbonyl group. It can push it into an imine. It can push it into a nitrile. Lithium aluminum hydride generally reacts completely to reduce things down. And so your textbook has chosen as a couple of examples to show you in the chemistry of nitriles that lithium aluminum hydride can react with a nitrile to give a primary amine adding in two equivalents of hydride temporarily going through an intermediate where you have aluminum on the nitrogen. Your textbook has chosen to remind you. And this is again just a smattering of the rich chemistry of the carboxylic acid family, much of which you're going to be guided not by having, and this is where people always make a mistake in learning chemistry, organic chemistry, not by memory because there's way too much of it. But by broad principles, all the principles we've seen today, you can apply to all the members of the carboxylic acid family and basically intuit lots and lots of different reactions. So your textbook has also pointed out and reminded you that nitriles can be reduced selectively. And we saw this in esters. We said lithium aluminum hydride blasts the heck of an ester all the way down to an alcohol. Di-Bal is a more mild reducing agent. It can stop and only add one equivalent of hydride. And so your textbook chooses to give you an example of a di-Bal reduction of a nitrile with water as a workup where you can use H3O plus as a workup. Remember, you're going to get an imine initially, but as was aptly asked early on, I think the gentleman in the third row there about primary imines, primary imines generally aren't stable and break down to the corresponding aldehyde in water conditions. And I'll give you two more examples from your textbook while we're talking about the chemistry of nitriles. And again, I could show you many other examples. So Grignard reagents and organolithium reagents, I'll call it R prime MGX or R prime LI followed by an aqueous workup H2O or H3O plus can add to give you ketones like so. And again, this is the same general idea that we've seen before, the idea that these nucleophiles can add in the case of the nitrile group, you often can stop at one addition, which is something you generally can't do with esters. Anyway, I think that basically wraps it up for the chapter. We will be picking up with chapter 23 next time. Thank you.
This is the third quarter course in the organic chemistry series. Topics covered include: Fundamental concepts relating to carbon compounds with emphasis on structural theory and the nature of chemical bonding, stereochemistry, reaction mechanisms, and spectroscopic, physical, and chemical properties of the principal classes of carbon compounds. Index of Topics: 0:56-Esters and Carboxylic Acids Reactivity 9:29-Fischer Esterification 16:41-Fischer Esterification Mechanism 29:52-Hydrolysis of Esters 32:13-Saporification 37:27-Amides and Nitriles 53:36-Making Acid Chlorides 58:11-Making Amides 1:01:33-Nitriles and LiAlH4 and other Organometallic Reagents
10.5446/19412 (DOI)
Good morning. So today I want to begin our discussion of Chapter 22. And Chapter 22 brings us back to carboxylic acids. We talked a little bit about carboxylic acids and their family in Chapter 19. And then we started to introduce some of the chemistry of the carbonyl group in general. Now of course a carbonyl group is embodied in the carboxyl group of carboxylic acids. And so we really needed this understanding to begin to proceed on. So today we're coming back to carboxylic acids. And we're going to talk about themes in carboxylic acid chemistry that involve the same type of reactivity that we saw with ketones and aldehydes. That is the ability of nucleophiles to add to the carboxyl group and to replace the carboxyl group. We're going to come back again later in a couple of more chapters where we start talking about carbon-carbon bond forming reactions and talk about clasin condensations and other additions of carbon nucleophiles that are going to be based on this other property of carbonyl compounds, the acidity of the alpha proton. But right now we're going to just talk about the carboxylic acid family and their properties, the different functions, the different members of this family and their interconversion. And today we'll conclude by discussing the chemistry of acid chlorides and acid anhydrides, the two most reactive members of the carboxylic acid family. So let me draw out the family here or at least the main members, the important players. Of course we have carboxylic acids. And then sort of as a very close relationship we have esters. We've already talked about the relationship between alcohols and water and here in the carboxylic acid you sort of have a half of a water molecule and ester you have half of an alcohol molecule. So they'll have many things in common. Amids of various flavors. I'll just draw the amids structure generically with two sort of generic R groups. They can be alcohol, they can be aromatic, they can be hydrogens and we have various flavors of amid primary, secondary and tertiary. Amid we'll talk a little bit more about them. And these then moving along in the family we have acid chlorides. Acid chlorides are very reactive. We'll be talking about their chemistry. I'm giving you the important members of the family. One could easily envision acid bromides where the bromine is replaced with the chlorine and perhaps envision very similar properties. In practice they're much less commonly encountered but very similar in their reactivity. Acid iodides even more unusual and more reactive. Acid chlorides are a little bit funny. We're not going to talk a whole lot about them. They're still quite reactive but actually a little less reactive than acid chlorides for reasons of resonance stabilization. Also in the reactive members of the family we have anhydrides or sometimes you'll hear them referred to as acid anhydrides. And finally and again of course I'm only taking a limited subset of the family we have nitriels. And if you look at the a nitrile, nitrile is sort of the odd man out in this group in the sense that you would say by comparison I guess if I'm writing everything with S I'll write carboxylic acids. By comparison it doesn't look anything like the other members of the family. It's sort of the odd cousin. And what is in common to all of these is that the oxidation state of the carbon atom is the same in all of these. In all of these family members we're in the plus three oxidation state for that carbon. So even though a carboxylic acid and ester and acid chloride and anhydride have carbonyl groups, carbon double bonded to oxygen and the nitrile obviously does not, there are many similarities in reactivity. Also when we talked about imines I said that in many ways the reactivity of a carbon nitrogen double bond is very similar to a carbon oxygen double bond. In other words, imines have a lot of the same reactivity as aldehydes and ketones. And nitriles now you have a triple bond but again you get this theme of a carbon multiply bonded in this case triply but otherwise doubly to an electronegative atom. All right, let's take a moment to talk about naming compounds and I don't want to get heavily caught up. I think it's very easy for students to obsess about nomenclature and I want you to be able to see the forest from the trees. I really want you to be able to see the anatomical features of the molecule. In other words, be able to recognize the pieces of the molecule because conceptually this is the key to understanding the molecules and it's very easy to quickly end up getting yourself confused with rules of alphabetization and so forth. So here we have an ester and an ester as I just mentioned has one component that comes from an acid and another component that comes from an alcohol and just recognizing those two key components then is key to understanding their synthesis, some of their reactivity and so forth. So let me take a specific ester and we can see how to name it. And so this ester has an acid component from butanoic acid and an alcohol component from ethyl alcohol or ethanol. So we call this ethyl, esters get a first name and a last name. We call this ethyl butanoate and it kind of makes sense on the nomenclature intuitively if you recognize that what we've done is just take the butanoic acid and replace the OIC with OATE. And so they're being able to see the components is important. I'll give us another example along the same lines. So we'd call this compound methylbenzoate. That's OATE on the end because it's derived from benzoic acid. For amides a lot of the thinking is kind of similar. We have two components and we sort of recognize that here's our amide and so we have a component that came from the acid and a component that came from an amine or ammonia. And so I'll give us a couple of examples here. In a way you can think of this as being a parent compound in the sense that this is sort of the parent of any hexanoic acid derived amide that would have a nitrogen on it whether it had substituents or not. So we would call this hexanamide. And you can just think of this as basically putting amide on the end so it's derived from hexanoic acid. So we call this a primary amide because it's derived from ammonia because there are two NHs, two hydrogens on the nitrogen. And I'll give us an example of another amide. Let's actually I'll give us an example of a couple of more amides to let them start on this blackboard over here. So I think that would work. All right, a couple more examples here. So this acid, this amide comes from acetic acid. So we would call this N-methylacetamide. This compound is a secondary amide. And if you're typing out the structure, you would italicize the N. The N means the atom nitrogen. It means that there's a methyl group on the atom nitrogen. So unlike the lower case N when I talked about say, inbutylithium which meant normal, it meant the linear chain, a capital N as I said, typeset and italics but probably just written like I've written it here, means on the nitrogen atom. Take another example here. Common amide, an amide that's often used as a solvent is N-n dimethylformamide. So we have two substituents on the nitrogen so we call this N-n dimethylformamide, all one word. It's a tertiary amide. In other words, it has two substituents on the nitrogen. And one thing to keep in mind, many, many students look at a compound like dimethylformamide and they say, oh it's an aldehyde because I'm used to the C-H-O group. Well, the nitrogen and the carbonyl function together as a pair, they work as a functional group. In other words, we see a functional group, you know, one of the driving concepts in organic chemistry is that groups of atoms closely connected also often have very specific properties. Because the nitrogen is conjugated because it's in resonance and I'll talk more about that in a moment, because it's in resonance with the carbonyl group, this behaves like an amide, not like an aldehyde in all of its reactivity. So just as methylacetamide and methylacetamide is not a ketone and N-n dimethylformamide is not an aldehyde. Is the name acetyl and borma like a proper ion? Okay, great question. Are these the proper names or are these the common names? Anyone want to answer? Common. Common, yeah. So this one would be N-methylethanamide if I wanted to write out the IAPAC name just as we had done there with hexanamide but no self-respecting chemist would call it that. The latter one would be N-n dimethylmethanamide because it's derived from methanoic acid but everyone calls it formic acid. Wait, then would it be alright if we put this instead of the IAPAC name on the test? As I said, students often obsess over nomenclature. You would be hard, no, it's okay and it's scary. It's scary because I literally can hand you a book 500 pages on how to name organic compounds and it's easy to obsess over it. The other reason it's easy to obsess over this is because when it comes down to it, this is simple. I don't mean it's simple to know all of the rules and some of them are arcane. I mean it's something that a computer can easily work through and there's very little higher thought process involved in naming a compound and so it's easy to spend time obsessing over that and not to get on to the stuff that's really conceptual. So don't worry, I won't ask you on a test. Was that the IAPAC name or the common name? Alright, now I'll give you one thing that I wouldn't expect you to obsess over but I was obsessing over just to show you one other example of where we have two different substituents here. So this is another tertiary amide and for this particular one, it actually was an example from your book. It's n-isobutyl n and I'm going to break it with the hyphen here just because I can't write it all out on one line. N-methyl and then what's our carbon chain? 1, 2, 3, 4, 5, pentanamide. I think your textbook must have had butanamide so I'm going to draw it with one fewer carbon here. Butanamide and that was an example from the problems that I asked you to work out as you go along when you're working out, working things out. Anyway, what we've done here is we've named the two halves on the nitrogen and we've alphabetized it but again, I think it's really, really easy to end up obsessing over that and don't get that obsessed. Alright, let's go on to acid chlorides and acid anhydrides. Alright, so let's go on to an acid chloride here, derived from pentanoic acid and again, we're seeing the family relationships here too. This is an acid chloride derived from pentanoic acid so we call it pentano-wheel chloride. We've taken the pentanoic of the acid from which it's derived and we've changed it to OYL. With the common names, you do it slightly differently so this compound here is acetyl chloride rather than acetoyl chloride and it's just how people name it, how it flows off the tongue. And let's do one more, I'll do an anhydride here. This is the anhydride derived from benzoic acid so we call it benzoic anhydride. Alright, last class of compounds I want to talk about in the family is nitriels. And so I'll just take the nitrile that's related to hexanoic acid, the one that has six carbons in it. You might draw it with C triple bond N, you might draw it just as CN, it's the same thing. This is called hexane nitrile so since it's a six carbon chain, it's called hexane and you just put nitrile on it. You don't have to specify the position of the nitrile because being triply bonded, there's no other place that you could put that nitrile group except on the end of it. Again, the small molecules tend to have common names. We also tend to splash the small molecules around like water in the laboratory, acetonitrile is a common solvent, this is acetonitrile, acetone is a common solvent, acetic acid is a common solvent and so you splash them around in separatory funnels and in chromatographic columns and the like. And let's see, I'll give you one more example. So one of the things that we saw when we were talking about naming carboxylic acids was we said when you have different groups, some of them will have lower priority so in general carboxylic acids have higher priority than ketones and aldehydes and nitriles have lower priority than carboxylic acid. So if you have the cyanone, if you have a nitrile group and an acid group, you end up naming it as the substituted acid. So this one is commonly called cyanowacetic acid. All right, well that gives a kind of a quick overview of how we talk about these compounds. I want to talk now about their physical and then their spectroscopic properties because I think that gets us into things that are more interesting and more important. So let's see. Your textbook sort of approaches this from the point of generalities and I decided I would approach our discussion today of the physical properties of compounds from a couple of specific examples that were kind of important compounds. So and this is maybe giving you a little bit of a flavor of my own thinking about the chemistry of the carboxylic acid family. So I decided to start our discussion today with ethyl acetate. Ethyl acetate is of course a widely used solvent. It's present in nail polish remover. You may have used it for liquid liquid extraction in the laboratory. Esters in general tend to have rather nice fruity odors and so ethyl acetate has a strong smell to it that's not unpleasant. Some of the esters like isoamyl acetate have very strong fruity odors so that's just overpoweringly banana. It's one of the components in banana. So ethyl acetate is a liquid. It has a boiling point of 77 degrees Celsius and I thought that might be a nice kickoff point to kind of contrast some of the properties to other molecules and so when I was thinking about molecules that are kind of the same size I figured well ethyl acetate has six heavy atoms, six carbon and oxygen atoms. It's about the same molecular weight as hexane. So by comparison I'd say hexane is a liquid 69 degrees as its boiling point and then if you say well we learned when we talked about Van der Waals contacts that if you have a more linear molecule you get more of Van der Waals contact and of course ethyl acetate sort of has a branch in it you might say maybe it would be a better comparison to compare it to two methyl pentane and two methyl pentane is also a liquid and it has a boiling point of 60 degrees. And so the take home message on this is not surprisingly ethyl acetate has a higher boiling point than molecules of similar size that don't have dipoles in it and it should make sense. I mean you have a molecule that has a molecular dipole in it and as a result you also see differences in solubility and all of this really can be explained by thinking about resonance structures. So I'll just add that the solubility is it's soluble in water soluble to the extent of about 8.3 grams per 100 milliliters and I always find that sort of interesting. I mean on the one hand you expect ethyl acetate to be have solubility in water. We've learned that if you have polar atoms and you have a reasonable ratio of polar atoms to carbon groups you should have some solubility in water and at the same time you may have heard the number 4 that if you have 4 carbons per oxygen or fewer you can think of something as soluble. But here we have no way we have 2 carbons per oxygen and so you think about something like ethanol and it's miscible with water it mixes with water so 2 carbons 1 oxygen. Diethyl ether 4 carbons 1 oxygen is about the same solubility in water but here we have 2 oxygens. Tetrahydrofuran 4 carbons and 1 oxygen is completely miscible with water. So in a way it surprises me it's a little less soluble than you might think. And we certainly can think of it as polar and you can think of it either as oh yeah the bond between oxygen and carbon is polarized and so you can think of it as saying delta plus delta minus or you can think of its behavior in terms of resonance structures and so just as with every carbonyl compound you can write minor resonance structures in which the carbonate a minor resonance structure in which charge is separated like so and I guess I'll be a good person in drawing my lone pairs over here. What's interesting about ethyl acetate and all other esters is you can write a second resonance form like so with a positive charge on this oxygen and so collectively the major resonance structure and the minor resonance structures, the small contributors certainly can explain the polarity of the molecule just as we saw and explained that acetone had a higher boiling point than say isobutylene and yet there's a little bit of unsatisfying why it's not more polar. The one thing that these resonance structures don't really embody is the fact that this oxygen is while it's donating electrons through resonance, it's also pulling them away in the sigma bonds. So in other words we have these two oxygens pulling in opposite directions through the sigma bonds to pull electrons away and for that reason ethyl acetate isn't as polar as you might otherwise think. In other words it's soluble in water but it's not super soluble in water and not miscible in water. It is a polar molecule that has a dipole moment to it but the dipole moment is not huge. It's not huge as say dimethyl formamide which I'll talk to you about in a moment when we talk about amids. All right I want to contrast ethyl acetate. As I said I'm coming at this from the point of view of specific molecules and their properties and sort of what they mean to me. I want to contrast ethyl acetate to a couple of familiar amids and so I'll start with acetamide and so acetamide by comparison is a solid. It's got a melting point of 82 degrees and if you heat it enough so it boils it has a boiling point of 221 degrees. So clearly acetamide even though it's a smaller molecule than ethyl acetate is much stickier and we saw this principle in carboxylic acids when we talked about their high boiling points. Acetamide has the ability to hydrogen bond and so you can form hydrogen bonded dimers and you can get further hydrogen bonding because you have the electronegative nitrogen bound to the hydrogen and so that can make these molecules stick together. Now dimethyl formamide of course doesn't have hydrogen bonding. You don't have any hydrogens on nitrogen and so dimethyl formamide can't participate in hydrogen bonding and yet it too is much higher boiling than ethyl acetate. So dimethyl formamide is a liquid. Its boiling point is 153 degrees. Decomposes to carbon monoxide and methylamine at that temperature so you can't really distill it and it's much more polar. It's got a bigger dipole moment, a bigger dielectric constant than ethyl acetate. It's miscible with water and you really in the case of dimethyl formamide can think of it getting a lot of its properties from that minor resonance structure off on the right. I'm not going to write off all of the resonance structures. I'm just going to write out the key resonance structure here and say you can explain a lot of its behavior by this type of resonance structure. Now this brings up an important point about amides. So this is still a minor resonance structure. But the point is the molecule is always, I'll get to your question in a second, the molecule is always multiple resonance structures all at the same time. These are just different pictures of the same thing. But in the case of ethyl acetate, it's just a little bit of this resonance structure. And in the case of dimethyl formamide, it's a little bit more. It's on the order of maybe 30% of that resonance structure if you needed to have a number in your head. One of the things that's very important to keep in mind about this fact is the fact that this nitrogen in dimethyl formamide and in amides in general is much closer to being sp2 in its properties, to being sp2 hybridized than sp3 hybridized. I'm going to write it as sp2 hybridized here because that really comes as the closest description. It's somewhere in between but it's more like sp2 hybridized. In other words, that nitrogen is not basic like an amine. It's much less basic than an amine because it's participating in resonance. All right. I saw a question. First. What does it say behind the table? Ah, decomposes. DEC is often the shorthand. You'll see chemists write for decomposes. Another question. Yeah. Back to the top of the board. What's the point of some kind of two pentanone? Of two pentanone. Two pentanone, let's see. It's acetone boils at I think 56 degrees. So we're talking somewhere around 80-ish. Oh wait, pentanone. So I'm thinking butanone. So pentanone, yeah, close to 100 degrees. So yeah, I mean even a bigger dipole for there. But the point is if you look at 153 versus 77, it's a big difference. So in other words, ethyl acetates a polar molecule but it's not like a super polar molecule. And by the time we come to the amides, it really is quite polar. If I wanted to make maybe a closer comparison to ethyl acetate, maybe I could also say Nn dimethylacetamide just because let's see, here we have 4, 5. I guess that's a reasonable comparison here. Other questions. All right, I want to take a look at this point at what the IR spectra tell us about the behavior of these molecules in parts so you can get used to recognizing them and in part so you can continue this theme of understanding their properties. All right, so to separate the forest from the trees, we talked before about all the carbonyl compounds. We talked, well except amide, no, I guess we talked about amides. So except acid, chlorides and anhydrides. We talked about esters and aldehydes and acids and ketones and amides and their relative carbonyl stretches. And the main point is you have a carbonyl band somewhere around 1700 wave numbers. And they differ a little bit depending on the nature of the particular carbonyl compound. So amides have their carbonyl typically around 1660, somewhere below 1700 is typical. Typically I'll sort of take a middle ground of around 1660. And so if we compare this, I always like to think of when I hold things in my head for understanding them, I always like to think around one compound. It's kind of the same that you saw in the theme of my talking about acetyl acetate or dimethyl formamide. So if I think of a typical ketone, whether it's cyclohexanone or acetone, I sort of think of a typical ketone as having about 1715 wave numbers. And so you think about this and you say, well this is saying that the nitrogen, that the carbon oxygen double bond stretch is weaker than that of a ketone. So I'd say a weaker CO. And you think about this resonance structure and this minor resonance structure really helps explain that very nicely. In other words, of course, it's not one, it's not the other, it's both and other resonance structures at the same time. But if you look at this, you say, oh yeah, I can understand. We have some single bond character mixed in here with the double bond character. So instead of vibrating at a higher frequency like a stiffer spring, it vibrates at a lower frequency, ever so slightly lower like a less stiff spring. Now if we come over to esters, typical ester, and again, these are sort of generic compounds and generic values, the typical ester is at about 1735 for the carbonyl stretch. So you don't see it very, very different from a ketone, just a little bit different. But where you really start to see things different is by the time you get to acid chlorides and acid anhydrides and this is where I think it's really telling. So you look at an acid chloride and the carbonyl stretch, now is it about 1800. And if you're looking at an IR spectrum, it's 1800s really distinctive. In other words, 1720, 1735, you'd say, okay, I can see differences, I can read the scale, but they're all sort of similar. Amid you'd say, oh 16 or 50, 1660, 1670, you'd say that's significantly different. Then at the other end you look and you'd say 1800, that really starts to look different. And one of the ways you can think about this, there are a couple of ways you can think about it. So obviously the fact that we're at 1800 means here, we have a stronger CO bond. And one way you can think of it is without resonance. You can say, well chlorine is electronegative. You can say chlorine is electronegative, it has a pulling electronegativity of 3.2 and it's basically pulling electron density down. And the big difference between chlorine and oxygen is oxygen is the same row as carbon. Oxygen can give good resonance overlap with carbon. Chlorine, instead of being second row, is third row. It's one row down. You can't get much pi bonding. You end up with very little double bond character, but a lot of that sigma electron withdrawing character, a lot of the chlorine inductively electron withdrawing. And so you can think of the chlorine as pulling electrons down from the oxygen making this bond stronger. It's pulling electron density down. You have lone pairs of electrons. They're pushing back in. I like to, in the back of my mind, I probably wouldn't write this resonance structure, say, elsewhere, but in the back of my mind, I kind of keep in mind the fact that if you take that type of thinking to its logical extreme and say, all right, there is a component of the chlorine pulling electron density away inductively, you can think about this non-bond resonance structure here. And in this non-bond resonance structure, you have some triple bond character. In other words, this is a very minor contributor, but it's basically that oxygen pushing in extra electron density, making that carbonyl bond even stronger, if it's stronger, you have it resonate at a higher frequency. And so you end up at 1800 instead of 1700 wave numbers. It's also very hot electronically. And we're going to see that acid chlorides are the most reactive member of the family with nucleophiles. Now, you have the same type of principle in acid and hydride. So just like the chlorine is pulling away electron density, you have the ASO group is pulling away electron density. And for that reason, in acid and hydrides, the carbonyl stretches also come at a higher frequency than you might expect for say a ketone. And acid and hydride show pairs. 18, 20, and 17, 60 would be typical for a pair of bands in the IR. In other words, you have two stretches, not one. And at first you might say, oh, well, that means that there are two types of carbonyl groups. It's not really that simple. When you have vibrations and they're close together, you get what are called coupled vibrations when they're close to each other in space. Kind of like splitting in the NMR spectrum. And when the vibrations couple, you have them working together. In other words, it's not one carbonyl stretching and the other carbonyl stretching, but it's both of them stretching together. And there are two types of stretches. One of them is an asymmetric stretch. And one of them is a symmetric stretch. So you end up with two bands. All right. And so I think what the IR spectra really are telling us is that acid chlorides and acid and hydride are really special in their properties. And they're special in that you have a lot of extra electrophilicity at the carbonyl. In other words, in other words, acid chlorides and acid and hydrides react with many different electrophiles because that carbonyl has the pulling away, the electron withdrawing group of the acyl group or of the chloride group. So to put it bluntly, if I take acid-teal chloride and I pour it into water, it sizzles. Spatters, it reacts violently. And the reaction gives acetic acid and HCl. Acid and hydrides also react with water not as violently, but they react. I'll just write reacts by contrast to violently. And the acetic N hydride hydrolyzes. Hydrolyzes is a fancy way of saying cleaves, lices by water. And where I really want to compare this to, to start our discussion of the chemical reactivity of the chemical properties of the carboxylic acid family, where I really want to contrast things to is to start to contrast them to say esters and amids. So if I take ethyl acetate and water, there's no reaction. We'll learn later how we can hydrolyze ethyl acetate with water, but it doesn't occur by just mixing ethyl acetate and water. I can qualify that. It can occur over a very, very, very long period, like years, or it could occur if you slowly, if you boil the ethyl acetate and water. But for all intents and purposes, there is no reaction. And that's a very good thing because esters and amids, which I'll write as the next molecule, I'll write NN dimethylacetamide, these are the molecules of biology, not ethyl acetate and NN dimethylacetamide, but of course, esters make up your lipids. The membrane in your, that covers every cell in your body is made of lipids. It's made of long chain fatty acids that are esterified to glycerol that are hooked to other fragments like acetylcholin. And what would happen if at room temperature, at 37, at body temperature, esters reacted with water, is your cells would all be, would all break apart. So it's very fortunate that esters don't automatically, don't without a catalyst or an enzyme, react with water at any appreciable rate at room temperature at 37 Celsius. Amids, it's the same thing. If I take an amid with water, there's no reaction. And again, this is very, very important because all of the proteins in your body are made up of amids. And if they were to react with water, the proteins would break down, you'd just be a pile of amino acids and fatty acids and glycerol. And you wouldn't be you. Now, amids and esters are also widely prevalent compounds, not only naturally, but synthetically. Your nylon backpack is made of a polyamid that chemists made to mimic proteins and initially the protein silk. Because stockings, as I see you're wearing, are, used to be made only available in silk. And silk is expensive and fragile. And at the time of World War II was needed for the war effort. And so having synthetic substitutes was useful. Esters, again, for a very good thing that polyamids like your backpack don't hydrolyze, when it rains your books would fall out and get wet. And polyesters, in addition to polyester fabrics, if you're wearing a polyester warm-up jacket there, are made, are used to make your water bottles. And you're plastic many of the, that's probably polystyrene in your container up front. But your water bottles that you buy, the aquafina or whatever herbal water they sell on campus here, are made of esters. And again, you'd be in a lot of trouble if they hydrolyzed on their own. Would the amide and the ester reaction go forward if we apply some acid to the amide? Would the amide, yes, and we will talk about that in tomorrow's, in our subsequent talk here. So yes, indeed, acids and strong bases can make them react. I want to finish one discussion of spectroscopic properties before moving on to chemical reactivity and focusing on acid fluorides and anhydrides. And I want to, I want to conclude maybe by talking about acetonitrile here and nitriels in general. So we talked about all the carbonyls and we said carbon-oxygen double bonds are centered around 1700 wave numbers. Triple bonds are of course stronger than double bonds. So carbon-nitrogen triple bond is centered at about 2250 wave numbers. They're usually sharp in the IR spectrum. As long as we're talking about acetonitrile, I'll add also no reaction with water. And again, that's in the absence of strong acid or strong base and we'll be talking about that later. I also want to give you a generalization. Remember we were talking about NMR before and I said I like to have a few baseline numbers in my head. The methyl group, whether it's on an acetonitrile or next to any sort of carbonyl, these methyl groups are always about 2 ppm, very close to 2 ppm in the 1H NMR, in the proton NMR. And the reason I like to keep that number in mind is then I can think okay, if we have a methylene, it's just like a methylene in an alkyl chain is a little further downfield, a few more tenths downfield than a methyl group and a methine in an alkyl chain is a little further downfield. We can go a little further downfield. So in general you can say for a hydrogen that's next to a carbonyl or next to a nitrogen, in general about let's say 2 to 3 ppm or 2 to 2.5 ppm depending on how you want to look at it. In other words, a methylene, a CH2 is going to be a few tenths further downfield, a methine will be a few tenths further downfield. I don't want to get overly caught up on the numbers here for spectra. All of, I just want to mention a few things. In the carbon 13, carbonyls in general are way downfield of the amide region, of the aromatic region. So in general you can pick out carbonyls. Carbonyls and ketones and aldehydes typically are around 200 ppm, a little bit more, 220, 190 somewhere around there. Typically for the whole carboxylic acid family, we're talking about 160 to 180 ppm in the C13 NMR. For the whole sort of carbonyl, the whole carboxylic acid family and just for the sake of completion, I'll give you nitriels. You have a carbon-carbon triple bond. It's kind of like an alkyne but you have an electronegative atom so you're talking about 115 to 120 ppm. All right. There, organic chemistry is about making stuff, at least a big part of it. And there are chemical reactions to interconvert all of the members of the carboxylic acid family. Acid chlorides, acid anhydrides, esters, carboxylic acids, amides and even nitriels can be interconverted to other members of the family, to nitriels, to esters, to carboxylic acids, to acid chlorides, to acid anhydrides. Now, if I were to say, okay, how many different, just if I figured one reaction for each of these and I think I've named six members of the family going into any other six members of the family, I basically would end up having a minimum of 15 different reactions and there are, of course, more to interconvert these members of the family. And so the first thing you might think is, oh my God, this is overwhelming. How can I possibly understand all of these reactions, all of these reagents? And the answer really becomes by thinking mechanistically, understanding the principles and understanding the general reactivity of different molecules. So I want to give you some generalization here before we dive into specifics. And so if we have some general member of the family, and nitriels are kind of the oddball, so I'm going to leave them out. We'll talk about them at the end on the next lecture. And we have some nucleophile, NU minus or NUH. Sort of a very, very generic type of species. Water, of course, was NUH. It was OHH. In general, a common theme is that the group on the carboxylic acid can under some conditions get replaced. It can get displaced by a nucleophile. And if I'm going to write a balanced equation, I would also say plus X minus or HX. And that's not meant to be a functional equation at this point. This is meant to be a generalization. And now I want to start to put structure in some specific to this. And so what I would say is this occurs with basic nucleophiles. So in other words, species like alkoxide, RO minus, hydroxide, HO minus or OH minus, and let's say amines. I'll write it as R2NH, but I'm not meaning specifically a secondary amine. I could mean a primary amine or I could mean ammonia. Or, so in other words, in general, members of the carboxylic acid family in general can react with good nucleophiles or with good electrophiles. And of course, what do I mean by good electrophiles? Well, good electrophiles are those ones that sizzle or react vigorously with nucleophiles. So specifically in this family, I'm talking about acid chlorides and acid anhydrides. So that's sort of one generalization that I'd make. And the other generalization that I would make is that weakly basic nucleophiles. And what do I mean by weakly basic nucleophiles? Well, we talked about these with ketones and with aldehydes. We're talking about things like alcohols and water. So I'll write ROH and water. And I'll say that they can react with less reactive electrophiles. And what do I mean by less reactive electrophiles? Well, I mean the members of the family that don't react with these, that don't have that electron withdrawing group, that don't have that carbonyl shifted up to 1800 or thereabouts in the IR spectrum. So we're talking esters, acids, amides, and nitriels. And they can do this if they have some help with strong acid catalysis. And what we're going to see in the next lecture is that a strong acid can protonate the carbonyl of an ester or a carboxylic acid or an amide or can protonate a nitrile group and take something that's only a weak electrophile and turn it into a strong electrophile in a mechanism that we end up going through. All right. So that generalization serves as a framework. And now I want to go on to some specifics and to talk about specific reactions of acid chloride and acid anhydrides. And so by way of a specific example, I'll take acetyl chloride. And I want to write a balanced equation here. Acetyl chloride, let's look at its reaction with a simple amine, methyl amine. Acetyl chloride can react with two molecules of methyl amine to give dimethylacetamide. And organic chemists are always bad about balancing equations, but I will balance it. And dimethylammonium chloride, dimethylamine hydrochloride, ME2NH2 plus Cl minus as a salt. What I want us to be able to do, because this is the archetype for all of our thinking about this chemistry, I want us to be able to think and understand our way through these mechanisms. And particularly to get the big picture, because sometimes the details aren't going to be that important. So here's our acetyl chloride. We know that that carbonyl is electrophilic. And we know that dimethylamine is nucleophilic. It has a lone pair of electrons. It wants, it's willing to share those electrons. We can attack very much like the theme we saw in imine formation chemistry. We can attack this extra electrophilic carbonyl. And at this point, I'll write this, I'm going to write this as irreversible. It's always a little bit of a judgment call. But if you have something where you're really, I guess I can write the first step as reversible, although honestly I'm not going to sweat about it. So I'm just going to write this one way. Okay, so at this point though, the big picture, the big idea is now just as in imine formation, at this point we formed a tetrahedral species. We formed a tetrahedral intermediate. And this and the next step really become the big idea here, the next part of the reaction. Yes. Oops, did I forget an age? No, I drew in an extra lone pair. You mean here? Ah, wait, where? Oh, okay, I was meaning to, I'm sorry, I was meaning to draw in dimethylamine. So dimethyl, let's do two molecules. We could do it with methyl amine. But let's do two molecules of dimethylamine react to form the dimethylamide and dimethylammonium chloride. And let's have our two methyls on the nitrogen with a hydrogen and a lone pair add to the carbonyl attack to give a tetrahedral intermediate. And the big point about this is our tetrahedral intermediate is going to be unstable just as we saw in imine formation where the hemiaminal is not a stable compound, it's not an isoble compound. That same theme emerges here. Question? Yeah? Why do we need two equivalents? You're going to say why do we need two equivalents? Great. All right. Just as in imine formation, your tetrahedral intermediate is unstable. I'll be a good person for one moment here. And I'm going to draw in all of my charges and all of my lone pairs of electrons. The tetrahedral intermediate can break down. It doesn't stick around. It can kick out chloride. Chloride is a good leaving group. Chloride gets expelled. But remember, this nitrogen here in an amide is not an amine nitrogen. It is not a basic nitrogen. It is not an sp3 nitrogen. It doesn't want to have a proton on it. It is very acidic and it's going to give up that proton to anything that's basic. And we have dimethylamine present. And so our dimethylamine is the strongest base in the house. And dimethylamine is going to pull off that proton to give you your dimethylacetamide plus dimethylamonium chloride. Well, I guess I've already written my chloride so I'll just balance my equation and say plus the dimethylamonium product. And if I were to not have that extra equivalent of dimethylamine around, halfway through all of my dimethylamine, the remaining dimethylamine would be protonated as the hydrochloride. Now, the reason I'm saying not to get too bent out of shape on this mechanism, the big picture, nucleophile attacks, we get a tetrahedral intermediate, the tetrahedral intermediate breaks down, protons shuffle around. Your textbook writes these two steps in reverse. Or more specifically, your textbook on closely related reactions and in the homework writes the deprotonation step at the tetrahedral intermediate. I don't think that makes as much sense on the basis of acidity. Don't get bent out of shape about it one way or another. The big picture nucleophile attacks, tetrahedral intermediate breaks down, protons shuffle around. If they shuffle around beforehand, it's not that big a deal. Other big picture item from a synthetic point of view, chemists often want to go ahead and not waste the valuable amine. Sometimes they'll add a base that's sacrificial, a tertiary amine like triethylamine or pyridine is added as a base. I'll write parenthesis pyridine here is added as a sacrificial base so you can use only one equivalent of amine. All right. This same basic principle of reactivity of acid chlorides applies with all other species whether it's strong base, whether it's basic nucleophiles like amines or weakly basic nucleophiles like alcohols and water. Acid chlorides react vigorously. So for example, if I take benzo-wheel chloride and I take ethanol, they react just like I said, acid-tyl chloride reacted to form with water. They react to form an ester ethylbenzoate. And again, if I want to balance my equation, HCl would be a byproduct. Very often in this chemistry as well, often you'll use pyridine as a base. Pyridine triethylamine can be used as well, disapropyl ethylamine as well to react with the HCl. So just for the sake of writing a balanced equation, if I take my benzo-wheel chloride, plus ethanol plus pyridine, I'm going to go ahead and get ethylbenzoate plus pyridinium hydrochloride. And on a preparative level, in the laboratory, you would probably carry out an aqueous workup in a separatory funnel in which you would extract the ethylbenzoate into the organic phase. You would wash away the pyridinium hydrochloride salt in the aqueous phase, and then you would dry your organic phase over magsulfate and filter and concentrate to get your ethylbenzoate. And you can imagine all sorts of other reactions of acid chlorides. We already saw that acetyl chloride reacted with water to give acetic acid, or you could use some sodium hydroxide in there to get ethyl acetate out of there, sodium acetate out of there. You could react sodium acetate with acetyl chloride to get acetic anhydride. And so maybe I will just very quickly sketch out these reactions, acetyl chloride plus H2O goes to acetic acid plus HCl, acetyl chloride. And you should be able to think your way through mechanistically on all of these acetyl chloride plus 2 hydroxide anion goes to acetate anion plus water H2O plus chloride anion. And I'll just write one more balanced equation, acetyl chloride plus let's say sodium acetate just to the hell of it I'll write in the counter ion here goes to acetic anhydride plus sodium chloride. All right, as disparate as all of these reactions sound, they're actually all the same basic principle. Once you get the idea of a nucleophile attacking your acid chloride to form a tetrahedral intermediate, the tetrahedral intermediate breaking down and some protons shuffling around, you end up comfortable with all of this chemistry and you see that it really, really falls into the same category. Now I wanted to mention two last points. One of these is the trends we've been talking about. We said that acetyl chloride is more reactive or in general I'll write acid chlorides are more reactive than anhydrides and those are more reactive than esters and those are more reactive than amides. And that makes sense if you consider the pKa of the conjugate acid of the leaving group. In other words, HCl is the conjugate acid of chloride as a leaving group. Its pKa is negative 7. In other words, chloride is a very good leaving group even in this or in this addition elimination chemistry. The pKa of a carboxylic acid, the conjugate base of a carboxylate leaving group in anhydrides is on the order of 4 to 5. While it's much less of a good leaving group than chloride, remember this is addition elimination chemistry, not S into displacement chemistry, it's still a good enough leaving group. By the time we come to an alcohol, the conjugate base of alkoxide leaving group, we're talking pKa 16 to 17 here. Now we're not so good and then by the time we come to an amine as our leaving group here, now we're at about, depending on which number you use from your textbook, about 38 and so now we've gone, we basically spanned five orders of magnitude here in our peak, or spanned pardon me, almost 50 orders of magnitude here, 45 orders of magnitude in our chemistry here. All right, the only sort of odd ball in this mix are carboxylic acids and the reason I haven't immediately included them is there's one special caveat. You'd say for many purposes and we'll see in fissure esterification and transesterification, esters carboxylic acids are the same, but in the case of a base, often you will have a base deprotonating a carboxylic acid to give you a carboxylate and then you end up really, since the carboxylic acid is acidic, you really have to think about O2 minus, which is just not a leaving group. So there are certain cases where you're talking about say an ester will react with an amine if you warm it, but a carboxylic acid is just going to do proton transfer with an amine, unless you heat the absolute hell out of the thing to hundreds of degrees. All right, last thing I want to do is talk about the reactivity of anhydrides and really for many, many purposes the reactivity of anhydrides is like that of chlorides, acid chlorides, except they don't sizzle with water. So they're less reactive. So if I take acetic anhydride and dimethylamine and again I'll write a balanced equation, I get dimethylacetamide and I also get plus dimethylamonium acetate. By the way, you will often see this written as acetic anhydride AC2O and sometimes you'll see it written here as an ac group, but hence I'm just writing it here as OAC. Now for this same reason and the same idea we talked about when we were talking about the chemistry of acid chlorides, because you're using a second equivalent of amine as a base in this chemistry because it's getting protonated by the acetic acid byproduct of reaction, often you will use a sacrificial base like pyridine. So I'll write a balanced equation and at this point I'll use the shorthand for acetic anhydride. So I'll write acetic anhydride plus methylamine plus pyridine. Often you would see these as reagents written above an arrow goes to ac same product here and then if I want to write a balanced equation I'm going to get pyridinium acetate as my byproduct. And all of these principles of reactivity then apply to things like alcohols as well. So if I take acetic anhydride and ethanol and again I'll just use this common shorthand for acetic anhydride plus ethanol just as we saw it reacted with water to give acetic acid, acetic anhydride reacts with ethanol to give ethyl acetate and again there are many ways you could write ethyl acetate. I'll just write it here OET plus acOH. All right so I think that gives us kind of an overview of the reactivity of the most reactive members of the family, the acid chlorides and anhydrides as well as the general properties of the family. We'll talk about the reaction of acid, catalyzed reaction with weak nucleophiles for esters and carboxylic acids as well as the effect of strong nucleophiles like bases on them next time.
This is the third quarter course in the organic chemistry series. Topics covered include: Fundamental concepts relating to carbon compounds with emphasis on structural theory and the nature of chemical bonding, stereochemistry, reaction mechanisms, and spectroscopic, physical, and chemical properties of the principal classes of carbon compounds. Index of Topics: 2:00-Carboxylic Acid Derivatives 5:54-Nomenclature 17:44-Acid Chlorides and Anhydrides 22:28-Boiling Points of Esters Versus Alkanes 26:22-Resonance Structures 28:59-Properties of Amides 35:12-IR Spectroscopy 43:51-Reaction of Acid Chloride and Anhydride in Water 45:05-Reaction of Esters and Amides in Water 51:58-NMR of Carbonyls 54:51-Carboxylic Acid Derivatives and Nucleophiles 58:08-Weakly Basic Nucleophiles 1:00:49-Balanced Equation Example 1:05:19-Student Question 1:09:28-Acid Chloride Reaction Example 1:14:11-Relative Reactivity of Carboxylic Acid Derivatives 1:17:44-Anhydride Reaction
10.5446/19411 (DOI)
Good morning. So today I'd like to finish our discussion of the reaction of aldehydes and ketones with various nucleophiles. And this is basically the content of Chapter 21. So we had started by talking about basic nucleophiles and reviewing how basic nucleophiles including very basic nucleophiles like alcohol nucleophiles and hydride reacted with aldehydes and ketones. Then we went on to other sorts of what I'd say were moderately basic nucleophiles, things like amines where the pK of the conjugate acid was on the order of 10 or 11. And now I'd like to conclude by talking about weakly basic nucleophiles, things that are basic formally like alcohols and water, but where the pKa of the conjugate acid is so strong that it's very acidic and then conversely your nucleophiles are very weakly basic. So just to give you an idea of the theme that I'm talking about, if you have some generic aldehyde or ketone like so, and maybe I'll draw in my lone pairs just to complete our structure, you can think of this aldehyde or ketone as kind of moderately electrophilic. In other words, nucleophiles like to attack the carbonyl group, but they need to be moderately good or very good nucleophiles. So I'll kind of label this as moderately electrophilic. Now just as water, just as an alcohol is a base, a weak base, so is the oxygen of a carbonyl group, and you can think of the oxygen of a carbonyl as being able to be protonated. And if you protonate the oxygen of this ketone or aldehyde, then the situation changes because at this point you have a full positive charge in the molecule. In other words, when we were thinking about aldehydes and ketones, we thought about it and recognized that oxygen is more electronegative than carbon, and so you could say, well, there's a very minor resonance structure with a full negative charge on oxygen and a full positive charge on carbon, but it's only a minor contributor. As we go to a protonated carbonyl, now we come up with a different situation because now you've got a full positive charge. The carbon atom becomes very electrophilic. One way we can think about this is to recognize that although often we'll just draw one resonance structure, there's a second resonance structure, and in this case our second resonance structure now doesn't have any negative charge in it unlike when we had to separate charges on the ketone, so it's even more of a contributor, and now you have the positive charge on carbon. It's still a minor resonance structure, but it's a bigger minor resonance structure, a greater contributor to the reactivity. So while we will maybe just draw one picture very often in the back of our head, we'll be keeping in mind that there is this component of reactivity embodied in the second resonance structure that makes this extra electrophilic. Often we will refer to this species, I don't think your textbook uses this name, but sometimes I will refer to it as an oxocarbenium ion. Carbonium ion is a fancy name or a more proper name for carbocation which you learned about in previous quarters, and oxocarbenium ion just tells us there's an oxygen substituent on there. Because the oxygen can donate in, you really don't have very much of the carbocation character if I had to put numbers on it, I'd say it's sort of 80, 20 in terms of the components, but nevertheless you can think of there being a little bit of this resonance structure in with the other. And so collectively those two structures will make up a picture of the molecule. All right, this structure here, this oxocarbenium ion, really helps embody a lot of the reactivity that we're going to see today. And in fact we're going to see reaction upon reaction in which this theme is continuously the same. So let's start by talking about a reaction that occurs and for the most part we don't even pay attention to it. If you have an aldehyde or a ketone, again I'm just going to write this sort of generically as R, C, O, R. And you have water present, let's say you dissolve it in water, dissolving acetone or dissolving acetaldehyde in water. You have an equilibrium that in many ways you don't see, in many ways it's invisible because if you distill your product out you never end up seeing this, you just get back your acetone or your acetaldehyde. But you have an equilibrium with this species here. Now instead of having a carbonyl group you have two hydroxy groups. Water has added to the carbonyl group. This species is called a hydrate, kind of an obvious thing to call something to which you've added water. Sometimes you'll hear it referred to as a geminoldiol. Gemini you might recall is the zodiac character for the twins. So geminole just means that there are two hydroxy groups on the same carbon, twinned hydroxy groups if you will. Now I'll just emphasize that this is not a stable molecule. With certain exceptions in other words it's not something that you can put into a bottle in pure form. So you have this equilibrium. In the presence of water the equilibrium will lie somewhere to the right or to the middle or to the left depending upon the exact nature of the carbonyl compound. I find it very instructive to take three examples. Your textbook uses the same examples and I think they really embody the idea here. So if you have acetone or indeed just about any ketone unless you have something truly exceptional, oops I should be drawing methyl groups here. If you have acetone or just about any ketone unless you have something truly exceptional I would say like a trifluoromethal group. That equilibrium lies far to the left. In other words when you dissolve acetone in water you have mostly, mostly, mostly acetone and just a little bit of the geminoldiol, just a little bit of the hydrate. The ratio at equilibrium is 98 to 0.2. For acid aldehyde and indeed for aldehydes in general that equilibrium lies more in the middle and so for acid aldehyde the equilibrium lies at 42 to 58. In other words almost one to one. Now I look at these two numbers and I find this really instructive to keep in my head. Not the details in the numbers but this gist that the acetone at equilibrium is way to the left, acid aldehyde is way in the middle. In a way what that's telling me, the way it's influencing my thinking is saying whoa that means that the carbonyl and acid aldehyde is like a thousand times like 10 to the third more electrophilic than the carbonyl and acetone. The carbonyl and acid aldehyde is much less happy being a carbonyl. It's much more willing to accept water as a nucleophile. The main reason for this is electronic, the main reason we talked about electron donation into the carbonyl group, the methyl groups donate electrons. You can think of this either just thinking methyl groups are electron donating or thinking about hyper conjugation thinking back to carbocation and remembering that resonance structure where you have the charges separated in your ketone and saying wait a second this means here we have methyl donating in. You can also think of it in a molecular orbital approach thinking about the orbitals of the CH groups overlapping with the pi star molecular orbital. Anyway it's about a thousand fold difference if we take away this remaining methyl group and there's only one aldehyde in this category, the aldehyde is formaldehyde. Formaldehyde really, really, really is unhappy in the aldehyde form. It prefers to exist as the geminal diol form and again the number from your textbook or indeed from anywhere else is.1 to 99.9. In other words now we've got another three orders of magnitude in the direction of favoring the hydrate. And if you want to put this in energetic terms remember for every order of magnitude in equilibrium at room temperature you have about 1.36 kilocalories per mole. So you can sort of think of this in an energy diagram where an aldehyde is like 5 kilocalories per mole more high in energy or more reactive than a ketone and formaldehyde is like another 5 kilocalories per mole just to give you sort of a ballpark on the numbers. All right at this point I want us to be able to look at how we get at the mechanism because this is going to become a big theme here at the mechanism of how we get from the aldehyde or from the ketone to the geminal diol. So what we're going to do and this is going to be an archetype for all the other mechanisms we see today. What I'm going to do is write out the acid catalyzed mechanism of addition of water. The main point here is that acetone is not on its own super electrophilic. In other words acetone and water is not on its own super nucleophilic. So what really speeds up this reaction what really makes it go is some acid. You can add some acid to the water if you do this in neutral water of course you should remember that even neutral water has a little bit of acid present because neutral water has 10 to the negative seventh molar hydronium ion. So you always have, unless you're in basic solution, you always have some small concentration of H3O plus and we'll just imagine adding a few drops of aqueous acid say aqueous HCl to the water. So the first step of this reaction is an equilibrium, Bronsted acid base equilibrium. For the moment at least I'm going to be good about writing curved arrows. Later on we may get a little faster or a little bit sloppier but we can envision electrons flowing from the lone pair on the acetone to one of the protons on the hydronium ion. They're all the same even though I may write one or the other and electrons flowing back on to the oxygen atom to give us protonated acetone plus H2O. So if you want to get a feeling for where this equilibrium lies we know what the pKa of hydronium ion is. The pKa of hydronium ion is the strongest acid you can have in water. pKa of hydronium ion is negative 1.7. Acetone's a bit less basic than water is. This equilibrium's going to lie a bit to the left. We're going to have protons going on and off. The pKa of protonated acetone is about negative 7. And in general my rule of thumb is if within about 10 orders of magnitude you have a difference of pKa protons can transfer back and forth. Our equilibrium's going to lie way to the left but you'll have a significant and a sufficiently appreciable concentration of protonated acetone for it to react. All right, let's move on to the next step because what happens in this step is we've bumped up the electrophilicity of the carbonyl by protonating it to make the oxacarbonyl ion. Now at this point water is good enough nucleophile to attack. So here's our protonated acetone. Here's our water. Electrons flow from the thing that has electrons to the thing that wants electrons from the nucleophile to the electrophile, they flow onto oxygen. Again we have an equilibrium. So finally protons come off, protons go on, you have 55 molar water, mass action basically dictates most of the time the protons are going to be on the water instead of on that hydroxy group. And so our final step in this mechanism, in this three step mechanism, is a proton transfer to water. And again it doesn't matter which proton I ride or which lone pair I use over here. So our final step of the equilibrium is that we have our geminal diol. And if you look collectively at these three steps you really see the embodiment of catalysis. In other words the catalyst is taking intimate part in the reaction. In the first step of the reaction the hydronium ion that's catalyzing this reaction is being consumed. And we know a catalyst isn't consumed or destroyed in a reaction which means in the last step of the reaction, it doesn't have to be the last step but in this case it is the last step, in the last step we're getting it back. In other words the entire balanced equation has been embodied in the addition of one molecule of water to the acetone. But that reaction has gone easier in the presence of a catalyst. I could also write a mechanism for this reaction that was base catalyzed and your textbook does it. Hydroxide is a good enough nucleophile to add to the carbonyl. You would envision hydroxide adding to the carbonyl to give an oxyanion, the oxyanion picking up a proton from water to give you back hydroxide. Now technically I could write an uncatalyzed mechanism. In the case of acetone that mechanism probably doesn't occur to a heck of a lot. In the case of formaldehyde which is remember about 10 kilocalories per mole, about let's say about six orders of magnitude more electrophilic, formaldehyde maybe you can have an uncatalyzed mechanism where water attacks the formaldehyde. But we're going to skip over that because basically that sort of is the exception and we really set up the theme for the class. The theme is basically a good nucleophile like hydroxide or amine or methyl group, methylithium or hydride can attack an unactivated carbonyl. A weak nucleophile like water or alcohol generally requires protonation of the carbonyl first. Now you add too much acid to the reaction, would the acid just protonate the OH group instead of just dehydrate the whole molecule? If you add too much acid would you protonate the OH group and dehydrate? Now we are going to see an interesting mix of chemistry coming up. And so right now we've learned two species that can be present. We've seen our acetone and we've seen our geminal diol that's not stable and we've seen a protonated species along the way that's two protonated species that are very high in energy. We said in acetone we have.2% when you dissolve acetone in water. You have.2% as the geminal diol. Later on we're going to see that there are other species present also in small amounts. So what you will see, I think it's in the coming chapter, it may be in the one following that will be this species here, the acetone enol. That will enter into our consideration. This too is unstable and higher in energy like the geminal diol. Now the practical implications of this. This is the stuff including a little bit of acetone enol. This is the stuff that's going to be present in a water solution of acetone or even with a little bit of acid. It won't take a lot of acid. You actually even just with the 10 to the negative 7 molar H3O plus in water are going to have all three of these present in equilibrium. Later on we're going to start to learn about new reactions like the aldol reaction and you're going to see that if you really cook the acetone or indeed if you cook other sorts of ketones and aldehydes together that they will start to react in carbon-carbon bond forming reactions that can be promoted either by base or by acid called the aldol reaction. It'll be one of the biggies that we're learning about soon and that will go either through the enol or in the case of base catalysis the conjugate base the enolate. In practice if you take acetone and expose it to certain types of acid long enough you will find species where two molecules of acetone have come together to form the aldol product or even under special conditions three molecules to form a benzene product, 1, 3, 5 trimethyl benzene called mesitaline and you can catch your TAs in their office hours to discuss how three molecules of acetone can come to mesitaline. All right, well there's something else that's very, very cool about this reaction and we know it's an equilibrium. But we know that there's a reverse reaction, equilibria have forward or reverse reactions. And I want to give you a big, big overarching principle here and I'll give it a fancy name in a second. The reverse reaction must go through the exact same pathway that the forward reaction went through under these conditions but in reverse. In other words in acid the reverse reaction which we're about to see in a second must go through the same mechanism. And there's a fancy name for this idea. It's the principle of microscopic reversibility. But like so many things that have fancy names they really come down to very, very simple ideas. So if we look at the reaction, I'll take the reaction we had here but indeed this is universal so we can take any reaction. Imagine a reaction energy diagram. You've seen these in earlier chapters of your textbook. In other words something where we have energy on the y-axis and we have some type of reaction coordinate. You can think of it as the progress of the reaction on the x-axis. Imagine a scenario in which we go from reactants to intermediate and on to product. And in this particular case I'll give us an example of a slightly uphill reaction just as our acetone forming the hydrate was slightly uphill. Now when we make a diagram for a reaction like this what we're really doing is diagramming out the lowest energy pathway for the reaction. In other words there may be other pathways for this reaction. There may be a pathway that's way, way, way up here but it's going to be higher in energy. And the basic premise for a reaction is that as we proceed from reactants to intermediates to products over our first transition state, over our second transition state if we have multiple transition states. We go on over a series of energy barriers and we're going to take the lowest energy path. Well if this is the lowest energy path in the forward direction then it's also going to be the lowest energy path in the reverse direction. If there were a hidden lower energy path they would have gone through that pathway because it would have taken less activation energy to go over those barriers. The molecules would have gone over that pathway in the forward reaction. And this principle, this idea of microscopic reversibility then tells us exactly what must be happening in the reverse reaction for even a reaction you haven't seen before. Now we're going to start with something pretty simple and it should be easy to intuit your way through this reaction even without any high-fancy, high-falutin-fancy principles of microscopic reversibility. Because all of this chemistry is just about protons going on, protons coming off, and the formation of oxo-carbenium ions. So let's imagine the reverse reaction at this point. And here's our geminal diol and we're going to get ourselves back to acetone. And the idea has to be the same as the forward reaction. In other words, the last step of the formation of the geminal diol involved a loss of a proton from the geminal diol. So the first step of the reverse reaction has to be putting a proton onto the geminal diol. So here's our H3O plus and again it's going to be acid catalyzed. So we put a proton onto the geminal diol, electrons flow from the lone pair to the proton, from the hydrogen, the bond to the hydrogen, back on to the oxygen. And for now at least I'm going to be a good person and write everything out step by step. Later on I'll get a little faster, a little bit quicker and expect you to follow along. But in our next step of the mechanism now you can just envision the water getting pushed out by a lone pair of electrons. And so we push in, push out and we get protonated acetone. It doesn't particularly matter whether I have the proton pointing off to the left or to the right. In the final step of the mechanism we're in water. There's lots of water protons go on, protons come off just about everything with a lone pair. I'll take the long way around here, pull off my proton. And we get our hydronium ion back. And so the mechanism of the reverse reaction looks identical to the mechanism of the forward reaction but in reverse. Some students might wonder why don't we just draw water leaving here and we could draw a carbocation and the answer is there's no difference. I've written one resonance form, I've written the more important resonance form. If you were to write it one way in the forward reaction I'd probably write it the same way in the reverse reaction but in the back of our head just as I said at the start of the lecture in the back of our head is the idea that embodied in this structure are two different structures, two different species, two different resonance forms I should say, two different pictures of the same thing. Questions or questions at this point? Great question. Does the reversibility. It's applying to the same mechanism in the forward reaction and the reverse apply to other reactions as well. Absolutely. And so we saw cyanohydrin formation on Tuesday a week ago and we didn't talk about cyanohydrin decomposition but the base catalyzed decomposition of cyanohydrin back to aldehyde. Psyonides and cyanide goes by the exact same mechanism in reverse and in discussion section this week you'll be seeing that reaction. We're also going to be seeing some examples in the homework of acetal decomposition and other sorts of reactions and yep that idea applies and it doesn't apply just because I said it. It applies from this fundamental principle that if the lowest energy path in one direction is indeed the lowest energy path, that path is of course the same in the reverse direction so yeah it's universal. If you were to change the conditions and say alright now imagine I threw in a handful of sodium hydroxide into my acetone solution and ask how does my geminal diol decompose now up? We've just changed the conditions then it's going to be a base catalyzed mechanism then it's going to be pulling a proton off getting an oxyanion kicking out hydroxide. But as long as the conditions are the same as long as you have the same species present the same conditions of pH, yep same forward and reverse. Other questions? Good question. Do you need that heat or group heat in order to do reaction one way or the other? You know this is an interesting reaction. So this reaction will go at room temperature, it'll go at higher temperature, you're not going to shift that equilibrium. There's essentially nothing you can do to isolate a bottle of acetone geminal diol or a bottle of acetaldehyde geminal diol. They are that equilibrium essentially give or take a little bit stays right where it is regardless of temperature. So yep no way you can drive that. Now I'm going to now introduce us to something where instead of forming an unstable species, a species that you can't isolate or put in a bottle, we're going to see the formation of a stable species, an acetal. And so that's where we're going to go next. And we will invoke Le Chatelier's principle to drive that reaction. So alcohols in a way are the cousin of water. They're cousin in the sense that they are related. They both are hydroxylic compounds, they both have similar pKa's and pKa's of the conjugate acids and they both can give up a proton. The big difference with water is it has a second proton to give up. So that means there are going to be many reactions that look a heck of a lot alike. So let's take our friend acetone here and let's imagine instead of treating our acetone with water basically dissolving your acetone in water, we treat it with, I'll write this as H plus for now. And by H plus I mean a strong acid catalyst and some methanol. We specifically don't want H3O plus because we're going to be seeing a reaction in which water is the product of reaction and we want to drive that reaction by getting rid of the water so you don't want to do this reaction in aqueous acid. And the product of the reaction is what's called an acetal. This particular one is called acetone dimethylacetal and the acetal unlike the geminal diol is stable. The other product of reaction is water. So you want to go ahead and drive this reaction by getting rid of the water which is why I said we want to use anything but aqueous acid for the reaction. The reaction is going to proceed, so this in a way is sort of a cousin of our geminal diol. It's a cousin in the sense that it has a methoxy group and a methoxy group instead of a hydroxy group and a hydroxy group. And the reaction is going to go by way of an intermediate that is sort of a sister of the geminal diol and that's by way of a hemiasatal. Hemi means half and so a hemiasatal means a half acetal. In other words it's something where you have one group that's an alkoxy group and one group that's a hydroxy group. A hemiasatal in general is unstable. And I'm going to say right now that at the end of today's lecture and perhaps even in your backpacks right now, we will see stable hemiasatals, those circumstances can make a special condition. And we're going to see how this reaction goes. Now by the way, there's an older system of nomenclature you may see and it may have even popped up in the sapling course. Sometimes you will see the term ketal used. It's fallen out of usage but you'll sometimes see the term ketal used. Ketal is an acetal of a ketone. So sometimes you'll see this referred to as acetone dimethyl ketal but these days acetal is preferred. And similarly sometimes you'll see this referred to as a hemiketal. I'm going to put both of these terms in parentheses so we don't worry about them but if you hear them either cross my lips in the course of our discussions or you see them in any of where you read, that's what you're going to see. Older textbooks tend to use them and as I said they may not have scrubbed it out of sapling. All right. So before we move on to the mechanism, let's take a moment to talk about the acid. So the strongest acid you can have in water is H3O+. In other words, if I dissolve HCl in water, I don't have HCl in water. It protonates the water. If I dissolve sulfuric acid in water similarly, it's nice to have in mind some idea of what constitutes a strong acid. In general a strong acid is anything that's got a pKa that's lower than that of the solvent that you're thinking of. So HCl pKa of negative 7, H2SO4 sulfuric acid pKa of I'll just write negative 3 underneath. One popular one that's used. So HCl dissolves in methanol, just great. HCl doesn't dissolve in say benzene so well. It's not so soluble in say a solvent like benzene which is good because we learned that benzene is a good solvent for removing water. We learned about azeotropic distillation which is often important in driving reactions like acetyl formation that are equilibria. So another popular acid that organic chemists like to use is peritallium sulfonic acid. Peritallium sulfonic acid looks a lot like sulfuric acid, right? Sulfuric acid is H2SO4, H-O-S-O-H-O-S-O-O-H. And peritallium sulfonic acid just has a benzene. The benzene is actually electron withdrawing so the pKa of toxic acid is about, I'll just write this here, PTSDH is how you usually see it abbreviated which is a fancy name for peritallium sulfonic acid. Anyway pKa of negative 7, again a very strong acid. So if we imagine for a moment say taking methanol and dissolving an acid like HCl or H2SO4 or H2SO4 or toxic acid in it, you have an equilibrium but that equilibrium is going to lie way to the right, you're going to protonate your methanol. Protonated methanol is the strongest species that can exist in methanol, the strongest acidic species that can exist in methanol and of course you'll have chloride. This equilibrium lies to the right, you can think of methanol as being very much like water, in other words the pKa of protonated methanol is just about the same as the pKa of the hydronium ion, it's just a hair lower, it's negative 2 if you want to be exact. In general you can think of an alcohol or an ether having a pKa of the conjugate acid of about negative 2 or negative 3, the alcohol group's a little bit electron donating. So when we imagine acetal formation and when I imagine this reaction here it would be an acid like HCl or like H2SO4 dissolved in methanol but I'd think of my acid and the mechanism probably think of it as protonated methanol because that's going to be the strongest species that can occur there. So I want to take us to the mechanism of acetone dimethylacetal formation and the mechanism is going to be identical to the mechanism we saw for hydrate formation but it's going to occur twice. Now it's identical in the way that you have to think a little bit broadly in that you have to think that well methanol can react analogously to water, protonated methanol can react analogously to a hydronium ion and then everything is the same. Oxocarbenium ion formation is the same, everything else is the same except you're going to have methyl groups present. What do I mean? Because you don't actually have to know anything to write this. All you have to do is be able to think your way through. All right. We've got our acetone here and we have our protonated methanol. In acid protons go on and off just about anything with a lone pair of electrons. We flow our electrons from our carbonyl from our weak Lewis base, our very weak I'm sorry Bronsted base to the Bronsted acid of the protonated methanol just as we had done with protonation from the hydronium ion. Now you end up with the self-same oxocarbenium ion we've seen before, the self-same protonated acetone so we know that we can have an attack occur. I'm going to go a little bit, I think I'll go a little bit faster here. In the next step, and I'll skip curved arrows because by this point you should be able to do this. In the next step our methanol attacks and whoops we still have a proton on it. I don't want to get that fast. So in the next step our methanol attacks and then in our next step a molecule of methanol comes along and pulls off the proton and again I'm going to skip the curved arrows. You can imagine electrons flowing from the lone pair to the hydrogen electrons flowing back on to the oxygen. And so at that point we have catalyzed the formation of the hemiasatel intermediate. And so far, and I'll go ahead and write this out here, you know our abbreviated mechanism. And so far everything is identical to what we wrote in acetal formation or in hydrate formation. All right, I want to take us on at this point to the formation of our acetal from our hemiasatel to our acetal. And everything is going to be identical to what we've seen in acid. Protons go on, protons come off, everything with a lone pair of electrons. So here we are at our hemiasatel. Here's our protonated methanol. And I'll go through a little bit more slowly, a little bit more carefully now. We'll put a proton onto the hydroxy group. Electrons flow from the lone pair to the proton. Electrons flow from the proton back on to the oxygen atom. Now, in the next step, we're going to kick out a water molecule to form another oxacarbene ion. Electrons flow from the oxygen, push down, push out the water molecule. It matters which lone pair of electrons I use, they're both the same. Electrons flow back on to the OH group. We push out a water molecule, we go through the oxacarbene ion. Here's our water byproduct of reaction. Now another molecule of methanol attacks, again electrons flow from the species with electrons to the species that wants electrons. We push up electrons onto the oxygen, doesn't matter which way I push them to the left or to the right as long as they go from the pi bond onto the oxygen. In our final step now we have lots and lots of methanol protons go on, protons come off and we recover our protonated methanol catalyst. Let's go back on to the oxygen. We get our protonated methanol. Beautiful question. One great question, why doesn't methanol attack this intermediate and kick out water in an SN2 reaction? Anyone? So okay, so there are two sort of questions here. So you've just mentioned carbocation, I'm going to hold that for a second because I want to come back to that. To weak of a nucleophile, okay we're getting on the right track. What do we know about SN2 reactions? It's a tertiary carbon and in general we don't have SN2 displacement at a tertiary carbon and indeed only very good, very few nucleophiles even do SN2 well at a secondary center. So yes, it's too weak to be at a secondary center, it's a tertiary center, we essentially never see SN2 at a tertiary and you mentioned carbocation and the reaction is indeed an SN1 reaction. Because if you think about it, remember the leaving of water as a leaving group to form this species, this is just a carbocation, it's just the other resonance structure, they're one and the same. The oxocarbenium ion is both the carbocation like resonance structure and this resonance structure. So the substitution that we see here is indeed an SN1 type reaction and indeed not an SN2 reaction. Other questions, great questions, exactly what you should be thinking at this point. Is it possible for the acid to actually prognate the mesoxy group instead of the like alcohol group? Ah, another question, exactly. Have I planted people in the audience to ask, these are the questions that all of you should be asking, I'm really happy to be hearing these because these are the questions I hear every time from beginning students on this. So they should be going through your mind and I am very happy to have people brave enough to ask them. Your question is why doesn't the prognate hear and indeed it does and that takes us on the path back. So as we go over a pathway from reactants to intermediates to products in general we go and if the reaction is downhill eventually we end up there. And so indeed that occurs along the reverse pathway and if you're trying to make an acid to the towel and synthesize it you drive that reaction as best as possible by kicking out the water. In some cases it's just by use of a large excess of methanol, the Châtelier's principle. In some cases we really push it with deemstark distillation to drive the water out. It doesn't work so well with methanol because of the boiling point of methanol, it works with other alcohols. In some cases we add a compound that reacts with the water, for example methylpropenol ether or trimethyl orthoformate to react irreversibly with the water and suck it up. And in some cases one adds a drying agent, a dehydrating agent like molecular sieves. Alright, I want to take us on in a couple of directions before we finish up our discussion of acetals, hemiasatals and hydrates. And one of the things I want to take us on is the reverse reaction. So as I said all of these reactions are equilibria, all of these reactions can be driven by the use of excess methanol and in turn all of these reactions can be driven in the reverse reaction. So if we go ahead and carry out hydrolysis with lots and lots of water we can break down our acetal. In general that's going to mean just changing our solvent and keeping our acid. So let's take our acetone dimethylacetal and I think at this point I'm going to avoid writing the, alright I will write the methyl groups one last time here but I expect you to be able to understand them. And so imagine a source of acid in water, aqueous HCl, aqueous sulfuric acid and lots and lots of water. Our acetal breaks down, whoops, back to acetone and if I feel in the mood to balance my equation two molecules of methanol. Now at this point I expect you to be able to think your way through the mechanism. It's a good exercise, you should do it yourself. I'm going to give you the gist of it in shorthand. The gist of the mechanism involves protonation, I'm just going to draw out a series of intermediates here maybe with a few lone pairs to help us keep track of things. The gist of the reverse mechanism is the exact reverse. First step is the same as the last step. First step, protonate on oxygen. Next step, kick out methanol. This intermediate is our oxacarbene ion. Next step is attack of water. Next step is remove a proton to form our unstable geminal, our unstable Hemiacetal. Next step is reprotonate on the methanol. Protons come off. These go on, all different places, all different lone pairs. Next step is we push out the methanol. The next step is our penultimate intermediate, our protonated acetone that loses a proton. There, there in a nutshell is the embodiment of the entire mechanism of acetal hydrolysis in reverse. This is the only mechanism you're really going to see in all of this acid-catalyzed chemistry with slightly different wrinkles. Intramolecular, intermolecular, but no huge differences. Question? Should we get 2CH3OH2 as a result or H2O acid? Ah, okay, good question. Should we get protonated methanol? We're in a huge sea of water. We have 55 molar H2O, and we've dissolved up a molar, half a molar of our compound. Most of the H3O, most of the protons are going to be on water. All right, let's take a look at a few more common examples and a little bit of synthetic chemistry. And your book does, your textbook does a nice job with this. So I think I'll conclude by borrowing a few examples that your textbook invoked. So we've already learned that at certain points in synthesis, it's necessary to hide a group, to render one group so it can't react. We saw, for example, that in carrying out certain reactions we would want to hide an alcohol so the OH group isn't available by protecting it as a TBDMS ether, protecting it as a silo ether. Acetals are often used to hide a ketone or aldehyde functionality. So for example, and this comes straight from your textbook because I think it's a good relevant example, for example, your textbook poses the question, how could we selectively take this ketoester and reduce it to a keto alcohol? And obviously you see the conundrum. You look at this reaction and immediately you say, well, okay, I know there are plenty of reducing agents that I can use to blast down an ester. Basically we've learned in the course lithium aluminum hydride nukes any carbonyl down to an alcohol. And yet we recognize the problem that if we treat this compound with a powerful reducing agent like lithium aluminum hydride, we're also going to reduce the other carbonyl. We're also going to reduce the ketone group. And so the solution to this is to go ahead and to take this compound, this ketoester, and hide the ketone group. And you can do so selectively by making an acetal out of the ketone group. And so if you envision often to make, particularly for acetals of ketones, particularly for the ones I referred to as ketals, because ketones are much less reactive than aldehydes, often you have to work really hard to make that reaction go. And one way to do that, to push the reaction, is to make it go intramolecule, to have two alcohol groups in the same molecule. So ethylene glycol, 1,2-dihydroxyethane, and propylene glycol, 1,3- or 1,3-propane diol and 1,2-ethane diol are often used as protecting groups for ketones. And so if one treats with catalytic-tosic acid, which as I said is often used in organic solvents, and with deenstarch distillation to drive out water, often in benzene or toluene, if one treats the ketone and ethylene glycol with catalytic acid, you can selectively protect, you can hide the ketone as the acetal. And now you can envision a three-step process where your first step is to protect, your second step is to reduce an lithium aluminum hydride followed by workup with water, and I'll say or H3O plus, and I'm going to come back and comment. You know that I like to work up my lithium aluminum hydride reactions with acid, and usually that just means adding a little acid to the reaction. And if you just add a little bit of acid without really cooking things up, without heating it, in general your ketone isn't going to break up. And generally you end up to really break down your ketone, to break down your acetone. In general you need water and acid and a little bit of heat. I'm not at this point you're learning going to get bent out of shape over these differences here. You should just realize if you go into the laboratory, if you pour a little bit of dilute acid in at this point, you're probably not going to hydralize your ketone. You can then in your separatory funnel isolate it, dry it over magsulfate. If you then take it in water, boil it up with some aqueous HCl, higher temperatures, longer reaction time, and so forth. You will de-protect, you will remove the protecting roof. And I'll put in parenthesis of course, ethylene glycol, although again your organic chemist is probably going to forget about that very quickly. So that's a nice example of where acetals are very useful in synthesis and where they can be used to achieve a goal selectively, which as I said is really one of the big things about organic chemistry. It's that I want to make this molecule, not that molecule. I don't want to make a mixture of molecules. I don't want to make a mixture of diastereomers. And in some cases I don't want to make a mixture of enantiomers. I want a single enantiomer. And this is all what these tools are about. All right, I kind of dropped the hint that intramolecularity ends up giving you a special relationship. Remember, water is 55 molar. In other words, when a reaction occurs with water, say the formation of a hydrate, like we saw in acid aldehyde, where the equilibrium lay right in the middle, essentially at 1 to 1, at 42 to 58. That equilibrium lies in the middle because in 55 molar water there's only a certain amount of water present to push in a hydroxy group. But if you have the hydroxy group tied in the molecule, you can have that carbonyl group seeing an even higher concentration of water. In other words, the effective molarity instead of being 55 molar water can be 100 or a 30 or a 1,000 or 10,000 where that hydroxy group is just staring the carbonyl group in the face. And your textbook gives two nice examples that are relevant to the chemistry of carbohydrates, which is where I will finally conclude. One of these is a hydroxy pentanol derivative and the other is a hydroxy butanol derivative. And both of these compounds exist in equilibria with their geminal diol, with their hemiazital. And those equilibria now lie toward the right, and so I guess I'll make my arrow a little bit longer. In the former case, you have a hydroxy tetrahydropyran type of structure where now the hydroxy group has cyclized into the carbonyl to give a geminal dot, to give a hemiazital. And in the other case, you have a hydroxy furan structure. And now because that hydroxy group is staring it in the face, your equilibrium, as I said, lies to the right, it's 6 to 94 in the case of the former, and it's 11 to 89 in the case of the latter. In other words, if it were just water, if it were just water or just even methanol, you'd have halfway roughly for the equilibrium. You'd have half of the geminal diol, half of the aldehyde, or if it were methanol, you'd have half of the hemiazital, half of the aldehyde. But by the time you have the hydroxy group in the molecule and it can form a 5 or a 6-membered ring, then you have the much higher effective molarity of the hydroxy group staring the carbonyl in the face. The equilibrium lies to the right. Six-membered rings are good because they're unstrained. Five-membered rings are good because they're smaller, but you get a little bit of ring strain from eclipsing. Remember the ring strain and cyclohexane is effectively zero. The ring strain and cyclopentane is about 6 kilocalories per mole. So higher effective molarity of hydroxy group in the second case in the hydroxy butanol, but some ring strain there. All right, now where this really ends up coming into play and why I said you probably have this sitting in your backpack and certainly you have this sitting in your bodies is the sugar molecules. And if we look at a molecule like glucose, and I'm going to draw it one way, which I think is a little bit closer to what we're seeing here and then I'll draw it another way. So this molecule with all of these hydroxy groups on it is glucose or more specifically what's called beta-D glucose. What it tells us about the stereochemistry at this position, the OH group is pointing out at us, D tells us about the stereochemistry up at that position. But the main thing is this is a sugar that should be familiar to you. If you're drinking unsweet, if you're drinking what do they call high fructose corn syrup, you've got glucose in there. If you're eating sucrose, it's part of the molecule, but if you're eating high fructose corn sugar, it's been broken open. If you look at candy where glucose has been added, it's there as well. Now if you notice here, amidst all of these hydroxy groups is a carbon that is an acetal. This carbon is an aldehyde hiding mask just as our carbon is over here. I haven't drawn in the hydrogen, but of course there's a hydrogen here and there's a hydrogen here, which means just as our hydroxy pentanol exists in equilibrium with the cyclic form, our hydroxybutanol, our glucose exists in equilibrium and that equilibrium is way, way, way in favor of the cyclic form, even more than 94 to 6. It's like 99.99 something. And yet there is a teeny tiny amount of the aldehyde form and I'll draw in the hydrogen here just because to make it a little clear like so. And I guess to keep it consistent, I will draw in the CH2OH. And so particularly with the presence of a little bit of acid to catalyze the reaction, your equilibrium will go back and forth between the closed form and the open form. In this case, there are a couple of reasons why this equilibrium is further toward the cyclic form. One of them is conformational. The hydroxy is just perfectly organized, the molecule to form a nice stable chair cyclohexane. You'll often see beta-D glucose written in its chair conformation like so. But all of the hydroxy groups are equatorial on this ring. All of the hydroxy groups are equatorial. The other reason is electronic. Your hydroxy groups, particularly the alpha hydroxy group, is inductively electron withdrawing. It pulls electron density away from the carbonyl group. And so it makes the carbonyl of glucose even more electrophilic than other aldehyde carbonyls. It's even more prone to react. And I think this is where I'm going to wrap up our chemistry. And you'll get a very nice example of some sugar chemistry in the latter homework problems from Smith. And I urge you to take a look at them. It's a very nice exercise. All right. We will pick up with our next chapter on Thursday.
This is the third quarter course in the organic chemistry series. Topics covered include: Fundamental concepts relating to carbon compounds with emphasis on structural theory and the nature of chemical bonding, stereochemistry, reaction mechanisms, and spectroscopic, physical, and chemical properties of the principal classes of carbon compounds. Index of Topics: 1:19-Electrophilicity of Aldehydes and Ketones 5:37-Hydrates 12:17-Acid-Catalyzed Addition of Water to Acetone 21:29-Acetone Enol Example 24:01-Reverse Reaction 25:31-Energy Diagram 29:28-Reverse Reaction Mechanism 36:38-Acid-Catalyzed Acetal Formation 40:00-Hemiacetal 43:01-Strong Acid 47:23-Hemiacetal Formation Mechanism 50:52-Hemiacetal to Acetal Mechanism 1:00:52-Acid-Catalyzed Acetal Hydrolysis 1:06:12-Protecting Groups 1:12:15-Cyclic Hemiacetal
10.5446/19410 (DOI)
All right, so I am thinking about where we're going in the course here. And I'm starting to put together the discussion section problems for next week as well as thinking about what's important. And there are a whole bunch of cool reaction mechanisms involving the chemistry of carbonyl compounds. And these are really on my mind and I think we're going to be working on them in discussion. And I'm going to want you to participate a little more in discussion. We're going to get up to the blackboard and put our thoughts and really work together on thinking about these problems. All right, so we're in the midst of the chemistry of ketones and aldehydes and we did a little bit of basic introduction of their chemistry last time. We introduced how we name them. We introduced some ideas about reactivity at the carbonyl group. We talked a little bit about their spectroscopy. And then I introduced the idea of how I like to think about reactions of carbonyl compounds with nucleophiles. And I like to think about there being sort of three types of nucleophiles, broad types, the very strongly basic nucleophiles like hydride and alko groups, things who the PKA groups for which the PKA of their conjugate acid is a very large number. In other words, things that although the conjugate acids we call a very weak acid would not to any measurable extent dissociate in water. An alkane like methane doesn't dissociate to methyl anion even though it is technically a very, very weak acid. If you work out an equilibrium for a mole of a compound with PKA of 50 in water and try to figure out the concentration of the conjugate base and a proton, the concentration is less than one molecule, well under one molecule. So basically things like methane and hydrogen don't dissociate in water. We then moved on to a category that I roughly grouped as moderately basic nucleophiles and that fits a lot of things where you think of their conjugate acids as weak acids. Hydrogen cyanide for example, PKA 9.4 dissociates in water a little bit. So you have cyanide anion in water which actually acts as the nucleophile. Nucleophiles in water are sort of at the lower edge of that category as very weakly basic nucleophiles. And then finally I mentioned very weak nucleophiles, things where the conjugate acid really is a strong acid, things like an alcohol where the conjugate acid ROH2 plus is a strong acid. We're sort of off in the negative numbers there. And in our third lecture we'll be talking about that class but here I want to continue our discussion of the category of moderately basic nucleophiles. And I just want to lay two examples from the previous lecture to talk about what they taught us because we're going to go on now to looking at the reaction of amines with carbonyl compounds with ketones and aldehydes. This fall in that moderately basic category the PKA of the conjugate acid, the PKA of an ammonium ion is about 10 or 11. And we saw what set the stage for these reactions in two different reactions. We saw the reaction of hydrogen cyanide with a generic ketone or aldehyde. I'm not meaning this to mean acetone per se but any sort of ketone or aldehyde. And the reaction was to form a cyanohydrin. And then the other reaction we talked about last time was the reaction of a vitigre agent. And again I'll just sort of write a semi-generic vitigre agent, I'll write RCH2 PPH3 double bonded. And remember we talked about there being two resonance structures of this. So we talked about there being a second resonance structure of the vitigre agent that had an illid form, in other words had a separated charge. And only because phosphorus can take an expanded octet, only because phosphorus can take 10 electrons around it, could we write this other resonance form here. And then the product of that, again generic ketone or aldehyde with this sort of semi-generic vitigre agent is an alkene. Now what these reactions set the stage for is the idea that nucleophiles like to add to the carbonyl group. We see that hydrogen cyanide we can think of as dissociating to H plus and CN minus or in water H3O plus and CN minus. CN minus adding to the carbonyl, the resulting alkoxide anion then picking up a proton from another molecule of hydrogen cyanide or from hydronium ion. In the case of the vitigre action the start of this theme was very similar. In other words we start our mechanism by electrons flowing from the nucleophilic species, in this case the basic carbon, the carbene ion like carbon to the oxygen. But then at the same time electrons flow on to the phosphorus. Now from the oxygen. Now phosphorus really, really loves oxygen and here's where the theme for today's lecture gets set in. Phosphorus binds on to the oxygen and then pulls off the oxygen and so the oxygen is now taken out of the molecule. And this is the same theme although not with the pull from the same atom, not with the pull from phosphorus that we're going to be seeing in the reaction of amine nucleophiles with ketones and aldehydes. So by way of diving into things let me start with a generic reaction here. If we have some compound organic chemists often use R groups to indicate unspecified alkyl groups or sometimes even alcohol and hydrogen. So I'll say if we have some ketone or aldehyde this is a very general reaction. And we treat it with a primary amine and I'll use double prime to indicate just that we're talking about some R group here not necessarily the same R group. A primary amine of course is an amine with one alcohol group on the nitrogen. Remember it's a little confusing in alcohols of course the only alcohols are alcohols with one R group on the oxygen. So a primary alcohol is an alcohol where you have an RCH2 connected to the alcohol where you have only one other carbon. A secondary alcohol is an alcohol where you have two carbons connected to that carbon like isopropanol and a tertiary alcohol is an alcohol where you have three carbons connected to that carbon like tertiary butanol. But in the case of amines because you can have multiple R groups on the nitrogen we call a primary amine and amine with one alcohol group on nitrogen. We call a compound with two alcohol groups on nitrogen a secondary amine and a compound and amine with three alcohol groups on nitrogen a tertiary amine. So with a primary amine and a ketone or aldehyde they react. The textbook indicates catalytic acid and we will invoke this in the mechanism and I'm going to write a little caveat on this sometimes because ketones and amines can react without the presence of catalytic acid. Remember a catalyst ends up facilitating the pathway but that doesn't necessarily mean the reaction can't occur without it plus there are various sources of H plus. As you go through the reaction you're going to generate protic species. So the product of this reaction is an amine where the nitrogens R group is derived from the primary amine and the amine has this structure. Again, organic chemists are terrible about writing balanced equations but the other product of the reaction is water and that actually gets important in driving the reaction. So I'll write out the name for this. I'll just say an amine and maybe I'll give you a concrete example of this reaction. So for example if I take benzaldehyde, remember benzaldehyde is one of those aldehydes whose common name is so widely used that we would probably never call it anything else and let's take benzalamine as our other partner in this reaction. Usually it takes some heat to drive this chemistry but really what this reaction takes, the reaction is an equilibrium. Other words and I'll write it later as such, right now I'm writing this more in a synthetic fashion but the equilibrium, water and the amine exist in equilibrium with the ketone or aldehyde and the primary amine. And the real problem is if you're trying to make this chemistry go and remember chemists often try to control their chemistry and drive the reaction to a product. Other words get rid of all the starting material and form as much product as they can as possible. You do this in your chem lab class when you're monitoring by TLC and you're saying as my reaction done yet, is it done yet? Can I work it up? Have I used up all my reactants? And the problem in an equilibrium is that unless you employ Le Chatelier's principle, unless you push it, you will often end up with your reaction never quote being done because done is in the middle. So the way that chemists often drive this reaction is by doing it in a solvent that water doesn't dissolve in such as benzene, sometimes they use toluene, at reflux. Reflux means boiling. Now benzene and toluene have a very special property. Benzene and water toluene and water co-distilled to form what's called an aziotrope. In other words, the benzene drives the water up in the vapor phase. And if you go ahead and then have a receiving vessel, water is heavier than benzene. If you have a little receiving vessel under the distillation apparatus underneath the condenser, the water and benzene drip back in. But once the receiving vessel fills up with benzene, the benzene keeps sluicing back into the reaction flask and continuing to distill while the water goes to the bottom. This apparatus is called the Dean Stark Trap after its inventors. And by carrying out the reaction under these conditions, you can get your imine. Your textbook writes, quote, mild acid. This particular reaction proceeds just fine without an acid catalyst, although an acid catalyst will make it go faster. And so here's our imine product. And again, at least for now, I'll be good about balancing my equation and writing water. And sometimes you'll hear an imine derived from an aldehyde referred to as an aldimine. So I'll write that out. And sometimes you'll hear of an imine derived from a ketone as being referred to as a ket imine. Let me give you an example of a ketimine forming. The examples I've chosen are real examples from real experiments just to show you typical conditions that one employs for this chemistry. So the example I'll give you is methylcyclohexanone. And I'll give you phenylethylamine. It turns out that there's a lot of really beautiful chemistry of imines and enimines that we're not going to talk extensively about today, and your textbook doesn't present extensively. But they can be really important in carbon-carbon bond forming reactions. And I told you early on, and we've talked about synthesis, how important it is to build up molecules, build up greater degrees of complexity. This is how we make new medicines, for example. This is how you make chemically synthesized steroids and so forth and drugs. And so if one uses a chiral amine, and I'm not going to draw a particular enantiomer here, one can go ahead and form a valuable amine from this. Turns out, imines have stereochemistry to them about the carbon-nitrogen double bond, and not surprisingly, if you have a choice, you want to form the least sterically hindered product. Amine formation is thermodynamic. I guess I was writing pH for benzene here, so I will continue to do so. Amine formation is thermodynamic, and so you form the thermodynamic less stable compound. And here the experimental conditions are very similar. The reaction's done in toluene. Benzene boils at a little bit lower temperature than toluene. Amine boils at about 110 benzene at about 80 degrees, and refluxing in toluene, again with a Dean Stark apparatus, drives the reaction. And of course you get water as a byproduct of the reaction, which you collect in the Dean Stark's trap. If I had my choice personally between using benzene or toluene, I prefer to use toluene. Benzene is carcinogenic, and so in general, people don't like to work with it as much. It's not really carcinogenic. I mean, it is really carcinogenic. It's not super carcinogenic. We use it in an experiment in the Chem 160 lab course that I use. You just work with it carefully like you do when you work with other toxic chemicals. So that's the question. Yeah, is that NH2 and 40? Thank you. Yes, it is the primary amine NH2. Thank you very much. I have another question. How exactly does the S replace the odd? And once again, thank you. You have led in to the next point. So let's talk about the mechanism of immean formation. And so now we come to the stage that's been set by the Vittig reaction. We come to the stage that's been set by cyanohydrin formation and by the Vittig reaction, where nucleophiles like to add to the carbonyl compound, the carbonyl of the ketone or aldehyde is electrophilic. And the oxygen can, under the right circumstances, go away. It can leave. And obviously, it becomes water because I've written water several times. So let's see how that happens. So as I said, the reaction is catalyzed by acid. There's an intermediate that forms halfway along the way called the hemiaminal or an amino carbonyl, depending on whether you prefer a more common name or the name the book prefers for it. And that intermediate is slow to break down. That's where the water is about to leave the reaction. Acid catalyzes that step. It makes it occur more quickly. So what I'm going to write out for you is a mechanism of acid catalyzed imine formation. And for the most part, we can think our way through the mechanism. So we know that amine is reasonably nucleophilic. I told you that pKa is 10 or 11 for the conjugate acid. In other words, it is nucleophilic enough to attack a carbonyl compound. So here's that generic ketone or aldehyde that I started with. And I'm going to be a good person and try to remember to write in all of my charges, all of my lone pairs of electrons, and to use curved arrows to always show the flow of electrons during this reaction. So here's our amine. The amine has electrons. The carbonyl wants electrons. Electrons can flow from the nucleophile to the electrophile. Of course, we can't have 10 electrons around oxygen. So just as in cyanohydrin formation, electrons flow up onto oxygen to give an oxyanion species. All of these steps, and indeed all of imine formation, is in equilibrium. In other words, every step that can occur forward can occur in reverse. In fact, under identical conditions, if you go through the reverse process, the hydrolysis of imines, it has to occur through the exact same pathway that the imine formation occurs, because that's the lowest energy pathway. So we add our amine to the carbonyl, and now we have a species where we have a negative charge and a positive charge, and a proton is going to get transferred. I'm going to be a little bit vague and loose with how the proton transfer occurs. You could think of it as occurring in one step. Your textbook implies this, and I think for where you're at now in terms of your thinking, and particularly for carrying out this reaction in the presence of, let me get my r's and r's primes here. I think for carrying out this reaction in benzene or in toluene, I think it's reasonable to think of it that way. So I'll write this as proton transfer. I think you could also think of it as occurring with, remember, you have some catalytic acid, of course, you have other molecules around, you have water around eventually. I think you could also think of it as occurring by picking up a proton and then losing a proton. You don't really have water in this reaction or in large quantities, but you may have a little bit of catalytic acid. Anyway, however you wish to think about this, I think is fine whether you think about this oxygen pulling off a proton or you think about BH plus some acid that's present transferring a proton and then pulling off a proton or even the reverse I think is fine. In other words, first pulling off a proton with a base like amine and then putting on a proton. So I will write all of these ways that I think are valid for thinking about this. So at this point what we have done is we have gotten to a species that looks like it should be a neutral molecule. This species is an intermediate. It's not in general a stable species. In general you can't put this species in a bottle. We call this a hemiaminal. Hemi means half. You're going to see or if you've completed the chapter reading you'll see the term hemiasatel and hemiketal. Hemiaminal means half of an aminal. An aminal is another unstable species in which you have two nitrogens on one oxygen. A hemiaminal is one in which you have one on the nitrogen, one nitrogen and one OH group. The textbook also refers to this as an aminocarbonol. Carbonol is a very old term for alcohol. So aminocarbonol is a fancy way of saying an aminocalcohol which is a fancy way of saying a molecule that has an aminogroup and an alcohol group that happened to be attached to the same carbon. Anyway, in general this is not a stable intermediate. I'm going to write in parenthesis unstable. In other words it's going to break down and that's going to be the remaining part of our mechanism. So that's your question. Yeah, since this reaction is acetyl catalyzed wouldn't the O- reverse you take an H-plus from the acid instead of forming this unstable intermediate? You mean over here? You mean first? Yeah, since there's acid in the other side. You have hit an absolutely beautiful question. So the question that's being asked from the front row is a really good one and it caused me a little bit of thought and a little bit of consternation in putting together today's lecture. And the reason for it, so the question that's being asked which is an extremely valid one is why don't we protonate the carbonyl oxygen first by acid? And what causes me real consternation, the mechanism I'm giving you is the best one for this reaction catalyzed by mild acid. However, and it's the one that most closely accords to experiment for the rate determining step being the breakdown of the hemiaminal which we will see in just a moment. However, if you for example look at other sources or you look at wikipedia or more not wikipedia the organic chemistry wiki text from the University of Michigan you will indeed see that mechanism and it doesn't accord quite as well with experiment even though it represents very sound mechanistic thinking. So coming back to the question of why I'm writing the mechanism this way because this is important because your thinking is sound and mechanistic and specifically not wrong for writing the mechanism even though experiment is different. Why am I harping on this? Why am I now taking the time of 200 people because you're going to worry about this later on when we start to come into our last segment and you worry why is there a difference between the mechanism I wrote here and the mechanism that we're going to write with very weak nucleophiles. Here's the reason why I consider this mechanism that I've written to be a more realistic, more valid mechanism, a better mechanism. So we're doing this reaction with catalytic amounts of acid. In other words, this reaction is being done with a little bit of tostic acid which I will show you later for example or some acetic acid or just with the amount of inherent acid that's present. You have one mole of amine present. Amines are basic. So the strongest acid, if I mix a strong acid with the amine, if I mix a little bit of HCl, remember less than one equivalent, a catalytic amount of acid or a little bit of tostic acid which I'll show you later with the amine, the strongest acid that's present will be the ammonium ion, RNH3+. RNH3+, is a very weak acid or is a weak acid to keep consistent with my terminology. PKA about 10 or 11. A carbonyl, that carbonyl is a relatively weak base. It's weaker than water. Water has a PKA of roughly for the conjugate acid for hydronium ion of negative 1.7. A carbonyl group is even less basic. It's sp2. The electrons are held more tightly to the oxygen atom. So the PKA of the conjugate acid to protonate that carbonyl is well into the negatives, negative 3, negative 4, somewhere around there. In general, an equilibrium where you have 10 orders of magnitude or greater generally doesn't get invoked in a mechanism. It's just too far to the left for an ammonium ion, PKA 10 or 11, to be protonating a carbonyl. When we come to weak acids, we are going to see a different mechanism because now you've got the strongest, now you don't have an amine present, you don't have that base and so we're going to have weak acids being acid catalyzed where yes, you protonate. Now we take the flip side in favor of this mechanism. The flip side in favor of this mechanism is your nucleophile, is PKA for the conjugate acid of about 10. That's like cyanide, that's like other nucleophiles that we see happily add in an unacid catalyzed step to the carbonyl. So this first step occurs without protonation of the carbonyl. However, the thinking is not long, it's not bad thinking to think about it in the other way. So back to my consternation at putting this lecture together. So what gave me some consternation is I wanted to follow the order of the textbook here and this is a nice reaction because it introduces the principle of a nucleophile that's not phosphorus pulling the water out. And I think they made a good choice but mechanistically today's mechanism is the oddball mechanism because you precisely have the conundrum that you've cited. So thank you for raising that, it really is good. And coming to your point as students about should I be confused about this mechanism or if I'm feeling confused or the parallel, oh do I need to know this. If I'm feeling confused, yes this is the one of all the mechanisms that we're going to see. Today's mechanisms are the ones that will cause you the most consternation. Next Tuesday's mechanism should end up showing more elucidation. And so my consternation in presenting this was do we want to go with the most confusing one first and I decided to follow your textbook. But yes if you're scratching your head you ought to a little bit. Alright at this point our hemiaminal undergoes acid catalyzed breakdown. In very, very special circumstances, certain hemiaminal. Hemiaminal can be stable but in general they're not. And the rate determining step, the slowest step is the breakdown of the hemiaminal. Acid and it can be as simple as some of the other water that's present or other adventitious sources of acid or it can be a little bit of added acid which in the end although again you're going to find some mechanisms writing as H3O plus really would end up being a protonated ammonium ion. It would really end up being a protonated amine. So some source of acid is going to transfer a proton. You can think of electrons as flowing from the oxygen to the acid back onto the base. Maybe I'll skip the curved arrows at that point just because we're very good at that. Whoops. Onto the oxygen. So both of these atoms are basic and to get over the hump. Now if we're headed back basically reversibly you can protonate the nitrogen but if we're headed back, if we're headed forward now we have to get over this hump. The nitrogen has to push out a molecule of water. So protons come on and off. Every Lewis basic acid in the molecule but sometimes they go on to this oxygen and when they do we're now set up to overcome the rate determining step. In this step electrons push from the nitrogen and push out a water molecule. And I guess since I've been, I'm going to actually write this in a separate line because things are getting crowded here. So here we have our hemiaminal protonated on the oxygen atom and now in the final, the penultimate, the rate determining step. Now we're going to break this guy down. So I'm just rewriting the species and electrons are going to flow from the nitrogen and push out water. And again every step in this reaction mechanism is an equilibrium. Whoops. Now we're going to get a double bond to nitrogen. Alright now we're ready to finish up our mechanism and in the final step of the mechanism so now we have our aminium ion. And as I said this is the rate determining step and now in the final step of this process we're going to simply take a proton off. Electrons flow from the base to the proton. We pull the proton off and we end up with our amin. And you notice in these three steps I've written here the first step where the base is protonating the oxygen, the second step where our protonated intermediate is breaking down and in the third step where we're getting our base back you see how the acid is acting as a catalyst. A little bit of acid gets invoked at the beginning but it comes back at the end. It's regenerated at the end. So if you had a catalytic amount of an ammonium ion present. Now that ammonium ion would be given up at the beginning but by the end of this catalytic cycle would be regenerated. Yeah well the R double prime be at a 180 degree angle with a double bond or does it mean for it to be? Ah okay so remember and I thank you for my lone pair so remember this nitrogen is sp2 hybridized, this carbon is sp2 hybridized and so you have a 120 degree angle here and a 120 degree angle here. Another question. The base there, could you just use a water for that? Yeah you could use a water and the only reason I'm not using water and not using H3O for this, well actually the main reason is in the presence of amine and we have amine present, in the presence of amine you get only a minuscule amount of H3O plus remember H3O plus pKa1 negative 1.7 ammonium ion pKa roughly 10 or 11. So you'll have very little auto dissociation to hydronium ion but yes and as I said for so many reasons today's mechanism is the oddball mechanism for so many reasons today's mechanism is hard to think about and this is one of them. Yes we will be using H3O plus and H2O or ROH in Tuesday's mechanisms but here realistically speaking most of the acid we're going to have around is going to be the ammonium ion. Now coming back to this proton here because if you're thinking and on your toes you're probably saying well why is this going to protonate? This is even more basic than a typical alcohol so we will protonate this and you're only generating a little bit of protonated species. This is the toughest part the breakdown of that intermediate. Other question? Another great question is that lone pair of electrons taking up a little more space back to VSEPR theory and geometry of molecules yes a little more space remember methane ammonia water the hydrogens in methane 109.5 degree angles hydrogens in ammonia about 107 I don't remember I think it's 107.3 degree angle they get pushed ever so slightly two degrees closer together hydrogens in water 104 I think it's 104.5 degrees so about two degrees closer. So yes technically this bond angle is probably closer to 118 degrees rather than 120 degrees but 120 or 118 is a hell of a way away from 109.5 or 107 so it is sp2 hybridized. I saw another question. All right one last question. Will a racemic mixture of both E and Z isomers be born? Will a racemic mixture of both E and Z oops bad question. Remember alkenes no chirality to the double bond diastereomers so the question is racemic means handed. So the answer will we yes we will if we had let's say a methyl group and an ethyl group here form a mixture where it would be very close to equal but if we have one group that's big like a methyl group and one group one group that's relatively big like a methyl group and one group that's small like a hydrogen as in an aldehyde amine and aldehyde amine then indeed you will have exclusively the trans or if you have one group that's very big like the methyl on the cyclohexanone that I showed and the other that's less big but if they're roughly the same yep you will get two of them. All right so we've walked through we've another question. Will this reaction oh I love it I love the question and this is every consternation I was thinking about and putting together today's lecture. So brilliant brilliant brilliant question. What do we think? How many think it will? How many think it won't? This is good and how many think I'm asking the wrong question? Yay. All right it turns out in general in general imines of this sort are unstable in general they go on to form other products in general whereas you can put most imines in a bottle remember by stable I mean things you can put in a bottle you can isolate the amino carbonyl the hemiaminal intermediate in general you can't put in a bottle although I can give you examples where you can in general you can't in general you can put an aldamine or ketamine in a bottle I showed you two in at the start in general you can't put this one in a bottle now just to check at the beginning of putting this lecture together I was curious I went to one of my favorite sources which is organic syntheses and indeed they have a preparation of one very very special such imine with trifluoromethyl groups which are very electron withdrawing and very special here but in general this ammonia imine the oddball imine which isn't primary it isn't secondary in general that is unstable and undergoes further reaction so yes you would form it transiently as an intermediate and then it would undergo further reaction alright now alright for coming back down to earth here because this is good we have had a really important discussion of some reasonably heady topics we have wrestled with mechanism and this is good and this week's discuss coming weeks discussion section from Tuesday on I am going to ask you to wrestle with mechanism so this is good we have been engaging and thinking about it we have asked questions that are deliberately outside the box and outside the textbook this is exactly what you should be doing so I want to come back to earth with a few basic principles here to ground us because the other thing that comes with heady discussions is this is confusing this is scary will this be on the exam so let's come back to some general principles that are less scary alright one of the principles I want to mention is that imine formation is an equilibrium in other words in writing these reactions and thinking about synthesis I have said yes we can drive this equilibrium we are organic chemists we can do anything we can make anything we can push compounds to go in almost any direction that we want them to go but let's not forget little shadow little yay if you don't take out water we come back to this reaction and it's an equilibrium which means it is just as valid to write the reverse reaction and if we don't take out water and we throw our imine together with water we can go ahead and drive the reaction in reverse again the shadow yay's principle it is just as valid to write the hydrolysis if instead of throwing a dean stark trap on there and instead of using benzene to azeotropically distill out water I go ahead and I throw in lots of water then I get the corresponding imine back alright further I want to further generalize because again organic chemistry can be scary and you say what general principles should I take away ok in general the reaction of moderately basic nucleophiles and weakly basic nucleophiles with ketones and aldehydes we looked at cyanohydrin formation that's an le on the end by the way we looked at cyanohydrin formation that reaction is reversible you can drive it in the reverse by distilling out or using acid to protonate the HCN and driving it away as a gas so in general the reaction of moderately basic nucleophiles like amines or hydrogen cyanide or weakly basic nucleophiles we'll talk about alcohols next time in general that reaction is reversible and in general the reaction of strongly basic nucleophiles is not in other words in general when you add an alkyl nucleophile or grignard reagent or an organo lithium compound or an acetylide to a ketone or an aldehyde in general it ain't coming back out in general if you add a hydride nucleophile to a ketone or an aldehyde it's not coming back out and the fun part are the exceptions and those exceptions go beyond the scope of the course but they end up being absolutely fascinating mechanistically. If you learned it in pyridine chemistry you may have learned one weird example called the chitchy bobbin reaction where a hydride nucleophile comes out it's a fun name if you didn't learn it google it just for fun. Alright again staying grounded in the stuff that people really fret about in sophomore organic chemistry let's go ahead and just look at a couple of species that we haven't seen before this particular species is called an oxyme and if you look at an oxyme and you say okay I haven't seen this before but I know how to form it because I can think backwards retro synthetically you can say oh that's just a funny looking amine called hydroxyl amine reacting with an aldehyde and so you can think backwards you can say ah I'm smarter than I think than he thinks I am I know how to make that I just react hydroxyl amine with this aldehyde maybe with a little bit of acid catalysis but let's take another funny looking species called a phenyl hydrazone it used to be really really important to make derivatives of carbonyl compounds because they were one of the ways people characterized them and if you look at this you can say oh again I'm clever enough to figure out how to synthesize it I just realized it's just a funny looking amine derived from acetone and phenyl hydrazine and so these principles that we're learning here for forming and taking apart molecules really ends up being much much more general. Now we've talked about primary amines and we've talked about ammonia surprisingly and now I want to move on to secondary amines and show you the conundrum that they present tertiary amines really can't go anywhere they can add reversibly but you can't even pull off a proton and form a hemiaminal. Alright. When people get tired of writing out long words like primary and secondary they'll often go ahead and use a degree symbol so two-naught amine is another is a shorthand for secondary amine and secondary amines with ketones or aldehydes go to a species called enamines and I'll give you an example of this reaction first. Again I've gone to one of my favorite sources for this orgsin and so I've taken cyclohexanone this turns out to be a reasonably important one and unfortunately your textbook doesn't do real justice to the beauty of this chemistry because it's useful in making steroids and chemical synthesis and asymmetric synthesis and it was pioneered by a fellow named Gilbert Stork really brought into very high utility by him maybe I'll put something on this week's discussion section. If you take a ketone or an aldehyde that has a hydrogen at the position adjacent to the carbon and you take a secondary amine and again you subject it to the same types of conditions that we used before benzene reflux removal of water with a Dean Stark trap you might not even see that written you might see acid catalysis this particular example doesn't require acid catalysis but in general you might say sometimes acid catalysis is used or if you're concerned you could write acid catalysis. So what we've done here is we've combined our secondary amine and our ketone to form a species called an enamine and again if I'm going to be good and write a balanced equation and remind us that we have an equilibrium that we're driving by our Dean Stark distillation we drive that reaction removing water. Alright so I guess I will also write in parenthesis or maybe below here sometimes with catalytic acid. Alright and where I want to close our discussion is to just talk about the mechanism for formation of the enamine and maybe a little bit more about it. Alright so just as in the case of our primary amine our amine is a nucleophile the carbonyl is an electrophile the amine is a moderately basic nucleophile it's a good enough nucleophile to attack the carbonyl it's like cyanide it's reasonably basic. So just as we had done in our previous example I am going to now assume that you can get yourself all the way to the hemiaminal attack of the amine onto the carbonyl proton transfer and at this point again we have some catalytic acid this is probably the most confusing and worst one and what was your name by the way it was a good question you asked. Kyle. Kyle and Kyle asked this very good question about H3O plus and so here I'm going to be a little bit vague but honestly your acid is probably in this case the ammonium ion. So we have our equilibrium here you have a small amount just as we have done before you have a small amount protonating here and now in our intermediate and again I'll be a good person and try to fully balance my equation here and maybe I'll even draw a curved arrow here just to complete things. Alright so now we come down to the crux of the matter the breakdown of our protonated hemiaminal and nitrogen has a lone pair of electrons it can give a good push we push electrons in to form a double bond we push out water and up until now everything everything everything has been the same as we did in the amine formation so here we have our aminium ion but at this point we have ourselves in a conundrum because in the case of the aminium ion formation we could now pull a proton off off of the nitrogen and at this point we're stuck we can't pull a proton off of the nitrogen there's no proton to pull off the nitrogen. Aminium ions can be stable species under special conditions but in general their intermediates and something else occurs and let me show you what else occurs. So remember I said that we have to have beta proton so here's our aminium ion and we can think about this two ways and they're both valid ways of thinking about this. So one way you can think about it is you have base present the base among other things is the base that just got released over there it can be a mean you can think of it as being water so we have various basic species around one way you can think about it is the base pulls off this proton and I'm perfectly happy with this view and we're going to be taking a view very much like this as we move into I believe it's chapter 23 and discuss the chemistry of enolates we push our proton from the push our electrons from the base to the proton we pull off this proton we push electrons in forming a new double bond and we push them up onto the nitrogen all of these steps are reversible and so I will show you curved arrows I will show you an equilibrium arrow rather and here we go and that's a perfectly valid way of thinking about this. Now equally valid is recognizing the fact that we can think about there being two resonance structures of the aminium ion and I'll use a resonance arrow we have a major resonance form in which everyone has a complete octet but the electronegative nitrogen bears a positive charge we have a second resonance structure a minor resonance structure in which the positive charge is on the carbon that's good carbons electron less electronegative than nitrogen but it's bad in so far that the carbon doesn't have a complete octet so we have a major resonance structure and a minor resonance structure and we can think of our base as pulling off a proton and if you're more comfortable with this type of way of doing it you can say alright the base pulls off our proton and we push electrons in over here and I guess if I want to want to keep track of my hydrogens I will write in a hydrogen there and now we have our protonated base and these are both valid ways of thinking about the same thing. Alright well I think that pretty much wraps up the chemistry that I would like to talk about I will probably bring in some carbon-carbon bond forming mechanism with enamines into our discussion chemistry to show you a little bit about the beauty of their chemistry and a little bit about curved arrows with them. I will see you on Tuesday.
Index of Topics: 4:10-HCN Addition and Wittig Reaction 7:13-Ketones or Aldehydes and Amines 10:32-Aldimine Formation Example 15:23-Ketimine Formation Example 19:55-Mechanism of Acid-Catalyzed Imine Formation 33:28-Acid-Catalyzed Breakdown of the Hemiaminal 44:33-Answer to Student Question 47:50-Imine Formation 49:49-Reversibility 53:15-Example of Reversibility 55:50-Enanamines 59:04-Nucleophilicity of Amine 1:01:50-Imine Reaction with Base
10.5446/19409 (DOI)
Good morning. So today I want to start talking about Chapter 21. And we're getting into the meat of the course right now. So we're talking the whole overarching theme of a huge portion of the class is carbonyl chemistry. And when I introduced the course and overviewed the course on the very first day, I said there are two main classes of reactions of carbonyl compounds that are going to be a lot of our thinking. One of them is reaction at the carbonyl compound with nucleophiles. And the other is reaction of the alpha carbon as a nucleophile. And we'll be learning about that later. But now we're going to really be delving in to the reactions of carbonyl compounds and particularly aldehydes and ketones with nucleophiles. And we've already gotten this theme and we're going to see now some variations. So the theme that we've gotten is if you have a carbonyl compound, a ketone or an aldehyde, and you have a nucleophile, and I'm going to describe that nucleophile as a strong nucleophile or maybe more specifically we'll say a strongly basic nucleophile or even a nucleophile that's not quite so strongly basic even let's say a moderately basic nucleophile. And I'll elaborate on this in a moment. In either of these types of conditions, a carbonyl compound, a ketone or aldehyde more specifically, is electrophilic enough at the carbonyl compound that the nucleophile is going to attack the carbonyl. We've already seen this reaction. Electrons flow from the nucleophile to the carbonyl compounds carbonyl carbon. You can't have five pairs of electrons around a carbon so concurrently as electrons are flowing as the nucleophile is approaching the carbon. Electrons are flowing up onto oxygen and the overall result now is that we have an alkoxide anion. I'll write that as O minus. We have three lone pairs of electrons around the oxygen. And in very, very generic terms because we're going to see a lot of variations of this. But in very generic terms, if we have some source of H plus, and remember of course I'm going to put it in quotes because you don't have naked H plus. It would be a hydronium ion or acetic acid. Or we're going to see lots and lots of variations here. Anyway, some source of a proton, some source of H plus, can protonate our alkoxide anion to give you an alcohol like so. And so that's what you've seen already. We're going to see some variations on this. But we're also going to introduce, and this is where things get really meaty, we're going to introduce the reaction of carbonyl compounds with weakly basic nucleophiles. And again, in the most general overview now, I'm going to write this as our carbonyl compound, our ketone or aldehyde, plus a weakly basic nucleophile. And again, it's a little hard to generalize. But let's envision some species that in general is not going to have a negative charge. Not all strongly basic nucleophiles have negative charges, but many of them do. Not all weakly basic nucleophiles don't have negative charges. But let's say in general they don't. And we'll envision that that nucleophile still has an electron pair to share. You've seen weakly basic nucleophiles before. Alcohols, water, those are weakly basic nucleophiles. And so along with our weakly basic nucleophile, imagine for a moment that we have some source of an acid catalyst that we'll call BH plus. And so imagine now for a moment that the nucleophile, because the carbonyl compound, the ketone or aldehyde, is only moderately electrophilic, imagine for a moment that the nucleophile isn't nucleophilic enough to attack the carbonyl. But you can set up an equilibrium where the base protonates the carbonyl. And so I'll write this as an equilibrium where now you protonate the carbonyl. And of course you still have your nucleophile H with its lone pair. And now you have your base, your conjugate base. All right. At this point now your carbonyl is a lot more electrophilic. Remember something that's electrophilic wants electrons. In general if you've got a positive charge it's going to want electrons all the more. And so now your weekly basic nucleophile says, wow this guy really, really wants me. I'm going to share my electrons. And so we can envision electrons flowing from the nucleophile to the carbonyl carbon, the protonated carbonyl compound just as they did before. But the exception or the difference is it's a lot more electrophilic. And again just as before we can't have 10 electrons around a carbon. So as electrons are flowing from the nucleophile we're putting electrons up onto the oxygen atom. And at this point now we have our tetrahedral species but it's already protonated. And we still have our base. And our positive charge now is on the nucleophile. And so at this point the base, the conjugate base of the acid catalyst can pull off the proton. And if this sounds a little bit abstract right now don't worry because we're going to see lots of concrete examples. And in many of these concrete examples some of them, not ones that we'll see today but later on, this species can undergo further reaction. And so over the course of the next three lectures, this lecture and next week's lecture will be exploring these themes in carbonyl chemistry and specifically in the chemistry of aldehydes and ketones. All right so that kind of serves as the overview of what we're going to see over the next few weeks, over the next three lectures. So let's start in by talking about aldehydes and ketones more specifically and talking about their properties and how we name them. Naming by now should be pretty easy for you. You can recognize the idea of getting a principle, identifying a principle chain, a four carbon chain for example in this compound tells us that's a derivative of butane. And so to name it we just call it butanol. The aldehyde can only be at the end of a chain so we don't need to go ahead and put any number to it. On the other hand if we have a ketone, let's take this example. Now of course you can have a ketones carbonyl at various positions. We've got to identify the principle chain. The longest chain in this molecule is a five carbon chain. We look at the molecule and we say okay I'm going to try to number it so I put the carbonyl at the lowest position so that's at the two position. So and we have a methyl group at the three position and we use O and E to indicate a ketone. So this compound is three methyl, two pentanone. And really that's all there is to naming compounds by way of the IUPAC names for aldehydes and ketones. Now there are so many aldehydes and ketones that have common names that we would maybe never even use the systematic name. So for example if I looked at this ketone, who knows what this ketone is? Acetone, exactly. I think I'd be very hard pressed to say propanone for it just because its common name, its nickname is so ubiquitous. If I did say propanone because the only position the carbonyl could be at is the center position, I wouldn't even have to put a number on it. In general small compounds that have some history to them have trivial names, have common names that usually become the ones that roll off people's tongues. This aldehyde here, anyone? Formaldehyde is one carbon and what do we call, what's the two carbon? What's the two carbon acid? Ethanol is right, the two carbon alcohol and CH3COOH is acetic acid and so this is acid aldehyde. And again its real name or its systematic name is ethanol but nobody is going to call it that unless they're naming things as a substituted version of it. This aldehyde here, Benzaldehyde, even though its systematic name would be phenylmethanol, for the most part nomenclature is dull as dishwater other than perhaps systematizing in your mind the anatomy of a compound. So let's take a moment to talk about some of the properties of aldehydes and ketones. You've probably all had the opportunity to work with acetone if nothing else, it's a common solvent that's used to wash your glassware. If any of you are wearing nail polish out there, you've probably used it and smelled it along with ethyl acetate and nail polish remover. It's a pretty volatile liquid. It's got a boiling point of 56 degrees so it has a high vapor pressure as I said it's a liquid. One of the things that one can do is put properties of compounds into context comparing them to similar size compounds. So for example if I look at a similar size compound containing just carbon if I look at isobutane, isobutane by comparison is a gas with a boiling point of negative 12 degrees. So isobutane of course can only have Van der Waals interactions among the molecules, it's a nonpolar molecule. Acetone can participate in dipole-dipole interactions. It's got a great molecular dipole to it. It's miscible with water. It even dissolves some inorganic compounds like sodium iodide dissolves very well in acetone. And if we go further, so isobutane has Van der Waals interactions so very little to hold it together. Acetone brings in Van der Waals plus dipole-dipole interactions. By the time you get up to isopropanol your boiling point is even higher. Now it's a liquid with a boiling point of 82 degrees. And of course there you get hydrogen bonding as well in its interactions. I don't want to spend too much time. We're going to get more of a flavor of reactivity later on as we go. But I want to give you a general feeling that in general ketones are more reactive than aldehydes. And that kind of makes sense. We're going to see more of it when we talk about hydrates. I think that's where it really brings home the point. But let me just say compare acid aldehyde versus acetone. So acid aldehyde is more reactive. I'll draw it. Similar purposes. And the main difference in reactivity that I think of is mainly electronic. In other words your carbonyl in both of these compounds, both in acid aldehyde and in acetone is reactive toward nucleophiles. But your acid aldehyde is more reactive, more electrophilic. Because the carbonyl is more electron deficient. Remember methyl groups are electron donating. So in addition to having the carbonyl dipole, you have one dipole here donating in electrons. And so in the other case you have two sets of donations. The methyl groups can donate. So you're less electrophilic here. The carbonyl is less unhappy. You also have a steric component. And so between the two of those, the electronics of the donations from the alkyl groups and the sterics of the methyl groups, it's more electrophilic at the in acid aldehyde. Resonance will also affect things. So for example, benzaldehyde versus acid aldehyde. Benzaldehyde has resonance stabilization of the carbonyl. So it's going to be a little bit less reactive than say acid aldehyde. So I will write two electron donating groups here. First is one for acid aldehyde. All right. I want to take a moment to talk about some of the spectroscopic properties of carbonyl compounds. And maybe the way to do it, since obviously in IR spectroscopy they all have a carbonyl stretch as a defining factor. Maybe the way to do this is to look at sort of differences among them. And so let's talk about IR spectroscopy of typical carbonyl compounds. One way I think keep things straight in my mind when I think about the very subtle differences in carbonyl stretching frequencies is just to keep in mind a progression that in general as we go from esters to aldehydes to acids to ketones to amides, in general the carbonyl stretch moves to slightly lower wave numbers, slightly lower frequencies. Esters, a typical aliphatic ester is about 1750 to 1735 wave numbers. A typical aldehyde is about 1740 to 1720 wave numbers. A typical carboxylic acid is about 1725 to 1705 wave numbers. A typical ketone, or let's say, yeah, a typical ketone is about 1725 to 1700. And a typical amide is about 1690 to 1650. So outside of amides all of these sort of end up in overlapping ranges. And as I said, these are kind of general values. In other words, if you have conjugation like benzaldehyde, that's going to shift the carbonyl frequency by several tens of wave numbers. So in other words, you look at these bands and they're not purely diagnostic on their own. But then there are other factors that clue you in. We talked, for example, about carboxylic acids. And we said it's pretty hard to miss a carboxylic acid in the, oops, I have managed to swap ester aldehyde ketone, pardon me, acid amide. So if we look at, say, a ketone versus an acid, there's not a heck of a lot of difference. They fall essentially in the same range. But a carboxylic acid has a very well-defined OH stretch that's really broad from about 17, from about 3,500 to about 2,500. I shouldn't say well-defined, but very pronounced. Remember I drew it out for you before. It's this big, ugly, encompassing blob that starts well above the CH stretches and ends well below the CH stretches, may obscure them and has kind of little features to it. It's pretty hard to miss. As long as your molecule isn't gigantically huge, in which case the carboxyl group is only a small part of the molecule. So for the most part, if you saw a peak at, say, 17, 15 wave numbers, you'd say, well, that might be a ketone or it might be an acid, but then you look down at the region around 3,000 and you say, oh my God, there's this big blob here. It's got to be a carboxylic acid. So similarly, there are other corroborating features, albeit sometimes more subtle. For example, esters, you can sometimes, not always, because the fingerprint region is pretty crowded, you can sometimes see the CO bond single stretch at about 1,300 to about 1,100, but again, there's a lot of stuff there, so I'll put this sort of in parenthesis as you might be able to pick it out. So you get a little hint. Of course, NMR spectroscopy brings in other hints. We talked about a CH2 next to an oxygen in an ester, and we say that's so about four parts per million, and so that would clue you in. Aldehydes also have little hints. For example, the carbonial, the aldehyde hydrogen gives you a couple of bands from the CH stretch. The CH stretch typically shows you right at the lower edge of the CH stretching region, about 2820 and 2720 shows a couple of bands associated with it. They're sometimes hard to pick out because they're right on the lower edge of all of the other CH stretches, but if you look hard, sometimes you can pick it out. However, there are going to be other spectroscopic features, for example, in the NMR spectra that would clue you in, say, to an aldehyde, the presence of the CH group, which we'll talk about in just a moment. All right, as I said, there are a lot of factors that perturb these sort of general aliphatic carbonyl stretching frequencies. So one of the big things is conjugation, as I just mentioned. So for example, if you take a look at cyclohexanone, cyclohexanone has its carbonyl stretch right in the middle of where you'd expect, right in the middle of where you'd expect for a ketone, right at about 1715. If on the other hand you go to cyclohexanone, the conjugation of the double bond with the ketone goes and weakens the CH stretch. It shifts it to lower frequency to about 1685 wave numbers. We've already seen this in talking about an overviewing some of the chemistry of alpha, beta, unsaturated carbonyl compounds when we were talking about cuprate chemistry and we explained that there are many different resonance structures. One of the resonance structures has single bond character. It's a minor contributing structure, but it shows you how collectively the various pictures of the molecule end up indicating that the carbon-oxygen double bond isn't quite as strong that it doesn't stretch at quite as high a frequency. This same type of effect occurs in other sorts of alpha, beta, unsaturated carbonyl compounds. So for example, if we look at acetophenone, the ketone is also at about 1685 wave numbers. Now, another thing that can change the carbonyl stretching frequency is ring strain. So if you take a look instead of it cyclohexanone, if you take a look at cyclobutanone, now you've got a four-membered ring. And of course, the bond angles in a four-membered ring are much smaller than in a six-membered ring. Encyclohexan and cyclohexanone, the carbon-carbon bond angles can be essentially what they desire to be. At carbon, sp3 carbon bonded to an sp3 carbon bonded to an sp3 carbon wants to be 109.5 degrees. An sp3 carbon bonded to an sp2 carbon bonded to an sp3 carbon wants to be 120 degrees. But by the time you get down to cyclobutanone, all of your angles are getting forced to be much, much closer to 90 degrees. As a result of that, you're having to use more p character in making up the ring bonds. That leaves more s character for the CO bond. And remember, s orbitals are lower in energy, so that's going to make the CO bond stronger, which in turn means it's going to vibrate at higher frequency. So cyclobutanone ends up having a stretching frequency of 1780 wave numbers. And I'll just jot this as more p character in the ring leads to more s character in CO bond. And that leads to a stronger CO bond. The same effect of rings, cyclobutanones are pretty rare. They don't occur commonly. You don't find them in many molecules like, for example, steroids and other sorts of very few natural products, say, contain them. On the other hand, cyclopentane rings and cyclopentanones are much more common. And even in a cyclopentanone, you can see the same effect of a stronger CO bond. So for example, when we compare cyclopentanone to cyclohexanone, our carbonyl stretching frequency is still about 30 wave numbers higher. It's at about 1745. And as you can see, if you only relied on these general CO values and you said, oh, the only thing that's 1750 to 1735 is an ester, so that carbonyl must be an ester, you'd be wrong because there are many factors that perturb it. Ditto, if you said, oh, the only thing in that table that's at 1685 is an amide, so it must be an amide, you'd be wrong on those because, again, there are many factors that perturb it. And this is why the confluence of infrared spectroscopy and NMR spectroscopy and good sound chemical and mechanistic thinking and being able to read other subtle clues in the spectrum like a CO single bond stretch or a CH of an aldehyde or the not so subtle OH of a carboxylic acid ends up being very important. All right, well, in NMR spectroscopy, there are also some general things to keep in mind. And one of the things that I like to do when I think about NMR is sort of put things in broad classes. Alkyl CHs, generally, if there's nothing perturbing them, show up from about 0.9 to about 2 ppm, about 1 to 2 ppm for a methyl group, a methylene group or a methine group respectively, more toward 0.9 for a methyl, more toward say 1.4 for a methylene and more toward 1.5 or 2 for a methine. Ditto, if you have a hydrogen that's next to a carbonyl, you tend to have sort of a general area that that hydrogen might be at, sort of generally about 2 to 3 ppm depending on the type of hydrogen. So for example, a methyl group off of a carbonyl tends to be more about 2 ppm. And again, all of these are approximate numbers. So I'll put little till days to indicate sort of general. If it's a methylene group, it'll be a little bit further downfield, maybe 2.3ish ppm. And so this is kind of a good starting point for reading an NMR spectrum. By the time you're having a hydrogen that's directly attached to a carbon that's attached not to a carbonyl but an oxygen, you've kind of moved into the 3 to 4 ppm range. So a CH2 that's a part of ethanol is going to be at about 3.4, a CH2 that's part of ethyl acetate is going to be at about 4.1 ppm. The aldehyde CH is another very characteristic feature in the spectrum. An aldehyde CH is typically at about 9 to 10 ppm. One of the things that's interesting about aldehydes is your coupling constants for most J coupling with the exception of double bonds, most J coupling is about 7 hertz. In other words, when you see a triplet or you see a quartet for ethanol, the spacing of those lines is generally about 7 hertz apart. In an aldehyde because of the electronegativity and because of the hybridization of the aldehyde carbon, the J coupling ends up being considerably smaller between the adjacent hydrogens. Your J value is generally about 1 to 3 hertz. Now, the implications of that is when you look at a compound that say has an ethyl group in it and an aldehyde group in it, you look at the ethyl group and you say, oh, it looks like a typical triplet for the methyl. The lines are in this pattern of spacing that I'm used to. And then you look at the aldehyde and you say, my God, the lines are so close together, what's going on? Well, what's going on is that it has a smaller coupling constant. And so being able to recognize that clues you in and you can say, I have an aldehyde next to one hydrogen or I have an aldehyde next to two hydrogens. I guess the other thing I'll touch on very briefly is your C13 NMR spectrum. The most defining feature of aldehydes and ketones in the C13 NMR spectrum is the carbonyl. Your textbook gives a number of about 190 to about 215 ppm for aldehydes and ketones. The carbonyl of ketones tends to be a little bit more toward the downfield end, a little bit more toward the 210, 215, the carbonyl carbon of aldehydes tends to be a little bit more toward the upfield end, maybe 195 being sort of a typical value for aldehydes. These, of course, numbers are very different than what you see for say a carboxylic acid or an ester where you still have a carbonyl carbon standing out very far downfield, but now it's more like 170 or 180 ppm. So, if you were to shoot a hypothetical subject, you would have done 160. So, other than this, you would have also shot one of the comparisonocy fuels of aldehydes and the rest of the variables which we Your textbook does a very nice job of reviewing chemistry that you've already learned. And I'm just going to mention a few things on the synthesis of aldehydes and ketones, things that you've seen before in earlier chapters. So when you were learning about alcohols, you learned about oxidation reactions to make aldehydes and ketones, and I mentioned this briefly when I was talking about carboxylic acids. Chromium 6 is a very common oxidizing reagent, often in the form of potassium chromate or potassium dichromate or sodium dichromate or chromium trioxide. A general and indeed old-fashioned and somewhat toxic and carcinogenic recipe for oxidizing secondary alcohols to ketones is to take potassium dichromate or sodium dichromate and sulfuric acid in water sometimes called Jones's reagent. And that is a general oxidizing agent to oxidize the secondary alcohol to a ketone. Your textbook introduced you to the concept of selectivity. This reagent oxidizes primary alcohols directly to carboxylic acids, but if you take a primary alcohol, RCH2OH, I'm going to write it a little bit neater here, RCH2OH, and you treat it with the reagent PCC, pyridinium chlorachromate, often in methylene chloride, you need a nonhydroxylic solvent, you need an anhydrous solvent for this reaction. Methylene chloride does a nice job for this. Then you can selectively oxidize a primary alcohol to an aldehyde. Ketones and aldehydes are in a higher oxidation state than alcohols. Ketones and aldehydes are in a lower oxidation state than carboxylic acids. So for example, if you take an ester with a selective reducing agent like di-BAL, you can reduce your ester right down to the corresponding aldehyde. And again, I've mentioned this one before, di-BAL H or di-BAL followed by an aqueous workup with water or H3O plus aqueous acid can reduce your aldehyde, your ester directly to an aldehyde. And of course, the other product of the reaction is your corresponding alcohol. Your textbook also reminded you that there are selective reactions to reduce acid chlorides. Acid chlorides are extremely, extremely reactive. You'll learn as we go on to discuss esters and as we go on to discuss other members of the carboxylic acid family that acid chlorides react directly with water. They react directly with alcohols because the chlorine is electron withdrawing and they're very electrophilic. You can selectively reduce the acid chloride down to an aldehyde with a very attenuated form of lithium aluminum hydride, lithium aluminum hydride in which we've added three equivalents of tert-butanol to get this very bulky, very non-reactive lithium triturt butoxy aluminum hydride, Li, Al, H, O, TB, U, 3. And this reagent barely, barely wants to transfer hydride but the hydride is nucleophilic enough that the very electrophilic acid chloride can be reduced selectively to the aldehyde. And again, you need some type of aqueous workup in this water or aqueous acid. All right, so that kind of covers reactions that you've seen for reactions in which you're transforming oxidation state without really changing the structure of the molecule. You've also learned about some reactions that transform the structure of the molecule more profoundly while changing oxidation state. So for example, you've learned again in past chapters about ozone analysis. You can take an alkene and treat it with ozone which you generate by passing an electric discharge through oxygen and then you can reduce the resulting ozonide with dimethyl sulfide, ME2S, or zinc and water. You can reduce the resulting ozonide and you cleave, hence the lysis, you cleave your alkene into two carbonyl halves, two ketones or two aldehydes or a ketone and an aldehyde depending on what substituents you have on your carbonyl group. Again, by way of review, your textbook reintroduces various reactions of alkynes and this is all a quick, quick survey of things you've seen before. So your textbook reintroduces the Markovnikov addition of water across alkynes to give ketones. So for example, if we have a terminal alkyne and we treat it with sulfuric acid and a catalyst, typically a mercury catalyst like mercuric sulfate HGSO4 in the presence of water, we add a mole of water across the alkyne in a Markovnikov sense, the first product is an enol which we'll be talking more about later. The enol undergoes tautomerization to give the corresponding methyl ketone. Organic chemists are all about control being able to control chemo selectivity being able to control stereoselectivity and being able to control regioselectivity. The natural regioselectivity of addition across an alkyne is to put, of an alkyne is to put the substituent on the more substituted carbon and that has to do with stabilization of carbocations. Chemists for that reason have developed chemo selective reactions that do the opposite and so hydroboration which 1HC Brown, the Nobel Prize ends up adding in an anti-Markovnikov sense. In other words, if you treat an alkyne with borane or a borane derivative BH3 and then you carry out an oxidative workup with sodium hydroxide and hydrogen peroxide, you end up adding in an anti-Markovnikov sense to get the corresponding aldehyde. Anyway, your textbook gives a few more reactions and does a nice general survey of synthetic reactions but I think it's really all review. All right, what I would like to do at this point is to really get us into the meat of the material and the meat of chapter 21 is going to be what I alluded to at the beginning of class, this addition of nucleophiles and one of the concepts that I've been harping on and will continue to harp on is the notion of pKa as a way of thinking about strength of a base or strength of an acid or strength of a nucleophiles. So when I think about the reaction of carbonyl compounds and particularly ketones and aldehydes with nucleophiles, in my mind I sort of group nucleophiles into different types. I think for example about some nucleophiles as being very basic, let's say very strongly basic. We've already seen examples of this, R minus alkyl nucleophiles, grignard reagents and organolithium reagents. Of course, these are not naked carbonyl ions. They're covalent bonds between magnesium and carbon or between lithium and carbon. But you can think of them from a mechanistic point of view as R minus ditto things like hydride nucleophiles. And again, typically we're not talking naked hydride. We're not talking about H minus as a free species. We're talking about hydride and lithium aluminum hydride or insodium borohydride. Nevertheless, these end up reacting in many ways like H minus. And when I think about these nucleophiles, I think okay, if I were to think of the conjugate acid of the nucleophile, Rh for an alkane, I would remember, oh yeah, it has a pKa of 50. An alkane is a very weak acid. It's not an acid that if I pour it into water, I'm going to measure any protons, any acidity. The water will still be pH 7 if I pour, put an alkane into water. Well, it wouldn't dissolve, but if I could dissolve it, it wouldn't affect the acidity. But if I had a strong enough base, I would need a very, very, very strong base to pull off that proton. Ditto, the conjugate acid of hydride is hydrogen, the pKa of hydrogen, and I'll put tilde's here. I'll put approximately. The pKa of molecular hydrogen is about 35. Then by comparison, I might think of, let's say, from very strongly basic to moderately strongly basic. And these are all loose categories. But for moderately strongly basic nucleophiles, I'll think of things like hydroxide anion and alkoxide anion and amines RNH2 for primary amine and ditto I can think of a secondary amine as R2NH and cyanide anion. Now, all of the conjugate acids here fall in the realm of what you would typically call a weak acid. There are things that you would think of as being a little bit acidic, but not strongly acidic. The pKa of the conjugate acid of hydroxide, the conjugate acid of hydroxide, of course, is water. The pKa of water is 15.7. The conjugate acid of alcohols is just about the same, maybe a hair weaker depending on the alcohol, about 16 to 17. The conjugate acid of amines is ammonium salts, RNH3 plus for a primary amine or R2NH2 plus for a secondary amine. The pKa of a conjugate acid of an amine, of an ammonium ion is on the order of 10 to 11, sometimes a little higher, sometimes a little lower, but that's a reasonable number. And the last one, hydrogen cyanide, which is actually where we'll start our discussion of reactivity because it has a nice simple reactivity, hydrogen cyanide is often called hydrosyanic acid, is a weak acid with a pKa of 9.4. All right, so that takes care of what I'd call very basic and moderately basic nucleophiles. And you could probably predict that there would be others in that category, things like hydrogen sulfide where you have a similar sort of pKa, but this is plenty to get us started. Then at the other end of the spectrum, we come to what I'll call weekly basic nucleophiles. And by that point, we're talking about things like water and alcohols. It's very important to remember, water and alcohols are amphoteric compounds. So there's actually two pKa's to keep in mind. If I'm thinking about water as a base, not as an acid as we just did, but as a base, I need to think of the conjugate acid of water, the hydronium ion H3O plus, the pKa of the hydronium ion is negative 1.7. If I want to think about the conjugate acid of an alcohol, the conjugate acid is RoH2 plus. Now we're talking negative 2 to, and again, these are sort of approximate values, so I'll use a little tilde, approximately negative 2 to negative 3. Okay. All right. I'd like to start the discussion of the reaction with the reaction of strong nucleophiles, the reaction of aldehydes and ketones with strong nucleophiles, and start with something with which you're quite familiar because we've been talking about it for a while, and that's the reaction with various types of alcohol nucleophiles. So let me take sodium acetylide. Sodium acetylide, as I mentioned before, is one that you probably can think of as more ionic than covalent, so it's sort of a nice analogy. Acetylene's pretty special. Acetylene, remember, we have an sp2 carbon, so whereas alkanes have a pKa of about negative 50, of about 50, and alkanes are still kind of similar, 44, by the time you get to alkanes and you have all that S character in the CH bond, the CH bond is reasonably acidic. Acetylenes are negative 25. So sodium acetylide is still a very strongly basic nucleophile, and if I treat acetone with sodium acetylide, and then I carry out an aqueous workup with some acid, you could write it as H3O plus, or you'd go into the chem stock room and you get some sulfuric acid and some water, or some hydrochloric acid and some water. Your alkyne adds, your alkyne anion adds, and the overall result is an alcohol. That's a reaction that you've seen in the last chapter, and you've also seen SN2 displacements of alkanes before on halides. So now let's think about an analogous reaction of hydrogen cyanide, and I'm going to write this first sort of in a way that may not be so obvious why the reaction is analogous. But if I treat my alkyne, my acetone with hydrogen cyanide, maybe a little bit of base as a catalyst, we have an equilibrium to form a cyanohydrin. Now, the hydrogen cyanide adds in to the acetone, and we get a product that really in many ways looks very analogous to the addition of acetylene. Now, hydrogen cyanide is not something you want to work with. It is probably the most common, the most poisonous commonly encountered compound in the organic chemistry laboratory. Hydrogen cyanide is typically fatal at 50 milligrams. It's a gas, or more specifically, it's right on the edge of a gas and a liquid. Its boiling point is 26 degrees. If you've ever worked with methylene chloride or with ether in the chem lab, you know how volatile those are. If you spill it, it evaporates immediately. 26 degrees evaporates basically right at room temperature, so it's practically a gas, which means it's very easy to breathe in 50 milligrams. So, only slightly safer is to not work with hydrogen cyanide as a gas, but to work with a solid cyanide source and acid. If we take sodium cyanide and sulfuric acid, you generate hydrogen cyanide in situ, and so it's equivalent, but at least you're not trying to dispense this half liquid, half gas, this thing teetering on the edge. And this is a very good way to add cyanide to a carbonyl compound to a ketone or aldehyde. Sodium cyanide is nasty stuff. This was used in the gas chambers in Nazi Germany to kill people by this very reaction, and it used to be used in our gas chambers to kill people where you would mix it with sulfuric acid. So, this is not nice stuff to work with. It's very poisonous. But from a chemical point of view, what we've done here is very cool. We formed a carbon-carbon bond, and this is the basis for building up, one basis for building up much more molecular complexity by forming carbon-carbon bonds from simpler molecules. Just out of curiosity, what mechanism does cyanide do to harm us? What mechanism does cyanide do to harm us? I believe it binds to your hemoglobin. So, cyanide, carbon monoxide, nitric oxide, I think all can bind to your hemoglobin to various degrees, but it's a nasty, nasty poison. However, I thought you were going to ask, what mechanism does it add to the carbonyl compound? And that question is one that actually brings us to the heart of the mechanistic chemistry that we're talking about. So, we can think about this mechanism as involving cyanide as a nucleophile, and cyanide is a good enough nucleophile to add directly to a carbonyl compound. So, hydrogen cyanide is an equilibrium with cyanide anion, sodium cyanide and sulfuric acid is in equilibrium with cyanide anion. And so, cyanide anion can add to the carbonyl compound like so, just as we've seen before, electrons flow from the nucleophile to the carbonyl carbon from the carbonyl double bond up onto the oxygen, you add, you form an anion, an oxyanion. And then in a second step, that oxyanion can protonate, and I'll write it as protonating from hydronium ion, could protonate from another molecule of HCN as well. So, electrons flow from the oxyanion to the hydrogen, that in turn pushes electrons out of the OH bond back onto the oxygen, and we get our cyanohydrin. So, what you can see here really is a big degree of analogy between the chemistry that you've seen thus far where we've added an alkyl metal and this new chemistry where we're just adding a moderately basic nucleophile. Your moderately basic nucleophile exists as an anion. It can add to the carbonyl, you get an alkoxide anion. The alkoxide anion can be protonated. The only big difference is with a strongly basic nucleophile, you can't have your proton source present at the same time because the strongly basic nucleophile would react with your proton source and would be quenched, whereas the moderately basic nucleophile can exist in equilibrium with the protonated form, and so you don't have to worry about it being quenched. All right, your textbook pedagogically does something that was very interesting at this point, and at first it sort of surprised me, and then I thought about it and it made sense. So the rest of this chapter is going to set us up for more complex reactions. It's going to set us up for the formation of imines, the formation of acetals, formation of hemiasatals as well, the hydrolysis of imines, the hydrolysis of the formation of enamines, and all of the reverse reactions. And at this point, your textbook introduces a reaction that's a little bit of an oddball. It introduces the Vittig reaction, and when I thought about it pedagogically, it actually made sense why they're doing this. I think very few textbooks introduce the Vittig reaction at this point. The Vittig reaction is the reaction of a ketone or an aldehyde with a phosphorus illid to form an alkene. I'll write this out in just a second. But the gist of the reaction is that a nucleophile is adding into your ketone or aldehyde, and ultimately we're pulling the oxygen out and replacing it fully, not half replacing it or adding to it as we did here, but we're replacing it fully with the nucleophile. And that theme is going to come up in the rest of the chapter, in the formation of acetals, in the formation of enamines, and in the formation of imines. So let me write out the reaction and explain how it works. So we have a ketone or an aldehyde. We have a carbon nucleophile called an illid. Now write out the structure. Invariably it's a phosphorus illid. An illid, so this is called a Vittig reagent. An illid is a species where you have a separated positive and negative charge. And so we call this a phosphorus illid. Because we have the separated positive and negative charge on phosphorus. And the overall reaction that occurs here, again, in very generic form, is that we now replace the oxygen to get an alkene and as a byproduct of the reaction. Remember again, a chemist hate writing byproducts of reactions, you get triphenylphosphine oxide. Triphenylphosphine oxide is not only something that's easy to forget about as a byproduct of reaction, it's also a pain in the neck to get rid of if you're carrying out the reaction in the laboratory. All right, there's a lot of anatomy here. One of the things you'll find is in shorthand, we often write pH as a phenyl group. So I'm going to write things out in longhand now for the conjugate acid of the phosphorus illid. The conjugate acid of the phosphorus illid is a triphenyl phosphonium salt. And I'm now writing the benzines explicitly so you can see at least one time what we will, for the rest of today's lecture, be writing out as pH. And the main thing is in the phosphonium salt, you have a proton and that proton is acidified by the positive charge and the stabilization that phosphorus provides. So the proton is acidified, its pKa is about 22. In other words, it's right in that range kind of like acetylide or kind of like acetylene as far as its pKa goes. It's at that very sort of lower edge of strongly basic. And there are two things that are super stabilizing about this phosphorus. One thing that's stabilizing about the phosphorus is, of course, that you have the negative charge next to a positive charge. The other thing, and I'll write out my fennels explicitly for a moment here, pH, pH. The other thing that's specially stabilizing about phosphorus is phosphorus is in that row of the periodic table. It's down from the row from carbon and oxygen and nitrogen and fluorine. It's in the row of periodic table where you can invoke D electrons, where you have D orbitals. And so we can write a resonance structure that has more than 8 electrons around the phosphorus. And together these two resonance structures make up a more complete structure of the phosphorus illid. So for these two reasons, we have a good degree of stabilization, a good degree of acidification of this proton versus what you would expect for a plain old alkane which would have a pK of about 50. All right, so let's go on to talk about the mechanism of this reaction. You can think of the mechanism of this reaction as occurring in just two steps. Or you can think of it as occurring in three steps. Your textbook writes it in two and I'm going to write it in that way and tell you why it's been of so much concern for people. So you can envision that in the first step, your phosphorus illid has a nucleophilic carbon and an electrophilic phosphorus. And so two things can happen at the same time. Electrons can flow from the nucleophilic carbon to the electrophilic carbonyl carbon atom. And at the same time, they can flow up onto the oxygen but form a bond with the phosphorus. So I should say we can go ahead and have our electrons flow like so forming a four-membered ring called an oxaphosphatine. I'll write out the name for it. And this is an intermediate that actually can be observed experimentally. It's been debated in some detail whether this reaction occurs in a concerted fashion meaning both of these bonds are formed at the same time or whether they form first with a carbon-carbon bond and then in a second step with an oxygen-phosphorous bond. And consensus from experiment and calculation seems to be on the concerted, coming down toward the concerted mechanism. But in some textbooks and in some places, you will see an intermediate written now where we still have charges separated. In other words, where one bond has formed before the other. This intermediate is called a beta-ine. And I have personally seen people yelling at each other over the distinction in mechanism. For your purpose, it's not so important. The reason this reaction has been so hotly debated is it exhibits some stereoselectivity toward forming a cysalkine, just a little bit of stereoselectivity but enough to raise people's attention. And for this reason also a lot of interest. In a second step, the oxafosphatane breaks down. And the oxafosphatane breaks down again in a concerted process giving rise to the alkene and triphenylphosphine oxide. Like so. And so through these two steps, addition of the phosphorus illid to the carbonyl to form an oxafosphatane and then breakdown of the oxafosphatane to the alkene and the triphenylphosphine oxide, we can go ahead and form a new carbon bond. Question? Yeah, one like the two molecules are used in that box. Wouldn't the substituents like to be in a transposition rather than a cis position to be as far away from each other as possible? The two substituents, which one here? The four substituents, sorry. The four substituents. So one of the substituents is pointing out, one is pointing back, one is pointing out, one is pointing back. And getting well beyond the scope of the course, and you can read more for starters on Wikipedia on the article cited there, is this issue of why in certain circumstances you prefer to form the cis species. But I'm going to skip that for now because it gets well beyond the scope of the class. All right. I want to talk at this point about what one can do with it. This is an incredibly powerful synthetic reaction. We've just formed a carbon-carbon bond, a carbon-carbon double bond, stitching together two halves of two pieces to make a more complex molecule. That's powerful. And it's interesting, and it's mechanistically interesting. And for that reason, George Whittig won the Nobel Prize in 1979 for the discovery of this reaction. Let's just take a look at how one does this in practice. So I'll show a couple of examples. Let me show how I do a Whittig reaction of cyclohexanone. And so first I will go ahead and just show you the reaction of the phosphorous illid, and I'll write it in the other resonance structure. Both of them are correct. If I mix the phosphorous illid and cyclohexanone, this is the phosphorous illid derived from ethyl. So I get the ethylidine compound. I've added in these two carbons. And the other byproduct of the reaction is triphenylphosphine oxide, like so. Now in practice, the way one carries this reaction out in the laboratory is you go ahead and you make the phosphorous illid yourself. Triphenylphosphine is a good nucleophile. You can take an electrophile like ethyl iodide and mix them and you get ethyl triphenylphosphonium iodide, pH3P, CH2CH3 plus I minus. And now again in the laboratory, you would then make your own illid. You would go ahead and you would treat your ethyl triphenyl phosphonium iodide with a strong base, like butylithium. I'll write in butylithium to indicate it's the normal isomer, one butylithium. Sometimes you just write butylithium. Or you could use sodium amide. Both of them are strong enough bases. Remember the pK of the conjugate acid of butylithium is, the conjugate acid is butane, pKa50. The pK of the conjugate acid of sodium amide is ammonia, pKa of 38, so they're both good enough bases to do it. So they will generate our phosphorous illid, our ethylidine triphenylphosphorane, it's called. And so that's kind of neat. I want to close by comparing and talking a little bit about selectivity and why this reaction is so powerful, why the Vittig reaction is so powerful. And so I want to offer a comparison to the elimination reactions that you've learned about the E1 and E2 elimination reactions. And we'll just look at an E1 example. If we wanted to make this same alkene by doing an E1 elimination reaction, I might imagine starting with cyclohexanone and treating it first with ethylmagnetium bromide and then doing an aqueous workup to give the corresponding alcohol. And now if I were to treat this alcohol with sulfuric acid, maybe a little heat under dehydrating conditions, sure, I'd get some of this product that I set out to make by the Vittig reaction, but I'd get it as a mixture of products in which we would also get the internal alkene. And so much of organic chemistry is about synthesis and about control. And the control that the Vittig reaction provides is very, very powerful. Now as I hinted at before, the other element of control and it's only partial control is that under certain conditions and in certain circumstances, you can preferentially get the cis alkene. So if we have a monosubstituted Vittig reagent, in other words, a Vittig reagent that has just one R group on it, and we have an aldehyde and we allow them to react, we get a mixture of products, the cis and trans alkene. It's pretty hard to get just one pure. Well, you can sometimes get the trans pure, but the trans isn't surprising because trans alkenes are more thermodynamically stable. But what's interesting is that sometimes under some conditions, the cis product can be the major product. And this is surprising because it's contra thermodynamic. The more stable alkene is the trans alkene. And the cis alkene, the two substituents bump into each other. If I have cis 2-butene, the two methyl groups gently bang into each other, but cis 2-butene is about one kilocalorie per mole less stable than trans 2-butene. And in part because of this surprising property of the Wittig reaction, people have yelled at each other and debated and studied the mechanism in tremendous depth. Next time we will pick up by talking about other reactions, we'll talk about imine formation and enamine formation and their mechanistic reverse.
This is the third quarter course in the organic chemistry series. Topics covered include: Fundamental concepts relating to carbon compounds with emphasis on structural theory and the nature of chemical bonding, stereochemistry, reaction mechanisms, and spectroscopic, physical, and chemical properties of the principal classes of carbon compounds. Index of Topics: 1:08-Carbonyls and Strongly Basic Nucleophiles 4:01-Weakly Basic Nucleophiles 9:56-Naming Carbonyls 14:22-Properties of Ketones and Aldehydes 16:59-Reactivity 19:38-IR Spectroscopy 26:04-Conjugation 32:12-NMR 37:52-Synthesis of Aldehydes and Ketones 47:14-Reactions with Nucleophiles 54:25-Acetylene and Hydrogen Cyanide Examples 1:00:16-Workup of Cyanide Anion Addition 1:04:15-Wittig Reaction 1:09:44-Wittig Reaction Mechanism 1:16:24-Making a Wittig Reagent 1:18:14-Wittig Reaction Examples 1:20:11-Stereoselectivity
10.5446/19407 (DOI)
So today we're going to really start from launching to the main video course and we'll start to talk about reactivity of carbonyl clouds. And this is going to encompass capture 20, but it's going to not just run through 20, but really all the way 24, captures 24, the next six weeks. This is the main piece of the course and this is also going to really be some of the intellectual height of organic chemistry. And we're going to see general themes of reactivity of carbonyl compounds and really it has to do with sort of two properties of carbonyl compounds. One is the reactivity with nucleophile, which is what we'll be focusing on today. And the other property that we're going to be learning about particularly as we move through the course into I think chapters 22, 23 and 24 is that there, well maybe I should say there are reactions with nucleophiles let me. Oh we'll keep it as reactivity. All right and the other will be there reactivity as nucleophiles. What do I mean by that? Well the first one is a little bit easier to see and is where we're going to be starting today and indeed in the next few lectures. And that is that the carbonyl group is electrophilic. The carbon of the carbonyl group is electrophilic and we're going to see how nucleophiles can come in and right now I'm just going to draw an arrow not really yet representing flow of electrons to say that nucleophiles are interested in reacting with the carbonyl carbon. The second concept reactivity as nucleophiles we're going to see as we develop the idea of enols and enolates, isomers and related species to carbonyl compounds. And at that point when we start to invoke that reactivity, what we're going to learn is that the alpha carbon, alpha carbon means the one over can react as a nucleophile and again that's not meant to represent the flow of electrons yet just showing the position and maybe I'll go ahead and emphasize that by saying alpha carbon. So in general as you go along from a carbonyl group you'd say the carbon next to it is the alpha carbon, the carbon one beyond that is the beta carbon, one beyond that is the gamma carbon. And here we'll refer to this as the carbonyl carbon. So in its own right this diagram doesn't really say very much but it sort of lays a framework. So let's start to move from this level of abstraction to a level of bonds and structure. And let's start with carbonyl group. And this isn't going to be acetone or any particular carbonyl group. I'm just drawing this as a general carbonyl group. And we'll be good people. We'll write our own pairs of electrons and focus on carbonyl group. So oxygen is more electronegative than carbon. Oxygen has a greater nuclear charge. It pulls the electron forward. In other words the carbon oxygen double bond, the bonds that comprise a sigma bond and a pi bond are while shared electrons while the covalent bond between carbon and oxygen they're not sharing equally. Those electrons spend a little more time at the more electronegative oxygen, the atom with the greater nuclear charge. And so I can represent that in terms of a partial negative charge and a partial positive charge. In other words since the electrons while spending time between oxygen and carbon spend a little more time at oxygen, we shift our charge over to oxygen. There's a partial negative charge. Our carbon is a little bit deficient in charge. There's a partial positive charge. We can also represent this type of structure by resonance structures. And remember resonance structures aren't one or the other but both at the same time to varying degrees or in some cases more than one if you're more than two. And so we can think of the carbonyl group as having a major resonance structure. And also a minor resonance structure in which instead of having a double bond and having a complete octet for carbon and a complete octet for oxygen, we can represent a minor resonance structure as having a single bond with a full negative charge on carbon on oxygen and a full positive charge on carbon. Now I'll bracket these structures to represent that it's, the two of them together we're thinking about. We're not resonating or vibrating or oscillating between the two structures. We're mostly the one on the left and a little bit of the one on the right. This is also representing the type of electron density that you would see in the molecular orbitals for the carbonyl group. The other thing I'll point out is we're going to be focusing a lot on arrows in this course. We'll use them to think about and communicate ideas of electron flow of equilibria and of resonance. And there are different types of arrows that we use to communicate different ideas. The double arrow like this communicates resonance. It communicates that it's both structures. It's not an equilibrium arrow which is two arrows pointing in the opposite direction. And it's not a flow of electrons where we draw an arrow originating at a electron and flowing at something at a once. In other words, originating at the nucleophile and flowing at the electrophile. And that actually brings us to our next element of reactivity and that is the reaction with nucleophiles. Now if you have a carbonyl group and again I'll draw it just as some generic carbonyl group not meant to represent acetone, not meant to represent any particular group and it encounters some nucleophile. Again for now we'll just represent that nucleophile in the abstract. They can react with each other. And so I'll use a reaction arrow to show that we're going from reactants to product. The product of this reaction now can be represented like so where our nucleophile has formed a bond to the carbon. And we can think about how that reaction occurs by thinking about the flow of electrons from the nucleophile, from the thing that has electrons to the carbonyl carbon, to the carbon that wants electrons. In our mind's eye we have in mind a picture where the carbonyl group is polarized and so electrons want to attack as carbon. In the very back of our brain we have a picture like this is very minor resonance structure guiding us and making us think from where the electrons want to flow. And of course we can't stop at this point because if we just left our electrons here now we would have 10 electrons around the carbon. We would have more than an octet. That wouldn't be possible. And so electrons have to continue to flow as electrons are flowing from the nucleophile to the electrophile to the electrophilic carbon in terms electrons are flowing up onto oxygen. And so when all is said and done we formed a bond between the nucleophile now represented by this line or these two electrons and we move two electrons onto oxygen and in turn put our negative charge there. Now as I said at that point I'm dealing with abstractions. The nucleophile here is not meant to be any particular nucleophile. But now let's come maybe to something more specific and in turn this is not meant to be any particular carbonyl group. But let's take a look at acetone and a nucleophile and sort of halfway between reality and an abstraction at this point. And so the nucleophile that I'll draw is hydride. And I think I'm going to put it in quotes. The reason I'll put it in quotes is you essentially never have hydride as an entity. The very end of our discussion here I'll show you an example of an actual hydride with a hydride anion that actually doesn't react as H minus or at least doesn't react as a nucleophile. But for now we'll worry about what our hydride source is in just a moment. For now just think about the abstraction of hydride and we'll have hydride reacting with acetone. And so electrons are going to flow from the hydride from the lone pair to the carbonyl. And again we can't stop at that point. Our electrons have to flow up from the double bond onto the oxygen atom. And so when all is done. Now we have an anion. It's the anion that would have been derived from isopropanol so we call it the isopropoxide anion. And it is a member of the broader family of what we would call alkoxide anion. So if you have an anion that's derived from an alcohol that's equivalent to removing H plus from an alcohol, you end up with an alkoxide anion. So a lot of organic chemistry question. Oh yeah, so does the nucleophile attack when the carbonyl is at its minor resonance structure? Or does the nucleophile cause the minor resonance? All right. I'm going to toss this question which is a good one out to somebody in the class. Does the nucleophile attack when it's the minor resonance structure or does it attack? Or does it attack cause the minor resonance structure? It wants to take a stab at it. Does it attack when it's the minor resonance? Okay, so now we have doesn't it happen in both because it alternates? It says it's a hybrid. A hybrid, yes. So I didn't like the word alternate but you've got the right idea. It's not one or the other. It's both resonance structures at the same time. So it's not like it's waiting for the minor resonance structure. They're both there at the same time. The problem is chemistry is all about monos, about conceptual monos. And the beautiful thing about drawings like this is they're simple. We can wrap our head around. That's super, super powerful. The problem, so that's the plus. The disadvantage is that these models are always incomplete. So there are layers of meaning in the models. And another approach is to look at molecular orbitals and electron density but it's harder to immediately wrap our head around things. The beauty about these drawings is you can scratch them in a stick on the sand or under paper and have an immediate grasp of reactivity. So it's not one, not the other but both at the same time. Now the second half of your question is interesting because of course the bond forming process is one where the electrons do start to approach. And as those electrons are approaching, as the nucleophile is approaching the electron, we're moving the other electrons continuously up onto the oxygen. So in a way this is what you would call a reaction coordinate. We're going in the process from the nucleophile to the electrophile being very far apart and having almost completely a double bond character in the electrophile and no bond between the nucleophile and the electrophile. We're moving the nucleophile into the carbonyl group. The carbon oxygen double bond is becoming more and more like a single bond and getting weaker and weaker until finally as we've gone over that energy of the transition state and down to the products, we've now formed that single bond. So that's the reaction we can have. Other questions? Good question. Should we be concerned with the stereochemistry? Ah, great question. Hang in there. Question, what should we be concerned with the stereochemistry? So let's start at the beginning. So the answer is yes and let's get to that point. All right. So organic chemists love to make stuff. We live and die by making new medicines, making new drugs, having reagents that cause chemical reactions and inventing new reagents. And so this is a huge part of organic chemistry. It's fun because you have an idea in your mind's eye and then you test it out. So two reagents that are used as a source of this, what I would say here is abstract or hypothetical hydride and ion is lithium aluminum hydride, too very popular in long standing reagents. Lithium aluminum hydride and sodium borahydride. Both of these reagents react as hydride with carbonyl compounds, particularly with aldehydes and ketones, which is what we're going to focus on today. The structure of lithium aluminum hydride is an aluminum hydride anion or tetrahydride anion as a lithium anion. The structure of sodium borahydride is a borahydride anion, BH4 minus, like the other is ALH4 minus, and a sodium cation. And you'll notice these structures are related. Boron is above aluminum in the periodic table, so in many ways they have similar properties. They differ in that aluminum is more electropositive than boron. The electronegativity of hydrogen is about 2.2. The electronegativity of aluminum is about 1.6. The electronegativity of boron is about 2.0. In other words, in all of these species, you have the bonds polarized to having more negative charge on hydrogen than on the metal. But in the case of aluminum hydride, they're even more polarized. In other words, aluminum hydride is a more reactive anion. Lithium aluminum hydride is more reactive. And you can see this in the laboratory immediately. If I take a spoonful of lithium aluminum hydride, a great powder and throw it into water, I better get back because it's going to release hydrogen with a big fizz and maybe even catch fire. And if I eat it too much, it'll explode. Zodium boron hydride is a white powder that will sort of bubble in water, but won't react nearly as fast releasing hydrogen gas. And there was a question here. Would NAH also release a hydride? NAH, we're going to come to in a moment. Great question. Let's talk about some reagents and their reactivity first. So in a way, that falls into the category of the exception and we're going to see its reactivity in a moment. So let me take an organic compound. We'll take a simple compound. It's a ketone. It's a ketone with a benzene ring on one side of the carbonyl group and a CH3 on the other side. You might see people write the CH3. You might see them leave it just as a line. Both are correct ways of writing it. The IAPAC name for this compound is one phenylethanone, but nobody is going to call it that. Everyone's going to call it aceto phenone because it's one of these compounds where the common name just really dominates. So I'll write out the systematic name just as a reminder. But again, the common name is going to predominate. And we're going to imagine treating this compound with lithium aluminum hydride. And now we're going to see how it reacts as hydride anion. As I said, aluminum is more electropositive than hydrogen. The bond between them is covalent, but it's a polar covalent bond. And it's one in which we can think of it almost as H minus or in other ways we can think of the electrons as flowing from the bond between aluminum and hydrogen onto the carbonyl carbon, toward the carbonyl carbon. And remember, I use an arrow from the electrons to the thing that wants electrons. I put two little arrowheads on here. It's representing that we have two electrons. And for now at least, I will be good at drawing my lone pairs of electrons and reminding us that we have two lone pairs and we have one more pair of electrons flow up there. And so when all is said and done, we end up with the alkoxide anion. And for now at least, I will be good at drawing in my hydrogen. And in addition to this, we have lithium cation. And in addition to this, we have alH3. And that's where I'm going to stop it at this point, is at the alkoxide anion. And that's how you can think of it, but I'll put a little bug in the back of your mind. In the back of your mind, you can think about the fact that aluminum doesn't have a complete octet. And in reality, this lone pair can now attack one of the lone pairs, can now attack the aluminum and fulfill its octet. So technically you'll end up with an aluminum alkoxide salt. All right, so this is kind of a mechanistic way of thinking about this reaction. So let's go and think about things from a synthetic point of view. So redemic chemists will often write equations as little recipes. Mix this with your compound and then mix in something else and then you get that. And organic chemists are very bad at writing balanced equations. Organic chemists often will just write reactants and products. Question. Is there a conservation of charge? Oops, good point. Thank you. So yes, so our lithium aluminum hydride, we have a lithium cation, an aluminum hydride anion, that's our reagent, the aluminum hydride transfers its hydride. At the end you have your lithium cation, your alkoxide anion, and alh3, which as I said will typically bond to oxygen. Also typically that undergoes further reaction with additional ketones. So often when you're doing the reaction in the laboratory you don't mix one mole of a ketone and one mole of lithium aluminum hydride but you might use two moles of a ketone or even three moles of a ketone and one mole of lithium aluminum hydride. So let me write a reaction as a synthetic organic chemist would. So now I'll be a little bit sloppier in the sense that I'm not going to write in my lone pairs of electrons. We're thinking more like a synthetic organic chemist. Not even going to write in my methyl group. It's implicit over here. And so step one is treatment with lithium aluminum hydride. I'll write it as LiAlH4, but sometimes you'll see it abbreviated as LaH, lithium aluminum hydride. And then I'll write in a second step in this recipe. And I'll write in the step H3O plus or your textbook writes H2O and I'll tell you about that in just a second. And then I'll probably also indicate the solvent that I would use to carry out this reaction. And typically I would carry out the lithium aluminum hydride reduction reaction in THF or in diethro ether. So this constitutes a little recipe. It says take some benzophenone, put it in a flask with some THF or some ether, throw in some lithium aluminum hydride, and then after a while after the reaction is done, throw in some acid or some water. Of course you can't go through one acid, you can't go to the stock room and say, give me a bottle of H3O plus. Look at you funding and say, oh, we don't have any bottles of H3O plus. We have aqueous hydrochloric acid, which of course is H3O plus and CO minus. We have aqueous sulfuric or concentrated sulfuric acid, which you can add to the water to make H3O plus and bisulfate N9 HSO4 minus. So that's a little bit of a short-term for adding an acid that you would get a strong mineral acid like H2O4 H2O4. Now, I think we call this step here the workup. I'll just write solvents and I'll just write workup here. And honestly, this particular one you could do with either aqueous acid or with water. Aluminum salts in water under the warm condition can form tremendous gelatinous things. You've all had lab, you've all shaken the septic funnel. You may have even encountered an emulsion. Who's encountered emulsion? I hate emulsions, don't you? The advantage of throwing in a ton of acid is it dissolves all the aluminum salts and gets rid of the emulsion. You can also add water in just the right way, a little bit of water, a little bit of sodium, a little bit of sodium sulfate, which makes your aluminum instead of gelatinous, makes it granular. So, either of those work for a workup and you'll see things written both ways. The main thing, of course, is that until we add something that provides a proton, whether it's acid, H3O plus aqueous HCl, or whether it's water, we have an alkoxide anion. But after the workup, you isolate your product, the alcohol. And as I said, organic chemists are typically very bad about balancing equations. So, typically this becomes a little recipe. And as I said, I'll just write it explicitly, our workup ends up taking our alkoxide anion, and we have the alkoxide anion plus H3O plus, plus hydroamine, or plus water under the right circumstances, and electrons flow from the alkoxide to the source of protons, and electrons flow from the hydrogen oxygen bond, onto the oxygen. And as I said, we've called this step. Questions or thoughts at this point? Ah, does it always make a secondary alcohol? Good question. If we had an aldehyde, we would get a primary alcohol. Of course, you couldn't have, you couldn't make a tertiary alcohol with hydride nucleophile, because by definition, hydride is going to add in a hydride. Next class, we'll learn about Brignard reagents and Organolithium reagents, instead of adding quote, unquote, H minus, can add an alkover to light, quote, unquote, metal minus, and you'll see how they pervade for, for example, tertiary alcohol. All right, there's a concept that really is useful in permeating your thinking, and that concept is oxidation state. I introduced it last time when I was talking about the carboxylic acid family, and I said in the carboxylic acid family, the oxidation state of an alcohol is, or the oxidation state of the carbon is plus three. In a ketone family, the oxidation state is plus two. If you remember in calculating oxidation state from general chemistry, you play a game where you divide up the electrons, giving them to the more electronegative atom, and then saying, okay, what's the net charge on the atom? If you have a carbon bound to another carbon, you divide them equally. So in a ketone, the oxidation state is plus two. I'll write ketone here. In our product, in our particular alcohol that we've, we've generated, secondary alcohol, our oxidation state is zero. So if you notice, by going from an oxidation state of plus two to an oxidation state of zero, we have undergone a reduction reaction. And the chemical that's done it then, our lithium aluminum hydride, is a reducing agent. It's the chemical or the reagent that carries out the reduction reaction. And there are many different reducing agents. I drew another one. I drew sodium borohydride. And let's talk about that. And I'll give you an example. Since the very astute gentleman asked the question about aldehydes, let's take, and there's primary alcohols. Let's go ahead and take an example of reduction of an aldehyde to a primary alcohol. And so we'll take benzaldehyde. Benzaldehyde is a very nice smelling compound that kind of smells of cherries. It's sort of the flavor of cherry coater, artificial cherry flavor. If you take, for example, sodium borohydride, the reaction would work with lithium aluminum hydride, but I'd like to introduce you to other common reducing agents. And in this case, you can actually run the reaction in a cell that's like methanol or ethanol. I said sodium borohydride reacts only slowly with water. If I tried to run a lithium aluminum hydride reaction in methanol, just like water, it's a source of hydroxylic protons. If I tried to run a lithium aluminum hydride reaction in methanol, I'd be rewarded by the whole thing as best spatter in the face and worst tattoo in the fire. So our product of reaction here is benzalazole. And we can think of this reaction occurring very much like the other reaction has occurred. So here's our aldehyde. Here's our borohydride anion. And the boron hydrogen bond is polarized. It's a polar covalent bond with more electron density on the hydrogen. And so borohydride anion can transfer a hydride adding it as a nucleophile to the carbonyl group. And again, we pick up our electrons onto oxygen. So now we get our alkoxide anion and BH3. And again, I'm skirting a little bit loosely because BH3 doesn't have a complete octet. And so typically it's going to form a bond with oxygen reversibly. Or we can think about it as forming a bond with oxygen. Now the nice thing about running this reaction in a hydroxyl exolvent is you've got this huge, huge excess of methanol. And so methanol can protonate the alkoxide anion. So here we have our alkoxide anion. We're in a ton of methanol. And so electrons can flow from the oxygen of the alkoxide anion to the proton of methanol. We put electrons back onto the oxygen. And after all is said and done in this equilibrium reaction now, driven by the mass action of having so much methanol in it. Now we have our alcohol in metoxide anion. I'm sorry, wouldn't metoxide be more happy without the H or without the H? Great question. Would the metoxide be more happy without the H or with the H? So in general, if you want to sort of keep one thing in mind, the basic rule would be all alcohols have pretty similar acidity. Water, I said to PK, was 15.7. That's sort of at one extreme methanol. It's about 16 ethanol, maybe pushing toward 17, 16 or 17, tert-butanol toward 18. Benzal alcohol is a little bit more acidic inductively. But the main point here is we've got a ton of methanol. Your methanol is 20 or so molar and you've got one molar of compound. So you've got this huge excess of methanol grinding this equilibrium to the right. And then you're going to do an aqueous workup in the end that's going to extract your compound into an organic salve. So you're right. It is an equilibrium. In this particular case, it's okay that it's an equilibrium. But that equilibrium, remember I was talking about PK last time and I said, the thing that we really want to be able to focus on in organic chemists, it does an equilibrium lie way to the left, way to the right, kind of in the middle or maybe a little more to the left or a little more to the right. That's how we think about things. And you're right. This equilibrium lies kind of sort of in the middle. Do you want to run a reaction with a liquid in your project and you react with methanol? Oh, ah. Well, if you've tried to run a lithium aluminum hydride reaction in methanol, the lithium aluminum hydride would probably first react with the methanol. But as I said, make hydrogen so vigorously and so rapidly that it would blow up in your face. So it would definitely react with the methanol. It might also react with the ketone, but I'm not going to try the experiment in the laboratory and see at the end when I wash my face off whether I had any reduced ketone. So in this case, in this case we started with benzaldehyde. And the oxidation state of benzaldehyde is plus 1. And by the time we've gone to benzal alcohol, again it's a reduction reaction. The oxidation state is minus 1. And that's not important in thinking about families because remember I said carboxylic acids and the whole carboxylic acid family, esters, amides, nitrioles, all that entire family is plus 3 oxidation state. They are more oxidized than aldehydes. And then aldehydes are more oxidized than primary alcohols. And you'll notice they go in twos and this is pretty common in organic chemistry. As you change oxidation states almost invariably you end up going into organic chemistry. The reason it's important to sort of keep this in the back of your mind is it helps you focus your thinking. When you change from a carboxylic acid to an ester through a chemical reaction, there's no change in oxidation state. You wouldn't think about using an oxidizing agent or reducing reagent to affect that change. You're changing the same oxidation state. You're changing from a ketone or an ester or an aldehyde to an alcohol. Then you're changing oxidation state and you think about using a reducing agent. If you're changing from an alcohol to a ketone or an aldehyde or an acid, you would think about using an oxidizing agent. There are a ton of high-grade reducing agents. Your textbook has given you some, I'll show you a few others. The general principle, the overarching principle of high-grade reducing agents is that you have a metal hydrogen bond, metal broadly defined, usually as a polar covalent bond where you have M with a partial positive charge and high-grade with a partial negative charge. By broadly defined, I mean that Goron is kind of a metal or a metalloid, aluminum is a metal, and there are many, many others. So the general principle, as I said, with lithium aluminum hydride technically after that first mole of hydride is transferred, technically what happens is the AlH3 reacts with the alkoxide and now this intermediate can transfer again hydride anion to another carbonyl group, which is why you may only use one mole of lithium aluminum hydride for several moles, for two moles or three moles, up to four moles, although typically you wouldn't use it of your electrophile, of your carbonyl compound. Your textbook gives an extremely example of this where you transform, you preform the reagent with three tert buttoxy groups on aluminum and this is a less reactive hydride source. There are two reasons for this. One reason why once you start to put alkoxide on the aluminum, it's less reactive is that the oxygen is electronegative and it's pulling electron density away so there's less of a partial minus charge on hydride. The bond is less polarized. Another reason is sterics, the tert-fuel group is very big and so that big set of tert-fuel groups gets around the way of this. So only the very most reactive carbonyl compounds react with a tetra-tritricerfutaxiome and hydride reagents. The oxygen metals that don't have a full octet can react as a hydride source. Your textbook mentions and we will talk more about in a moment or later lithium, a diasecudal aluminum hydride, abbreviated dival age, sometimes just dival, you will see it. And again, you have a polarized metal bond. Typically what happens in a dival reaction is the aluminum which doesn't have a complete octet first coordinates onto an oxygen or onto a nitrogen to get a complete octet and a formal negative charge on aluminum and then finish the hydride. I'll just show one other reaction. Sodium cyanoborohydride. It's another hydride reagent that's less reactive. Cyanogrups are electron withdrawing and so sodium cyanoborohydride is less reactive than sodium borohydride. There's a big alphabet soup of different reagents out there but you'll notice that the general theme in all of these reagents is that a metal is bonding the hydrogen. So the various student question was asked about sodium hydride. And that sort of is the oddball exception. Sodium hydride, NaH, actually reacts as a strong base not as a reducing agent. And there are a couple of reasons for this. All of the reagents I showed over there and the sodium borohydride and the lithium aluminum hydride have covalent bonds between metals and hydride. Sodium is even more electropositive than aluminum. Its electronegativity is about.9. And so the sodium hydride is actually an ionic compound and it's pretty darn insoluble in organic solvents. As a result you never really have a chance to have soluble hydride and it doesn't get into and react as a nucleophile. Plus because the bond is very ionic and because hydrogen is relatively electropositive compared to say chloride anion, sodium hydride is a very strong base. And so in general if you take sodium hydride with almost any source of protons, water or say methanol, it reacts. And so if I throw sodium hydride into say methanol, it reacts to form sodium methoxide and hydrogen gas. And so I was talking about acidities before and saying well you don't typically calculate things but you'll keep in mind where an equilibrium lies based on the difference in pKa's. Hydrogen has a pKa so this is an acid base reaction. Methoxide anion reacts with methanol to give methoxide anion. I've just shown it as NaOCH3 but of course that's Na plus OCH3 minus anionic compound plus hydrogen gas. So this is an acid base reaction. The methanol is an acid pKa about 16 or 17. The hydrogen is an acid on this side of the equation. Its pKa is about 35. It's a very weak acid whereas methanol is just a weak acid so that reaction, I won't even write it as an equilibrium. The reaction lies way, way, way to the right. pKa of 35, pKa of 16, difference of 19. If I were to write an equilibrium constant it would be 10 to the 19th just massively on the right. So that reaction ends up reacting as a base. Good point for some questions. The sodium hydride reacts bilimply in water. Absolutely. If you get water on it you see a beautiful bright orange flame. The big danger, if you were to take a scoop of it and throw it in water you'd get a big flash of fire. The big danger in the laboratory is when you're weighing it out you spill a teeny little bit and later on you're cleaning up and splattering acetone and water around. At that moment when the water hits an acetone is splattered around all the acetone and all the solvent goes up in fire. So when I work with sodium hydride what I'll generally do is get a wad of wet paper towels and wipe down my work area and I might see a little flash of orange. And that flash of orange under the big wet wad of paper towels doesn't do any harm and it prevents my feet from having to fire over and lighting lots of acid. How do you find oxidation state numbers? Okay great question. Alright oxidation state. State two examples here. We'll start with an extreme example. Carbon dioxide and methane. Carbon has four nuclear charges. We have eight electrons but we're going to play a game here. The game is that we give all those electrons, I'll even be good and write my Lewis acid structures, or write my Lewis electron dot structures. We play a game that we give all those electrons to oxygen and leave none for carbon because oxygen is more electronegative. Because we have a net four nuclear charge the oxidation state is plus four. Methane, carbon is more electronegative than hydrogen so we play the same game. But now we give our electrons to carbon and so we have plus four the nuclear charge minus eight the four electrons and our net oxidation state is negative. Now final, last case. Would the oxygen also have a negative charge? Yes the oxygen, I wasn't counting on the oxygen. The oxidation state of oxygen is negative two here because you have six nuclear charge minus eight electrons and the oxidation state of hydrogen here is plus one. I'm only counting for carbon. Why does carbon go from plus four to minus eight? You take the nuclear charge minus the number of electrons. So you take your nuclear charge and calculating oxidation state plus for the outer valence plus four. You have the one S which you don't count and two of the nucleons, two of the carbon ions. You count carbon spore across in the periodic table so carbon atom is carbon nucleus plus four electrons but now in calculating oxidation state in carbon dioxide we're taking all those electrons away. In methane we're giving it four more electrons. And in ethanol, let's take our last example ethanol and we play the same game here. We'll divide up our electrons in ethanol and for the metals we share and share a light. And so for ethanol our carbon is, this is our primary alcohol, our carbon brings four nuclear charges. We take away five electrons and we're at negative one oxidation state. Now let me tell you honestly, I am not generally calculating oxidation states in my head but it definitely is a romantic penis permeates my head. In fact I think in broad terms I think acid oxidation state, aldehyde oxidation state, primary alcohol oxidation state. Then I realize well ketones are shifted by one, secondary alcohols are shifted by one but they go in care. So when I'm thinking about stuff it's definitely not this calculation. This is just the underpinnings of my thinking. When I think about a reaction of say an alkene and a hydrogen I think carbon carbon jubbubon now gets replaced by carbon carbon single bond plus two carbons bound to hydrogen. That's taking my oxidation state of each carbon down by one or taking me down by next to a bond oxidation state. When I think about say forming a general diol from an alcohol I think oh I'm going up. And when I think about hydrating an alcohol I realize one carbon is going down, hydrating an alkene to an alcohol, one carbon is going down, the other is going up. They balance out. So for the soft side one why does the CO have a high electron? Why does the CO here? Sorry the carbon, how come the carbon bond? Bookkeeping, when you have a carbon carbon bond you divide equally. You give one to each carbon in bookkeeping for oxidation state. Alright so that's what permeates my thinking on oxidation state. And as I said the biggies become the acid family, the aldehyde family, the alcohol family and then the ketone and secondary alcohol. Alright so I want to talk a little bit about reactivity toward nucleophile, toward hydride and other nucleophile. In a very good generalization, again there are always exceptions to generalization, but a very good generalization is that aldehydes are more reactive than ketones. And ketones are more reactive toward nucleophiles than carboxylic acids and esters. So this means for example if I were to mix a mole of sodium borohydride with a mole of an aldehyde, a mole of a ketone and a mole of an ester, I would expect the aldehyde to react first. In other words if I monitored the reaction by thin layer chromatography, the first species I would expect to disappear would be the aldehyde. So if I wanted to give a particular example just so I don't put this in the abstract, let's compare acetaldehyde, acetone and let's just say methylacetate CH3CO methoxy. So why can we think of this this way? Well think about our resonance structures. So you think about the carbonyl resonance structure and you'd say okay we have two resonance structures that we need to worry about in general for a carbonyl group. One resonance structure, the major resonance structure in which the carbonyl has a complete octet and the minor resonance structure in which we have separation of charge and the carbon doesn't have a complete octet. Now in the case of acetone we have two methyl groups here. Those methyl groups are stabilizing by electron donation. When you learned about carbocations you learned about hyperconjugation. You learned that a tert-butyl carbocation is more stable than an isopropyl carbocation which is more stable than an ethyl carbocation. So the carbon group is a tertiary carbocation which has three alcohol groups donating electrons by hyperconjugation feels less pain from that positive charge than a secondary carbocation and primary carbocation. The same principle over here. When you have alcohol groups on both sides of the carbonyl, that carbonyl is less electrophilic. It is more stabilized by electron donation. When you have an aldehyde like acid aldehyde it's more reactive because you have only one alcohol group stabilizing and if you have the one aldehyde with no alcohol groups from aldehyde it is extremely reactive because there is absolutely no stabilization of the partial positive charge. In the case of an ester you get a little bit of extra stabilization here because you can write a second resonance structure and I'll just go ahead and complete my lone pairs here. You can write a second resonance structure like so that provides an extra special stabilization of your positive charge of the carbons. So you get one additional resonance structure. I saw a question back. The question was if you have an aldehyde with a secondary carbonyl. So the question was very clever. If you have an aldehyde could you have a high drive ship? And the answer is that the partial positive charge is not enough on its own to introduce a high drive ship. However there are certain reactions. For example the pinnacle rearrangement where you can go ahead, actually not the pinnacle but there is another rearrangement where you can go ahead and push a high drive in once you've protonated the carbonyl. So the short answer is not for an aldehyde per se but your thinking is actually self. Another question. Can you explain how it's stabilized by electron donation? So you actually write a double bond between the carbons and then you write H plus. It's that exact same thinking. Oh I wouldn't go so far as to write such a structure. So if basically think of it as each of these CH bonds. Remember the hydrogen is more electropositive than carbon so each of these CH bonds puts more electron density on the carbon which inductively donates it in. So I'm going to take one last question and then I want to wrap up a couple of concepts that came up. Okay of course you asked there would it be better if the positive charge is on the carbon instead of the oxygen? All different resonance structures. Ah your question. Is this a better resonance structure than this? And the answer is no. And the reason the answer is no in terms of contribution is we have two competing ideas. We have the idea that atoms want to have complete octets and the idea that in general when there's a choice put the electrons on the, put the positive charge on the more electropositive the less electronegative atom. But the one that wins out in terms of being more important is octets. And so in an ester there are three different contributing resonance structures. That resonance structure is a little bit more important than the other resonance structure but they all contribute. They all stay on. Alright I want to bring up a concept that I asked about at the beginning and I promised to get to it at the end. And that was the concept of stereochemistry. So when we carry out a reduction reaction, when we for example take our benzo phenome and we treat it with lithium aluminum hydride and then we do a workup with water or aqueous acid as I said it's okay to use either. And I write this alcohol as our product. Even though I have written that molecule flat there is a stereogenic center in it. The carbon is a stereogenic center. By that I mean there are four different substituents attached to that carbon. It doesn't matter whether I draw it or don't draw it, it is. Just like it doesn't matter whether I tell you my middle name or I don't tell you my middle name, that S stands for something. So whether I write it or not we can have one enantiomer, we can have the other enantiomer and unless I do something special to only get one, unless I bring to bear some source of chirality I get both enantiomers. It takes chirality to make chirality. If I take an achiral reducing agent like lithium aluminum hydride or sodium borohydride and I take an achiral ketone I will get both enantiomers in equal amounts as the racemac. All of the proteins in your body, all of the amino acids in your body with the exception of glycine, all of the sugars in your body, all of the nucleic acids in your body. All of the lipids in your body are chiral. And in general, chiral molecules of one-handedness interact in a different fashion than the other. In other words, if I go to shake your hand and I instead present my other hand they don't fit as well together. And for that reason there is a tremendous interest in synthesizing chiral molecules of just one chirality as drugs and for many other purposes. So often the biological activity of one enantiomer is different than that of the other. In medicine one may have a desired effect, the other may be toxic. That's one of the reasons why many of the form babies were born due to polyvase where the enantiomer, which is given to combat nausea and pregnancy in the 60s, the enantiomer induced both effects. So in this reaction if we take, and your textbook focuses on one particular reagent called the CBS reagent. In part because the author of your textbook got her PhD with Nobel Prize winner E.J. Corey who invented this reagent. But in general there have been many sources of chiral hydride reagents that have been invented. And the general goal is instead of making one enantiomer and the other in equal amounts, you get just one enantiomer. In your textbook develops the idea of which one you get at this point in the thinking. It's not so important. But realize that if your man were a ketone and I came forward with this hand bearing a hydride, I would have transferred that hydride to the pump. And if I had come forward with this hand bearing a hydride, I would have transferred it to the back of your hand. And just in the same way we can bring in a hydride from one face of the carbonyl, from the front face of the carbonyl, to end up with the hydrogen pointing outward. To end up with the R stereochemistry or with the hydrogen coming from the back face of the carbonyl. In this case, end up with the S stereochemistry. Now I've written just one enantiomer. That's not quite true. It's very, very hard to get just one enantiomer. The molecules in your body, the enzymes, are so big and so good at engulfing substrate molecules that they're very good at generating just one enantiomer. In general, chemical reagents generate mostly one enantiomer. 99% is very good. 99.5% is very good. There's a magic number that Johnny knows for kilocalories per mole. And what is that number? 1.36 takeouts per mole at ambient temperature, about 1.4 kilocalories per mole that corresponds to a 10 to 1 difference in rate constant or a 10 to 1 difference in equilibrium constant. A parallel reagent that fits with 2.5 kilocalories or 2.7 kilocalories better on one face than another can select 99 times as good. Now I want to finish up with one last concept here. And what your textbook is talking about is really the big ideas here. And this is one of the problems I have with your textbook is sometimes, sometimes in trying to present the big ideas, you end up getting lost in the little pieces and never seeing the bars. So I'm just going to present one sort of more big idea that ties into the same thing. Imagine for a moment now, and this is in a way a little easier to wrap your head around than enantiomers and it doesn't really involve moving hands to demonstrate it. Imagine for a moment that we have tert-butyl cyclohexanone and the tert-butyl group is on one side. I've drawn it as a wedge. I've drawn it coming out. And we treat this with sodium borohydride in ethanol. Now the hydride can add either from the front face or from the back face. If I add from the front face, I get the OH pointing down and the hydrogen pointing up. If I add from the back face, I end up with the OH pointing up and the hydrogen pointing down. And we call the relationship, the stereochemical relationship between those two molecules. Diastereomers. And now even in the absence of any sort of chiral reducing agent, we don't get equal amounts because these two molecules aren't equal. We happen to get the 80 to 20 mixture. The mixture ratio isn't so important, but it's a little bit easier to see if we go ahead and we look at drawings. So the tert-butyl group is very big. I'm going to draw a chiracyclohexane. Remember, cyclohexane likes to sit with a large group equatorial. So here's our cyclohexanode. And now we have two ways that hydride can come in. Hydride can come in from the top or hydride can come in from the bottom. If hydride comes in from the top, we end up with this diastereomer, the transdiastereomer. And if hydride comes in from the bottom, now we end up with the axial LOA. We end up with the sixth diastereomer, the minor diastereomer. And the last thing I'll point out is organic chemists are control frees. When we synthesize molecules, we want to have absolute control of what we make. So naturally, for the same reason I talked about enantiomers, you want to make the right enantiomer of the drug. You want to make the right diastereomer of the one that you need. And so naturally, if nature did an 80-20 mixture of cis and trans, of trans and cis diastereomers, organic chemists have come up with ways for flipping to heat or death all of the cis. I'll see you next month and have a good weekend.
This is the third quarter course in the organic chemistry series. Topics covered include: Fundamental concepts relating to carbon compounds with emphasis on structural theory and the nature of chemical bonding, stereochemistry, reaction mechanisms, and spectroscopic, physical, and chemical properties of the principal classes of carbon compounds. Index of Topics: -1:00 Reactivity with Nucleophilic -4:08 Resonance in a Carbonyl group -8:41 Nucleophiles and Carbonyls -18:09 LiAlH4 and NaBH4 -26:29 Example Reaction -32:38 Reduction -44:10 Hydride Reducing Agents -48:57 Sodium Hydride -54:02 Oxidation State -1:00:14 Reactivity Toward Nucleophiles -1:08:44 Making Racemic Mixtures -1:12:38 Chiral Hydride Reagent -1:16:05 Tert-Butyl Cyclohexanone Example
10.5446/19406 (DOI)
Monday, Wednesday, Friday, classes end up being 10-11, 11-12. I've kind of split the hour from 10.30 to 11.30. But honestly, if you want to try to see it other times, come on by my office. There should be no doors usually open. There shouldn't be an excuse I can't make to office hours. In terms of getting a touch with me this way, patch me after class or during my office hours, particularly for questions involving organic chemistry where there are structures involved, it's very hard to communicate about technical matters by email and just honestly, they're too good at checking my email. Let's see, the other thing, if you, the other people who are going to be very, very important to you in the class are teaching assistants, Johnny Pham and Kim Lee. And I picked two of the best graduate students from my laboratory to serve as teaching assistants. Johnny and Kim, do you want to stand up? So, Johnny and Kim are going to be handling the discussion sections, and so you'll get to know them in the various discussion sections for the course. They've set office hours on Wednesday and Monday, and they meet right in the area outside of my office. So you'll be able to meet with them, and I posted their email addresses here. So, the textbook for the class is the Smith Text, which you've been using. I won't go a whole heck of a lot into it. I think it's a pretty good book. I'm going to put emphasis on various parts in the lecture. The break up to me, you'll get a feeling for what I think are some of the most important aspects of the book. Some of the material, I'll sort of final directly out, but I think they have a really good way of liking things. Some of the things I'll pull from other notes of my own, you'll get a feeling for my perspective on them. Ultimately, what I want to be doing with them is sharing my perspective on the Smith Text, which I really love and am passionate about. Organic chemistry is so central to life and to all of its functions. Johnny and Kim are both earning their PhD in organic chemistry and are working on health-related problems. Johnny is working on how to understand his research, how to understand and control protein aggregation with Alzheimer's disease using organic chemistry. Kim is working on protein interaction in cancer and in HIV transmission, again, using organic chemistry. The thing that we're going to learn in this class is central understanding all of life's processes and in terms of developing new medicines. The textbook for the class, as I said, is pretty good by now. Probably none of you are going to be doing this, but if you want to get the electronic, if you're coming in, say, from having been in a different quarter elsewhere and you want to get the electronic version, that's available as well. Now, organic chemistry classes are really only a whole piece of the picture. The biggest picture for organic chemistry is not reading a textbook. It's not just coming to class. That's sort of the basis. But the real part is active learning. And organic chemistry, in particular, you learn by actively processing problems. One of my developments in this section is I can't do what I've done in the honors class. The honors class has students get rated feedback from the GAs. It's also a much smaller class. And it's really just so incredibly valuable. You're working and wrestling with a problem set in a deadline to have to actually work the problem in your set. And the other thing, of course, that's wonderful is deadlines. I hate them, but I love them for myself. I mean, it keeps me on focus. And this is, of course, one of the greatest wonders that I've ever done in the past. It's easy to fall behind as a class. And so what I've done is the next best thing that happened with Johnny and him, where homework is signed into individual. And that is you won't have electronic homework, who's that for the work, I know. How many of you have used this in previous quarters? So most of you are familiar with this system. This has been the first year I've adopted this system. I consider it to still be a work in progress. This is the first time. There's a lot of junk out there. I've been watching for years with textbook companies coming up with their own quick multiple quick. The first point, I think it's getting close to thinking of life-organic plans. It's not perfect. It's a little clumpier on the implementation than I'd like, but it's a baseline. It's a starting point. On top of that, we're going to have problems that you work and present in the discussion section. And there are homework problems which, alas, are too much sort. Have the answers key with them so you can always check yourself. But I know, I know, I know there's this temptation when you're working problems to look at the problem, say, oh, I understand it, or I think I understand it, then look at the answer key. And that is such a short circuiting to the learning process. And so I urge you, I beg you, if you want to master the material, don't do that. Actually write out the answer, commit, and then go ahead and look at the answer key. And I know it's hard to have the result. So, all right. So you have the website for the course, and let's see. So we have discussion sections for the class. As I said, we're going to be working the problems, working problems in most of these. I've made them match up to the chapters in the course for running through chapters 19 through 25, and then we're jumping to carbohydrate in 27, and then the last week we'll do some special topics from amino acids and from some of the chemical chemistry. And so I've matched up the discussion sections to them. You need to be enrolled in a discussion section. It's best to go to the one you're enrolled in, but if you can't make it to the one you're enrolled in, there are other discussion sections you can go to. It's a little confusing how I've juggled things, because we miss Monday discussion sections. We're going to hit the ground running on Tuesday. Discussion sections in the first half of the course are going to run Tuesday to Monday, Tuesday to Monday each week. Then at the midterm, we're going to switch. We'll have a block of discussion sections from Wednesday to Friday, right after the midterm, which will be going over the midterm. I urge you to come to it. It's a great way to learn about things that you didn't understand. And then for the course after the midterm, our discussion sections will be running Monday to Friday, Monday to Friday, and if you're in the Memorial Day one, you'll just pick up one of the others. If that sounds confusing, don't worry. I've put a link here, and you can go ahead and see the schedule for discussion sections so you never miss out. So that's just on the syllabus website. Friday had two discussion sections that had very low enrollment, and so we closed those discussion sections. I urge you to come to the, I think it's the 12 to 1230 on Friday instead, but if that doesn't work with your schedule, just pick another discussion section. All right. This is the first time that I've taught this particular section, and so I've set up our schedule in advance. I think it's all going to work, but you should check the website just in case we make any changes in the scheduling. So I've set up all of our reading assignments for the year up here, and I've set up our first homework assignment and its deadline, and then others I've set the deadlines, but I'll be getting the problems up there. The problems should be up about a week in advance. If you're not seeing the problems about a week in advance, send me an email, and I'll let you know if there's anything wrong with the posting. Sorry. Like for the homework assignment, some of them say not to be submitted. Ah, great question. So the question is, for the homework assignment, some of them say not to be submitted. So the Sapling one supports you to submit online. I would love to be able to see your paper written out of homework. In fact, you would make me incredibly happy if you come to my office, if you ever don't understand something, and bring me a big sheet of sloppy, messy papers with pencil scrolls with all of your efforts on the homework. If you come to my office, bring your notes. I don't know if you don't understand. I want to be able to help you. I want to see your homework. But as much as I would love for Johnny and Kim to be able to actually bring their homework, they can. So the second best thing to having homework that's actually due to hand in is problems from those textbook homework assignments are going to come back to you on the quizzes. So the quizzes, you're going to have seen all of the problems before. The quizzes are going to have problems that are taken directly from the discussion section and from the Smith-Pomer problems. The discussion section problems won't have answers. You won't be able to get them online. So you've got to go and visit the discussion sections to see the problems and to discuss them. Alright, homework's always a conundrum, particularly in the context of the issue of academic honesty and reading. I've really thought before you about this issue for homework because I see it as different from the exams. My hard-to-feeling opinion on homework is I want you to learn by doing the problems. Some people like to work problems alone. Some people like to work problems in group. My primary feeling is learning. And so I've really set up the network. If you get a problem wrong, it poachers you. You get a chance to do it over. There's just a small penalty. So for working in groups, my philosophy is it's okay to have real peer learning to be learned in every community. What's not okay is to just be approving a person's answers and then to be mindlessly typing them in to the standpoint. That's not learning. That's not teaching. If you're actually communicating and understanding from a peer, you're learning how to communicate. You're better reinforcing the ideas in your mind and your peer, in turn, is actually learning. And next, the attitude for working in groups that I would see on the homework problems. Alright. So, got to come to the lecture section. You're going to miss things if you don't. I've set up this course on video. Videos for the course will be available if you have to miss the lecture or better still, if you want to miss the lecture. You can download them. We're going to get them on YouTube. The open courseware site produces the I. The I tunes used so there will be lots of ways to access the material for review. But come to the class. Alright. So, quizzes. We have six quizzes. As I've said, the quizzes are going to come directly from the homework assignments and from the discussion section problems. The quizzes are on the dates that I posted here. We don't have make up quizzes. We drop the lowest quiz. Any quiz that's missed counts as your own. I think that we drop the lowest quizzes. Quizzes are returned through the electronic thingamajig here. I think you're all familiar with electronic exam return. Yeah. Yeah. So, you'll get your quizzes back through that. Quizzes count for 20% of the grade. The midterm exam, which is on Tuesday, May 8th and covers chapters 19 to 22, is on. Counts for 25% of the exam. The final exam is on June 12th and counts for 45% of the course and the homeworks count for 10% of the course. There'll be a seating assignment chart for the midterm and for the final exam. I won't have seating assignments for the quizzes, although I appreciate it if you try to spread out and choose an empty seat without a neighbor if possible. You do need to bring a picture ID. The UCI ID is the best thing. A driver's license would be the alternative for the midterm and for the final exam. You'll be passing them down the aisle and the DA's will be matching your face with the ID and the exam, you know, the assigned seat. And during the exams, you need to have that. All right. All right. Academic honesty. You all know a cheating is copying off your neighbor, getting materials in an appropriate way. Don't do it. It is fatal. You will get a zero in the course. A note will go into your file and you will be able to go on with things that require this. Two students in my previous class of 1051 received a failing grade for cheating. And one friend of them who wasn't an enrolled student but colluded received a note from his class. So don't do it. Cell phones. We all have them. We all love them. We check our email on them. We get text messages. Take them away in class. Away. Off. No buzzing. You vibrate if it doesn't distract you. I find my own distracting if it vibrates because it means, oh, there's something in my pocket that I now need to know on. Just turn it off. Don't get me cell phone. If you don't. If you're distracted by your cell phone, I will send you out. All right. By now you probably know about enrollment in these large classes. The professors don't handle any of that. It's done online and through the undergraduate office and there's all the contact information. Tutoring. Best place to get help. Me, Johnny, Cam, office hours, discussion section, their office hours coming by. If you want to get some help through tutoring, there's LARP. Chemistry also makes tutoring services available for free and they'll have information that's posted. And then I already blasted you with an email. I thought this was actually pretty cool what the chemistry department was offering. So while they're focusing on this particular homework or that particular homework they recovered and all the topics and I feel like that's pretty good. That's important here. So anyway, let's see if there's anything else that I want to talk about. I think that pretty much covers it. Oh yeah. I'll be giving you some software. I paid about 700 bucks for this software. It's great for visualizing molecules and they said I could give it to all my students and they said they could use it for research. It's really cool for looking at molecules. We'll use it later on to look at sugars and understand some of your theory of chemistry. And so during one of the discussion sections, the TAs will be working with you to help teach you how to set that software. Who has a laptop computer or portable device in the class? Good number of you. Bring those to that discussion section. That will be the week of, they will help you set up on your computer. That will be the week of April 17th through April 23rd. Then we will remind you again. Alrighty. Well, I think that about covers it. So, questions on the syllabus. So of course. So our discussions are running. The questions went through the discussions starts. So we'll start on a Tuesday and run through Monday. So Tuesday, Wednesday, Thursday, Friday, Monday will be the same as the first half of the course. Up through the midterm and then after the midterm will have three Wednesdays and midterms on a Tuesday. So Wednesday, Thursday, Friday will be the same as the first half of the course. So the quiz schedule. The quiz is, check the syllabus I believe there on Thursday, the first half of the quarter and Tuesday the second. Alright. Other questions? Well, I'm really enthusiastic about teaching this particular course. This is in my opinion the most exciting quarter of organic chemistry because we get to learn all the good stuff. All the stuff. We've got to leave all this groundwork in place. You've learned about stereopenistry. You've learned about alkane, and alkene, and alcohol, and texting on our cell phone. So you've learned about all of this incredibly, incredibly cool stuff. And now we've come to what in my opinion is the richest, the most wonderful stuff in organic chemistry. And most of the class, seven weeks, is going to focus on carbonyl chemistry. Broadly defined. We are going to start off with carboxylic acids. And the carboxylic acid family. We're then going to work on to aldehydes and to ketones. Aldehydes and ketones have just a fantastically rich chemistry. They have chemistry of reactivity at the carbonyl group. They have chemistry of reactivity at the adjacent carbon. Alphabetum saturated carbonyl compounds have chemistry of reactivity of the alkene part of the molecule. Carboxylic acids. We're going to start off. Chapter 19 is kind of funny. It's sort of just a little book of throwaway chapter in carboxylic acids. Just the taste of it. But carboxylic acids constitute a big and important family. And so we're going to learn about members of the family. We're going to learn about esters and amygs. And then we're going to move on in about the eighth week of the course to talk about amines. And then we're going to spend the ninth week of the course talking about carbohydrates, sugars. And finally, if everything goes according to schedule in the tenth week of the class, we'll have some selected topics from chapter 28. Chapter 28 is on amino acids. And so it's sort of a refrain of carboxylic acid chemistry. And amine chemistry. We'll talk a little bit about peptides and their synthesis. And if everything goes according to plan, we'll spend maybe our last lecture talking about chapter 26 and some really cool organometallic chemistry that I want to show you. We won't have too much emphasis on this material, but there'll be one homework assignment from Saffling that's due to help reinforce that material. We're not going to need to clean for the intensity of that because we won't get a discussion section on it. All right. Well, on that note, I think what I'd like to do is to plunge right into chapter 19 carboxylic acids. So carboxylic acids are really important compounds. You encounter them literally every day. One of the simplest carboxylic acids is acetic acid. You encounter that on your salad dressing from vinegar. You get to taste your chemicals. You know that carboxylic acids are kind of tart, kind of sour, that some of them have some strong aromas to them. They're volatile. You encounter them also perhaps in the morning in your orange juice, or citric acid. Citric acid is actually a tricarboxylic acid. Citric acid has three carboxylic acid groups, two on the end of the five-part exchange, and one off of the middle along with the hydroxy group, so that's what we would call an alpha-hydroxy acid. You might have heard of alpha-hydroxy acids. Anyone? Face cream, stuff that you put on your face to go ahead, maybe you will peel or something for your skin. But you see it advertised in the cosmetic chart with alpha-hydroxy acids. Lactic acid and milk is another alpha-hydroxy acid. Due to the inductive effect, they're a little stronger than regular carboxylic acids. The amino acids are also carboxylic acids. Your chapter gives a nice coverage of them, and as I said, we'll be coming back to them in chapter 28 in the last week. So I'll just draw one of these here. I will draw the simple amino acid alanine. I used to turn alpha-hydroxy acid. Alpha means the position next to the carboxylic acid. You'll also hear amino acids refer to as alpha-amino acids, that's because the amino acids are alpha-amino acids. So carboxylic acids are important, and they're ubiquitous. And the defining feature of carboxylic acids is the carboxyl group. So we have a general structure. I'll kind of write out all of the lone pairs of electrons and all of the atoms here. In fact, let me be even more explicit. I have trouble getting in the habit. I'm so used to writing skeletal structures, but I will write all of the atoms here. So this is a carboxy group, the functional group that defines the carboxylic acid. The carboxy group is sometimes referred to as a carboxyl group. So you'll probably hear me referred to it both ways in this class. Now, you've already seen that I can write carboxylic acids in a number of ways. I wrote it as CO2H over here. So in addition to seeing structures explicitly spelled out like this with or without the carbon, you can see them written as RCO2H or RCOOH. These are all representations of the same thing. Compounds containing the carboxyl group fall into the broader family of carbonyl compounds, which includes ketones and aldehydes and so forth. So this is the broader family. Much of the reactivity that we see in the carbonyl group of the ketones and aldehydes, which we'll be talking about later, you get in the reactivity of carboxylic acids in their family members. So one of the things that I think students get awfully caught up on is this whole issue. And it's really important to be able to understand the anatomy of something. In other words, to recognize when we look at a molecule like citric acid that I just added up, oh, there's a carboxy group in the molecule. It contains a carboxy group. It is that looking at a greater level of depth. And the way I will also point out comes from drawing it, which is why I said writing out the whole word, act as we were, is so important. And yet it is so easy to lose the forest from the trees and naming molecules and just start to say, oh my God, I remember, do I alphabetize di-methyl under D for di or M for methyl? Do I put methyl before methyl because it has an ear and after because it's bigger? It's so easy to get caught up in that. And the fact that one thing goes on for pages and pages of gums lecture that it's difficult to see the forest from the trees. So I'm going to talk about what I see as the forest from the trees on the nomenclature carboxyl. You name them as the name of the alkane chopping off the E plus OIC acid. So very simple. If I have a carboxylic acid that has six carbons in it, one, two, three, four, five, six, the alkane that it would have been derived from is hexane. And so this molecule becomes hexanoic acid. The molecule that I drew on the blackboard before and said its common name is azetic acid is formally known as anethanoic acid. So I got a great question by email last night. And the question was how much do we have to know about it? Now some acids have names that are so widely used that you're going to never hear anyone referring to their binauristic anatomy. I doubt anethanoic acid would ever roll off of my tongue voluntarily or at least outside of the context of the vandectic situation because everybody calls it acid. Another one is a perfect example where just about nobody would refer to it by the common name is this guy. Now on the underpact name, what is a one-carbon? Acid one-carbon is methan. So its systematic name is methanoic acid. And yet you will invariably hear it referred to as formic acid. And it's its name from ants because ants have formic acid in their pipes. And if you distill and indeed the way it was first isolated was to put it in a place much like UCI which is loaded with ants, the first way that it isolated formic acid was to throw ants in water and steam the still out the formic acid. And since ants in Latin are formis, they ended up calling the after-tortions formic acid. And of course it's often the simplest compounds that have these historically driven common names because they were discovered so long ago. Alright. So the carboxylic acid is one of the highest ranking functional groups in naming. In other words, it ends up dictating the name of many compounds. For example, if we have a carboxylic acid that also has a hydroxy group on it, we don't name it as the carboxylic, as the alcohol, we name it as the carboxylic acid. So this is for hydroxybutanoic acid. If you have a ketone group on the chain, like so, we would call this three oxo-butanoic acid. And we would name it after the 1, 2, 3, 4 carbon chain molecule before carbon chain acid. Like so many molecules, this has a common name. That common name happens to be acetoacetic acid. If you have two carboxylic acid groups at the ends of a chain, we call it a dioy acid. Since there are two. So this six carbon chain molecule is hexane dioy acid. You're going to encounter it in the discussion section this week. So hexane dioy acid is also referred to as diphtheic acid. It's a component of nylon. Question? Yeah, sorry. Is that dioy acid or dioy acid? Di-o-wick. So it's H-E-X-A-N-E-D-I-O-C acid. D-o-wick. Pardon me, thank you. D-I-O-I-C acid. Thank you. Good catch. All right. The last sort of class that I'll just talk about in general is if you have benzene, then it's a benzoic acid. And so I'll just give you one last example. If we put a chlorine off of our benzene, this would be P-chloro-power-chlorobenzene, I would guess. Okay. I have a question. Do carboxylic acid make really good hydrogen bonds? Great, great question. They do indeed. And thank you so much for leading us into our next topic, which will be the physical properties of carboxylic acid. So carboxylic acids boil a little higher than you might expect for compounds of their size. Acetic acid is a little molecule. It just has two carbon atoms and a couple of oxygen atoms. And yet it's got a high boiling point. It has a boiling point of 118 degrees. And I borrowed this example from your textbook because I thought they did a really nice job of explaining things. So if you look at a comparison, so it's a liquid, I think we would all expect something with a boiling point of 118 degrees to be a liquid. Unless of course it were solid that might melt below 118. If you compare a molecule about the same size, let's say butane, butane is a gas. And it goes at zero. Molecules have boiling points above absolute zero because there are forces that make them stick together. But on your hand, liquid helium boils pretty darn close to absolute zero. And the only thing that helium has are Van der Waals interactions. Remember spontaneous dipole-induced dipole interactions that make the molecules stick together. But in terms of get up to hexane, to butane, of course you've got a lot more molecule and a lot more polarizability that can give rise to interaction. So butane has Van der Waals interactions holding it together. It's about the same size and yet the boiling point is a lot lower. If you go to a molecule like butanol, or let's go to propanol, for example, they get about the same size, about the same number of heavy atoms, about the same molecular weight as a seedic acid. Butanol, propanol, has a boiling point of 97 degrees, so it's lower, 97 of course these are all Celsius, so it's lower than a seedic acid. You've got Van der Waals interactions. You've got dipole-dipole interactions. In other words, you've got a dipole and the CO bond within the OH bond and that can make the molecule stick together. And you've got hydrogen bonding because the OH groups can hydrogen bond the molecules. And so, collectively those interactions bring the boiling point of propanol way above almost 100 degrees above the boiling point of butanol. And yet, not as high as a seedic acid. So hydrogen bonds are clearly worth something. How long do you think about separating them from, say, the dipole-dipole component? Well, we can look at an example of a similar molecule that doesn't have any hydrogen bonding. So we can look at propanol. Propanol, again, is about the same molecular weight. It's got the same basic number of heavy atoms for heavy atoms. It has a dipole in it and again it has an hydrogen bond. The dipole in point is 48. It's a length, just like propanol. And yet, without the hydrogen bonding, the dipole in point is about 50 degrees lower. So we have annuals of 9.9. So there's something really, really special about the hydrogen bonds in the seedic acid and in carboxylic acids in general. Carboxylic acids love the hydrogen bond together because they can form a very nice hydrogen bond really dynamic. In the hydrogen bond in dimer, you have one carboxylic acid facing another carboxylic acid. And the oxygen of one hydrogen bond to the hydrogen of the other and vice versa. And this makes the molecules stick together extra well. If you in your laboratory course ever run thin layer chromatography, TLC, like carboxylic acid, you will see that typically they streak in the TLC. By streaking, I mean that they have a spot with a tail on it, like a comet. Because at the front of the band and the TLC, as your solvent moves up the TLC, your sample is really concentrated and it's hydrogen bond moving to itself. So it doesn't hydrogen bond to the silica of the TLC plate. It moves quickly up the plate. But at the tail, as it gets more dilute, you have less hydrogen bonded dimer, less in the molecule sticking to itself, and more of it available to stick to the silica gel of the TLC plate. And so it lags, the more it lags, the more diluted it becomes, the more diluted it becomes, the more you have, the more you have, the more it lags. So TLC-wise, you see very characteristic behavior of this. You see some really interesting features spectroscopically for carboxylic acid. So for example, in the infrared spectrum, you have an OH stretch at a characteristic position. It's really, really unusual. You see this very, very characteristic band from about 3,500 to 2,500 wave numbers. It's one of the ugliest features that you'll ever see in the IR spectrum. It's very broad. And the best way I can sketch it out would look something like this. If your IR spectrum sort of starts at 4,000 wave numbers, by about 3,500, you start to see this band come up and it's sort of misshapen, and then it kind of comes down at about 2,500. So it's a very hard, hard, and spelling. It usually obscures the C8 stretches at about 3,000. And then as you come along in the carbonyl region at about 1,700 or 1,725, you'll also see the CO stretch, the carbonyl stretch. So let's say about 1725 to 17300 wave numbers. It's a really, really characteristic, just staring you in the face when you look at these. So NMR and IR spectra also have characteristic features of carboxylic acids. And a lot of this is the best way. You'll get to see some of these compounds in the lab class if you haven't already. The best way is to actually see spectra question. It's still pretty ugly. And so the question that's being asked is about concentration. And if you want it, concentrated would be say the liquid sandwich between two salt plates would be typical. Or if it's a solid in a potassium bromide pellet. And those tend to be really ugly in my experience. In solution, I haven't looked personally recently. I would think of anything you possibly, very dilute, see a little warm autumn or it should be more well-bending. So I'm not sure if that's true, but if you see an example, I'd look to see what you're reading there. It's the other thing that's interesting in the IR spectrum. Some of it depends on how big the molecule is. After all, if you've got a small carboxylic acid like butanoic acid or acetic acid, that molecule has a ton of carboxyl compared to other stuff. So when you're sandwiching a drop of acetic acid between two salt plates, there's a ton of carboxyl groups. If you had a molecule with 20 carpins in there and just one carboxyl group, you'd see a much smaller stretch for the carboxyl group. So what I'm saying here and for that spectrum is sort of characteristic of a smaller molecule. For like an amyloid molecule, like a steroid, like a cholesterol molecule, the carboxylic acid will be smaller and a little bit less obvious. But there's still you to the obvious. Good question. Other questions? Sorry, how can we differentiate a carboxylic acid from just an alcohol? Ah, great question. Carboxylic acid from just an alcohol peak. So typically an alcohol peak, and again I'll refer to one concentrated, kind of picks up at about 3500 and kind of comes down by about 3000. So this would be a typical alcohol and you'd see it more sort of centered at 3300. Whereas the carboxyl is pretty featureless. It may have some small features over here or over here. And it's just sort of this blob that encompasses the CH region of about 3000. Oh, sorry, I'm on questions like, so how can we see the CH peaks in the carboxylic acid? You may not. The question is how do we see the CH peaks? And the answer is you might not see them, but guess what? These days in organic chemistry there are so many ways to tell a molecule as CH is in it. For example, NMR spectroscopy that in general is a molecule. And in the scientific journal called Journal of Organic Chemistry, back many years ago when NMR was the primary way of describing molecules, you were supposed to describe every band in the spectrum and list like 20 or 30 peaks. Nowadays, the instructions, since there are so many good ways of looking at molecules, the instructions aren't list the main peaks as they're shooting at functional groups. These days if Johnny or Kim prepared a carboxylic acid and described it in the Journal of Organic Chemistry or in the laboratory report, they would probably say 3,500 to 2,500 wave numbers of broad peaks and 17, let's say 10 wave numbers of another peak. So you may not see them. In the NMR spectrum, you of course get to see lots and lots of hydrogen. The carboxyl hydrogen, ironically you don't always see. Generally it's about at 10 to 13 ppm. Your textbook says 10 to 12, neither knows its part. Often it's broad. Its position depends a little bit on the solvent, if you're looking at it in chloroform, if you're looking at it in dimethyl sulfoxide, and sometimes you actually won't see it. Your textbook, in a lot of ways, would never give you an example of an NMR spectrum where you didn't see the carboxylic acid or wave, but if Johnny or Kim went into the laboratory and prepared a carboxylic acid and tried to determine a carboxylic acid and took an NMR spectrum in chloroform and said, I don't see the carboxyl OH, even though it looks like a carboxylic acid, the infrared spectrum, I don't know if I have a carboxylic acid, I'd say, you know, sometimes you don't see the OH because it can be very broad due to exchange with water. Why don't you go back and run the NMR in a different solid like dimethyl sulfoxide and you try to come back and say, ah, I see it. But your textbook would never give you that much reality, or I wouldn't, because it's way beyond the scope of this book. But that's the reality. Now, the other thing is okay, what do you think about when you think about the hydrogen, the carboxyl group is electron withdrawing, in doubtful way. And so the CH that's next to a carboxylic acid generally appears at about 2 to 3 ppm. The textbook says 2 to 2.5, either is fine. If it's a methyl group, it'll be at about 2. If it's a methylene, a CH, 2 group, it'll be about 2.5. If it's a methine group, a CH group, it'll be at about 3. And if there are other electron withdrawing groups, it'll be further down fuel. The NMR spectrum, the carbon-13 NMR of carboxylic acids, your carboxyl carbon generally appears at about 170 to 180 ppm. That general region of about 170 and further down fuel is generally referred to as the carbonyl region. So generally, carbonyl compounds are generally about 170 to 220. The textbook said for carboxylic acids, 170 to 210, but they were really trying to encompass all of the carbonyl region. So generally, it'd be about 170 to 180 ppm. I'm going to write in general here. So, I'm going to write in general here. So, carboxylic acids, carboxyl groups of carboxyl groups, of carboxylic acids, is in a high oxidation state. In fact, they are the highest oxidation state of any organic compound, with the exception of things that are in the carbon dioxide oxidation state. So, if you in general have a carboxylic acid like acetic acid or hexanoic acid or benzoic acid, the oxidation state is plus three for the carbon. Informic acid, if you count your oxidation state, it's plus two. But what that immediately tells us is they're generally synthesized by oxidation reactions, because in general, a lot of organic compounds you encounter have carbon in lower oxidation states. So, alcohols, for example, depending on the substitution, will have oxidation state of if it's a primary alcohol, negative one, if it's secondary it'll be one different. And so, primary alcohols can be converted to carboxylic acids by oxidation. And you've already encountered oxidation reactions in the 51B course. So, for example, with chromium-6 reagents. Let's say EG with chromium-VI. So, what I mean is potassium dichromate and sulfuric acid, or sodium dichromate and sulfuric acid, or chromium trioxide and sulfuric acid. They're all about the same in their reactivity. There are other oxidizing agents. In general, chromium-6 is a really bad actor. It's personogenic, it's toxic. In general, organic chemists try to use safer oxidizing reagents these days, ones that are more environmentally friendly and don't generate waste. So, other sorts of oxidation systems that get used involve things like bleach, sodium hydrochloride, and various catalysts. Anyway, the general gist is there are many oxidation reactions that can make, can synthesize the carboxylic acid group. So, for example, you're also familiar with oxidative cleavage. Alkynes, ozone. That's a little bit of an oddball in some way because alkynes aren't that commonly occurring. Alkenes are a lot more common. So, I also included in the example in this week's discussion section, alkynes, and you'll see a reagent system for the oxidative cleavage of alkynes. Your textbook provides a nice review, and so you'll also see in your textbook oxidation of aromatic compounds. So, you'll see that in the next slide. With an n-zillic CH group. So, these are all things that you've encountered in your previous course. And in that case, you'll see, for example, potassium permanganate KM04 as a reagent. All right. As the name carboxylic acid implies, carboxylic acids are acidic. They're not strong acids, like sulfuric acid, like battery acid or hydroporic acid. Those acids, if you dissolve them in water, completely ionize. One molar solution of sulfuric acid is pKa, or one molar solution of hydroporic acid, is pKa of zero to ver, is pA, pardon me, zero. The ver is strong acid, and if you splash it in your eye, it's going to cause real damage. Vinegar is a weak acid. Vinegar or acetic acid is a weak acid. It's a 5% solution, which is close to one moment. If you splash vinegar in your eye, it's going to hurt, but you'll wash your eye after, and that's only to be blind or to be emergency-proof. Weak acids and strong acids, of course, react with strong bases. So for example, acidic acid reacts with hydroxide aniline to give you acetate aniline in water. And I've sort of focused here on the ions. You can't just buy or find a bottle of ions. If you go to the stock room and you say, maybe some hydroxide, they're going to say, well, I can't just give you any hydroxide. We've got to add a particular hydroxide. I can give you sodium hydroxide. I can give you calcium hydroxide. But you can't get hydroxide ions just to sit with each other without metal counteron, as they're for each other apart. And so we could write a real balanced chemical equation for, say, the acidic acid plus sodium hydroxide goes to sodium acetate, CH3, CO2, all right, with minus NH plus. So acidic chemists are not good people who are horrible about balancing equations, but now I'll be a good person and balance my equation. Sodium acetate in water. Yes? Oh, sorry. Sodium acetate should be CH3, CO2 minus. CH3, CO2 minus. Thank you. I'm going to front row every class. And I want everyone else to help out with this. Yes. Wow. So I haven't written an equilibrium there, because that reaction just lies so bloody far to the right that for all intents and purposes, if I throw sodium hydroxide, one mole of sodium hydroxide, together with a mole of acidic acid, there is no acidic acid left. I've got a mole of sodium acetate. That equilibrium lies fantastically far. Sulfuric acid has a pKa, so a way an indicator of acidity is pKa. The pKa of acidic acid is 4.76. That's typical of a weak acid. The strong acid, like sulfuric acid, is negative. Hydronium ion is negative, I believe, 1.7. In this equilibrium, water is acting as a base, or rather hydroxide is acting as a base. Water is the conjugate acid. We often compare equilibria by comparing the conjugate acid on the two sides of the equation. Water has a pKa of 15.7 acting as an acid. In other words, it's a much, much weaker acid, much, much weaker acid than acetic acid. That equilibrium lies to the way, way, way to the right. So far to the right, then we barely consider it as an equilibrium. Organic chemists often think about water and alcohols together. They're kind of in the same family. They both have hydroxyl groups. They have many similar properties. The pKa of alcohols is very similar to the pKa of water. Alcohols are about, if you want to keep one number in your head, about 17. If you can't keep one number, just say, oh, they're about the same as water. We call them both 16. So these are weaker acids. Their conjugate acid, conjugate base is RO minus or OH minus. And so if we think about why they're weaker acids, one way, one model in which to understand this is when we look at acetate anion, we can spread that negative charge around. There isn't a negative charge on one oxygen and a neutral charge on the other. So there isn't a double bond to one oxygen and a single bond to the other. It's sort of half and half. There are two resonance structures that are equivalent that together represent a more complete picture of the structure of the anion. We can say that the negative charge is stabilized by resonance. And that special stabilization that doesn't occur in hydroxide anion or in alkoxide anion makes this a weaker base, makes acetic acid a stronger acid than water or then in alcohol. Organic chemists aren't big calculators. Organic chemists are big estimators. We tend to think about things in sweeping terms. So when you're taking general chemistry, you're typically focusing on calculating in detailed positions of equivalent. When you're thinking about organic chemistry, often you're thinking about acid-base reactions and asking, what is this equilibrium like? Is it light in the middle? Does it light to the right? Does it light way to the right? Does it light way to the left? Does it light or way to the left? And that's how I like to use these days in my thinking. So when I think about equilibrium in an acid-base reaction, I sort of think about broad estimates in terms of pKa. And I think I write equations because that's not how I think, but I'll show you how I get to my thinking. So the equilibrium constant is 10 to the delta pKa. So what do I mean? I mean, if you have an acid or COO8, and its pKa is about 5, see I'm not even going to worry about extra digits here because basically I'm thinking in broad terms, carboxylic acids have pKa and 4 or 5. So I have a base like alkoxide or hydroxide, and I have an equilibrium. I've already said this equilibrium line is way, way, way to the right, and I'm so far to the right, I'm not even bothering to think about why it's where it is. So here's my equilibrium, and the pKa of my alcohol, my hydroxide, is 17. My estimate, the thing that's going on in the back of my head is oh, kEq is equal to 10 to the 17 minus 5 is 10 to the 12. That equilibrium is so far to the right that it's hardly an equilibrium. It's just there, it's just reactive. 10 to the 10th is a big number, right? It's 10 to the 1, 10 to the 2, maybe even 10 to the 5, even maybe sort of up a little bit above that, like 10 to the 8th. You can say, okay, there's kind of sort of an equilibrium, but this is way, way, way to the right, which is why I didn't even bother to think about it. So most carboxylic acids are pKa of 4 or 5. We saw it with acetic acid 4.76. Benzoic acid is a little bit worse. But sometimes you have big effects. Sometimes you have big effects that lead to inductive stabilization, it becomes a good base. And that's going to lead to a stronger acid. So as I said, typical carboxylic acid is 4 to 5, but if you take something like trifluoroacetic acid, trifluoroacetic acid has a pKa of 0.23. Johnny and Kim work with trifluoroacetic acid all the time in the laboratory. They use it as a relatively strong acid, and it's right on that equilibrium between strong meaning, reported water at all ionizing, and weak meaning, it doesn't ionize a lot. Ionizing is a lot in that group. If you get it in your eyes, there, you should worry about it. If you get it on your skin, there you should worry about it. What's going on? Those fluorines are super, super electron-induined, and we got three of them. They all have these night poles pulling negative charge away from the conjugate base, stabilizing the conjugate base. And so we get five orders of magnitude more acidic than a regular carboxylic acid. If you put fewer electron withdrawing groups, like one or two fluorines, like less acidic, if you go ahead and you move your halogens down the chain, like 4-chlorobutanoic acid versus 4-chlorobutanoic acid, out 2-chlorobutanoic acid, they're both more acidic than but 4-chlorobutanoic acid, but 4-chlorobutanoic acid, but 2-chlorobutanoic acid is a little more acidic, whereas 2-chlorobutanoic acid is a good idea, Laura. And you get the same effect, I'll give you one last example to close here. You get the same type of effects with benzoic acid, and you can think of this in terms of the reductive effects that you've learned. So benzoic acid has a pKa of 4.19. If you take parenitrobenzoic acid, you can have reductive and resonance effects pulling electron density away from the carboxyl group, and its pKa is 3.19. So you get effects there. Alright, I think that wraps it up for today.
This is the third quarter course in the organic chemistry series. Topics covered include: Fundamental concepts relating to carbon compounds with emphasis on structural theory and the nature of chemical bonding, stereochemistry, reaction mechanisms, and spectroscopic, physical, and chemical properties of the principal classes of carbon compounds. Index of Topics: -0:26 Office Hours -1:42 Textbook -4:57 Homework -13:22 Quizzes -15:21 Academic Honesty -16:52 Enrollment -17:05 Tutoring -18:02 Software -21:36 Carbonyl Chemistry -23:34 Amines, Sugars, and Selected Topics -25:08 Carboxylic Acids -32:52 Carbonyl Compounds -42:07 Some Properties of Carboxylic Acids -49:04 IR of Carboxylic Acids -55:31 NMR of Carboxylic Acids -59:55 Oxidation of Alcohols -1:03:22 Oxidation of Aromatic Compounds -1:05:55 Carboxylate Anions -1:08:54 pKa of Carboxylic Acids -1:13:06 Equilibria in Acid-Base Reaction -1:15:41 Inductive Stabilization of Conjugate Base
10.5446/19347 (DOI)
All right. So what we've been doing in the course up until now is I've been trying to present a very programmatic and systematic approach to spectroscopy, but particularly to NMR spectroscopy. I've wanted to give us a small collection of tools for our toolbox and to teach us how to use those and then add to them and particularly allow us to build an appreciation. So we started in 2D NMR with Toxy and Cozy and then we are with, I'm sorry, with HMQC and Cozy and we learned how to use those and then we got to appreciate how Toxy could help us in certain situations and also how HMBC could help us put the pieces together. In the last lecture I introduced HMQC Toxy, which helps us deal with overlap. We've also in 1D NMR, we've learned a little bit about the theory of the techniques. We've learned about coupling, we've tried to get a deep understanding of coupling, we've had a few special topics in there, we've talked about dynamic NMR, which I thought was particularly useful and relevant. We've talked about the nuclear overhouser effect and we've introduced some experiments over there. Now so I was thinking about today's lecture and really trying to think what I wanted to do and I wanted to break away from that. There are a lot of things that I found useful over the years or think you might find useful that I don't want to introduce in a systematic fashion. You may not need these in your toolbox, you may need them in your toolbox, you may find two or three years from now in your project, you have a particular situation that comes up and you reach back into the recesses of your mind or into the handouts and say oh yeah I recall he mentioned this in class and now I have a problem that I can use that. So today's lecture is going to be a little different, it's going to be more fragmented, it's going to be things that I have found important or in the case of the first two, which I haven't used myself, think you might find important. And I've given you some of my sources here and I'll give you some more, I'll actually pull in some stuff from my own work. Can somebody send a couple of handouts over to James there? Alright so where I'd like us to start is with the issue of coupling and we've gotten really good at analyzing multiplets and we've also learned how to address making connectivity when you have complex spectrum when multiplets overlap and of course the one thing that you lose out on when multiplets overlap is often it's hard to analyze those multiplets because they end up being overlapped with another multiplet. So I wanted to mention two techniques that may be useful to you in your own research, you're not going to get these on the final. 2DJ resolved NMR is one technique and the other one is E-Cosie which stands for Exclusive Correlation Spectroscopy and I guess that's a capital O in Cosie which is exclusive. And so what I'll say is both of these can help you extract J values from complex multiplets and I just took a couple of examples from sources that I like and the source that I like these days for modern NMR experiments to the extent that I've now bought the book three times first in the 100 and more version then in the second edition which was 150 more and more NMR experiments and now in the 200 and more NMR experiments version is this book here and I'll just show you very briefly the two types of spectra here. So this is in that book, this is an example of a 2DJ resolved spectrum and it's of a very simple compound. It's a two dimensional technique but it's a two dimensional technique where you have on the F1 axis you have the H1 NMR and on the F2 axis and on the F1 axis you have J and so just so you can see this for the first time what you have here is basically a projection of the peak like this. In other words this peak is a quartet and so along this axis we see 1, 2, 3, 4 and if you want of course on the spectrometer you can then go and get this out separately and basically go along this dimension because remember these contour lines are basically peaks coming out like this. So this is obviously not a complex spectrum, this is a very, very simple molecule but you can see what it does to the multiplets. So for example here we have a triplet and you see one main, two main and three main peaks there's a little bit of artifacts here. This is the methyl, you have a doublet of doublets, you have a doublet of doublets because you've got your coupling from the methyl group to this hydrogen and then you've got a lilac coupling over here and so you can see your doublet of doublets here, your four lines so that if you pick this up would just be a doublet of doublets here. As I said this is a trivial molecule, you would have no need to use this technique for such a simple molecule but where you would bring this out would be in cases where maybe you had a couple of overlapping multiplets and you really wanted to get your J values. Remember we said J values can be very useful for dealing with stereochemistry and so if you want to figure out okay do I have a 10 hertz coupling constant, do I have an axial-axial interaction, do I have a 3 hertz coupling constant, this can come out. Here you have a doublet of quartets and another doublet of quartets, that's of course, this one is of course associated with this proton where you've got a big, big trans coupling and then about a 7 hertz coupling to the methyl and you can see your lines so you go 1, 2, 3 and 4 is one quartet and 1, 2, 3 and 4 is the other quartet and then here you have another doublet of quartets and you can see your quartets here. So put that away in your toolbox for cases you may need it. This experiment isn't too widely used because in cases where you have really bad overlap you're still going to have this. In other words, if I had another multiplet right on top of this you would still end up experiencing the two of them right on top and so unless they were a little bit separated you wouldn't necessarily be able to solve anything. The technique, so this, I'll write it, well you have this in there, yeah. So this next one is an E. Cosy and I think that's the second one in your handout here and I just want to show you how to interpret the technique in part because when you look at the book for the first time it's a little bit confusing. So they've taken another trivial compound. They've taken a slice that's not on the diagonal so here's your diagonal. I mean in other words, of course, what they've done is an expansion. Of course you could take the entire spectrum. They just didn't in this particular example. I just want to show you how to interpret this. So what we're looking at is a molecule that has three hydrogens that are all mutually coupled to each other with different coupling constants. And it's also confusing. It's not a square thing. So on this axis they've taken the region at about 3 ppm and here they've taken the region so from about 3 to 3.4 or 2.8 to 3.4. Here they've taken it from 3.3 to 3.9. So that encompasses all of the hydrogens. So you see one multiplet for the H3A, another multiplet for H3B which is not on this one and so it's a doublet of doublets, a doublet of doublets and then another H2. And I just want to show you the cross peaks here because it's from the cross peaks that you can extract the J's. And so do you see this pattern of the little squares here? You see the little square of four dots here and four dots here? This is giving you the quote active coupling. This is giving you the coupling between 3B and 2A, I'm sorry 2 and the distance basically any of the distances in the squares, that distance is the J value. So the distance within the square is the J value. And so that's 3 to 2B. Here we have 2 to 3A and initially it's confusing until you look and you say oh yeah I see one square here and one square here. Do you see that? And again it's the distances in the squares. So it's this distance that's the J for 2 to 3A. This was the J for 2 to 3B. So you can extract very easily the J's between different protons from this type of experiment. And if you're looking and trying to assign some stereochemistry based on this then it can be a very valuable tool to add on. Here we see the 3A to 3B coupling and of course this is the one that's going to have the biggest coupling because that has your geminal coupling. Geminal couplings are generally bigger, not always because they're highly variable based on hybridization but on sp3 carbons they're generally the biggest. And so now you see our overlapping squares here. I think what I will do is highlight the square so we have one square here and maybe what I'll do is get fancy here and pull out a different color to highlight the other square. So from the sides of the squares basically from putting your cursor on this dot and this dot you can get from that distance here you can get the J3A 3B. Again maybe not so important for this very simple molecule but more important for a more complex system. All right so that's what I want to say about that. Now the one that we haven't talked a lot about is chirality and using NMR spectroscopy as a tool to analyze an anti-imeric purity. And of course the thing that I've emphasized in the course is that an anti-immers have identical spectra. In the absence of some source of chirality you can't tell an R molecule from an S molecule and yet many times you're doing some synthetic transformation and you want to ask what percent EE did I generate my molecules in or do I have a single enantiomer or do I have a mixture of enantiomers? And this sort of question then needs some source of chirality and so I want to introduce two ideas here. We'll start off with chiral shift free agents and then I'll talk to you about chiral derivatizing agents. In order to talk about chiral so I'll say they're useful for determining an anti-imeric purity and in order to talk about chiral shift free agents I first need to introduce a different concept and that concept is lanthanide induced shift free agents or related concept. And plain old lanthanide induced shift free agents have largely fallen out of fashion. They were developed back when NMRs were much lower field and overlap was a much bigger problem. And you had a 60 megahertz NMR spectrometer, very few of your multiplets were beautiful multiplets and a lot of spectra were just overlapping heaps of junk. And the idea behind lanthanide induced shift free agents was to add a paramagnetic Lewis acid that would coordinate to a Lewis base atom on your compound, bind to it and paramagnetism creates its own little magnetic field so you would create extra dispersion in the molecule that would be related to where the Lewis, where the shift free agent was in relation to other protons. And the general format for these reagents, many of them were based on Europium, they're lanthanides, lanthanides have unpaired electrons, unpaired F electrons and many of them were based on Europium, some of them Praciodimium and some of the others. And the general format for them was an ACAC type of ligand. ACAC is acetylacetanate. Who's seen ACAC in organic chemistry or coordination chemistry? Okay, so they're all based on an ACAC ligand with various types of R groups here. And so the metal is typically in the plus three coordination states so you typically have three of these. And the great thing about lanthanides, they literally make like a little kind of here's your Europium and you've got this, this and this and then you have a spot where your Lewis base can coordinate because lanthanides will take basically as many ligands as you can throw around them. So two of the non-kyro ones, before we get to the kyro ones, two of the non-kyro ones that are popular and these are, by the way, this is all in the other handout that I've given you. So I used to use Phrybolin, this is all taken from Phrybolin but I've worked with some of these compounds myself. The Phrybolin book I used to use as a supplemental text, a required supplemental text for the course, I like it. There are a few really good chapters, the dynamic NMR chapter is pretty good. So this one which has two tert butyl groups, ACAC has two methyl groups, it's acetylacetanate. This one is called DPM and DPM is just dipyvylwile methanado. And so the reagent is EUDPM3, another one, a lot of them have fluorinated groups and particularly the chiral shift reagents. And so this one here, again it's an ACAC type ligand, this one has one tert butyl group and one hexafluoropropyl group and this one is called FOD and so the reagent is EUFOD3. And so what these reagents do is the molecule will bind to it and then they will create a high degree of magnetic anisotropy. And you usually just add a little smidgen of the reagent. So I wanted to show that to you and then talk to you about the chiral shift reagents. So this is really a beautiful example here. So this is on page 336 of your Fribalin handout. And so this is a spectrum of hexanol. All is going to look like crap at any field NMR because you've got all of these methylenes, you've got the alpha methylene that's going to be very dispersed even at low field and you've got the beta methylene that's going to be at high field a little bit separated but then you've got the gamma, delta and epsilon methylene that will all heat together and this was done at low field so the beta is on top of them. And then you've got the methyl. So this is sort of your typical long chain alcohol group. So they add a little bit of EUDPM3 and look at what happens to your spectrum. You end up binding the shift reagent. It's reversible so you don't even need a full equivalent of shift reagent. It goes on and off rapidly on the NMR timescale. It binds to the oxygen and then your methylenes shift down. Your alpha methylene shifts down and your beta shifts less far down and your gamma and your delta and your epsilon and your methyl. So what's happening is there's both a distance and a geometrical relationship to the shift reagent that's resulting in shifting down field from the paramagnetism. The further the protons are from the paramagnetic center, the further you end up at the end up or the less you end up with down field shifting. There's also an angular relationship. So that's sort of the background. As I said, I think they're actually a useful tool for solving overlap but they've largely fallen out of fashion for that. But chiral shift reagents are still very useful because you can have either the two enantiomers binding with different binding constants to a chiral shift reagent or different geometrical relationships. So regardless, what happens is the protons of the two enantiomers will separate and so you can see a methylene for one enantiomer and a methylene for another enantiomer takes chirality to distinguish chirality, a chiral shift reagent makes for that chirality and that type of interaction. So chiral shift reagents, I'm sure there are more out there but the ones that are popular, the ones that I've used are based on camphor. Basically it's an aldol condensation of camphor, right? So this is the structure of camphor. Camphor has a ketone over here. It has a methyl here. It has a couple of methyls on the bridgehead. We've seen camphor before in some of the problems. It's a very common, common terpinoid structure and by doing an aldol condensation you get an ACAC. Here I'm not drawing this. I'll just draw it as a single resonance structure rather than a dotted arrow. But you get an ACAC type ligand and then you do an aldol condensation and you can do it with tri, I mean you don't do it. You buy it from Aldrich. You can do it with trifluoromethylacid aldehyde or hectofluoromethylbutyraldehyde, heptafluorobuteraldehyde. You can have either a trifluoromethyl group or a heptafluoropropyl group and these are respectively called EU and so you have three of these on a eropium just like we did with the other type of ligand, right? It's just another ACAC ligand. And so you have the reagents that are called EU TFC3. TFC stands for trifluoromethylcamphorado or EU HFC3 for the heptafluoropropylcamphorado. So let me show you one of these compounds and we'll look at this with a, so again now we've got our chiral-shift reagent. So before we had the alcohol, what they'll do in the next demonstration is we'll look at this with a chiral amine with phenylethylamine. So the nitrogen has a lone pair. It's Lewis basic. It can coordinate. And I'll show you two slides there continuing in your frible and handout. So usually what you do when you work with these is you titrate in the reagent because you don't want too much reagent. If you add too much chiral-shift reagent you just broaden the spectrum and turn it to help because paramagnetism induces relaxation. And so if you make for very fast relaxation you end up with broader lines. Remember you have to have a proton stay in one spin state for a while for like hundreds of milliseconds in order to have a sharp line. If your proton is flipping spin states on the order of 10 milliseconds or 30 milliseconds your line is going to be very fat. Where we added deliberately added paramagnetic reagent chromium AC when we talked about the inadequate experiment because we deliberately wanted to get those quats and other carbons to relax a little bit faster. So you basically titrate in your shift reagent. So they start, this is pure phenethylamine. This is a single enantiomer. So this is pure, I'll say pure single enantiomer. And so then they titrate in increasing amounts of shift reagent. So just look at the methine here and your methine as you titrate more and more it starts to walk downfield more and more and at the same time broaden out. And so you basically want to get it shifted a bit but not so much that it's all completely broad. So they did this first with material that was enantiomerically pure and then they wanted to go ahead and see if you could distinguish two enantiomers. And so in this case they took, this is enantioinriched. And so in the enantioinriched you'll notice that the two methylenes for the two, the two methines for the two enantiomers now, so this is phenylethylamine. And so the methines for the two enantiomers now separate out because you have this chiral shift reagent that interacts differently with the two enantiomers and so they undergo different shifting and you can integrate them and they're separated. Here they do the same experiment with the racemate and you see that the peaks are about equal in size. So this can be very useful because if you're working on a project that's say asymmetric catalysis and you want to be able to go ahead and measure your enantiomeric purity, if you can work out the right system to distinguish your enantiomers then it's as quick as taking an NMR spectrum. So the protons and the chiral shift reagent are largely blown out of the way by its paramagnetism. But as you'll see in this graph, particularly at high concentrations, this is one to one, you'll notice here we see I think it's one of the methyls of your chiral shift reagent and here's some other stuff of your camphor. So the answer is yes. You do have to worry about them. But it can be a very nice and very handy technique. You'll get multiple binding points and if you had say an alcohol on an amine it would bind primarily to the amine and if you had like an alcohol on an ether it would probably bind primarily to the amine. Then you would have it bind to all of them and you'd have to see if. So I mean chiral shift reagents are not a, what? For an achiral shift reagent. Well it would shift everything around whether or not it would help you resolve things is uncertain. One of the first things I do when I have problems with overlap and I've done this for the class is I'll throw the thing in deuterobenzene because deuterobenzene creates a shift that's a diamagnetic shift from the ring current of the benzene. And so very often if I've just got a couple of persnickety overlapping protons very often just throwing the thing in deuterobenzene is enough to shake up the spectrum. Basically what you're trying to do is get some change and see what works. All right this next example here and I'm just putting this in it's pure, pure, pure self-grituitousness. This is a very little scientific value. It happens to be the first paper I published as an undergraduate and it was just using chiral shift reagents in a very unusual way with molecules that basically was a tight ion pair. And it was determining, determining enantiomeric ratios in a ruthenium complex and so what was happening was it was done in a non-coordinating solvent and so the chiral shift reagent was coordinating through chloride to the ruthenium complex and you could see the various protons of the ring would separate. So this is the phenanthroline ring so you could actually see the two enantiomers. Anyway, I've had a long-standing love affair with enomorous spectroscopy and maybe it's part of where it started. All right so enough with self-indulgence here. I'm going to come back to self-indulgence in a second. And that brownie is very good by the way talking self-indulgence. All right so chirality is a real problem for enomorous because as I said enomorous is not inherently able to tell enantiomers apart. You've got to do something to distinguish among enantiomers. So the other way, another way to go and I'll say another way because there are lots of clever ways including ways of being developed in the Riknowski group right now and that have been published out of the Riknowski group but another way that's been used for a very, very long time is chiral derivatizing agents. Enantiomers do not inherently have different NMR spectra but diastereomers do. So if you can take your enantiomer and if you can take your enantiomer or mixture of enantiomers and get it to react with an enantiopuramolecule then you make diastereomers and you can distinguish the two of them and there are tons of them out there, tons of chiral derivatizing agents. I'm just going to show you two. One of them is very popular. It's been around for decades. I think since the 60s, this one is called, well it's called Mosher's reagent is what everyone refers to it as. It's MTPA which is methoxy trifluoromethyl phenylacetic acid. This one is the R enantiomer. People call it Mosher's acid or Mosher's reagent. And what you do is you simply prepare an ester and amide derivative with the carboxylic acid and what's cool is the reagent itself has two very nice handles that give sharp singlets in the NMR spectrum. A methyl that gives the sharp singlet in the H1 NMR spectrum but even more cool, a trifluoromethyl that gives the sharp singlet in the fluorine NMR spectrum. So that's one popular one for reagents that have a nucleophilic site, for compounds that have a nucleophilic site. For things that have an electrophilic site, one popular one is our alpha methyl benzelysosionate. At least that's one way you can describe this thing. So you can buy this enantiopur from Aldrich or from Flucca. There's also a version with an aphtho group. Isosionates react with amines to give ureas. They react with alcohols to give carbamates and so you can very easily react your molecule to make an enantiopur, to make derivatives in which you now have a chirality in there. I'm going to show you one example from my own experience just because it happens to be something I can draw on. It also introduces some ideas of chirality. I'll just erase over this. I guess what I'll add is this was something that worked well and was easy for me and I like it. So now we're kind of into stuff that I like that I think is cool that I think you'll like too if you come to the point in your project where you have such a problem. All right, so my particular problem and project was I was taking amino acids and developing a synthetic method for making isosionate derivatives of these. And the problem was I couldn't tell. You get an NMR spectrum and the stuff looks great. But what you couldn't tell is are you also getting the enantiomer, in other words is there racemization in the reaction? So I'll put a big question mark here. So in this case it's kind of the antithesis of the isosionate being in the molecule of interest, being in the derivatizing agent. Remember the molecule we were making had an isosionate in it so I just derivatized it by reacting it with methylbenzylamine. And so as I said you can get methylbenzylamine as a single enantiomer. I happen to take the R enantiomer here. So we treated it with that. And the idea was to see if we were forming diastereomers and so you could look at the diastereomers by NMR and say okay, are we seeing any evidence of diastereomer? And so this is what you'd get from the compound with the natural stereochemistry. And so the question is are we getting any of the diastereomer? So when we took an NMR spectrum we didn't see it. Now the big problem with a negative result of course is you get a negative result that doesn't prove it's not present. Maybe the diastereomer was coincident. So the way you have to address this and this would apply to whether you're doing chiral HPLC or anything else or chiral GC is you need to prepare an authentic sample. So there's an easy way and a hard way to do that. So the hard way to prepare an authentic sample is to now go ahead and take the enantiomer of the amino acid and react it with this amine, with the aramine. The easy way to do this was simply to go ahead and take the enantiomer of the amine and react it with the product. This should be a phenyl here. And so the point is that these two molecules are enantiomers and so the spectrum of this molecule is identical to the spectrum of the diastereomer. So now when you go ahead and you take this molecule here and you don't see any diastereomer, what you do to confirm that there's no diastereomer is you spike with this stuff here and you can see if it shows up as a separate peak. And indeed it did. The methoxy of the two ends up being separated by 0.2 to 0.3 ppm, which is ample. It becomes like an HPLC trace, which was ample to distinguish. And in fact with a very small spike, with a spike of just 0.5%, you see it. So that means that we know that the original is greater than 99% EE. So no racemization to speak of. All right, so that's what I want to add about chirality in NMR and how NMR can be a useful tool. And I think what I want to do at this point is toss out a couple of other techniques that I found useful over the years and that indeed we use. So, technique that I'll talk about now is called XZ, which is exchange spectroscopy. And what this is useful for doing is identifying conformers or other species in moderately slow exchange. The situation comes up where you'll prepare a compound, let's say a carbamate or an amide, and you'll see other peaks in the NMR spectrum. We saw this with amides. We talked about this with amides where we could see two different rotomers or we had that very thorny problem where remember we had the series of spectra and we were talking about this being a minor conformer, that five-page sheet problem. And so the question is, yes, sure, you say you think it's a conformer, but how do you know? Your advisor says, hey, we can't publish this. Your NMR spectrum isn't pure. We don't know if it's pure. The reviewers are going to say you've made a mess. How do you establish that that mess really is your compound? And spectroscopy is the same pulse sequence as rosy or nosy. In fact, it's just a nosy or rosy spectrum. And the exchange cross peaks are the same sign as the diagonal. I'll show you what I mean. Yeah. Yeah. So in a nosy spectrum for a small molecule, the cross peaks are opposite sign to the diagonal. So in the phasing, you have one, you saw this when you worked up some of your phase sensitive spectrum. You had sort of the red region and the blue region, right, with the color maps. This is, yeah, exactly, it's phasing. So these will be on the same side as the diagonal. In the nosy spectrum of a small molecule, that's going to be opposite the cross peaks. In a rosy spectrum, that'll be opposite the cross peaks. Now the trick on this is timing, and there are really two different time scales for NMR spectroscopy. There's the time scale of the, we talked about this when I talked about dynamic NMR. There's the time scale of the uncertainty principle. Time scale of the uncertainty principle is if a proton doesn't stay in a single spin state for more than a few milliseconds, you won't be able to see, you know, you'll, well, how can I explain it? If you have two different states, you won't be able to see them as distinct unless you stay in those different states for sort of 10 millisecond or more. Then you have the time scale of relaxation, which is magnetizations returning to the z-axis, T1 relaxation, or dispersing in the xy plane, T2 relaxation, and that time scale is on this order of seconds. So you have to window your exchange process. So it's faster than 10 milliseconds sort of time scale, but slower than second time scale. I like the ballpark things in my mind. So in other words, you have to window that time scale so it is on the order of 100 milliseconds. In other words, if you have an amid that rotates very slowly, remember we talked about time scale and energy barriers and temperature, you have to raise the temperature to get up into that regime of having exchange. Now a lifetime of 100 milliseconds means an extra 4 hertz peak width. In other words, the peak width at half height becomes 4 hertz wider, and that's very good because a typical doublet is like 7-8 hertz. So you can sort of see, a doublet normally has two sharp lines. You just want to fatten out your peaks so that your peaks are getting a little bit fat. A sharp line in the NMR is about like 1 hertz, 1.3 hertz. So you want your lines to get just a little bit fatter. So I'll say choose a temperature so that the peaks broaden slightly by a couple of hertz. Two examples, let's see what did I do? I think I made them as, I think it was, yeah, I just took, what did I do? I took two papers here, so I'll just hand out a couple from my experience. Being profound but very, very useful for us and I think potentially, potentially for you. So, one of these, when you get multiple conformers, it is really, really a nightmare because your spectra get so, so complicated. So this is a macro cycle that one of my students prepared. The molecule has fourfold symmetry but the problem is you have a conformer in which the molecule has twofold symmetry and there are two varieties, two identical degenerate versions of that conformer. So in other words, here you see one type of resonance, here you see two types of resonances but then each of those two can swap around. And so my student was trying to establish that these were indeed interconverting conformers. So he ran an XE spectrum, he ran in this case a rosy spectrum and just took the phase at the cross peaks the same as the diagonal. And if you just look here for example, in your 1D spectrum you're seeing three different, let's see where's a good example, an expansion here. All right, we'll take this region here. In your 1D spectrum you see a whole set of peaks associated with a side chain with these protons here and when you expand it you can see a cross peak corresponding to one exchanging with the other. So basically this exchanging with this and then with this, no, no, no, with this and then another cross peak with this exchanging with this over here. Anyway the point is you can see all of those conformers interconverting which is very useful for establishing that they're related and he chose a temperature for this experiment that was just right for it. The other paper was a similar thing, it was in equilibration among two different species where he's looking at Homo and heterodimers and he mixed one enantiomer and another enantiomer and this was Michael who did this and saw some new very teeny tiny peaks in the mixture. So this is one enantiomer, the other enantiomer and he saw these little tiny peaks and he wanted to establish whether that was a diastereomer or a heterodimer so how do you do that? You can say they're new peaks but what are they? So you show that they're an exchange so again he ran the nosy or rosy sequence and was able to see exchange cross peaks here to show they're an exchange and you notice he picked his temperature so that his peaks are just, the peaks are normally sharp and he warmed it up just a little bit just to make the peaks a little broad. All right I want to conclude with two other things again just to file away in your toolbox. Things that I find useful. So one of these is called diffusion ordered spectroscopy dozee and what it does is it basically uses the second dimension to separate spectra by diffusion coefficient and hence molecular weight. And the reason you might find it useful is it's useful for mixtures and identifying impurities. And I'll just show you what I'm talking about with an example and this is an example out of that 200 more NMR experiments. So this is a dozee spectrum in your 200 more NMR spectra of a mixture of two different molecules butanol and a triethylene glycol in two different solvents and what you're doing is using pulse field gradients to separate your molecules by diffusion coefficient basically little molecules like water and methanol diffuse rapidly. Big molecules like propylene glycol don't diffuse a lot. So you end up with a sub-spectrum here so here's your mixture and here's the dozee spectrum and you end up with a sub-spectrum at a small diffusion constant for the peaks associated with the triethylene glycol. Another sub-spectrum and you can extract out all your spectra for your butanol which is smaller and so you can see all the peaks for your butanol right. So in this mixture you've got all these different peaks. You don't know what's what and you say wait a second this methyl group, this methylene, this methylene here and that methylene there correspond to the butanol and then you have your methanol here and then you have your water here so you say methanol in water. We just use this in my lab, we use this all the time for looking at self-association of molecules because for example tetramers have a diffusion constant that's about 0.6 that of monomers but we just use this in a way that you might use it very recently. A student of mine, Mandy, had a sample she just couldn't could not purify and we were trying to say is there something wrong with her chemical or is this an impurity. She took a doze spectrum and she saw very clearly that the unexpected peaks were a low molecular weight impurity in her molecules so she knew okay it really isn't something to matter with her compound. All right last point I want to make. What are suppression? So the techniques that are involved use gradients or other pulses to eliminate H2O. Now the reason that this is important to eliminate the water peak let's say, the reason this is important is it allows observation of some NHs. So if for example you have let's say an alkaloid that has an amide NH group and you want to be able to see that amide NH group you can take a spectrum. In 9010 H2O D2O because on the laboratory time scale that's the third time scale so we have uncertainty principle relaxation laboratory time scale. On the laboratory time scale if you dissolve an amide in pure D2O the NHs exchange with deuterium as do the OHs very quickly in fact the NHs exchange with deuterium and you can't see them so you can never see protons on a heteroatom in D2O never on that I won't say never but you almost can never. So you take the spectrum in water with just a little D2O for the lock but then the problem is you have 50 molar H2O in your sample you have 100 molar protons from that and you need to get rid of it and you can do it by using gradients to do so. So I will refer you to two things one is just in your 101 and more NMR spectra an example of this they do it on sucrose which is kind of a lame example because you can never observe OHs but you're suppressing the region right around the water but the thing that I will do in conclusion is just give you a handout and one closing comment here this handout I find very useful. So you're still fighting the uncertainty principle if your protons are exchanging very rapidly you will not be able to see them because they will be part of the H2O peak that's suppressed. You have to get the exchange rate down on the order of hundreds of milliseconds or greater and this happens to be a graph for proteins from a book by Vutrich and what he points out is as a function of pH you have your exchange rate here this graph is a little confusing this is an exchange per minute. So the line that I've drawn at 10 to the 2 is exchange on the order of 100 per minute in other words a lifetime on the order of 500 milliseconds. So in this range protons like amide protons on backbones can be observed and in this range up here they're not observable. What does that mean? That means that you can never observe OH protons peptide and other sorts of amide protons can be observed in the acidic pH range but in the basic pH range their exchange rate goes fast. So typically you have to tweak with the pH a little bit. Alright that's I think all the sort of final brain dump I wanted to give you of things that I've found useful or think you'll find useful and I will see you a week from Saturday if not sooner.
This is a graduate course in organic spectroscopy, focusing on modern methods used in structure determination of organic molecules. Topics include mass spectrometry; ultraviolet, chiroptical, infrared, and nuclear magnetic resonance spectroscopy.
10.5446/19297 (DOI)
So, all right. So, yeah. So, I wanted to discuss this, the homework problem. I figure by now everyone's looked at it. Whether you've gotten it or whether you haven't gotten it, it's a problem that has, by the way, not, get one, I made 22 copies. All right. Well, whoever comes in late can get it. Anyway, it's a beautiful problem. And it actually was something that just came serendipitously in the research of the graduate student who happened to be TA for this course. He was trying to do an arntistert homologation on a CBC derivative of glutamic acid and ended up getting something he didn't expect and literally had no idea what it was. And as the structure unfolded, it ended up being a really beautiful structure, but also just a beautiful example of once you figure out a structure, being able to try to understand conformation, stereochemistry. And so that's what I'd like to share with you today. It's a challenging one. I think it also has depth so that even if you've gotten it, I hope you'll appreciate the additional perspective. So, OK. So the basic inspection of it, we have a molecular formula of C15H17NO5. That means you have eight degrees of unsaturation. We knew there's a CBC group in there. And so the CBC group can account for five of them. And so we still have a couple of other things going on in there. So I'll just say that that's five DU. And it's pretty obvious once you see the CBC group. And it's not going to end up telling us a whole lot. So OK. The IR was interesting. You see an NH stretch at 3363 broad. You see a couple of peaks in the carbonyl region. One at 1732. 1732 is certainly right in the region you'd expect in ester. The other one is at, let's see, the other one is at 1696. Carbomates are like amids, right? So you've got a, we know we have a CBC group. So carbomates are like amids. The nitrogen donates into the carbonyl. So that shifts it to lower wavelength. So that's pretty reasonable to be with that. NHs often have clear bends in the IR spectra. And so you can see an NH bend at 1531. And that's pretty prominent. That's right down in that region that I say, well, you can't do too much with, but if you know what you have, you can sort of pick stuff up. So NH bends kind of fall into that region right below 1600. All right. What I'd like to do at this point is to attack the spectra here. And so I've made a bridge version of the problem. I figure this is good. Even if you have your homework problem handy, you can feel free to annotate this and follow along with me. And so the general paradigm that we've been using in the class for structure solving is once you get the basics of the structure, once you get the basic analysis of figuring out something about the formula, figuring out degrees of unsaturation, looking at the IR, we're going to look at the NMR and letter of the peaks and at the proton NMR and letter of the peaks and at the carbon NMR and number of the peaks. And we'll work our integrals. And everything's pretty straightforward on the proton NMR spectrum, right? We have five hydrogens for peak A, clearly associated with our CBZ group. We have two hydrogens for peak B. Then we have a bunch of peaks that are one hydrogen. Then we have four peaks that are close together, one hydrogen, one hydrogen. Here you have to split your integral. So the relative is 2. You can just sort of divide as best as you can between the peaks and it becomes 1, 1 and 1. You can also in some of the peaks see a certain degree of tending in toward each other. So immediately when I look at, for example, the doublets of D and F, I look and say they probably are tending in to each other. They're probably diastereotopic protons. Also, you see a big coupling constant, right? You can get a pretty good idea of what a 7 Hertz coupling constant is from a lot of the patterns here. And this looks a little bit big. This is probably a geminal coupling constant. We have these two very interesting doublets. So in addition to these doublets here of D and F, we have these two very interesting doublets of G and I. We're going to see, and they're going to, I think, give you, I think they're going to give us problems. I think they've probably already given us problems in placing this group when you've worked this on your own. They're interesting. You have a very small coupling constant. They're tented in to each other. They look like they might be a geminal methylene group, and yet the coupling constant's very small. Then we've got some multiplets over here, another multiplet, and another multiplet. And there, we'll look at those in more detail in the end if we have time, because there's some really beautiful analysis associated with them. All right. Carbon NMR, we see 12, we see 13 unique resonances in the C13 NMR. We can just number them. 10 and 11 are really, really close to each other. They're about 1 1⁄ of a PPM apart in the carbon NMR. As we come into techniques like HMBC and HMQC, it's going to be really tough no matter how you expand to resolve at that level. Remember, I said you generally get about 10 24 slices with zero filling and so forth in the F1 domain, and your digital resolution's generally about 1⁄ of a PPM. So you may not be able to discern them. If you were in a situation where you had to discern two resonances, one of the easiest ways to shift things around is just to take a spectrum in, well, specifically in deuterobenzene. Deuterobenzene induces magnetic anisotropy from the ring current of the solvent. And very often, if you've got overlap like this, you'll shake things up enough to spread them out. Deuterobenzene or deuterotoluene are very good choices. We didn't hear, and it's not necessary to solve the structure. We'll see the one point in the HMBC where there's some confusion actually disambiguates itself because it becomes pretty clear which is which. All right, so we have all of these peaks. Let's see. These guys here are quats. These guys are methines. 7 and 8 are CH2s. 9 is a quad. 10 is a CH. So if you look very carefully, you can see we have a CH over here. And then we have a CH2 over here. If you look really carefully, you may notice that it looks like we even get a little bit of the CH2 coming up over here. So 10 comes up here. And it looks like you may have a little bit of a hair for 11. Remember that the depth technique relies on an average J value. We're going to see that this is part of a ring that doesn't have typical J value. So it shouldn't completely surprise you that your depth isn't quote perfect. 12 and 13 are CH2s. All right, so that takes us through our preliminary analysis of the proton in carbon. Where I like to go next is to the HMQC spectrum. And again, I try to be really fastidious about transferring our labels. And this axis here is going to become our Rosetta stone. It's going to become our workhorse in the problem. So I go and I just transcribe. And the goal, of course, is to correlate and figure out what's what and get our letter and number assignments together, G, H, I, J, K, and L. I'm going to get a different marker here. This one's getting mashed on the tip. All right, so we can go through very quickly. 4 to 6 are associated with A. 8 is associated with B. C doesn't seem to have anyone partnered with it. You've got a little broadness to C. C is pretty clearly our NH group over here. 7 is associated with D. 10 with E. 7 with F. So those guys were indeed diastereotopic. You can see things over here. As I said, it's very hard to disambiguate 10 and 11. But I think it's pretty obvious, since we know that 10 is the methine and 11 are the methylenes, I think it becomes pretty obvious which one is 10 here and which one is 11. So we have 11 G and 11 I and then 12 H and 12 J and then 13 K and 13 L. So that gives us, so this upper axis, now really gives us our workings of the problem for putting pieces together. And the first thing is going now to be to use the COSY to build up the fragments that we can. Then we're going to want to keep in mind what we don't know and then try to use HMBC to put those pieces together. All right, so I come in at this point to the COSY. And again, I very, very slavishly transcribe my axes. I always find it helps me avoid problems just by saying things to myself out loud. 4 to 6 A, 8 B, we have C, we have 7 D, we have 10 E, we have 7 F, we have here 11 G, 12 H, 11 I and 12 J and then 13 K and 13 L. And I'll do the same here, 4 to 6 A, 8 B, C, 7 D, 10 E, 7 F, and I have G, H, I, J, 11 G, 11 I, 12 H, 12 J, 13 K, 13 L. All right, at this point we want to start to work our way through the COSY. It doesn't really matter where we begin. Since the spectrum is symmetrical, right, we have our diagonal running along here. I just pick one side of the diagonal. If there's anything questionable, I check for correlation on the other side just to see if I see anything. We do seem to see a little cross peak here between 4 and I honestly didn't try to disambiguate which it was. So I'll just say 4 to 6 A to 8 B. Now that's kind of interesting. So I'll start over here. Here's our benzene ring where 4 to 6 A and our CH2 is 8 B. And this is kind of interesting because you don't normally see any sort of obvious splitting between the orthoprotons and the methylenes. And yet you've got a very small benzylic coupling less than a hertz. So it's not going to give you a splitting. But in the COSY, if you've got a big peak like this singlet here, you may see a cross peak for it. It's not a big deal. You'll, you notice this coupling if you take a compound like toluene, you won't see the methyl split at all. But the methyl on toluene is ever so slightly broader than another methyl. So say if you had a methyl ester or methyl ether in the molecule, that methyl singlet would be taller than the methyl on toluene because that toluene is getting a minuscule little bit of benzylic coupling too small to see less than a hertz. So no particular consequence. Now we're going to come along. And of course that's part of our CBZ group. And we know our CBZ group. So I will just continue over here. And the next peak that we see is a cross peak that involves that NH, right, that NH is C. And so we see C to 10 to 10E. And so that C to 10E peak basically takes us over to the methine over here and we're starting to build up our chain. There's nothing else that C is crossing with. The next cross peak we see is a trivial one. It's 7D to 7F. And that's that geminal cross peak. Your geminal cross peaks tend to be very strong. We don't see any other cross peaks off of 7. And that group is going to be a problem to us. As we continue we see we have some cross peaks here. Our 10E is crossing with 13K and 13L. And so that's going to allow us to build our chain. Oops. Questions or comments at this point? Yeah. So the carbonate, ah, okay. Oh, how do I know? Well we have this cross peak here that's kind of clowing us in that we're seeing this very small benzylic coupling. Yeah. Oh, because taken as a given was that we had a CBC group in the molecule. It was part of what was, I think it was listed in the, Yeah. Yeah. And we see cross peak between 6 and 10. So it's really a two-pegs thing. In the HMBC. Yeah. Yeah. The kinematics of touch carbonate. But I think in just the description of the problem I said there's a CBC. Yeah. And I, you didn't say which carbonate, like it was 8 or 7. It could have been 7. Ah, I see, I see what you're saying. Well at this, at this point based on this cross peak I'm kind of clued in. Now it's interesting, we know that the molecule has a stereocenter. We see diastereotopic methylenes. Every methylene in the molecule is formally diastereotopic. The CBC group could appear as two doublets forming an AB pattern or if those doublets are exactly at the same position, if the two protons are coincident then it appears as a singlet. So it's what, it's, it's actually probably right near a stereocenter because we have a carbon that has three different things on it and it's certainly possible they're coincident. If I took the spectrum in deuterobenzene it wouldn't surprise me if I saw an AB pattern with two doublets tending into each other. So I'm not going to make much, much of that assignment. All right, as we go through and continue we have mostly trivial NOEs. So for example in this, trivial cross peaks in the COSY. So for example these two cross peaks here are respectively 11G to 11I which is just a geminal coupling and 12H to 12J which is just a geminal coupling. But then we get a couple of useful ones over here. So we see 12H to 13K. We see 12J to 13L. And the strength of these cross peaks, you know, I mean here we see a teeny tiny cross peak associated with a very small coupling constant. The strength of these cross peaks reflects the magnitude of the coupling constant and the height of the peaks. But that allows us to complete our chain and so we go to C12, H, HH and HJ. All right, so that pretty much completes the information that we get out of here. We have one more trivial geminal coupling 13H to 13L. See this is why I love going through the HMBC first because I really end up not getting myself sweated up over duplicate information. I end up not getting myself sweated up over trivial information. We very quickly get the information we need. Now at this point we can start to make a little bit of a scorecard here. So we still have our issues of C1 and C2 to resolve. We have our issue of we don't know what's happening with C7, HD, HF. We've got our quad of C9 that we don't know about. We have another isolated methylene of C11, HG, HJ. That's the one with the funny small couplings on it. And we have three oxygens. And we should keep in mind that C7 is pretty far downfield. In the carbon NMR it's showing up at about 70 parts per million. In the proton NMR we're seeing these two resonances here around four parts per million. So I think pretty clearly C7 is probably attached to an oxygen. Now we just have to figure out how to put it in. So at this point I'm going to turn to HMBC and try to figure out how to nab the pieces. And again I'm going to be very, very mechanical in the whole process to help avoid making mistakes. I just go one, two, three, four to six. I'm not going to stress about assigning four to six. I could zoom in if I wanted to and figure out which one's the ortho one and so forth. But I'm not going to stress about it. It's just not that important in terms of the nature of the problem. Seven, eight, nine, ten, eleven, twelve, thirteen. And here's four to six A, eight B. C stands alone. Seven D, ten E, seven F, G, H, I, J with eleven G and eleven I and twelve H and twelve J and thirteen K and thirteen L. All right. So I'm going to, I'll start off of here. We have carbonyl number one. I mean one pretty clearly is a carbonyl. It's not a ketone, not at, not at 170 ppm or thereabouts. And so we look at this. Let's see. We have one to seven D, one to seven F, one to twelve H and twelve J and one to thirteen K. All right. So if we're trying to build up, build up a chain over here and we have one and it's got to be, got to be an ester group. It's crossing with twelve. It's crossing with thirteen. That's pretty much going to put it right over there. It's crossing with seven and we're pretty sure seven right where it's at has an oxygen on it. So it comes through, we've got an oxygen and we get our C7 HD HF. And so that's a really useful example of using HMBC to build up, build up our structure. So once we determine the 12 and 13 are next to each other, we know that we can see that one, four bond coupling is our limit. Well three is normally the limit. So we go from the hydrogen on C to C is one. From C, 13 to 12 is two and from 12 to one is three. And here from the hydrogen on seven to seven is one. To the, from seven to the oxygen is two and from the oxygen to C1 is three. I kind of played around if there was any way I could think of putting the carbonyl here but the only thing I, and saying maybe this cross peak came through here but then I would have had to tie up this valence as well and it would have been game over because I would have had to basically go around here. So there really is no, no way to build up this structure that I can, can think of. So will HMBC always go through hetero? HMBC goes through hetero atoms but remember the, the big caveat is you're not guaranteed to get an HMBC cross peak. Yeah, there's nothing special about hetero atoms. It's just going through the electrons making up the bonds. So you don't rule it out of this absence? Don't rule it, exactly. So the presence of a peak says two or three bond connectivity. We saw one example of four bond and if you have a little like intervening, a little like double bonds you might have more. But basically I'd say don't expect it to ever be more than, than three. So it's basically two or three. I have a quick question. Cross peak is between one and I, you ruled that out and you say that one is cross peak. One and, oh, okay here, one and I. I can't rule out one and I. What I can say from the shape of this peak in this dimension is clearly when you look at the, the lineup on this. So peak, peak 12J is wide. Peak 11I is narrow. So when you look at the lineup, it clearly rule, it clearly lines up. If I've laid my grid on there correctly, it clearly lines up with J. I can't rule out that that little lobe of the peak isn't also a cross peak of I. I just can't discern it from there and I suspect there's, there's just about no way I could do this. If I didn't run an inverse detected experiment and I ran a carbon detected experiment, remember I talked about het core and long range het core, then I'd probably get the resolution but the signal to noise is incredibly, incredibly bad in that experiment. If I really wanted to determine, as I said, I would probably use deuterobenzene as a solvent and see if I could shift things around. There's also a possibility of using lanthanide induced shift reagents that create a paramagnetic, better paramagnetic and shift things around if I really needed to buy pie first try deuterobenzene. Anyway, this is what I know thus far. Other questions or comments at this point? All right. So continuing along here, not that I think there's any doubt at this point, but we see a cross peak from 2 to 8B and so if there had been any doubts about what our relationship was over here, now we have it because our 8B goes again through the oxygen, it's a 3 bond coupling over to this carbonyl. We get some more cross peaks off of the benzene. This cross peak just by distance here to 8B is going to have to be the ortho. Honestly, I don't care at this point to assign my ortho, but if I wanted to, I could assign which of these guys was the ortho. All right. So let's continue on up into this region here. So the next one that's kind of interesting is we have 9 to 7F. Now 9 was one of our problem children because we've taken care of 7, we've taken care of C1 and C2, we've taken care at this point of all but one of our oxygen. So we don't have a whole lot left to play with. We have two valencies left on the molecule and we have just two carbon atoms and we have an oxygen atom and so we get this cross peak with 9 and 7. And it's interesting because the one thing that we know at this point, we know that carbon 11 can't be attached directly to carbon 7 because if carbon 11 were attached to carbon 7, we'd be seeing J coupling. I mean, methylene next to a methylene has got to give J coupling. So at this point, we have to attach carbon 9 over to here. And we're kind of stuck in the same position here. We can't be attaching carbon 7 over to carbon 10. So we really are stuck in an interesting position about how to put this together. And it's going to require a little bit of thought and I'll show you this at the end. Everything else that we get from this is trivial, we get 10 or 11 to 7 F. So can't be 10. It's got to be 11 here. I mean, you can't, if it's 10, it's got to be going through here. So you're basically now starting to be left in a puzzle situation. We've got to get over to here somehow. We've got to isolate this. We have valencies on this carbon that we need to fill. And so the only way to fill it is going to be to go ahead and have C11 HGHJ attached over here. And we have one oxygen left and we're not going to get any more useful information from the spectrum. We have to use our smarts to this. We've got 10 to 12 H here. That doesn't really tell us anything that we didn't already know. We've got 9 to 13 K. Okay, well that's consistent with this connection here. Let's see, we have 10 to 13 L. That doesn't tell us anything we don't know. We have 13 to 12 H and 12 J. That doesn't tell us anything we don't know. And so we're left here with one oxygen and two valencies. And the only place to put that oxygen is over here as an epoxide. Is there a reason why 9 is a total coefficient? Like 10 or 10? I want to do it. Geometry. So, methines are the worst. So, two bond couplings are all over the map. The J values can be all over the map. The oxygen and the hybridization probably make the J smaller here. But there's no guarantee of seeing a coupling. The one that I'll say is guaranteed, three bond couplings off of a methyl group. Isolated methyls are fantastic. Because the hydrogens point in all different directions and they rotate. So, a three bond coupling off of an isolated methyl, I'll say you'll always pick that up. In other words, if you have an isolated methyl like so, not in this molecule but in others. And you have a cross peak off of it. It may be a two bond coupling, but you're definitely going to pick up your three bond couplings off of an isolated methyl. Because you're always going to have a good carpolis angle. Three bond couplings from methines are the worst. Because if you are no way guaranteed to pick it up, because your carpolis angle may be 90 degrees, you may end up having no coupling. And epoxides are confusing for a couple of reasons. So, if you look at oxy-rein, the parent compound in the carbon NMR, and this is one of the reasons you have the Pretch book, you'll find, well first of all, of course, your Js are small. But you'll find that in the C13, it's about 40 ppm. I think it's 39 and a half. And in the H1NMR, it's about 2 and a half ppm. I think it's 2.54 ppm. Oxy-rein is very weird. And it's not specifically the SP, you know, the hybridization, the angles, because if you go to oxytane, the four-membered ring one, things go in the other direction. And it's a little too far downfield in the proton NMR, and a little far downfield in the carbon NMR. So that's one of the things that throws us, because we're not expecting 11 I and G to be on, have an oxygen attached. And yet, we're forced into reaching that conclusion by the fact that we just use up all of our evalances and use up all of our atoms. One more question I saw. Also, like, I keep seeing that cross-quickity, like, I, like, 13 to I, isn't it? Can you see it? Three cross-quicks, I, 13, so we see 13 to H. And the... Whoops, this is... Did I do this wrong? This is... You have J. This is, wait, G... I. Whoops. Let me correct this. I, and that's I over here. All right, G, yeah. Okay, so you're seeing a cross-pick. 13 to I. 13 to I. I guess I'm just... I mean, we see the one to 32K. So where, which cross-pick are you... So like, I guess I'll just make this one here. See, now, but you see, okay, let's look, all right. So let's look at that multiplet. It was the, it was the, the question was what was the glutamic acid derivative. It was the, the anhydride of glutamic acid. All right, so let's take a look at the peak here. So here's the peak we're looking at for the doublet. And you can see, so we've got this pattern of something that we've got a line, a line, then there's another line buried right under here. And so we simply cannot tell. Anything that was just off of peak I here would just line up with this. So we're seeing ones that line up with both. And so we just can't tell if we have anything unique. So then why wouldn't I do one cross-pick if it was just crossing with that one over there? Why, if it was just crossing with which one, this one? Yeah. Because this one comprises peak here and peak under here. It is purely overlapping. And so, you know, you can see that the last part of this peak is overlapping. And this is the problem with ambiguity. You have to be able to deal with ambiguous data. And, you know, the way I dealt with it here is I said I just can't tell. It's 10 or 11. But here I could tell that it, I couldn't tell if part of it was with 11i. But I certainly could tell there's one with 12 age. All right, at this point I want to redraw the ring. And then I want us to work on the stereochemistry of this compound. All right, so to redraw the ring, let's just go ahead. It's a seven-membered ring. And we have an oxygen. Let me, I think I will write it bigger here so we all get it. All right, so here's what we have at this point. We have a seven-membered lactam, lactone ring. We have an epoxide. We have a spiral ring fusion. I think this is the first spiral ring fusion we've seen in the class. We have two stereocenters in the molecule. So we've got to get those stereocenters relative to each other. And then a spiral ring fusion, understanding the confirmation of the ring is going to be even more important than it is in, say, a bridge bicyclic or a fused bicyclic system. Because we really end up having to figure out which hydrogen is close to which and which way things are pointing on the ring. So let us begin with the nosy spectrum. And we're going to have to assign our resonances. All right, let's see. And so I think I'm going to start. And we're going to have to make diastereotopic assignments of our resonances. So I'm going to give us a clean slate on this so that we can deal with things. Now, one of the things that you've got to keep in mind is you cannot assign the absolute stereochemistry of the molecule. Simply isn't possible, which means you just need to pick a stereocenter, assign it, and assign everything relative to that. In this case, I happen to know what the absolute stereochemistry was because I know which an anti-merb, glutamic acid we started with. So I'll actually give you the right one. So I'm going to redraw everything here in a way that's going to allow us to put in stereochemistry. So if you want, you can feel free to follow along with me. One, seven, nine, ten, thirteen, twelve. And so arbitrarily, I'm just going to pick HE as pointing up. Doesn't matter. All right. And so now we have the problem of the epoxide that we've got to deal with. All right. We have two expansions of the nosy for you. I will start with the first one and then we'll move into the second one just to make it a little easier on us. All right. So the things that are kind of interesting, we see the whole 4 to 6a to 8b bit over here. That's just the orthoprotons off of here. We have a little kind of something here off of the CBZ. I'm not even going to use it, but I'll show it to you in a second. We see 8b to 11g here. If you're confused because it's a pretty small peak, you can look. We have this stripe of T1 noise off of the big peak here, off of 8b. If you look, you can see symmetrically that it appears over here. So this is 11g to 8b. We're not going to. So what we're getting is it's off the CH2 of the CBZ and it's going to be to the CH2 of the epoxide, but I'll show you. We're going to see two more peaks, one off of HC and one off of He that will give us that same information. So we don't need to stress over that. All right, let's move in to the expansion of the nosy and we'll find everything that we want to need over there. All right, so off of. Let's see, where should I start? So off of C, we see 11g. So let me transcribe my letters. C, 7d, 10e, 7f, g, h, i, j, 11 and 11, 12 and 12, 13k, 13l. Let me just do the same here really quick. 7d, 10e, 7f, 11g, 12h, 11i, and 12, 11, 12j, 13k, 13l. All right, so a picture is going to emerge as we start to work this. So we've got 11g to C and 13l to C. So the fact that we're getting. All right, so we've got 13l over to C and. So it's sure suggesting that we have a cis relationship over here, not proving it at this point. And then we've got 11g to C. So that's interesting because we have our epoxide over here. We don't yet know the stereochemistry. This is going to prove to be the toughest, toughest part of things. But we've got this relationship here. And let's see, where do we continue to go? All right, so let's continue to work our way and just assign our resonances. So we've got 10e, a little hard looking in here. We've got 10e to 7d. This one's trivial, 7f to 7d. That's just a geminal. But 10e to 7d. See this one, this is really interesting. Because I can't be sure these two are cis here. If I see one big NOE, so 8s, actually I can be sure they're cis. Because I don't see an NOE between C and K. If I saw an NOE between C and K, and this one was big, and this one was little, I could be sure they're cis. But if I don't see an NOE, that also, I mean basically you have to be making comparisons here on geminal ones for figuring cis. But once you're moving over to a 1, 3 relationship, the only way that you can get an NOE of any size like this one, like this 10e to 7d, is for them to be cis. And probably, probably in an axial relationship. So that one here is really, really useful because it gives us a stereochemical relationship. And it's going to start to give us a confirmation. All right, as we continue, we're going to see more like this. So we see 12j to 7d. And that's interesting because that continues to take us in this non-adjacent relationship business here. And so we see that one. That's giving us this. And if we continue to go, we're going to see a couple more that are very useful. Let me show you. All right, so we see 13k to 10e. 13k to 10e. So that's kind of corroborating our earlier assignment on this, the stereochemistry of those diastereotopic hydrogens. 12j to 10e. And you can kind of now see, if you look at the alignment here, you notice where this cross peak is centered, David. See where this cross peak is centered here? And you notice where this one is centered here. See that little offset on them? So now we can start to get some distinction here. So we see 12j to 10e and we can go ahead and say, all right, 12j to 10e, that completes things around here. And then we're seeing 11f, 11i to 7f. And we're seeing 11g to 10e. So this is interesting. So we're continuing to make this network of NOEs over here. Most of the remaining ones are trivial. I think we see one more. There's a bunch of geminal NOEs in here and visceral NOEs in here. And yeah, so that pretty much gives us our key NOEs. What I want to do at this point is to build up the conformation of the molecule. And I was joking last time. I just say, let me do this over. I'll do this here. Then we'll end up pulling the board in front of it. All right. I was joking last time that I can draw two types of rings. Let me show you how far those two rings will get you. So if you treat a cyclohexane ring like a cyclohexane ring and you say basically, you can think of it just as an extended cyclohexane ring. That will take you pretty far in terms of your relationships. And we see our HE, our HJ, and our HD all have these nice NOEs to each other. It's this ring of NOEs that I've written over here. And that really superimposes very nicely on this model. That puts our HC here sitting in an equatorial position, it puts our lactone over here, puts HL over here, HK over here. Now we last have an our HF over here. Now the last thing we have to deal with is our epoxide. And our epoxide, the way I've drawn it, you probably won't be that experience at this point, but the way I've drawn it now, I think you can end up seeing. We see an NOE from HI to HF. We see NOEs from HG to HE, NHC, and also to the CBZ group. And so that puts our methylene out here like so for the epoxide. It gives us our epoxide stereochemistry and it assigns, so that sets this stereocenter. And now we just have our specific resonances. And so pointing out is HI and pointing back is HG. And if you look at a model, let me very quickly, if I can make my computer talk to the projector, I'll pop that up. If not, I have a printout. Let's see if it warms up quickly enough. Let's see if they talk to each other. So, give us one moment. Here it comes and if not, all right, I'm going to pop. All right, great. Then let me, all right. So, this is the model here. And what's nice is you can, you know, look, if you're experienced with these types of rings, you can probably do this on pencil and paper. But building a model to influence your thinking and being able to query that model and say, you know, okay, what distance do I expect in this model? Is this consistent? Is so valuable. The other thing you can get better than I can do with my pigeon drawings here is your coupling, your dihedral angles. And it turns out that these are really, really beautiful. When you look, there are three multiplets here that are very, very dissectable in this structure. And I'll just, I'll just flash this up and conclude us, conclude us with this here. So, the three, the three multiplets that I think are just, just beautiful to analyze is you can work through this multiplet is a DD, D, with 14.9, 8.2, and 1.8 hertz coupling. This one's a little tough. If you push yourself, you can get it as a DDD with 14.3, 8.1, 4.5, and 1.9. And this one, if you really push yourself, you could call an apparent QD with three big couplings. It's a DTD with 13.9 for the big 11.7 and 1.8. And I felt very, very proud of myself because after working very hard on those multiplets, I just plugged them in in my first order, order simulation. And they really matched, matched like a fingerprint on that. So, so then you can correlate that with your confirmation. Yeah, no. Well, actually I probably learned a few things from people in class on this one. Right, the mind's more symmetrical because it's only first order. All right, I've kept you a long time. So, we'll, we'll talk this afternoon about Vailala and some of the others. Thanks.
This is a graduate course in organic spectroscopy, focusing on modern methods used in structure determination of organic molecules. Topics include mass spectrometry; ultraviolet, chiroptical, infrared, and nuclear magnetic resonance spectroscopy.
10.5446/19295 (DOI)
All right, well I think maybe we'll begin even if the last few people come in. So I want to talk about two related techniques today. They're related in pulse sequence. They're completely different in what they do. One of them is toxy and one of them is rosy. So toxy is a correlation experiment. It stands for total correlation spectroscopy. I'll put total in quotes because one doesn't get an infinite number of cross peaks. This technique was co-developed at the same time with another technique that's the same pulse sequence called ho-ha-ha, which always sounds good at Christmas time. It stands for homonuclear Hartman-Hahn spectroscopy. And they're the same technique, but toxy has taken over. So the idea is that you get cross peaks with all, and again I'm going to put this in quotes because there are limits, other spins in the spin system. So what this technique is like is it's like a super cozy. I mean I'll give you a really simple example here. If we have propanol, and that was sort of the sketch of the molecule when I gave the first intro to 2D spectra, if you have propanol, cozy will link your methyl group to your central methylene, and it will link the central methylene to the next methylene. And assuming the OH is exchanging rapidly, that won't be linked in there. What toxy will do since all of these groups are in the same spin system is toxy will also link the methyl group to the terminal methylene. And where toxy really, really shines, there are sort of two different situations that toxy really shines. In the small molecules realm, where toxy really shines is in situations of overlap. And I've been pretty good about giving you spectra where there's not too much overlap and you can walk your way through cozy. But sometimes you'll end up with peaks overlapping on other peaks and you simply stop being able to walk your way through. And so you look and you say, hey, what's going on here? I can't figure out my way all the way through. So I'll just give you a couple of hypothetical examples that maybe illustrate my thinking on this of a case where you might have overlap. So like if you take a molecule pentanol, and we think about where things typically show up at it, we'd say our plain vanilla methyl is 0.4, a methylene that's next to an oxygen say is at 3.5 parts per million, a methylene that's beta to an oxygen, that's going to be, I don't know, somewhere around 1.9 parts per million. But by the time you get down to this methylene chain, bless you, you're going to have your methylenes pretty much unperturbed, both at about 1.4 ppm. In other words, if you go into the cozy spectrum, you're going to get into a quagmire right here where you have trouble tracing your way through the cozy spectrum. And so those types of issues, if you've got multiple spin systems in the molecule and you're really trying to figure out what your fragments are, those types of issues can be problematic. And so again, let me give you a molecule and just sort of talk about typical chemical shifts. So if we'd say, all right, an ester, a methylene next to an ester, I usually think 4.1 ppm, plain vanilla methylenes, I think about 0.9, methyls, I think about 0.9 parts per million, a methyl group that's beta to a carbonyl, I think about, say about 1.1 parts per million. In other words, it's beta to an electron, a drawing group, so it's at the plane position shifted down by a couple of tenths of a ppm. But then if you think about a methine that's, say, beta to an oxygen, normally I think about a methine maybe at 1.9 ppm, but by being beta to an oxygen maybe it'll be at about 2.4 ppm. And normally I'll think of, say, a methyl group as next to an ester as being about 2 parts per million, but if it's a methylene group, it'll go down by another about 0.4 parts per million. So you could easily see how a molecule like this might have two spin systems where when you try to trace your way through you get caught up. And so if everything overlapped at 2.4, it would be really hard and a cozy of a molecule like this to distinguish this spin system from this one. In other words, to try to walk your way through and see if this methyl was part of a different spin system than this methyl over here. And Toxy's extremely good at doing this. The other thing that Toxy is good at, there's a parameter that's very important in Toxy called the spin lock mixing time. And so when I say all other spins in the spin system, we're typically talking about within a limit maybe through about seven bonds. If you vary the spin lock mixing time, and you can use Toxy as sort of a super cozy experiment where if you have a very short time, you basically get just one jump just like from here to here. But if you go a little longer, two jumps starts to appear. If you go a little longer in your spin lock mixing time, more and more go. So you can do a series of Toxy experiments that'll basically walk your way from one spin to the next to the next. And what's good is if you have a region where there's overlap, and then a region where there isn't overlap, so like the overlap might be a 2.4 in this molecule, and the region that doesn't have overlap might be at say 1.1 and 0.9, you can go ahead and walk along those Toxy tracks and see who the coupling partner is for each, and then do longer and longer mixing times to pick them all out. So that's one really good use for Toxy is overlap. The other really good use is I'll call it biopolymers, which sounds like something intimidating, but any sort of molecule that has spin systems that are units within it. So there are many types of macro lactams and many types of antibiotic cyclic esters that have unnatural amino acids that have a series of spin systems. I'll just show you some biopolymers. So for example, peptides and proteins. And so if you think about it, each amino acid in a peptide or a protein is its own spin system and so forth. Where each unit comprises a spin system, and so you can pick out all of these spin systems and basically very quickly assign all of the resonances in a polypeptide. We'll do an example of this with a cyclic peptide. Sugars are another example. We just saw Professor Peng Wu's seminar and he was working with various types of oligosaccharides. And so each oligosaccharide, each monosaccharide unit is an isolated unit and they're often very heavily overlapped. And so I'm just giving sort of a generic cartoon of an oligosaccharide structure. And so each sugar unit is its own spin system and toxy, they're very crowded together. They all end up having similar chemical shifts. And toxy really shines at working with oligosaccharides. And the other area that works out very well with toxy is nucleic acids, DNA and RNA, where again the basic unit is sugars and bases and each sugar is its own little spin system. So you have a nuclear base and depending on if it's DNA or RNA you'll have an OH at these positions. So I'll just put this in brackets. So again all of these are representing kind of pieces of a biopolymer structure that might be useful for elucidating. So as I was hinting at before, one of the limits of toxy is it doesn't go on forever. And so the limits are, I'm going to say I always hate to put a hard number, about seven bonds. So for example, what do I mean? I mean let's say we look at the molecule lysine. The lysine is an amino acid with a four carbon chain. I'll put this as part of a biopolymer. So if you're talking about tracing your way from the epsilon carbon to the NH group, you're going through one, two, three, four, five, six, seven bonds. That's about as far as you would go. And so in other words you'll end up having this hydrogen if you do it right, crossing with all of the methylenes along the way, giving cross peaks, as well as if you do it right, the NH group. Unless you do the experiment in D2O in which case the NH group will have exchanged. So as I said, the parameter is, the key parameter is a mixing time. And typically this is one of the experiments. The experiments downstairs that are like a COSY experiment or an HMQC experiment or an HMBC experiment, the parameters John Greaves gives you. If you take this sort of default 10 hertz HMBC experiment, that's going to be one size sort of fits all. In the case of a TOXI experiment, you actually have to think intelligently about the experiment. Small values are about 75 to 100 millisecond spin lock mixing time. And obviously you'd want to go to the high end to pick up longer correlations. You might go up to say 200 milliseconds. If you go shorter, particularly if you're down sort of in the, let's say 25 to 75 range, you'll be using the experiment as kind of a super COSY, but one where you can walk your way from one bond to the next to the next. Now one of the implications for your own project is that with Stricknein is because Stricknein has some really extended spin systems, you may not be able to trace your way through all of the spin systems, but you'll be able to get part way. The other limitation, so obviously, so one limit is the number of bonds. The other limit is your coupling basically proceeds directly depending on how strongly things are coupled. In other words, if you have a very small J, that can lead to an absence of cross peaks. So it's not so much an issue with a flexible chain, but if you come down to Stricknein and you're tracing your way through a spin system where one dihedral is close to 90 degrees, your coupling constant is very small, you know, a hertz or two or zero hertz. If you have a really small coupling constant, TOXY may not take you through. Basically you need to have some reasonably large coupling. So you may see things behaving as if they're isolated spin systems or nearly isolated spin systems. So at the end, now the nice thing about TOXY as I said is it's very good at dealing with overlap and I'll show you in just a moment an example where you just would be struggling like crazy by COSY and we're going to assign, you know, a zillion different protons in one fell swoop. There's an alternative that's extremely powerful and we'll talk about it in the last week of class. And that's the HMQC TOXY. So TOXY works as long as you can find some regions where there aren't overlap and you can get like one resonance that isn't overlapping, but if you've got really bad overlap, you may even have trouble tracing your way through with TOXY. The HMQC TOXY is a variant that's like TOXY, but it has the dispersion of the C13 dimension. Remember C13 resonance is because you have 200 ppm end up having very little overlap and so the dispersion can be very, very powerful. That's too much for us to assimilate at this point, so let me just say I'll show you that in the future. All right, what I'd like to do now is to talk about, give us an example of one molecule, we're going to assign every resonance in this molecule. And the molecule is Grammocide S, it's an antibiotic and it's a non-ribosomal peptide, but that means it's not synthesized by the traditional tRNA, DNA messenger RNA, tRNA mechanism. And its structure consists of five amino acids that are repeated twice and so I'm going to draw the structure of the molecule and I'll draw it kind of in a stylized fashion because I think that's actually useful for reflecting the conformation of the molecule. So the molecule starts with a proline and we next continue with a valine and we next, it's a non-ribosomal polypeptide. So we next have an, call it unnatural amino acid, but it would be better to say non-proteinogenic or non-ribosomal amino acid. And so the next one, I'll label this as valine, the next one is Ornithine. Ornithine's like lysine except instead of having a four-carbon chain, it has a three-carbon chain, so one, two, three. The next amino acid in the molecule is leucine. And the final amino acid before we repeat ourselves is the unnatural enantiomer of phenylalanine, so that's D phenylalanine. And so that's half the molecule and then the molecule repeats itself, so let me write leucine up here. Then the molecule repeats itself and so now we're going to continue around with proline and the next amino acid is valine and then we come to Ornithine once again. And then we come to leucine. Just draw it. If you don't want to draw it out, that's fine too. Do you have anything better to be doing right now? All right, as you can see, there are a lot of different hydrogens in this molecule and one thing to keep in mind is there's actually some sense to all of this. In other words, you look at a molecule like this and you'd say, oh, well, okay, alpha protons, that's the proton that's directly next to the nitrogen and next to the carbonyl and you're going to say, oh, wait, that's next to an electron with drawing group, it's tertiary and it's alpha to a carbonyl and so you'd say, oh, okay, well, tertiary brings you down field next to a carbonyl, shifts you down field next to an electron with drawing group, shifts you down field and you end up in the 4 to 5 part per million range. Or you look at the beta proton, say, in valine that's 1 over and you'd say, oh, well, okay, now that's beta to an electron with drawing group so that's going to go down field a little bit, it's tertiary so that's going to go down field a little bit so it's going to be a little down field of 2 parts per million. Or you look at the gamma protons, the ones on the methyl groups and you're going to say, oh, okay, those are methyl groups that aren't really near to anything so those will be like 0.9 or maybe 1 ppm and so similarly we're going to have alpha, beta, gamma, delta for the ornithine and we'll have alpha, beta, gamma and delta for the leucine and alpha and beta and then all the phenyls which if you wanted to you could call them delta, epsilon, etcetera and then similarly for the proline alpha, beta, gamma and delta so we start to make some sense of this. Now one thing that's nice even if you're not an expert in this area even if you don't do this stuff a lot what's nice is okay you can always sort of look up where things typically go up and so I will start with a little handout for you and basically what these data that I'm passing out are is really just what we've intuited when I started to go through the valine there with an example. These are just typical chemical shifts of unstructured amino acids in water. By unstructured I mean not part of any sort of alpha helix or beta sheet and so pretty much just as I went through and said hey we can intuit that your alpha proton on your valine is going to be somewhere in the 4 to 5 parts per million region and your beta protons are going to be somewhere a little down field of 2 parts per million and your gamma protons are going to be somewhere around.9 parts per million you can go ahead and look that up and you can do the same thing for leucine and so this basically provides you with good guidance for things you might already really know. I mean in other words you look say at ornithine and you'd say okay well where should the delta protons at ornithine show up? Well you've got this ammonium group next to them nitrogen isn't as electron withdrawing so you'd say oh about 3 parts per million but you could look and say okay lysine where does it say for the epsilon protons on lysine and you'd say oh okay about 3 parts per million my intuition is correct so this can be a nice help. The flip side gives you all 20 of the protein and genic amino acids so you don't have to go ahead and know exactly what they are. Alright so we are going to use these to help us assign our resonances but of course ultimately because things will vary this compound has some structure to it it happens to adopt a beta sheet structure things may not show up at exactly these positions plus every amino acids neighbor will shift it around but you can look and say okay where would I expect say the beta protons of phenylalanine to show up and you can say well it's a methylene it's going to it's next to a benzene ring it's beta 2 and nitrogen you'd say oh somewhere around 3 ppm or you could go ahead and say look where would I see for phenylalanine oh yeah I'd see somewhere around 3 parts per million for the beta protons. Alright what I would like to do at this point is to for us to look at the actual toxy spectrum of gram-a-side in S and so to answer your question yes the structure is written out so if you're drawing really did look like a disaster then you have it here but then you'll have to keep have to keep flipping flipping over and over again to keep labeling our resonances. Alright so what's funny it's only good for one laugh it never gets two out of people. And it's not even Christmas time. Alright so whenever I'm dealing with a heavily overlapping spectrum and I want to want to help my eyes out I like to slap a grid on the thing just to help help me see things line up. You can also use a ruler but it's very very nice and very gentle on your eyes to be able to say trace across peak over and then trace the cross peak right up over here. So I like to do that. What's because toxy is like a super cozy you basically can trace an entire track off of toxy and get everything in a spin system. Now remember a spin system isn't always the whole amino acid so for example in phenylalanine the benzene ring is one spin system that's separate for all intents and purposes not coupled to the alpha proton, the beta proton and the NH proton. I'll even draw in my NH. So this happens to be a spectrum in DMSO so this is in DMSOD6 and this particular one happens to have a 78 millisecond spin lock. Spin mixing time. Now one thing about molecules with NH's and OH's those generally exchange rapidly so if I took a spectrum in D2O we would just see an HOD peak like we did in our hydroxyproline problem we just see HOD but in DMSOD6 the protons don't exchange so you're going to have NH's and so forth there. If you want to see your NH's in water you can actually do an experiment where you use 90% H2O and 10% D2O for locking so most of your protons, 90% of your protons stay as NH's and then use water suppression because you're working with millimoles of compound in 100 molar water, you know 50 molar H2O and 100 molar of protons. Alright so let us start and let's look at the anatomy of the spectrum. So the anatomy of our spectrum and I'll show you along this axis your alpha protons are over here, your methyls are over here, your NH's are over here, this is your phenyl group so I'll label it, we'll put all of our labels here so this is our phenyl group from the phenylalanine and let's see you've got some betas and gammas and deltas over here so. And so that kind of gives us our starting anatomy right, our methyls are kind of at the.9 ppm range, your alphas that are directly next to electron withdrawing groups are down here, your NH's that are attached to nitrogen are over here. Alright what we're going to do now is use toxine to assign every resonance and I want to show you the power of the toxine technique and we'll just take a single track in the toxy. So I'll start off of this peak here that's a tight little doublet and I'll draw a line just to help my eye trace along and you look and you say okay so what sort of residue has an alpha proton and a couple of protons at about three parts per million? Is it the valine? What does the valine have in its spin system? And what types of protons do we get in the valine? What residues, what do you have in valine that you don't have in say ornithine or phenylalanine or probably methyl? So we would expect cross peaks somewhere up here so it's not a valine, it's not a leucine, so we have alpha protons and one other sort of proton in that residue so what is that residue? And those protons are right around three parts per million. So phenylalanine because we just have two other protons, the two diastereotopic beta protons so you trace your way up here and in this cluster of three which we could expand upon is your phi alpha and you trace your way up here and here are your two diastereotopic phi betas. And you can kind of see the ABX pattern of one of the phi betas tending in to the other. So that basically assigns one of our residues. Alright, let's go on to another one. Let me take this toxy track. So I'm going to label this guy as well, he's our phi NH so we are going to assign all the residues here. So let me take this next toxy track. So what does this cross peak tell us? Methyl. So this is valine or leucine and what did I say about the gamma proton, the beta protons of valine? Methine typically, it's beta to an electron withdrawing group so it's typically about two a little further downfield than two. So this is our leucine. So this is our phi NH, this is our leu NH so I'll just trace that up to here on the diagonal. So there's our leu NH. So our leu methyl are hiding right in this cluster here. So that is our leu deltas and then our leu betas and gammas are lumped together over here. Where's our valine hiding? Yeah, the one just below it. Look at that, sneaky devil. Sneaky devil at valine NH is hiding right under the phenyl group and you wouldn't have known it except that darn fetal is not part of a spin system with methyl groups. And here we see the cross peak for our valine gamma protons, the methyls and here's the cross peak for our valine beta proton and look at that. That valine beta proton has a nice splitting pattern because it's a hydrogen that's split by the methyls and also split by the methine. It actually ends up being a doublet of septets if you want a technical analysis for it. And hiding under here is our alpha proton. Oops, I meant to mark, I marked our leu betas and gammas, I marked our leu NH and so if I trace up here, that guy is the leu alpha so I'm going to label him because we are going to victoriously assign every resonance here. So okay, we've got our leu alpha, now let's go on and we'll do our valine toxy track. So sneakily hiding under here is our val NH, underneath this group here is our val alpha, right close to the phenylalanine alpha, here's our val beta and underneath the methyl cluster a little bit off on the side if you trace your tracks is your val gammas. Alright, so we've got our val and this is our phenyl. Alright, so what do we have left to trace out? So we've got one more, this is the whole NH region here, so we've got one more NH but something's funny, something's funny about this. What's left for NH? Ornithine, proline doesn't have an NH, it's the one amino acid that doesn't have an NH. So this has to be, this has to be ornithine and yet you look at this guy and you say wait a second, okay so we've got our alpha here, we have, this has to be ornithine here. We've got our alpha, that's the alpha over here. We've got a bunch of stuff over here but remember what I said, the delta of ornithine is like the delta of lysine, it's like the epsilon of lysine, right, it's next to an ammonium group, it should be at about three parts per million, we don't see a track for it. Now we're doing a 78 millisecond spin lock time and remember I said the longer the spin lock time, the more jumps you can make but of course is the big caveat, if you go too long you've got relaxation. You're also putting a lot of power into the spectrometer for the spin lock mixing so you can't go too long or you're going to be turning your sample into cooked eggs, you're going to be heating it up with all the radio frequency radiation. So you have to go six hops to go from the NH of ornithine to the delta protons of ornithine and we're not quite going there in 78 millisecond spin lock mixing time. So normally if you go there you see the same tracks repeated again and again so for example you get a toxy track for the phenylalanine alphas where you can see here you get the, on the phenylalanine you get the betas and you'll get the alpha proton here and then the NH over here but here we're not getting all of our cross peaks so we're getting our ornithine, you're getting your ornithine betas and gammas, they're right under here but not your ornithine epsilon but look what happens now, if we haven't gone all the way through I can just pick a different toxy track so if instead of starting at the ornithine NH I start at the ornithine alpha proton, now look you get one more cross peak so you still have this cross peak here but now we get one more and there's our missing orn delta protons and so the orn delta if you trace it up traces up right underneath over here so it's right over there. Alright we have only one residue left to assign at this point, all we have left to assign is our proline, this by the way is our ammonium so this is our NH3 plus and so all I need to do is pick an unclaimed residue and work my way through so we haven't claimed this guy yet right, he kind of stands out and he's got to be something associated with the proline and he's too far up field to be a proline alpha proton so he's our proline delta proton alpha, beta, gamma, delta so there we'll start with our proline delta proton and I'll just draw my toxy track, proline of course doesn't have an NH so we have nothing out in the NH region and I can just trace all of my cross peaks so we have our proline delta over here and then I can trace these guys up here so here's my proline alpha, it's lumped right under here, looks like it's a little bit down field so it's that guy right at the edge, there's our pro alpha, there's our pro delta right over there, I'll just, whoops and then these guys over here are our proline betas and gammas so I can just trace them right up and it's basically one of them is lumped under our water peak and then one of them is over here and then the last one is kind of right over here and so these guys are our pro, beta and gamma and so the point in this is in very short order we've gone ahead and been able to get all of our resonance assignments for, I don't even know how many different protons but bunch of different protons and it was a lot less painful and a lot more quick than trying to trace our way through a cozy and in a cozy in that region with the betas and gammas where things overlapped heavily we would have been completely stumped, we would have traced our leucine metals into the beta and gamma region and never been able to trace our way over to the leucine alpha or the leucine NH proton, we would have been lost so this is a very nice example of how Toxy deals with overlap. Alright the last experiment I wanted to present is Rosie, we've already presented nosy, nosy is a 2D NOE experiment, the big problem with nosy is that you go from having positive NOEs to having negative NOEs as you go from small molecules to very big molecules in that intermediate range molecules of say molecular weight of let's say about 1000 to 1500 you often have zero NOEs and what Rosie is is NOEs in the rotating frame, it's rotating frame overhouser effect so it's basically like nosy but for intermediate weight. It's actually the same pulse sequence as a Toxy, it uses a different level of power in the spin lock mixing and so it's good when you have molecules that have zero NOEs so I want to go ahead and show us the rosy spectrum for gram-a-cyton S and Rosie is particularly good for dealing with stereochemistry and conformational analysis just as we use NOEs to deal with stereochemistry and conformational analysis in proximity you can use rosy for the same thing. So I'll show you an example and I'll show you one little highlight. So here's our oh and I should give you your next handout and actually I'll give us two handouts so I can finish us up here. So this is the what I'm handing out right now is the rosy spectrum of gram-a-cyton S and I just want to show you what it's showing about the conformation of the molecule and then what I'll do is just give us a little hint on the upcoming homework set where we'll use Rosie and Toxy. If there aren't enough sweep them over I made enough of these. All right I've actually drawn the molecule I've drawn gram-a-cyton S in a realistic conformation it's actually this extended conformation and what's cool about this extended beta-strand conformation is you can basically trace your way from residue to residue. So each of your alpha protons are pointing basically your side chain is pointing out of the blackboard and back into your blackboard the hydrogen here is pointing like this the hydrogen here is pointing like this the alpha hydrogen here is pointing like this while the valine side chain is pointing out and so what this ends up doing is it puts the interresidue distance as very short and actually gives you a much further intra residue NH alpha distance. So let me show you how this manifests itself in the Rosie spectrum of the molecule. So this region here and of course this region here is the cross peaks between the NHs and the alphas right because we've got our NHs here in the 8 ppm range and the alphas in the 4 to 5 ppm range. So we've just blown this up over here this is actually from Nakanishi's books and Nakanishi blew this up. So let's go ahead and look at say this cross peak here this is a cross peak between phenylalanine NH and lu alpha and you notice that cross peak is very very strong right here's our phi NH here's our lu alpha and then if you look at the other cross peak off of the NH it's much weaker this is our this one here is our lu lu NH lu alpha this is our I'm sorry our phi alpha phi NH to phi alpha it's much weaker because they're not staring each other in the face. You see that same behavior over here this one here is our lu NH to orn alpha and again these guys are staring each other in the face here's the lu NH here's the orn alpha and you'll notice the cross peak with the of the lu NH and the lu alpha is much weaker. Remember NOE cross peaks vary as distance to the inverse 6th so if you have two hydrogens that are close to each other like two and a half angstroms you get a much stronger NOE that if you have hydrogens a little further apart like three and a half angstroms remember that table I put up of relative intensities where it was like a tenfold difference in intensity of NOEs. Normally here you have the orn NH to val alpha and so that's this one right over here so you can see this sort of extended beta strand conformation of the molecule. Okay you're going to use this exact same type of analysis in your homework to assign all the residues in this molecule which forms a hydrogen bonded dimer and I want to give you a couple of little hints on it. One of the little hints is in assigning your resonances you'll be able to identify these methylenes this methyl and methylene you'll be able to use NOEs to walk your way over the ring and you'll be able to use COSY and TOXY to walk your way through the aromatic ring systems. You'll be able to look for hydrogens that are close to each other across the ring and see evidence of dimerization in your structure. Of course if you have two hydrogens that are symmetrical you won't see a cross peak between them because they're one resonance. Have fun with this you will actually be able to apply these same skills to basically work your way through the spin systems do the TOXY to get all of your assignments and then do the rosy to go ahead and figure out which hydrogens are close to each other. You can't see a proton with itself because if you have a hydrogen at 4 ppm and it's the same hydrogen at 4 ppm you can't get a cross peak so those two are symmetrical. Alright so that will be something you'll be doing I guess over the weekend.
This is a graduate course in organic spectroscopy, focusing on modern methods used in structure determination of organic molecules. Topics include mass spectrometry; ultraviolet, chiroptical, infrared, and nuclear magnetic resonance spectroscopy.
10.5446/19291 (DOI)
I want to move on and start talking about 2D NMR spectroscopy. And what we're going to do, we'll be using this as a tool very, very useful for structure salving. There's a whole sort of alphabet soup of different techniques, but rather than just unleashing a torrent, I mean people do research in this area just like they do research in organic chemistry. And so the big thing is invent a new technique to self-specialize problems. But rather than trying to sort of talk broadly about everything, we're going to focus on getting a few tools in our toolbox and see how to use these techniques to address different problems. We'll start out with two tools in the toolbox. That will be HMQC and COSI techniques. And then we'll add some more tools and I'll try to put them into some sort of context. There are two additional lectures that aren't specifically on 2D that will come in either possibly next time or the time after that. So we'll be talking specifically about the nuclear overhouser effect which applies to 1D NMR as well. And we'll be talking about dynamic NMR and dynamic effects in NMR spectroscopy. But we're going to start so our next homework set will start to bring in 2D and I'd like to get you familiar with the tools. All right. Theory, I'm going to start really, really simple minded. And I think this is actually a good way to think about things. So in 1D we said the basic idea was you pulse and then you observe, right? That's your 90 degree pulse. The observe is your FID. Have you now seen your FID on the spectrometers? Have you seen this, you know, the little wiggly squiggly cosine wave with a die off? So this is your FID. And of course what you've got here is an amplitude domain. And then over here you have time, right? This is literally your signal dying off with time and the cosine wave that corresponds to the periodicity of the various nuclei. And so the whole idea in a 1D Fourier transform is this time domain on the x-axis ends up getting transformed to a frequency domain and that's your parts per million. And so your spectrum still has amplitude on the vertical axis and it has frequency in the units of PPM on the horizontal dimension. And the reason we call this one dimensional NMR spectroscopy is not because this is a 1D graph. It's not. You'd say this is a 2D graph. It's because you have one time dimension and that gets transformed to a frequency dimension. Now in 2D NMR you get two time domains, two time dimensions in the FID. And they get transformed into two frequency domains. So I'm going to give you, just as I have given you my simplified version of an NMR spectrometer, an NMR spectrometer, an IR spectrophotometer, and a mass spectrometer and so forth, I'll give you my simplified version of a 2D pulse sequence. A 2D pulse sequence is going to be pulse weight, pulse observe. And so what you do when you do this is you get two time dimensions because the weight is, you're waiting for some time. You're going to vary the weight and then you observe. And so this first weight becomes time 1, we'll call that T1, and the second weight becomes T2. Now these are not to be confused with the capital T's we talked about for relaxation. Remember we talked about capital T1 is vertical, is spin relaxation where the magnetization returns to the Z axis, and capital T2 is spin lattice relaxation where the magnetization spreads out in the XY plane. These are lower case T's and they in turn transform, when you do a 2DFT they transform to two frequency domains. And so you get a spectrum that might look like this where you have one domain here and this is called your F2 domain and then another domain here and that's called your F1 domain. Now what does this mean? As you're varying T, well you understand here of course in T2 you're collecting a signal and it's dying off with time. So you understand that basic transform that if the periodicity of this signal is one cycle per second, we get a line at 1 hertz and if the periodicity of this line is two cycles per second you get a line at 2 hertz and if it's a composite of one cycle per second and two cycles per second and others you get a spectrum consisting of many lines. Now similarly as you vary this T1, let's say starting with hypothetically a millisecond in the first experiment then the next experiment two milliseconds, the next experiment three milliseconds, the next four. Another periodicity occurs. In other words your FID what you observe in this time also shows variation that occurs in time. Variation, amplitude, a periodic variation, those variations transform to the second frequency domain and so you get a spectrum now that consists of two frequency domains. It is of course plotted two dimensionally but it is really just as this is actually a 2D graph, this is a 3D graph if you will and typically these days the way we express it is that it's a topological map so you'll typically see a series of contours that's just like if you've ever seen a topographical map of the mountains, each contour represents a certain height. So a very tall peak has many contours and a short peak has fewer contours. So it's three dimensions being represented being projected in two but again the reason we call this 2D NMR is not because there are two dimensions in the graph but rather because there are two time dimensions. All right that's what I want to say about sort of the basic mechanics of the experiment. There are two general types of 2D NMR experiments. One of these experiments is one of these families, the one that we'll be talking mostly about is correlation experiments. Correlation means connectivity. It means literally what's connected to what. Another way of thinking of this is coupling. It can be proton-proton coupling. It can be proton-carbon coupling. That's what correlation experiments give you information on. You've already been using this type of information from coupling patterns and coupling constants. When you see a triplet here you say oh that's a methyl group and it integrates the three hydrogens. You say oh that's a methyl group that's next to a CH2 group. When you see a quartet here and it integrates to two hydrogens you say oh that's a methylene group that's next to three hydrogens maybe it's next to a methyl group and correlations give that same type of information. When you see a 17 hertz coupling in a transalkene you say oh that's 17 hertz coupling must have a partner somewhere. Ah here is its partner that also has a 17 hertz coupling. So you're already using connectivity information in helping to deduce your structures. 2D experiments provide that information in a more general term. The other type of 2D experiment that we'll be talking about are overhouser effect experiments. We'll be talking more about the nuclear overhouser effect in a couple of lectures. Those give rise to information on spatial proximity. These can be very useful for information about stereochemistry and conformation. All right my philosophy on teaching 2D NMR spectroscopy as I said before there's a whole alphabet soup of techniques out there. My philosophy is not to bombard us but to give us a small box a small toolbox of what I'll call core techniques. In other words techniques that if we are good at we can use to solve a variety of problems and then if you're good with those techniques you'll be able to say oh here's a hole in my tools where I have a very specialized problem that isn't being solved by these tools and you can go and go to Phil or go to the NMR manual and say oh I'm encountering this particular problem with a cozy and a toxin isn't helping me out but I remember him saying something that there was some type of technique called a relay cozy and saying I can add that to my toolbox. So okay the first two tools that we'll be talking about are cozy which was really the first main 2D technique. It stands for correlation spectroscopy. And so this is typically proton proton or let's just say homonuclear coupling. And then the second technique that we're going to add to the toolbox is HMQC. And this is heteronuclear correlation. Well I should say something. So we are learning about the modern versions of the experiments. HMQC uses something that's called inverse detection. That means on the F2 dimension you're detecting proton and on the F1 dimension you're detecting carbon. The older less sophisticated version of this experiment was called HETCORE. I'm going to put it in parenthesis but that's not really, it's not the same thing. HETCORE was heteronuclear correlation spectroscopy and now that's what you'd call, that's what you would call HMQC. HETCORE was an experiment where you would collect carbon data on the F2 dimension and proton data on the F1 dimension. And it was a slower, less efficient experiment. So we're going to start with these two techniques as our initial starting point for building our toolbox. And we'll see that they're extremely powerful. We're then going to add in TOXI. TOXI is what stands for total correlation. And I'll put that in quotes. It's like a super cozy that gives cross peaks with all other nuclei in the spin system. I'll show it to you today but you won't have the, you won't yet have the experience to see where it's useful. We'll bring in some problems later on but I don't want to bombard you with too much. And HMBC is sort of a long range HETCORE. In fact, that's the version of the experiment that it used to be. And it is basically, these two experiments are a little conceptually more complicated because initially you're going to say what do I need them for and it gives you a ton of data. But when you start to encounter specific problems of overlap in the case of the former and in the case of the latter fragments that you can't put together, they'll be very helpful. So all of these are correlation techniques. And then we will also throw into the mix of core techniques. Nosey and rosey, these are both overhouser effect experiments. They both give rise to information on proximity. Nosey is good for molecules that are small and molecules that are very large but there's a hole right in the middle of medium sized molecules that don't work well in it. And rosey ends up working well with medium sized molecules. Let's start with cozy and HMQC and let me just show you the general gist of the two experiments. So let's start with cozy. And imagine for a moment that you have propanol. And so if you think of your H1NMR spectrum of propanol, you'll probably think of something that looks like this. You'll see a triplet with a 1 to 2 to 1 triplet for the CH2 that's next to the oxygen. You'll see a singlet for the OH typically unless you're very free of acid or very free of water. And the singlet is going to correspond to the OH that's going to be exchanging rapidly and not coupling unless you, as I said, are very acid free. You'll see something that looks kind of sort of like a sextet in a 1 to 5 to 10 to 10 to 1 ratio. I guess that's not the prettiest of sextets. Let me make my outer peaks a little smaller. And then you'll see something that looks like a triplet in a 1 to 2 to 1 ratio. And as I said, you already know correlation. You know that when I see this triplet here downfield, it's telling us that I have a, and two hydrogens, it's telling us that I have a CH2 next to a CH2. And when I see this triplet upfield, I see, I know that I'm having a methyl group with an integral of 3 hydrogens. I'm having a methyl group and it's next to a CH2. And when I have this sextet here, you know that I'm having one methylene group if it's two hydrogens and by being a sextet, I know it's coupling with equal coupling constants to 5 different hydrogens. So for this simple problem, you're very good at reading this. And COSY is providing exactly this type of information but in a more systematic fashion. Now similarly, if I have a carbon NMR spectrum, let's say for the same molecule, I may have something that looks kind of sort of like this with let's say three lines in it and what HMQC is going to do is it's going to correlate the proton signals with the carbon signals. In other words, it's going to say, ah, this proton signal is connected, is coupled with that carbon signal, this proton signal is coupled with this carbon signal, this proton signal isn't coupled with any carbon signals and this proton signal is coupled with that carbon signal. All right, let me give you a handout that sort of starts us on all of the core correlation techniques, both these two and the COSY and the toxin head core. And let me show you schematically what I'm talking about. Oh, it helps to plug in the machine, doesn't it? That's better. All right. All right, so this is not a real spectrum. This is a sketch of the COSY spectrum of propanol. And so it's my little pigeon sketch of it. And so a COSY is going to give us all of our couplings. It's going to give us our J33, in other words, our visceral couplings. And our J3s and our J2s, in other words, our geminal coupling, any case you have coupling, you'll get long range coupling as well, like a lilac coupling. In general, if your coupling constants are small, the signals are going to be weaker. So if you have a very small coupling, like an lilac coupling, it may not show up as strongly. Or if you don't go down in that topographical map enough, you may not see it. Later on, we'll talk about some tricks to help bring up those signals. But right now, basically, anything that's coupling is going to give you a peak. Now, remember I talked about our axes. So this is our F2 axis. This is our F1 axis. And these, technically, are not part of the spectrum. These are actually one-dimensional spectra added for reference. So you typically, and you'll be doing this, we'll take a 1D spectrum and you will use it as a projection on the axis so that you see how things line up. Now, in terms of the anatomy of a cozy spectrum, this is what we call the diagonal. And the diagonal, basically, is just the spectrum. In other words, it's the methyl peak here, the methylene here, the OH here, and the methylene next to the oxygen. These are the peaks that are interesting. These are called the cross peaks. There are four of them here. The cross peaks, if you'll notice, are symmetrical about the axis. And what I always like to do in naming my spectra, and we'll be doing this as a convention in class, is we'll identify all of the peaks in the 1D spectra and we'll letter them starting at the left of the spectrum. So I will call this peak A, this peak B, this peak C, and this peak D. And we'll do the same over here, A, B, C, D. And what the cozy is telling us is that A, you notice it lines up with A, is crossing with C. And so you see this peak and so we have this cross peak for A cross C and you get the same thing over here. And then you have another cross peak here and that's C crossing with D. And I like to go ahead and basically keep the idea of my peaks and my cross peaks before we assign where those peaks are in the molecule. So of course now we know that in this molecule, this is HB, this is H A, this is H C, and this is H D. And I'll show you as we progress, we'll learn more and more how to systematically extract this from unknown structures. But you can see, for example, that A crosses C and so that's corresponding to this coupling, this correlation. And we can see that C crosses with D, that's corresponding to this coupling, this correlation. And we can see in this particular simulated spectrum, this particular, I should say sketch of a spectrum, B, because it's not J coupled, isn't coupling to anything. If B were a triplet, if it were J coupling, then we would expect it to give a cross peak with A. And so we'd see a separate peak over here associated with that coupling. All right, so that's our cozy spectrum. So now let me show you our HMQC coupled spectrum. All right, so this is your HMQC spectrum. Your HMQC spectrum picks up one bond CH coupling. And in picking up one bond CH coupling, of course, now we have no diagonal because we've got on our F1 domain, we've got C13, and on our F2 domain, we've got our proton spectrum. And so there's no diagonal. And what instead we have is a series of cross peaks. And again, if I transcribe the structure of the molecule, and I call this HBOCH2ACH2CCH3D for the molecule, now what we're going to do is to correlate these carbon peaks with the proton peaks. And again, I like to very, very, very slavishly label my peaks. So I'm going to go through every time I encounter a spectrum. I'm going to go through start at the left, go A, B, C, D for each of my peaks, and if I start at the carbon, I'll do one, two, three, and so forth. And one of the reasons I'm so dogmatic about this is because when you get to larger molecules, it's very easy to start to get confused. You'll have one expansion here and one expansion there. If you take the time to do this, it'll always help you keep track of what's going on, particularly when you have many spectra. So okay, so now we have these cross peaks here, 1A. So in other words, I look across 1A, I look across 2C here, and I look across 3D and nothing's crossed with B. And so I can say okay, this is C1, this is C2, this is C3. Thoughts or questions at this point? You mean reverse it and have upfield? Oh, yeah, it is possible. And in fact, well let's see which way is it typically plotted? I think it's typically plotted this way because you could envision picking this up and putting it here. So I think you will always see downfield down here, but I could be wrong. It's of no consequence. Let me put it this way. It's of no consequence whether we go from zero PPM to high PPM or we go from zero PPM to high PPM. You will also see maybe in the textbook, you may see a few het core spectra given for some of the compounds in a het core spectrum, the C13 is going to be up here and the proton will be down here. Other thoughts or questions? All right, I want to throw into the mix. I don't yet expect you to assimilate it because we're throwing out a lot of information. I want to throw yet into the mix the toxy and HMQC. So the big difference in toxy and I'm sorry HMBC, let me again make our little schematic molecule here. Okay, in our little schematic molecule, in a toxy spectrum, you still get all the cross peaks of the COSY, but now you get new cross peaks. Within, so we get this cross peak here and we get the cross peak corresponding to this coupling here. But in the toxy spectrum, what you also get is a cross peak between these two protons. You don't get a cross peak with this OH if it's exchanging because if it's exchanging, it's not part of the spin system. But what you get is cross peaks with all other protons in the spin system. And at this point, it's hard for you to see why in heck you'd want that, the COSY already seems very information rich. But it's very good for dealing with overlap where your COSY can't walk you through and you can break through overlap with the toxy where you have peaks on top of each other. And the other thing it's extremely good for is biopolymers, oligosaccharides, nucleic acids and proteins and peptides because each residue in a biopolymer typically is one spin system. So I'll give you a quick schematic of the toxy. We'll have a separate lecture on this later on, but I want to just introduce you to the basic anatomy here. All right, so this is again our sketch of a spectrum and it looks just like a COSY. In other words, you have your diagonal. Everything is the same as the COSY. You have, if I again go and slavishly label our peaks, A, B, C, D, A, B, C, D. You have all the peaks that you would have seen in the COSY. You have your A, C, peak. You have your A, D, peak. Your C, D, peak rather. But now you get this one additional cross peak. So you get A to D. That's unique to the toxy. And that's that cross peak between these two here. You can do that and you'll find if I do the same thing here, I could call this either C to A or A to C. And I could call this D to A and I could call this D to C. It's providing no additional information. The only thing that I use this, and it doesn't matter whether you use this half or that half, the thing that I use it for is basically to check if I'm confused, if something's a real peak, if there's a lot of noise or some artifacts, I'll check if it's there in both. Sometimes things will be clearer in one or clearer in the other. That's for a homonuclear curl. Heteronuclear, right. You don't have a diagonal. You don't have this element of symmetry. All right, the last one in our schematic, now we come to our HMBC and let me again sort of show you in my simple minded view on the blackboard here. So again, we'll come back to our molecule. HMBC can be like drinking from a fire hose. There's a ton of information there. And what you end up needing to do is use it in a very focused fashion because you'll just drown in peaks. So remember, HMQC was our one bond CH couplings. In HMBC, we get two and three bond CH couplings. Not always in a predictable or guaranteed fashion. So in other words, this hydrogen will be coupling with this carbon. This hydrogen will be coupling with this carbon. This hydrogen will also be coupling with this carbon. This hydrogen will be coupling with this carbon. This hydrogen will be coupling with this carbon. This hydrogen will also be coupling with that carbon. So you're getting this tremendous amount and if the OH is exchanging rapidly, it won't be coupling with any of them. And again, right now, it's too overwhelming for you at this point to just throw all these spectra at you and say use them. So what I'm going to put it is just like I say, this is particularly, toxic is particularly good for overlap and biopolymers. What I'm going to do is say that HMBC is particularly useful for what I'll call putting the pieces together. And you know how on the homework, I'm telling you to write down fragments, things that you know. I know this molecule has an ethyl group. I know this molecule has an isolated methyl group. When you're getting to that point and you have these fragments and you're saying now how in heck do I systematically put them together, this is where HMBC shines. Where you say oh, now I can see that this fragment is somehow connected to that fragment where you have these isolated spin systems and you're trying to put them together. So I'll give you the schematic of an HMBC right now. There's no single bond coupling? Ah, great question James. Yes. You will sometimes see single bond coupling. And your textbook actually removed it from a few of their problems and I put it back in. I basically took out. Well, the reason is what good is it to have spectra in a textbook that are doctored when you then encounter real spectra, to put it another way, you encounter them in your research or the exam which may be on people's mind more. And it looks different and you're like what the hell is going on. So you can see those and we will get used to that. We will see that. They are, yeah, rare and usually in the case of strong peaks. And you will know because I will refer to them as, you will see them as these, hey it's Halloween, vampire bites around the peak. They are, you will see the J1CH splitting them. All right, so if we again go back to our system here. So you notice now we're getting this very rich piece of information here. So for example, if this is our molecule OHBCH2ACH2CCH3D, and we already know these are carbons 1, 2, and 3. So let's just, we'll just look at two of these. So this cross peak here of 1 to D, that's telling us that we're seeing, and again this is just my sketch, that's showing us that we're seeing this long range heteronuclear correlation. This cross peak here of 2, that's my scroll of a 2, this cross peak here of 2 to D is telling us that now we are seeing this correlation over here. And you will see how to use this very, very information rich system in the future. Yeah, it's not so much how far. Remember how I said that J2CH and J3CH are typically 0 to 20 and they're going to depend on higher 0 to 10, they're going to depend on hybridization. They will have different intensities based on the J value. If your J value is very, very small, you won't pick it out up no matter what. If you've got a J of like 1 hertz, good luck finding that coupling. So it's, and this is the killer on HMBC is that you can't tell your J2CHs from your J3CHs. So you get this information but there are always these question marks. Are they direct, you know, are they neighbors or are they nearest neighbors or are they neighbors one down the road? But don't worry about this right now. We're going to spend a week or two not using HMBC. What I do want to start us out now is on an example with HMQC and COSY and show you how beautifully they work together and show you how I solve a simple problem. And this is a problem from not this week's homework but next week's homework. So it'll be sort of a demo problem for you. And if anyone didn't get one, there's enough to go around. Now the other thing I would like to give you is a tool that's useful particularly when you get more crowded spectra and that's these grids. They're very useful in helping you line things up. They're yours to keep. And you can print more on transparency film or if your lab mates are envious of you and steal them, you can go ahead and go ahead and get them. All right, now, all right, what the heck? Ah, okay, so I want to whip through this kind of sort of quickly, so okay. This is a spectrum and we have a mass spectrum, we have an IR spectrum. Now the reason I've been pushing on you right fragments, right pieces of information is it helps you organize your thoughts. And it helps me if I go ahead and you get an answer wrong, it helps me figure out what you're thinking was because often there's good thinking and a wrong answer. All right, so I look at the spectrum, I see a carbonyl, I see something at 1743, I work out the formula from the mass, it's C7H14O2 works out for the mass, there's one degree of unsaturation and it sure looks like it's an ester. 1743 is about the right position for an ester, here, there happens, it's a small molecule, a very small molecule, I happen to see the CO single bond stretch. If I look in the proton NMR spectrum, I see some downfield peaks that look like it's consistent with an ester. So take it as a given right now that it's an ester. I go ahead and I look at my peaks and again, I really, really, really like to get in the habit of labeling them and just walking across the spectrum, A, B, C, D, E, F, G, it's a little confusing here. If I look closely, it looks like I see a doublet, can you see the pattern of the doublet on top of a triplet? You see the 1 to 2 to 1 triplet. So it looks like I have G is probably a doublet and H, so that's probably G and that's probably H right over here. Now, you really, really, really want to be diligent about putting a ruler, measuring the height of your integrals, I like to be good, I like to take this height, this height, this height, this height, this height, this height, everything I'm sure of, divide by the number of protons and get the most accurate height per proton possible. This one is pretty obvious to follow by inspection. If I'm really feeling lazy, I could always just even use my grid as some sort of Uber ruler and I say 1.7, 1.7, 5., looks like about 5.3, 5.4, yeah, 5.4, 1.7 or 1.8, I guess if I want to be good about it, I will even try to line up my grid a little bit better, yeah, about 1.7, 1.7, about 2., about, let's see, about 10.6 and if I work this out, I'm getting about 1.7 per hydrogen, say about 1.7 per hydrogen, this ruler by the way is graduated in tenths of an inch is the small tech marks on there in case you're wondering. All right, so I can very quickly go through and say 1 hydrogen, 1 hydrogen, 3 hydrogens, 1 hydrogen, 1 hydrogen, 1 hydrogen and this is looks like 3 and 3, it looks like it's 6 hydrogens. Similarly, I like to look at the carbon NMR spectrum and if I have a depth spectrum, I'm very happy and again, I'll go and number my peaks 1, 2, 3, 4, 5, 6, 7 and I look at my peaks and I say it looks like 1 is a quat, carbon, 2 looks like a methylene, I may have to make judgment calls if my depth isn't completely clean, 3 is a CH, 4 is a CH2 and 5 through 7 are CH3s. Now with these data alone, I'm going to have, this is at the harder end of a molecule to solve with just 1D data, it's not that you can't, you could easily puzzle out the structure but I want to show us how 2D data is going to help us. Usually at this point, I sort of jot some ideas down as fragments, I see I have a methyl group at 2, I don't know, maybe a methyl group at 2 might be indicative of CH3, carbonyl might be something. I think I have, it looks like I have 2 methyl groups here, one of them is a triplet, one of them is a doublet. So I probably have, if I'm just tallying up fragments, I probably have a CH3, CH2 fragment and I probably have another CH3, CH fragment. And honestly, if you puzzled around now, you could probably put the structure together but I want to show you this way of putting the structure together that we're going to do here using HMQC and COSY in a systematic fashion. All right, I actually like to start with my HMQC spectrum and the reason I do is that's going to help me, first of all, it's going to avoid having me waste a lot of time getting stuck on geminal couplings and it's going to give me a very systematic way of naming things. And again, I'm going to be very slavish. A, B, C, D, E, F, G, H, E, F, G, H. And you notice we've left out the carbonyl, we left out the carbonyl at about 100. Oh, that was another thing that clued me into an ester. The carbonyl was at what, 170 something ppm? Typical ester so it's not a methyl ketone, it's not an aldehyde, right, a methyl ketone I'd expect at like 205 to 220, an aldehyde I'd expect at like 190 or 200. So I am pretty darn sure this is an ester anyway, but we don't need an HMQC, it's not going to correlate anything because it's a quat carbon, it's not coupled. So I start my numbering 2, 3, 4, what am I doing here? Oops, I'm staring in the light, 5, 6, 7. And now I just look at my cross peaks and so 2 is crossing with A and B, 3 is crossing with D, 4 is crossing with E and F. Every time I get one of these carbons crossing with 2 methylenes, I know it's a diastereotopic methylene. Six is crossing with, now this is where it's hard to see. And if you have trouble, particularly in a crowded spectrum, just slap a grid on it. And you can see one cross peak lines up kind of centered with H, the other cross peak lines up with G. They've included an expansion here, I believe they have actually forged their data here, I think this cross peak actually should be spread out and they were trying to make it easy for students by showing it just under here. But again, what good is that going to do for you when you encounter your own real data and you say, oh, it doesn't look like it looked in the problem. So here I look and I see, oh yeah, you see how nicely you can see with the grid lines, this lines up with G, this lines up with H. So okay, so we get 6G and 7H. And now I'm going to be very, this is going to become my Rosetta stone for the problem. I'm just writing all of my numbers here right over the letters, 2A and 2B, 5C, 3D, 4E, 4F, and 6G and 7H. All right, here's where all of this work pays off. Now we go to the cozy spectrum. And what I do, again, I'm very, very, very mechanical about this. I go ahead and I transcribe from my other axis, 2A, 2B, 5C, 3D, 4E, 4F, 6G, 7H. And I do, if I had another axis up here, I would do the same. They only gave us one edge projection. That's not going to matter. All right, we're now all set to put this molecule together. All right, so I literally, I go through now, I identify my diagonal. I draw a line through my diagonal so I don't get confused. Ruler is better than the side of my grid, but if the grid is what I have on me, then I use the grid. David always comes prepared. He has his ruler. All right, now we're ready to look at our cross peaks. 2A crossing with 2B, that's just, I'm taking the 2A and the 2B diagonal, they're crossing with each other. Normally I go up and over, but here because they're all on this side, I go over and over. So, okay, that, tell us something we don't know, right? That's our C2 HA, HB. The only thing I really do know at this point, that's the carbon at 70 parts per million. So I know that that carbon probably is connected to an oxygen. I think I have an ester in here. All right, here's where we start to get some new information because 2A and 2B each cross with 3D. See, I can go up and over. So that's useful. 2A with 3D and 2B with 3D. Okay, that's useful. Because now I know I have C3 HD and it's connecting. And I'm starting to put this thing together in a systematic fashion. And I'm just going to continue to read my spectrum. So we go over here and we say, oh, here we get 3D cross 4E and 3D cross 4F. And you say, oh, okay, that's useful. I have this methylene C4 with E and F connected. It's got to connect up. C4 HE HF. And I'm building up this chain that's harder to put together than a usual coupling where we can just read off and see what's coupled with what. And you say, hey, this is useful. And I look up here and I say, okay, I've got this cross peak. Maybe I need to slap a grid on it to help see how things line up. And I look at my grid and I say, ah, it looks like that aligns with 6G. And so now I say, ah, okay, so I have 3D lining up also crossing with 6G. Ah, okay, so 3D also has to cross with C6 H3G. And now I have almost the entire chain built up. All right, I have this cross peak here. Does that tell me anything useful? What's that cross peak? So I go over, normally I'd go over and up, but it's 4E cross 4F. Well, that's fine and dandy, but it isn't telling me anything useful. 4E cross 4F, that's just the diastereotopic one. But now I come to the last ones and I get 4E with 7H. You notice this one's lining up with the full edge. So 4E to 7H and this one's 4F to 7H. And that gives me the last of my chain. C7 H3H. All I have left now is I have this isolated methyl, C5 H3C, right, he's not correlating with anything here. If I had an HMBC, I could put him in systematically. I have one carbon left, that's C1, which is part of a carbonyl. That was in my other one. And you can see how it comes together now. We had two valences on the carbonyl that needed to be filled. We had a valence on C5 H3C that needed to be filled. We had a valence on the oxygen that needed to be filled. The only way to put the molecule together was to connect that valence from C5 H3C to C1 and the other valence on C1 to the valence on oxygen and bingo, you have the whole structure systematically worked out. Obviously it's not as easy the first time around as I make it look here. But the same strategy, we'll start with a simple problem set next week, the same strategy of going ahead and working the HMQC and then working the COSY is going to take you very far.
This is a graduate course in organic spectroscopy, focusing on modern methods used in structure determination of organic molecules. Topics include mass spectrometry; ultraviolet, chiroptical, infrared, and nuclear magnetic resonance spectroscopy.
10.5446/19263 (DOI)
And get good at recognizing and identifying the multiplets and extracting the coupling constants. So the things that we were talking about and the question that was raised, is that coupling really 700 hertz? What makes it 700 hertz? So let's talk about factors that J depends upon. And I've tried to sort of group out maybe five factors and give us some points. So let's say one is the magnetogyric ratios of the nuclei involved. And so remember how when we started talking about magnetogyric ratio, I gave you two examples. We talked about the C13 satellites of chloroform and proteo chloroform, right? So when you see the H1NMR of CdCl3, of course you don't see any of the deuterium chloroform that's in there, but you see that 0.2% or 0.1% of proteo chloroform. And you see a peak that's very big at 7.26. But then symmetrically disposed about it, you see these two satellites. And so this is your CHCl3 or more specifically your C12 HCl3 peak. But then your satellites come from your 1%, 1.1% of C13 CdCl3, CHCl3. And the spacing of those two lines, the distance here between these two is 208 Hertz. And that distance happens to be 1.6 is 1.6, is 1 over 6.5, the distance that we see in the C13 NMR of CdCl3, right? In CdCl3 you do indeed see the C13, the 1% C13. And you see this 1 to 1 to 1 triplet centered at 77 ppm. And the distance between the lines here is 32 Hertz. And that ratio of 208 to 32 is equal to 1 over 6.5, which is the magnetogyrach ratio of proton over the magnetogyrach ratio of a deuteron. Meaning that when everything else is equal, if you have a magnetogyrach ratio, a nucleus with a magnetogyrach ratio that's big, you get big coupling. If you have a nucleus with a magnetogyrach ratio that's small, you get small coupling. For heteronuclei, we said that fluorine, for example, has a big magnetogyrach ratio. So fluorine's going to have big coupling. We said that carbon has a relatively small magnetogyrach ratio. So carbon, in general, is going to have small coupling. So the gamma of the nuclei is important. The number of bonds, so generally, generally, generally, we see coupling through one or two or three bonds, sometimes four or five that's called long-range coupling. So if we have some system, WXYZ, and we look at it for talking about coupling through one bond, coupling through two bonds, or coupling through three bonds, and I need to make some wildly general generalizations, I could say, our J1s are on the order. And you can just sort of look at the appendix I handed out. And if you want to keep a number in your head, I'd say let's say 30 to 300 Hertz. Kind of one bond couplings are big. They're on the order of 100 Hertz. Give or take a factor of half a log unit. We saw you can have a 700 Hertz coupling in the phosphorus. But generally, yeah, like 100 Hertz would be a good number to keep in mind. J2s are generally on the order of 0 to 20 Hertz. And again, I'll give you examples that fall out of there. But if you want to keep a number in mind, 10 Hertz, 20 Hertz, something like that. And J3s are generally on the order of 0 to 20 Hertz. So in other words, one bond coupling is huge. Two bond coupling, three bond coupling is smaller. All right, other factors involved. Geometry. Particularly in three bond couplings, where good overlap leads to big coupling. Remember, coupling is carried by electrons in bonds where a nucleus feels another nucleus through polarizing the pair of electrons making up the bonds so that the one with its spin up is nearer to the one with its nearer to the nucleus that's spin down. And so that travels along the line. And if you have good orbital overlap, for example, an anti-periplanar relationship or a sin-periplanar relationship, you'll have a big coupling constant. If you have bad overlap, for example, a 90 degree dihedral angle, you'll have essentially no coupling constant, no zero coupling constant. And if you're sort of at a low angle like a gauche angle, something close to 90 degrees, 60 or 120, you have still relatively poor overlap so your coupling constant is small. That was what we were talking about the other day with cyclohexane, where I said, yeah, for axial coupling on the order of 10 hertz, 8 to 10 hertz. For axial equatorial, that's axial axial. For axial equatorial or equatorial equatorial, where your dihedral angle is about 60 degrees, yeah, 2 or 3 hertz. All right, so geometry also matters. Hybridization. And a general rule is more S character leads to bigger J's. And other factors, electronegativity. Hybridization is like Y in transalchine. We see a J of 17 hertz, typically, versus in a diaxial interaction on a axial axial coupling on a cyclohexane, which also has 180 degree dihedral angle just like a transalchine. We only see a coupling constant on the order of 10 hertz. In other words, you have more S character in an SP2 bond, in a bond involving an SP2 carbon, then a bond involving an SP3 carbon, so you have a bigger coupling constant. So the other, another factor, let's say, I'll just say, other factors such as electronegativity. So for example, a hydrogen that's next to an oxygen that's on a carbon with an oxygen will have slightly smaller J values, particularly if there are two oxygens on there. All right, let me give you some typical J values, and then we'll look at some examples. And I don't want us to have a, I mean, these sort of generalizations that I just put up are pretty useful. But unless you're doing a project with particular nuclei, you may not end up keeping all the numbers in your head. But let's just look at sort of some typical examples, and these are actually in the appendix here. So let's take a look at a fluoroalkane. So your J2HF, and this is all in the appendix, is really, really big. It's like 44 to 81 hertz, so even bigger than a sort of generic two bond coupling that I talked about. Fluorine has a large magnetogyric ratio, so you've got very big coupling. Your three bond HF, your three bond coupling, is on the order of 3 to 25 hertz. And fluorine is so, so good at coupling, right? So this is two bond coupling. This is three bond coupling. Fluorine is so good at coupling that you can even sometimes see a little four bond coupling. J4HF is on the order of, let's say, 0 to 4 hertz. Part of it's the polarization, but part of it is the orbitals that fluorine is using in bonding. So if you have a hydrogen, we talked about two bond and three bond HH coupling. So a typical two bond HH coupling might be, I said 14 hertz in an unperturbed system, and a typical three bond HH coupling, I said let's use 7 hertz as a typical number. So that hydrogen is contributing a 1S orbital, but the fluorine is going to be contributing orbitals that are going out further because it's using the second shell in coupling. So we're in the two SP3, technically. So your coupling is going to be bigger with fluorine. So I don't think it's just, it probably involves some electron. Yeah, actually, it would involve electronegativity as well, because it is going to be pulling those electrons in really tight, and that's going to give more interaction of the nuclei with the electrons. So yeah, I guess it's both of those. Other questions or thoughts on this? When you have the control of the control and axial control, you said you're both under on 3 to 3, but it's like a product that we should get over? Of one over the other? No, I mean, think about your Newman projection of a perfect chair cyclohexane. A perfect chair cyclohexane, if I draw it as a Newman projection, I'll just draw half of the cyclohexane. So this is axial. This is axial. This is equatorial. This is equatorial. And in a perfect chair cyclohexane, this dihedral angle is 60 degrees. This dihedral angle is 60 degrees. And this dihedral is 60 degrees. So it really should be about the same unless you flatten the ring out or do something to perturb it. So since the magnetic gyroic-gyrographic ratio of 4 is so high, do you ever see intermolecular coupling between, say, the two? OK, do you ever see coupling that's essentially through space? One can, so outside of the realm of covalent chemistry that we're seeing, you can, for example, see coupling across hydrogen bonds and other situations where things are held into close proximity with each other. So for example, you can do N15 coupling across DNA, for example, from one nucleobase to another through the hydrogen bonds. But just for a normal ordinary organic molecule where it was in some conformation, not that I know of any example. Yeah, nothing without a polar functionality. Nothing where the molecules aren't locked together. I mean, I suppose you could come up with some example where you take some poor molecule and bang two methyl groups into it so hard that they're banging in at Van der Waals radius. And you might. I don't know the answer. That's the sort of thing that one would try experimentally. Other questions? Benzines are interesting with fluorobenzines. And you will have, I think it's on this coming Mondays homework set, you'll have some fluorobenzines. And it's a little bit counterintuitive. The problems are pretty easy. They're out of chapter, was it 5, 4? What's the one that I gave you to read that's the coupling involving other nuclei? 6. OK. Anyway, so keep this in mind. So your ortho coupling, your J3HF, is on the order of 6 to 10 hertz. And so that's kind of what you'd expect. And what's sort of surprising, I mean, in the case of hydrogens, you have metacoupling. But it's usually on the order of a couple of hertz, you know, 2 or 3 hertz, 1 to 3 hertz. In the case of fluorine, your metacoupling is bigger than you might otherwise expect. It's on the order of 5 to 6 hertz. And then because we know that fluorine is very good at coupling, you even see some paracoupling. And it's on the order of 2 hertz. And these are all kind of approximate. Yeah, I mean, the good news on all of this, that appendix F is just such a treasure trove. And so the good news is appendix F puts a lot of these data right at your fingertips. And the only reason I'm talking about this is because I think hearing it once is sort of helping you see where to look it up and so forth. Let me just point out also the numbers that I had given you before and just put this into some context. So when we started talking about NMR and spin active nuclei, I mentioned the magnetogyrach ratios. And just let me put those up here again. Magnetogyrach ratio for proton is big. Magnetogyrach ratio for fluorine is big. Magnetogyrach ratio for phosphorus 31, I guess I'll even put up F19 and H1 is 10,840. And the magnetogyrach ratio for C13 is 6,728. So let me tell you what I was talking about. When I was saying you can correlate things roughly with magnetogyrach ratios. So for example, JCF, J1CF is pretty darn big. It's at the high end of what you would typically expect for couplings. It's on the order of 2 to 300 hertz. J2CF is also pretty big. It's at the order of 20 to 40 hertz. And J3CF is on the order of 10 hertz. And then phosphorus, as was already pointed out, one bond phosphorus hydrogen coupling is huge. It's on the order of 700 hertz. Two bond pH coupling is on the order of 10 hertz. And three bond pH coupling is on the order of 20 hertz. Certainly these aren't numbers to keep in your head. These aren't numbers to keep in your head. These are just sort of numbers that have seen once. Why is J3 bigger than? Often J3s are bigger than J2s. In carbon hydrogen coupling, often J3 to hydrogen, often three bond coupling is a little bigger than J2. Sometimes J2 is bigger. Remember, of course, one case you can actually have an anti-periplanar relationship. So if you think about it, in J3 you can get a nice zigzag relationship. In J2 you've got different relationship. These electrons aren't as directly overlapped. And J2 often depends on hybridization and geometry. I mean, a striking example. So you look at alkenes, right? And this coupling is on the order of 0 to 2 hertz, the geminal coupling. And then you look at your visceral couplings, and it's on the order of 17 hertz. And even the cis coupling is on the order of 10 hertz. So here's another example where J2 is smaller than J3. Is the coupling carbon fluorine? These ones, yeah, carbon fluorine. So we've now just had this tremendous traipse through all of these weird and wild couplings and sort of in the abstract, in the sense I've listed some numbers. So let's now look at some real compounds. And these are just compounds I pulled out of Aldrich. And for that matter, compounds that you might well, or types of groups that you might well encounter. And the first thing I'll start with is triethylphosphite. And you would encounter this last night. We talked about Horner-Wadsworth-Emmons type reagents. So if you made a Horner-Wadsworth-Emmons reagent, you will encounter, or a Vittig reagent, or a phosphonium precursor. To a Vittig reagent, you will suddenly find yourself encountering fluorine proton and fluorine carbon coupling as you get to know your molecule. So let's take a look at an example. And I love these Aldrich spectra because you can just pull all sorts of spectra out and say, all right, what would I get? So I pulled this out at www.sial.com. And then I just blew things up. OK, so let's start with we have 300 megahertz proton spectrum. All the Aldrich spectra are 300 megahertz H1 and 75 megahertz C13 spectra. So triethylphosphite, we see something that looks like a triplet for the methyl group. And then something that looks a little more complicated over here. How do we describe this pattern? Quintet would be a good place. So we could call this a quintet, or what was that? Quintet, I like that. So quintet, I like even better apparent. Because I've taken this peak, and I picked it up and blown it up here. And what do we see? Little shoulders. So we know it's not a perfect quintet. We don't have four couplings that are exactly the same. Can we recognize a pattern hiding under here? Triplet of triplets. Now, then? Doublet of quartets. Watch this. So doublet of quartets is a pair of quartets. 1, 3, 3, 1 for this shoulder. And then here for this shoulder, 1, 3, 3, 1. You see that? 1, 3, 3, 1, 1, 3, 3, 1. So it's a doublet of quintets. Quartets, I'm sorry. So if we want, we can extract both J's. The smallest J, the small J, the J associated with the quartet, is going to be the distance from the last line to the next to the last line, or the first line to the second line. And I handily put a scale on here. And I read that distance as 7 hertz. And the big J is going to be the distance from this line to the first line, the second from the last line to the last line, or from the first line to the third line. And I can't exactly read where that line is, but it looks like it's about a hertz more than here. So let's call that 8 hertz. So we could characterize this as a DQ, use Q for quartet, quint for quintet, J equals 8 comma 7 hertz. So 7 hertz, that's just our, and a quartet, that's just our coupling to the methyl group, right? Because we have P, O, C, H, H, C, H, H, H. So 7 hertz is just our J3HH. And 8 hertz is our J3PH through 1, 2, 3 bonds. So 20 hertz is just approximations. Those are just approximations. I, yeah, trying to give you sort of general numbers to ballpark it. So 1 bond couplings on the order of 100 hertz, 2 bond, 3 bond couplings on the order of 10 hertz, you know, sometimes bigger, sometimes smaller. Depends on gamma, depends on other factors, depends on hybridization. We can do the same thing with carbon here. And even though our two peaks in the C13 NMR are really small here, they conveniently give us a peak printout up over here. So those two constitute a pair, and those two constitute a pair. Each of them is a doublet. The doublet for this carbon we can deal with as 63.64. I want to calculate the coupling constant minus 63.56. Those are just the two values on the top of the table. And PPM is 0.08 PPM. And we have 0.08 PPM times 75 hertz per PPM is equal to 6 hertz. So that's our J1 piece, that's our J2 PC. And we can figure out our J3 PC from this other one. So we have 16.19 in the upper left hand, upper right hand corner. And 16.10 has the position of the two lines. And that difference is 0.09, 0.09 times 75 is equal to 7 hertz. And so that's our J3 PC. Thoughts, questions? In the carbon NMR. So in the upper right hand corner, they list the two line positions. They're in the proton NMR. You mean how we see the doublet? So okay, I can't do this well with my hands because my hands aren't in 1 to 3 to 3 to 1 ratio. But okay, imagine my hand is a quartet. And if we have, so the distance between my hands is the big J. And if the distance was 1 fingers worth, we would see a perfect quintet. Oops, if it, this is a bad, oh, I've got a thumb there. Okay, if it were what, I've got to get rid of my thumbs, chop them off. Okay, if it were 1 fingers worth, we would have 7 hertz spacing between the fingers. And then it would be split into 5 lines all equally spaced at 7 hertz apart. But they're a little bit further apart. So we see a quartet and another quartet. And the distance between lines 1 and 2 is the J of the quartet. And the distance between lines 1 and 3, or in this case, 1 and 2 and 1 and 3 is the distance of the doublet. Why is the middle peak is very slim? The other two. Interesting question. So do you notice these little jaggies right on the edge of the peak? Do you see how the peaks aren't smooth? So remember I was talking about digital resolution. So you take a spectrum that's let's say 16,000 points wide. And you have those 16,000 points over a spectral width that's let's say 4,000 hertz here. And so your digital resolution is a quarter of a hertz. So you think of your spectrum as a smooth curve. But what it really is is a series of points that have been splined together. And because we may be missing a point right on top of the peak, you end up with something not looking completely symmetrical. And that's just an artifact. That's just an artifact of this. As a matter of fact, I would say if I went and told the spectrometer by increasing the acquisition time, told it to have more digital resolution, we would probably see something that was better resolved. You just type in, there are two ways. So you type in number of points and you make the number bigger. Or you make the acquisition time longer. And the number of points in the acquisition time and the spectral width are all intimately linked. So you can basically collect data for five seconds instead of three seconds to increase your number of points or you can tell it more points. I can't use the 3j page page. Where does that refer to? So that would be the j between the methylene and the methyl group. Oh, okay. So let's take a look at a fluorine NMR or a rather a fluorinated compound. And maybe I'll just show you some highlights. So I grabbed from Aldrich the spectrum of fluoropentane. And so let me just write out the structure here just so you can see it. All right. What do we call that? It's a doublet of triplets. And what's doing the splitting? What's giving the doublet part of the splitting? Which proton is it, first of all? Which protons are? One alpha to the fluorine. And so this is giving a two bond, JHF. And what else is giving the splitting? The methylene. So we have this methylene is coupled to the adjacent methylene. And so that's giving the triplet part of the splitting. And you can read off the two bond JHF. What value do we get here? Yeah, somewhere around 48, 47. So your two bond coupling, I think I got 47. You notice this multiplied over here? It's not so neat. Remember I talked about nonfirst order coupling when you've got things lumped on top of each other. You get virtual coupling. So the next couple of methylenes are lumped on top of each other and you've got coupling here and coupling to the fluorine. So it's not so pretty, but if you pull it out and you expand it, you can pick out your J3HF. Even if you can't quite pick out what the multiplet is, if it's just sort of a generic multiplet, you can measure that distance there. And it looks like it's about 24 hertz. Somewhere J3HF is 24 hertz. What's that? That fits into the model. And that fits into the model. You can do the same thing with the carbons. And if you look at the carbon spectrum here, you'll notice a big, big, big, least separated doublet over here. What does that correspond to? J1CF. So that's the carbon that's directly alpha to the fluorine and you've got a J1CF. And if I want to calculate the J1CF, what do I do? And what numbers do I subtract to multiply? 85 minus 83 or more specifically 85.26 minus 83.09 times 75 and that gives us 167 hertz. So that's a J1CF coupling. And I won't work through it, but you'll notice that your next peak here is split into a doublet. You can see the pair of lines over here and that corresponds to these two. That's our J2CF and then the next one is split and that corresponds to our J3CF coupling. So you can pull all of this data out of your spectra. So you just have the carbon in the NMR without the proton. Is there a way to see whether that pair of doublets if not just two single carbon peaks or whether it's a couple together? Answer on that blackboard. Take your carbon NMR and go ahead and run it at 75 or I guess for our department we have carbon at 100, carbon at 125 and carbon at 150. So you could just go ahead and run it at 2 and see if the two lines are now at the same PPM. If each line is at the same PPM, their distance and hertz has changed and they correspond to two singlets. If on the other hand their positions in PPM have changed and they've moved toward each other, but they're still centered at the same position in PPM and their distance and hertz apart is the same, then they corresponded to a doublet. All right, let's have some fun with carbon, carbon and carbon hydrogen coupling now. All right, CH coupling. So SP3, so I'm talking right now about one bond coupling. We'll start with one bond CH coupling. One bond CH coupling is important because all of your heteronuclear techniques and your depth technique rely on carbon hydrogen coupling, one bond or in some cases two bond and three bond coupling. So a typical, remember I said how hybridization matters and the more S character you have for everything else being equal, the bigger the J if everything else is equal. All right, so typical J1 CH for an SP3 carbon is about 125 hertz. So for example, if you look at ethane, your value is 124.9 hertz. If you look at cyclohexane and these are all in your appendix table as well, it's 123.0 hertz. I'm just pulling out some highlights from one of the appendices I've handed you. SP2, more S character, 25% S character and 6 in SP3, 33% in SP2 and so your J1 CH goes up proportionally. It's about 160 hertz. So you look at ethylene and it's 156 hertz, 156.2 hertz and these are all in one of the appendices that I've passed out to you. You look at benzene, it's 159.0 hertz. All right, now where does this, where else does this become interesting? Where else does it become important? Yeah? So this is where we don't use this in C13 because we take it to couple plus. Beautiful, yes. So C13 NMR, you will invariably run it proton decoupled so you won't see proton coupling. And yet, you will still see people use the term to refer to a depth spectrum where a methylene is referred to as T for a triplet and there's history there. And the history is that before they had depth and other techniques, they would run what's called off resonance decoupling, partial decoupling. And so you would get a methylene and you would see it as a triplet because it would be blowing out most of the couplings. You wouldn't see the 2 and 3 bond coupling which is really horrendous because peaks, when you talk about 2 and 3 bond coupling, you can imagine how split your carbons are. Like the methyl group in ethanol is split into a triplet of, into a quartet of triplets. And the methylene group in ethanol is split into a triplet of quartets. So these are, you know, you have huge, huge splitting in fully proton coupled carbon. But you will still see a methylene referred to as parenthesis T from that old, old thing. So yeah, all the carbon NMR we're going to run is proton decoupled. You do see, remember I said in your C13 satellites, of course you see the reverse because you're not carbon decoupling when you're running a proton NMR. And for the most part it doesn't matter because 99% of your carbon is carbon 12. But if you look closely on your methyl groups, you can see little satellites and on other sharp singlets. Yeah, could you have all sequences that actually decouple CF bonds as well? You could indeed. One of the problem with X nucleus, so the question was could you decouple fluorine? So you didn't get fluorine coupling. And the short answer is yes. One of the problems is the amount of power you put in has to, depends on your spectral width. And so if you have the width of fluorine, which is very wide, it's 200 or 300 ppm, you've got to put in a huge amount of power to irradiate all of the fluorines. And basically that turns your NMR into a giant microwave. And so you'll cook your samples. So it actually isn't so simple. It's easy. Protons have a narrow spectral range. It's only 12 ppm. Carbons, on the other hand, have about 200, 240 ppm. So you would have to put in a lot of power to carbon decouple. You could do specific decoupling experiments where you irradiate at one specific frequency. And that's another way you could do it. But it's hard to blast an entire wide spectral width. And that's how they get decoupled experiment. Yeah, but normally it's proton decoupling. Proton's the easy one. I have another question. There's a negative J value here? Negative, okay. Negative and positive for the most part don't mean anything in terms of what you will observe except in a phase sensitive spectrum. But a positive J value means that if one nucleus is spin up, the other feels a stronger magnetic field. The other, but because you're going through electrons and you're polarizing the electrons in the first bond which are polarizing the electrons in the second bond, you may end up with polarization so that if one proton is, one nucleus is spin up, you end up with the other feeling a weaker magnetic field. So that's what a negative J value means. But in terms of the doublet, you'll see the same doublet. All right, let's try a little bit more and then I want to show you one really, really, really cool example. All right, it kind of makes sense that if you start to change the amount of S character in the CH bonds, you're going to end up changing the coupling constant. So for example, if you go to cyclobutane, you use more P orbitals in making the carbon-carbon bond framework, you use more P characters so you have more S character for the CH bonds. So your J1CH is bigger. So your J1CH for cyclobutane is 134 hertz instead of 125 hertz. For cyclopropane, your J1CH is 161 hertz. All right, so this is SP3 and SP2. Now you come to SP though and things end up really, really tricky. So SP, your J1CH, now you have twice as much S character, your J1CH is twice as big as an SP3. It's 250 hertz. Now that's tricky because a lot of the experiments you do depend upon using an average value. So when you do a depth experiment, there's a delay in there. That corresponds to one over the J1CH coupling. That's how it ends up working and picking out whether something's a methylene or a methine. We'll talk more about it when we talk about complex pulse sequences. But if the J value is twice as big, everything can get mixed up. The practical implications are that acetylenes in depth. So for example, anything where you have a methine on the acetylene may be completely messed up. Opposite I'll say of what is expected. So I'll say depth and later on we're going to talk about HMQC and so because your Js are opposite, you may see things that you do not expect there. All right, the last example I want to give is incredibly wild and I pulled this out because I thought this is fun and I thought this is fun and this is cool. Because it gives us every sort of heteronuclear coupling you could imagine and all sorts of bond coupling and I found this in that Aldrich collection of spectra and I thought hey, we got to take a look at this because it's fun and it's cool. All right, so this is an isotopically labeled Horner-Wadsworth-Emmons reagent. It would be something that if you wanted to do an isotopic labeling experiment and put C13 into your molecule in specific places, you could put it in but it's got an absolutely funky proton and carbon spectrum. So just to orient ourselves, remember the Horner-Wadsworth Emmons reagent is a phosphonate ester and you have a regular ester and the typical Horner-Wadsworth-Emmons ester. Both of them have ethos and we won't worry about the ethogrups other than to say this is OCH2, CH3 from both parts of the molecules and this is the OCH2, CH3. But what I would like to worry about is what we see here in the middle. Now what we see here in the middle is that CH2. Let's think about what's going on here. So that CH2 is being split. It's being split by the carbons to which the hydrogens are attached, which are C13s. It's being split by the phosphorus through a two bond pH coupling and it's being split by the C13 of the carbonyl by a two bond CH coupling. So what pattern do you observe with three distinct coupling constants? Doublet of doublet of doublets and that's exactly what you see over here. It's a DDD. You can pick out your smallest coupling is this distance. Your next coupling is this distance and your biggest coupling is this distance over here. So I get that this distance is 7 hertz. This distance is 22 hertz and this distance, which corresponds to the biggest J, it's either the distance between 1 and 4 or 1 and 5 but here it's clearly the distance between 1 and 5. I get that it's 130 hertz. So it's a DDD, J equals 130, 22 and 7 hertz and that corresponds to a J1 pH equals 130 hertz. J2 pH equals 22 hertz and J2 CH is equal to 7 hertz and that's pretty cool. Now there's even more cool stuff embedded in this if you look at the C13 NMR. Remember this thing is isotopically labeled. So most of the carbons are present only at 1% abundance but then that central methylene and the carbonyl are present at 100% or 99% isotopic abundance. So you get to see something that you never, never see in regular carbon NMR except in what's called an inadequate experiment, which we'll talk about at the very end of this, the quarter, which is carbon, carbon coupling. And if you look at the spectrum, now we see some neat stuff. So this is the proton decouple. Wrap your head around this. This is the proton decoupled carbon NMR but of course you still see carbon, carbon coupling and carbon phosphorus coupling. So you look at this peak over here and you look at the lines over here and that peak is ADD. That's your carbonyl. So that's your carbonyl. It's a doublet of doublets. And doing the same thing we did before of taking 1 minus 2 and 1 minus 3, we can extract our J values. So our DD here for the carbonyl ends up being J is equal to, let's see, I get 59 hertz and I get 6 hertz for analyzing that DD. And if I do the same thing for this carbon here and I look at this carbon and we can see it over here as this very, very, very, very nice, very pretty doublet of doublets for the CH2. And I do the same thing here and I get 134 hertz and I get 59 hertz. All right, so let's figure this out because now we have a puzzle problem. We have three different J's and we have three different relationships here. What does the 59 hertz have to, have to, have to correspond to? Has to correspond to the carbon-carbon coupling because carbon, because coupling is mutual. So your J1CC is equal to 59 hertz. Now, this guy is a doublet of doublets with 59 hertz and 6 hertz, so what is the 6 hertz correspond? Two bond phosphorous. Two bond phosphorous carbon coupling, so your J2PC is equal to 6 hertz. And the last coupling we observe is 134 hertz. What's the 100 for the methylene here? What's that coupling? The 130 hertz. 130, what is it, 134, yeah. That's carbon phosphorous. That's your one bond carbon phosphorous coupling. That's your, right, one bond. J1, whoops, did, yeah, right, that's your J1PC is equal to 134 hertz. All right, last thing, stretch your imagination. I don't have a phosphorous NMR, but imagine I had a proton decoupled P31 NMR spectrum. What would the peak for phosphorous look like? One peak, everyone agree? A one peak, but what, it's splitting pattern. Splitting pattern, what would it splitting pattern be? A doublet of doublets, and what would the Js be? JPC, 6 and 134. So if we took a proton decoupled phosphorous NMR, you'd expect to see a pattern that looks, what is this, Richard Nixon here? A pattern that looks like this, a doublet of doublets with a really big J for the one bond coupling, and a much smaller cut pattern for the two bond CPC coupling. All right, well, I think I've taken enough of your time today, so that sort of wraps up, and that'll set you in good stead to attack this next homework set that has all sorts of cool coupling stuff. You had a question? Please input right below our 42-bit multiple dataات side. If you ask me about our twookus on DEMO system, I think we might have picked up some sort of three set up set up that looked like removed clear pattern before right near this. Ah, could be really useful. The dip will draw in all these two real concepts with build simply for building our own
This is a graduate course in organic spectroscopy, focusing on modern methods used in structure determination of organic molecules. Topics include mass spectrometry; ultraviolet, chiroptical, infrared, and nuclear magnetic resonance spectroscopy.
10.5446/19261 (DOI)
Yeah, so as you may have noticed, this is from your homework. And I want to do this as a demonstration regardless of whether you've already solved this problem. In fact, I hope that you've solved this problem because what I'd like you to do is to be able to think really deeply about it and show you my perspective on structure solving and in particular we're going to be talking about using HMBC as a very focused tool to help solve structures and specifically for the problem of putting the pieces together. You've seen on the templates that I've given you, I've had this tremendous emphasis or at least I've tried to have this tremendous emphasis on thinking your way through the problem, reading the spectrum, getting the formula, writing out fragments, jotting down what you know, jotting down what you don't know if possible, and then being able to ask focused questions. HMBC is an incredibly data-rich technique. It also has ambiguities to it because we get two bond and three bond couplings. So you've got a huge amount of information, a huge amount of data. And what I'd like us to do today is to learn how to use it as a focused tool. So I want to zip through the problem from Silverstein at the beginning and then focus on the HMBC angle. So this is problem 8.43 from Silverstein. And I want to jot down my, you know, I've worked this problem just like you folks and I want to jot down my impressions on working the problem. So I look at this problem and I generally start with if I have, I mean, what's the most useful thing you can get, molecular formula and functional groups. That's sort of the most general stuff. And we'll be able to get molecular formula in just a moment because we'll actually see all the hydrogens and all the carbons. So we basically will get them, get the oxygens by difference. So before we start with the NMR spectra though, looking at the IR spectrum, I see what looks like an OH group. I see what looks like a carbonyl. At 1728, it's a little high for a typical ketone, right? A typical ketone's a little bit lower. It might be an ester. I've been emphasizing it's very hard in any sort of level of complexity to get CO single bond stretches associated with esters. It's probably hiding right here at 1188. So you sort of get a hint at it. But we'll see in a moment there's some other hints that are pointing toward ester. We probably have an alkene. That's probably an alkene CH. It could be an aromatic. We'll see in a moment it's not. That's probably an alkene CC bond. All right, mass spec, it's 200 molecular weight in the EIMAS spectrum. What I'm going to do before we actually get the formula, so maybe at this point I'll just jot down sort of a question mark on the IR spectrum, ester, sort of my thinking on this. All right, at this point I want to go and look at the proton NMR, look at the carbon NMR. And I've really, really, really been emphasizing this notion of keeping the resonances separate from the atoms. In other words, we know resonances. It's something you can see. We're going to be assigning those resonances to the structure as we build the structure. And so we have a common language. I go ahead and I simply letter the peaks A, B, C. It's hard staring into the light D, E, F, G, H, I, J. And we number the carbon resonances and I'll go 1, 2, 3. That's our chloroform. 4, 5, 6, 7, 8, 9, 10, 11. I like to do a good job of working the integrals. My philosophy, every particular integral has experimental error associated with it. The best way that you can do it, if you know the number of hydrogens in the molecule or you know multiple hydrogens, is add up a bunch and divide by the number of hydrogens. If you don't or you're in a hurry, often you can get it by inspection with a ruler. These integrals are a little hard to read. They're starting them right in the baseline. They're not offset. You can use a ruler and draw straight lines. You can slap a grid on it. I'm just using my ever, ever useful grid. And if I'm looking, I start to see a ratio that's just a hair under 6, a hair under 6, a hair under 3, hair under 3, this one's just a little bit, actually this is just a hair under 6, hair under 9. So basically, we're talking about like 2.8 units. These happen to be 10 to 7 inch per hydrogen. This guy is interesting. He's coming up a little bit. This one right at 1.6 ppm. So he's coming up over 0.6. And I'll tell you about that in a second. And then we see one that's just a hair under 0.9. And another that's just a hair under 0.9. So you pretty much by inspection can go ahead and get, and again, it's really hard staring in here, 2H for A, 2H for B, 1H for C, 1H for D, 1H for E, 1H for F. Did I? 2H for F, thank you. 3H for G. Now, H is interesting. 1.6, this is in chloroform solution. And chloroform water typically shows up at about 1.6 parts per million. And so you can kind of see the water peak right over here. So you have this multiplet that's reasonably symmetrical. And then you have a little bit of water off on the side here. I would go in if I were at my own spectrometer, I'd go in and zoom in and get a better look and see. But I think you can see the integral just gives a little extra kick up for the water. So H is 2H, I is 3H, J is 3H. So in other words, our molecular formula has a total of H20 in it. Now it's certainly possible if I had an amine or something that the amine NH might not show up or an alcohol NH. So I'm not immediately locking in. And this is really important. You have to be keeping your wits about you. Secondary amine NHs, aliphatic secondary amine NHs are terribly hard to see. Alcohols can be broad. Alcohols can be with the water peak. Carboxylic acids can be broad as well and can be disappeared, particularly if you're in chloroform versus DMSL due to exchange. If we look at the carbon NMR here, peak number one is at about 170, just a hair down of 170, about 173 ppm. Where you would expect for an ester, not where you'd expect for a ketone. We've got a couple of peaks over here. If I want to go ahead at this point, I'll say one is a quad, two is a quad looking at the depth. Three is a CH2, four is a quad, five is a CH2, six is a CH2, seven and eight are all CH2s. And then nine, 10 and 11 are all CH3s. So basically if we do this, we see we have C11, H20. If we have symmetry in the molecule, which you've gotten in a couple of homework problems this week, of course you might end up with a count that's lower if your carbons aren't all different. Or you could have overlapping peaks. But symmetry is a typical reason. If you have a plain phenyl group, you're going to see four carbon peaks, but you're going to have six carbons. If you have a ring like a cyclopropane ring and there's no stereocenter in the molecule, you may, if you have one point of attachment, have two methylenes that are the same. But if I look here, I'm suspecting an alcohol, I'm suspecting an ester, I have 200. If I take away C12, C11 and H20 from that, I get O3. So I'm reasonably happy at this point. I think I have a molecular formula. Now the next thing I do with a molecular formula is I'll start to start to, and it's nice to have a scorecard here. So I might, for example, over here jot down some thoughts, ester, alcohol, alkene as some of the groups that we're seeing in the molecule. If I want, I can calculate degrees of unsaturation, another very useful thing. Remember, I don't do it by formula, I just say C11 would be H24, I'm at H20, so we have two degrees of unsaturation. So I can help keep my wits about me. That also tells me if I have a carbonyl and I have an alkene, I know I have no rings in the molecule. All right, now the next place, any questions or thoughts at this point? Does it, let's see. And this is actually a good point in checking yourself. I have an incredible ability to screw up arithmetic on my feet, which means go ahead and double check your. I think you're actually right. I believe in this. Yeah. All right. So, C, can that be the OH? C could indeed be the OH. So we've got some interesting points here you can already see. So if you're reasonably experienced, I'm going to bet anything that we have a stereocenter in the molecule. Now, even though I haven't measured the coupling constants, I could measure the coupling constants. They very conveniently give me a scale here when you get a peak printout. But very conveniently, a typical aliphatic CH coupling constant is about 7 hertz. A methyl group next to a methylene is really very typical for this. You'll, a methyl group next to just about anything is going to give you about 7 hertz. So immediately if I'm eyeballing this, even if I don't know, I'm at 600 megahertz and I see this triplet here, that's obviously a CH3 next to a CH3 next to a CH2. In fact, I can write this as one of my fragments here because I think we're pretty obvious at that point for this and this here. But if I'm looking at that, I see, okay, these guys are leaning into each other. We have an AB pattern. It's obviously a big coupling constant. This separation is at least twice the separation in the triplet. So it's like a 14 hertz or 15 hertz coupling constant. That is very typical for a geminal coupling. So in the back of my mind, I'm thinking stereocenter, something with a methylene that's diastereotopic. If I have a stereocenter, every methylene in the molecule is going to be diastereotopic. But usually the ones that are further from the stereocenter behave as if things are coincident. So we look here, we have what looks like an ethyl group. It wouldn't have surprised me to see a more complicated coupling pattern for this ethyl group. But it doesn't necessarily surprise me to see a less coupling constant. I'm pretty less complicated coupling pattern just to see a plain old quartet. I'm pretty certain I have an ethyl ester at this point. Pretty confident I have an ethyl ester because that sure looks like an OCH2, CH3 off of an ethyl ester, but it could be something else that's shifting it downfield. All right, at this point it's time to get analytical. And where I'd like to go next is actually the HMQC rather than the COSY. As I was saying in discussion the other day, the problem is you're drowning in data in a COSY quite often. And a lot of the data isn't particularly useful. You'll have two diastereotopic protons. And they'll both couple to another two diastereotopic protons or even to one proton. And you're getting more information than you need because you'll get that the diastereotopic protons are coupling with each other. Okay, but big whoop. You'll get that each one's coupling to one of the protons. All right, that gives you some new information, but that's redundant. And if you have two diastereotopic protons coupled to two diastereotopic protons, now you've got lots and lots of data points that basically just tells you you have a CH2 next to a CH2. So in order to help make sense of the data, I go next to the HMQC. And I'm very, very rigorous about trying to transcribe stuff. And I'm not super neat, but I tend to really try to be analytical. So I'm going to copy all of my numbers here to the carbon axis. And I'll copy all of my letters to the proton axis. And at this point, again, a grid is extremely useful. If you're working on your own spectrometer, you might want to do an expansion. You might want to expand this region just so you can get a close look and see what's lining up. But if you're having trouble following with your eye and things aren't completely obvious, slapping a grid on the spectrum is a very useful way, for example, to see that this peak at 9 here is actually crossing with the singlet. So we have two methyls that are right next to each other. One of those methyls is a singlet. One of them is a triplet. And so you can very nicely see that 11 is crossing with I and 9 is crossing with J. And then we can go and 10 is crossing with H, I believe. And again, I'm going to cheat a little bit because 10 is crossing with G. I'm going to cheat a little bit because it's hard staring in here. And it looks like 7 is crossing with H. And then F, it looks like is crossing with 8. And let's see, 6 is crossing with D and D. So 6D and 6E. And it looks like 5 is crossing with B. C has no partner. And it looks like 3 is crossing with A. And this information here really becomes my Rosetta Stone. It really becomes the key piece of information that I'm going to be using now in building the structure. Because now that's going to give us all of our easy connectivity. And you need to keep your wits about you about chemical shift as well. So, you know, obviously if we're talking a carbonyl, we're probably talking 1 is a carbonyl. If we're talking about an alkene, we're probably talking about 2 and 3 being the alkene. And it looks like 3 is a quat carbon of an alkene and 2 is a CH2 of an alkene. So it looks like we have a gem dimethyl group here. 4 and 5 are interesting. Remember the region, your carbon protons track pretty well with your protons scale. And if you're next to, not so well on halogen or nitrogen, those tend to be sort of, if you're next to halogen or nitrogen, those tend to be here. But if you're next to an oxygen, you usually tend to be somewhere around here in the 50 to 90 range depending on whether it's an OCH3 at one extreme or say a carbon that's a quat with an alcohol at another extreme. If you're down further than that, it could be 2 oxygens on a carbon or it could be an alkene or it could be a nitrile. Okay, so it looks like we probably have a couple of carbons with an oxygen attached to them. Number 5 is a CH2 and number 3, as I said, was a CH2. 4 is a quat, 2 is a quat, 1 is a quat. Quats and other things that are isolated are going to be problems later on. So if you look at this spectrum, we have 7H and 9J that don't show that are close to singlets and we'll see 7H is going to come in. We have C that has nothing on it and so we're going to have to deal with him. Okay, now at this point I'm prepared to go to my cozy. This particular cozy, the way they plotted it in the book to save space or allow you to give bigger spectra, they only plotted the axis on one edge and that's okay because you can just bounce up and over and then up. Otherwise I'd just be bouncing up and up to that axis. However you want to do it is fine. Alright, so now as I said I'm ready to attack my cozy and the first thing I'm going to do is again very slavishly transcribe so I have 3A and 5B and C and you really don't want to make a mistake at this point. 6D, 6E, 8F, 10G. The other nice thing in addition to having it so that we all can discuss things together, the other very nice thing about taking this sort of meticulous systematic approach to this and 9J here, the other thing about taking this sort of meticulous systematic approach is it means that you can set down the problem, come back to it later and get your bearings a lot more quickly because it's not just oh we've got a lot of stuff, it's actually oh I've got this resonance and I still don't know where it goes. Alright, at this point we want to sort of build up our fragments and I'm going to look at the cozy. You can use a grid, you can draw straight lines on it, whatever you like. If you want a grid you can do it this way. If you're fancy and you like to work off the online problems, in Acrobat the command U, if you're using a full version, I'm not sure about the reader, command U actually just slaps a grid right on the screen which is useful and you can even, there are parameters in Acrobat to set how fine a grid. But it's helpful with, particularly with the book problems where they tend to be less generous with the expansion. So at this point I tend to go through and just list all of my cross peaks. So if I'm working up and I only need to work on one side of the diagonal, it should be pretty symmetrical but if you're uncertain whether anything is noise, check if it's on both sides of the diagonal. If you're working on the spectrometer you can go down a level or up a level with the times 2 or divided by 2 or the slider and you're going to get down to a level where you have two types of things. At the very bottom you'll just have a basement of noise, particularly in data poor experiments. But you'll also have artifact baseline role. Your phasing is very important in the 2D experiments in terms of not getting a lot of crap off the baseline. So you really want to take time when you're phasing it to do a good job. Okay, so we've got this peak 3A to 10G. And it looks like we have something of 3A and 8F here. I'll put a little question mark there. I'm not completely sure what's going on. Well, of course I'm sure what's going on but at this point in analyzing the thing I'm not sure. Okay, this is kind of nice because you look here and you say all right yeah we've got 6E, 6F but I already know they're on the same carbon. It's no big deal, they're diastereotopic protons that are coupled to each other. Okay, I don't need to stress about that. All right, 8F cross 7H and I think that about does it. So at this point I want to put together fragments and this is what I'm using that. Oh, here we go, yeah, 5B, right, 5B to 11I, absolutely, 5B to 11I. And you notice that you're using multiple sorts of tools in thinking about things because on the one hand you're recognizing when we just had the 1D data in front of us, you were recognizing the match of patterns and coupling constants. You were recognizing a 3 hydrogen triplet up field and a 2 hydrogen quartet down field, midfield, probably went together as an ethyl ester group because CH3 split into a triplet has to be next to a CH2. CH2 split into a quartet, remember it didn't have to be a quartet but CH2 split into a quartet probably is next to a CH3. It could have been next to a CH2 and a CH where it had the same J value so I don't know for sure. But now with this and everything else, I think I can be pretty sure. So let me sort of jot down what I think I have at this point for my fragments. So I think I have OC5H2B, C11H3I as one fragment and I like to use that way of doing it where I put the number on the carbon, the letter on the hydrogen. So this just means carbon 5 is part of a CH2 group with 2 protons B and C11 is part of a CH3 group with 3 protons I. All right. What else do I have in my score card here? Well, that CH2F cross peak with C7H2H gives me another fragment. The other thing that I like to do in keeping score at this point is I like to show my valences. It helps my thinking to say, okay, that means I have a valence here. This helps me think about where my unfilled valences are. All right. What else do I have in my score card? I have an alkene and it's C3HAHA. If I were thinking about it, I might say maybe these are two distinct hydrogens here. If I later went on and I said, oh wait, I thought they were one type of hydrogen but they're two and this is important to my analysis, all I'd need to do at this point is say, all right, we're going to call one of them A and one of them A prime. And the nice thing is you're not renumbering or re-lettering your whole spectrum if you suddenly say, oh wait, this resonance is really two resonances. If I decided that H was really two resonances and of course H and F really are two resonances because you have a stereocenter and they're methylenes and they're diastereotopic methylenes. It's not like the cozy we saw in discussion section the other time where I was going on where we were talking about highly differentiated, highly anisotropic CH2 groups but it's the same sort of deal. So if it were important I could say H and H prime, F and F prime if I really started to see distinct cross peaks. But honestly I don't. So this is absolutely fine for the analysis. Okay, so I have C3 and then C3 seems to be bound to C2 which is a quad and we have this interesting situation here where we see this nice cross peak off of 10G, right? 10G is a methyl group. 10G is kind of at this position of about 1.7. Now remember I said I like to keep some numbers in my head and my sort of quick and dirty is a benzylic methyl is 2, a methyl that's alpha to a carbonyl is 2 ppm and a methyl that's allylic is about 2 ppm. And then I said caveat, if you really want to keep an extra number in your head keep 1.7 for that allylic methyl. So this is very typical of an allylic methyl. It's exactly what you'd expect for its position and it's exactly the sort of thing that you would expect for allylic coupling. So C10H3G comes here and then this kind of makes sense of the cross peaks. So right we're seeing this cross peak here. We're seeing this little cross peak with 8. So if you want to we'll get it from the HMBC if you don't want to do it. But if you want to get it at this point it certainly makes a heck of a lot of sense that 3A is crossing with 8. So I can put this in. If you're uncertain about something, if you're uncertain about a connection put it in with a dashed line. It's a great tool to remind yourself on your scorecard on working out the problem if you're worried or concerned about something. So at this point we need to figure out the rest of our stuff. So let me continue with our scorecard. We have a carbonyl and that's our C1. I hope you can see this from, yeah, you're just about, just about on the edge of the screen here. All right, so we have a carbonyl. We have some other problems here. We have our C6HDHE and I'll keep filling in my valences to be good about this just to remind us that we have some issues of valences here. And then I have some carbon and there may be redundancy here. I have some carbon that's connected to C9H3J and that carbon has to be a quad. It has to be because we're isolating that methyl over here. And I have some other carbon. Remember I have this carbon 4 and that carbon 4 is pretty far downfield in the C13NMR spectrum. It's just at about 70 parts per million and that's got to be a carbon next to an oxygen. All right, so at this point that's kind of my thinking. Now certainly by brute force you could now assemble these pieces. You would basically start to try all different possibilities and eventually you'd probably come up with the right structure. I like this molecule because it's a simple enough molecule that you could but what I'd like to show you now is how HMBC really lens this, makes this into a much more systematic, let us say, process. All right, so at this point I'm going to pull up the HMBC spectrum and we get a lot of cross peaks. Your textbook as I've railed about has doctored its HMBC spectrum so I have literally undocked the HMBC spectrum. What the textbook did which I don't like is it's taken out the HMQC type of cross peaks in the spectrum. There's no reason to do that. You should be able to identify these. You're going to see them in real data. The HMBC, we've talked about this notion of delays. We've talked about the idea that you're doing what's basically a series of pulses and delays where your delays are optimized to different things like coupling constants. So when we talked about our depth spectrum last time I said the problem with a depth spectrum is you're choosing, you have to choose AJ value for the depth spectrum. You're going to choose a typical J value and that's going to give an optimum performance at that J value. And guess what? If your J's aren't 145 hertz, if they're a little off 125 hertz, 160 hertz, you'll be fine but if they're a lot different you'll start to see other things. Now HMBC is optimized to small couplings. Small couplings typically mean on the order of 0 to 20 hertz and the spectrum downstairs is sort of centered at 10 which pretty much catches it all. But that doesn't mean your one bond couplings that are 125 hertz may not sometimes come in. And so you can see your one bond couplings. The pulse sequence, remember in the depth how we turned on the proton decoupler in the final acquisition. In a typical HMBC you're not turning on the proton decoupler in the final part of the acquisition which means you're seeing your CH couplings. Now most of those are two bond couplings. So most of those are on the order of 2 and 3 bond. So most of them are on the order of 10 hertz. Which means okay when you're seeing something where your peak's a little bit wide, the peak's a little bit wide because you're seeing that coupling. But when you're picking up the one bond coupling which is not what the experiment's supposed to pick up, it is extremely obvious. You get these sort of vampire bites around the peak. And so I just put across through each of them to help remind me of what's going on, right? So this is peak number 11 and this is 11 over here is 11i. So those two vampire bites there are the one bond coupling. It's trivial. That's the information that's already in your HMBC spectrum but it's confusing in this data-rich experiment. So let me go through and now systematically number 10, 9, 8, 7, 6, 5, 4, 3, 2, 1. I'll systematically number my carbon axis. I'll once again slavishly write my labels on the proton axis 3a, 5b, c, 6d, 6e, 8f, 10g, 7h. I already did 11i and 9j. And you can pretty much see all of your sort of vampire bites here. There happen to be six pairs of them here. So we're getting one around 5. That's your HMQC pattern. We're getting one around 7. That's your HMQC pattern. We're getting one around 6. And we're getting let's see one around 10 and one around 9. All right. Even without these types of information, you are still extremely data-rich. And the question becomes where to begin. Now, if you're a computer, you just go ahead and suck in all the data and fit the pieces together that way. But as a person, you've got the tremendous strength that we've already seen of pattern recognition. We saw it. We could read that ethoxy group in the ester. We could read the diastereotopic methylene. And you were seeing that from this whole host of little things with the diastereotopic methylene, from the big J value, from the peaks tinting into each other. It's the same way most of you were able to tackle those coupling problems on the midterm exam and just read and say, okay, this is this nitrobenzene. This is that nitrobenzene. This is this methylperidine. Because you were starting to recognize the magnitude of the coupling, the tinting of the peaks and so forth. So you've got some tremendous advantages. And yet we've also got this ability to or this issue of how do we avoid confusion here. So usually what I like to do are to start with my problems. And in general, my problems are going to be the isolated peaks. In general, it is the peaks that are isolated that are going to be both the tough ones to put together, like 3,9, Hj, because we don't know where it fits. It's not coupling into anything. But they're also going to be the sources of tremendous strength because those isolated ones are then going to link to the other isolated parts. So let's start with the carbonyl. The carbonyl is 5B to 1 and 6D and 6E to 1. And that's very, very useful. So remember, HMBC can pick up 2 and 3 bond coupling. And the problem is you don't necessarily know which is which. That's the really tough thing with this technique. Later on we'll talk about inadequate, which is a very powerful technique. It's like a carbon-carbon cozy, but not a very useful technique because of the low natural abundance of C13. It's very atypical to have 2C13s next to each other in a molecule. But that's incredibly powerful because it means you can assemble your whole carbon skeleton like a cozy process. But the problem with HMBC is you've got both 2 and 3s. You're always second guessing yourself. So whenever you can avoid second guessing, it's a tremendous breath of fresh air. So here the 5B to carbon 1 is very nice because that provides a linkage there. We kind of sort of knew this was an ethyl ester, but this tells us because there's the 3 bond coupling is going through there so it can't go any further. There can't be an intervening atom. The 6 is less clear because it could be directly connected. But at this point I can't know. There could be an intervening atom that still, we know that the 6 is isolated. We know that D and E are isolated. They're not J coupled to anything else. But I don't know about this bond here at this point. So at this point I might write a big question mark here. All right. I'm not going to go ad nauseam through everything because a lot of the information is redundant. So for example, here we're seeing that 2 is crossing with 7. So this is 8F cross 2, 10G cross 2 and 7H to 2. And in a way you could say all of that is redundant because I've already replaced groups on here. And so you're 2, you notice, and this is a perfect example. If I weren't already sure of this or pretty sure by a little coupling, I wouldn't necessarily know since 2 is crossing with both 7H and 8F. I wouldn't necessarily know which end this is going because it's 2 and 3 bond coupling. So it could couple either way. So the only thing that's really told me this, and I think by this point I can go ahead and turn this into a solid line, the only thing that really told me that was the cozy. But fortunately we'll get enough other things because we're going to see in just a moment what attaches over here to 7. All right. So let's focus, let's continue to focus on our isolated peaks. So if we look at 4 and we go with 4, we have 9J to 4. We have 7H to 4. We have 6D and E and maybe the better way to do it is 6DE to 4. And we have C to 4. Now, all right, we have 4 and we're pretty sure at this point we're pretty sure we have this alcohol. We're pretty sure that C is the alcohol. It's isolated. I think at this point we really can say, all right, here's our 8C, we're on 4. Now 4 is going to be a very, very important lynchpin. And I guess the thing that's confounding to me at this point is the fact that we've got 9J to 4, but that's not necessarily saying that that isolated methyl is directly attached to 4. We're running out of atoms, so we're going to be good in the second. We have 7 to 4. We have 6D and E to 4. They're probably all attached, but watch what happens if I now pick up on another isolated one. So I probably can start to infer things, but let's continue with another one of our problem children, another one of our isolated ones. So let's go off of C. We wouldn't be seeing cross peaks off of C if it were exchanging rapidly. If the alcohol on C were not residing on that proton, on that oxygen for, you know, several hundredths or a tenth of a second if it were exchanging rapidly, usually the less sterically congested alcohol, the more rapidly it exchanges. So usually a primary alcohol exchanges rapidly. Usually sometimes a second is secondary as slow, sometimes it's fast. Usually a tertiary tends to be slower, just more steric congestion, harder for a molecule of water to get in and make it exchange. Deacidify your chloroform, pass it through alumina, not your sample, but just your chloroform through flame or furnace dried alumina. It's a good way to reduce exchange because you're getting rid of acid in the sample. But here we happen to see beautiful, beautiful coupling off of C. And so if you look at your cross peaks here, and again we're going to use things in this focused way, we have C9, C7, C6. And so you look at all of these cross peaks and that really is nice. Because remember you're going to be picking up your two and three bond coupling unless you have any intervening coupling through a double bond where sometimes you can pick up four bond coupling. Remember sometimes like acetylines we saw how weird the acetyline behaved. I mentioned it's a two bond, it's a 50 hertz coupling so you can get homopropargylic coupling. But here, this is pretty nice. We've already taken care of two of our bonds. So look how valuable this is as a linchpin. Every cross peak now we get is going to help give us our connectivity. So we have C4, that's going to connect over to C6 because we're getting that cross peak here. So we know that this is three bond, that's as far as we can go. We're really lucky at this point. Now we get this cross peak over to seven. And so again that's just sowing this whole molecule together. We have this cross peak to nine and we said already here, remember we had this fragment, we weren't able to place it but it could be redundant because we were running out of carbons. We have this cross peak over to nine and so there's our C9H3J and now this whole molecule is sewn up. So if you look at our structure right now, I'll just redraw this and I guess I'll draw it real small up here. So here's the whole structure of our molecule. We have our seven and eight over here or six here or ethyl group or isolated methyl or isolated hydroxy. And this set of cross peaks here has really been key. Now the good news is there are other isolated points in this molecule that can put things together. So when I try to attack a problem, I'm going to start with the isolated ones. Obviously eventually you want to go back and sort of check yourself and see that everything's consistent. But let's take another point of attack here. So let me just run down this track of 9J and see who 9J is crossing with. So 9J is crossing with seven. 9J is crossing with six and 9J is crossing with four. And so you look at that and you say, oh, okay, that's giving me the same information. See the HMBC is really screaming out at me through the isolated ones. It was a gift that we got HC. HC might not have coupled. It's an alcohol. HC might have been exchanging rapidly if there was some acid in our sample. It was a gift that we got. It just gave us the whole problem. But we get that same gift right off of carbon 9 because 9 with J is giving us seven. So we're crossing over to here. And again, remember, you're hydrogen. You have one bond from hydrogen J to carbon. One bond from carbon 9 to carbon 4. And so any other cross peak now has to be attached directly to carbon 4. So we see a cross to 7. We see a cross to 6. And we see a cross to 4. That's our two bond coupling. So that's giving us the information. I'll take one more isolated carbon just for the heck of it. It's not really completely isolated, but it's 10 G. And so if we go off of 10 G, let's see, we have here 10 G with 3 and 10 G with 8 over there. And so if you look at that, that's also giving us some information. We had the 10 G to 3 by a little coupling by the proton NMR. So that information was nothing new. But you don't get a little coupling right through here. So this information here of 10 G to 8 is actually useful. Had we not been able to place 8 directly on 2? Had we not picked up that a little coupling? Or had things been more complicated or confusing? Or had we only at that point had this HMBC cross peak between 2 and 7 and 8? Remember how I said 2 is crossing with both HF and HHH? And we couldn't be sure about that. If I wasn't certain at that point, then we could have gotten that later on from this cross peak. So there's multiple pieces of evidence all pointing in this direction. Anyway, this is how I view HMBC as being incredibly powerful for putting pieces together. I want to show you a couple of last things that are sort of common features that are kind of cool. They're also germane to some of the upcoming homework. So it's worth actually keeping in mind. One thing that's very cool is okay, if you have 2 CH3s on a methyl. So remember how I said you can get these vampire bytes, you can get your one bond couplings. But if you're going ahead and if you have no stereocenter, in other words if these methyls are either not diastereotopic or they're coincident, then your HMBC, even if you see these vampire type, byte type of cross peaks here, even if you see, so here's your methyl and here's your methyl in the C13, here's your methyl in the H1, even if you see those types of cross peaks, this is a real HMBC. Cross peak here because the 2 methyls are crossing with each other, so that's kind of cool. Well in this particular cartoon example, they're magnetically equivalent. If they were magnetically inequivalent, if they were diastereotopic, then you'd still see HMBC peaks. By the way, the tough thing about HMBC is you're not guaranteed to get a cross peak because you're particularly on 3 bond. So 2 bond is weird because your 2 bond J's end up being all over the map, they'll usually show up, but not always. 3 bond is weird in a different way. It's weird by a dihedral angle, by a carpolis relationship. So if you're hydrogen, so if you have a dihedral angle that's defined as HCCC, like so, if you have good overlap between this hydrogen and this carbon, a good geometrical overlap, meaning an antiperiplanar or a sinperiplanar relationship, you typically get a big J. It shows up in the HMBC. But if these 2 are at close to 90 degree angles, you're not going to get a cross peak typically. And so that's the third thing about HMBC that's really confusing. The beauty of methyl groups is with a methyl group, no matter what, you're always going to have, at least you're always going to have protons at a good dihedral angle. So methyl groups, isolated methyl groups in general, end up being extremely valuable for HMBC. But we also see here that the isolated methyl groups are usually the problem children because you don't know where to put them and fortunately they are talkative problem children because they will talk to you in the HMBC. So that's a very useful one. Couple of other things just to keep in mind. Carbon eels, if you've got like this, if you've got something like this, whatever, you know, the problem is you don't know if it's 2 bond coupling or 3 bond coupling, but if you can build up your pieces and say, oh well, I've got both of them, then you can figure out all right, that carbon eels attached to one and the other. Let's see, I guess, I don't know if this comes up. We already saw on Esther some people have said to me, oh I didn't know that you could get coupling through hetero atoms, but yeah, coupling occurs through carbon oxygen bonds, through carbon carbon bonds, through carbon nitrogen bonds. So for example, and in a mid here, like so, again, your carbon eel can be a real lynch pin. You can get all different protons coupling with that carbon eel, so they can end up telling you lots and lots of information for putting the pieces together. But what's nice is carbon eels often isolate one spin system from another spin system, and it's those isolated spin systems, what I'm calling fragments, that are so hard to put together, and that's why HMBC is so valuable as a focus tool. All right, this should give you the skills to attack the problems, not for this week's homework set, but for the next week's homework set, where the molecules are going to get more complicated, and where you're going to be more dependent on being able to systematically put your pieces together. Yeah? There's no way to determine steric. You couldn't tell, great question, James is asking, could we tell the stereochemistry of our center? No, the racemate would have the exact same spectra as the one enantiomer or the other enantiomer. The only way to differentiate them would be to add something chiral, to make a Mosher ester here, for example, with a chiral-derivitizing agent, or to use what's called a chiral-shiftry agent, which I haven't planned a section on for our course, but it's basically a Lewis acid that's chiral that will interact with the two enantiomers differently. So you need chirality to distinguish chirality.
This is a graduate course in organic spectroscopy, focusing on modern methods used in structure determination of organic molecules. Topics include mass spectrometry; ultraviolet, chiroptical, infrared, and nuclear magnetic resonance spectroscopy.
10.5446/19257 (DOI)
So when we were talking about coupling constants, I said sometimes there are some really big differences between coupling constants, distinct differences between coupling constants. So like in alkanes. If you have a cis coupling, your J3HH is about 10 hertz. If you have a trans coupling, your J3HH, that's your 3 bond coupling or your visceral coupling is about 17 hertz. And by the way, I will again caution you to make sure you understand the difference between coupling through a double bond versus coupling between double bonds. So a lot of people, particularly when they are starting out, confuse stereochemistry with conformation. They can rotate about single bonds. So even if you have a bond between two single bonds, that might be S cis or S trans, that's always a dynamic equilibrium. It may be heavily weighted toward one way, but that's not stereochemistry, that's conformation. And that mind you has a different carpolous curve than the carpolous curve for an sp2-sp2 carbon pair that's connecting two hydrogens. So anyway, this is specifically not on here. But let's now talk about cyclohexane, which is what I'm going to choose for today's lecture and just remind us of some of the key features I pointed out. Previously, we talked about the carpolous curve for sp3-sp3 systems, and we said that there are some very distinct relationships that are in cyclohexane. So 180 degrees gives you a big coupling constant, a 60 degree relationship gives you a small coupling constant. So our axial coupling has a 180 degree dihedral relationship. Those of you who saw the previous sophomore class that was just filing out got to see Hannah talking about Newman projections, and if you Newman project, you have 180 degree dihedral angle. And typically you have about 8 to 10 hertz for an axial-axial coupling. If you have an axial-equatorial coupling, these are of course all three bond couplings or an equatorial-equatorial coupling. You have a 60 degree dihedral angle, and you remember the carpolous curve that I drew out before. And so that's about 2 to 3 hertz for each of those. So what I'm going to do right now is pass out a or mention a very real example that just came up in my lab, and I thought it would make a cool example for spec. And it was a stereochemical problem associated with a conjugate addition to an alpha, beta, and saturated nitro compound. So we were working with nitrocyclohexane. The nitrocyclohexane is electrophilic at the beta position, and we were doing an addition of aniline, I'll write that as pH NH2, to give the addition product like so. So the issue here was whether we have the trans product or the cis product. And so of these two stereoisomers, what do we call the relationship between these stereoisomers? So of these two diastereomers, each of them of course is formed as the racemate, and that doesn't matter because you can't tell one enantiomer from another by NMR. The spectrum of a racemic mixture is identical to the spectrum of either an individual enantiomer unless you have some sort of chiral solvent or unless I prepare a chiral derivative. So the only way I could distinguish these two apart would be say to make an amide, the two enantiomers apart, would be to make an amide where I had a chiral acid brought in to make an amide or to use something like a chiral shift reagent or a chiral salvating agent. So the big question is which of these two is formed? The cis or the trans. And I want to pass out the spectrum. We'll take a look and analyze it. And I have a few extras here. Anyone else? One more back here. Great. All right. Great. So we have here the NMR spectrum in chloroform solution and what I've done here is I've blown up this region, the midfield region. So we call this region the downfield region, this real region the upfield region. And I'll call this the midfield region. So our molecule of course is, night has a phenyl group in it. And so I think it's pretty obvious that our phenyl group is over here. You might notice for example if you look at the phenyl group that we have something that looks like a doublet or an apparent doublet, that corresponds to the orthoprotons. There may be some metacoupling going on there. We're not going to be talking in any great detail about this. But I just want you to get in the habit of always reading your spectrum. So that corresponds to the ortho. We see something that looks like a triplet that's the same integral. If you notice the height in the integral from here to here is identical from the height from here to here. So that triplet or apparent triplet corresponds to the metaprotons. There are two of those. And then we see something that looks like a triplet over here. And again it's either a triplet or an apparent triplet or there's some small additional coupling. I'll say HM. And that corresponds to the paraproton. Now I don't know if you can see on here but you certainly can see on yours. Do you notice where the orthoproton and the metaproton and the paraproton show up? What's their chemical shift roughly? 6.6, 6.7. I said aromatics are typically 7 to 8. Do you know why they're a little upfield? Nitrogen donation. So the electrons pushing in from resonance off of the nitrogen by resonance we get extra electron density at the ortho position and the para position and so that ring is shifted a little bit upfield which is kind of cool. If I made an amide out of that nitrogen which would pull electron density out these guys would scoot over a little more downfield. And here this little guy over here, this is your chloroform peak. All right, all of this is all of the other cyclohexyl stuff that are not directly involved. And then we have three peaks in the midfield region. Remember right now we don't know the stereochemistry and we don't yet know what's what. Why do we have three peaks? The NHs. So we have these two protons and the NH. Something very interesting happened with this sample and this wasn't anything that I planned on. It was simply a day later I went to rerun the sample, same sample. And the midfield region looked a little bit different. This is your day old sample. This is the freshly prepared sample. What's going on there? So we still see it. So James said the nitrogen is swapped with deuterium so we still see it but now it's broad. What does that tell us? Maybe moist. If it were very, very wet, you see this peak over here. So this is, and the sample was nicely sealed. So this little peak here at 1.6 is H2O. That's about where you see it, 1.6, 1.56. That's very typical for H2O and chloroform. So we don't have a lot of water in there, probably about 10 millimolar, 20 millimolar water. And we have lots and lots of sample. What else did I tell you about chloroform? Ingenera HCl and a little bit, even a little bit that forms is going to catalyze the exchange of NHs between molecules or between molecules and water. So even if you form just a little bit, 1% for example of I guess it would be DCL but the majority of course if it's 1% of your molecule, 1 mole percent, the majority is still HCl. But what's happening is now your NHs instead of saying attached to the same molecule are getting swapped between molecules. And as a result, in this case it's also getting swapped with water. But as a result if that proton doesn't stick around for tens of milliseconds or hundreds of milliseconds, you can't see the spin as to whether it's spin up or spin down. So we lose coupling. It becomes a singlet, in this case a broad singlet. Now let's look at these patterns here in the unexchanged sample. So these are all the midfields. So which one's the NH over here? 3.4 ish. The doublet is the NH. And so the other two, and we'll talk more about this in a moment, but the other two, one of them changes a little bit in pattern visibly. All right, let's talk now about what we call these patterns. So what do we call this pattern? We saw it last time. It's a triplet of doublets. You have two big coupling constants and one small coupling constant. What do we call this pattern here? A quartet of doublets. So you have in roughly 1 to 3 to 3 to 1 ratio four little doublets. And if you wanted to be fussy about it, you could say, well, you know, my quartet isn't quite perfect. I can see these two aren't quite the same or they're one's a little fatter than the other, you know, because all four coupling constants may not be exactly the same, but they're the same within a hertz or half a hertz basically within the line width and the limit of digital resolution. So if you didn't like to analyze it as a QD, you could call it an apparent QD. I'm fine with either. I think either of these accurately reflects what you see. And here, if you said, you know, I kind of sort of see a little humpy thing over here and over there, you could call it an apparent, so I'll write, or apparent TD. I'm happy with either analysis on this. All right. So, and you'll notice this peak simplifies. The quartet of doublets simplifies, which makes sense because that must have been the proton that was coupled to the NH group because we lose that coupling. So that quartet of doublets now has become a TD or an apparent TD. Well, it's not deuterium. Remember, even though you're getting a minuscule amount of DCL, let me put it in numbers. This sample is 50 millimolar, roughly. We have maybe generated 0.5 millimolar DCL, but that DCL is enough to catalyze the exchange. So now this NH isn't sticking around on this molecule. Every millisecond, this NH is bumping into another molecule and trading partners, or every millisecond, this molecule is bumping into an H, a little bit of the H2O in the sample and trading partners. Typically, when I prepare a sample like this, I pass the solvent through flame or furnace dried alumina to remove traces of water and DCL first if I want an ice spectrum. Or DMSOD6 is another good solvent because it hydrogen bonds nicely and typically keeps your OHs in place by stabilizing them. So carboxylic acids that are hard to see in chloroform often show up well in DMSO. Question? I would say like when the water helps these places, you're fresh, so water there, so when? And the water, so the water could help the exchange, but apparently not enough that it actually, you know, that proton actually does stay in place very nicely and it's just when you get some acid in the sample. Yes, so I was saying that the double, the double, the NH, the double is becoming a singlet, so we would call this a broad singlet, BRS. And then the QD is becoming a TD. So, okay, great question. The QD is becoming a TD. And remember how we teetered on the edge here between being a triplet of double and you can kind of see a little bit of humpy stuff? All the three J's aren't exactly alike. They're all different sorts of protons with their own specific dihedral coupling to it. So there are some differences. And so depending on the shimming of the instrument, one day, one time it looks like a TD. And the other time, this looks like a DDD with two very, very similar coupling constants. So we can just at this point see eight lines here. And so at this point, just due to chance of the shimming, we're able to resolve the two coupling constants that differ by about a hertz. So it becomes a DDD. That's, this is purely, purely coincident. If I had had this with slightly less good shimming, it would have looked exactly like that. All right, what I want us to do now that we've thought about this a little bit is to extract the stereochemistry from here. So we, by figuring already, actually happened to know then that this proton here corresponds to this one. This one here corresponds to that one. But even if we didn't, we'd be able to figure, even if we didn't have this spectrum, you'd be able to figure that out by the amount of splitting that you see. Okay, at this point, I want us to focus on these lines. I want us to extract our coupling constants. I'm going to show you how I handle my own data. I've made things bigger on the back. So this is a peak printout. I'm a big fan. You get this from a second, a separate command on the spectrometer. I'm a big fan of getting these peak printouts because in addition to giving you the peak frequency of each line in PPM, it happens to give it to you in hertz, which of course you can calculate just by multiplying the spectrometer frequency. But the other thing that's really useful is it also gives you the peak height so that if you have little stray peaks or if you have either an impurity or nonfirst order coupling in there, you can pick out your main peaks. Here everything happens to be very, very straightforward. So that first multiply the one that's the triplet of doublets has six lines to it. And so I'm just drawing a line with my pen. The quartet of doublets has eight lines to it. And the doublets of doublets has two lines. The doublets has two lines to it. All right. So remember our analysis of a triplet of doublets. We split with a big J into a triplet. In other words, we have two of the same big J. And then we split each of those lines further into a doublet. And so we get this one to two to one pattern where the lines on the outside are relative, hide half the lines on the inside. And if I called my lines, if I called my lines one, two, three, four, five, six, then the distance of the big coupling is one to three. It's two to four. It's three to five. It's four to six. What did I say? One to three, two to four, three to five, four to six is our big J. And one to two, three to four, and five to six is our small J. And you can see that here. So we're dealing with real data now. What I showed you before was simulated data. All those lines were exactly the same distance apart because it was fake data, because it was a simulation. So now to get the most accurate value of our J's, remember, you've got digital resolution, you've got the fact that your two coupling constants may not be exactly identical, but we can't extract them separately because we're not seeing separate lines. Turns out on that later spectrum where you did see the pattern resolve into a DDD, I was able to extract them. You'll get practice. We got practice with a DDD. Remember, one to two and seven to eight is your small J, one to three, and six to eight is your medium J, and then one to eight minus medium J and small J is your big J for a DDD. But here all we can do is extract it and analyze what we see, which is one big J and one little J. So okay, to get the most meaningful data out of here, I'm going to take all of those numbers and average them. So get a sharper pin here because it's a lot of writing to do here. So if I take these and I've jotted it down, normally you could do this with a calculator. So I've jotted it down here. The one to three is 12.282. The two to four is, I'm sorry, it's 10.282. The two to four is 10.253. The three to five is 11.154 and the four to six is 11.280. And those are our big J values. So what I'm going to do is average them of all of that, of all the one to three, two to four, three to five, and four to six. And I got the average is 10.7 hertz. And now I take one to two, three to four, and so forth. And the average of those is, well let me get the numbers, 4.065, 4.036, 4.162. So the average of those is 4.1 hertz. All right. So if we wanted to report this peak, the way I would report this peak to tabulate it to give us the short story is 4.38, I'd call it a TD or an apparent TD. Maybe because I'm seeing that there is some deviation here, I might call it an apparent TD. J equals, whoops, put a comma there. J equals 10.7 and 4.1 hertz. And I didn't go do the integral here, but if I did the integral, I mean I did it, but not now, it would be one hydrogen. Thoughts or questions at this point? We're finding out the PPM of that peak. I take the average of it. I want to show you something now I like to do. I like to take that peak print out and throw it into a spreadsheet. You will find on most of the problems that I have assigned, I actually have a digital version that you can highlight with your cursor, paste it into Excel or whatever spreadsheet program you use. This one happened to have been done a while ago, and so I didn't do that, but it's very easy if you can slap the data in a spreadsheet. Even if you can't, I'm a huge fan of this. So somebody help me out here because if I make a mistake normally, I proofread. I'll just do 11.87.921. And you'll see how quick and easy this is. 11.83, 11.83,.63,.680, 11.77, 11.76, 11.77,.774. Am I doing that right? 11.77,.11,.73,. By the way, number pads are also extremely useful on this. 11.67,.305 for data entry. But again, I'm a big fan of pasting stuff in. And you definitely want to check your data because the literature is just full of crappy errors in data. And you do not want to be contributing garbage to the literature. Or to put it in more concrete terms, you don't want your committee going and handing you back your second year report with a non-passing redo because you've contributed garbage. Okay, so I think I have all of our numbers there. Okay, so this is a quartet of doublets. So it's going to be 1 minus 3. And it's also going to be 2 minus 4, 3 minus 5, 4 minus 6, 5 minus 7, and 6 minus 8. So I can get all those values. And I can just take the average. And I get 10.3 hertz. So that's our big J and our small J is 1 minus 2. And it is 3 minus 4. And it is 4 minus 6. And 4 minus 3 minus 4, 5 minus 6, and 7 minus 8. And I can again just take my average. I guess I haven't pasted it all the way down. Kind of obvious what the average is there. But, all right. So the average there is 4.1 hertz. So I can go ahead and transcribe my analysis over. And of course normally I would be sitting at my desk probably with a spectrum in front of me where my group members would be sitting at their desk. So the next one we can describe as a 3.90 QD or apparent QD if you prefer 10.3 since it really did look like that analysis was completely on. I'd call it 10.3, 4. J equals 10.3, 4.2 hertz, 1H. And usually if I'm being good, particularly with my computer, I will separate numbers from units. So I will separate, put a space in here. And I'll put a space in there because you separate numbers from units and the space here and the space here. And the last one I didn't do but it's our doublet. It's 3.41 and it's a D. That's just the difference between these two lines which happens to be 9.5 hertz. And that ends up integrating to 1 hydrogen. All right. Thoughts or questions? What is the coupling constant for? Between the two ones. Let's find out. So now we've extracted our data. Now it's time for us to analyze our data and figure out the stereochemistry of the molecule. And also to think if there are any conformational issues. So generally when you have a problem where there are two possible answers, the best way to approach it is to go ahead and to try one answer, see how it fits, try the other answer, see how it fits, and see if you can distinguish them apart. So I'm going to go ahead and draw acyclohexane ring. And let's start with the transsteroisomer. And if we have the transsteroisomer, I'd assume that the favorable conformer would have the two substituents in the equatorial position. Now I wouldn't have known this a priori in terms of the conformation of the amino group. But that NH coupling was pretty big. That was a doublet with 9.5 hertz. That's consistent with an antiperiplanar conformation. Remember that's not stereochemistry, that's conformation. But I can be pretty darn sure that it's realistic to draw this like this. So the thing that I know right now is this is our doublet with J equals 9.5 hertz. All right, if we have this molecule, this proton here, how many big couplings would we expect to it? And how many small couplings would we expect? Two antiperiplanar couplings. So we have this axial proton giving an axial-axial coupling to this one and an axial-axial coupling to this one. And so okay. And one axial equatorial. So we would expect it to be something akin to a triplet of doublets with the J of the triplet, the big J of about 10 and the little J of about 3. And so what we see here is actually a TD or apparent TD with J equals 10.7 and 4.1 hertz. Those are the data that we extracted. And that seems to so far be pretty reasonable. All right, what would we expect for this proton? Somebody else. Three axial couplings. So we would expect, and again, we wouldn't a priori know whether I'd expect a big coupling or a small coupling or no coupling at all to this NH. Depends on the conformation. If you draw the phenyl, it actually makes a hell of a lot of sense that it sticks out like this. You know, in other words, that it really does push it antiperiplanar. But a priori, I might not know what to expect, but it expected least a big coupling from this guy to this guy, axial-axial, and at least a big coupling from this guy to this guy. And we know from the J of the NH that at least in the fresh spectrum, the fresh sample, we have big J there. So what other couplings would we expect to it? One axial equatorial. So this one here, we would expect to see as something like a QD or an apparent QD. And we'd expect to have three big couplings. And what we see is J equals 10.3 and 4.2 hertz. Now coupling should be mutual, and coupling is mutual, but as I said, you're aligned with digital resolution each or about a hertz, digital resolution is actually a few tenths of a hertz, line width is probably about 1.2 hertz. But within the limits of the digital resolution and more importantly, the line width, we're not getting a separate splitting here. Ditto over here, we see 10.7, which within the limits of experiment is the same here. In fact, you could see that we were kind of teetering on the edge between that QD and a DDD type of, or seeing some of our additional splittings, because you could see all those spacings weren't equal. But we couldn't resolve it any better on this. So we see a QD or an apparent QD with 10.3 and 4.2. And this is what I'd report, and it's consistent with these data. But now we also need to think, this is super, super important, because think about this. You start on a total synthesis of a natural product. You do a key step that gives you stereochemistry early on in the synthesis. And you make a wrong conclusion. And now 20 steps later, you finally get your natural product, except it doesn't match the public spectrum. And you're in trouble. And you're ready to graduate and you find out that your, your synthesis of, isn't going to be titled, total synthesis of hard complex molecule, but rather total synthesis of epi hard complex molecule. And that's not nearly as good. So this is really, really important to get this right. Okay. Let's take a look here. So imagine for a moment that instead of having the molecule as the transsteroisomer, we had the molecule as the cissteroisomer. And I don't know if the nitro group's going to want to be axial or if the nitro group's going to want to be equatorial or if I'm going to expect some conformational mixture rapidly equilibrating. But let's start with the premise, maybe, maybe it would be axial. And let's think things through. I think it's pretty reasonable to assume that the trans is all equit, is both equatorial, diequatorial because diaxial would be the ring flip and that would put two big substituents axial. But here we have a nitro group and an aniline group and they're both kind of big. So what would we expect for this proton, alpha to a nitro group, alpha to an axial nitro group? Three equatorial couplings. So what would you expect that to be? Like a quartet with what sort of J? Something like 3 hertz. Q, I'll say it might be an apparent Q. Something that looks like a Q, J equals, I'll say approximately, equal little squiggly, 3 hertz. So that would be our prediction for this molecule. Three equatorial, oh, axial, equatorial, equatorial, about 3 hertz, equatorial, axial, about 3 hertz, equatorial, axial, about 3 hertz. Now here's the cool thing. Let's suppose you couldn't even resolve the multiply. Let's suppose the multiplet was a little broad and misshapen. You could look at that multiplet and say, so let's say for a moment that that multiplet looked, let me give it a little more structure than that. Let me, let's suppose our multiplet looked like that. Not pretty. Like a snake that had swallowed an elephant or something. All right, you could go ahead and say, all right, I can't get a peak print out on this thing, but I can measure this distance with my cursor. If that distance looks like it's about 12 hertz, that sure as heck is not consistent with this one here. Because this one, even if you couldn't resolve it, even if you couldn't exactly pick it out, what would that distance be about? About 25 hertz because we'd expect it to be 10 or so plus 10 or so plus 3 or 4 or so. So in other words, we're using the number 10 hertz, which was just sort of the number I wrote on the blackboard or 8 hertz or 9 hertz. I would expect it to be at least 10 plus 10 plus 3. Two big couplings of about 10 hertz each and one little coupling of about 3 hertz each. So that molecule, even if it didn't give me its coupling constants precisely, would scream at me that it was consistent with this and not consistent with this. Now what would we expect to see for this proton here? Let's assume that we continue to have coupling to this NH and it's about 10 hertz. What would we expect to see here? Two diaxyl couplings or? All right, good. So we would expect to see it as, how would we describe that pattern? A triplet of triplets or TT or something that looked a heck of a lot like it. Now I don't like calling this an axial coupling because that's special. I mean it happens that we happen to have it be big here but it's not really axial on here. But you can think of it, I mean because it's not on a ring. It's not axial on a ring. But we see it's big. Anyway, the point is you would have one big coupling on the cyclohexane ring, one coupling to the NH that, in this case, we happen to know is about the same size and then two small couplings. And so our pattern would look like one, two, one, two, four, two, one, two, one. So the protons are on the carbon that are theta, why do they not split the protons or the protons that are alpha differently? Because can you say that if a carbon is next to a chiral center, two protons are different. Do they not split differently? And the answer is they could split different or the same. If the dihedral angle is similar, then you will see either the same or very close to the same. If the dihedral angle is different, you'll see different. It may be, and we saw how this was teetering with the spectrum. We're coupling constants that were the same within about a hertz weren't quite resolving apart, 11 and 10 hertz, 9.5 and 10.3. So it might be that this pattern instead of being a Q, could be a TD or a DDT or a DDD with three small Js. For example, it could be a DDD with 4, 3, 2, and that would be consistent with this or a TD with 3 and 2 or a DT with 2 and 3 or 4 and 3 and that would be consistent. So three small Js no matter what. All right, I want to play with this idea for a moment longer and ask the question what would happen if my assumption about the annulin group being equatorial was wrong or was incomplete and so I'll do a ring flip and imagine for a moment that my annulin group is axial and my nitro group is equatorial. And so if we had this conformer, so these are both cis, we have two different conformers here that we're considering. So let's take our proton alpha to the nitric group. What would we expect for this proton now in this conformer of the cis diastereomer? One axial, so it's this one to this one and two equatorial partners. So one axial-axial coupling and two axial-equatorial coupling. So how would we describe this proton here? A doublet of triplets. DT or apparent DT and what would we expect our Js to be? First name for the coupling constant for the multiplet is doublet. So that's the big split. Ten. Something, yeah, three, four, something like that. So we would expect it to split with a big J and then split into a triplet with roughly the small J. And so the pattern you'd see is something like one to one, one to one with this distance here being three, so three, three, three, ten. And this guy here. And let's assume again that we still have a big coupling to the aniline. So the one that's alpha to the nitrogen here, what do we expect for him? Two large. So I'm assuming we're large to the nitrogen. That's kind of a wild card. And then who are its coupling partners on the ring? Axial. So this is axial-equatorial. So this is equatorial-equatorial. This one. Axial-equatorial. Axial-equatorial. So what are we? Two axial-equatorial. No. No, no, no. We have, I'm assuming we're big J to the nitrogen. Oh, that's a good sound. Let's assume, let's just assume because we happen to see that that NH was split. So I'm assuming that's a big J. What are all of our other J's? All small. So this one we would expect to see as a DT, as a DQ, or apparent DQ depending on how it is. And this one we would expect to see the big J3 and the small, the big J10 and the small J3. All right. Last thing I want to do. All right. Let's call this cis-conf 1 and this cis-conf 2. Now imagine that we had an equilibrium, which you may very well a conformational equilibrium. There are two big substituents between cis-conf 1 and cis-conf 2. And that equilibrium is going to be rapid because ring flip on a cyclohexane is rapid. And I just want us to think now about one of these protons. Let's just talk about what we would see for the proton that's alpha to the nitro group, which I'm going to call H sub A. And what I want us to think about is it's coupling specifically with proton B, proton C, and proton D. We'll call B and C the ones that are on the methylene group on the back, D the one that's on the methylene group on the front. And so B is axial, C is equatorial here, and this is D. And what I want us to do is think about what we would observe if we had a dynamic equilibrium between conformer 1 and conformer 2. What would we expect? So if we look at JAB and conformer number 1, it's about 3 hertz because it is an equatorial, equatorial coupling. If we look at JAC, it's also about 3 hertz because it is an equatorial axial coupling. And if we look at JAD, it is also about 3 hertz. And that's why we said that proton was a quartet. In conformer number 2, if we look at it, JAB now is very different. It's about 10 hertz because AB is axial, axial. AC is axial equatorial, so it's still about 3 hertz. AD is axial equatorial, so it's about 3 hertz. So now if we are somewhere in the middle here, not all conformer 1, not all conformer 2, we would now expect to see one coupling constant that's somewhere between 3 and 10 hertz and two coupling constants that are both about 3 hertz. So we would now expect to see this as a DT or an apparent DT or something that showed one big coupling and two small couplings. In other words, a J big of 3 to 10 hertz, if it were right in the middle, we'd say about 7 hertz, so that might be my first guess. And a J small of about 3 hertz. So regardless of whether we had the cis as one conformer, the cis as the other conformer or the cis as a dynamic equilibrium in which both conformers are present, our observed data of a triplet of doublets with 10.7 and 4.1 hertz strongly matches the trans and does not match the cis. So that gives us hysteria chemistry. All right, we will pick up next time talking about other aspects of structure in NMR. And specifically, I guess we'll talk about coupling involved in other nuclei.
This is a graduate course in organic spectroscopy, focusing on modern methods used in structure determination of organic molecules. Topics include mass spectrometry; ultraviolet, chiroptical, infrared, and nuclear magnetic resonance spectroscopy.
10.5446/19256 (DOI)
All right. Well, I will leave these and get started then I guess. All right. So I think I want to finish up what I'll call basic NMR spectroscopy today. In other words, things that all sort of fall at the level of basic interpretation of structures and in turn things that we'll get on the midterm. I think probably where I'll pick up next time is going to be introducing 2D NMR and then our next homework set, not Mondays, but the one after that we'll start using 2D NMR spectroscopy. So what I wanted to do today was to talk more about carbon-13 chemical shifts. And I gave you, when we talked last time, I gave you this sort of general information that just like proton NMR, carbon NMR, aliphatics tend to be upfield, aromatics tend to be downfield, things that are next to electron withdrawing groups, particularly oxygen, tend to be midfield, we'll call it midfield, sort of in that 50 to 70 range. I also indicated, and we said that the range is a lot, lot bigger. It's about 20 times bigger in PPM for C13 NMR. In other words, an aldehyde CH is at roughly 10 PPM, whereas in carbon NMR, an aldehyde carbonyl is at roughly 200 PPM. So it's sort of like 20 times bigger range. Now, C13 shifts have a bigger range, and there's also more richness. In other words, when we talked about proton NMR, it was pretty easy, and we were able to come up with some really simple back of the envelope calculations where you could typically peg the chemical shift to within a few tenths of a PPM. We talked about if you're next to an ester, or if you're next to an oxygen, figure you're going to be about 2 PPM downfield of where you'd normally be. If you're next to a benzene ring, or a double bond, or a carbonyl, figure you're about 1 PPM further downfield. I gave you several ways of thinking about this, and you should all be able to pretty much estimate things. We talked about the effects of alpha substituents and said that alpha substituents have a really big effect, being next to CH, next to a halogen, next to a nitrogen, next to an oxygen, shifts you down a couple of PPM. We talked about beta effects, and we said that they're smaller. Beta effects in proton NMR shift you down by 0.2 to 0.5 PPM. C13 NMR is a little bit more subtle, and a little bit, I won't say less predictable, because we're going to see it's actually quite predictable. But the factors, there are more factors. For example, gamma effects, as well as beta effects, tend to be big, and there are some really interesting steric effects. Now, along with this richness comes tremendous power, because this means that carbon NMR also can give you tons of rich information about structure and can be really useful for figuring out structures, confirming structures, disproving structures. And at the end, I'll show you a beautiful example of some fraudulent work that was disproven by Professor Riknowski's laboratory, and also going ahead and basically having a tool that can get you a lot more information than meets the eye. So I want to show you some of the factors that contribute to these sorts of general ranges, and particularly now, perturb them. And let's start with something pretty simple, inductive effects and resonance effects. And electron density, of course, plays a huge role in chemical shift, because electrons contribute to the shielding, or deshielding, if they're absent, of various nuclei. So if you have substituents that increase or decrease the electron density in a carbon, you're going to shift that carbon upfield or downfield. Let me show you what I mean. We'll start with a simple benzene example. Now, the easiest way to, in your mind, think about chemical shifts is to start with a base value and then perturb it. So a great way to think about benzene is the normal position for benzene is 128.5 ppm. And then if you put substituents on it, you perturb things in a rational way. So let me show you what I mean. If we put a methoxy on the benzene, the oxygen is electron withdrawing through the sigma bond. And so the carbon attached to the oxygen shifts substantially downfield. So you go to 160 ppm. In other words, you shift downfield by 30 ppm, more than 30 ppm, by putting that oxygen there. Now, what's interesting then is the ortho carbons end up having by resonance extra electron density at them. In other words, the two ortho carbons, you can push your arrows and you see they're electron rich. It's the same reason why electrophilic aromatic substitution occurs ortho and para when you have a methoxy group on there. So the ortho carbons appear at 114 ppm in methoxy benzene. You don't get a big effect at the metacarbons, which makes sense because you have inductive effects that are now quite removed. So it's very small. And resonance doesn't pump up the electron density at the metacarbon. You go to the paracarbon and now you also see an upfield shifting, albeit a smaller upfield shifting at 121 ppm. Now, I'll come in a moment to empirical additivity relationships, but one way to think about this is to think about it if you have a methoxy group or an alkoxy group on a benzene that it shifts the ortho protons upfield by about 14 or 14 and 1 half ppm. And if you have a methoxy group, it shifts the paraprotons upfield by about 7 and 1 half ppm. And if you have a methoxy group or an alkoxy group, it shifts the metaprotons downfield by just a fraction of the ppm. And what we'll see in a moment is that you can add up all these effects and then calculate for different aromatics the effects of different substituents. All right, let's take a look at some other examples of electron of inductive and resonance effects. So let's take an alkene. And I'll give you cyclohexene as a base value. In cyclohexene, your alkene is at 127.4 ppm. Let's compare that to cyclohexanone. And in cyclohexanone, we see a very big effect at the beta position and just a little effect, just a little inductive effect at the alpha position. The beta position is 151 ppm. And the alpha position is just shifted downfield by a hair. And that makes sense because you look at this and you say, OK, now you can think of a resonance structure in which you're electron deficient. We all know that enones are Michael acceptors, that nucleophiles like to attack at the beta position. Are you doing this with orbitals in Van Vrenken's class now? Yeah, so you know about frontier orbitals and electron density. And so you see the effect is actually very substantial. Both of these carbons, they're symmetrical. They're at 127, you go more than 20 ppm downfield by decreasing the electron density. These effects can be absolutely among us. And one of the things that I've tried to emphasize when I've talked about these ranges here are, these are general ranges. These are not carved in stone. And so you already see, for example, that this one inductive oxygen here brings us even outside of this very generic range here. Let me show you just how huge the effects can be. So ketene acetal is a good example, right? Alkenes are normally like 110 to 150 ppm. But if you usually perturb the electron density, you can have huge effects. So it probably doesn't surprise you too much if I tell you that you now by having a 2-methoxys on an alkene can shift it downfield to 169.7. But what's really huge is you look at the position here, the beta position on the alkene. And now we're so electron rich. This thing is so nucleophilic at this position. There's so much electron density at that position that we're at 45.5 ppm. You look at a spectrum of that, you wouldn't even know it's an alkene. Because you'd say, oh, that's got to be aliphatic. That's got to be somewhere over here. And we've just pumped up the electron density usually. The most radical example I know off the top of my head is this sort of push me pull you system here, where you have two electron donating groups and then two electron withdrawing groups, two cyano groups. And so this alkene, you go to 39.1 ppm. And then this carbon here is at 171. And 171, you'd say, all right, well, that's really downfield. But you'd say it makes sense. You've got these beta electron withdrawing groups. But you look at 39.1. Who would have thought that that is an alkene? Yeah? What is that letter? CW or CN? CN. So these are two nitrile groups. These are two cyano groups, CN groups. All right. So substituents have substantial effects, whether they're alpha, whether they're beta, whether they're gamma. And you can really see this. I'll give you, we're going to walk through this. And I'll give you some examples. So first let's talk about alpha-alkyl substitution. And if I want to give you a general principle, in general, alpha-alkyl substitution leads to more downfield shifting. So if we, again, take our benzene example, and remember we said that benzene was at 128.5. If we put a methyl group on it and make it into toluene, now we go to 137. Point is we shift downfield by about 9 ppm by putting on a methyl group onto benzene. Let's take a look at alcohol systems. So we'll look at propane. And we'll look at the central methylene of the central carbon of propane. You put on an alcohol group onto propane, and you get isobutane. And now you're down to 25 ppm. And so you'll notice it's kind of about the same. Here we move down by about 8 or 9 ppm. And here we, again, move down by about 9 ppm. So in other words, we're talking on the order of 10 ppm or thereabouts. All right, you put on another alcohol substituent, and the effect is as dramatic. But again, you move further downfield. Now we're at 28 ppm. Now what's nice about this is these ideas are generalizable. There is really science here to it. And this is the point that you can take little bits of knowledge and generalize and build up in your mind what's going on. So let me compare us, say, to ethanol. If we started 58 for ethanol, and now we have envision going to isopropanol, what would you predict your carbon to be at here? 67 would be a very good prediction. Because we say, OK, we take 16, we add 9, we get to 25, you add 9, you get to 67. And that's a very good yes. 64 is the answer. All right, now imagine we go further and we go to tert-butanol. Now what do you think for tert-butanol? 66? You don't think it's going to change? OK. Other guesses on this estimate? 67. All right, and the answer is 69. No, you're doing good. You don't have to peg it to the nearest PPM. But we would want to take it right. Oh, OK, the price is right approach. The chemical shift is right. Do you think we have a show here? Maybe really late night TV. This is the full Bob Barker. Maybe we can do a webcast of this. Try it out in a test market. All right, so in the case of proton NMR, we also saw that shifting, adding an alkyl group, shifts you down field, right? We said a methyl group is typically at about 0.9 parts per million. A methylene group, we said 1.3 to 1.5. So in other words, you're shifting down 1.2 to 1.4, I think I said. So in other words, we're shifting down field to about 0.5 PPM. A methine is down at like 1 and 1 half for 2 PPM. These are the baseline values. So in other words, we go a few tenths of a PPM more. And so it kind of makes sense if you get half a PPM for going, adding one alkyl group and another couple of tenths of a PPM for adding another alkyl group. Kind of makes sense here with a scale 20 times bigger that we get about 9 PPM or 10 PPM for adding one alkyl group and about 5 PPM for adding another alkyl group. With the case of proton enomar, beta alkyl groups don't make a huge effect in chemical shift. In the case of C13 alkyl groups, though they do, beta substitution ends up also leading down to further downfield shifting. Not quite as dramatic, but let's take an example. And what I'll do is I'll take butane as an example and we'll look at this carbon here. And then we're going to put substituents over here. So there'll be beta to it. In other words, instead of directly on it, there'll be 1 over. So if we add one methyl group here, so I'll go from butane to methyl butane. Now this carbon goes 7 PPM more downfield. We go to 32 PPM. And then if I add another one, we go another 5 PPM more downfield, we go to 37. Not as big but still pretty darn big. Okay, so that's beta substitution. Let's look at gamma substitution. Now gamma substitution is interesting because gamma substitution leads to upfield shifting and it's really a steric effect. So with gamma substitution, what basically you're doing is now getting interactions that are by having steric repulsion pushing more electron density onto the carbon and shifting you upfield. So let me show you what I mean. So we'll still keep to this same type of general structure but now we'll consider this carbon here. And so if you look at the carbon here and you have hydrogens banging into it, you basically will have hydrogens banging together. This is going to lead to more electron density on the carbon. In other words, electrons of the CH bond repelling electrons push electron density into the carbon. And since you don't want to have steric repulsion, this occurs most pronounced when the molecule cannot avoid steric repulsion. Let me show you what I mean. In other words, if we start with butane and we start over here, the methyl group of butane is 13 ppm. If I add one methyl substituent, gamma, so right in other words, if I attached it directly to this carbon, we'd be alpha. If I attach the methyl substituent here, we'd be beta. If I attach the methyl substituent here, we'd be gamma. If I add one methyl substituent, that carbon shifts from 13 to 12 and you'd say, yeah, that's not a big deal. That's not a huge effect. And part of it is this methyl group can adopt a rotational isomer, rhodomer, where it keeps out of the way. But if I add one more methyl group, then no matter what, we're going to be staring that other methyl into the face. So if I go like that and go to 2-2 dimethyl butane, now there's no way to avoid that steric repulsion and we shift over to 9. So now we've shifted upfield by about 4 ppm relative to our initial compound. So even this very remote substituent can make a big difference. You can really see this in confirmationally constrained systems like cyclohexane. So if I take cyclohexane and I consider the carbons, all the carbons of course in cyclohexane are the same and they're all at 27 parts per million. If I now add a methyl group, gamma to this particular carbon, so remember if I attached it here at v alpha, if I attached it here, it would be beta. If I attach it here, we're gamma. If I add one methyl group, that methyl group keeps out of the way because it keeps equatorial and so we don't see any change. But if I add a second methyl group gamma, then one methyl group has to, has to, has to be axial. And there's no way to avoid 1,3-diaxial interactions. And so now that carbon shifts up to 21 ppm. And that's a pronounced effect. And I'll show you the implications of that in just a moment. All right. So these are all of the sorts of biggie effects in C13 NMR. And now I'll show you the last biggie effect and that's heavy atom effects. All right. So let's take a look at what happens when you make various hillomethanes. So again, it's very helpful to have a baseline value. Methane occurs at negative 2.3 parts per million. So we're going to compare the hillomethanes to methane itself. And so we'll look at monohillomethane CH3X, dihillomethane CH2X2, trihillomethane CHX3, and tetrahillomethane CX4. And we'll start with X being chlorine. And so that, no great surprises here. You put a chlorine onto methane, you get chloromethane, and you go downfield. It's 25 ppm. You add another chlorine, you go further downfield. It's 54 ppm. Chloroform, where does that show up at? 77. 77 is chloroform. So you go further downfield, you put yet another chlorine on there, and you go further downfield. And so you look and you say, hey, what am I wasting your time for? This doesn't seem like any sort of surprise. Well, if we move down the periodic table, the atoms get bigger and they start to have the orbitals and they start to have their orbitals extend outward. And then we see something very surprising. You put on a bromine and you'd say 10, and you'd say, well, that's not so surprising. Bromine is less electronegative than chlorine. It's going to shift you less further downfield. You add two bromines, you go to dibromomethane, and you say 21. When you say, okay, that doesn't sound so surprising. We're moving further downfield. Three gets a little bit weird because we start to move upfield. And by the time we're at four, we're at negative 29. And then iodine gets downright funky. So iodine, iodomethane is at negative 21. Diiodomethane is at negative 54. Triiodomethane is at negative 140. And tetraiodomethane is at negative 292. And what's happening is the orbitals are extending so far out with these heavy atoms. As you move down the periodic table, that their electron clouds are actually enveloping that carbon and shielding it from the applied magnetic field. And as you can see, in some cases, shielding it very dramatically. Now, the practical implication for this becomes if you go ahead and do a reaction to say make an alkaliah died in synthesis and you don't go ahead and look upfield, you may miss your carbon and say, oh my God, I can't see my carbon. There's a parameter in the NMR called sweep width that you adjust. That sweep width is the spectral window that you look at. If you have a compound that you expect to be very far downfield or very far upfield, this is true in the proton NMR as well. If you have a compound that you expect to be very far downfield or very far upfield, you can just increase your sweep width, field width, by whatever number of hertz you like. You type in the parameter SW, get a bigger spectral width, and then you can see, for example, your carbon that's attached to iodine. Same thing with protons attached to iodine. I once took a spectrum of HI. I was doing a deep protection reaction in an NMR tube. And HI, the peak was at negative 10 ppm in the proton NMR, which was absolutely wild. Why like in the bromine one that at first, if it's a more downfield, then when you get three bromines, then all of a sudden, now it pushes it back upfield? I think what it is, so the question is why are two bringing it more downfield? Obviously, you have the inductive effect pulling away. I think by the time you get to three, you just have that carbon completely surrounded by the electron clouds. So now you just have electron clouds sticking out in all directions, and then four, it's just all around it. These are in part relativistic effects. When you're doing MO, when you're doing molecular orbital calculations on heavy atoms, you actually need to have special terms taking into account relativistic effects of the orbitals. All right, so one of the take home messages from this is there are a lot of factors that go into carbon-13 chemical shift, and for this reason, carbon-13 chemical shifts are very rich and very valuable, and being able to predict them can lead you to lots of useful information on structure that can be extracted, sometimes can give you a problem-solving tool that you might not otherwise have. And so what I'd like to do now is to show you some of these problem-solving tools and their applications. So we'll talk a little bit now about C-13 chemical shift prediction. And we're going to talk about three different ways of doing this. One is what is called empirical additivity relationships. That's the simplest. The idea there is we're going to go and say, okay, the effect of an ortho substituent is this if it's an oxygen, the effect of a meta substituent is this if it's a chlorine, the effect of an alpha substituent is this, the effect of a beta substituent is this, the effect of a gamma substituent is this, and we're going to add up all of those effects. If you use ChemDraw and you have one of the more advanced versions of it that does chemical shift prediction, that's exactly what it's doing. Those calculations also for all sorts of systems, aliphatic and aromatic systems are shown in your book, in your structure determination, the orange book that you have for the course, you know, the supplemental book and you can do it for all sorts of systems. And they do it to a limited extent in Silverstein and I'll show you that just for aromatic systems. Unfortunately, the ChemDoodle program which tries to do chemical shift prediction, thus far, they're still very much in development but they've thus far got it wrong. There is also a small CD, Windows only, that goes with your, with the orange book in the course with the supplemental book that has some limited chemical shift prediction based all on empirical additive relationship. Another way of doing this is based on databases where you come up and rather than simply saying, all right, we're going to have alpha effects and beta effects and gamma effects, you have a training set. And then from that training set or that set of reference compounds, you find parameters that fit them and then you can extrapolate. So you first interpolate to encompass all of the compounds in the set and then you can extrapolate to encompass other compounds. And so there are generalized databases and they're also specific ones. So for example, for various stereochemical problems. And the third way of doing this is going to be by electronic structure calculations. And we're not going to do this in the course but I'll show you an example at the end. Basically, since carbon 13 chemical shifts come from electron density, if you can calculate the molecular orbitals at an appropriate level of theory to figure out how the electrons are distributing your molecule, then you can figure out the electron density around any carbon and hence it's shielding from the applied magnetic field. All right, let's take a look at these various methods. And I'll start you with a simple page right out of Silverstein and Prech has a, the orange book Prech has a similar table. Oh, that doesn't look good. Ah. It helps to plug it in. All right, so this should be on your handout. And as I said, this is just one of the many tables in Prech but a tool is so much more useful when you actually have used it and know how to use your tool. All right, so this is a table of empirical additivity relationships for substituents on benzene ring. And literally what was done to make this table was, as we said, benzene's 128.5. So somebody took a spectrum of phenol and said the carbon that's directly attached to the OH of phenol is shifted down field by 26.6 ppm or 20, what did I say, 26.6 ppm. The carbon that's ortho is shifted up field by 12.7. The carbon that's meta is shifted down field by 1.6 and the carbon that's para is shifted down field by 7.3 ppm. All right, let's take a look at the following compound and then I'll give you two spectra and I'll show you how we'll use these. So let us imagine for a moment that we were trying to distinguish the following compound from other isomers. So let us suppose for a moment that we were trying to distinguish say this compound to for dichlorophenol from this isomer 3, 4 dichlorophenol. That would be a tough one to do based on coupling patterns because in the proton NMR. Because if you look at the proton NMR you would say, we would expect to have one proton that is split by an ortho coupling so we would expect it to be a doublet and its J value would be somewhere on the order of about 7 or 8 hertz. We would see another proton. What would you expect this proton here to appear as? As a doublet of doublets with J values of what? Metacoupling 3. So we'd expect this to be a doublet of doublets with a big J of about 7-ish and a small J of 3. And this one we would expect to be 3 as a doublet. And you would expect this exact same pattern of coupling here. A doublet of doublets with a big J and a small J. A doublet with a big J and a doublet with a small J. So we wouldn't be able to tell them apart. But let's look at this compound here and use these principles. If we want to calculate the chemical shift for let's just take, I'll just do three of the carbons here. So if we were to want to calculate the chemical shift here, we would start with the base value of 128.5. And then we would say, okay, we have an orthoalkoxy and we'd look in our lookup table and we'd say we'd or an orthohydroxy and we'd subtract 12.7. So minus 12.7. Now we would then look at the effects. Can we see from this angle? Should I move these calculations over? Let me move this over. So 128.5 is our base value. Then we have a orthohydroxy and so we take away 12.7. Now we're going to look at the effects of chlorine for this compound and so we have two metachlorines. So we'll go to our lookup table and we'll look at the effect of a chlorine. So I'll draw a line here. And so now we have two metachlorines. So we have a metachlorine over here. And that's going to have an effect of plus 1.0. And we're going to have, I guess I should make my numbers line up if I'm going to run a tally. And we have another metachlorine and that effect is plus 1.0. So we tally all of those up and we predict 117.8. And now I can do, so that's for this carbon here. Now I can do this next carbon. So you help me out with this calculation for this carbon. So what do we use as our base value? 128.5 and then what do we do for the oxygen? So we add, so the oxygen is meta OH. So we add plus 1.6, okay. And then what do we do next? James? Point two. Point two for? For the metachlorine. Sorry, the orthochlorine. Orthochlorine, so we do O-chlorine is, you said plus point two? Plus point two. Plus point two. And then somebody else, what do we do last? Subtract two for a parachloro. And so we tally all of that up and we predict 128.3. All right, I'm not going to do any more. We could do it for all six of them. But let's flip to the next page in your handout. And I grabbed from the Aldrich Library of Spectra the proton and carbon spectra of the two compounds. And we're just going to look at the carbon spectrum. And the thing that jumped out at me in the carbon spectrum for a difference that was really cool was in the carbon spectrum of the first compound, remember the quats are small and the CHs are big due to relaxation, differences in relaxation time and the nuclear overhouser effect. And what jumped out at me immediately was that here we have two of the CHs close to 130. And one of them, so two basically downfield of 120 and one upfield, so at about 115. And what jumped out at me here was the dramatic difference. We're here we have one at about 150, about 130. And then two of them at the range between 110 and 120. And of course we could do this for the quats. They're dramatic, there are substantial differences as well. You can see here are your quats. So all I did in preparing for today's discussion was I just calculated for the two compounds. And so we did 118.5 and let's see was that right? Wait, oh what did I do? I did my, yeah I don't know how I managed to tally things up wrong here. Wait, 118.5. Let's see, 128, 129, 130, 118 point, wait 118 point, what was it? What? It was at 128.5. Wait, 117.8. Okay, so I get, I don't know what I was writing down here, 117.8 and 128.3. And over here, I think what did I end up doing? 130.7 and then over here, 115.2 and 117.5 and I think here, 131.7. All right, so the point of this is even though it might be very hard looking at the proton NMR to assign which isomer we have, by looking at the carbon NMR you can say, oh wait a second, okay, the first isomer that has the 130.7, 128.3 and 117 matches this spectrum and we could do this with the quads as well. So this spectrum corresponds to the first isomer. The second isomer that has the 115.7, 117.5 and 131 matches this spectrum. And so imagine for a moment that you're doing an electrophilic aromatic bromination of phenol, you want to determine whether you got the product you expect. You know you have a dichlorophenol, you don't know the regiochemistry, you can very quickly check yourself. And the good news is these types of relationships generally good to let's say plus or minus, let's say 3 to 5 ppm on the average. So the point is that you can with very little difficulty tell things apart. All right, there are many, many more sophisticated ways of doing this. As I said you can do this for aliphatic compounds as well. With aliphatic compounds you've got to add up alpha effects, beta effects, gamma effects, there's even a little bit of delta and epsilon effects so you have to look at the whole molecule, there's steric effects. You can do this easily by pencil and paper but it's even easier to do it with computer software and as I said even chem draw in the more sophisticated versions incorporates this. There are other empirical additivity relationships that are out there and but in addition to that there are databases that have training sets. So for example this is just one poster I pulled that's a database approach and what they were looking at was how well their system that was trained on a training set would predict the C13 NMR of taxol and in general their values were good to plus or minus 1 ppm on the average and so for example they were able to distinguish here's another one that would be hard to do by NMR. They were able to use their database approach and here we have two tautomers and so they, if you synthesize this molecule you might not know which tautomer you have whether you have the molecule with the carbonyl or the molecule with the hydroxy and it's not so easy that you can take an IR spectrum because by that point you end up with very strong stretches associated with the CN bonds of the pyridine tautomer and so the IR spectrum is not clearly going to scream carbonyl at you. The C13 NMR the difference between what you would expect here and what you would expect here for the carbonyl is small enough you can't just look and say obviously I have the pyridone or obviously I have the other compound but in fact they can go ahead and calculate to within a couple of ppm the, so they were able to experimentally measure the value and then say okay what's the deviation and here they're getting an average deviation of about 2 ppm. In other words some of the shifts will be off by 3 ppm, some of the shifts will be off by 1 ppm but on the average they'll be good to within about 2 ppm. All right so that's an example of a database approach and in general their methods good to about 3 ppm. Many times you encounter specific problems. You are working on a research project that involves a specific class of molecules. For example the Riknovsky group here and the Kishi group at Harvard are very interested in 1,3 diols. 1,3 diols are important classes of natural product. They come from pyosynthetic pathways that give rise to molecules of many different structures and the big issue becomes determining stereochemistry. The Riknovsky group noticed after the fact they were working with 1,3 diol acetonides and the question was do they have a syndiol or an anti-diol right? So a syndiol would be a 1,3 diol with the 2 OHs are like so and an anti-diol would be one in which they are like so and the beautiful thing is if you're a clever graduate student or a clever professor and you keep your eyes open and look at your data you say hey we've got a pattern here and that pattern tells us something and that pattern means something. And when they went back and looked at all of their C13 NMR spectra of the 1,3 diol acetonides that they had prepared, they saw something very interesting. The methyl groups of the 1,3 diol acetonides when the diols were syn appeared split at about into two sets of diastereotopic peaks one peak at about 20 ppm, the other peak at about 30 ppm and when they had the syndiol acetonide both of the methyl groups appeared at about 25 ppm. In other words you could now take a diol of unknown stereochemistry, make the acetonide and just by looking at the C13 NMR spectrum say oh that's a syndiol or that's an anti-diol. It's hard to do that otherwise that's extremely valuable. Why does this occur? It's that gamma effect again. When you make the syndiol you end up with a chair. And in that chair one of your methyl is axial and one of your methyl is equatorial. And remember the axial one gets steric compression so it is shifted up field. The equatorial one doesn't get that steric compression so it's shifted down field. On the other hand when you make the anti-diol acetonide then you can go ahead and both your methyl groups are sort of in the middle neither of them really has. You get a twist conformation neither of them has unusual effect and they end up in the middle. So just by a quick C13 NMR with this bit of knowledge in hand you can go ahead and assign the stereochemistry. The Kishi group at Harvard has taken this type of approach with their diols and this is a really, really cool use of synthesis. So they have diols where you have alternating hydroxy and methyl groups. These are compounds that occur in a variety of different natural products. And so they wanted to be able to tell the stereochemistry of these patterns. So they went ahead and they said, all right, we've got lots of natural products with this type of unit where you have a diol, a methyl, an alcohol, a methyl, an alcohol, a methyl. And so what they did was make a training set of all the possible stereoisomers. So they made ones in which they were all syn and which one is anti and which two are anti in different positions and so forth. And they found that there were characteristic that each carbon in their training set. So they used this molecule as the training set. Each molecule in the training set had an average chemical shift of a certain position. And so then they took the average value and they said, if you compare it to the average value, you have a fingerprint where certain ones are shifted upfield, certain ones are shifted downfield. And each of the possible stereoisomers has their own pattern. So that means you can then take an unknown compound based on this training set and the database and take an unknown compound and say, ah, the pattern matches this stereochemistry. All right, last example I want to talk about. And this was really cool. So this is all calculating based on known information. We started with the simplest thing. You just took phenol and you said, okay, what's the effect of an ortho substituent? What's the effect of a meta substituent? What's the effect of a parasybstituent? To chlorine, to chlorobenzene did the same and then say you could predict another compound. These diols are also examples where you have a training set. But for really funky and unusual compounds that have very unusual rings and strained rings, there may not be a good model out there. And there was a really cool compound that was synthesized, in quote, by a single researcher in San Diego who published this on his own in Angavanto with no co-authors and no university affiliations. His name was James J. LeClaire. Still is James J. LeClaire. And he published a synthesis that looked really cool because the molecule he said he synthesized was this, hexacyclineol, one that Phil Barron, I think, would appreciate as a challenging target. And like a student who maybe didn't quite get an A in SIN 1, his synthesis had some stuff that was funny about it in addition to him being the sole author. There were steps that just didn't seem to make sense. And so the buzz in the community was something wasn't right here. Now nobody wants to tell their entire lab, hey guys, let's reproduce James J. LeClaire's experiments and see if it really works. That's several graduate students and dissertations worth of work. That's not exactly a great job to be doing. So Professor Riknowski used electronic structure calculations to see how well he could first predict the chemical shifts of a known molecule. So he took a known compound, ellipsa seterin, and did these electronic structure calculations and plotted a graph of the actual chemical shifts versus the observed chemical shifts. And as you could see, most of the chemical shifts calculated, the calculated ones and the observed ones matched within a couple of tenths of a PPM. So in other words, here we have a match of plus or minus 2 PPM on the average. All right, so confident, confident of his methodology, he then took the structure of hexacyclineol. And I'll put this in quotes here as you'll see in a moment. And found a terrible match. The vertical scale on this graph is from 0 to 5 parts per million. You look at the scale on this graph, it's from 0 to 25 parts per million. The deviations on the average are within about 7 PPM. It's many of the shifts are way off. So that's the average. Now, he then went ahead and thought, this guy got the structure wrong. And he had a hypothesis of what? So not only did he think that the synthesis was a fraud, he thought that the structure wasn't even right because it didn't match. So he reinterpreted the published structure of the molecule, the one from the Journal of Natural Products, where they had isolated this molecule and thought it was this structure, reinterpreted the data and considering biosynthetic factors came up with what he believed the correct structure to be was and there the structure matched and he did two different conformers of it and there for this structure matches within plus or minus 2 PPM average. By 2 PPM average, I mean RMS deviation, root mean squared deviation. So on the average within 2 PPM. So the answer became not only did James J. LeClaire, what would I say, cheat, forge? A synthesis of the molecule, but he forged a synthesis of the wrong molecule and it was an impossible synthesis. Anyway, it was pretty cool and the Riknowski group was really happy for a while. But who is he exactly? A very unusual character. So the other thing that was interesting and it's all out there is if you look at his spectrum of hexacyclinol, hexacyclinol is a terpene, it has methyl singlets in it, which are big tall peaks. If you look at his spectrum of his synthetic hexacyclinol, the methyl groups are missing C13 satellites. Those little side peaks spaced 125 PPM, 125 hertz around there at 0.5% of the height, which for a 20 centimeter height peak, you can actually see in the spectrum. So he fabricated this synthesis and his spectrum out of whole claw. If you go and you earn your PhD here legitimately and then later on as an independent scientist working at the Zenobi Research Institute, your own research institute, publish absolute nonsense in the literature. Yeah, I don't know. I don't know how to get public. Oh, interesting question. A very controversial story.
This is a graduate course in organic spectroscopy, focusing on modern methods used in structure determination of organic molecules. Topics include mass spectrometry; ultraviolet, chiroptical, infrared, and nuclear magnetic resonance spectroscopy.