File:Integration simpson.svg
Summary
Description |
English: Numerical integration by the Simpson's Method. The function being used is . The interval is split in 15 pieces.
Español: Integración numérica por el método de Simpson. La función a integrar es . El intervalo está partido en 15 sub-intervalos. |
Date | |
Source | Own work |
Author | Nicoguaro |
SVG development | |
Source code | Python codefrom __future__ import division
import numpy as np
import matplotlib.pyplot as plt
from scipy.interpolate import interp1d
# Interpolation data
x = np.linspace(-2, 2, 15)
y = x**2 + np.sin(2*np.pi*x)
f = interp1d(x, y, kind='quadratic')
# Fine data
x = np.linspace(-2, 2, 200)
y = x**2 + np.sin(2*np.pi*x)
# Plots
fig = plt.figure(figsize=(4.5, 1))
ax = plt.subplot(1, 1, 1)
plt.plot(x, y, lw=2, zorder=6)
plt.plot(x, f(x), '--r', lw=2, zorder=7)
plt.ylim(-1.5, 4.75)
plt.xticks([-2, -1, 0, 1, 2])
plt.yticks([0, 2, 4])
plt.grid(b=True, lw=2, color='gray', linestyle='solid', alpha=0.5,
zorder=3)
ax.spines['right'].set_color('none')
ax.spines['top'].set_color('none')
plt.savefig('Integration_simpson.svg', bbox_inches='tight')
plt.show()
|
Licensing
I, the copyright holder of this work, hereby publish it under the following license:
This file is licensed under the Creative Commons Attribution 4.0 International license.
- You are free:
- to share – to copy, distribute and transmit the work
- to remix – to adapt the work
- Under the following conditions:
- attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.