<jupyter_start><jupyter_text>Welcome to Relatwinity!By <NAME>**________________________** In this notebook, we will learn about special relativity by exploring The Twin Paradox using interactive space-time diagrams.   The Twin Paradox**In the classic Twin Paradox example, there is Twin A and Twin B, who we will assume are exactly the same age. While Twin A remains on Earth, Twin B travels to some distant star and then returns to Earth where Twin A is. After this trip, which twin is older?**Without considering special relativity, one might say they are still the same age, of course! Although one has taken a trip to space, the same amount of time has passed for each twin and thus they are still the same age, because that's how time works, right? As we learn about special relativity, we will come to realize that this is not quite true. When we take the relativistic speed of Twin B into consideration, we will see that one twin does end up younger than the other. If you already have a strong grasp on the concept of special relativity, please feel free to skip ahead and view the space-time diagrams of the Twin Paradox (immediately after the section titled *Space-Time Diagrams*). If you are new to relativity or would like a refresher, please read the following sections!  What is Special Relativity?In introductory physics courses, we learn about things like gravity, acceleration, projectile motion, and friction. This is called Newtonian physics, and while it is generally an accurate way to describe the motion in our every day lives, it does not take *all* the laws of physics into consideration. One of these neglected effects is called special relativity. Relativity applies to all motion to a small extent, though it is only really relevant to objects moving at extremely high speeds (close to the speed of light, 3·108 meters per second). In special relativity, we examine the following questions: What if time was not definite, but relative? What if objects seemed to be different sizes at different speeds? What happens when we consider motion from the reference frame of the moving object, instead of the reference frame of the stationary observer?One basic yet vital concept that must be learned to understand relativity is that of a reference frame. A reference frame (more accurately, an inertial frame) essentially refers to the perspective of a certain observer or object. For instance, if you are standing on a sidewalk and you see a car passing by, you claim that you are stationary (relative to the ground) and that the person driving the car is moving with some velocity, v. However, the driver claims that she is stationary (relative to the car) and that you are moving with the velocity, v, in the opposite direction.*These are different frames of reference, defined by a set coordinate system (like the ground or the car in this case). Both observers are "correct" - They just have different perspectives *due to their motion*. Essentially, an inertial frame is defined by an observer or object's specific surrounding coordinate system which is reliant on its motion. Thus, this coordinate system is only upheld when the motion of the observer or object is unchanging. \* *This is an example of Galilean relativity. If you are struggling with the concept of reference frames or special relativity in general, Galilean relativity problems may be helpful as they are more familiar.For a more detailed definition of an inertial frame of reference, or to find resources on Galilean relativity, please see the references at the end of this notebook.*  Basic Rules of Special Relativity Although relativity is a very complex concept, it can be boiled down to a few key points for the purposes of this notebook. Some fundamental assumptions that we must keep in mind are: 1. Nothing can travel faster than light. ($c=3\cdot10^{8} m/s$)2. The same laws of physics apply to all reference frames.3. Every reference frame observes the same speed of light. 4. There is no prefered reference frame - Any observer can accurately claim to be at rest.And the conclusions that result from these assumptions are: 1. Time dilation - Observers in different reference frames experience differences in time elapsed.2. Length contraction - Observers in different reference frames experience differences in lengths of objects. There are also several important formulas in special relativity. These are the few that are commonly taught in introductory physics: * $t=t_{0}\gamma$ *(time dilation)** $L=\frac{L_{0}}{\gamma}$ *(length contraction)*There are also more detailed (and more reliable) special relativity formulas, which are called Lorentz Transforms:* $x = \gamma(x_{0} + vt_{0})$ *(space transform)** $t = \gamma(t_{0} + \frac{v}{c^{2}}x_{0})$ *(time transform)*In all of these formulas, gamma ($\gamma$) is a factor which allows for conversion from one frame to another. This is also called the Lorentz factor. Gamma is always a quantity greater than 1 for any object in motion relative to another object. * $\gamma=\frac{1}{\sqrt{1-\frac{v^{2}}{c^{2}}}}$ *More in-depth explanations, proofs, and derivations of these phenomena and formulas can be found in the references at the end of this notebook, but for now, let's take these to be true so we can apply them to the Twin Paradox.*  Space-Time DiagramsSpace-time diagrams are frequently used to visually represent special relativity problems, and they are exactly what they sound like: A diagram that graphs time on one axis (vertical) and space (position) on the other(s). For simplicity's sake, we will assume that only one-dimensional motion is occurring in our Twin Paradox example. However, it is important to note that this can be applied to two-dimensional motion as well by plotting the second dimension of position on a third axis. In relativity problems, it is useful to create multiple space-time diagrams for one scenario. This is necessary in order to represent the events of the problem from all references frames. **Let's look at what the space-time diagrams would look like for the Twin Paradox.**In the following diagrams...* The red line represents the motion of Twin A, who stays on Earth.* The yellow line represents the motion of Twin B, who travels to the distant star at relativistic speeds.* The dotted line represents the motion of the distant star. The first diagram shows the motion of each twin and the star as observed by Twin A. The second diagram shows the motion of each twin and the star as observed by Twin B. When looking at these diagrams, do not worry about units or numerical values. Instead, focus on understanding their meaning in the context of the Twin Paradox scenario.*For further information about space-time diagrams, please see the references at the end of this notebook.*<jupyter_code>import plotly
plotly.tools.set_credentials_file( username = 'jkulp', api_key = '<KEY>' )
import plotly.plotly as pl
import plotly.graph_objs as GO
#Creating data point values for TRAVELING TWIN (TWIN B)
t_valsB = [0, 1, 2, 3, 4, 5, 6]
x_valsB = [1, 2, 3, 4, 3, 2, 1]
#Simple line for TRAVELING TWIN
traceB = GO.Scatter(
    x = x_valsB,
    t = t_valsB,
    name = "Twin B (Traveling)",
    mode = "lines",
    line = dict(color = "rgba(300, 200, 0, 1)",
                width = 3)) #editing style of line

#Creating data point values for EARTH TWIN (TWIN A)
t_valsA = [0, 1, 2, 3, 4, 5, 6]
x_valsA = [1, 1, 1, 1, 1, 1, 1]
#Simple line for EARTH TWIN
traceA = GO.Scatter(
    x = x_valsA,
    t = t_valsA, 
    mode = "lines",
    name = "Twin A (On Earth)",
    line = dict(color = "rgba(185, 0, 0, 1)",
                width = 3))

#Creating data point values for DISTANT STAR
t_valsDS = [0, 1, 2, 3, 4, 5, 6]
x_valsDS = [4, 4, 4, 4, 4, 4, 4]
#Dashed simple line for DISTANT STAR
traceDS = GO.Scatter(
    x = x_valsDS,
    t = t_valsDS,
    mode = "lines",
    name = "Distant Star",
    line = dict(color = "rgba(0, 0, 0, 4)",
               width = 3,
               dash = "dash"))

#Editing layout
layout1 = dict(title = 'Space-Time Diagram - Twin A frame',
              xaxis = dict(title = 'Space/Position (x)'),
              yaxis = dict(title = 'Time (t)'),
              )

data1 = [traceB, traceA, traceDS]
fig1 = dict(data=data1, layout=layout1)
pl.iplot(fig1, filename = "first_example")
q1 = input("What event occurs at (0,0) on the space-time diagram? ")
q2 = input("What event occurs at (4,3) on the space-time diagram? ")
q3 = input("How would <NAME> describe the position and motion of himself, his twin, and the distant star? ")
q4 = input("How would <NAME> describe the total time of the trip? ")
#Creating data point values for EARTH TWIN (TWIN A)
t_valsA2 = [0, 1, 2, 3, 4]
x_valsA2 = [1, 0, -1, 0, 1]
#Simple line for EARTH TWIN
traceA2 = GO.Scatter(
    x = x_valsA2,
    t = t_valsA2,
    name = "<NAME> (On Earth)",
    mode = "lines", #no "points", only lines
    line = dict(color = "rgba(185, 0, 0, 1)",
                width = 3)) #editing style of line

#Creating data point values for TRAVELING TWIN (TWIN B)
t_valsB2 = [0, 1, 2, 3, 4]
x_valsB2 = [1, 1, 1, 1, 1]
#Simple line for TRAVELING TWIN
traceB2 = GO.Scatter(
    x = x_valsB2,
    t = t_valsB2,
    name = "<NAME> (Traveling)",
    mode = "lines", 
    line = dict(color = "rgba(300, 200, 0, 1)",
                width = 3))

#Creating data point values for DISTANT STAR
t_valsDS2 = [0, 1, 2, 3, 4]
x_valsDS2 = [3, 2, 1, 2, 3,]
#Dashed simple line for DISTANT STAR
traceDS2 = GO.Scatter(
    x = x_valsDS2,
    t = t_valsDS2,
    name = "Distant Star",
    mode = "lines",
    line = dict(color = "rgba(0, 0, 0, 4)",
               width = 3,
               dash = "dash"))

#Editing layout
layout2 = dict(title = 'Space-Time Diagram - Twin B frame',
              xaxis = dict(title = 'Space/Position (x)'),
              yaxis = dict(title = 'Time (t)'),
              )

data2 = [traceA2, traceB2, traceDS2]
fig2 = dict(data=data2, layout=layout2)
pl.iplot(fig2, filename = "first_example2")
q1 = input("What event occurs at (1,0) on the space-time diagram? ")
q2 = input("What event occurs at (1,2) on the space-time diagram? ")
q3 = input("How would Twin B describe the position and motion of himself, his twin, and the distant star? ")
q4 = input("How would Twin B describe the total time of the trip? ")
q5 = input("What do the differences from the first space-time diagram reflect about the different experiences between the two twins' reference frames?")<jupyter_output>What event occurs at (1,0) on the space-time diagram?  
What event occurs at (1,2) on the space-time diagram?  
How would Twin B describe the position and motion of himself, his twin, and the distant star?  
How would Twin B describe the total time of the trip?  
What do the differences from the first space-time diagram reflect about the different experiences between the two twins' reference frames?
{'fraction_non_alphanumeric': 0.0770927134062299, 'fraction_numerical': 0.017642194247909585, 'mean_word_length': 3.9226594301221165, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '374307', 'license': 'MIT', 'n_tokens_mistral': 3123, 'n_tokens_neox': 2892, 'n_words': 1632, 'path': 'relatwinity.ipynb', 'repo_name': 'kulp95/relatwinity', 'size': '10904'}