Hi everybody, welcome to Delhi stage. And I think we can start up with our first session for Python India 2020. So the first session we have today is understanding peak memory layout with PernDebat. I hope I pronounced it correctly, Rohit. And our speaker for today is Rohit Keshri. I think Rohit, you'll be up. Yes, hi, how are you? Yeah, I'm good. Thank you. Okay, thank you so much. Glad to have you at Pycon India. And so for everybody who's tuned in on Hopin, so we will have a 25 minute session by Rohit on peak memory and followed by five minutes of questions. So please do put up your questions on the Hopin platform and we will take that up at the end of the talk, right? Does that sound good, Rohit? Yep. Okay, so I think with that you're on. All the best. Thank you. Hello, everyone. Thank you for joining me. My name is Rohit Keshri. I work in Red Hat as Product Security Engineer in Kernel Space. I'm going to talk about dynamic memory allocation mechanism in user space programming. In this, we will be talking about heap internals. We'll know how the heap formation takes place, its metadata, register contents, and so many things about this. To understand the user space memory layout, we will be using a tool known as PernDebug. This is a Python-based module and is running as a plugin with GDB. This is an open source project and here is the GitHub page for this. PernDebug tool adds some interesting introspection mechanism to understand the resources, especially the memory layouts. And here is, in the case of heap, it is also very much helpful. In the Hall segment of this page, you will see the installation guidelines. It's very simple. You just need to clone up a script and you just need to run it. It even installs GDB for you on your system and that is ready to go with this tool. The agenda for today is like, we will be talking about the memory layout in C. We will know about heap internals. We will know what are arena's heap chunks. We will also see a live demo on the tool itself and we will try to use a C program, which is small and where we will be in a process of heap formation and we'll learn so many things. So when a user space program gets started, it gets some default resources allocated and memory is one of them. Looking closely at this memory, you will see there are so many different types of memories that are getting associated to the program. Stack is one of them, which is used to store the local variables and the passing arguments of the function and also it holds the returns. Any global variables defined in the program are stored in the DS data segment, which is if initialized. If the global variables are not initialized, they are the DSS segment because they are made default to zero by design. Text segment contains the executable instructions, which is a read-only memory. So the above four memory are the default memory that a program gets as a default by the kernel, but there is also one more memory called heap segment, which is not a default thing. And it is only there when the programmer demands it with the help of certain functions. To understand this memory layout further, I have a small program where I have defined some variables for you to see where it goes and gets stored. Here int x, which is a global variable because this is defined outside the main is initialized and that's why this is going to be stored in the data segment. Int A and float B are two local variables and they will be stored in stack. There is another global variable, static y, which is not initialized and this goes to the BSS segment. PTR is a local variable, which stores in the stack, but this is a special type of variable which is designed to store addresses. And this is going to get an address from a function called malloc. Malloc by design is a function which is defined to reserve memory from the heap. And on success, malloc returns you the address of the heap that is reserved. Every time a programmer allocates a heap, it is his responsibility to free this after its usage and that is done by the function called free. If this is not done, this becomes a memory leak and this can affect your system in long go. So heap is not a default allocation and this only comes in the runtime. It is managed by functions like malloc and when you want to free this, you can call free. Apart from that, there are colloc and realloc, but they are just internally calling malloc and free. So this is the ML commission of malloc and free. Heap is a memory which grows from lower memory address space to higher memory address space, which is just the opposite of the stack. So malloc is a library function provided by the G-Lipsy and this is a function which is collection of so many different underlying functions and the metadata where metadata consists of arena, heap and chunks. To understand the prototype of malloc, it is very simple. It takes only one argument as the size. The size says how much memory you want from the heap reservation and on success, it returns you the heap address that gets reserved. Adenas are the internal building blocks of the heap which actually administers the complete heap memory region. It looks after the free, it look after the any usage of the heap. Heap in turn is a contiguous block of memory which gets broken down into pieces whenever there is a request from the malloc. That means chunks are the fundamental unit of the malloc that malloc deals with internally. So every time a malloc is requested, there is a chunk gets created. In this first diagram, you will see there is a unused pool of memory which is the heap and this is also known as top chunk. Later, there is a first malloc request of 16 bytes which goes to the top chunk and asks for a smaller amount of memory which gets assigned to the user in the form of chunk A. Later, there is a second malloc request of again 16 bytes which again gets addressed by the top chunk and a new chunk comes into picture that is chunk B. So every time a malloc request is raised, top chunk gets divided into smaller fragments and that gets associated to the user. So top chunk is a free pool of heap memory. To after knowing the internals of the heap, let's directly jump to the demonstration with the help of this tool. I have a small program and we'll see how the heap formation takes place. I have a small executable for you. Also, the check set is a tool by which you can see the security stands of a binary. It tells you with which mitigations techniques this binary is built. These are the flags with which the library is built. Here you can see that this binary is built with full railroad, means there are some parts which are made read-only so that attacker cannot violate and rewrite that and produce some attack on the system. There is also, it is enabled with NX enabled, but this is not enabled with Kennedy and also the position independence address space is also not enabled on this binary. I'm running this binary with GDB. You will notice since we have started the GDB, we see that there is a terminal that is represented as Power and Debug. This is because Power and Debug is working as a plugin which runs with the GDB. I'm setting a breakpoint at main so that we will see the code line by line and we'll understand this better. Then we will just run the program. Welcome to the tool. You can see there are so many things going on on the screen. We'll see them individually. The first thing you will see there is the register related informations on the screen. Then you can see the disassembly part of this code, source code. Then there is a source itself. Then you will see stack part and at the end you see the back traces. I'm making this view little smaller so that this is easily understood. So I'm setting the context. I'm setting the context to view only the code. And now you can see that there is only code viewed.  If you want to see the stack, you can just call the stack. So I'm just limiting this view to the source code right now. Since we have set a break point at main, now our execution is halting at the start of the main. I want to see what is the default allocations that this program has got. And I am focusing on the memory part. So there is a command called VMMAP. This gives you the details of all the memory stances of this program. You will notice that there is a different color conventions shown here. Here a stack is represented in yellow, heap in blue, code that is the text section in red, and data in violet. You will notice there is no heap which should be represented with blue. And this is right. This is because the heap is not a default memory and this is only coming into picture when the programmer demands. So my first instruction in this main is calling a heap by function malloc. And we are requesting a nine bytes of heap. So I'm just running next or end. So you can see the line number five has been executed and the cursor is waiting at seven. So by now I think there should be some heap. Let's see. Yes, you can see the heap which is represented in blue is not there. You can also notice that this is starting at the address 0x602000, which is the start address of this heap. One more interesting data here is this column which talks about the total size of this heap and this is in hex. So this is 0x21000 which is approximately 135,000 bytes which is quite huge because we had only requested for nine bytes. Let's see what is there inside the heap and this can be done by this command. This command actually shows you all the details of the heap and here you can see again the different coloring conventions. Here you see that there is something of the color sign which is 32 bytes because eight bytes and four of such sets. So this is the first allocation that was requested and this is the first chunk. This is the chunk that was requested with the first malloc of size nine bytes. The first thing you will notice is that this request is more than nine bytes because eight bytes of four such sets means 32 bytes. I want to see what is the address that was written by the malloc and that should be stored in A. So we can do that by print A. Notice the address stored in this pointer is 602010 which is the second eight byte of this chunk. So you will notice that this is the place from where the user space data actually starts for the programmer usage and the first eight byte is something that is reserved and this is reserved for kernel and that is the meta data. It holds the meta data of the chunk. So you will notice that every chunk later in this program will have a different meta data individually for this chunks. So the user data that we have got now is of 24 bytes on the request of first nine bytes. So what I'll do is I'll just run the next command and we'll see what is the reservation of heap when we requested for a one byte of memory. In the viz you will see there is a second chunk now coming in the list. This is again of 32 bytes and again the user data starts from the second eight byte of this chunk and the first eight byte is again the meta data field. Let's see what happens when we request for a malloc of zero bytes. Technically it shouldn't be allocated a memory, right? Let's see what happens. Notice there is a third chunk in shown in green which is again of 32 bytes where eight bytes of meta data and 24 bytes of user data. So things boils down to like the default chunk that a malloc can return is of 32 bytes and it cannot be smaller than this. First thing, second thing you will notice that the user data starts from the next eight byte and the first eight byte is reserved for the chunks meta data. You can notice that every chunk has this meta data reserved and only the user data starts from the next eight byte. So since we have 24 bytes of user data given to every request and that is of size 24, let's see what happens when we demand a malloc of size 24 bytes. There is a fourth chunk and this is again a size of 24 bytes which was right because 24 bytes of demand should be suffice in this default chunk which is of 32 bytes when eight bytes of meta data and 24 bytes of user data. What happens when we ask for a memory more than 24 bytes? That is let's say 25 bytes. Notice the chunk is no bigger and this time you have allocated 48 bytes where eight bytes of meta data and then 40 bytes of user space data. Now I'll talk about what is the first eight bytes of this meta data. The first eight byte of every chunk represents the size field of this chunk. We have seen that the default chunk size that we have got previously in the four sequences were of 32 bytes. In hex 32 means 0x20. So the first chunk, second, third and fourth are all of equi-sized that is the default size and its size is 20, 0x20. Later, since the fifth chunk that we had requested was not able to fulfill the request, so it got a bigger chunk and this time the chunk size was increased to 48 bytes. That means the next after default the chunk size increases by 16 bytes and that's why you can see the extra 16 added to this chunk size where 48 in hex is represented as 0x30. But you will notice in all the meta data there is one bit extra added to the size field, why? This is because the chunk size meta data does not only hold the meta data for the size but its last nibble also represents the flags. These flags are some special flags and in this case there is a flag known as prev in use flag which is set for all the chunks. What is this prev in use flag doing? Actually the prev in use flag is used to show what is the status of the adjacent chunk. So if the adjacent chunk is reserved, this flag is set and if that is free, this is reset. So we can see that we have just reserved these five chunks and that's why its adjacent chunk is reserved and that's why this flag is set. But you will ask why the first chunks prev in use flag is set. So theoretically the first chunks size field will have the prev in use flag as set by default. That is by design. You will also ask why the first aid byte was not used and we have seen that this is the starting of the heap. So why designed? Colonel understands that heap has started indeed from the 0x20 to 000. But for the user, the first user access address starts 16 bytes later to the heap start. And that's why you would have noticed the first chunks user space data started from this which we also saw by print a. Now you would also feel what is the last byte doing here and what is this seen in every of the chunk reservations? Like you could see this in all the reservations it gets concatenated at the end. This was even in the first chunk. So like every chunk has a size field to represent the chunk size, the top chunk that we had discussed before top chunk is a free source of heap. Any request comes to top chunk and they demand a free memory from the top chunk and top chunk gets a slice and reserves that for the demand. Similarly, there is a top chunk size field. This is confusing, but you'll have to understand that every chunk like had a size field top chunk also has a size field. And every time a malloc request is raised. So since the first argument of this malloc is the size that gets compared to the top chunk size. If the top chunk size has a larger value that means there is free reserve pull and that's why it can address the forthcoming request of malloc. And so you can see that this field that is represented as the last eight byte is the top chunk size field. This was also seen in the VM map command that I showed you earlier that the heap reserved was 0x21000 and this was approximately of the size of 135,000 bytes. So there is a reserve pull, there is a request. Request gets satisfied by the top chunks and the top chunks size field get it decremented as the allocations is done. In many versions of GLFC, this top chunk size field is not subjected to an integrity check. So consider if there is a reservation of memory like malloc in this case, example is I have reserved a four bytes of memory from the malloc and I have written four bytes of data in this memory. So the first diagram can be seen that these reservations of memory is seen like this after we have reserved it and we have written some data. In the second diagram, you will see that there is the same four bytes of memory reserved but we have written 100 bytes of data. So internally it corrupts the memory which is not even reserved to this address space and this can even flood the top chunks size field because GLFC did not have the integrity check before the GLFC version <IP_ADDRESS>. Later versions this integrity check was added. So imagine if this metadata gets corrupted, the forthcoming request from the malloc and if there is no top chunk heap is empty but due to corruption, if this field is corrupted to a very large value, kernel will think that there is still a huge top chunk already available and it will keep on giving the next forthcoming malloc request and in this way, this can corrupt other user spaces, programs, memory and which is generally silent and when those programs run, this can encounter a problem and there could be segmentation faults. This problem was seen and this was known as house of force. Actually there are similarly different types of problems recorded earlier and this has been given some names like house of force, house of prime, mind, law and spirit. So these are on the basis of different metadata corruption and one we are discussing here is house of force which gets seen when there is a corruption in the top chunks size field. Now, since we have talked about reservations, it's time to talk about free. I have a second program. I'm setting the break point and setting the context only to the code so that we do not have so many things on the screen. You can see there is a similar reservation of heap. I'm just running these first three mallocs. So now we must have got some chunks. Yes, so we have got three chunks. Now I want to free this. There are several lists of free sources where every time you free the chunks that gets listed to some of the free list. I'm going to talk here about a list known as fastbin which can be seen by command fastbin. Here you will see a list of such pools and these pools are defined on the basis of chunk size. You notice the default chunk size was 0x20. Second time when the chunk size increased by 16 bytes it's became 0x30. And similarly, the chunk size increases by 16 and these are the list of forthcoming chunk sizes. In this we know that the three reservations that we have done is of A, B and C are all falling in the category of 0x20 chunk size. Let's free the first malloc that is chunk A. Let's see what has happened to the fastbin. You will notice the first list which was of size 0x20 has got one entry which was before empty. This is because the first chunk of this size has been freed and that gets attached to the head of this list. Let's see what happened to the list. You will notice the first chunk which was reserved before is now represented in the fastbin and that is also of the size 0x20 and this is at the index 0. Let's free the second chunk. Let's see the fastbin. You will notice the second entry is there added to the head. If you are curious to see what were there in A and B, I'll just print this for you. You will notice the A which was first released is here. But the A that was having was some different address which was 16 byte ahead. This is because the user only know about the user data and kernel knows its heap from metadata onwards. That's why there is a difference in the address which is 16 byte difference. But altogether they both are referring to the same chunk. Let's do the third free and now fastbin shows the third entry also in the 0x20 list. Let's see what, yeah. Sorry to interrupt but we are running short of time and we have a question that would like to take. Yes, sure. Are you doing that? Just I can take two minutes. Okay, sure. So the question is, yeah. I believe the metadata is a function of allocator that is being used, right? Question mark. So this is a good way to understand how do allocators allocate stuff. What's up? All right, yeah. Functions are the, there are actually some inline functions that are doing the reservations for Miloc and this is actually done by the kernel and that completely depends upon the size that Miloc is requested with. There makes some indexes according to the size and then they decide what should be the chunk that is to be allocated. I hope I answered but I think if the questions are there in the list, I'll definitely see that again and answer that if you have misunderstood. Sure, so for those of you who is listening on popping, please feel free to join Zulip Chat and we have a stream just for deli stage and Rohit will be present on the deli stage to take all of your questions. So Rohit please also head to the deli stage stream on Zulip. Thanks a lot, that's wonderful talk. Thank you. Sure, so just the two minutes can I take on this recommendation? Yeah. So you can see here that the last free is done and this is also listed in the fast wins head. Now what happens when there is a further allocation of the memory with the help of Milok? Obviously if the chunk size would be same, it will first go to the fast win. Let's say in this line number 14 is actually demanding for a memory of Milok of one, which is obviously going to get a default chunk of 32 bytes. Let's do that. So now you can see the fast win is having only the two entries because the third entry which was there in the head is now allocated to D. We can see that by D. Similarly, the consequence calls like next and again I'm doing the next. Now you will see that the fast win is empty. This is because the further request that comes first comes into the fast win. And if there is some chunk that was recently freed that gets associated to the new request. And in this way the re-breaking of the chunk that is stop chunk does not happen. And this actually saves with so many fragmentation of memory. So one thing more I just missed. You can see that now all the chunks that was actually represented in the fast win is now omitted and they all are the free chunks which got associated with the request. So I have also covered that on the slides and yep. So there are several free lists in the Melloc terminology but we have only talked about fast wins. Fast wins are smaller chunks request which when freed goes to fast wins. If the size of the freeing chunk are in the comparison of the top chunk size that goes directly to the top chunk. There are something also called unsorted wins which further divides into small wins and large wins. And there is another a T cache which is which we are not discussing in this talk. So this was all with this presentation. Thank you Roy. Thanks a lot. The attendees will be present in the Delhi stage three on July. So feel free to join and have a conversation. Thanks a lot. Thank you. Thank you everyone. Thank you for joining.


We were at work on the harmonic oscillator that is the single most important dynamical system in physics. A model for a huge number of physical applications. We had this Hamiltonian which is basically P squared plus X squared. The crucial thing is that it's obviously quadratic in P. But especially it's also quadratic in X. That's its peculiar characteristic of its potential energy. We went the plan for what we're trying to do is find the stationary states, in other words, we're trying to find the states here, which are eigenfunctions of the Hamiltonian because they will enable us to follow the dynamics of the system, their crucial tools. We went after them by defining this thing A, the annihilation operator, which is a dimensionless operator made up of X and P, and we found that it, we evaluated, well, we found two, this thing had two properties.  First, important property. Second important property that its commutator with its Hermitian adjoint is minus one when done this way round. So using those properties, we said, suppose we have a state, a stationary state of energy E, if we multiply this equation through, this defining equation of that state through by A dagger and do some swapping of the order of operators using the results above, we were able to show, this is where we finished, that H on the state that you get by using A dagger on E is equal to E plus a h bar omega plus h bar omega times that self same state. In other words, this state here, this state here is essentially a state, well it is a state, a stationary state of energy increased by h bar omega. And because we could repeat this, it follows that the energy is, if there is an energy E, then there must be energies E plus h bar omega E plus two h bar omega, and far as we can see E plus any amount, any number of h bar omegers, any energy number of h bar omegers. And what remains at this point is to find out what the number E is that we first thought of. And we do that by applying not a dagger to that equation, but A to that equation. So then we have, if we take, if we start with now E E is equal to h E and we multiply both sides of the equation by A, not a dagger this time, then we swap the order here just as we did before into H, HA, and then we have to add in the commutator A comma H, all operating on E still. We yesterday, this is absolutely repeated what we did yesterday, this is HA. Now we replace that H as advertised up there by A dagger A, et cetera. We observe, so this should become the, this is going to be replaced by A dagger A plus a half H bar omeger. We can forget about the half because we're inside a commutator and a half commutes with everything. We can take the H bar omeger outside the commutator. And then what we're looking at is plus A comma A dagger A H bar omeger close brackets. E, we use our usual rules for taking the commutator of product, which is to say it should be the commutator of this with this, with that standing idly by, and then in principle the commutator of this with this with this standing idly by, but the second commutator vanishes. And this commutator by the result up there is equal to plus one, okay, because the turned around there A dagger A is minus one. So this commutator A comma A dagger must be plus one. So this is saying this becomes HA plus A H bar omeger E. So we have an AE with no operator in front on this side of the equation, but we have the same thing on that side of the equation. So we take these together and onto this side of the equation and we then have that E minus this H bar omeger goes to the other side and becomes a minus H bar omeger is equal to HAE, which establishes on the face of it what we might have hoped, which is that the states you get that you have after you used A on this stationary state E is another stationary state with an energy lower than E by H bar omeger. So A dagger raises your energy, it increases the excitation of the harmonic oscillator and A evidently lowers the energy of the harmonic oscillator. Now you have to this point start to worry because by the previous rhetoric it would follow that if there's E then there is also E minus H bar omeger and so on down through E minus N H bar omeger and it looks as if you can find states of lower and lower energy without limit. And you should be worried about that because thinking about the Hamiltonian up there because classically it looks manifestly positive because p squared should be positive and x squared should be positive. You can't trust such things in quantum mechanics, but what we can do is we can work out, we can say look E is the expectation value of the Hamiltonian in the state E obviously because H on E is equal to EE comes outside and this on this is one. So that's a self-evident equation. Replace what's inside here, this becomes over two M of E p p E plus M squared omega squared E x x E and because these are observables and therefore Hermitian I can put a dagger there if I want to. Doesn't make any difference because P dagger is P and I can observe that this is now manifestly P E mod squared. This thing is the mod square of that of the catch you get by using P on E and this is M squared omega squared of x E mod squared. Just deliver two M which is boring and this is manifestly greater than or equal to zero. Even in quantum mechanics there can't be any argybargy this has to be greater than or equal to zero. So all the energies, all the allowed energies, the entire spectrum of the Hamiltonian has to be positive. But we've apparently established that by using A we can get states which by successively using A and A and A and A we can get states of lower and lower energy because we take H bar omega off every time we use E. Sorry we use A. So there's a problem and the problem is the assumption. So let's just look carefully at what we've established here. What we've established is this equation here. This equation is absolutely copper bottoms. It's beyond criticism. It's true. It was obtained by totally legitimate operations and it establishes that this thing is an eigenfunction with this lower energy provided this thing is non-zero. But if at any stage in this chain of applying A's this thing here would vanish. So if when you get to a certain energy, lowest energy and you apply A, A simply kills it, it produces a ket of no length at all then we won't have a state of even lower energy. And since it's clear that this chain of operations, it's not, it's logically impossible to go on creating states of lower and lower and lower energy. This chain of results of applying extra factors of A has to stop somewhere and the only way it can stop since this equation is true is by this thing becoming zero. Then because H on zero is equal to any number you like on zero, so if this is zero this equation does not establish that this is an eigenvalue of H, right? But that's the only circumstance in which this equation would not establish that this was an eigenvalue of H. So for the lowest energy, the ground state energy, it has to be that A kills it. So that's the ground state. We must have that A on E zero equals naught, right? So I'm using this symbol now to indicate the lowest energy. So what does this equation mean to give more precise meaning to it? So what we say is that this ket that you get here has no length squared. So let's just evaluate the mod length squared. So we're saying that A E zero mod squared which is equal to E A dagger A E is nothing. But this thing, we have it somewhere up there, it's just in range. H is equal to A dagger A plus a half H bar. So this thing is, this is the expectation value of H over H bar omega minus a half. So these ones have zeros on it because we're talking about the ground state energy, not any old energy now. We're just talking about that one special lowest energy, the ground state energy that this equation is valid for. And so what we're discovering is that E zero over H bar omega is equal to a half. In other words, the ground state energy E zero is a half H bar omega. And now we know what the general energy is because we know that we can make states of higher energy by applying A dagger to the ground state moving up by H bar omega each time. The nth energy must be n plus a half H bar omega. So we have found the allowed energies and the next item on the agenda is to find the corresponding, find the wave functions of the corresponding eigenstates, stationary states. Let's move over here. So let's ask about wave functions of the stationary states. Now we've found the allowed energies. Actually, before I do that, it's probably good to generalise this calculation here. So what we've established is, so let's just talk about normalisation as a sort of preliminary. I think it's better to do it just now, normalisation. What we've established is that A dagger, and I'm going to introduce a new notation. We're going to say what previously I'd called E is going to go to n. So this is the state with E equal n plus a half H bar omega. We could write E n in here, but everybody writes just n. It just saves energy. It works well. Now we've discovered what the energies are and that they're labelled by an integer n 01234. So this is n equals 012 and so on. It makes sense to have a nice compact notation and to call our stationary states the state 0, the ground state the state 1, the first excited state the state 2, the second excited state. What we've established is that A on n is some constant, I'll call it k, times n plus 1. Because we've discovered that when we used A on the state E, we got a state which was an eigen ket of H with eigen value E plus H bar omega, which would be in the new notation the state n plus 1. If this E was n plus a half H bar omega, this will be n plus 3 halves H bar omega. And the issue arises, so what value does this thing have? So just to be clear, we've had relationships like this. We had a corresponding one up there. Yep, there we go. Yesterday we derived this equation and that equation establishes that this thing is an eigen ket of H. It doesn't establish that it's a properly normalized eigen ket of H. I want it to be properly normalized. And so I'm asking about what's the normalization constant I have to use after I have applied an A dagger. It's easily found because we just take the mod square of this side of the equation and the mod square of that side of the equation. So taking the mod square, so taking mod square of both sides, we get n A A dagger n is equal to k mod squared times 1 because that's by definition going to be correctly normalized. We can take k to be a real number, we can take k to be a complex number if we determine to but why don't we just agree to take it to be a real number and this just becomes k squared. We're just trying to get the thing normalized. We don't care about the phase. Let's ask ourselves what this is. If I swap this over, I want to swap this over because then I can relate it to the Hamiltonian. Then I have to add on A, A dagger. Oops, commutator. So that's that rewritten. This is the Hamiltonian minus, it's the Hamiltonian over H bar omega. Where is it? Yeah, it's up there. It's the Hamiltonian minus, it's the Hamiltonian over H bar omega minus a half. So this is H over H bar omega minus a half. That's this thing. And what's this? This is plus one I think because the commutator the other way around was minus one. So this is plus one. So that's that. H on n is equal to n plus a half H bar omega by definition. So this on this produces n plus a half H bar omega divided by the H bar omega and we have n plus a half. Take away a half, we have n, add one, we have n plus one. So this is in fact equal to n plus one. So what follows this? So comparing this with this, we find that k squared is equal to n plus one. Going back to up there, we have that n plus one is equal to one over the square root. Sorry, sorry. That's right, square root of n plus one of a dagger n. This is a very important equation. If we would go through this rigmarole, the same logic using a on n being some other constant times n minus one, we would find that n minus one is equal to one over the square root of n of a operating on n. We know that a operating on n is going to produce n minus one. It depletes the energy by H bar omega and therefore reduces n by one. The normalisation constant turns out to be one over the square root of n. I would recommend you check that after the lecture. It's a precise repeat of this logic here. It's worth remembering these rules because this is such an important relationship. They're very easy rules to remember. The normalisation constant is one over the square root of the biggest number that appears in the equation. So in this equation, the biggest number appearing is n plus one, that's what you use. These are two very important equations which physicists remember. What we have to do now, we're trying to find the wave functions fundamentally. This is just the tedious details of the normalisation. Although those equations are of bigger use than just with wave functions. Let's find the ground state wave function. What is it? We'll call it u0 of x and it is of course x0. It's the function that's defined by this, the amplitude to be at x, if you were in the ground state. Also called this. These are just two notations for the same thing. This satisfies a natty equation because what we know is that a, operating on n minus one, is equal to nought. The ground state is defined to be, it comes into the world as the state, the one and only state, that the operator, the destruction operator a kills stone dead. So if we multiply this equation on the left by x, we still have a valid equation. And this, and let's write in what a is. So a is m omega x plus ip. In principle, it's over the square root of 2 m h bar omega, but because I'm about to put this stuff equal to 2 m h bar omega, I'm about to put this stuff equal to nought. I can neglect the factor on the bottom. I can multiply through both sides of the equation, the factor on the bottom, and get rid of the garbage, right? Clean things up. Why don't we write this? I mean, we're more or less committed to writing this in the position represent. Well, I mean, we have it there, right? This tells me that m omega x, m omega x, x nought, because this is the position operator. This is an observable. I can imagine that it operates backwards on this. This is an eigenfunction of that operator. So those are both operators. That's not an operator. This operates on this, if I want, backwards. This is its eigenfunction. We get an x, the number, times this. This then meets that and produces this, which is our wave function. And then we also have plus i x p nought, and the momentum operator was defined by saying that this thing is minus i d by dx of x. This was the definition for any wave function of how p operated. With an h bar. Thank you. Thank you, absolutely. So I need to write this stuff down. I need to write some more stuff down. This is equal to zero, provided I put in the m omega x, x. If I rewrite that in wave function notation, it becomes m omega x u nought of x is equal to, and let's clean this stuff up. Sorry, it's not equal to plus h bar d by dx of u nought of x equals nought. So what is this? This is a first order linear differential equation, and it's in fact an ordinary differential equation because there are no other variables than x present. I've written this as a partial derivative. Consistency with what we do in more in three dimensional cases, I suppose. But it is a first order linear differential equation. There is no sort of differential equation that's more user friendly that we encounter. We solve such equations by using an integrating factor. Just to get this into standard form, I would actually write this as d u nought by dx plus m omega over h bar x u nought. This is the standard form for a first order linear equation, which you should remember from Professor Ross's course or whatever in the first year. It has an integrating factor, which is e to the integral of the coefficient of the linear of the constant term, the not derived term, this term, e to the integral m omega over h bar x dx, which is clearly e to the m omega x squared over 2 h bar. That's its integrating factor, and the equation is then, if you multiply by the integrating factor, the equation says that d by dx of the integrating factor times u nought is equal to the right side, which happens to be zero ergo. This quantity here is a constant ergo u nought is equal to e to the minus m omega x squared over 2 h bar, which I want to write as e to the minus x squared over 4 l squared. Why do I want to do that? I want to do that because the probability associated with x, the probability of finding your particle at x, which is equal to u nought mod squared, will then be e to the minus x squared over 2 l squared. This is a normal distribution with dispersion l. The reason I want to get this into this form is in order, because I can identify that as the Gaussian width of the distribution, the width of the Gaussian distribution. Also, once I say that this is the probability distribution from my knowledge of statistics and stuff, I know what the normalising constant has to be. I know that it's 2 pi l squared, root 2 pi l squared, because that's the factor you need to normalise a Gaussian distribution. Oops, I'm missing a minus sign, crucial. So what does l have to be in order that this form is the same as that form? I think a simple algebra to show that l has to be h bar over 2 m omega, but l squared has to be that. Let's check that this has the right dimensions. One should always be checking one's dimensions in physics. This has the dimensions of momentum times distance, so this has dimensions of m, x, p. This is m, x, v. This is what I should have said, momentum times m, v, x. What am I talking about? Yes, m, v, x, right. m, v, x is the dimensional structure here over the dimensions here. Indeed, this thing has dimensions of length squared, so l is indeed length, so it's okay. What have we learnt? We've learnt that the ground state of a harmonic oscillator has a wave function, which is a Gaussian, with a characteristic width given by this. Crucially, we've already studied distributions of particles which are Gaussian, have wave functions which square up to Gaussians, and we now know what the probability distribution is for momentum. From what we did before, we will have that the probability of momentum will also be a Gaussian. It will be e to the minus p squared over 2, should we call it sigma p squared, over some square root 2 pi sigma p squared. Remember, we had the uncertainty principle, which said that the dispersion in x times the dispersion in momentum is equal to h bar over 2 for the Gaussians. This was a result we established when talking about the free particle. That tells me that sigma p is equal to h bar over 2l. There's some characteristic momentum that the particle has. In the ground state, a particle is not stationary. It is moving with a characteristic amount of energy. It's also not at the bottom of the potential well. It has a characteristic amount of average potential energy. We've come to the conclusion. We have an example here of one of the most important, perhaps the most important prediction of quantum mechanics, which is the existence of zero point energy. The basic issue is that if we're trying to minimise the energy of the particle, which clearly the ground state by definition does minimise the energy of the particle, is the state with the lowest energy by definition. If we're trying to minimise this energy, we want to get the potential energy to be as small as possible. That clearly means moving towards the origin and getting as close to the origin as you can. But because of the uncertainty relationship, because the more narrowly confined you are in real space, the more uncertain your momentum has to be. If you restrict yourself too much in position to be too much at the bottom of the potential well, you will have a large uncertainty in your momentum and you'll have kinetic energy. In practice in the ground state, there's a compromise between being reasonably close to the origin and having a reasonably small kinetic energy. Because of the uncertainty relation, quantum mechanical systems in their lowest states have a finite extent spatially, even though really it's a point particle, there's a finite extent in which you'll find the particle, and a finite kinetic energy. I hope you see that this is a specific example of a totally general phenomenon. We have to expect to occur always when we are considering particles trapped in some kind of potential wells. This is enormously important because it's exactly this physics which determines the size of atoms. Atoms here are typically pretty close to there, near enough in their ground states, and the size of these atoms is determined by the electron. If the atom gets any smaller, and indeed you take a piece of steel or something and you stuff it into a press and squeeze the thing down, it will get smaller, but it'll resist violently, you'll have to do work, you'll have to increase its energy to make it smaller, and what happens is that in order to make it smaller in real space you have to give it more kinetic energy and the uncertainty principle, and that's the work that you do squashing it down, and you can see that idea worked out quantitatively in one of the later chapters of the book. The size of atoms is determined by this zero-point energy business and the uncertainty principle, and interestingly the mass of protons and neutrons is not entirely but is overwhelmingly accounted for by the kinetic energy of the quarks and gluons inside there, which are moving around relativistically, they're in a very deep potential well, and because they're very narrowly confined into 10 to the minus 15 metres, in order to be confined, even though they're fairly massive particles into this very small space, they have to have a lot of kinetic energy, and the mass associated with that kinetic energy accounts for most of the mass of us, that's what it mostly is. So this zero-point energy phenomenon is extremely general and enormously important, and here we have the simplest, the classical example. In fact, you see if we say H is equal to 1 over 2M of P squared plus M squared, omega squared, x squared, and we put in the uncertainty relation, we say that x squared, if we say that P squared is equal to H bar squared over 2x, let's get this right, sorry, over 4, because I've squared it, over 4x squared. So for the ground state, x squared is essentially the uncertainty in x, so it's associated with the uncertainty of momentum in the same way. If you stuff that into this, you put this relationship in, you find that H is 1 over 2M is going to be whatever it is, H bar squared over 4x squared plus M squared, omega squared, x squared. This now is a function, maybe I shouldn't call it x squared, maybe we should call it L actually, perhaps that would be more helpful. So I'm saying that x squared is on the order of L squared and P squared is on the order of this. So here we have a function of L and a minimum, if you ask yourself, what's the, what value of L does this function have a minimum? The answer is it's that value that we gave up there from quantum mechanics. So it's really true that L is being chosen to minimise the energy given the constraints imposed by the uncertainty principle. Okay, so that we found the ground state wave function, it would now be useful, I guess, to show how we should calculate the, sorry, my notes are a bit out of order here. Yep. So what we want to do, let's get the first excited state as an example. So first excited state, excited state wave function. So u1 of x, which is by definition x1. What do we know? We know that 1 is equal to 1 over the square root of 1 times a dagger working on the ground state. So if I bra-through by x, that tells me that u1 of x, which is equal to x1, is equal to 1 over the, sorry, the 1 over the square root of 1 doesn't need to be written anymore, but this is 1 over the square root of n plus 1, n here is 0, of a dagger, which is n omega x minus ip, yes, over the square root of 2 m h bar omega. Now what we want to do is, it's helpful actually to find out what is to rewrite this in terms of l, this characteristic length there. So let's just say what a dagger is in terms of l. 2 m h bar omega, well where's, so if you take that equation up there, that defines l, and you multiply both sides by the square root of 2 m omega, and then you multiply through by a square root of h, you find, so I need to write this down, so l is equal to the square root of h bar over 2 m omega, multiplying through by this, I find that the square root of 2 m omega is equal to the square root of h over l, if I multiply through by h bar, that's a bar by the way, sorry, if I multiply through by h bar, I find that the square root of 2 m h bar omega is in fact equal to h over l. So this factor here is equal to h over l, so I can say that a dagger is equal to m omega x on the bottom is h over l, so an l here and an h bar there, minus I need a, I have an h bar on the bottom, and an l on the top times p. Let's keep working, this stuff is looking remarkably like l all over again, if I would multiply this by 2 on the top and 2 on the bottom, then this would become 1 over l squared, so this is equal to, the l squared would cancel this, and I would have that this was x over 2l minus, now let's put this into the position representation, in the position representation this is minus i h bar d by dx, so the, yes, so the i's get together and make a minus sign, and the minuses cancel each other, so we have an overall minus sign, and this becomes l d by dx. A dagger was billed as being dimensionless, is it dimensionless, yes, because they have an x over l and an l over x. So this is a handy formula for future reference. So let's find out what, sorry I shouldn't have written that complicated expression up there, it wasn't helpful, that u1 of x is equal to this baby, this animal working on, what does it work on? It works on u0 of x, but what is u0 of x? It's business end is e to the minus x squared over 4l squared, and under here I have to have a 2pi l squared to the quarters power. This factor comes in, I said what the normalisation constant was, so just to see where that comes from, I needed p of x to have this, so we obtained u as, I should have said a constant k times this, right, there was an arbitrary constant in this, arbitrary constant of integration, which is in fact going to be the normalising constant, so I know now that the wave function is, behaves like this, which gives me a probability that looks like this, the correct normalisation of the probability is this, so what I need to do now is to say that in order to get things to work out well, I should replace that k with a quarterth power of what's inside here, so when you square it up, you find the right normalising constant of the probability. So we've got the ground state now at last properly normalised, it has that quarter power, and this, now this is going to come out because we've paid proper attention to normalisation, this will come out correctly normalised, and it's, what happens is very simple, when we do this differentiation, we're going to bring down a minus x over 2l squared, and this l will cancel that, and we'll be, and cancel this, and we'll have an x over 2l coming from here, we've got an x over 2l coming from there, so the whole thing at the end of the day, is 1 over this 2pi l squared, one quarterth power, x over l e to the minus x squared over 4l squared, that's the first excited state wave function. To find the second excited state wave function, we'd use this self-same operator, I'm not going to do this, but let's just see what it would look like, u2 would be x over 2l minus l d by dx, 1 over 2 factorial, sorry, 1 over the square root of 2, that's the 1 over the square root of n plus 1, operating on u1, which is x over l e to the minus x squared over 4l squared over 2pi l squared to one quarterth power, and you can see that what's going to happen is we're going to get an x squared term times e to the garbage, we're going to get from this differentiation, we're going to get an x term from this, from the diff, we'll get various things, we're basically going to get an x squared term, and when differentiating away this, we'll get a term in x to the nothing, and when we bring this down, we'll get another x squared term as well, and we multiply this in x squared, so we're going to get terms in x squared and x to the nothing times e to the minus thingy. So this is going to be a polynomial of degree 2. It goes by the name of a Hermite polynomial. It doesn't matter. And every time we use this operator, we're going to get a more and more elaborate polynomial. Can you see that that's what's going to be the consequence? Our wave functions are all going to be this Gaussian that came with the ground state, and then they're going to be times polynomials, which are going to be of order n. So the general state, un of x, is going to be a Hermite polynomial, hn of x, e to the minus x squared over 4l squared. I'm not paying proper attention to the normalisation at the moment. And it's straightforward to find out what these are. You only have to differentiate. You don't have to do any clever, any things. Just differentiate, and they will all drop into your lap. Something important to notice is that the ground state wave function is an even function of x. E to the minus x squared. The first excited state wave function is an odd function of x because this operator is odd. It has one power of x in both places. It changes sign if you turn x to minus x. This one is going to be an even function of x because we're going to apply another odd operator to a thing that's odd, and we'll end up with an even result. Ground state is an even function of x. First excited is an odd function, and the second excited. In fact, un of x is even if n is even, an odd otherwise. We'll meet this phenomenon in other cases. It's very often the case that the ground state is even, and the first excited is odd, and the next one is even, and the next one is odd, and so on like that for similar reasons. Quantum mechanics has its own jargon for this. It says that this is an even parity state. Parity just means is it even, or is it odd, the wave function, and this is an even parity state. We'll have more to say about parity in a general context later on when we're covering the material in Chapter 4. Sorry. This one is odd, excuse me. I was not sure which line I was on. This one is even. The ground state is even. The first excited state is odd, and this has a parity. We say this has a parity minus 1 to the n so that, you know, that jargon is used sometimes. I wouldn't worry about it. It turns out to be useful to know. We'll find it's useful to know whether your wave function is even or odd. It enables you to short-circuit various computations. Okay. We can do, yeah, all right. We're out of board there. Let's, yeah, let's have a go at this. Let's work out the expectation value in the nth excited state of x squared. So we want, it will be nice now to build some connection to classical physics. Can we connect these results to classical physics? Classical physics, as I've said several times, is all about expectation values. From quantum mechanics to classical physics occurs through expectation values. So let's work out this expectation value, which is going to enable us, for example, to work out what the mean potential energy is because the potential energy is proportional to x squared in the nth excited state. Now, how do we work this out? What we do is we observe that A, now we had a dagger. We went to some trouble. Here we go, here we go, here we go. Here is, here is A dagger. A is going to be L, sorry, is going to be x over 2L plus i L upon h bar p. And A dagger we've got there, we've got there, is going to be x over 2L minus i Lp over h bar. So if you add these two equations, you discover that A times L, sorry, L A plus A dagger is equal to x. So a handy, this is a very handy relationship, expresses the x operator as a sum of annihilation and creation operators times L. I've just added these two equations, the momentum of cancel on each other. These have added up to give us an x over L. Here we've had A plus A dagger. I've multiplied through by L. So when I want to work out this expectation value, I can replace each of those x's with this thing here. L squared comes out because it's only a number A plus A dagger squared N. Let's multiply this out.  Now, what's this? A squared applied to that is proportional to N plus 2, sorry, N minus 2, because each of these A's takes away a unit of excitation. So A squared times that is proportional to N minus 2, but N minus 2 is orthogonal to that, so that makes no contribution to this expectation value. Similarly, a dagger squared on this produces some multiple of N plus 2, which is orthogonal to that, so that doesn't contribute. So these two terms don't contribute to the expectation value. These terms, Jollywell do, contribute to the expectation value.  Let me write this out. So this is going to be L squared of N A. What's A dagger on this is going to produce root N plus 1 of N plus 1. This A dagger working on that will produce root N plus 1 times N plus 1, and then, and now I've left the other A to be done, and here we're going to say that this is equal to N A dagger times the result of A working on that, which is root N times N minus 1. It's the square root of the largest integer occurring in the equation, and then this A is going to produce a root N plus 1 times N, which will couple with this and produce 1, so this is going to be L squared. This is going to lower N plus 1 down to N, which will produce a 1 when it meets this, and we'll have another of these square roots, so we're going to have N plus 1, and when we use this on this, this N minus 1 is going to be raised back to N, which will produce a 1 when it meets this, but we'll get another square root of N in the process, so we'll have plus N. In other words, it's equal to 2N plus 1L squared. My time is up. We've discovered something interesting, which is the expectation value of X squared is 2N plus 1L squared. Did we already know about it? No, we didn't, in a certain sense. Yes, we did. For the ground state, N equals 0, we knew that the probability distribution was a Gaussian, and we knew that the dispersion of that Gaussian, the expectation value of X squared, was L squared. We've now discovered how the dispersion increases when we add excitations and the probability distribution gets broader, but tomorrow I want to connect this to classical physics.


Sor Juana Ines de la Cruz was a 17th century nun from Mexico, known then as New Spain, and at a time when most women in New Spain could not even write their name, Sor Juana wrote poetry, mathematical treatises, social manifestos, musical compositions, passionate love poems, and stage plays. She was a prolific writer who earned the title of the 10th Muse. And in her writing, Sor Juana expressed her deep concerns as an intellectual Creole woman, and her writings are key to understand the history of New Spain. Now although Sor Juana's literary identity was forged in colonial Mexico, her works were published in Spain making her a prominent writer of the Spanish Golden Age. Now one of the major themes in Sor Juana's work is the right of women to have access to knowledge. And she defended her right to be an intellectual and asserted that women should not only be educated but also become educators. And in 17th century New Spain, knowledge was a dangerous commodity that was carefully controlled by the church and rigorously policed by the inquisition. And any interpretation of scripture that questioned the prevailing orthodoxy was dangerous. Access to knowledge of the divine order, whether scientific or theological, was strictly mediated through a patriarchal hierarchy of men. And this is why it's so extraordinary that the first great poet to emerge from New Spain was a woman and a nun. It wasn't easy for Sor Juana to defend her right to be an intellectual in a masculine culture where the writers, editors and readers were all men. In 1690 she criticized the theological ideas of a very famous and well connected Portuguese Jesuit, Antonio Vieira. And after that in 1693 she sold all her books as well as her musical and scientific instruments and renewed her religious oath by signing it in blood. Now doesn't it seem strange that a prolific writer would suddenly renounce her intellectual labours and sign a statement of self-humiliation with the words yo la peor del mundo meaning I the worst of them all. So what happened in New Spain between 1690 and 1693 that led to Sor Juana's abjuration? Now before we get to the life story of Sor Juana, let's briefly review the institutions and society of 17th century New Spain. This historical context is crucial to understand the life and work of Sor Juana. Now after a decade of conquest and exploration Spain created the wise royalty of New Spain in 1535. It was the first of four wise royalties that Spain created to govern the colonies in the Americas. The Aztec capital Tennischtitlan was raised and then Mexico City became the capital of the wise royalty of New Spain which included modern-day Mexico, much of Central America, parts of the Caribbean, Southwestern United States, Florida and the Philippines. During the first 100 years of Spanish rule the indigenous population of New Spain declined from an estimated 25 million to 1 million as a result of disease, war and systematic destruction of indigenous cultures. Now soon after the military and political conquest, Catholic missionaries began arriving in the Americas to begin the spiritual conquest of indigenous people. The missionaries founded monasteries and open schools because educating the indigenous population was a crucial justification of the colonizing enterprise. The church also evolved significantly over 300 years of colonial rule and Spanish colonization in the Americas took place through a partnership between church and state that aimed to further the power of both institutions. The church controlled all aspects of life from birth through marriage until death and the religious climate of the colonial state was much more orthodox than in Spain. The church was extremely wealthy and powerful. Now on the most basic level the clergy fell into two large camps, the secular and the regular clergy. The secular clergy included the common parish priests who served under the supervision of the local bishop or archbishop as well as high-ranking clerics who served in the cathedrals. The secular clergy and the bishops were under the administrative supervision of the king of Spain thanks to a series of papal grants and privileges and this control over the church in the new world was known as the Royal patronage. The Spanish kings exercised the royal patronage over the church by appointing major officials to administer the church including bishops, archbishops and members of cathedral chapters. That's why the viceroy and the archbishop who were appointed by the Spanish monarch held great power in the colonial state. Now throughout the colonial period education was almost exclusively in the hands of the Catholic church. The regular clergy had its own internal governance and hierarchy ultimately under the supervision of the pope. In New Spain the Franciscans landed first in 1523 followed by the Dominicans and the Augustinians and these mendicant orders focused on educating the indigenous population and their major goal was to force the indigenous population to convert to Christianity. All instruction was in Spanish and mostly of catechism. The spread of Christianity stimulated a massive religious building campaign in the Americas and one important type of religious structure was the convent. Convents were large complexes that typically included living quarters for the missionaries, a large open-air atrium where mass conversions took place and a single nave church. The missionaries used the large outdoor atriums as classrooms. They trained elite indigenous boys to be the helpers to the priests. Now the Jesuits arrived in New Spain in 1572 and they provided education for the colonial elite. Their teaching was designed to instill loyalty to the Spanish crown and the curriculum remained strictly within an officially approved theological framework. The Jesuits established some of the most impressive libraries in their urban colleges as well as their missions. Jesuit libraries also functioned as centers of cultural power and distinguished themselves in many ways by the norms and rules they set up for the ordering of their books. They promoted homogeneity of knowledge in all Jesuit centers of learning and the Jesuits dominated education until the Spanish king expelled them in 1767. Jesuits occupy an important place in Sorfana's own life and education. They believed in the interrelationship of piety and intellectual practice and Sorfana herself shared this conviction. For several years she confessed with one of the intellectual luminaries of New Spain, Núñez de Miranda, a Jesuit confessor. Later on after their relationship faltered Sorfana dismissed him as her confessor. But Sorfana's intellectual activities brought her into constant contact and eventually into conflict with the Jesuits. In 1551 the king of Spain Charles V established the royal and pontifical university of Mexico. Theology and law dominated the curriculum but after 1579 the university offered courses in medicine and indigenous languages. The royal and pontifical university was the only institution that could confer academic degrees that were equivalent to European degrees. And soon rivalry developed between the university and some of the Jesuit colleges as they jostled to position themselves as premier institutions of higher learning in Mexico. As the Catholic Church established itself in Mexico the desire to promote Latin soon followed and a Latinate class of clerics ensured the doctrinal purity of Christian instruction and it was the clearest manifestation of the flourishing of western cultural ideals in the Americas. Eventually in the mid-18th century students from a few Jesuit colleges succeeded in earning college credit for the courses they took there to graduate with a degree from the royal and pontifical university. Now women could not attend the university in Colonial Mexico. Most of the Mexican population was illiterate and unschooled. And the point that I want to emphasize is that higher education was provided for a small minority only. The education of girls was not a priority in New Spain. Private tutors educated girls from wealthy families but only enough so they could oversee a household. Now a few girls in Mexico City entered convent schools around age 8 to remain cloistered for the rest of their lives.  She lived in a society where men occupied positions of authority and power. Men also defined acceptable female conduct and controlled the justice system which punished those who overstepped the established boundaries of acceptable behavior. And the parameters of acceptable female behavior and activities were closely tied to a woman's social class and racial category. It is really important to understand colonial society to appreciate So Juana's achievements. She manipulated social values of 17th century New Spain by becoming a nun and rejected marriage, the only other honorable choice for women. Entering the convent allowed her not only to remain respectable but also to attain a certain sense of freedom to pursue her educational goals. Juana Ramirez was born in San Miguel, Nipantla, a small town southeast of Mexico City. She was the illegitimate daughter of a Spanish father, Pedro Manuel de Asuaje, probably of Basque origin and a Creole mother, Isabel Ramirez de Santiana. Now although it was not unusual in New Spain for a Creole woman to have children outside of wedlock, it certainly required a firm independence of character. And what we know is that her father was absent from So Juana's life. And there is no doubt that her mother Donia Isabel contributed greatly to Juana's independent attitude. Now Juana's mother had other daughters by Juana's father and three more children by another peninsular. Now because of Juana's illegitimacy, the date of her birth is contested. Many biographies list 1648 as the year of her birth, but a few studies suggest that she might have been born in 1651. The register in which the names of children born of peninsular parents were recorded in Ameca Meca, the city closest to where So Juana was born, but that is missing. And some scholars point to a baptismal certificate from 1648 in a parochial archive of Chimalwakan of Ija de la Iglesia meaning someone of illegitimate birth. Now Juana's maternal grandfather owned property in Ameca Meca and Juana spent her early years living with her mother on his estate. She learned to read when she was three years old and composed her first poem when she was eight. After her mother remarried, Juana was sent to live in Mexico City, with her maternal aunt Donia Maria Ramirez and her husband Juan de Mata. And when she learned that there was a university in Mexico City, Juana asked if she could be dressed in men's clothing to be enrolled in the university. Now Juana wanted to join the University of Mexico, but women were not permitted to pursue higher education. So she continued to study privately and by the time she was a teenager, she had studied Greek logic and Latin grammar, which enabled her to read philosophical and theological works. In 1664, when she was 16 years old, her aunt presented her to the court of the viceroy, where she became a lady-in-waiting for the viceroy. Her aunt and uncle had hoped that the court would be a perfect place to find a husband for Juana. And when Juana was 17 years old, the viceroy invited a panel of scholars to test her intelligence. Juana outwitted these scholars, and the range of skills and knowledge she demonstrated before the panel became publicly known throughout Mexico. As a young, intelligent and beautiful teenager, Juana had to constantly defend herself from the amorous advances of the married men of the court. Eventually, she rejected the idea of marriage and became Inam. In her own words, joining the convent was the most decent thing she could do for her intellectual growth. Initially, Juana entered the mendicant order of the discalced Carmelites, but she left the Carmelite order after three months. And some scholars have speculated that the snobbish attitudes of the peninsular women who dominated that particular convent might have led her to leave after only three months. 1667, at the age of 20, Juana joined the convent of San Jerome in Mexico City and lived there until her death. There, she took the name Sor Juana, which means sister Juana. The Order of Saint Jerome is a Catholic cloistered religious order and a common name for several Augustinian congregations modeled after the life of Saint Jerome. Sor Juana was a faithful Catholic, but she was not a mystic. And the life story of Sor Juana is the tale of a female intellectual who entered the convent to pursue higher education without the obligations of a conventional marriage. Now, in the convent, she lived very comfortably. Her cell was an apartment maintained by servants and slaves and she had a huge personal library containing various scientific, mathematical and musical instruments, works of art and about 4,000 books. Sor Juana's great book collection was unique for her nun, but she never enjoyed the same institutional protection as the Jesuits and confiscation of her books always loomed as a possibility. The possession of dangerous books often led to accusations of heresy. The inquisition held great power to punish publishers, booksellers and readers. Although Sor Juana never possessed any banned books in her collection, eventually her singular views seemed to pose a threat and she became the target of misogynistic attacks. Sor Juana's library was in her room, a private space, but the knowledge that she acquired there allowed her to participate in the public arena through her writing and her small room in the convent became a meeting place for Mexican intellectuals. In 1680, the Count of Paredes arrived in Mexico City as New Spain's viceroy from 1680 to 86. He was welcomed by two triumphal archers, one was erected by the municipal council and the other by the cathedral chapter. The cathedral commissioned Sor Juana to design one of the archers and write a poem in his honour. Very quickly, a friendship developed between Juana and the Countess of Paredes. And the viceroy and the vicerain were frequent visitors at the convent and supported her literary ambitions and ensured the publications of the first two volumes of Sor Juana's works in Spain and it was for them that she wrote some of her best poems. The first printing press in the Americas was established in Mexico in 1539 early on in the colonization phase. It was controlled by the Spanish monarch and the church and it was designed to produce texts for the conversion of indigenous people. Now most of the paper was imported from Europe. Given the limitations of the Mexican press the best option for new Spanish authors was to publish in Spain as did Sor Juana who published three volumes in Spain. She used her fate to support her intellectual talents. Sor Juana's works were printed and widely circulated in Spain which made her a writer of golden age Spain's literary culture just as much as she was part of Colonial Mexico's cultural production. The first volume of her work containing a large number of secular poems was published in Spain in 1689. Sor Juana wrote 12 Viancicos or Carol Sequences for festive performances in cathedrals in Mexico City, Puebla and Oaxaca. This literary genre was considered a humble one so she took advantage of the freedom and fluidity offered by its marginality and she used this popular genre to express the sentiments of marginalized social groups such as slaves, indigenous people and women. Traditionally Viancicos held a connection to Christmas but in the mid 17th century that changed and cathedrals in Mexico celebrated many festivals with the singing of Viancicos. Gongorismo is a literary style named after famous golden age Spanish poet Luis de Gongora and Sor Juana very much admired his work and in some ways her Primero sueño is a homage to Gongora's Soledad Primera. Sor Juana's Primero sueño or first dream occupies a unique place among her works. It was a baroque masterpiece and it is her most important single work. Together with the respuesta it constitutes the basis of an understanding of Sor Juana as a person and as a poet. Primero sueño is a long poem and in it we find the whole range of Sor Juana's learning mythology, theology, ancient modern science, physiology and philosophy. The poem begins with a description of the invasion of night. Then sleep enters the poets inner world. Only the soul is still awake ready in it's dream voyage to be the protagonist of Sor Juana's philosophical adventure and Sor Juana dramatizes the human soul as a thinking being. The soul rises above the stars even above itself in search of a complete living of the universe. Perhaps the journey represents the author's own crisis as a religious woman in the pursuit of knowledge. In the 1680s she wrote You Foolish Men, her most famous redondilla which is a popular Spanish verse style. Her poem expresses her disappointment in the hypocrisy of the relations between men and women in New Spain. She wrote With foolish arrogance you hope to find a Thais for courtship but want a Lucretia after you've possessed her.  So essentially Sor Juana highlighted the double standard of sexual relationships in which women are criticized for being chased and also criticized for being sexually active. Sor Juana's criticism was incredibly radical for its time especially from Annan who was supposed to concern herself only with spiritual matters. Consequently she became the target of misogynistic attacks from the church for her candidness and commitment to women's advocacy. In 1688 her beloved patrons, the Count and Countess of Paredes returned to Spain and with their departure Juana lost her most powerful protectors in New Spain. The Bishop of Puebla Don Manuel Fernández de Santa Cruz who was a friend of Sor Juana requested her to write a review of a sermon delivered by a very famous Portuguese Jesuit named Antonio de Vieira and the sermon about Christ's proof of love for man had been delivered in the Royal Chapel in Lisbon in which Vieira articulated the meaning of one of Jesus's finesses a divine act of love for humanity particularly about Jesus washing the feet of his disciples and Vieira dismissed the theological ideas of Saint Augustine, Thomas Aquinas and John Chrysostom and reached his own conclusion that Christ had washed his disciples' feet for love's own sake. Christ's greatest favour was to make his love for us an obligation to love one another and not to love him in return. At the request of the Bishop of Puebla Sor Juana wrote a critique of that sermon and this was Sor Juana's only theological composition in which she criticised Antonio Vieira not just for the wrongness of his opinions but also for his arrogant dismissal of the ideas of the Church Fathers Saint Augustine, Thomas Aquinas and John Chrysostom and she argued in a very sophisticated way that if God does not command us to love him in return it is to free us of the sin of ingratitude. In other words, God would never make humans feel obligated to him since we can never repay him and this critique set off a chain of events that ended Sor Juana's literary career along with the dismantling of her library the symbol of her greatest disobedience. In 1690, the Bishop of Puebla published this critique now known as Carta Athenagorica or letter worthy of Athena along with his own letter but signed it with a feminine pseudonym Sor Filotea and the Bishop published Sor Juana's critique without her consent In his letter, the Bishop of Puebla advised Sor Juana to write about devotional matters rather than philosophical and scientific topics Sor Juana knew that the Sor Filotea pseudonym was the Bishop of Puebla and she took three months to respond to the Bishop's letter and she probably could have expected her critique to be circulated in manuscript form but she did not anticipate that her friend the Bishop of Puebla would print it without her permission for wider circulation I guess she was not aware that he was a foil to the misogynist archbishop of New Spain Francisco Aguirre E. Sejas Now here's the interesting part Sor Juana's Carta Athenagorica was republished later with her permission in Spain in 1692 as Crises Sobreón Cermón in the second volume of her works and it was received with great enthusiasm in Spain in fact the Spanish Inquisition declared that it contained nothing contrary to the faith so why did it arouse a storm of criticism in Mexico? Some Jesuits viewed Sor Juana's singular opinion of divine favors as an attack on the Jesuit order to which Vera as well as the archbishop of New Spain Francisco Aguirre E. Sejas belonged and Sor Juana's Carta Athenagorica was declared heretical it was strongly condemned in New Spain because the Jesuits were very powerful Now in 1691 Sor Juana responded to the bishop of Puebla's letter and in her response she defended herself vigorously claiming for herself the right to study and her respuesta was an eloquent biographical document with details from a personal life and intellectual contributions to defend the rights of women Now several scholars have described Sor Juana as a proto-feminist not only for her defense of women's intellectual capacities but also for her legitimization of traditional feminine qualities namely obedience, humility and silence and Sor Juana's respuesta is far more than a political self-defense from the Mexican Inquisition a layered and nuanced work that showcases the depth and richness of her thought Sor Juana asserted that with the exception of Primero Sueño all her work had always been commissioned and she wrote about her lifelong desire for learning and although she wanted to pursue higher education in the university she was not permitted she explained her choice to join the convent but graced me with a gift of immense love for the truth and since the first light of reason dawned on me my inclination toward letters was so intense and powerful that neither reprimands by others of which I have had many no self-reflection of which I have done not a little have been sufficient for me to stop pursuing this natural impulse that God put in me So Sor Juana argued that since her talent was a divine gift she should neither be praised nor blamed for it and she included a list of exemplary women from the Bible and from classical antiquity to champion the intellectual rights of women and she implied that women as scientists have empirical advantages by reframing cooking as a philosophical practice and poked fun at Aristotle and wrote if Aristotle had done some cooking he would have written even more and she claimed a superiority for women on the basis of the menial chores assigned to them Sor Juana distinguished herself from her male colleagues by suggesting that her brilliance was not in spite of her gender but in some ways because of it such a feminist argument was unique in 17th century New Spain in 17th century St. Paul's famous precept let women keep silent in church now while some have interpreted this to mean that public lecturing or preaching is inappropriate for women Sor Juana took that quite literally to frame her argument about women's education she wrote that not only women but men too should be silent and listen in church that does not mean that women should study or give private lessons in fact the Christian community needs educated women especially to instruct young girls who might be led into sin by men who tend to be heretics one sex has nothing to do with one's ability to understand the bible and while she championed the intellectual rights of women she also defended her own right to disagree with father Vera and highlighted the absurdity of framing Vera's view as immune from criticism and she asked is it bold of me to oppose Vera yet not so for that reverent father to oppose the three holy fathers of the church in 1693 the theological debates were put aside and Sor Juana became the subject of a secret episcopal trial started by the powerful bishop of new spain and the archbishop's attitude towards women was medieval he considered women to be the source of temptation to man he hated the theater and fiestas that Sor Juana wrote comedias and even published them must have been a crime in his eyes and the archbishop's goal was to silence Sor Juana so the charges levied against her included the suspicion of heresy and activities incompatible with her religious state after five months Sor Juana was found guilty and ordered to renounce her literary and intellectual activities she was forced to make a public declaration of guilt which the archbishop then circulated among the other nuns of Mexico city and her downfall was to serve as an example for all those women who might foolishly consider trespassing on the exclusive masculine territory of knowledge clerics dominated the intellectual scene in new spain and created a society in which higher education became synonymous with an ecclesiastical career powerful men within the colonial church built an intellectual emotional machine that not only promoted official knowledge but also excluded dissenting opinions and unwelcome participants such as Sor Juana Sor Juana's assertion of female access to knowledge and culture challenged the very foundation upon which it had been built she skated on very thin eyes for many years and Sor Juana's nuanced intellectual abilities clashed with patriarchal society's tendency to relegate women to a condition of ignorance surrounded by criticism and under great pressure from her confessor Sor Juana began the process of forced abjuration in 1693 a couple of years later in 1695 a plague hit Mexico city and while looking after her sisters in the convent she contracted the disease and died at the age of 46 Sor Juana was neither royal nor aristocratic but we remember her today for her intense love of learning during her lifetime two out of three volumes of her complete works were published and the last volume was published five years after her death and like the other volumes was reprinted several times within the posthumous volume we find her first biography by father Diego Caejo which was based largely on her own words Sor Juana is a national icon in Mexico she is the subject of many movies plays novels and Netflix series and her image appears on the 200 pesos bill her old convent is now a university bearing her name the university of the cloister of Sor Juana was founded in 1979 and the life and work of Sor Juana forms the intellectual basis and identity of the institution I hope you enjoyed watching this video please feel free to share your comments with me thank you


I live full-time in an RV and I have for six years and I almost always a boondock and today I wanted to tell you guys about it because it literally changed my life for the better. Happy Sunday birdwatchers! It's Robin with Creativity RV. I hope you're all doing well out there. As you can see I'm out in the middle of nowhere boondocking. Now that means I am staying on public land in my RV usually for free. Now a lot of people don't know about this so if this is a new concept for you you're not alone. I didn't know about it until I stumbled across it on YouTube one day and saw this solo female RVer driving her RV out into the desert and I was thinking what is she doing? Where is she going? And then when she set up camp I thought is that legal? There are a million of us out here and if you haven't heard about this life it might be because most of us keep to ourselves and we go into a town and we get supplies, we do what we need to do like everybody else and then we go home. But home for us is usually down a dirt road in the National Forest or in the desert or in Army Corps of Engineer land all kinds of places and we set up camp and we can usually stay up to two weeks there for free. Now boondogging sounds great and it may sound great that it's free but there are things that go into it.  Let's start with a couple of definitions because I think some of them can be a little bit confusing. So what I'm doing right now in my air stream on Bureau of Land Management land is boondogging. Boondogging means that you're going out and camping usually in public areas without an RV park kind of a hookup. So you don't have a water connection, you don't have an electrical connection, you don't have a sewer connection, there are no trash cans, you have to be completely self-sufficient. So there is some work that goes into it. So when I say boondogging on public lands is free, it is free to camp here but most of us have to make an investment into an RV that we can live in full-time that supplies us with all the power that we need, the water that we need and the ability to pack out all of our trash until we get back to civilization. You may also have heard the term primitive camping. Primitive camping is just like boondogging except that when you go into the Bureau of Land Management website BLM.gov and you read about areas where you can go recreate for free which means camp, they call it primitive camping. To them primitive camping again means camping with no hookup and what they're basically telling you is that you have to be self-sufficient. The next term you might see is something called dispersed camping. Dispersed camping is the same thing except that it's basically boondogging on national forest land. So if you go to the National Forest website where you can see all the places that you can camp totally legal for free usually up to about 14 days you're going to see that they call this dispersed camping not to make it more confusing. So boondogging, primitive camping, dispersed camping all the same thing then you're going to see a term called dry camping. Now a lot of people as you can imagine start to use these terms interchangeably but dry camping is a little bit different. You're not necessarily out in the middle of nowhere maybe you're at a national forest campground where you have a reservation and you pull into a spot and you're there dry camping without an electrical hookup without water at your site without sewer at your site. You might have access to a water spigot or a trash can or a dump site every campground is different but most people consider that dry camping. Now these probably shouldn't be confused with stealth camping which a lot of people do. People are living in their RVs or vans in cities a lot of times because they can't afford the rent or because they're just traveling through and they want to stay in their house they don't want to stay in a hotel.  That's like what you do at a harvest host. When you go to visit one of the great hosts have an experience and stay the night in your own rig usually without a hookup. That's the same thing as if you went to a Walmart or a truck stop or a rest area. These are all places where you can overnight camp or overnight park. They really are the same thing except that. People used to say overnight camping a lot and then the word camping got kind of a stigma because of people that were like living in encampments on city blocks or in Walmart parking lots and so a lot of these entities want you to know that you're not supposed to camp. Like if you go to a rest area for example you may see something that says no camping. Well what that means is they don't want you putting out your camp chairs and putting out your grill and setting up for days at a time but if you go to the state websites then it will tell you that they want you to be safe that you need to pull over and you can stay to get rest so you're safe to get back on the road so overnight parking is just fine and by the way if you haven't subscribed to my blog yet creativity RV.com I do have a blog post that has leaks to every single United States rules for rest areas and where they are. Now that seems like a lot of definitions right well maybe it's because there's so much camping opportunity in the United States. Did you know that over 50% of this country is public land and if you go into any of those government websites they're going to say that one of the purposes of public land is recreation and that's us.  I was living in the corporate world and was trying to find a way out so that I could be a writer and a painter which is what I was meant to do but I couldn't figure out a way to do that and pay the bills and then I stumbled across boondocking RV life and I crunched the numbers and I realized that if I boondocked I could make a living as a writer. Now it took a couple of years of planning it's not like I fell over into an RV and was able to do this I wasn't. I quit that corporate job took a part-time job and then worked the other part of the time creating some kind of a mobile income for myself paid off all my debt and saved up for a rig that I could buy so I wouldn't have a payment that's me everybody's different but once I did that I discovered that my expenses were really low so the why for me is that boondocking allowed me to live the life that I wanted to live without having to be tethered to a job in one location. There are so many opportunities out there for people to work from the road now it's crazy so 10 years ago this wasn't possible for a lot of us but now it is. Now let me tell you how I do it. First of all I have a great boondocking power system I just had one installed inside of the airstream from battle born and dragonflight energy and so when I'm out here in the middle of nowhere like I am today and you can see it's cloudy outside and raining it's okay. I have enough power stored in here that I can work on my big computer and I can do everything that I need to do including running my starlink which is right there and work remotely just like anybody else. It is an investment to have that kind of a system put in but for me I'm saving so much on rent that it's worth it. The other big three things you have to worry about are water trash and sewer and it takes some time to get into the groove.  I'm in a wilderness area in Colorado and if I walk outside it looks like I'm in the Alps. This is an absolutely beautiful area but right down the hill is a town and so I have a signal and I'm really only about 15 minutes from a store. Now the first time I camped here I found this spot on the Bureau of Land Management website or BLM.gov where if you go in then you can drill down by state and by area and see all of the places. You can also do that with the National Forest website but there are a lot of apps and programs now that will help you find places just like this. I like RV Trip Wizard if I'm trying to stay in a campground or an RV park I'll put the link for that below. I like Harvest Hosts because I take advantage of other host locations while I'm driving from one place to another all year long it's my favorite thing in the whole world and then to find boondocking places I usually use Campendian and I Overlander. And where can you boondock? Well some places are better than others like I said more than half of the country is available for recreation but most of it is on the west coast. In fact Nevada has more public land than any other state but if you get over to like Maine or Pennsylvania it does get a little bit harder to find big areas of public land where you can boondock. I'm actually headed there for the first time this year and so I'll let you guys know how it goes for me but I know I'm going to have to stay probably at a few more campgrounds or RV parks when I head east. Luckily though there are Harvest House all over the place I'm going to maple tree farms and wineries and go-kart places and car museums. Can't wait it makes my travel so much more fun and I know some of you are wondering what it's like to be out here by myself in the wilderness. Well you know what I really love it. It's not a lot different than being solo in real life. My life looks just like it did then. I wake up I take a shower I make breakfast I go to work and then I get to go sit outside but my backyard is just fabulous and if I want to see other people it's really no big deal. I camp with other people in groups of people all the time but then when I want to split off and be by myself I can and unlike in an RV park I don't feel like I'm in a fishbowl. I'm literally surrounded by trees and mountains right here. I don't see another person and that's the way I personally like it. And one of the most common questions I get is do you feel safe or are you safe out there? Aren't you scared? I feel safe and I am not usually scared. Now I try and be really aware of my surroundings but that's the same for me here as it would be if I still lived in a city and I share my location all the time with about four people that can always see where I am and they check in on me and I'm ready to defend myself in here if I need to just like I would if I were walking down a city street or if I were in an apartment. And look I didn't grow up doing this I had never been in an RV until I bought one flew out to pick it up and started living in it full-time and I figured it all out and again that was six years ago and I absolutely love it. I don't see myself going off the road anytime soon. I mean my feeling is life is short and there's so much to do and so much to go see and for me there's no better way to do that than boondocking across the country and an RV. And seriously I pinch myself every time I go outside in the morning and the birds are singing and I've got this view. I am so lucky that I stumbled onto this life. If I weren't here I'd probably still be in some corporate grind you know just trying to pay the mortgage. Feeling like I was dying just a little bit more each night sitting on the couch waiting to go back to work the next day. This is a completely different life and it's available for you just like it was available for me. I hope you guys found this video helpful. If you did please give it a thumbs up and consider subscribing. I'll see you guys all next week with an all new video. Until then everybody out there have happy travels and be free.