<jupyter_start><jupyter_text>HW 1  Imports<jupyter_code>import sympy
import numpy
import plotly.graph_objects as go<jupyter_output><empty_output><jupyter_text>Problem 1<jupyter_code>zeta = sympy.symbols('zeta')
lam = sympy.Matrix([
    [sympy.cosh(zeta), -sympy.sinh(zeta), 0, 0],
    [-sympy.sinh(zeta), sympy.cosh(zeta), 0, 0],
    [0, 0, 1, 0],
    [0, 0, 0, 1],
])

lam
eta = sympy.Matrix([
    [-1, 0, 0, 0],
    [0, 1, 0, 0],
    [0, 0, 1, 0],
    [0, 0, 0, 1],
])

eta
sympy.simplify(lam.transpose() * eta * lam)
sympy.simplify(eta * lam)
print(lam.transpose()._repr_latex_())<jupyter_output>$\displaystyle \left[\begin{matrix}\cosh{\left(\zeta \right)} & - \sinh{\left(\zeta \right)} & 0 & 0\\- \sinh{\left(\zeta \right)} & \cosh{\left(\zeta \right)} & 0 & 0\\0 & 0 & 1 & 0\\0 & 0 & 0 & 1\end{matrix}\right]$<jupyter_text>Problem 2<jupyter_code>def star_rad(conf_time: float, rad_0: float) -> float:
    """Surface of star radial coordinate in conformal time"""
    return 0.5 * rad_0 * (1 + numpy.cos(conf_time))

def star_time(conf_time: float, rad_0: float, mass: float = 1) -> float:
    """Surface of star time coordinate in conformal time"""
    return numpy.sqrt((rad_0 ** 3) / (8 * mass)) * (conf_time + numpy.sin(conf_time))

def a_m(rad_0: float, mass: float = 1) -> float:
    return numpy.sqrt(rad_0 ** 3 / (2 * mass))

def co_rad(conf_time: float, rad_0: float, mass: float = 1) -> float:
    return 0.5 * a_m(rad_0, mass=mass) * (1 + numpy.cos(conf_time))

def co_time(conf_time: float, rad_0: float, mass: float = 1) -> float:
    return 0.5 * a_m(rad_0, mass=mass) * (conf_time + numpy.sin(conf_time))
conf_times = numpy.arange(0, numpy.pi, 0.01)
mass_fracs = [0.1, 0.25, 0.5, 1.0]
r_full = 5.0
r_0s = numpy.array(mass_fracs) ** (1/3) * r_full

rads = []
times = []

for r_0, mass_frac in zip(r_0s, mass_fracs):
    print(r_0)
    rads.append(star_rad(conf_times, r_0))
    times.append(star_time(conf_times, r_0, mass=mass_frac))
fig = go.Figure()


for r_0, r, t in zip(r_0s, rads, times):
    fig.add_trace(go.Scatter(x=r, y=t, mode='lines', name='{:.2f}'.format(r_0)))

fig.update_layout(
                  yaxis_range=[0,25],
                  xaxis_range=[0,6],
                  width=600,
                  height=600,
                  showlegend=True,
                  title_text=r'$\text{Oppenheimer Snyder }(\tau, R)$', 
                  title_x=0.5,
                  xaxis_title=r'$R / M$',
                  yaxis_title=r'$\tau/M$')
fig.show()
fig.write_image('hw1-prob2.pdf')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.18296034550451512, 'fraction_numerical': 0.043580683156654886, 'mean_word_length': 3.1296596434359807, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 17, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '401238', 'license': 'MIT', 'n_tokens_mistral': 1115, 'n_tokens_neox': 1027, 'n_words': 218, 'path': 'notebooks/homework-1.ipynb', 'repo_name': 'JWKennington/CourseNR', 'size': '2547'}