Group Abstract Group Abstract

Message Boards Message Boards

1
|
2.2K Views
|
2 Replies
|
1 Total Like
View groups...
Share
Share this post:

Using symbolic indices on symbolic vectors?

Posted 1 year ago

Is there a way to use symbolic indices on symbolic vectors? The most barebones example, I can think of is the following:

aV = Array[a,3];
aV[[m]]

which evaluates to a warning:

{a[1], a[2], a[3]}[[m]]
Part::pkspec1: The expression m cannot be used as a part specification.

Instead, the behaviour I would like to see is that this simply evaluates to

a[m]

Having this functionality for symbolic indexation would be useful for many more complicated contexts to derive symbolic expressions, and Integration into the Indexed function would also help keep expressions readable.

To add another less barebones example, here I calculate a general cross product between vectors $b_l$ and $b_m$ in $\mathbb{R}^3$:

Nb = 7 ; (*length of list of R3 vectors b_i, not important*)
bV = Array[b, {Nb, 3}];
stdbasis = IdentityMatrix[3]; (* standard basis vectors in R3*)
crossProductFormula[l_, m_] = 
 Sum[stdbasis[[i]]*LeviCivitaTensor[3][[i, j, k]]*bV[[l, j]]*bV[[m, k]], {i, 3}, {j, 3}, {k, 3}]

The function works for specific l and m inputs, but it would be nice if it could generate a readable symbolic expression.

POSTED BY: Jan E
2 Replies

An attempt to get a nice formula:

OverVector[Subscript[a_, i_]][j_] := a[i, j]
crossProductFormula[l_, m_] =
 Inactive[Sum][
  Inactive[Times][Inactive[UnitVector][3, i],
   Inactive[LeviCivitaTensor][3][[i, j, k]],
   Inactive[OverVector[Subscript[b, l]]][j],
   Inactive[OverVector[Subscript[b, m]]][k]],
  {i, 3}, {j, 3}, {k, 3}]
% // Activate
POSTED BY: Gianluca Gorni

Maybe Indexed[] is what you are looking for.

POSTED BY: Henrik Schachner
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard