Fractals/Mathematics/Vector field
Vector field^{[1]}
Here mainly numerical methods for time independent 2D vector fields are described.
DictionaryEdit
 vector function is a function that gives vector as an output
 field : space (plane, sphere, ... )
 field line is a line that is everywhere tangent to a given vector field
 scalar/ vector / tensor:
 Scalars are real numbers used in linear algebra. Scalar is a tensor of zero order
 Vector is a tensor of first order. Vector is an extension of scalar
 tensor is an extension of vector
VectorEdit
Forms of 2D vector:^{[2]}
 [z1] ( only one complex number when first point is known , for example z0 is origin
 [z0, z1] = two complex numbers
 4 scalars ( real numbers)
 [x, y, dx , dy]
 [x0, y0, x1, y1]
 [x, y, angle, magnitude]
 2 scalars : [x1, y1] for second complex number when first point is known , for example z0 is origin
gradientEdit
The numerical gradient of a function:
 "is a way to estimate the values of the partial derivatives in each dimension using the known values of the function at certain points."^{[3]}
Gradient function G of function f at point (x0,y0)
G(f,x0,y0) = (x1,y1)
Input
 function f
 point (x0,y0) where gradient is computed
Output:
 vector from (x0,yo) to (x1,y1) = gradient
See:
Computation:^{[4]}
 "The gradient is calculated as: (f(x + h)  f(x  h)) / (2*h) where h is a small number, typically 1e5 f(x) will be called for each input elements with +h and h pertubation. For gradient checking, recommend using float64 types to assure numerical precision."^{[5]}
 in matlab^{[6]}^{[7]}
 in R^{[8]}
 python^{[9]}
Field typesEdit
 time independent (= stationary = Steady ) or time dependent ( unsteady flow)
 dimension: 2D, 3D, ...
 mesh ( grid) type
 scalar function
 potential
 electric, magnetic, ...
 vector function
 equation ( for symbolic computations)  ODE
 numerical values ( for numerical computations)
 field line integration method (scheme):^{[10]}
Force fieldEdit
A gravitational force fields
 the field lines are the solution of
 the trajectory of a test mass is the solution of
where
 g is the standard gravity
 m is a mass
 F is a force field
An electric field
 The field lines are the paths that a point positive charge would follow as it is forced to move within the field. Field lines due to stationary charges have several important properties, including always originating from positive charges and terminating at negative charges, they enter all good conductors at right angles, and they never cross or close in on themselves. The field lines are a representative concept; the field actually permeates all the intervening space between the lines. More or fewer lines may be drawn depending on the precision to which it is desired to represent the field. The study of electric fields created by stationary charges is called electrostatics.

Diagram of electric charges induced in conductive objects (shapes) by the electrostatic field (lines with arrows) of a nearby charge (+), due to electrostatic induction

Electric field around two identical conducting spheres at opposite electric potential
AlgorithmEdit
 start with
 plane (parameter plane or dynamic plane)
 scalar function
 vector function
 create scalar field using scalar function ( potential)
 create vector field from scalar field using vector function ( gradient of the potential)
 compute:
 filed lines ( stream lines )
 contour lines ( equipotential lines )
 map whole field using
 Line Integral Convolution (LIC)
gradient descentEdit
 Gradient Descent by Aytan Hajiyeva Aytan Hajiyeva Oct 1, 2021
 Gradient Descent algorithm by Raghunath D Raghunath D Jan 28, 2019
 An overview of gradient descent optimization algorithms by SEBASTIAN RUDER 19 JAN 2016 and pdf from arxiv
 Escaping from Saddle Points by Rong Ge • Mar 22, 2016
 An Easy Guide to Gradient Descent in Machine Learning By Great Learning Team May 24, 2020
 Gradient Descent in Python Sagar Mainkar Sagar Mainkar Aug 25, 2018
Field line computingEdit
Problem Statement:
 Field line tracing ( not curve sketching^{[11]}}
 drawing contour maps ( in computer graphic) = Numerical continuation ( in math)
 compute an integral curve from a seed point through a vector field without any analysis of its structure on the uniform grid ( raster scan or pixels)

Natural parameter continuation, a very simple adaptation of the iterative solver to a parametrized problem

Simplicial linear continuation algorithm.

Pseudoarclength continuation, based on the observation that the "ideal" parameterization of a curve is arclength, is an approximation of the arclength in the tangent space of the curve\

Methods ( solvers) available for the fieldlines^{[12]}^{[13]}
 Euler^{[14]}
 RK2
 RK3
 RK4  the original authors of those sampling algorithms: Runge und Kutta.^{[15]}
None of these 4 methods generate an exact answer, but they are (from left to right) increasingly more accurate. They also take (from left to right) more and more time to finish as they require more samples for each iteration. You won't be able to create reliably closed curves using iterative sampling methods as small errors at any step may be amplified in successive steps. There is also no guarantee that the fieldline ends up in the exact coordinate where it started. The Grasshopper metaball solver on the other hand uses a marching squares algorithm which is capable of finding closed loops because it is a gridcell approach and sampling inaccuracy in one area doesn't carry over to another. However the solving of isocurves is a very different process from the solving of particle trajectories through fields. ... Typically field lines shoot to infinity rather than form closed loops. That is one reason why I chose the RK methods here, because marchingcubes is very bad at dealing with things that tend to infinity.^{[16]}
ConstructionEdit
Given a vector field and a starting point a field line can be constructed iteratively by finding the field vector at that point . The unit tangent vector at that point is: . By moving a short distance along the field direction a new point on the line can be found
Then the field at that point is found and moving a further distance in that direction the next point of the field line is found
By repeating this and connecting the points,the field line can be extended as far as desired. This is only an approximation to the actual field line, since each straight segment isn't actually tangent to the field along its length, just at its starting point. But by using a small enough value for , taking a greater number of shorter steps, the field line can be approximated as closely as desired. The field line can be extended in the opposite direction from by taking each step in the opposite direction by using a negative step .
rk4 numerical integration methodEdit
Fourthorder RungeKutta (RK4) in case of 2D time independent vector field
is a vector function that for each point p
p = (x, y)
in a domain assigns a vector v
where each of the functions is a scalar function:
A field line is a line that is everywhere tangent to a given vector field.
Let r(s) be a field line given by a system of ordinary differential equations, which written on vector form is:
where:
 s representing the arc length along the field line, like for example continous iteration count
 is a seed point
2 variablesEdit
Given a seed point on the field line, the update rule ( RK4) to find the next point along the field line is^{[17]}
where:
 h is the step size along field line = ds
 k are the intermediate vectors:
only xEdit
Here
Given a seed point on the field line, the update rule ( RK4) to find the next point along the field line is^{[18]}
where:
 h is the step size along field line = dx
 k are the intermediate vectors:
Examples:
 ^{[19]}

Slope field (black), some solutions (red) and isoclines (blue) of y'=x

Three integral curves for the slope field corresponding to the differential equation dy / dx = x^{2} − x − 2
Visualisation of vector fieldEdit
Plot types (Visualization Techniques for Flow Data) : ^{[20]}
 Glyphs = Icons or signs for visualizing vector fields
 simplest glyph = Line segment (hedgehog plots)
 arrow plot = quiver plot = Hedgehogs (global arrow plots)
 Characteristic Lines ^{[21]}
 streamlines = curve everywhere tangential to the instantaneous vector (velocity) field (time independent vector field). For time independent vector field streaklines = Path lines = streak lines ^{[22]}
 texture (line integral convolution = LIC)^{[23]}
 Topological skeleton ^{[24]}
 fixed point extraction ( Jacobian)

LIC

Streamlines and streamtube

Imagebased flow visualization

Integral Curves

integral curves
"path lines, streak lines, and stream lines are identical for stationary flows" Leif Kobbelt^{[25]}
quiver plotEdit
Definition
 "A quiver plot displays velocity vectors as arrows with components (u,v) at the points (x,y)"^{[26]}
stream plotEdit
A stream plot uses stream lines
Example fieldsEdit
flowmapsEdit
 FlowMap Painter by TECK LEE TAN
 Flowmaps, gradient maps, gas giants by Martin Donald
 godot game engine
fBMEdit
fBM stands for Fractional Brownian Motion
SDFEdit
SDF = Signed Distance Function
 SDF for 2d primitives
 normals to SDF
 gradient
 i quilezles : interior distance ( SDF)
 Glyphs, shapes, fonts, signed distance fields by Martin Donald
 CSC2547 DeepSDF Learning Continuous Signed Distance Functions for Shape Representation
 2D Signed Distance Field Basics by Ronja
 snelly is a WebGL SDF pathtracer by Jamie Portsmouth
 shadertoy : SDF Raymarch Quadtree by paniq
Potential of Mandelbrot setEdit

( Empty) field : points of rectangular mesh

Scalar field : potential of Mandelbrot set

Vector field: Array plot of the gradient
ProgramsEdit
 CGAL  2D_Placement_of_Streamlines by Abdelkrim Mebarki
 Python
 OpenProcessing
 G'MIC  display_quiver
 OpenCV
 dsp.stackexchange: howtodetectgradientsinimages  Histogram of Oriented Gradients ( HOG )
 arrowed line
 Maxima CAS
 plotdf ( for ODE)
 C++
 par_streamlines ( C, WebGl) by Philip Allan Rideout, github: prideout/par
 JavaScript
 c
 vfplot  program for plotting twodimensional vector fields by J J Green
ExamplesEdit
ImagesEdit
 images from commons : Category:Field_lines
 images from commons : Category:Vector_fields
 fractalforums.org : cruisingthroughfractalflowfields
ShadertoyEdit
 arrows = quiver plot
 Line Integral Convolution (LIC)
 3D vector field
VideosEdit
See alsoEdit
ReferencesEdit
 ↑ Vector field in wikipedia
 ↑ Euclidian vector in wikipedia
 ↑ matlab : gradient function
 ↑ stackoverflow question: isthereanystandardwaytocalculatethenumericalgradient
 ↑ nnp_numerical_gradient by Mamy Ratsimbazafy
 ↑ matrixlabexamples : gradient
 ↑ matlabfunctiongradientnumericalgradient by itectec
 ↑ numDeriv : grad
 ↑ numpy : gradient
 ↑ Numerical Methods for Particle Tracing in Vector Fields by Kenneth I. Joy
 ↑ curve sketching by David Guichard and friends
 ↑ liruics : Introduction to Scientific Visualization  Flow Field
 ↑ rasteralgorithmsbasiccomputergraphicspart2 by whatwhenhow
 ↑ bolster.academy : Euler's method interactive
 ↑ interactive Runge Kutta 4 by Greg Petrics
 ↑ grasshopper3d forum: fieldlineshowtorebuildandmakeperiodic?overrideMobileRedirect=1
 ↑ Classification and visualisation of critical points in 3d vector fields. Master thesis by Furuheim and Aasen
 ↑ Classification and visualisation of critical points in 3d vector fields. Master thesis by Furuheim and Aasen
 ↑ Weisstein, Eric W. "Integral Curve." From MathWorldA Wolfram Web Resource
 ↑ Flow Visualisation from TUV
 ↑ Data visualisation by Tomáš Fabián
 ↑ A Streakline Representation of Flow in Crowded Scenes from UCF
 ↑ lic by Zhanping Liu
 ↑ Vector Field Topology in Flow Analysis and Visualization by Guoning Chen
 ↑ Vector Field Visualization by Leif Kobbelt
 ↑ matlab ref : quiver plot
 How I built a wind map with WebGL by Vladimir Agafonkin
 math.stackexchange question : whatdopolynomialslooklikeinthecomplexplane
 mathematica.stackexchange question : visualizingacomplexvectorfieldnearpoles
 fractalforums.com : smoothexternalangleofmandelbrotset
 J.M. Hyman, M. Shashkov, Natural discretizations for the divergence, gradient, and curl on logically rectangular grids, Computers & Mathematics with Applications, Volume 33, Issue 4, 1997, Pages 81104, ISSN 08981221