#!/usr/bin/env python3 import sys import matplotlib.pyplot as plt import pandas as pd def main(): src = sys.argv[1] if len(sys.argv) > 1 else sys.stdin df = pd.read_csv(src) fig, ax = plt.subplots(figsize=(10, 5)) ax.plot(df["time"], df["tao"], label="Tao (symplectic)", linewidth=1) ax.plot(df["time"], df["rk4"], label="RK4", linewidth=1) ax.set_xlabel("Time") ax.set_ylabel("Energy") ax.set_title("Double pendulum energy: RK4 vs Tao's method") ax.legend() ax.grid(True, alpha=0.3) fig.tight_layout() plt.show() if __name__ == "__main__": main()