我想将这段 Mathematica 代码重写为 Python,但当时我很困惑,请帮助我!非常感谢。也许集成的结果与数组不同,但是,我不知道!
那时我对python代码感到困扰......
# -*- coding: utf-8 -*-
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
import math
import scipy as sp
from pylab import *
#from scipy import *
from scipy.integrate import quad, dblquad, tplquad
plt.figure('God Bless : fig1')
plt.title(r'fig1_')
plt.xlabel(r'z')
plt.ylabel('$L_0$(erg $s^{-1}$)')
#plt.axis([0,10,-2,2])
Limit = 1.e48
c = 2.997e10
Om = 0.27
H0 = 70e5/(1.e6*3.86e18)
z = np.arange(0,10, 0.01)
def dLz(z):
return 1./(1.-Om + Om*(1.+z)**3.)**(1./2)
val, abserr = quad(dLz, 0, 10)
print ("integral value =", val, ", absolute error =", abserr)
dL = val
Fmin = 2.0e-8
Llimit = 4.0*np.pi*dL**2*Fmin
plt.plot(z, Limit)
plt.savefig('fig_1.eps', dpi=300)
plt.show()