<jupyter_start><jupyter_text>Vector Fields
We can denote a vector field with the vector F has a function of x and y like this: F(x,y)

We can also write it in 3d like this: F(x,y,z)

$ \vec{F}(x,y,z) = P(x,y,z)*\vec{i}+Q(x,y,z)*\vec{j}+R(x,y,z)*\vec{k} $  Example Problem 1:

$ \vec{F}(x,y) = -y*\vec{i}+x*\vec{j} $

Graph the Vector Field<jupyter_code>import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline

x,y = np.meshgrid(np.linspace(-5,5,10),np.linspace(-5,5,10))

u = -y
v = x

plt.quiver(x,y,u,v)
plt.show()<jupyter_output><empty_output><jupyter_text>As you can see, the function follows a circular path centered at the origin. The length of each arrow is dependent on the x and y value chosen. The further away the end of the arrow is from the origin, the larger the arrow will be. Each arrow is tangent to a circle centered at the origin.

To calculate the radius of the circle, we take the following steps:

$ 
  r = \sqrt{x^2+y^2}
$
  Example Problem 2:

$ \vec{f}(x,y) = x^2y\vec{i}-y^3\vec{j} $

Plot the gradient vector field and the contour map of the original function Our first step is to calculate the gradient of $ \vec{f} $. We do this by taking the derivative of the P and Q function in f:

$ P = df/dx $

$ df/dx = 2xy $

$ Q = df/dy $

$ df/dy = x^2-3y^2 $

So our final gradient of f is as follows:

$ \nabla{\vec{f}} = 2xy\vec{i}+(x^2-3y^2)\vec{j} $

Now we can graph the gradient and our contour map<jupyter_code>x,y = np.meshgrid(np.linspace(-5,5,10),np.linspace(-5,5,10))

u = 2*x*y
v = x**2-3*y**2

plt.quiver(x,y,u,v)

xlist = np.linspace(-5.0, 5.0, 100)
ylist = np.linspace(-5.0, 5.0, 100)
X, Y = np.meshgrid(xlist, ylist)
Z = Y*X**2 - Y**3
plt.contour(X,Y,Z)

plt.show()<jupyter_output><empty_output><jupyter_text>The Vector Field shown here are perpendicular to the contour map, which would make sense considering the vector field is of the gradient vector of f.

**If $ \vec{F} $ is conservative, then $ f $ exists such that $ \vec{F} = \nabla{f} $**<jupyter_code><jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14658925979680695, 'fraction_numerical': 0.02467343976777939, 'mean_word_length': 3.9121140142517814, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '498060', 'license': 'Apache-2.0', 'n_tokens_mistral': 843, 'n_tokens_neox': 829, 'n_words': 262, 'path': '_notebooks/2021-01-01-Vector-Fields.ipynb', 'repo_name': 'moonbeam87/devpatel', 'size': '2067'}