| Hosted by CoCalc | Download
Kernel: Python 3 (system-wide)
import sys sys.version
'3.6.9 (default, Nov 7 2019, 10:44:02) \n[GCC 8.3.0]'
from scipy.integrate import quad
import numpy as np def f(x): return 2 * x**2 - 5 * x + 1 def g(x): a = np.sin(f(x - 1)) b = f(x**2) return a * b
quad(g, -5, 5)
(-88.47259860602325, 6.792159306545877e-07)
xx = np.linspace(-5, 5, 1000) yy = g(xx)
import matplotlib.pyplot as plt plt.plot(xx, yy) plt.grid()
Image in a Jupyter notebook
def f(a, b): def wrapped(r): return a * r + b return wrapped
f2 = f(2, 5) f2(10)
25
def f(sigma, epsilon): def U(r): return 4*epsilon*(((sigma/r)**12)-((sigma/r)**6)) return U def F(r,k,T,U): return (r**2)*(1-(np.exp((-U(r))/(k*T))))
F(3, 1.2, 2.2, f(3.3, 4.4))
8.999007441495761
from scipy.integrate import quad quad(lambda x : F(x, 1.2, 2.2, f(3.3, 4.4)), 0, 1000)
(-74.2454923933048, 1.1421246344685276e-07)