m (→XVIII. Differential calculus of vector fields) |
m |
||
Line 45: | Line 45: | ||
Starting with the gradient: | Starting with the gradient: | ||
+ | |||
+ | To fix idea, we will define a function that looks like a mountain landscape, as follows: | ||
+ | |||
+ | <syntaxhighlight lang="python"> | ||
+ | function f(x,y) | ||
+ | (cos(x*y)*y*((x-0.5)^2+(y-0.15)))^2*exp(-x^2-y^2/2) | ||
+ | end | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | |||
divergence | divergence |
This page is still largely in progress.
We are now going to start looking at differential calculus in higher dimensions. Before we look at equations, in which case we tackle the general problem of partial differential equations, we consider derivatives of fields, either scalar or vector. A scalar can be regarded as a 1D vector so this lecture is about differential calculus of vector fields. We will focus on 2D fields for ease of visualisation but the principle would apply similarly to higher dimensions.
The main differential operators of vector calculus are:
for a scalar $f(x,y)$ and vector $\vec F(x,y)$ fields, respectively. The vectorf field consists itself of two scalar fields $F_x$ and $F_y$:
$$\vec F(x,y)\equiv F_x(x,y)\hat\imath+F_y(x,y)\hat\jmath$$
We can now remind the definitions and physical meaning of the differential operators (remember, in 2D):
Derive the above results from a literal understanding of $\nabla$ as the vector $\begin{pmatrix}\partial_x\\\partial_y\end{pmatrix}$ and check the character of the resulting object in each case (scalar or vector).
The gradient is obtained from $\begin{pmatrix}u_1\\u_2\end{pmatrix}\alpha=\begin{pmatrix}u_1 \alpha\\u_2\alpha\end{pmatrix}$ where, however, we are careful not to commute $\alpha$ (here $f$) with the vectors components (which are, here, operators). It is, clearly, a vector, and provides both a direction (where the function is changing the most) and a magnitude (by how much it is changing).
The divergence is obtained by computing a scalar product $\vec u\cdot\vec v=u_xv_x+u_yv_y$ which gives the expression above. It is, as the name spells out, a scalar.
The vector product is specifically 3D (e.g., it does not apply to 4D objects) and is, in general and as the name again spells out, a vector. It can still still be defined for a 2D object, where it reduces to a vector in the third dimension (perpendicular to the field) as a consequence of its 3D origin. It can thus be considered, in this special case, as a scalar field as well: $\begin{vmatrix} \hat\imath & \hat\jmath & \hat k\\ \partial_x & \partial_y & 0\\ F_x & F_y & 0 \end{vmatrix} = \begin{pmatrix} 0\\0\\\partial_x F_y-\partial_y F_x \end{pmatrix}\,.$
... definition of grid ...
Starting with the gradient:
To fix idea, we will define a function that looks like a mountain landscape, as follows:
function f(x,y) (cos(x*y)*y*((x-0.5)^2+(y-0.15)))^2*exp(-x^2-y^2/2) end
divergence
curl