File:Produit convolution carre cercle.svg
Summary
Category:Unspec SVG created with Matplotlib#00050215Produit%20convolution%20carre%20cercle.svgCategory:Files by User:cdang
| Description |
Français : Produit de convolution d'une fonction porte et d'une fonction demi-cercle.
English: Convolution product of a rectangular function and a half-circle function. |
| Date | |
| Source | Own work |
| Author | Cdang |
| SVG development | |
| Source code | Python codeimport numpy as np
import matplotlib.pyplot as plt
n = 1000 # nombre de points
xmin = -2 # limites du calcul
xmax = 2
x = np.linspace(xmin, xmax, n)
dt = (xmax - xmin)/n # pas
def cercle(x):
"""Fonction cercle de centre O et de rayon 1 (équation cartésienne x² + y² = 1²)
Entrée : x, vecteur de réels (float).
Sortie : y, vecteur de réels de même dimension que x."""
bool = np.logical_and(x >= -1, x <= 1) # La fonction est nulle hors de [–1 ; 1]
y = np.zeros_like(x)
y[bool] = np.sqrt(1 - x[bool]*x[bool])
return y
def porte(x):
"""Fonction porte
Entrée : x, vecteur de réels (float)
Sortie : y, vecteur de réels de même dimension que x."""
bool = np.logical_and(x >= -1, x <= 1) # La fonction est nulle hors de [–1 ; 1]
y = np.zeros_like(x)
y[bool] = 1
return y
y1 = cercle(x)
y2 = porte(x)
plt.figure(figsize = [8, 8])
plt.rcParams["text.usetex"] = True
# Tracé des fonctions
plt.subplot(2, 1, 1)
plt.plot(x, y1, label="$f$")
plt.plot(x, y2, label="$g$")
plt.xlabel("$x$")
plt.ylabel("$y$")
plt.gca().set_aspect("equal", adjustable="box")
plt.legend()
# Calcul du produit de convolution
X = np.linspace(xmin - xmax, xmax - xmin, 2*n - 1)
Y = dt*np.convolve(y1, y2)
# Tracé du produit de convolution
plt.subplot(2, 1, 2)
plt.plot(X, Y, label="$f*g$")
plt.xlabel("$x$")
plt.ylabel("$y$")
plt.legend()
plt.suptitle("Produit de convolution")
plt.savefig("produit_convolution_carre_cercle.svg", format="svg")
|
Licensing
I, the copyright holder of this work, hereby publish it under the following license:
This file is licensed under the Creative Commons Attribution-Share Alike 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.
- share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.