# Shell tools are incredibly useful

So this is a small post on something pretty cool I was able to do that I thought was worth sharing.

This summer I’ll be doing research on speedreading as well as taking a course for school called Cyber Physical Systems.

I got interested in the question of whether I’d be able to speedread the course materials. So I downloaded the transcripts and took a look.

The transcripts all come in the form of .srt files which are a little inconvenient to work with, and there was a LOT of them, 302 to be specific.

$ls -la ./transcripts/* ... -rw------- 1.2K 89 - Intro to Industrial Networks - lang_en_vs1.srt -rw------- 2.8K 9 - Class Structure - lang_en_vs51.srt -rw------- 3.0K 90 - Industrial Control System - lang_en_vs51.srt -rw------- 2.1K 91 - Industrial Protocols - lang_en_vs51.srt -rw------- 3.8K 92 - Routable Networks - lang_en_vs51.srt -rw------- 2.8K 93 - Enterprise or Business Network - lang_en_vs51.srt -rw------- 1.8K 94 - Zones and Enclaves - lang_en_vs51.srt$ cat ./transcripts/* | wc -l
38744

# here's a random file in the corpus for an example of what we're dealing with.
$cat 93\ -\ Enterprise\ or\ Business\ Network\ -\ lang_en_vs51.srt 1 00:00:00,360 --> 00:00:03,340 An ICS is really an isolated network. 2 00:00:03,340 --> 00:00:08,270 For every factory floor, electric generator, petroleum refinery or 3 00:00:08,270 --> 00:00:11,450 pipeline, theres a corporation or organization that owns and 4 00:00:11,450 --> 00:00:12,850 operates the facility. . . .  So as you can see there’s a lot of space being wasted and a lot of cleaning we can do here.  # let's concat all the transcript files in numerical order into one file for i in {1..302}; do cat$i\ * >> OUTPUT; done

# then I'll use vim to open the massive file and start carving it up
$vim OUTPUT # delete all empty lines :g/^\s*$/d

# delete all lines containing only numbers
:g/^[0-9]$/d # remove all lines with timestamps :g/^00\:*/d # removed all <i> tags and removed all </i> tags :s/<i>//g :s/<\/i>//g  These steps together trimmed over 12000 lines of needless text. I then converted from windows to unix line endings : tr -d '\15\32' < windows.txt > unix.txt  To remove the &gt;s I highlighted the entire corpus and just cleared them out. :s/&gt; //g  Text all looks like this : And we earnestly hope that it will prepare you to secure the next generation of cyber-physical systems. We're eager to hear what you end up doing next. The fate of the world is in your hands.  To clean this up a bit I replaced all \n\n with a single \n. Now it looks something like this : the low voltage looks like. We can add to the lower terminal power a little power supply to the low or common terminal, connected the high terminal of the power supply to the input switches. That's all it took to simulate our system. So now we know how the system was set up. So how's the PLC actually programmed? For this project, we programmed the PLC using which is a graphical programming language that is based on the old practice of programming logic with hardware relays. The programming environment that we . . .  It’s not perfect but very usable for my purposes, as I wanted the filtered raw text to put into another platform. There were a few other cleanups like removing [INAUDIBLE] from the corpus. My original input size of 38744 lines was down to just 7000 lines. That’s just 18% of text content that actually needed to be there!! Fun stuff. The lesson here? Learn the shell tools. They are so great and will come in handy all the time. Now it remains to be seen whether I can speedread the entire course in an hour. Wish me luck! # Let's learn general relativity Hello there! It’s 4/20 and I hadn’t written a blog post in a little while. Instead of the devil’s lettuce I thought, “what better activity could we do?” So let’s clean off the spider webs and crack open our physics textbooks. We’re going to derive the Einstein field equations! I assure you, they’re a hoot and a half! Or at the very least you’ll see a lot of corny Pythagoras jokes, and that’s just as important. Readers should know that general relativity is something you’d only really understand after taking a graduate course in physics. This blog post is not a substitute for that course. But this post does show you a lot of the concepts that were relevant for deriving the theory. The majority of the derivations here were originally published and refined by Einstein between the years 1905 and 1915. Don’t worry about the math, what’s much more interesting here (for me anyway) is the concepts and how they came about. ## Introduction ### History Part of the appeal of learning these equations is the fleeting feeling that perhaps you’re on the same intellectual footing as one of the greats such as einstein. Einstein has always had a perception of being one of the greatest physicists of all time. I think that this perception is a little bit unfair to the other scientists who were doing incredible work at the time. I want to start this post with some background on einstein that I found in a very insightful comment on reddit. Here’s a portion of that comment on how einstein came to be seen as synonymous with intelligence. In the early 20th century, there were a handful of scientific heroes. Many of them have not persisted in /public imagination. Almost nobody outside of the sciences today is going to know who Robert Millikan is, but for a time he was the most famous scientist in the United States, for example. Einstein’s international fame was the result of several distinct events that led him to be branded as “revolutionary” on a level above and beyond his peers (and perhaps above and beyond his accomplishments). In 1905, when Einstein published his first papers on relativity theory, he was virtually an unknown. For the next decade, he became a little better known in the community of physicists, but even then practically nobody worked on relativity without having a direct personal connection to Einstein in some way. If you look back on those papers with a sober eye today, they are interesting, and the fact that all four of them came out in the same year is rather impressive, but they are not heads-and-tails more revolutionary than other work being done at the time. The paper on the photoelectric effect (for which Einstein got the Nobel Prize in 1921) is important in that it shows that Planck’s idea of the quanta has physical meaning (and is not just a mathematical heuristic, as Planck thought it was), the paper on Brownian motion is an interesting (if not strictly necessary by that time) way to argue for the physical reality of atoms. The$E=mc^2$paper is an interesting derivation but it was not at all clear it had any physical reality (and nobody, including Einstein, thought it had any practical applications). The length contraction/time dilation (special relativity) paper is an interesting approach to a curious physical puzzle (what happens if you take Galilean relativity seriously, but believe the speed of light is invariant?), but again, doesn’t really get you anything obvious out of the physics, and it wasn’t clear if it was physically real or not. In short, these papers did not shake the world up, but a few people took note. Awareness of Einstein perked up a bit in the 1910s, as he was one of the only German professors to protest against World War I (both the English and German professoriate were largely belligerent and issued long “manifestos” in the name of their countries). In 1915 he published his theory of General Relativity which was much more mathematically complex than his previous work, and much more ambitious in terms of its implications. Here was a new theory of gravity, in the end, one that would explain anomalies with Newton’s theory of gravity, but also would explain what gravity was in a way that Newton could not. This would be of much more interest to astronomers, if it were true. Ironically, perhaps, the place where the most latent interest for General Relativity would exist was the United Kingdom, in no small part because the mathematical training required as part of the British tripos system made the British scientists on the whole much more competent at such matters than those scientists on the continent (the German tradition of physics was more strongly rooted in experimental procedure, and the math of General Relativity is of a high-enough order that your average German experimental physicist of that time was not really capable or interested in dealing with it). One British astronomer/physicist, Arthur Eddington, decided in the postwar period that it would be a really splendid thing to see if Einstein’s theory was correct. Eddington had more than scientific motivations: he was a British Quaker, and he thought it would be an impressive demonstration of the unifying powers of science if, in the wake of the Great War, he were to undertake an expedition to prove correct the theory of a German Jew. What could be more international and pacifistic than that? So Eddington put together an expedition to the island of Principe to take photographs of stars near the edge of the Sun during the total solar eclipse of 1919, which, if combined with photographs of the same stars when seen from that position at a time when the Sun was not in the sky, would allow one to see if the starlight had been bent by the gravitational field near the Sun (a prediction of General Relativity). Eddington found that this was so and undertook to /publicize this discovery widely — Newton had been overturned. This received national newspaper coverage worldwide. Now Einstein started being known as the guy who overturned Newton. He quickly became an international celebrity, and he capitalized on this by traveling much, giving lots of lectures (which also conveniently got him outside of Germany, where anti-Einstein and anti-Semitic forces were mobilizing), and writing at length on lots of topics. Because Einstein was not just interested in science. He wrote at length about philosophy, politics, socialism, pacifism… he made a name for himself not just as a scientist but as a /public intellectual. Which, it should be said, still might not have cemented his long legacy. Other scientists did such things. It is not at all clear that Einstein was truly the most intelligent man of his time. He had a lot of competition — there were a lot of smart people around then, including people whose contributions to physics were no less enduring. There were also other /public intellectual scientists of the time, many of whom have been forgotten to all but science historians. Einstein’s physics is clever, but it is less “out of the blue” than it looks if you look at it in its context than in isolation. (Typically when Einstein’s work is taught, it is taught in juxtaposition to people like Newton, not in juxtaposition to the science of his time, which is largely forgotten. If you put Einstein’s work up next to, say, Lorentz and Poincaré, it looks more “of a piece” with what was being done at the time, and his early work looks relatively crude. This does not diminish it, but it is a lesson about the difficulty of properly assessing a scientist without looking at their actual context.) With that background in mind, Einstein’s work is some of the most important physics that’s happened in quite a long time. This post is going to discuss a lot of the mechanics underneath Einstein’s theory of general relativity, and hopefully give you an understanding of how it came to be. ### Math So let’s start with some basic assumptions that i’m making about you, the reader. You should know some calculus and a little bit of linear algebra. It’s gonna come up unfortunately. ### Equivalence If you’re in a room with no windows, you can’t tell the difference between being in a box that’s accelerating through space accelerating at$g$, and a box that’s on the earth while experiencing the same force of gravity$g$. That’s essentially the equivalence principle. Now on earth specifically the value of g varies due to tidal forces but that’s not really the point here. ### Curvature of light You’ll also need to know that light bends when traveling through a gravitational field. Let’s be more specific. Imagine you’re traveling in a windowless room that’s accelerating upward at the speed$g$. If you shoot a laser horizontally across the room you would expect it to land at the same height on the other side of the room. Now of course light travels forward and if the windowless room is accelerating we observe something different. As time moves forward and the room moves upwards, the landing height will become lower and lower by the time the light reaches the other end. The first of what is sure to be many diagrams in this blog post. So the light was pointed horizontally forward, but when it reached the other end of the elevator the light was lower on the other side of the room. The light curved. Because the equivalence principle tells us that we can’t tell the difference between this situation and the situation of the stationary situation on earth when influenced by gravity that results in an interesting conclusion that must be the case. That the light must be curved by gravity in order to be true. It turned out to be proven during a solar eclipse (that story about Eddington from the history section) when they were able to see a star that appeared to the right of the sun, despite astronomers knowing for a fact that the star was behind the sun. This meant that the light from that star was being bent around the sun. Newton’s laws of gravitation gave us a simple way to look at gravitation at that time. note: here$G$is the gravitational constant,$M$and$m$are the masses of the two objects, and$r$is the distance between them. But light has no mass… why is it being affected? This was the central problem, and the whole point of why this was a huge deal. Einstein says to imagine that spacetime is like a trampoline. When you stand on a trampoline you’ll notice that the space in the trampoline indents around you in response to your weight as you sink in. Apparently standing on a trampoline is the best allegory for spacetime that physicists could come up with. If you put a marble near you and stand on the trampoline, you’ll notice that the marble rolls towards you. Newton believed that this was because of the gravitation between the two objects. Einstein believed that this was the marble moving along the shortest path in curved spacetime. He went on to argue that the same thing was happening on the planetary scale as well. That the earth is rolling along what is really a straight line in curved spacetime around the “disturbance” caused by the mass of the sun. note: when we say spacetime here, what we’re referring to is 3 dimensional space coupled with time. also space and time are “the same thing”. (It’s more honest to say they’re intertwined, but physicists aren’t honest.) Here’s why: It started when Einstein showed that some basic laws of the universe affect both space and time equally. For example when a train is moving really fast a strange thing happens: People who are watching the train see that the time for the train and people inside it slows down. People inside the train see that the distance in front of them is getting shorter. These observations are not in contradiction, both groups (the observers and the people inside the train) are equally right even though one of them is seeing the time is affected and the other one is seeing that the space is affected. So we say that spacetime is affected. Yes, time is slowed down for those on the train. That is what Einstein discovered. The faster the object is moving the slower its time seems for those who are observing it. It is called special relativity. This only becomes significant if the object is moving extremely fast, close to the speed of light. There is also general relativity which says that also gravity affects time, stronger gravity will slow down time more. Note that the people inside the train will perceive their own time normally, it will only seem slower to the people outside the train. It is also interesting that the poeple inside the train will see that the time is slower (not faster!) for those outside the train. This leads to so called twin paradox and is actually hard to grasp at the beginning, you may need to read something on special relativity. ## The Field Equations This is the formula communly known as the “Einstein field equations”. Here,$\mu$and$\nu$can be any of the 4 dimensions (values 0 through 3). (accounting for the 3 dimensions and time) Every single parameter can be substituted in any way and the equation will still be true. In this sense it’s more like 16 equations. There are a few duplicates so they reduce to about 10 equations. The other constants are ones you’ve seen before: you know it’s an important equation when it contains the cool stuff like$\pi$and$c$. So the whole point of this equation is that it balances two things: • The left side refers to curvature of spacetime • The right side is about mass and energy. These equations show us that mass tells spacetime how to curve and that curved spacetime tells mass how to move. if this information is satisfactory for you then you can stop reading now, the rest of the post is all math, and who wants that? ## Metric Tensor Imagine you are a person standing on a grassy field with lots of hills and you wanted to model your height above sea level as a function of where you moved. So you start at your original position in this field from fixed point ($x$,$y$). And let’s represent our height as$\phi$. Now when you walk straight through a field with hills you’ll walk up some hills and down others which of course is a change in height. So to represent our height as a function of which direction we walk in, we will use the following equations for the$x$and$y$directions. These two equations essentially say that the change in height ($d \phi$) can be derived by multiplying the rate of change in that direction,$\frac{ d \phi_x}{ d x } dx$(also known as the gradient), and the actual distance you moved. So if you walk 5 meters down a 1/10 incline, than you’ll be 1/2 a meter lower. (shocking I know.) becuase$ d \phi_x = \frac{1}{10} \times 5 = \frac{1}{2}m $So this is a quite general form. The value of our field is multiplied by the gradient, or change in field, times the distance you traveled. Of course a 1/10 slope isn’t going to happen at your grandma’s favorite park, but it will happen at much smaller distances! (This is why we have$dx$. Which means unfortunately calculus is probably involved.) We need to deal with one other thing. People don’t walk in boring straight lines like$x$and$y$. Straight lines suck! So let’s get a little more abstract. Any path along a$2d$field is going to involve components of$x$and$y$. So let’s represent all possible paths as a combination of the two in a more generic equation. We’ll call our combined path$s$. If you’ve done literally any physics ever you know that to combine these vectors we need to talk to the hotdog choreographer himself, mac daddy pythagoras. this will give us the magnitude (or length) of the combined vector$s$. Of course we can add these vectors as well. So our representation of height as a function of movement along path$s$looks very similar, we’re just adding the changes in height contributed by the movement along each direction. if you needed more foreshadowing here, you can probably abstract this concept to as many dimensions as you want… This means that we can do another substitution based on what we’ve already done earlier with the$x$and$y$direction and add in our definitions for$d \phi_x$and$d \phi_y$Yes I know, we switched from$d$to$\partial$, this is just a semantic distinction to make clearer for the math people that the rate of change is specific to the variable we’re looking at in that term, but not the only rate of change we care about. So up until now we’ve been using$x$and$y$. Again we could use any set of coordinates here, variables are just labels after all. So let’s abstract further, and our equations that we’ve been building so far will use different variables. We’ll switch$x$with$x_1$and$y$with$x_2$. That leaves us with the convenient feature of being able to consider further terms and abstract to as many dimensions as we want. So we can go up to$n$dimensions. Equation 1: $$d \phi = \sum_n \frac{ \partial \phi_{x_n} }{ \partial {x_n} } dx_n$$ That weird$\sum$just means we add up all the terms based on$n$, if$n$is$2$we’d get the equation above we just made. On a totally unrelated note look how awesome that math term looks. You just know we cooked up some serious bullshit right there… uh, let’s continue. Now we’ve done a lot of math relating gradients and their effects from the reference frame of a single observer about their height as they walk through a field. Now we know from earlier that time and space are related in strange ways that result in time dilation and length contraction. That “reality is observed differently” by observers in different reference frames. If we’re ever going to make a statement that’s universally true, it has to be true in every possible frame of reference as well. The first thing we’d need to be able to do is model the two reference frames and relate them. So if two people are walking through the same grassy field, how would we model all the gradients of person$x$from the perspective of person$y$? Well it turns out we can do this. Let’s say we want to model all the gradients of person$x_2$: we’d use the chain rule to parse out what that looks like. I’m going to use$y_1$reference frame as an example. Meaning observing all the gradients of x from an observer in the “y_1” dimension. That hill analogy is certainly getting a little strange but bear with me. Now you’ll notice this can also be abstracted to an arbitary number of dimensions. Equation 2: $$\frac{ \partial \phi }{ \partial y_n } = \sum_m \frac{ \partial \phi }{ \partial x_m } \frac{ \partial x_m }{ \partial y_n }$$ note: here we’re using$m$as our summation variable, and using$n$as an identifier for the dimension of our observer. We don’t have to be using$y_1$here, it could be$x$,$y$,$z$,$t$,$etc.$### Tensors So it’s about time we talked about tensors. The whole point of all of this crap has been to talk about the metric tensor yet we still haven’t gotten to it. Let’s talk about what a tensor is for a bit and then we can get to the good stuff. Equation 3: the vector transform $$V_y^n = \sum_m \frac{ \partial y^n }{ \partial x^m } V_x^m$$ We can modify our equations from earlier a little bit to develop something you could call the vector transform. Essentially meaning that the$n$th coordinate of a vector in the$y$frame of reference is equal to the sum of the gradient term times the$n$th coordinate in the$x$th frame of reference. The idea here is essentially for a vector with$n$coordinates we can construct a representation of a vector from the perspective of$y$by “transforming” the vector from the x representation. It will be helpful to start with scalars first. A scalar is a quantity with no direction associated with it, temperature is a good example of this. Contrast this with a vector which is just a scalar with a direction (like velocity). You could think of a scalar as a tensor of rank 0. Then a vector is like a tensor of rank 1. Now a tensor could be thought of as a combination of vectors where there is a fixed relationship between the two. Imagine the example of a block being pushed by a force: try to ignore that weird angle bend in the image i’m trying my best here. So there are two forces here,$\vec{F}$and$\vec{G}$, note that only$\vec{F}$actually moves the box, and it’s moved a distance$x$. If you imagine that$\vec{F}$is the only force acting on the box, we know that the work done on the box will be equivalent to the force times the distance along the direction that the box moves in. Now of course there’s an$x$and$y$component to the force that’s acting diagonally on the box so we have to do something different here to evaluate the work done on the box in the$x$direction and we can resolve that problem pretty quickly. So that’s all fine. Now lets think about$\vec{G}$. The work done by$\vec{G}$is$0$because$\cos{90}$is$0$. But more obviously if you push down on a block it won’t move. This basic mechanics example has an important property. No matter what reference frame you view$\vec{G}$from, the outcome is exactly the same. The block does not move. A tensor is the relationship between two vectors. If a tensor has a value of$0$in one frame of reference, it has a value of$0$in all frames of reference. The block never moves. You might guess that this concept is going to be very useful in our discussion of Einsteins theories of relativity. Ugh I sound like such a textbook. Let’s bring it on home. Imagine two vectors (who cares what they are): We’ll look at the$m$th dimension of$A$and the$nth$dimension of$B$. We’ll say that the combination of the two creates a tensor of rank 2. Now there’s something important to point out here, which is that$m$and$n$are dimensions. In our examples so far we’ve been in the$xy$plane so$m$and$n$both are either$1$or$2$. This means there are four possible tensors to create between the two vectors. If you have$3$dimensions in space, then there are 9 different versions of$T^{mn}$and so on. Now what would$A$and$B$look like from the reference frame of$y$? Let’s use our equation 3 from earlier. So now let’s simplify that a little bit with some condensing, and we get toooooo Equation 4: the contravariant transformation $$T_y^{mn} = \sum_{r,s} \frac{ \partial y^m }{ \partial x^r } \frac{ \partial y^n }{ \partial x^s } A^r_x B^s_x$$ You’ll notice that this is an equation that enables you to transform$A^r_x B^s_x$, (better known as T_x^{rs}) into T_y^{mn}. Hence it is known as the contravariant transformation. If you’d like to make this harder to understand feel free to check out wikipedia. this is getting harder to follow along in an obvious way. I know. I’m sorry. For what it’s worth, writing this all out and formatting the math has been a nightmare. Here’s an alternate version of equation 4 that you should know about Equation 5: the covariant transformation $$T_{mn}(y) = \sum_rs \frac{\partial x^r }{ \partial y^m} \frac{\partial x^s}{ \partial y^n } T_{rs} (x)$$ Now we’ve come a long way talking about a lot of stuff that’s not the metric tensor. Like most physics textbooks we’re going to continue that trend by taking yet another look at the justin beiber of philosphers, that’s right. The mac daddy pythagorean theorem. Like good physicists we’ll draw a fun diagram and apply what we know to arrive at something we don’t. Afterwards, again like most physics students we’ll think we understand it after reading it and then fail to reproduce it in the future. Let’s examine this example triangle. Obviously the variable names for the lengths of the sides are completely coincidental. We’ll start with an initial pythagorean understanding of the situation. Now what you might have heard is that the phantom menace pythagoras wrote a theorem is actually just a specific instance of a more generalized rule. We can actually expand it out. Then we can restate it. Now for this to still be consistent, we have to make sure we’re not taking any products we don’t want in the sum. And so that’s that that$\delta$is for. That$\delta$there is the Kronecker Delta. The kronecker delta is a funky machine. Essentially on every iteration of the sum operation for new values of$m$and$n$,$\delta$is evaluated to be either 0 or 1. So if$m = n$then$\delta = 1$, and otherwise$\delta = 0$. The delta is essentially a scaling factor so we can take it out like anything else. Now we can use our definition from before: When we apply that to our working definition of$ds^2$, Now we’ve got something quite powerful. Let’s just rearrange this for a second. And there it is. The beautiful metric tensor. The metric tensor $$g_{mn} = \delta_{mn} \sum_{m n} \frac{ \partial x^m }{ \partial y^r } \frac{ \partial x^n }{ \partial y^s }$$ So… what does that really mean? Like most physics courses, we’ve barely said anything about physics for about 10 minutes and spent the majority of our time doing derivations. All we have is some cool looking math to show for it! To understand what the metric tensor is let’s look at the original sinetist (heh), pimp daddy pythagoras just one more time. Looking back at our more generalized approach from before, take a look at what happened. So our normal pythagorean theorem is functional for flat space. In flat space it’s perfectly true that we can use the normal pythagorean theoem. Now imagine we have that same right triangle drawn on a sphere. We wouldn’t be in flat space anymore, if we had the same right triangle on the surface of a sphere, we still couldn’t use meme lord pythagoras. So what the metric tensor gives us, is a device that corrects for operating in curved space. So i’m sure you can see how this is going to be valuable when operating in curved space. So our$g_{\mu \nu}$term works in that way, and that’s what that term is when looking at the field equations. note that the$\mu \nu$terms there are just a convention that is often used when talking about spacetime. Again, they’re just indicators for whatever dimensions you’re condidering. ## The Christoffel Symbols The important thing about tensors is that they represent a relationship between two vectors that’s true in all reference frames. let’s imagine a tensor$W_{nm}(x) = V_{nm}(x)$Here’s the problem. One thing that will come up pretty quickly when examinig tensors is that the derivatives of tensors don’t have the same powerful fixed properties that derivatives of vectors do. Are the derivatives of tensors the same? If we look at the derivative of$V$with respect to$x$in the$x$frame of reference, does that equal the derivative of$V$with respect to$y$in the$y$frame of reference. Does$ T_{mn}(x) = T_{mn}(y)$? Let’s look again at equation 5: We can use that and apply it to our question substituting$T_{rs}(x)$for$T_{mn}(y)$. We’re substituting it in which is why we’re using$rs$instead of$mn$. which simplifies : Again, what we’re trying to determine, is if$T_{mn} (y)$is equal to$ \frac{ \partial V_m (y) }{ \partial y^n }$. I’ll save some time here and just show what$ \frac{ \partial V_m (y) }{ \partial y^n }$is. $\frac{ \partial V_m (y) }{ \partial y^n } = \frac{\partial x^r }{ \partial y^m} \frac{ \partial V_r (x) }{ \partial y^n } + \frac{\partial }{\partial y^n} \frac{ \partial x^r V_r (x) }{ \partial y^m }$ note that the$\sum$still applies here. I just didn’t write it. Einstein actually believed that writing it out was trivial and that it was implied. So upon examination it turns out they’re unfortunately not equal. They’re quite close! If you look a little closer the only difference between the two tensors is those extra terms at the end of$ \frac{ \partial V_m (y) }{ \partial y^n } $. here’s those terms again just to be clear. Those extra symbols at the end there are called the christoffel symbols, and are often abbreviated as$\Gamma_{nm}^r$. So the question we asked was is if$T_{mn} (y) = \frac{ \partial V_m (y) }{ \partial y^n }$. We found the answer is no, however we can still work with this using something called the covariant derivative. Equation 7: $$T_{mn} (y) = \nabla_{n} \partial V_m (y) = \frac{ \partial V_m (y) }{ \partial y^n } + \Gamma_{nm}^r V_r(x)$$ The christoffel symbols exist as a correction for the transformation of the derivative of a tensor from one reference frame to another. So we did that for vectors, and now we’ll need to do it for tensors. So let’s look at the covariant derivative of$T_{mn}$. Equation 8: $$\nabla_p T_{mn} = \frac{ \partial T_{mn} }{ \partial y^p } + \Gamma_{pm}^r T_{nr} + \Gamma_{pn}^r T_{mr}$$ And there we have it! That’s the transformation of a tensor from one frame of reference to another! Swag. So just a quick concept check, what would the covariant derivative be of$g_{mn}$in flat space? The covariant tensor of the metric tensor in flat space is zero. In flat space the metric tensor is either 1 or 0. Either way it’s a constant, and the derivative of any constant is zero. Here’s how that would apply within equation 8. P.S. If professor Schnetzer at Rutgers is somehow reading this, here’s a free exam question for you next time you teach General Relativity. So we can rearrange this with the help of some crazy mathematicians. Equation 9: $$\Gamma^a_{bc} (x) = \frac{1}{2} g^{ad} \Bigg\{ \frac{ \partial g_{dc} }{ \partial x^b } + \frac{ \partial g_{ab} }{ \partial x^c } - \frac{ \partial g_{ab} }{ \partial x^d } \Bigg\}$$ Now we have our equation for the christoffel symbol in terms of first derivatives of the metric tensor. Now if you’re wondering why we care about the christoffel symbol, it’s because it’s a part of the ricci curvature tensor which is a part of Einstein’s equation. ## Curvature We’re going to have to define some other operations before wee can go on to the ricci tensor. Commutators. This is a commutator operation on some sample matrices$A$and$B$. #### Ricci Tensor So the Ricci tensor is the part of the curvature of spacetime that determines the degree to which matter will tend to converge or diverge in time. This may be slightly misleading, so i apologize if it sounds confusing. Vectors change due to curvature. This change can be modeled in the following way. You can break this down using that down that commutation definition and equation 7. I’m gonna skip it for now and leave this as an exercise for some non-lazy reader. The ricci tensor is made of christoffel symbols and derivatives of christoffel symbols, which themselves are made of metric tensors and the derivatives of metric tensors. And metric tensors, again are simply a tool to correct for the happy slapper mac daddy pythagoras when applying his nonsense in 3d. So the Ricci tensor$R_{\mu \nu}$is the$ [ \nabla_{\nu}, \nabla_{\mu} ] $terms in our model. i’m skipping a few steps to save time, mostly because typing out latex to this extent is a nightmare ~ It could be called the Riemann tensor, but for the purposes of relativity we’ll say that this is the Ricci Tensor. #### Curvature Scalar I’ll save some time and say that from the ricci tensor, you can derive the curvature scalar. It’s simply a scalar, not a tensor, not a vector. The point here is if the curvature scalar is not$0$, then the surface is not flat. ## Stress Energy Momentum Tensor Let’s start with a quick definition. Geodecic - the shortest line between two points that must travel along a curve. Examples are things like the equator, and any line drawn on a sphere. So let’s imagine what it looks like if we take a tangent vector of a geodecic. We can define a tangent vector as a rate of change of the distance we travel with respect to time. Wheat we’re interested in is to find the minimum path along a geodecic by taking the derivative and setting it equal to zero. Now remember we have to take the covariant derivative here because 3d so we’ll use equation 7: $\nabla \frac{d x^{\mu}}{ d \tau } = \frac{ \partial }{ \partial \tau } \frac{ \partial x^{mu} }{\partial \tau} + \Gamma = 0$ here$\tau$is the proper time. the gamma term is larger but we’re going to move it around in a moment so i haven’t expanded it here. We can simplify the time derivative: It’s worth noting, that$ \frac{ \partial^2 x^{\mu} }{ \partial \tau^2 } $is a second derivative of distance with respect to time. That sounds a lot like acceleration. #foreshadowing. So let’s re-arrange this equation for minimum path through a curved space. Now remember that when operating in normal 3d space we should ideally arrive at Newton’s equations which were seen as accurate for so long. Essentially newton’s laws and Einstein’s relativity must conform to the same thing. And there it is. What this means is that effectively this christoffel term has a broad equivalence to force. going back to equation 9, we have a formula for Gamma that we’ve already derived. Now lets consider a low gravity, low speed situation. We expect that from this formula we will find an equivalent for the newtownian version of gravity. So let’s look back here, in normal space almost all of those terms become incredibly small except for the component of time. So our equation becomes$ \Gamma \equiv \frac{1}{2} \frac{ \partial g_{0, 0} }{ \partial x } \equiv \vec{F} $Of course in newtownian mechanics, force is proportional to the negative change in potential. So if the potential near the earth is$\phi = mgx$where x is the height off of the earth then the force will be: So we just found the christoffel symbol is equivalent to the force term which is equivalent to the Thus,$g_{0 0} = 2 \phi + C$Let’s continue this argument by making a series of auxillary points that will become clearer after we’re done (Classic jerk physicist move). Let’s imagine we’ve placed a test mass$m$at a certain distance$r_p$out from the center of a planet with mass$M$. Now according to newtownian gravitation this is what we have: $F = - \frac{ G M}{ r_p^2}$ our unit mass will be of size$m=1$so it dissapears here. if we wanted to find the force capability across the whole of that surface of that sphere, it would be the integral of the force across the area of that sphere. Substituting in the equations for area of a circle and force. I’m switching from$r_p$to just$r$for convenience. Before we go on, there’s more stuff we have to cover. There is a theorem called the divergence theorem. You can look it up there. Divergence: the inner product of the operator$\nabla$and a given vector, which gives a measure of the quantity of flux emanating from any point of the vector field or the rate of loss of mass, heat, etc., from it. - mathematics definition from google. It says that the integral of$F \cdot d A$over an area is equal to the integral over the volume of$\nabla F \cdot dV$. What that means in normal terms is that the outward flux through the area of a sphere is equal to the volume integral of the divergence of the force. Flux describes the quantity which passes through a surface or substance. Also I’m just going to quickly remind you that density is mass divided by volume. circa like, Archimedes probably. In addition of course that means that the mass of an object will be an integral of the density with respect to the volume. So then, we’ve calculated$\int F \cdot dA$and we’ve got an equation for M as well. So let’s patch it up. we replace M with$\int \rho d V$for our definition of$F \cdot d A$Now the$dV$terms “cancel” out. What we’re left with is So then let’s break this down. So far we have shown : and remember earlier we showed that the time component of the metric tensor$g_{0, 0}$is equal to$2 \phi + C$plus some constant leftover from that christoffel term. and lastly that$\phi$is$\frac{1}{2} g_{0,0} $which means that once we put these together we get to: the constant term dissapears here because we’ve taken a derivative. then we find that : The only problem is that this isn’t a tensor equation! we’re supposed to have$\mu$s and$\nu$s in there somewhere! almost fun fact:$ \nabla^2 g_{0,0} $is sometimes called the Einstein tensor,$G_{\mu \nu}$. So intead of$\rho$ideally we’d want some tensor to represent energy as well as pressure / density. So we’d need to come up with a$T_{\mu \nu}$as well as something with a$G_{\mu \nu}$tensor as well. So there’s a definition for something called a momentum 4 vector, in which we have 3 components of space and 1 vector of time. $\rho = m ( \frac{x_0}{ \tau }, \frac{x_1}{ \tau } \frac{x_2}{ \tau } \frac{x_3}{ \tau } )$ note that here$\tau$is again the proper time, and$m$is mass.$\frac{x_0}{ \tau } $corresponds to the time dimension. Saving myself some time here because this is the longest and most painful blog post to write, ever, you can reduce these and see what physical components they correspond to. So this vector resolves to basic rest mass energy, plus the momentum vectors in the 3 coordinates of physical space. But what we want here isn’t a vector$\rho$, but a tensor$T_{\mu \nu}$. This actually finds itself in the form of a matrix. $T_{0,0}T_{0,1}T_{0,2}T_{0,3}T_{1,0}T_{1,1}T_{1,2}T_{1,3}T_{2,0}T_{2,1}T_{2,2}T_{2,3}T_{3,0}T_{3,1}T_{3,2}T_{3,3}$What we’re seeing is a relationship between the vectors based on the different values of$\mu$and$\nu$that will isolate different aspects of space when constructing the equation. For example$T_{0}{0}$is just the time component of the stress energy momentum tensor. Here’s a good diagram that shows how the tensor contains information about various different aspects of spacetime. It is sort of like units of Energy per unit volume. So there we are! that’s how we arrive at keeping our units consistent throughout this whole thing. so now we have our mass term on the right hand side. We’ve solved our problem for T_{\mu \nu}. But what should our space time curvature term be on the left hand side? ## The Cosmological Constant Einstein thought that the ricci curvature tensor$R_{\mu \nu}$would be a good candidate to be this$G_{\mu \nu}$term. The only problem is conservation of energy prevents this. I swear we’re almost at the end of the blog post. Just like a physics lecture, we’re so far into the derivation that we’re barely aware of why we’re even doing this anymore. If you were to take the derivative of the right hand side, you’d get zero. Unfortunately if you took a derivative of the ricci tensor on the left hand side it would not be zero. Meaning that this equation is physically impossible in it’s current state because energy is not conserved. Einstein found that the derivative of the ricci tensor was the following: $\nabla R_{\mu \nu} = \frac{1}{2} \nabla g_{\mu \nu } R$ note: it’s a good practice to always use covariant derivatives when doing this stuff. So now let’s set our newly found$R_{\mu \nu}$to$0$. Now we can put our modified$G_{\mu \nu}$and$T_{\mu \nu}$back into our equation setup on the correct sides. $R_{\mu \nu} - \frac{1}{2} g_{\mu \nu} R = \frac{8 \pi G T_{\mu \nu} }{c^4}$ we need that$c^4\$ for spacial reasons, it also corrects the units. Plus why not it’s relativity bro.

Einstein realized at this point that he had forgotten something. The equation only worked correctly when adding an additional tensor and scaling it by a constant. You see, at the time everyone believed that space was fixed, and was mostly unmoving. Yes the earth rotated around the sun but space on the whole didn’t really move around. That’s what people thought.

Bruh, so if the outer space isn't moving, shouldn't gravity be forcing the universe to collapse together? Obviously that shit ain't happening fam, so I'm gonna go out on a limb here and say something is preventing it.

• Albert Einstein (probably)

That thing that was preventing it? Abraham Lincoln The cosmological constant. It’s actually quite small and is usually left out. It’s typically only relevant when talking about large cosmological scales which is why you may see that it’s left out sometimes.

So he added in another metric tensor term, and scaled it by the cosmological constant, and here we are.

swag.

## Putting the pieces together

Oh wait we’re done.

## Resources

If you’ve made it this far thank you. I respect your desire to learn, and I’m sorry that I couldn’t write a better post to explain this. Here are some resources where you can learn more, from smarter people than myself. Lest I shout into the void a moment more.

# How to Fight a Traffic Ticket with Fire and Brimstone

I know I have written in the past that I don’t believe in disclaimers but this one is important. I am not a lawyer. This guide in no way serves as a substitute for legal advice and I am not responsible for anything that you do with this information. Use your own best judgement. If you don’t feel comfortable going through this process it is hereby recommended that you talk to a lawyer.

Remember this, 95% of tickets aren’t contested. Of those that are, 50% of them are won.

This isn’t meant to be a typical blog post per se, but more like a guide on what you should do throughout the process of dealing with a ticket.

In our example here, this is just a high level overview of what to do during the different parts of the process:

So let’s imagine some random scenario, it’s 1am, you’re driving home through NJ from philly to get home. You’re always in Philly late, you know you shouldn’t be staying out too long, but somehow now matter what you always get tempted into staying there, something something magic of the city. The reason isn’t important. There’s nobody on the road, and you just want to get home, so you’re just driving. Driving quick, and bam, the lights flash, the siren blares, and you’ve pulled over.

### When you get pulled over:

You’re going to want to leave a good impression, but not a memorable one. Just be polite and it will be fine.

• Hands on the wheel, engine off, lights inside the car on.

• Be Polite, don’t be a jerk. When the officer asks you for your license and registration, ask him if it is ok that you reach into glovebox/center console to retrieve it BEFORE you give it to him. Cops are always wary from not knowing if a person is a going to cause a problem or not. This will put him a bit at ease.

• DON’T ADMIT TO ANYTHING. Do not say something stupid like the following: “Why yes sir I was speeding. Thank you for this ticket!” Let him tell you what HE THINKS you did. Make sure to take note of exactly what he says. This information is important.

• DON’T ARGUE WITH THE OFFICER. It is ok to question what happened, but don’t make it into argument. You can always say something like “Really? I’m quite sure I was driving with the flow of traffic” or “My speedometer was reading at the speed limit.” It is best to let him do the talking and ask questions in a vague manner rather than challenge his judgment.

• ASK QUESTIONS. Don’t do this in a suspicious manner. The cop might get a hint that you want to fight the ticket if you get pushy. Act like you are clueless.

• Types of questions to ask:

• How did you catch me? If it was by radar ask what the reading was and if you can see it. Small things like him saying “75 or so” are crucial to your benefit. The less accurate he is, the better chance you have of succeeding. If he says he was pacing you, ask what that means so he describes it to you (appearing clueless).
• How long he was following you and from where. Make sure to take mental notes of all this. Remember, you don’t want the officer to actually remember that much about you, you want to seem like a totally routine traffic stop to him.

• COUNTY SEAT: If at this point he has decides to write you a ticket, ask if you can have it sent to the county seat. The county seat is the main branch in the county of where the ticket is issued. There are two reasons to do this:
• First, the main branch is usually not the officer’s home branch, sometimes it might be pretty far. This means he is less likely to show up in court should he have to go, because it is more work for him to drive there.
• Second, the ticket might get lost in the process. It's not that likely, but whatever you can do to put things in your favor. If he asks why, just tell him that you work near there or something. He cannot refuse this right and if he does take note of it.

• Write everything down! Once everything is settled and you are now on your way again, pull over somewhere and write down or record every detail you can remember. Every detail includes: weather, date, time, traffic conditions, where the sun was at, lane you were in, lane he was in, what the conversation entailed (how fast he said you were going, how he caught you etc.) The more info you have the better your case. Take lots of pictures of the area if you can. Or use google earth photos.

• Delay, delay, delay. Look at the date you are due in court. Call the a couple of days before and get an extension also known as a continuance. You will receive one, and you can always make up an excuse for one. 2 weeks before your next court date try to get another extension. You may or may not get one. I did. The longer time between you and the court date the more time has passed and the less likely the cop will be able to recall you or information about the violation. There are even circumstances where it’s been so long that the officer isn’t even serving in your jurisdiction anymore and the ticket can be dismissed automatically.

• Police Report: get a copy of the police report and go through it thoroughly. Make sure that every blank that should be filled out is filled out to the T. I’m not sure if getting a copy prior to court is free or not, but if you get to the point of court, you should be offered a copy then to look over. You may also just get a kickass judge like I did who will offer to look it over for you.

• Trial by Written Declaration: Read the citation and dig into what the rules are in your state for trial by written declaration. A written declaration essentially means you write up your case as opposed to showing up in court. Even if you lose this case, you can go to court in person anyway, which of course is up to you. Information is readily available on the internet about deadlines for this, but usually you have to send a letter postmarked 5 days in advance of your court date stating you want trial by declaration.

• You can find this information online and I suggest you do it well in advance before you send the actual letter. The letter will read something like “I would like trial by written declaration and include the citation number.” Again this buys you more time. What will happen is that the court will process your request and send you the appropriate forms to fill out. It takes a while for them to do this, it took over a month before I got my papers. Some counties might provide the ability to start the process from online. That is up to you. I personally would opt for typing a letter and mailing it. The more time you can buy the better.

#### Once you receive the papers

• Construct your case as precisely as possible. Include all the details you can. Your letter must be revised a few times to prevent contradictions or inaccuracies. Have some of your friends or peers revise it if you like.
• Structure: Make sure the wording is formal and that the events are in order. Start out by describing where you were driving, time of day, weather, how fast you were going etc. Followed by where you were being pulled over, speed, lanes. The conversation and then your reasons why feel the ticket is unjust.
• Diagrams: Include diagrams if you can. Even a hand drawn one. It helps
• Deadline: Send it by the deadline stated on the papers. Time extension is very important.
• Wait
• Results: Results will of course either be in your favor or against. If you lose you usually have the option to have an in person trial, or at this point just deal with the fine. Which of course you won’t becuase that’s why you’re reading this. I know this sounds like a lot of work, but it really only took me an hour or two to type a letter and make a diagram for it. I did a bit of additional research, but most of the information is here for you already. You’ll save hundreds of dollars and points on your driver’s license PLUS having to go and pay for traffic school. It was definitely worth the time.

Now to be clear you could win the case with a trial by declaration, which happens maybe 30% of the time, and that would be the end of it, and nothing more needs to happen.

IF YOU LOSE THE TRIAL BY DECLARATION: It’s time for shit to get real and go to trial in person.

### Court:

• Scheduling the court date: They will set a court date for you. First thing you should do is call the dispatch office where your officer is stationed (written on your ticket) ask for the officer’s schedule (this is considered on the /public record and legally must be disclosed). If the officer has 2 or 3 consecutive days off schedule your court date in the middle or just make sure to schedule your court hearing on his day off. Here’s why: typically officers will set up all their court dates consecutively in one day. If you’re the single ticket interrupting his weekend he’s probably not likely to show up to court.

Here’s why: typically officers will set up all their court dates consecutively in one day so they don’t have to make multiple trips. If you’re the single ticket interrupting his weekend he’s probably not likely to show up to court. Also remember, you’ve pushed this court date for quite a while. Many officers won’t bother showing up for what is now almost a 60 day old ticket. If you’d like to go to trial (again, remember nothing is lost by doing this, at worst you end up right where you started having to pay the fine.)

• Coming to court: DRESS NICELY and show up early. DO NOT use your phone or look down at it in court, just sit and relax. A lot of the folks you’ll be sitting with (other alleged offenders) will come in looking just TERRIBLE. If a judge sees that you’re well dressed, calm, respectful and have been sitting in court for a little while patiently observing and paying attention; you will stand out. Most judges and cops really respect people who respect the process. Eventually your name will be called for your case.

• BE RESPECTFUL OF THE JUDGE. I have found that by sitting in the front row, dressing nicely, sitting up straight, crossing one leg and sitting professionally and actually making eye contact with the judge as if you’re paying attention makes a world of difference. Saying “Good morning your honor” and ending every sentence with “your honor” makes a HUGE difference every time.

• Evidence: You should ask for the radar model number, and radar gun certificate. This certificate should include the last time it was calibrated. This must be done daily on every gun used in a police car, and signed off by a superior. In reality most officers do not have this in court or actually do this. Make sure to ask if the officer used Lidar or Radar to gauge your speed. Radar is less accurate so you might be able to get off a ticket if you just say there was a lot of traffic around you, like big trucks, etc.

A note on speed detection tools: