Operations on Vectors
The Wolfram Language represents vectors as lists, and never needs to distinguish between row and column cases. Vectors in the Wolfram Language can always mix numbers and arbitrary symbolic or algebraic elements. The Wolfram Language uses state-of-the-art algorithms to bring platform-optimized performance to operations on extremely long, dense, and sparse vectors.
Constructing Vectors
Table — construct a vector from an expression Array — construct a vector from a function ConstantArray — construct a vector of constants SparseArray — construct a sparse vector from positions and values AngleVector ▪ FromPolarCoordinates ▪ CirclePoints
Elements of Vectors
Length — number of elements in a vector Part — extract an element of a vector ( v [ [ i ] ] ) Set — reset an element of a vector ( v [ [ i ] ] = x ) VectorQ — test whether an expression is a vector
Mathematical Operations
+ , * , ^ , . — automatically element-wise: < a , b >+ < c , d >⟶ < a + c , b + d >Dot ( . ) — scalar dot product Cross ( ) — vector cross product (entered as
cross
) Norm — norm of a vector Total — total of elements in a vector Div — divergence Curl — curl in any dimension
Vector Space Operations
VectorAngle — angle between two vectors UnitVector — unit vector along a coordinate direction Normalize — normalize a vector to unit length Projection — find the projection of one vector on another Orthogonalize — find a Gram – Schmidt orthonormal basis KroneckerProduct — Kronecker outer product
Displaying Vectors
Row , Column — display in row or column form Arrow — represent an arrow in a graphic
Vector Distance Measures »
EuclideanDistance ▪ ManhattanDistance ▪ . DistanceMatrix — matrix of pairwise distances
Grad , D — derivatives of vectors of functions and functions of vectors Thread — force any function to thread over lists
Symbolic Vectors
Indexed — represent a symbolically indexed vector
Related Tech Notes
-
▪
- Constructing Lists ▪
- Building Lists from Functions
Vector Visualization
The Wolfram Language provides state-of-the-art fully automated visualization of vector functions and data — suitable for representing flows, field lines, and other vector fields of any complexity.
Vector Plots
VectorPlot , ListVectorPlot — plot vectors from a vector field
VectorPlot3D , ListVectorPlot3D — plot vectors from a 3D vector field
SliceVectorPlot3D , ListSliceVectorPlot3D — plot vectors on a slice surface
Stream Plots
StreamPlot , ListStreamPlot — make a stream plot from a vector field
StreamPlot3D , ListStreamPlot3D — make a stream plot from a 3D vector field
Combination Plots
VectorDensityPlot , ListVectorDensityPlot — vector plot with density background
StreamDensityPlot , ListStreamDensityPlot — stream plot with density background
Convolution Plots

LineIntegralConvolutionPlot , ListLineIntegralConvolutionPlot — vector fields transforming an image
Displacement Plots
VectorDisplacementPlot , ListVectorDisplacementPlot — vector fields displacing objects
VectorDisplacementPlot3D , ListVectorDisplacementPlot3D — vector fields displacing 3D objects
Geographic Visualization »
GeoVectorPlot ▪
GeoStreamPlot ▪ .
Complex Visualization »
ComplexVectorPlot ▪
ComplexStreamPlot ▪ .
Options
StreamPoints , VectorPoints — number or placement of streamlines, vectors StreamScale — scale and size of streamlines VectorScaling , VectorSizes — scale and size of vectors StreamStyle , VectorStyle — color and style of streamlines, vectors StreamMarkers , VectorMarkers — general shape of streamlines, vectors ColorFunction , Mesh , MeshFunctions — coloring, meshing, contouring, etc. for scalars StreamColorFunction ▪ VectorColorFunction ▪ RegionFunction VectorAspectRatio ▪ VectorRange ▪ ClippingStyle
Related Guides
-
▪
- Function Visualization ▪
- Data Visualization ▪
- Differential Equations ▪
- Angles and Polar Coordinates
Related Links
Array
Array [ f , n ] generates a list of length n , with elements f [ i ] .
Array [ f , n , r ] generates a list using the index origin r .
Array [ f , n , < a , b >] generates a list using n values from a to b .
Array [ f , < n 1 , n 2 , … > ] generates an n 1 × n 2 × … array of nested lists, with elements f [ i 1 , i 2 , … ] .
Array [ f , < n 1 , n 2 , … > , < r 1 , r 2 , … > ] generates a list using the index origins r i (default 1 ).
Array [ f , dims , origin , h ] uses head h , rather than List , for each level of the array.
Details

- Parallelize [ Array [ f , n ] ] computes Array [ f , n ] in parallel on all subkernels. »
Examples
With machine-precision input, the results are always machine precision:
With exact input, the results can be to the precision specified:
Scope (20)
Mathematical Constants (4)
Evaluate mathematical constants to any precision:
Get approximate values for large integers:
Complex number results:
More elaborate symbolic mathematical constants can be detected using NumericQ :
In general, NumericQ expressions represent numbers that can be evaluated to any precision:
General Expressions (3)
Evaluate the entries of a matrix numerically:
Evaluate numerically the numeric parts of a symbolic expression:
Make the coefficients of a polynomial numerical:
Machine and Adaptive Precision (4)
N [ e ] typically works by replacing numbers with machine numbers and computing the result:
This is equivalent to the expression with machine numbers:
The machine roundoff error shows up clearly on a log-log plot of the difference quotient error:
N [ e , p ] works adaptively using arbitrary-precision numbers when p is not MachinePrecision :
With adaptive precision, the difference quotient error matches the theoretical value:
The adaptive precision control has a default limit, $MaxExtraPrecision , for extra precision:
When the limit is reached, you can locally increase $MaxExtraPrecision to resolve the difficulty:
N does not raise the precision of approximate numbers in its input:
The precision of the result is the same as that of the input:
You can use SetPrecision to increase the precision of input expressions:
Data Objects and Special Rules (5)
N does not affect exact numeric powers:
The base is modified:
The power is modified if it is not NumericQ :
SparseArray objects are treated based on the represented array:
In general, N [ Normal [ s ] ] is identical to Normal [ N [ s ] ] :
Data objects like InterpolatingFunction have special rules so that only the data is affected:
Only the appropriate data has been changed so that the new function uses machine numbers:
Operations like Integrate use the corresponding N -functions when appropriate:
For high requested precision, numerical algorithms may take a lot of time or need adjustment:
In this case, you may want to use NIntegrate directly:
For most expressions, N affects the tree shown in FullForm :
The 1. appears in front of x because of how e is represented:
The integers in e have just been converted to machine numbers:
Defining Special Rules (4)
Prevent an indexed variable from being affected by N using the NHoldAll attribute:
With this, N only affects the coefficients:
Without this, N affects the indices too:

Define a numerical constant equal to :
In an exact symbolic expression, the constant does not evaluate:
Add a definition that will work with arbitrary precision or accuracy:
Numerically evaluate an expression to accuracy 20:
Define a function that represents the real-valued root
for positive
and positive integer
:
Prevent its second argument from being converted to real using NHoldRest :
An exact representation of the cube root of 2:
Define a data object that represents a polynomial
in a sparse form 
A representation of the polynomial :
Get the representation with approximate real coefficients:

Evaluate at :
Generalizations & Extensions (3)
5-digit accuracy and any precision:
1-digit accuracy, corresponding to integer part only:
Get either 20-digit precision or 30-digit accuracy:
Properties & Relations (3)
The result of N [ e ] generally has precision MachinePrecision :
If the result is too large for machine numbers, the precision may be different:
The result of N [ e , p ] generally has Precision equal to p :
When this is not possible, the Wolfram Language will give a message:
Typically, increasing $MaxExtraPrecision will resolve the problem:
For hidden zeros, positive precision is not achievable, so you may want to use accuracy:
The result of N [ e , < ∞ , a >] generally has Accuracy equal to a :
When this is not possible, the Wolfram Language will give a message:
Typically, increasing $MaxExtraPrecision will resolve the problem:
Neat Examples (1)

A -digit texture:
See Also
Tech Notes
-
▪
- Numerical Mathematics: Basic Operations ▪
- Exact and Approximate Results ▪
- Arbitrary ‐ Precision Calculations ▪
- Numerical Precision ▪
- Arbitrary ‐ Precision Numbers ▪
- Defining Numerical Values ▪
- Implementation notes: Numerical and Related Functions
Related Guides
-
▪
- Numerical Evaluation & Precision ▪
- Precision & Accuracy Control ▪
- Display of Numbers
Related Links
- Fast Introduction for Programmers: Numbers
- An Elementary Introduction to the Wolfram Language: Starting Out: Elementary Arithmetic
- An Elementary Introduction to the Wolfram Language: Ways to Apply Functions
- An Elementary Introduction to the Wolfram Language: Writing Good Code
History
Introduced in 1988 (1.0) | Updated in 1996 (3.0) ▪ 1999 (4.0) ▪ 2003 (5.0)