scipy.integrate.quad 是如何取点的

Table of Contents

探究 scipy.integrate.quad 取点的方式

import numpy as np
from scipy import integrate
import matplotlib.pyplot as plt

nodes = []


def foo(x):
    nodes.append(x)
    return np.exp(x) + np.sin(10*x)**2 + np.exp(x)**100


result = integrate.quad(foo, -1, 1, epsrel=1e-125, limit=2, full_output=1)
n = np.linspace(1, len(nodes), len(nodes))
print(len(nodes))
print(len(nodes)/21)
print(result[2]['neval'])
plt.plot(n, nodes, '*')
plt.grid()
plt.title('limit = 2')
plt.xlabel(r"$i$")
plt.ylabel("position of $i$th node")
plt.savefig('fig.png')

code

fig.png

1. Reference

Date: 2021-09-16 Thu 00:00

Created: 2022-04-18 Mon 20:39

Validate