Message Boards Message Boards

0
|
3951 Views
|
3 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Set a condition, j<k, for a system of equations in Wolfram Language?

Posted 8 years ago

Hey, i have 3 different numbers o1, o2 and o3. Now I shall solve ojok - okoj ,j,k =1,2,3 under the condition j < k. Of course i could type in the three different equations, but is there a more elegant way to do it with just one command? I tried :

Table[o[j].o[k]-o[k].o[j] , {j,1,3} , {k,1,3}, j<k]

but they just say "iterator {j < k} does not have approciate bounds". Has anyone an idea how to solve this?

POSTED BY: Robin Stöhr
3 Replies
Posted 8 years ago

Will this do?

Table[ If[j<k, o[j].o[k] - o[k].o[j]], {j, 1, 3}, {k, 1, 3}] /. Null -> Sequence[] // Flatten

which gives you

{o[1].o[2] - o[2].o[1], o[1].o[3] - o[3].o[1], o[2].o[3] - o[3].o[2]}

Or a slightly simpler version

Table[If[j<k, o[j].o[k] - o[k].o[j], {}], {j, 1, 3}, {k, 1, 3}] // Flatten
POSTED BY: Bill Simpson
Posted 8 years ago

Yep, thanks :)

POSTED BY: Robin Stöhr
In[6]:= Table[o[j].o[k] - o[k].o[j], {k, 2, 3}, {j, 1, k - 1}]

    Out[6]= {{o[1].o[2] - o[2].o[1]},
{o[1].o[3] - o[3].o[1], o[2].o[3] - o[3].o[2]}}
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract