<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 The Space-Arrow of Space-time
People have claimed Nature does not have an arrow for time. I don't think the question, as stated, is well-formed. Any analysis of the arrow of time for one observer will look like the arrow of space-time to another one moving relative to the first.
Two different problems are often cited on this subject. The first is that the fundamental forces of the standard model - EM, the weak force, and the strong force - are unaltered by a change in the arrow of (space-)time. Second, that the Lorentz group can be used an arbitrary number of times and still flip the value of time precisely.
In this short talk, I will show how keeping the space terms next to the time ones leads to the world we know, where space-time reversal does not come easy.
Space-time Reversal in EM
Let me provide a quick sketch of how to derive the Maxwell source equations, not just write them down like Minkowski did. The goal is to calculate the Lorentz invariant quantity $B^2 - E^2$, the difference of two squares. Based on high school algebra, this should be obtained by the product of the sum and difference of $E$ and $B$. Once one has this difference of squares, the Euler-Lagrange equations to derive Gauss's and Ampere's laws. 
Start all the ways a 4-potential can change in space-time (doesn't that sound general?)
Step1:  The member of the Lorentz group that reverses time is remarkably simple
Step2:  Create a 4-vector.
Step3:  Do the time reversal a bunch of times.
Step4:  It comes as no surprise that if the time-reversal member of the Lorentz group is done an even number of times, then nothing changes, but an odd number of times reverses time exactly.
For the quaternion approach, one solves a pretty simple algebraic expression instead of using a global matrix. The equation to solve is
Step5:  Does this considerably more complicated expression than the Lorentz group do its job? Of course is should, but let's just show this is the case
Step6:  Apply Tr twice to see if one gets back to the start point.
Step7:  This may not look "right" to the eye, so test it. Use "classical" values, meaning time $t >>> x, y, z$.
Step9:  The value for t returned to unity as it should, but the same cannot be said for the spatial terms. This is due to the cross product. See what happens if one does this many, many times. Define a function to do the work.
<ASSISTANT_TASK:>
Python Code:
%%capture
%matplotlib inline
import numpy as np
import sympy as sp
import matplotlib.pyplot as plt
# To get equations the look like, well, equations, use the following.
from sympy.interactive import printing
printing.init_printing(use_latex=True)
from IPython.display import display
# Tools for manipulating quaternions.
import Q_tools as qt;
Explanation: The Space-Arrow of Space-time
People have claimed Nature does not have an arrow for time. I don't think the question, as stated, is well-formed. Any analysis of the arrow of time for one observer will look like the arrow of space-time to another one moving relative to the first.
Two different problems are often cited on this subject. The first is that the fundamental forces of the standard model - EM, the weak force, and the strong force - are unaltered by a change in the arrow of (space-)time. Second, that the Lorentz group can be used an arbitrary number of times and still flip the value of time precisely.
In this short talk, I will show how keeping the space terms next to the time ones leads to the world we know, where space-time reversal does not come easy.
Space-time Reversal in EM
Let me provide a quick sketch of how to derive the Maxwell source equations, not just write them down like Minkowski did. The goal is to calculate the Lorentz invariant quantity $B^2 - E^2$, the difference of two squares. Based on high school algebra, this should be obtained by the product of the sum and difference of $E$ and $B$. Once one has this difference of squares, the Euler-Lagrange equations to derive Gauss's and Ampere's laws. 
Start all the ways a 4-potential can change in space-time (doesn't that sound general?):
The first term is a gauge field. Since photons are being studied, this gauge field has to be set to zero. For anything that is not a photon, this field will be non-zero. It is interesting to me that it is just "naturally" here. It can be zeroed out easily enough:
By changing the order of the differential acting on the potential, only the magnetic field $B$ will change signs.
Form the product of these two:
The first observation to make that everyone makes is that reversing time will never, ever change the value of the difference between the square of the magnetic field and the square of the electric field. That is what a square does. This is why one can conclude with confidence that the fundamental forces in physics are unaltered by changes in time. The weak and strong forces are mere variations on EM using other gauge groups.
The second observation that no one makes is that the Poynting vector is sitting right next door. The Poynting vector will change signs under time reversal. A complete analysis of EM must include the part that responds to time reversal. By omitting it, a mystery is claimed.
Space-time Reversal is Locally Irreversible
In this notebook, I will show two different ways how when one thinks about space-time reversal instead of just time reversal using space-time numbers, that such a system cannot be reversed an arbitrarily large number of times as is the case for the Lorentz group. First the tools need to work with space-time numbers have to loaded.
End of explanation
TimeReversal = np.array([[-1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]])
display(TimeReversal)
Explanation: The member of the Lorentz group that reverses time is remarkably simple: it is a matrix that has minus one in the upper diagonal position, positive one for the other diagonal positions, and zeros elsewhere.
End of explanation
t, x, y, z = sp.symbols("t x y z")
Vector = np.array([t, x, y, z])
display(Vector)
display(Vector * TimeReversal)
Explanation: Create a 4-vector.
End of explanation
display(Vector * TimeReversal * TimeReversal)
display(Vector * TimeReversal * TimeReversal * TimeReversal)
Explanation: Do the time reversal a bunch of times.
End of explanation
P = qt.QH([t, x, y, z])
Tr = P.flip_signs().invert().product(P.conj())
display(Tr.t)
display(Tr.x)
display(Tr.y)
display(Tr.z)
Explanation: It comes as no surprise that if the time-reversal member of the Lorentz group is done an even number of times, then nothing changes, but an odd number of times reverses time exactly.
For the quaternion approach, one solves a pretty simple algebraic expression instead of using a global matrix. The equation to solve is:
$$ P T_r = - P^ $$
Solve for $T_r$:
$$ T_r = - P^{-1} P^ $$
End of explanation
PFlip = P.product(Tr)
display(sp.simplify(PFlip.t))
display(sp.simplify(PFlip.x))
display(sp.simplify(PFlip.y))
display(sp.simplify(PFlip.z))
Explanation: Does this considerably more complicated expression than the Lorentz group do its job? Of course is should, but let's just show this is the case:
End of explanation
PFlipFlip = P.product(Tr).product(Tr)
display(sp.simplify(PFlipFlip.t))
display(sp.simplify(PFlipFlip.x))
display(sp.simplify(PFlipFlip.y))
display(sp.simplify(PFlipFlip.z))
Explanation: Apply Tr twice to see if one gets back to the start point.
End of explanation
Classical_subs = {t:1, x:0.0000000002, y:0.00000000012, z:-0.0000000003}
display(sp.simplify(PFlip.t.subs(Classical_subs)))
display(sp.simplify(PFlip.x.subs(Classical_subs)))
display(sp.simplify(PFlip.y.subs(Classical_subs)))
display(sp.simplify(PFlip.z.subs(Classical_subs)))
print()
display(sp.simplify(PFlipFlip.t.subs(Classical_subs)))
display(sp.simplify(PFlipFlip.x.subs(Classical_subs)))
display(sp.simplify(PFlipFlip.y.subs(Classical_subs)))
display(sp.simplify(PFlipFlip.z.subs(Classical_subs)))
Explanation: This may not look "right" to the eye, so test it. Use "classical" values, meaning time $t >>> x, y, z$.
End of explanation
def reverse_n_times(P1, T1, sub_1, n):
    Given a symbolic expression P, applies symbolic space-time reversal using a dictionary of values n times.
    P1_t, P1_x, P1_y, P1_z = P1.t.subs(sub_1), P1.x.subs(sub_1), P1.y.subs(sub_1), P1.z.subs(sub_1)
    P_result = qt.QH([P1_t, P1_x, P1_y, P1_z])
    
    T1_t, T1_x, T1_y, T1_z = T1.t.subs(sub_1), T1.x.subs(sub_1), T1.y.subs(sub_1), T1.z.subs(sub_1)
    T_sub = qt.QH([T1_t, T1_x, T1_y, T1_z])
    for i in range(n):
        P_result = P_result.product(T_sub)
        
    return P_result
print(reverse_n_times(P, Tr, Classical_subs, 100))
print(reverse_n_times(P, Tr, Classical_subs, 101))
print(reverse_n_times(P, Tr, Classical_subs, 1000))
print(reverse_n_times(P, Tr, Classical_subs, 1001))
print(reverse_n_times(P, Tr, Classical_subs, 10000))
print(reverse_n_times(P, Tr, Classical_subs, 100000))
print(reverse_n_times(P, Tr, Classical_subs, 1000000))
print(reverse_n_times(P, Tr, Classical_subs, 10000000))
Explanation: The value for t returned to unity as it should, but the same cannot be said for the spatial terms. This is due to the cross product. See what happens if one does this many, many times. Define a function to do the work.
End of explanation
<END_TASK>