OK, we are going to do an exercise. I promised you that I think it's something that it's good to remember and to bear in mind. I think it's very nice. I think it was done in a publication by Bonetto. It is cited in my notes, I think. So we're going to, first of all, build a thermostat. A thermostat, in this case, is something that will keep the energy constant. Now, if your system is following Newton's equations, there is no need for that. But imagine all the things that need a thermostat. For example, I have a sample. And I want to apply, this is a metal, and I want to apply AC magnetic field. You don't need to know a lot, but the thing is that the magnetic field is going to shake the dipoles inside. And this will create energy.  Because necessarily, it's like when you stir coffee, you're heating it up a bit. So unless you want to study specifically a situation where a system is heating up, that is not usually what you want to study. What you usually want to study is a situation in which this is in contact with some thermal bath or with some thermostat. And you do this. And then the system reaches, in this case, not a steady state, but a periodic state. Another example that we will talk about a little bit is in hydrodynamics. You have, I don't know, water. And then you have here some sort of thing that is turning. And you would like to understand, again, this is turning, you would like to understand. So this gives energy in some manner to the water. And you want to understand things about it, how much work you're doing, and so on. Again, if you're going to be strict, you're heating the water up. So maybe you want to study that, but usually you want to study a steady state, a state where the heat comes in through your work and then it goes out, and it goes out through some form of thermostat. So even theoretically, for many things, you need a thermostat. The one we're going to do here today, we're going to do two. The one we're going to do here is in connection with that little exercise. We're going to do a thermostat that is called, for reasons that I'm not very sure, the Gaussian thermostat. And it's a thermostat that fixes energy. There are thermostats that fix temperature. And those are the ones that are more common and are more, let's say, less theoretical. Because as you will see very easily, the thermostat I'm going to propose is not going to be something that Mahesh can do in his lab. But theoretically, they are very interesting. Why am I doing this exercise now? We will come back to this, but what I'm doing is the following. We have a system, and I told you that this was proven that it is completely chaotic, energetic, meaning that, loosely speaking, the energy shell is explored uniformly. We are going to discuss a little bit that, and then we are going to see what happens when we do exactly the same thing, but now we force the system with forces like these, and we apply a thermostat. And so the question is, okay, I am forcing the system, but then I'm applying a thermostat that keeps the energy constant. Can I recover ergodicity, thermodynamics, and so on? Is this a strategy that allows me to study any problem and you will see that there's a lot of limitations to this. This is going to be interesting for you because many of you will end up solving equations of many actors, for example, reproduction of cells or active matter and so on, which follow equations, but they follow and maybe keep the energy constant, but these equations are not of Hamiltonian form. And then you will see what are the limitations or what one can one do about it. Okay, so let's build our thermostat if I can find, yeah. This is, I think, also called Hoover, like the vacuum machine thermostat. Okay, so we have two dimensions. This is a simple Hamiltonian system. This is a force that may derive from a potential. And then we will add another force that doesn't. In, for example, this case, the force that doesn't, it's going to be, this will have periodic boundary conditions and it's going to be a force that goes like this, like this, and comes back like this. So it doesn't derive from a potential because it's like a torus, no? So you, so it does work on your system. And now this is just the equations of motion. So we have what? We have, these are the usual equations for a system that could be conservative. This is the drive term. And now we need to add the thermostat. So the thermostat will, we will do the following. It's, when you think of it a bit reasonable, we are going to add a friction. A friction is a term that is proportional to the velocity. A frictional force is linear in the velocity. So this is on purpose because this is doing work on your system. I need something that takes it away. So I will do something proportional to the velocity, but I will regulate it at every time so that the energy is constant. So this is a function of time that we will have to fix.  But the signs, because gamma is going to be, yeah, I don't know, the literature can, but the sign doesn't matter because gamma we will have to determine, no? So if I do it negative, it will, yeah. Okay, so let us, how do we guarantee that this thing is going to conserve energy? Well, the trick is to multiply these equations, this equation, sorry, what is it? We're going to multiply this equation by P left and right. So if I multiply and then I sum, this is just mathematics, then I have P i, P i dot equals minus d v d q i. And P i is q dot i over m, okay? I used this equation minus, here I could put P i if you want F i. I use the fact that it's the derivative because it's going to be useful for us, where are we? Thank you. And gamma of T P i squared, okay? So now here you recognize, and yeah, it was more comfortable to divide by the whole equation. The fact is that, look at this one, this is the derivative of P i squared over two. This is the derivative with respect to time because the potential depends multiplied by m, and here I divide by m and I put the minus side. I pass it to this side, and here on this side, yes, oh sorry, the derivative is also like that. Here on this side I have minus P i F i plus gamma of T P i squared. And now the mistake I made before, let me divide everything by m, and now it's nice, okay? And you make this one nicer, okay? Up to now I haven't done, and sorry, and now implicitly I'm going to sum over i. It has been summed here already, and I'm summing over i. Okay, for the moment, this is just using the equation of motion, and now I want the energy to be constant. That's the aim of this game. So I would like this to be zero, okay? Nice, so this tells me that if I want this to hold, I have to tune the friction at every instant. This is why Mahesh will not be able to do it. Here I do q dot i dot i, and here, let's say q, okay? So, where? Here, here? No, no, because it's P over m. Okay, so the whole story is that you are on an energy shell which is this thing equals constant. You are forcing the system. Remember that this is the force that doesn't derive from a potential, that could not derive from a potential. And now I'm asked, I have to tune this so that tweaking this because there is a forcing that would kick me out of the energy shell. This guy, if it's tuned this way at every single instant, it will keep the system on an energy shell, okay? So this is a system that conserves energy. We sort of imposed it, but it is not Hamiltonian. The equation of motion, as you see, this is not Hamilton form. This is not Newton. It has a force that is linear in the friction. Okay, two minutes to analyze this expression because it's very interesting. First of all, look what this quantity is. Force times velocity. So this is a power that is being done on the system by the non-conservative force. And what is this? This is kind of a kinetic energy average. So let us say that this is playing some role of, like as it were a temperature. It's not strictly a temperature for the moment because we didn't explain, but it's the average kinetic energy of a particle. Let's call it temperature. It's usually called that way. But what is power divided by temperature? You probably have seen and we will. So this is the power. And this would be the entropy production. So I'm telling you this. Maybe you don't know at this stage exactly what entropy is. We will discuss about this, but it's called entropy production. For those of you who have seen thermodynamics, entropy is precisely the energy, the change in energy that we're giving the system divided by temperature. If you haven't seen that in thermodynamics, it's just a name, okay? Yes, that this comes out in this thermostat this way was a very nice discovery because this is not a thermodynamic context. And you will see that it's even nicer in a second. Okay, so we have this thermostat and now our question is going to be, if I have a system that I manage that his energy is constant. Remember I told you a hundred times yesterday that there is some property that your system has to have in order that you can guarantee that eventually it will equilibrate, it will be ergodic, it will explore the energy shell in a democratic manner. All these are synonyms, okay? Now, this system, ah, sorry, another remark that is important. What happens if the force that does not derive from a potential is zero? Well, then gamma is zero, but that's good, no?  It conserves energy on its own, the system. And of course the so quote unquote entropy production is zero, okay? So now we're going to first discuss this system without forcing, so we don't need the thermostat. As I told you last time, what Mr. Sinai proved is that, so you crash against the wall, somebody yesterday asked me after the lesson, what is a wall? A wall is a potential that does this, and this is super high. So your particle comes and rebounds.  If not infinite, much higher than the energy you have, okay? If you don't like a wall because this is a bit cruel, you can make it a limit of a decent smooth potential and consider stiffer and stiffer situations, okay? So when I say V in this case, I'm talking about these walls. It's the only potential there is. Otherwise, within these regions, things are completely flat. So the only purpose of the potential is to reflect your particle when it meets the wall and it reflects it with a law of optics, no equal angles. So this reflects this way. I'm trying to be fair with my drawing. Now it comes into here. So to say that this is ergodic means a lot of things and it's amazing, you will realize how amazing it is. So I'm going to erase this part only. To say that it is ergodic, it means in that case that first of all, all space because the energy has to be constant and it's infinity here and zero here, all space has to be occupied with time, has to be explored completely democratically, yes? So the probability that in a long time you pass by this little square is just proportional to the area of that little square, okay? Then it also means that the velocity, which is fixed because you don't have any friction here until you will put these things, also is democratic. So you have Px, Py and it has to, again, if I ask what is the probability that the velocity is that, it is with time going to be explored also democratically. This is like saying that the constant energy surface is explored flatly, but there's even more because the form of the energy is P squared vector divided by two plus V. The distribution of this and this are independent. So this means something amazing. It means that if I am standing here, I'm going to see all directions of velocity with the same probability. So the fact that the wall is beside me doesn't change average over, this is amazing, no? And this is one example and you will, I will try to bombard you with examples where equilibrium is an amazingly strong concept. Mostly to tell you that normally you in your work are not going to have it because the equations that probably you will have to face unfortunately are not going to be equilibrium. But you see how amazing it is that even though the wall is nearby and you would think it would correlate with you, it doesn't. The fact that the measure is flat, it means that every point, if you think of it and take randomly a point on this constant thing, you immediately see that there is no, it's as if on average velocity and position, it's not mean, do not correlate at all. Okay, so the proof of this, as I told you yesterday, is hard and I have no idea how it's done. Well, I have a vague idea how it's done. Okay, there is a property here is that there is no, this is a thermostat but it's completely deterministic. Okay, so now we have this and now we will add a thermostat to this. So let me do these equations. So this one is this one and we would let us set the mass to one, doesn't matter. And we are going to apply here and this is going to be the only force that doesn't derive from a potential of a constant forcing in that direction. Okay, so we will have, well q dot x, q dot y we know and we have p dot x. In x, we only have the effect of the walls. Walls means the potential with the walls. Plus, this term has to apply, gamma of t px and p dot y is going to have the walls plus. Now we have the forcing to which we will assign a sign. The sign is a bit arbitrary and pointing in that direction plus gamma t times p y. Okay, so this is the thermostat equation. If you like here, you just simply put q dot dot x, q dot dot y, q dot x and q dot y, okay? Okay, and then that proof holds the energy is conserved, no problem, okay? So okay, fine, we applied the thermostat to this problem. Now let me show you what happens with this problem. We will, if you solve these equations, it's easy to do because you see this one is linear and this one is linear too. It's easy to do but I can tell you the solution, you can do it but it's very simple. If the particle is going this way, the field will want it to accelerate in that direction and the thermostat will keep the energy which is the kinetic energy constant so it will turn in this direction but the velocity will be shortened by the thermostat. So it will do this and move that way. If it's moving that way, the field wants it still to go upwards so this will do that something like this. So sorry, this is straight, it will do like this and it will move upwards and then even more straight. The only thing is that it doesn't accelerate because precisely for that, the thermostat is taking away energy. So the only thing that the field does is align you on the y-axis, thanks to the thermostat. You see if I didn't have the thermostat, it would be a mess because the particle will keep on gaining energy eternally and we don't want that, we want a stationary system. Is it okay? So now very easy, if you want to consult these equations you're going to confirm what I said just now. Now forget about this one and let us consider a case where the field is super strong because it will be easier to caricature. So we start here, the thing will be like this. Now it does this but the thermostat wants it to do like this. No, the thing I was saying. Then it does this and then it wants to be like this. Then it does, the rebounds are as usual. Are you convinced? And similarly on this side. And next time it comes, it comes already through here. So it comes, yes, so I didn't solve these equations because it would take us a short time but you see what this is doing. The thermostat we are choosing has something that takes away from the energy and the only energy, when the particle is flying the only energy is the kinetic energy. So it keeps the modulus of the velocity constant. Now when for example your particle comes like this and crashes against a wall it crashes with a law of reflection. Now the field wants it to do this. It's pulling it up. The only thing the thermostat is doing is that normally it would be gaining speed but the thermostat removes this gaining speed so the direction turns because of the field but we are not gaining in kinetic energy because the thermostat, the only thing it does is it takes it away, okay? So it sort of aligns the particle. Normally it would accelerate, not like gravity but imagine with gravity I throw a bullet but I have somebody who is always changing the velocity the modulus of the velocity. So the particle would still do something like this but it would not accelerate, just change its direction, okay? This is the way that it works automatically with those equations. Yes? Please have a question about, so maybe instead of adding another forces, the heat that you add over there if maybe we consider that the wall that we are going to use is going to absorb one part of the energy of the system. So in that case, are we going to have a equilibrium? The problem is that a potential, a force that derives from a potential doesn't absorb all the time. It always gives you back. So I throw a ball, it absorbs my kinetic energy but then it gives it back to me. So you need something that violates this form. That is not the gradient of that. So to take away, it has been chosen. This is a choice that is going to be friction. It's okay because friction is something that we have in life. A force that is proportional to the velocity cannot be derived from a potential and it takes away your heat, your energy, okay? No, there was you? No, okay. Okay, so are you convinced by this graphical solution of the equations of motion? You can, of course, do it. It's just when it's flying, it's flying and when it hits a wall, it remounces, okay? So at the end of the day, with a very strong field, I used a very strong field just to make it more extreme. At the end of the day, what I will have is something that comes in, pump, pump, pump, pump, pump, comes in, pump, pump, pump, pump, pump, pump, and so on. Okay? And so, for example, if I consider long times now, this region is not explored at all. It's, and furthermore, if I look at this, there is a very strong domination of this velocity because while it's flying, the field tends to align and then when it rebounces, you get other possibilities because the wall changes your direction. And furthermore, the non-correlation that I said before was a miracle between velocity and position is gone, why? Because when I'm outside the wall, I expected the velocity to be almost always vertical. When I'm near a wall, it's the only times at which I can have another angle. So all the miracles of thermalization of ergodicity have disappeared. And this happens as soon as I connect the forcing. I think this example is super nice because it illustrates, and we're going to come back to this, it illustrates how equilibrium dynamics, that potentially can lead you to equilibrium. Here, equilibrium, I'm using it in an ambiguous sense. It's not, well, the equilibrium is established when your dynamics allows you to do this. And you will see that this means some form of time reversal, as I told you already. Equilibrium dynamics of all the possible dynamics that you have is a very, very, very singular point. So of all the book of thermodynamics that you read, essentially 90% is an isolated point in the set of systems that you can have in life. And if you're going to do complex systems, complex systems, maybe your particles are going to be agents that buy or sell in the market or they could be cells that are competing and reproducing or they could be lots of things like this. Neurons, you cannot expect these people, these things to satisfy Hamilton's equations. And they will not. And then what is the probability that they satisfy an equation that leads to ergodicity, zero. So this is the thing one has to keep in mind. Yeah, so to put it pictographically of all the energy shell, which in this case is p squared constant and being outside the walls, you are only exploring some region. No, because this is a region and there is another one here, no? Okay, so now a little calculation, very simple calculation that is, I think, very nice. So these are the equations of motions when you have a thermostat, okay? Now, when you have an equation of motion that is like this, x dot i equals a certain function of all the x's, a vector function, and you want to start and you start with a set of initial conditions, you would want to study how the volume of this set of initial condition changes. So with dynamics, it may do this. Each point goes to a point, okay? You have studied, and this is the origin of the word, that what you have to do is calculate the divergence of this field. This is the origin of the word divergent. So the derivative of the volume with respect to time is this thing. This is the divergence, and this is why it's called divergence, okay? So we are going to calculate the divergence of this and see what we can learn from it, okay? So let's calculate the divergence of this, okay? So this is the equation for q. I have to differentiate this with respect. So the divergence, the derivative of the volume is the divergence of the equations of motion, and it is. First of all, I have to differentiate this with respect to q because it's a q coordinate, zero. Second, I have to differentiate this with respect to p. This part is zero. This is a potential. So we already realized that the Hamiltonian terms do not contribute to the divergence, very nice. Then I have to differentiate this with respect to p, zero. And then I have to differentiate this with respect to p, one. So all in all, I get n times gamma of t. So it means many things, n is the number of degrees of freedom because it's a sum. It doesn't matter, I mean one could have, but it's okay, and yes, sorry, two. I did it in general, but in our case let's keep the n. So it's a total sum, it's something extensive. So this means that if I start with a set of initial conditions here, it could be this set of initial conditions with all velocities like this, and then I follow all these initial conditions. So this is like an ink, think of the ink blood that is sort of moving. These are all that the dynamics takes you through. This is going to have, in fact it is a contraction that is proportional to gamma, but we said that gamma was the entropy production or force divided by temperature, work divided by temperature, and we also said that gamma was zero in a Hamiltonian system, no? You don't need the thermostat that is doing nothing in a Hamiltonian. So first of all, the ink blood size doesn't, volume doesn't change if the system is pure Hamiltonian. This is also known as L'Huvel's theorem. It's an amazing property of Hamiltonian dynamics that if you consider all the points initial condition here and you consider it a while later, the total volume they occupy is constant. This is why, remember when I was discussing ergodicity, I always said that you had an ink blood and in a case that it sort of stretches, I say stretches and not spreads because it conserves the volume, which is quite a miracle, okay? That's Hamilton, Newton conservative. Now, what happens here? I mean, how can the volume of something contract forever? Now we have a forcing and we are letting this system move with the thermostat. How can it, how can a volume contract forever? Can somebody guess? Nobody, you're shy, I think. So then Matteo will have to answer. You want to embarrass Matteo? Okay, yes, exactly. So a volume can contract forever if it ends in a point, zero volume, or if it is in a fractal. It ends up in a thing that has zero volume and the only things that don't have a volume are not the points, are also fractals. So this means that if you wait long enough in this thing, and this is amazing, not only you will not visit democratically, we saw it already, but on top of it, not even smoothly, the attractor as we call it, the set of points that you have a very long time in the dynamics is a set that has zero volume. It's a curiosity, we're never going to use this, but it's nice to say, when gamma is zero, nothing, you have conservation of volume, and then gamma finishes by being zero. Okay, so what have we learned from this exercise? I think two things, first of all. Another question, so about the sign, so gamma is the entropy production, right? Yes, and it's you doing work on the system, not the system on you. Okay, so the entropy production in this case is negative. Yes, I don't know, the signs depend on the literature, but the important thing to know is that when you stir coffee, you are heating up the coffee and you're not getting any energy from the coffee into your spoon, that's what you have to bear in mind. This is the second principle, so it's in that direction. And this is entropy contraction, I'm sorry, volume contraction. The other possibility would be expansion. Of course, maybe one can write systems, I don't know, but not in this one. Okay, so two things we have learned. Equilibrium properties are amazing. They're super strong, we will see this a hundred times. And they are very surprising and you shouldn't expect them to be valid away from, as soon as you do something that breaks this equilibrium property. You will also see that there is a lot of literature, really a lot of literature, where people attempt to do things in equilibrium, as if you were in equilibrium when you're not. The literature is not necessarily bad, it's simply that it's an assumption that is extremely strong. I heard we were talking yesterday about maximal entropy principles that are used, I think some of you, I don't know who it was, maximal entropy means that you are assuming in a system where you don't have a right to assume that, however, you are more or less democratically studying all the possibilities. Okay, this is a very strong assumption. I mean, the people who do it understand that it is a very strong assumption. But there is no a priori reason why such a thing has to be true, okay? Good. Any questions on this? Because I'm going to change gears a little bit. The system that, what is it about the curvature of the system that makes it aquatic? That it's like this, so it amplifies the differences. It's like a convex length, a mirror. So if we were to reverse the curvature. But you cannot make it like this everywhere. But if you want something that is not chaotic, then you need a symmetry. For example, an ellipse, amazingly enough, doesn't have any chaos.  Go figure. So it means that you have to be careful. By the way, this is what people call a billyard for obvious reasons. So do we learn that due to the presence of this external field, we get this entropy production? Yes. Okay. Yes. So if there wasn't any external field there. No. And it is. And egodicity is lost by this. Egodicity is lost by the effect of the field. And then there is a question, it may be someone of you asked. I said, there is no entropy production in a purely Hamiltonian system. But you say, well, how is this possible? I mean, we are taught in school that thermodynamics with Hamiltonian and everything, entropy increases. This is a fantastic subject. It's almost philosophy. It increases, sorry, you're guilty. You're guilty. So in a Hamiltonian system, an ink blood, it's a metaphor, becomes, as I said, stretched, but its volume is conserved. So entropy is not produced, okay? So how is entropy produced in the room where they've had half the full and the other half? No. The answer is entropy rigorously is never produced. It took humanity the best minds of Europe half a century to work this one out. Entropy does not increase in a Hamiltonian system unless you decide to look at your space in a coarse grained manner.  I am going to make a small error. And if you do that because your ink blood is super stretched, then it is as if it were uniform. And then you regain, you lose the conservation of volume. This is, for those of you who want the origin of irreversibility. So it took half a century for people like Boltzmann. Maxwell got it very before others. How can equations of motion that are reversible like Hamilton's produce irreversibility? You know, irreversibility, I throw a glass, it breaks, but I never see the pieces coming up and reproducing the glass, et cetera, et cetera. How can this be possible? And technically speaking here, you see it very well. The volume of this thing, which is the entropy, the log of the volume is the entropy, we will do a calculation. It's conserved. So how is this, there's no entropy production. Yes, true. But it appears only when I decide to look at the same thing with a little bit of error, coarse-graining. Only then entropy is produced because this thing conserves this volume, but it's so fractured into little filaments of ink, let's say, that when I look at it from a distance and I close a bit my eyes, I see it as gray. Or in other words, you have black and white. The volume of black is constant, but the black is sort of stretching and stretching and stretching such that if I manage to see the thing without precision, I see it all gray. So this is the paradox and the origin of irreversibility. I didn't want to talk about this, but since you forced me, I'm doing it, okay? So one last question. So in microclinical ensemble, we keep calculating this entropy and there's the fluctuation term, which is like connected to this, right? We need to have some fluctuation in energy or Hamiltonian that is causing this entropy. What is causing the entropy is the force, this frictional force, which is modulated, it is fluctuating, but it's always, not always, but most of the time working against you, stopping you.  That's what the second principle said. This creates entropy, which is the same thing, it's synonymous with the volume reducing. And this one is, you can write the equations, but if there is no F, there is no gamma because there is no need for gamma and you see it from the formula. You said if gamma is non-zero, then it will land on a fractal, it could land, right? So instead, can it not land on a, let's say, circle or some limit cycle? Yes, yes, it could land on anything that has lower dimension. In, I think, in most cases it ends up by being a fractal because you should be, I think, very lucky that it's sort of an integer, has to be a dimension smaller than two in our case, no? So that it doesn't have volume. I think that you're never lucky that it's going to be precisely one, but I'm not a big expert on this, but it will land on anything that has volume zero. Okay.  There is no formula that tells you what the attractor is going to be. Once you're outside the equilibrium, you're on your own. You don't have any way, a priori, to compute the attractor set. So you could say, well, I'm going to do thermodynamics, but instead of doing equi probability, I'm going to have another measure. Yes, you have another measure, which is where this system goes to, but there is no general, never any general formula for that never other than doing the dynamics. So I have a question or observation. So isn't this example of the breaking glass misleading because if your glass, I mean if everything was Hamiltonian, then if you wait long enough, you will see the glass form again. Yes. So, I mean it's, you have to wait a very long time. And here, unfortunately I don't have the film, but if you go to, I'm going to give you the website tomorrow. We think you do the experiment with ink. The equations are very similar on the other hand. And you turn a crank and the ink thing goes like this. And then you go back, I don't know if you've seen it. You go back in your cranking and it remakes the, so you have reversibility. This is the big paradox. This is why irreversibility is a problem in Hamilton. Because yes, it's true what you say, but if you coarse grain, if you allow a little bit of error in the motion, then you never come back. But basically never come back. Or the times in which you come back are epsilonic with respect to the total span of time. Yes, yes. Showing a better picture. Yes, yes, the coarse graining. But the one has to remember there is a famous thing where Boltzmann was discussing with, I don't know whom, about entropy and how is it possible when you have a reversible equation of motion. And there's a famous quote from Maxwell. I don't know what these Germans are discussing. They were not Germans, but for Maxwell probably, from his perspective, everybody was a German. And I don't know what they are discussing. It's clear that irreversibility can only happen if you coarse grain. So he saw it. So the correspondence was between Boltzmann and Ernst Zermelo. Zermelo, who was also, no, he was German, I think, yeah. But Ernst was also against Boltzmann's ideas. Yeah, and they were fighting for this. And I think that Maxwell, at the end of his life, understood that irreversibility comes from some form of coarse graining, which we have. Okay, let us, this is over. So now I'm going to change a little bit gears with a couple of exercises that I think are important and then we'll see a couple of things. So remember I said that the two things that count are the possibility of doing equilibrium and the fact that you have many degrees of freedom and that those things are independent. Okay, let's do this simple exercise that probably you've done, or maybe not. We have a sphere of radius one in d dimensions and we're going to throw a point randomly inside the sphere and we will try to see how big is the radius of that point, that the radius of the sphere is one. But we're going to throw a point at random and ask what is the radius. Okay, so let's do the average and we normalize by the volume of the sphere, which is the integral of the number one within the sphere. Okay, very good. So now we go to polar coordinates. We will have a volume here that we don't care for the reason that you will see.  So this comes from integrating over all the angles, nothing depends on the angles. This R is this X here and the normalization, this is why I don't care, is so that if this wouldn't be here I get one, okay? And let me write it in a slightly more suggestive way. Sorry, I should put a prime here because it's not the same integral. Okay, so this I'm going to put it like this with a normalization so that this thing has an integral of one and then I have the thing of which I am calculating the average, okay? I just rewrote this one in a more suggestive way and I'm going to call this rho over R because it's a normalized density of probability. Okay, so now we have to calculate this. Of course it's not difficult, but we bet the good thing is to see what this looks like. So let me plot this function. It's a function that has an integral of one and starts in zero and it's super for D large, sharply picked in one. No, because this is a very high power. If you want I can write this one and we will do this very often. So it's the log of R what we're doing. This is a way of saying that D minus one is multiplying a smooth function of one. I just took the log of this thing. So what is important in this calculation is this exponent here, okay? So the morals of this is that if I throw a point at random in a sphere of high dimension, the point is going to be very close to the surface with probability one, okay? This is an amazing fact of working in many dimensions. The point is going to be extremely close to the peel of the orange, okay? Okay, exercise number two, very similar. Now we are, can I erase? Exercise number two is I am on the surface of the sphere now and I want to know, I'm throwing a point at random and I want to know what is the typical angle from the equator it will have. I'm on the sphere, okay? So in other words, I am calculating the volume of this slice in D dimension. Yes, yes, yes, this is the center. This is the sphere. I am in D dimensions. So this is another sphere of dimension one less and the radius it has is the cosine of theta. So the typical angle is going to be cos theta. To the D minus one and here I want to put the angle just to say that I want to calculate the average value and then I have to divide it by the normalization which is the volume of the sphere. But okay, because the volume of this slice is, the radius of this slice is cos theta, okay? Now again, the function cos theta, cos theta goes from minus pi over two to pi over two. No, yes, and around zero the cosine does this but when I raise it to the power D minus one this is a function again that is superpicked in zero. You see because it's a cos which is close to one here as soon as the cos gets a little bit smaller than one the D if it's large kills it. So just before doing any calculation what is the morals of this? It is that if you are standing on a sphere and you have points at random on the surface of the sphere, almost everybody is in the equation. If you're standing in the pole everybody you see is living in the equator. This is again another property of large dimensions. So you see that geometry of large dimensions is something that is very different from the one of usual life. So there is spherical symmetry, right? So that the way you define the equator is arbitrary. And so isn't that... Contradictory, no, because you are standing in France and I am starting standing in Singapore. Our equators are different. Almost all of the people of the world are for you in your equator, your Polish France and my Polish Singapore and almost everybody is in another equator. So you should conclude almost everybody is in the intersection of both equators. The intersection of both equators is still a high dimensional thing. But one dimension less, but D is very large. So almost everybody is both in your and in my equators, intersection. But you cannot exaggerate too much. I mean if you take too many points then you begin to lose the dimensionality of the set and then you come to a point where you will have a problem. Okay, so when I told you yesterday that you had your energy surface, for example, and suppose that these are my spins, just variables, no? And then I'm looking at the magnetization which is the sum of SI one over the number of degrees of freedom. So the magnetization is this axis, one, one, one axis and you're measuring the magnetization values like this. Okay, so now imagine that I am moving on a sphere, let's say, or it could be a cube of S plus minus one, but I'm moving randomly. You see that the magnetization in spite of the fact that it can go from minus one to one because almost everything is in the equator. It will be typically this because almost every point is there, zero. So this is how the large dimensionality makes that the thermodynamic variables concentrate. Okay, this is if you are doing your exploration in a democratic way. What happens if you don't know, for example, the case we did a while ago where the energy shell is not covered democratically? What can I say? Well, what can I say? Please stop me if you don't see this point. What can you say in situations where you don't know? For example, active matter, people who act agents in an economic system, number of species in bacteria. Well, your attractor is going to be something, of which we say we don't know. So some people say, okay, maybe it's not democratic, but there is this effect of accumulation of the measure in one subset. Doesn't this compensate that at the end, it's the same as if I were democratic? The answer is sometimes, not necessarily, because all your measure could be here and you wouldn't be able to do these things. But people and many of you will end up by doing, I suppose, max entropy principles. It is to say, although I am treating a problem that does not have ergodicity, because the vast majority of the points here, independently of the dynamics, are in the equator, well, I can assume that the only part that counts is this one. It's generically not true. But people who do, for example, proteins use it and they are successful, so I don't know. Depends on the problem. Sure, there are questions. Is everything clear? Or I lost everybody. Okay, so, let's try. So you have a question. No question? No? No questions? Ah, I want. So maybe it's just to recap. So in the normal situation with ergodicity and no active matter, the point on the, let's say in the first space is clustered near the shell of the sphere. In this case, no, there are other situations where it can be clustered. And also on the, near the equator. Yes, in this case, in this example. But they are clustered somewhere. And this is pure geometry. It doesn't have to do with the dynamics itself. So also this justifies the fact that we only use the energy shell to build the mechocononical ensemble. This also justifies the fact, I would like to do this exercise, that you can go from micro-canonical to canonical and nothing changes. Because they are concentrated, the two measures in the same places. So this is one thing that happens that is due to the large n limit. So here again, you see the two things. Large n limit gives you a certain geometry of your space. Dynamics tells you how you explore it. Okay, so let me give you the technical point now. We want to calculate this, but instead of doing it by the I, I mean this function is super peaked in zero. So theta average is going to be approximately zero, which means everybody's in the equator. How do you do this in practice? Well, consider this function, which is the weight, no? This function here is, as I said, of the form e to the d minus one. And because I already see that this is going to be close to zero, I'm going to write cos theta as one minus theta squared over two, okay? So when I take the log of this, okay? So this is d minus one, theta squared over two. This is the integral I have to calculate, okay? And here I am calculating an average and I'm dividing by the normalization. I'm going to, I want just to justify what I said that almost everybody's in the equator. How do you calculate an integral like this or like this? Let's do this one that is easy for large d. Of course it's a Gaussian, no? We understood it's a Gaussian, but how do we calculate it without knowing that it is a Gaussian? So we need to calculate, or even with a cosine, let's say this one. So now what we have is a function here with a minus that has a minimum in zero. It could be even the cosine. And it has this very large exponent, okay? So where, who's going to dominate this integral? The minimum of the function you have here because the smaller this is, then the more that this is big. So if you have any function like this, this point here, if this is the function you have on top, and this is the lowest point, if you are doing it to an enormous power, all this is going to be infinite. This point will dominate. This will be exaggerated like this because d is a super large. So always it's the minimum that dominates, okay? So an integral like this is dominated. Here I could have put instead of this log of cos theta, which was your original thing. So you need to develop this function around the minimum, which is what I did, and this is what is called saddle point evaluation. So you end up, you start with the minimum, you end up with a Gaussian, and then you integrate it, and this is one over, I don't know, square root of pi over two, d minus one, and then there is a zero. So the point that we are doing is that all these integrals that are multiplied by an enormous number in front of the exponent are dominated by their smallest number, and this is called saddle point evaluation. And this is, again, saddle point evaluation is the same argument as saying every point is in the equator. There is a point, a typical value that dominates your integral, and that one is as if everybody would be there. So all thermodynamics, as we know it, once you got rid of dynamics, is constructed upon evaluating integrals like this. I mean, this is your bread and butter if you're doing thermodynamics. This is what you do all the time. Who of you have seen this saddle point evaluation? Please, hands up. Okay. Two thirds. Okay. Yes. Can, is it meaningful to look at the exponential as theta minus mu whole squared? So mu is zero. So the mean is zero. Yes, yes, yes. And d minus one is basically the inverse of the sigma squared. So square root of d minus one. So in the large d limit, this is going to become a delta function. Yes, yes, yes, yes. What we are saying is that in the large dimensional limit, it's as if everything becomes a delta function somewhere. That's what saddle point is telling you. So if I am measuring your angle with respect to the equator, the equator is a delta function in the large d limit. This is what the probabilists call concentration of measure. The measure which was flat on the sphere because of the law of large numbers ends up by being as if concentrated on the equator. Okay. Next, and we will discuss it later tomorrow. Why is this important? So then we have, again, this I'm sure you have seen already, but it's never bad to do it again. So what is an, suppose I have a system, let's say with, for example, spins on a lattice. So in every site, there is an SI. And the interactions are, let's say, not very long range. There are, so the system interacts relatively near neighbors. And we will need to calculate the partition function, which is the sum of, as you know, e to the beta, beta is one over the temperature with Boltzmann constant equals one. And the energy is, I don't know, for example, the sum of SI, SJ, where I and J are nearest neighbors. I don't know, it's an example like anyone else. I mean, it's not important. Some form of interaction between the things. So one thing that is very important for us, both in dynamics and in statics and always, is to identify which quantities scale with a system size. We say which quantities are extensive, which quantities are intensive. For example, energy, we expect that per unit volume has a limit that is not infinite or zero, neither infinite nor zero. So how can we say that? Why do we think that energy is extensive? Well, because if I cut the system here, and I cut it here, for example, I expect that I have a lot of energy in the bulk, then some energy here in the interface because of the interaction, then another energy in the bulk, then another in the interface. But the energy of the interfaces has one dimension less than the bulk. So you expect that the energies of three is more or less, except for the energy of the surface, the energy of number one, plus energy of number two, plus energy of number three, by which I mean that number one is now disconnected from number two, disconnected from number three, okay? And this is the argument we usually give to say energy is an extensive quantity. We expect it for a large sample to essentially scale with the volume because pieces add, their volumes add, so it's proportional to the volume, okay? Let's consider this quantity now. Now imagine the system would be disconnected. So I would have to compute the energy, total energy as the energy here plus the energy here, plus the energy here. And because of this and because this is an exponential and this is an addition, this means that if I disconnect the system, z total is more or less equal now because this is in the exponent, it's not a sum, well it is a sum in the exponent, but because this is a, we are adding this quantity, so there's something that is not nice here. The limit of large volume of this is a multiplication of things, which is not very nice. So what is the nice quantity? Well, the nice quantity, obviously, it's the logarithm of z, then this one is, yes, the logarithm of z one plus the logarithm of z two. I just took logarithms in this thing and this has a name, the logarithm of the partition function is either denoted, well, we could either denote it like this and this is going to be proportional to the volume, to all the degrees of here, or, sorry, not in exponent. I will add a sign, but what is important is this, the usual way of calling it is to define a thing like this and call this the free energy. The temperature here is conventional, but this is a name. For the moment, it's only a name. So conclusion, we were asked to calculate the partition function. We asked if it was going to be extensive. We concluded that it's not going to be extensive, but then its logarithm is a meaningful extensive quantity and we decided to baptize it with a fancy name, which is we add a beta and we call this free energy. It's a name for the moment. This is a nice quantity that we will expect that is proportional to the size of the system because it's additive, okay? Here and always, I'm going to use capital letters for the total quantity and per unit degree of freedom, I'm going to use the small letters and so on, okay? So that these quantities are per unit volume on number of degrees of free, okay? And just to end, there is another way of being extensive and I'd like to give this together. So I suppose that those of you who did a stat mech course started this way, I mean, at the beginning, but it's a nice thing to see this again. There are quantities that are extensive and this is going to be important in connection to the saddle point calculation we did before. Just a quick comment. Sometimes extensivity is not in space, but it could be in time. Let me give you an example. You have a system that has water in it and you're shaking it with this stirrer that creates a terrible turbulence here, okay? And because this is a mess what is going on in there, when you look at the work you're doing, work is a theta dot times torque. It's a work that you're doing for stirring and because this is a mess and you have water going in every direction, when you do, I don't know, experiment, you find that it sort of fluctuates and most of the time you are doing work into the water.  What I just said is the second principle of thermodynamics. Okay, so this is it. And I would maybe want to calculate the total work which is the integral of a small w, let's say of t dt and let me say, okay, this is the total work. This is a quantity that fluctuates and it is a bit random. It is meaningful to ask a question similar to this one. Can I assume that the work in a piece of time, that the total work can be decomposed in works on pieces of time, this time instead of space? Well, what does it need? It needs the correlations of this noise, let's say, are fixed in time and I have a longer time. So are these independent processes, if they are, I can consider that this is, let's say, extensive, but now in time instead of space, okay? So if this happens to be proportional to time, times work per unit time averaged for long times, then I say that this quantity is like I did for space here, you can use it also for time, okay? When you use it for space, we will use it in the context of thermodynamics, but I want to tell you this now because later on we're going to try to see a large deviations of problems and you will see that it's the same argument as you do in thermodynamics, but with respect to time instead of doing it with respect to space. That's why I think it's nice to see things together, okay? In real life, this is in the mathematics textbooks and this is in the physics textbooks, so it's divorced in actual real life. Okay, so let's stop here. So I was thinking that you said that ergodicity is breaking and entropy is produced, so is this statement vice versa? Because in micro-tyranical ensemble, we keep the full system ergodic and then apply the equal a priori probability and calculate the thermodynamics. In what system? Micro-tyranical ensemble. Yes. So we keep the equal a priori probability. So the system is ergodic, that whole of the space space can be accessed and then we calculate the entropy. But if your underlying dynamics is not one of the good ones, like Hamilton, like Newton, then you have no guarantee that you will explore the energy shell and that the micro-canonical assumption is good. So that's where it fails. Okay. Precisely. So when you are driving the system, it's funny because we introduced a thermostat so everything is on an energy shell and you would say, okay, I've solved my problem. I am on the energy shell because I forced it, but no, because the driving ruins everything in the sense that, yes, you are on the energy shell, but not democratically. Any other question? Valentino, do you have a question? Okay, let's take a break. Valentino doesn't have a question. Valentino doesn't have a question. Let's take a break. I reconvene here at 11 for Mahesh lecture and he told me that he will give the most important message right at the start. So be on time. Be on time.


Let's see what's on thinking man's mind today. What is the difference between a code and a standard? That's a great question. And one I get very often a standard is a set of criteria by which everything else is measured or compared. We use many standards in this industry. One of them is NFPA 80 the standard for fire doors and other opening protectives. The standard doesn't tell me where I need to use a fire door or what the rating needs to be, but it does tell me if you need a fire door it needs to look like this and act like this and the hardware requirements are as follows. And then the code is going to tell me where I need to use a fire door. And what that rating needs to be and if there's any exceptions to the standard. Other standards that we use in this industry NFPA 105 for smoke and draft control and ANSI a 117.1 for making buildings accessible to meet the requirements of the Americans with disabilities. NFPA 105 for smoke and draft control and ANSI a 117.1 for making buildings accessible to meet the requirements of the Americans with disabilities act are just a few that are referenced by our codes. It's something that is adopted into law, either in whole or in part by a state, a city or other jurisdiction. The international building code, the IBC has been adopted in various versions throughout the United States. You can find which edition on ICC safe.org. It's a great website, a very valuable tool. Also NFPA 101 is the life safety code. It's used predominantly in healthcare and government work, and in schools, and some states have adopted it outright. You can find that on codefinder.nfpa.org. By virtue of being referenced by the code. The standard then becomes part of the code. For example, in the international building code chapter seven, 716.5 says fire door assemblies and shutters shall be installed in accordance with the provisions of this section and NFPA 80. For those references, they will also say which year of publication those references are, and that's very important information if you're trying to look something up, either to answer a question for an architect, an owner, a contractor, or anybody that's trying to help in the built environment. For more information and continuing education opportunities, please visit Osa Abloy Academy by clicking on the link in the comments below. Please click like and subscribe to this channel. And you can follow me on Twitter at our consultant and or connect with me on LinkedIn for updates. If you have a code question, or if you'd like to see one featured in a future episode, you can email me at Catherine dot flower at Osa Abloy dot com. Thanks for joining me in the code corner today. My name is Katie flower and my goal is to help you achieve safe purity in the built environment.


How's it going? Yeah. Hope lunch was good. Was lunch good? Okay. Awesome. It's okay. You can say no. That's totally fine. I don't work for these people. So I won't get offended. Cool. So today I'll be giving a talk on why software engineers disagree about everything. Okay. My name is Haseeb Koreshi. I'm a software engineer at Airbnb. I work on the RIS team. I'll be talking a lot more about that and a lot more about kind of my own history and the different things that I've done in my past, because that really informs a lot of what this talk is about. I don't know that I'll totally answer the question of why software engineers disagree about everything. But I think this talk is going to be kind of an exploration of this question from a number of different angles. And another thing that's going to happen in this talk is I'm going to disagree pretty strongly with DHH's keynote. So that might be interesting. But hopefully at the very least, if I'm not convinced of what I'm saying, maybe get you thinking about some things. So this talk, in large part, is going to be about philosophy. So I know it's RailsConf. Usually people come up here and they talk about controllers or I guess someone else is talking about sorting and augmented reality. I'm not going to be offended if you get up right now and want to go into another talk. That's totally cool. We are going to go way into the weeds today, because that's what I'm all about. So specifically, I want to talk about the field of philosophy known as epistemology. And epistemology, the easiest way to define epistemology, is epistemology is the nature of knowledge, of justification, and of the rationality of belief. So this diagram here is of phrenology, which is this old science of trying to figure out what parts of the brain are responsible for what, which is a very old and ancient version of epistemology, which we've now thankfully displaced. But centrally, in epistemology, are the two questions, how does anyone know anything? And how do they know that they know it? I mean, these two questions are kind of navel-gazy, but that's fine. So let me tell you a little bit about me. So I studied English and philosophy in school. And before I ever came into the tech world, I used to be a professional poker player. And I did that for about five years. So I kind of took a very different path into programming than most people. And then I worked as a programming instructor. I taught programming at a coding boot camp. And for the last little bit over a year, I've been working as an engineer on the risk team at Airbnb, basically fighting fraud. So because of this, I've kind of snaked my way through many different subcultures. I've been something of a chameleon in that I've learned the different norms and the different beliefs and the different knowledge systems that many different worlds have and try to assert on you if you become a part of that world. And one thing that I've noticed, and then you can't help but notice the more worlds you step in and out of, is that knowledge is deeply cultural. So in the world of programming, the kind of things you might hear people tell you when you come into this world. They might tell you that full stack JavaScript is the future. They know this, for sure. They'll tell you that everyone should know C. If you don't know C, what are you doing? Go out there, crack open a book and learn some C. They'll tell you Rust is the best language for systems programming. They'll tell you that relational databases don't scale. They'll tell you that TDD is a fantasy and nobody serious tries to do it anymore. It's not practical. So now all of these are interesting questions and they're all things that people disagree on, obviously. But they're things that people hold with very, very strong conviction, that this is clearly and just irrefutably true. Now I'm not interested in convincing you of any of these claims. Each of these could probably be great talks. What I'm interested in is why we disagree about them. Why isn't that we all converge on an answer to these questions? Now it's funny because when I was in the poker world, I remembered this. This was very familiar to me when I was learning how to be a poker player because in the poker world people will tell you things like no limit is dying, you have to learn mix scans. Or they would tell you everybody needs to use a HUD. Or they would say only fish play loose passive styles. They would say GTO is a fantasy, nobody actually plays like that. And there's a wonderful analogy between these two worlds. Not just that people argue a lot and that people are maybe kind of whiny and excessive. But there are all these things that people fundamentally disagree on and each side of them holds tremendous conviction that their side is clearly and obviously correct. And so when most people hear stuff like this, when they hear someone say hey everybody should know C and if you don't know C you're not a real programmer, their natural reaction is oh god, is that true? And if that's true what should I do about it? But for me, having gone through this song and dance so many times, my reaction is why do they think they know that? And what is it that implanted so much confidence in them, so much conviction that the thing they're saying is actually true and universally true. And that's very interesting to me. It's almost like I tend to ask a more evolutionary question than a question about the world as it is right now. The thing that's kind of weird about programming in particular is that nobody agrees. There's so many things that people disagree on. They disagree about functional programming, object-oriented programming, TDD, old, robust proven frameworks, shiny new ones that solve new problems in different ways, ridiculous, adventure, blah, blah, blah, blah. You guys know all this. Nobody agrees why. That's really weird. Now you might think it's obvious that people don't agree. That's an understandable reaction. You might say, well, disagreement is a normal part of a society and the way that we, this divergence is a source of discourse and that's how we end up having a healthy society. So you might think that's obvious, so of course people shouldn't agree. I think it's weird. I think it's weird that people don't agree and I want to develop in you an intuition to also believe this is weird that people don't agree because in a way it makes more sense for people to agree than for them to disagree. Another way of putting what I'm saying is that systems in general tend to converge. When you see a system you should assume that over time it's going to converge on what's optimal, what's sort of the optimal state for that system. Let me give you an example. So I'm going to give you an example related to poker, but you don't need to know anything about poker in order to understand this. I can explain it in a couple sentences. So in poker there's a strategy called set mining. Set mining is very simple. So in Texas Holden you get two cards and if you want to set mine what you do is you wait for two cards that make a pair. So let's say you get delta pair and threes. Then what you do is you wait to see if you make three of a kind. If you make three of a kind you bet it really aggressively and if you don't you just fold. That's set mining. Super, super simple.  Almost anybody could do it and it worked. It worked really, really unreasonably well given how simple the strategy was. And so pretty soon what you would see in the world of online poker is that pretty soon when people started talking about this almost everybody started set mining at low to mid stakes for ring ends. The strategy just kind of took over like wildfire. And what you could say is that the game converged on set mining. Everybody saw that set mining was the high ground and they all moved in that direction. And so this is kind of one of the features that happened to poker after Internet poker took off. Internet poker took off really around 2004, 2005 maybe a little bit before that as well. And if you think about it before Internet poker ever existed there was live poker, right? Playing poker in a brick and mortar casino. And live poker was fundamentally really different than online poker in ways that people didn't really predict before it happened. So you can imagine live poker, let's say in the 80s and 90s, there are some people playing poker out in Phoenix maybe there are people playing poker in Vegas, there are people playing poker in Dallas, people playing poker in London. And these different groups of poker players weren't really communicating with each other. Ideas that were germinating in London weren't going over the pond and showing up in car rooms in Dallas, right? People were kind of isolated to their little groups and they were just playing poker and figuring things out as they went. But with the advent of online poker and the communication that it enabled for a lot of people, sorry there was like a fly running around me, with the advent of that communication what happened was that it allowed the system to converge where suddenly somebody has an idea for a strategy somewhere in Dallas or New Hampshire or wherever and suddenly they can share it and everybody can learn about this strategy very, very quickly. And so what this meant was that the state of poker strategy for a long time it was pretty static. The way that people played in the 40s and 50s was not that different from the way people played in the 80s and 90s. Information just wasn't able to evolve that effectively. But with the advent of online poker suddenly if you look at the curve of the complexity of poker strategy it just takes off right after 2003 when online poker comes to town. And so right here is a graph that audio is not playing but that's fine, he's saying look at this graph. This is a joke that didn't play audio, that's fine. We're going to roll with it. So this is actually just a graph that goes up into the right and has nothing to do with what I'm talking about but I thought it would give a sense of legitimacy to the slides. This guy knows what he's talking about. Look at this graph. So the point is, online poker converged in a way that live poker never did. It was never able to. And this to me is it makes a lot of sense. Of course online poker is going to converge. When do you have these people able to communicate to see what each other is doing and move around in this terrain? Of course they're going to settle on what's optimal.  So let's say for example you're walking downtown and you buy a loaf of bread, maybe you're French, I don't know. And let's say you eat half the loaf of bread and you toss the rest on the street.  But pretty soon one pigeon comes, three pigeons come and then a chorus of pigeons from presumably all over town just come in and start just binging on the piece of bread that you've left. And this kind of makes sense. The pigeons are able to very quickly come down to whatever is the optimal place for them to be. They eat as much food as they can and they disperse back to wherever it was they came from. Maybe to the next best piece of food that they can find somewhere downtown. So that's an example of a convergent system. So there's also this great Ramstein album that actually I love when I was a kid. This is actually just cell membrane in German because that was the only one I could find like 10 minutes ago. But the cell membrane you guys might remember from high school chemistry, they're water molecules on one side, they permeate through this membrane and pretty soon you've got the exact same pressure, the exact same density of water molecules on each side of the membrane, the system converges. And you see the same sort of thing in stock markets, a lot of natural phenomenon. It seems like this sort of thing is everywhere. So when I started working as a risk engineer at Airbnb working in the fraud space, naturally I started looking for convergence too because it just seems like one of those things that any sufficiently complex system should eventually have some optimal state and it should find convergence. So working in the fraud industry is its own little subculture, its own little world. And the subculture is not just the subculture of people working against fraud, which is interesting but that wasn't really what fascinated me so much. I mean it is very interesting, but the really fascinating thing about fighting fraud is that you're actively fighting against a community of people.  And so really there is actually a subculture that I can't see and don't have direct access to that's organizing and trying to attack all these major online companies and they're trying to make money. And that's really interesting. And so I wondered how do fraudsters figure out what to do? I mean what they're learning is pretty non-trivial. They're learning how to script, how to do sometimes cross-site request forgery stuff, XSS, whatever.  How do they learn this and how do they communicate this to each other? How does this knowledge spread in the world of fraud? Fundamentally the question I want to ask is is there convergence in fraud? And this actually pretty soon after the new MacBook Pro replaced the escape key we saw fraud go way up. So that was one person left of that. There we go, there we go. Just a little bit, that's all I need in order to keep going. Awesome, so I just want to run with you through a quick example of kind of what a standard fraud scheme looks like. This is some site called Shipmunk. Does anyone know what Shipmunk is? Anyone familiar with this esteemed company?  So Shipmunk, let's say they cut some corners, they kind of implement a feature they don't really know exactly. They're not really thinking about fraud when they implement this, right? Like some product manager is like, hey, we've got this story, we've got to get up the end of the week, we're going to all look good once we fill this thing out, great. Engineers who work on this just push it out, don't really think too much about it. So this feature is essentially some micro deposit where essentially they verify that you own this account and do it in amounts, you report them back, right? Pretty standard for some financial institutions to do this sort of thing. So let's say that they don't implement rate limiting. Easy thing to overlook. Well, you know, they go to sleep that night feeling great that they've launched this new feature and pretty soon someone gets alerted, let's say at 2 a.m. that night, that somehow we've lost $100,000, which really should not have happened.   They go and they try to patch this whole, implement some rate limiting, do some rules, maybe reverse whatever transactions they can. This is a common type of attack that, you know, a very easy vector that if your site influenced something like this, a kind of attack you would be vulnerable to if you didn't implement rate limiting. Let's say they get that under control, that's fine. Now what happens is that once you patch that vulnerability, of course the fraudsters disperse. They don't keep hitting it, maybe they try to verify that in fact it is patched, they try a few ways around it, it doesn't work, cool, you've patched the vulnerability and the fraudsters disperse. But kind of like the pigeons, they don't just go randomly to different places and just kind of leave your platform. What ends up happening is that they then go to the next best place to defraud you. So what they'll do is they'll find, that endpoint wasn't that good, but there's this other thing that we can do, like this maybe longer, more complex or more expensive fraud scheme, and we're going to go do that. And basically what you see is that the fraudsters head down to the next highest peaks in this terrain of fraud. Which, you know, this totally makes sense. This is convergent behavior, right? This is exactly what you'd see if the terrain suddenly changed, this peak became a valley, and they would go towards the next highest peak. So this seems to be like convergent behavior. It seems like fraudsters converge on what's optimal. But the more that I thought about this, the more I realized that this didn't totally make sense. And the reason that this totally didn't make sense, because I asked the question, why are they defrauding us at all? Why are any fraudsters attacking shipment? This might seem like a weird question, right? Like of course they're doing it so that they can make money and that's what fraudsters are motivated by. But if you think about it, the terrain of all the companies that they can defraud is huge. There are many, many, many companies that are vulnerable to fraud. And pretty much all of these companies experience fraud to one degree or another, right? There are all of these different sites that you could attack if you so wanted. And so what you can say is that there's some topology to that fraud, right? There are some peaks and valleys.  And so you would think that everybody would converge on the peaks. What you think is that almost all of the fraud would go towards the very most profitable, most attackable websites. But what you see instead is that fraud is just kind of dispersed everywhere. There's just sort of ambient level of fraud that if you start an e-commerce site, chances are that you're going to get some amount of fraud. Why? This is weird. This should strike you as weird. Why is it like those fraudsters just don't care about optimizing? Are they not trying to make the best use of their time? Is there something that they're misapprehending about the terrain? Like what's going on that we don't see this convergent behavior within fraud?  You know, even just looking at open-source solutions, there's so many different software packages and so many different open-source solutions to many, many different problems that are effectively, you know, trying to do the exact same thing. Why? It seems like software doesn't converge either. When you don't get this just one, okay, this is the best way to solve this problem, and everybody converges on that solution, what you see instead is many, many, many competing solutions, and it's not really clear which one is supposed to win. And when one does win, it's actually really surprising. You know, like, so, you know, React, you could say kind of one front-end UIs, and so far as you can say anyone won front-end UIs, and we're genuinely amazed by that on some meta level.  No one ever wins anything anymore, but React just won front-end UIs, you know?  But I think this is somewhat counterintuitive that more things aren't like this. Why is this such a rare story that React wins or SQL wins or one particular way of solving a problem just is clearly the best and we all adopt it? So you might have an obvious objection to this analysis, which would be that, well, of course, you know, things aren't going to converge because software doesn't just solve one problem, right? The obvious answer is that they're actually multiple terrains. So, you know, you can say that there's a terrain for pred-apps and that looks different and then there's a terrain for payments back-ends and then one for social networks and maybe the tools and the solutions that you use for these different apps are different and that's why you see this, you know, these multifarious solutions to effectively the same problem. But I don't think that's sufficient because even within a single terrain, you don't see convergence. You know, even just looking at pred-apps, right? Pred-apps are, you know, they're the majority of what people build. That's the majority of web apps are just, you know, glorified pred-apps, maybe with, like, Elasticsearch on top and, like, because they're the vast majority of what people build, they're the vast majority of what people disagree on. So it doesn't seem to me like that's satisfactory to explain why we don't see convergence. And the thing is you should want convergence. Convergence is actually good because convergence means that we all see the underlying terrain, we all understand it, and therefore we all go and do the best thing. You know, in the world of software, for the most part, we're not actually competing with each other. We're actually all kind of, at least to some degree or another, motivated by each other's succeeding. You know, when someone invents a great open-source solution, actually everybody benefits from that and most software kind of works this way. So the question I want to ask is, why do these systems not converge? I think there are four reasons, and I'm going to go through each one. So the first reason why these systems don't necessarily converge is because the terrain is actually unstable. The terrain is changing. It's not just one configuration that you can just see, you know, see something out in the distance and decide, okay, that's a peak, I'm going to go over that. The fact that the terrain is changing means that you're not really sure if you do go in this direction that by the time you get there, the terrain isn't going to be different, right? It also means, of course, that your terrain is moving underneath you. So by the time that you, when you originally came into Ruby on Rails, we thought, wow, this is the hottest, newest, shiniest web framework anyone has ever come up with, and now it's 2017, and Rails is not the shiniest, newest, coolest framework anyone has ever come up with. And so the terrain has changed underneath you, and that makes it hard for people to actually converge when there's so much change going on. There was this article that someone wrote on Medium a little while back, How It Feels to Learn JavaScript in 2016. Even if you didn't read this article, I'm sure you have an intuition of what this thing said, right? And we see this becoming more and more, I don't know if I want to say a problem, but more and more of a characteristic of software that things are changing very rapidly, and it might be that pace of change is even increasing, which wouldn't be that unreasonable to expect, actually as technology grows more and more rapidly.  So say, for example, that Facebook has some kind of hole, some kind of things that fraudsters can attack. Let's say it becomes really easy to spam Facebook and do some kind of referral, click fraud, whatever stuff.  Well, Facebook goes in and they patch the hole, and now instead of making $20 an hour, you can only make $3 an hour. But in order for the fraudsters to disperse and find the next highest thing, they might be just incentivized to say, hey, I don't actually know how easy it's going to be to defraud anything else, because that might get patched too, and the terrain might just change out underneath me. So you know what? I'll just keep defrauding Facebook for $3 an hour. That's fine. At least I know this is working during the time that I had it. So maybe that's some part of the explanation of why you don't see this optimizing across the terrain. So the second reason why I think you see a lack of convergence in some of these domains is because of high switching costs. Okay? So let's say that this is the domain, let's say this is software, this is the map of the software world. And let's say that you live all the way on the bottom right, and the bottom right, let's say, is Rails Land.   Nothing will ever go wrong. Your code will be way more performant.  Things are going to be great. The problem with that, of course, is that for you to actually engage in that switch, let's say even you see what this person tells you and you agree with them, but this peak that they're pointing to is very, very far away. So in order for you to get there, you're going to have to go down into a valley, traverse a really, really long space until you can finally actually reap the fruits of what they were claiming was so great. And who knows? Because the terrain is changing, by the time you get there, it might not even be a peak anymore. Something else might have become a peak, or maybe the place where you were at could have become a peak. Who knows? And so this instability and this uncertainty makes people really unwilling to incur the risks of traversing the terrain and exploring. You see, of course, the same thing in fraud, just like I just mentioned with the Facebook example. And this whole thing, of course, is exacerbated by specialization. The more specialized you are, the harder it's going to be for you to convince yourself to engage in those high switching costs, right? Because really, specialization is just basically you finding your way to some local maximum. That's what specialization is. It's climbing as high as you can onto a local maximum. Once you're there, it just becomes really uncompelling to climb all the way down from that peak of specialization you've arrived at to go find the true global maximum, which might be very far away, and we've already talked about the fact that it's changing and uncertain. And so this makes it harder, the more specialized we are. Same thing with fraudsters. There are fraudsters who are specialized in attacking one side as opposed to another, and it's hard for them to switch. If we learn a lot of new things, they have to start over in their knowledge. And the third reason why I think you don't see convergence in fraud or in software or in these other fields is information sharing is a very important part of how you get convergence, right? If you think about it, not all of us can actually clearly and lucidly see that underlying terrain. You know, there are these peaks and valleys we know they're there, but they're sort of like a fog of war, right? And that we can't see just kind of beyond our local environment because we just don't know that much about what Haskell Mountain looks like or what, you know, some other language or framework that you're not familiar with. So in order for us to really get that sense of what the terrain is like, we have to share information with each other about what the terrain is. That's how we learn what happens if we go out far enough into the terrain and whether the costs are going to be worth it. So different cultures have different amounts of information sharing, and that makes it harder or easier for them to converge on different things. So if you imagine this, if you imagine a graph of different cultures, you can sort of graph them on how closed versus open they are in terms of information sharing. So if you look at a very, very closed system, a good example of this is the fraud industry. So if you're a fraudster, then actually it's very hard to learn and get access to the information that you need in order to learn how to become a fraudster, right? So there are all these underground fraud industries. So fraud is an industry in many places in the world where basically you can, you know, get access to courses, you can buy them, you can get primers on how to hack this site or that site. There are various tools that you can buy, you can pirate, whatever. There's all the stuff you need to get up and running as a fraudster, and it's not easy to get this stuff. You actually have to, you know, make your way into communities. You have to prove yourself. You have to gain reputation.  It doesn't exist. You can't do that. You have to go in through a very specialized way, and not all information is actually readily up for grabs. There are some fraud rings that just don't share their information with anyone outside of it, and it's not for sale. And so that makes it very difficult if you're somebody who's wanting to learn more about fraud to actually figure out what is the optimal place for me to be spending my time defrauding people. Now, so what's more on the open side is you can look at a world like poker. So poker is kind of a more open system, you know, so there are all these forums. There are different places where people can exchange ideas. There are certainly books written about poker that you can just buy if you want to. But the very best players, the very best ideas, the very best theories and strategies about poker, they're generally not for sale. You know, the people who hold them and the people who profit the most from them tend to keep them close to the chest. So you get a lot of resources that are okay or that are really crappy, that are openly available, but the very best stuff sometimes is hard to find and hard to actually gain value from. And then on the other hand, if you look all the way to the right, you find the world of software. In a lot of ways, kind of staggeringly open.  Or security libraries that are, again, like completely open source. And companies will just say, yeah, we use open SSL. Ruby. If you find a weakness in open SSL, that's a weakness in us, right? And this is really about as open as you can get. And there are blog posts, there are all these things that are shared about software that make it seem like, wow, there's an enormous amount of information sharing. That should really make it so that people can really quickly what is actually the best solution for any different problem. Somehow in the world of software, it doesn't really seem like that happens all that well. And so, I don't know, I think there's somewhat of an open question of even though there is a lot of sharing on the surface, if in fact there are some things that people aren't that open about sharing. Like, I think, when it comes to what a lot of large companies are doing when they're putting together a lot of open source solutions to solve problems, they actually don't immediately go out and tell people, oh, hey, we solved this problem and here's how we did it. Very often the way that companies share this information is pretty selective and pretty strategic. And the moment you solve a cutting edge problem, you generally don't go out and share it unless you think there's some strategic value in doing so. And so that, I think, to some degree kind of exacerbates the problem of why is it that we don't get this convergence in the world of software? So reason number four, and I think this is a really interesting reason is basically the problem of group identities. And we heard some this morning from DHH about the value of group identities and I'm kind of going to go at it from a completely different angle. I'm going to talk about more the dangers of group identity. So you can imagine that the world of programming is kind of it's demarcated into these different kind of arbitrary groups. One of the groups might be Rubius and you know Rails programmers or whatever, which you can categorize myself in there. Then you have Java lovers over here and Pythonistas over here and then scholars over there. And they're kind of these special norms that dictate what you can do inside these different worlds if you want to fit in into these groups. These groups kind of say like, well, if you're a Java lover, you can explore this area but you're not really supposed to go over there. That's kind of weird stuff that we don't really do in Java. That make it hard for you to just freely traverse and explore this terrain without violating some kind of social norm associated with your group. Turns out, you get the same kind of thing with fraud rates. So there's a fraud ring that just defrauds Facebook. That's all they do and all they do is they're talking on some sort of secret channel where only fraudsters that are part of this group can communicate and they share information about just how to defraud Uber or just how to defraud Google. And if you're one of the members of the other groups, maybe you can't get into that group. Maybe fraudsters are just decided, no, we're this group and you're that group and you're not going to get our information. And so if you want to explore, you only get to explore this terrain over there. And I think in the world of software, you kind of see this when, instead of having an explanation of blog posts, it's just here's how Kafka works. There's the blog post, Kafka for Rails engineers. Or the blog post, XYZ for Rubyists. And this again is kind of reinforcing that demarcation that hey, I know you want to go explore that stuff, let me show it to you in the way that's appropriate for our group. And I think this is really fascinating to me because being somebody who's relatively new to the subculture of software, I could immediately recognize this behavior. And I think it's pretty well explained by this theory of psychology called social identity theory. So the idea of social identity theory, as I mentioned before, essentially suggests that the way that we construct our identities as human beings is largely as a result of the groups that we adhere to. So this kind of goes in several stages. So the first thing you do is you start categorizing the world into social groups.  So first you have to draw those boundaries. Next, you have to identify which of those groups you belong to. Do I want to be a meat lover? Do I want to be a pythonesa? Do I want to be somebody who loves red? Whatever. You have to decide which of those groups you're going to identify with. Then, once you do that, the last step is social comparison. Now you have to do the pretty hard work deciding why the other groups are bad and your group is good. You have to make this distinction between your in-group and the out-group and invent some kind of story or narrative that goes along and reinforces why you're good and they're bad. So there are all these classic examples of this sort of thing where basically there's some arbitrary distinction that you've arrived on as being important to your social identification and there's no intrinsic reason why that should be important and because of that, they're bad and we're good. We have to come up with some sort of story why that's the case and they have to do the exact same thing. Now, you might think the social identity theory would suggest that, okay, well that should mean that all Rubyists and all Rails developers are the same but I don't really feel like that. I'm not the same as the people around me. If you look around, you all don't look like a completely homogenous group of people and this is true. So there's this other theory and it's called differential psychology. And differential psychology essentially examines the way that people within groups try to make themselves different from each other as a way of somehow strengthening their bond as being a part of that group. So for example, if you've ever seen the movie West Side Story, so you look at these characters, they're all part of a gang in West Side Story and they're all together, part of the same group and you can tell they kind of have a look. If you just saw these people on the street, you'd be like, okay, these people do something together. There's something that somehow unites them. But notice, they don't all wear exactly the same outfit and they could. They could all wear the exact same outfit. They could all style their hair the exact same way but they don't. Why don't they? Why don't they do that? You'd think that maybe that would strengthen their group identity. If they all literally did the exact same thing, they would be a stronger part of that group. So it's important for us to differentiate ourselves. We actually spend a significant amount of energy just differentiating ourselves within the groups that we're in as a way of almost masking our identities within that group. As a way to not make ourselves feel that, like, hey, I don't have any identity outside this group because I seem to be wearing the exact same thing everyone else is wearing and doing the exact same thing everyone else is doing. We'll expend a lot of energy in order not to feel that. So that's exactly what you see is that there's something kind of similar going on when you look at something like this where we're expending this energy.  Even though we're talking about, you know, Kafka or Elixir or whatever it is, we're still keeping you as a part of this group and that identity is actually reinforced by you being here in every single way. Even the fact that you're going to these different talks, talking about different technologies, you're still seeing it as a Rails developer. And I think this is bad. I think this masks the severity of the problem of social identities making it harder for us to actually converge and actually find what is genuinely optimal. It allows us to kind of distract ourselves with this story that, like, hey, we're exploring these different things but really underlying it, we're not. So I think we should really want to find convergence. We should want to find the true global maximum. So as software engineers, what ought we to do about this? And I don't know that I have perfect answers to this. I think these are all really intrinsically hard problems but I do have a couple of pieces of advice that hopefully might be instructive to some degree. So the first piece of advice is an adage from Paul Grammer initially, where he said, keep your identity small. And really kind of what this means is to, as much as you can, as much as is possible, jettison the labels that you've very easily come to identify yourself with. And so that's to say, you know, don't think of yourself as a Rails developer or as a Ruby developer. But instead, think of yourself as a software engineer such that whatever ends up being the right tool for the job, and that tool might be Rails, might be Ruby, might be something else. That's what you fundamentally use. You solve problems in the world of software. And right now it might be very beneficial for you to go climbing up this hill of learning more about Rails or more about Ruby. But eventually you will not be. You can imagine 10 years from now, you'll be working on something, and Rails probably won't be the tool you want to use 10 years from now. In fact, I would, right now, I actually consider myself to be, I love Ruby, I love Rails. I think they're really awesome and wonderful tools. I was a Rails developer 10 years from now. And that was what I considered myself to be. I'm a Rails developer. You know, when DHH was talking about the article about COBOL programmers, that, you know, there are people still making money for banks working on these super antiquated COBOL applications, you can bet that there will still be Rails apps 10 years from now. And I'm sure that you'll probably be able to fetch a pretty penny, you know, basically managing these 10-year-old, 12-year-old, 15-year-old Rails apps. And that's basically what you want to be doing. Or is what you want to be doing to solve problems with software, however those problems end up changing, and however those tools end up changing. The second piece of advice I want to give, besides keeping your identity small, is pretty obvious, is just to explore the terrain. And exploring the terrain, to me, it means more than just kind of, you know, paying lip service to different things. They'll be like, oh, okay, I don't know what Kafka is.  It means fundamentally to do things you've never done before, okay? It means to do things that are kind of scary to you. It means to take real risks. And when I say real risks, I'm juxtaposing that against fake risks, which I think are a real thing and something you should caution yourself against.  No, you're not. No, you're not, right? The risk comes when you give up, you actually walk down the hill. And walking down a hill is uncomfortable. It's scary. It makes you nervous. And if you're not actually doing that, then you're not really taking a genuine risk. Another way of saying this is go to DjangoCon.  But if RailsConf is the only conference you're going to this year, reflect on that. Reflect on what that means, whether it means that you are actually taking risks that are important. And finally, of course, I think the most important part of exploration is just to have fun. And when you let go of the idea that you constantly need to be moving up and that in fact it's okay to move down and to take risks in a way that potentially make it harder for you to get your job done, but that's okay and allow yourself to have fun doing it. And I think that makes the whole process a lot easier. So that's it for me. I'm Haseeb Koreshi, a software engineer on risk at Airbnb. If you're a senior software engineer or a data scientist, we're always hiring. And yeah, thanks for listening.