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

Page contents not supported in other languages.
Nga Wikipedia, enciklopedia e lirë

Dokument origjinal(skedë SVG, fillimisht 720 × 360 pixel, madhësia e skedës: 280 KB)

Kjo skedë është prej Wikimedia Commons dhe mund të përdoret nga projekte të tjera. Përshkrimi në këtë skedë në këtë faqe nuk është treguar më poshtë. Shko tek faqja përshkruese në Commons Shko tek faqja përshkruese në Commons

Përmbledhje

Përshkrimi
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()
Data
Burimi Punë e juaja
Autori Colejhudson

Licencim

Unë, krijuesi i kësaj pune, e publikoj këtu në bazë të licensës në vijim:
w:sq:Creative Commons
atribuim share alike
This file is licensed under the Creative Commons Attribution-Share Alike 4.0 International license.
Je i lirë të:
  • ta shpërndani – ta kopjoni, rishpërndani dhe përcillni punën
  • t’i bëni “remix” – të përshtatni punën
Sipas kushteve të mëposhtme:
  • atribuim – Duhet t’i jepni meritat e duhura, të siguroni një lidhje për tek licenca dhe të tregoni nëse janë bërë ndryshime. Këtë mund ta bëni në ndonjë mënyrë të arsyeshme, por jo në ndonjë mënyrë që sugjeron se licencuesi ju del zot juve apo përdorimit tuaj.
  • share alike – Nëse bëni një “remix”, e shndërroni, ose ndërtoni duke u bazuar te materiali, duhet t’i shpërndani kontributet tuaja sipas të njëjtës licencë ose një të tille të përputhshme me origjinalen.

Captions

Add a one-line explanation of what this file represents
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.

Items portrayed in this file

përshkruan

8 janar 2023

image/svg+xml

Historiku skedës

Shtypni mbi një datë/kohë për ta parë skedën siç ishte atëherë.

Data/KohaMiniaturëPërmasatPërdoruesiKoment
e tanishme8 janar 2023 21:40Miniaturë për versionin duke filluar nga 8 janar 2023 21:40720 × 360 (280 KB)ColejhudsonUploaded own work with UploadWizard

Këto faqe lidhen tek kjo skedë:

Përdorimi global i skedës

Kjo skedë përdoret nga Wiki të tjera në vijim:

  • Përdorimi në en.wikipedia.org

Metadata