I was going to include Indexed in this answer, thinking that it operated much as a List-only Part equivalent, but I ran into a surprise:

Indexed[(a A + a B), 1]

During evaluation of In[13]:= Indexed::itv: a A is not a list or valid tensor variable. >>

During evaluation of In[13]:= Indexed::itv: a B is not a list or valid tensor variable. >>

Indexed[a A, {1}] + Indexed[a B, {1}]
  1. Is it documented that Indexed threads over addition (Plus)?

  2. What other heads does it thread over?

  3. Since e.g. a A can become a list or tensor can this message be safely turned off?

  • $\begingroup$ Interesting. I managed to fully miss this function's introduction. $\endgroup$ – Sjoerd C. de Vries Oct 18 '14 at 19:32
  • $\begingroup$ The documentation is very short and not explicit, as far as I can tell, but, isn't it implicit in the fact that is listed under Symbolic Vectors and in part when it says that Indexed[x, n] works like the n<sup>th</sup> component of the symbolic vector x? $\endgroup$ – rhermans Oct 18 '14 at 19:40
  • $\begingroup$ @rhermans Would you consider expounding on that in an answer? $\endgroup$ – Mr.Wizard Jun 1 '15 at 15:43
  • 1
    $\begingroup$ Even if it was not documented, it makes sense for it to thread over addition; it reflects the property that the component of a sum of two tensors is the sum of the corresponding components of the two. It is weird that it complains about Times[], since one can have the Hadamard product… $\endgroup$ – J. M. is away Feb 21 '16 at 18:46
  • 1
    $\begingroup$ I can't really think of any other operation it can be threaded on. Speaking of Times[] + Indexed[] weirdness, one would then expect Indexed[p - q, j] to expand appropriately, but it does not… oh well. $\endgroup$ – J. M. is away Feb 21 '16 at 18:52


Prompted by comments from J. M. I ran a brute-force check on System` Symbols to see if anything else threaded, or if this is a Plus-specific behavior.

  Join @@ MakeExpression @ Names["System`*"],
  h_Symbol :> Head @ Indexed[Unevaluated @ h["a", "b"], {1}]
] // Quiet // Tally
{{Indexed, 5474}, {String, 1}, {Plus, 1}}

So indeed it seems that Plus is unique as a head Indexed threads over. {String, 1} comes from List["a", "b"]; everything else retains the head Indexed.

Indexed::itv: message

I checked for the Indexed::itv: ... is not a list or valid tensor variable message as well. I have not figured out what is special about these particular Symbols but maybe someone else can spot the pattern.

  Join @@ MakeExpression @ Names["System`*"],
  h_Symbol :> 
    Check[Indexed[Unevaluated @ h["a", "b"], {1}], Sow @ Defer[h], Indexed::itv]
]; // Quiet // Reap // Last // Last
{Abs, AiryAi, AiryAiPrime, AiryBi, AiryBiPrime, Alternatives, And, ArcCos, ArcCosh,
ArcCot, ArcCoth, ArcCsc, ArcCsch, ArcSec, ArcSech, ArcSin, ArcSinh, ArcTan,
ArcTanh, Arg, ArithmeticGeometricMean, Ball, BarnesG, BartlettHannWindow,
BartlettWindow, BernsteinBasis, BesselI, BesselJ, BesselK, BesselY, Beta,
BetaRegularized, Binomial, BlackmanHarrisWindow, BlackmanNuttallWindow,
BlackmanWindow, BohmanWindow, Boole, BooleanRegion, BoundaryMeshRegion,
BSplineBasis, CardinalBSplineBasis, CauchyWindow, Ceiling, ChebyshevT, ChebyshevU,
Circle, Clip, Cone, ConicHullRegion, Conjugate, ConnesWindow, Cos, Cosh,
CosineWindow, Cot, Coth, Csc, Csch, CubeRoot, Cuboid, Cylinder, DedekindEta,
DirectedInfinity, DirichletWindow, DiscreteDelta, Disk, Divide, Element, Ellipsoid,
EllipticE, EllipticF, EllipticK, EllipticPi, EllipticTheta, EllipticThetaPrime,
EmptyRegion, Equal, Equivalent, Erf, Erfc, Erfi, ExactBlackmanWindow, Exists, Exp,
ExpIntegralE, ExpIntegralEi, Factorial, Factorial2, FactorialPower, Fibonacci,
FlatTopWindow, Floor, ForAll, FractionalPart, FullRegion, Function, Gamma,
GammaRegularized, GaussianWindow, GegenbauerC, Greater, GreaterEqual, Gudermannian,
HalfLine, HalfPlane, HammingWindow, HankelH1, HankelH2, HannPoissonWindow,
HannWindow, Haversine, HermiteH, Hexahedron, HurwitzLerchPhi, HurwitzZeta,
Hypergeometric0F1, Hypergeometric0F1Regularized, Hypergeometric1F1,
Hypergeometric1F1Regularized, Hypergeometric2F1, Hypergeometric2F1Regularized,
HypergeometricU, If, Im, ImplicitRegion, Implies, Inequality, InfiniteLine,
InfinitePlane, IntegerPart, Interval, InverseGudermannian, InverseHaversine,
InverseTransformedRegion, JacobiP, JacobiZeta, KaiserBesselWindow, KaiserWindow,
KelvinBei, KelvinBer, KelvinKei, KelvinKer, KroneckerDelta, LaguerreL,
LanczosWindow, LegendreP, LegendreQ, LerchPhi, Less, LessEqual, Line, Log, Log10,
Log2, LogBarnesG, LogGamma, LogIntegral, LogisticSigmoid, LucasL, Majority,
MathieuC, MathieuCharacteristicA, MathieuCharacteristicB,
MathieuCharacteristicExponent, MathieuCPrime, MathieuS, MathieuSPrime, Max,
MeshRegion, Min, Minus, Mod, Multinomial, Nand, Negative, NonNegative, NonPositive,
Nor, Not, NotElement, NuttallWindow, Or, ParabolicCylinderD, Parallelepiped,
Parallelogram, ParametricRegion, ParzenWindow, Piecewise, Plus, Pochhammer, Point,
PoissonWindow, PolyGamma, Polygon, PolyLog, Positive, Power, PrimePi, Prism,
ProductLog, Pyramid, QBinomial, QFactorial, QGamma, QHypergeometricPFQ,
QPochhammer, QPolyGamma, Quantity, Quotient, QuotientRemainder, RankedMax,
RankedMin, Re, Rectangle, RegionBoundary, RegionDifference, RegionIntersection,
RegionProduct, RegionSymmetricDifference, RegionUnion, Rescale, RiemannSiegelTheta,
RiemannSiegelZ, Root, Round, SawtoothWave, Sec, Sech, Sign, Simplex, Sin, Sinc,
Sinh, Sphere, SphericalBesselJ, SphericalBesselY, SphericalHankelH1,
SphericalHankelH2, SphericalHarmonicY, SpheroidalEigenvalue, SpheroidalPS,
SpheroidalPSPrime, SpheroidalQS, SpheroidalQSPrime, SpheroidalS1,
SpheroidalS1Prime, SpheroidalS2, SpheroidalS2Prime, Sqrt, SquareWave, StruveH,
StruveL, Subtract, Surd, Switch, Tan, Tanh, Tetrahedron, Times, TransformedRegion,
Triangle, TriangleWave, TukeyWindow, Unequal, UnitBox, UnitStep, UnitTriangle,
WelchWindow, Which, WhittakerM, WhittakerW, Xnor, Xor, Zeta}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.