Здравствуйте, я хотел бы решить следующую первую ОДУ:
dt / dr = + - cos (t) ^ 2 / cos (r) ^ 2
Я знаю, что решение: t (r) = t (r) = arctan (tan (r) + _ C1), с:
pi / 2
Я хотел бы знать, как я могу улучшить приведенный ниже код, чтобы мое решение напоминало кривую, которая стремится к + бесконечности по оси t на изображении:

Мой код:
import numpy as np
import matplotlib.pyplot as plt
from scipy.integrate import odeint
"""
Equations to be solved:
boundary conditions:
-pi/2 << t << pi/2
0 <= r <= pi/2
Equation:
dt/dr = +- cos^2(t)/cos^2(r)
Solution :
t(r) = arctan(tan(r) +_C1)
"""
def dt_dr(t,r):
return (cos(t)**2)/(cos(r)**2)
rs = np.linspace(0,pi/2,1000)
t0 = 0.0 #the initial condition
ts = odeint(dt_dr,t0,rs)
ts = np.array(rs).flatten()
plt.rcParams.update({'font.size': 14})
plt.xlabel("r")
plt.ylabel("t")
plt.plot(rs,ts);
и мой текущий графический вывод:
