In [1]:
import matplotlib.pyplot as plt
import numpy as np
In [2]:
t_0_val = 10
c_val = 1
u_val = np.linspace(0, c_val, 100)
gamma_val = 1 / np.sqrt(1 - (u_val/c_val)**2)
t_val = gamma_val*t_0_val
u_val_dots = np.array([0, 0.25, 0.5, 0.6, 0.87, 0.95])
gamma_val_dots = 1 / np.sqrt(1 - (u_val_dots/c_val)**2)
t_val_dots = gamma_val_dots*t_0_val
In [3]:
fig = plt.figure(figsize = (6, 6))
plt.plot(u_val, t_val, color = 'blue')
plt.scatter(u_val_dots, t_val_dots, color = 'red')
for i in range(len(u_val_dots)):
x_offset = 0
if i == 3:
x_offset = 0.1
plt.text(u_val_dots[i] + x_offset, t_val_dots[i] + 3, s= f'({u_val_dots[i]}, {round(t_val_dots[i], 2)})', ha = 'right', va = 'center')
plt.xlabel('speed of object(expressed in terms of c)', fontsize = 14)
plt.ylabel('time delay', fontsize = 14)
Out[3]:
In [4]:
c_val = 1
u_val = np.linspace(0, c_val, 100)
gamma_val = 1 / np.sqrt(1 - (u_val/c_val)**2)
u_val_dots = np.array([0, 0.25, 0.5, 0.6, 0.87, 0.95])
gamma_val_dots = 1 / np.sqrt(1 - (u_val_dots/c_val)**2)
In [5]:
fig = plt.figure(figsize = (6, 6))
plt.plot(u_val, gamma_val, color = 'blue')
plt.scatter(u_val_dots, gamma_val_dots, color = 'red')
for i in range(len(u_val_dots)):
x_offset = 0
if i == 3:
x_offset = 0.1
plt.text(u_val_dots[i] + x_offset, gamma_val_dots[i] + 0.3, s= f'({u_val_dots[i]}, {round(gamma_val_dots[i], 2)})', ha = 'right', va = 'center')
plt.xlabel('speed of object(expressed in terms of c)', fontsize = 14)
plt.ylabel('gamma factor', fontsize = 14)
Out[5]:
In [6]:
t_0_val = 10
c_val = 1
u_val = np.linspace(0, c_val, 100)
gamma_val = 1 / np.sqrt(1 - (u_val/c_val)**2)
t_val = gamma_val*t_0_val
u_val_dots = np.array([0, 0.25, 0.5, 0.6, 0.87, 0.95])
gamma_val_dots = 1 / np.sqrt(1 - (u_val_dots/c_val)**2)
t_val_dots = gamma_val_dots*t_0_val
In [18]:
fig = plt.figure(figsize = (6, 6))
plt.plot(gamma_val, t_val, color = 'blue')
plt.scatter(gamma_val_dots, t_val_dots, color = 'red')
for i in range(len(gamma_val_dots)):
x_offset = 0
y_offset = 1
if i == 3 or i == 1:
x_offset = 0.8
y_offset = 0
if i == 0 or i == 2:
x_offset = -0.1
y_offset = 0
plt.text(gamma_val_dots[i] + x_offset, t_val_dots[i] + y_offset, s= f'({round(gamma_val_dots[i], 2)}, {round(t_val_dots[i], 2)})', ha = 'right', va = 'center')
plt.xlabel('gamma factor', fontsize = 14)
plt.ylabel('time delay', fontsize = 14)
plt.xlim(0, 4)
plt.ylim(9, 40)
Out[18]:
In [8]:
l_0_val = 10
c_val = 1
u_val = np.linspace(0, c_val, 100)
gamma_val = 1 / np.sqrt(1 - (u_val/c_val)**2)
l_val = l_0_val/gamma_val
u_val_dots = np.array([0, 0.25, 0.5, 0.6, 0.87, 0.95])
gamma_val_dots = 1 / np.sqrt(1 - (u_val_dots/c_val)**2)
l_val_dots = l_0_val / gamma_val_dots
In [9]:
fig = plt.figure(figsize = (6, 6))
plt.plot(u_val, l_val, color = 'blue')
plt.scatter(u_val_dots, l_val_dots, color = 'red')
for i in range(len(u_val_dots)):
x_offset = 0.05
y_offset = 0
if i == 0:
x_offset = 0
y_offset = -0.5
plt.text(u_val_dots[i] + x_offset, l_val_dots[i] + y_offset, s= f'({round(u_val_dots[i], 2)}, {round(l_val_dots[i], 2)})', ha = 'left', va = 'center')
plt.xlabel('speed of object(expressed in terms of c)', fontsize = 14)
plt.ylabel('length contraction', fontsize = 14)
Out[9]:
In [10]:
l_0_val = 10
c_val = 1
u_val = np.linspace(0, c_val, 100)
gamma_val = 1 / np.sqrt(1 - (u_val/c_val)**2)
l_val = l_0_val/gamma_val
u_val_dots = np.array([0, 0.25, 0.5, 0.6, 0.87, 0.95])
gamma_val_dots = 1 / np.sqrt(1 - (u_val_dots/c_val)**2)
l_val_dots = l_0_val / gamma_val_dots
In [11]:
fig = plt.figure(figsize = (6, 6))
plt.plot(gamma_val, l_val, color = 'blue')
plt.scatter(gamma_val_dots, l_val_dots, color = 'red')
for i in range(len(gamma_val_dots)):
x_offset = 0.2
y_offset = 0
if i == 1:
y_offset = -0.3
plt.text(gamma_val_dots[i] + x_offset, l_val_dots[i] + y_offset, s= f'({round(gamma_val_dots[i], 2)}, {round(l_val_dots[i], 2)})', ha = 'left', va = 'center')
plt.xlabel('gamma factor', fontsize = 14)
plt.ylabel('length contraction', fontsize = 14)
# plt.gca().set_aspect('equal')
Out[11]:
In [12]:
from xv.math.algebra import PolynomialManager
In [13]:
ke = PolynomialManager()
In [14]:
from sympy import *
x = symbols('x')
c = symbols('c', constant = True)
func = 1/sqrt(1-(x/c)**2)
ke.initProblem(func)
Out[14]:
In [15]:
ke.printAnswer()
Out[15]:
In [ ]: