Fichier:Vector Field of a Function's Gradient imposed over a Color Plot of that Function.svg

Le contenu de la page n’est pas pris en charge dans d’autres langues.
Une page de Wikipédia, l'encyclopédie libre.

Fichier d’origine(Fichier SVG, nominalement de 720 × 360 pixels, taille : 280 kio)

Ce fichier et sa description proviennent de Wikimedia Commons.

Description

Description
English: An arrow plot of the gradient of the function , superimposed over a color plot of the values of that function, demonstrating that the gradient yields a vector field of a given function.

The plot was generated using Numpy and Matplotlib in Python 3.11.0 using the following code:

import matplotlib.pyplot as plt
import numpy as np

# Returns the partial derivative with respect to the `i`th parameter of the
# given function. This is done using the method of finite differences 
def partial_derivative(f, i=0, h=0.001e-10):
    def partial(*xs):
        dxs = list(xs)
        dxs[i] = xs[i] + h
        return (f(*dxs)-f(*xs))/h
    return partial

# Returns an np.array (a vector) of partial derivatives with respect to each
# parameter given, ie the gradient
def gradient(f):
    def gradient_of_f(*xs):
        return np.array([partial_derivative(f, i)(*xs) for i in range(len(xs))])
    return gradient_of_f

# The function to be plotted. It contains, by construction, an adjacent 'sink' and
# 'source'. These features demonstrate that the gradient operator yields a vector
# field wherein each vector points from sinks (lower values) to sources (higher values)
def f(x, y):
    return x * np.exp(-1 * (x**2 + y**2))

# Here we construct our domain (the inputs) by discretizing the space between -2 and 2
# into 25 evenly spaced points. This is done for both the x and y dimensions.
n = 25
x = np.linspace(-2, 2, n)
y = np.linspace(-2, 2, n)

# Then we generate a grid of points from our two dimensions, on which we'll evaluate
# the above function
x, y = np.meshgrid(x, y)

# Then we do said evaluating
z = f(x, y)

# And generate it's gradient. Note that `gradient` returns a single array, for plotting
# convenience I've separated out the the dx and dy parts.
dzdx, dzdy = gradient(f)(x, y)

# And finally we generate the plot
plt.figure(figsize=(8, 4))
plt.pcolormesh(x, y, z)
plt.quiver(x, y, dzdx, dzdy, scale=n, pivot='mid', headwidth=4, minshaft=2, minlength=2)
plt.colorbar()
plt.plot()
Date
Source Travail personnel
Auteur Colejhudson

Conditions d’utilisation

Moi, en tant que détenteur des droits d’auteur sur cette œuvre, je la publie sous la licence suivante :
w:fr:Creative Commons
paternité partage à l’identique
Vous êtes libre :
  • de partager – de copier, distribuer et transmettre cette œuvre
  • d’adapter – de modifier cette œuvre
Sous les conditions suivantes :
  • paternité – Vous devez donner les informations appropriées concernant l'auteur, fournir un lien vers la licence et indiquer si des modifications ont été faites. Vous pouvez faire cela par tout moyen raisonnable, mais en aucune façon suggérant que l’auteur vous soutient ou approuve l’utilisation que vous en faites.
  • partage à l’identique – Si vous modifiez, transformez, ou vous basez sur cette œuvre, vous devez distribuer votre contribution sous la même licence ou une licence compatible avec celle de l’original.

Légendes

Ajoutez en une ligne la description de ce que représente ce fichier
An arrow plot of the gradient of a function, superimposed over a color plot of the values of that function, demonstrating that the gradient yields a vector field of a given function.

Valeur sans élément de Wikidata

image/svg+xml

Historique du fichier

Cliquer sur une date et heure pour voir le fichier tel qu'il était à ce moment-là.

Date et heureVignetteDimensionsUtilisateurCommentaire
actuel8 janvier 2023 à 21:40Vignette pour la version du 8 janvier 2023 à 21:40720 × 360 (280 kio)ColejhudsonUploaded own work with UploadWizard

Aucune page n’utilise ce fichier.

Usage global du fichier

Les autres wikis suivants utilisent ce fichier :

  • Utilisation sur en.wikipedia.org
  • Utilisation sur sq.wikipedia.org

Métadonnées