VectorSymbol[v]
represents a vector with name v.
VectorSymbol[v,d]
represents a vector of length d.
VectorSymbol[v,d,dom]
represents a vector with elements in the domain dom.
VectorSymbol
VectorSymbol[v]
represents a vector with name v.
VectorSymbol[v,d]
represents a vector of length d.
VectorSymbol[v,d,dom]
represents a vector with elements in the domain dom.
Details
- The name v in VectorSymbol[v,d,dom] can be any expression.
- A valid dimension specification d in VectorSymbol[v,d,dom] is any positive integer. It is also possible to work with symbolic dimension specifications.
- Element domain specifications dom in VectorSymbol[v,d,dom] include:
-
Complexes complex numbers Integers integers Reals real numbers NonNegativeReals real numbers x with x≥0 PositiveReals real numbers x with x>0 - In arithmetic and many other functions that work with lists, VectorSymbol objects do not automatically combine with other list arguments.
- Optimization functions, equation solvers and D recognize that VectorSymbol objects represent vector variables.
Examples
open all close allBasic Examples (1)
Assign the value of the variable v to represent a length n vector with name "v":
v = VectorSymbol["v", n]Arithmetic operations recognize that v is not a scalar:
v + w + {1, 2}v - vD recognizes that v is a vector variable:
D[v.v, v]Scope (5)
Compute derivatives with respect to a vector variable:
v = VectorSymbol["v", n];D[v, v]D[Total[v], v]D[Moment[v, r], v]Compute derivatives involving vector-valued functions:
v = VectorSymbol["v", n];D[v[x].v[x], x]D[Mean[v[x]], x]This requires a real-valued vector:
u = VectorSymbol["u", n, Reals];D[StandardDeviation[u], u]Use a vector variable in optimization:
v = VectorSymbol["v", 3];ConvexOptimization[v.{1, 2, 3}, v.v <= 9, v]Minimize[{Norm[v], Total[v] >= 3}, v]Solve equations and inequalities involving a vector variable:
v = VectorSymbol["v", 3];Solve[v.{1, 2, 3} == 4 && v.v == 5 && Total[v] == 6, v]FindInstance[v.v == 1 && Total[v] >= 3 / 2, v]Applications (7)
Use a symbolic vector as a variable for optimization:
x = VectorSymbol["x", 3];Find the vector that has the smallest sum of elements with a constraint:
LinearOptimization[Total[x], Total[x + {1, 2, 3}] >= 4, x]Using a variable y treated by default as a scalar does not work since Total[y + {1,2,3}] expands:
Total[y + {1, 2, 3}]Find the radius
and center
of a minimal enclosing ball that encompasses a set of k points in n dimensions:
n = 3;
k = 47;c = VectorSymbol["c", n];
p = RandomReal[{-1, 1}, {k, n}];The ball encloses point
if Norm[pi-c]<=r:
res = ConvexOptimization[r, Table[Norm[Indexed[p, {i}] - c] <= r, {i, k}], {r, c}]Visualize the sphere and points:
Graphics3D[{Point[p], {Opacity[0.2], LightBlue, Ball[c, r] /. res}}]The optimization works in any dimension:
n = 7;
k = 33;c = VectorSymbol["c", n];
p = RandomReal[{-1, 1}, {k, n}];
ConvexOptimization[r, Table[Norm[Indexed[p, {i}] - c] <= r, {i, k}], {r, c}]Solve a differential equation for a vector-valued function:
y = VectorSymbol["y"];equation = y'[t] + (1 + t) y[t];
sol = First[NDSolve[{equation == {0, 0}, y[0] == {1, -1}}, y, {t, 0, 1}]];Plot[y[t] /. sol, {t, 0, 1}]Check that the residual is small:
Plot[equation /. sol, {t, 0, 1}]Approximate the variance for a perturbed vector:
u = RandomInteger[{-10 ^ 6, 10 ^ 6}, {7}] / 10 ^ 6;
eps = RandomInteger[{-10 ^ 6, 10 ^ 6}, {7}] / 10 ^ 16;t0 = Variance[u];N[Variance[u + eps] - t0, 20]v = VectorSymbol["v", 7, Reals];
d1 = D[Variance[v], v]t1 = t0 + (d1 /. v -> u).eps;N[Variance[u + eps] - t1, 20]d2 = D[d1, v]t2 = t1 + 1 / 2Normal[d2].eps.eps;Since the second derivative does not depend on
, the order-two approximation equals the exact value:
Variance[u + eps] - t2Find GammaDistribution parameters that best fit the given data using the maximum likelihood method:
SeedRandom[1234];data = RandomVariate[GammaDistribution[1, 2], 1000];f = Refine[PDF[GammaDistribution[α, β]][x], x > 0]Maximize the log-likelihood function
:
v = VectorSymbol["v", 1000];l = Total[Log[f /. x -> v]]dl = D[l, {{α, β}}]Find a zero of the gradient, with
replaced by
:
eqns = Thread[Expand[Normal[dl /. v -> data]] == 0]NSolve[eqns, {α, β}, MaxRoots -> 1]Show[{Histogram[data, Automatic, "PDF"], Plot[PDF[GammaDistribution[α, β] /. %[[1]]][x], {x, 0, 9}]}]Compare with the result computed using EstimatedDistribution:
EstimatedDistribution[data, GammaDistribution[α, β]]Find an optimality condition for a portfolio optimization problem with the expected return
and standard deviation
:
x = VectorSymbol["x", n];
μ = VectorSymbol["μ", n];
Σ = MatrixSymbol["Σ", {n, n}];
Subscript[μ, p] = μ.x;
Subscript[σ, p] = Sqrt[x.Σ.x];The goal is to maximize
when the vector
of asset weights satisfies
. The constraint can be used to represent
, where the unconstrained vector variable
consists of the first
coordinates of
:
A = MatrixSymbol["A", {n, n - 1}];
y = VectorSymbol["y", n - 1];
b = UnitVector[n, n];The maximum occurs at a critical point of
:
cond = D[Subscript[μ, p] / Subscript[σ, p] /. x -> A.y + b, y] == 0Express the condition in terms of
:
cond /. A.y + b -> xCompute the gradient of the log-likelihood function of the linear regression model represented by the equation
, where
are normally distributed random variables with mean zero and variance
:
y = VectorSymbol["y", n];
X = MatrixSymbol["X", {n, k}];
β = VectorSymbol["β", k];
u = VectorSymbol["u", n];The log-likelihood function
is given by:
l = -n / 2Log[σsquared] - 1 / (2σsquared)u.uSubscript[l, β] = D[l /. u -> y - X.β, β]Express the result in terms of
:
Subscript[l, β] /. y - X.β -> uSubscript[l, σ^2] = D[l, σsquared]Properties & Relations (3)
A vector symbol is a tensor of rank 1:
TensorRank[VectorSymbol["a"]]Use TensorDimensions to get the dimensions of a matrix symbol:
TensorDimensions[VectorSymbol["a", {d}]]VectorSymbol["name"] represents a matrix of unknown dimensions:
TensorDimensions[VectorSymbol["a"]]ArraySymbol[a,m] and VectorSymbol[a,m] both represent vectors:
TensorDimensions[VectorSymbol["a", m]] == TensorDimensions[ArraySymbol["a", m]]Related Guides
History
Text
Wolfram Research (2024), VectorSymbol, Wolfram Language function, https://reference.wolfram.com/language/ref/VectorSymbol.html.
CMS
Wolfram Language. 2024. "VectorSymbol." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/VectorSymbol.html.
APA
Wolfram Language. (2024). VectorSymbol. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/VectorSymbol.html
BibTeX
@misc{reference.wolfram_2026_vectorsymbol, author="Wolfram Research", title="{VectorSymbol}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/VectorSymbol.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_vectorsymbol, organization={Wolfram Research}, title={VectorSymbol}, year={2024}, url={https://reference.wolfram.com/language/ref/VectorSymbol.html}, note=[Accessed: 13-June-2026]}