Group Abstract Group Abstract

Message Boards Message Boards

0
|
2.9K Views
|
7 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Inactivate Times[ ] which is used to generate the matrix elements

Posted 1 year ago
In[22]:= Outer[Inactivate[Times], {x, y, z}, {x, y, z}]

Out[22]= {{x^2, x y, x z}, {x y, y^2, y z}, {x z, y z, z^2}}

So, how to Inactivate the Times which is used to generate the matrix elements?

POSTED BY: Hongyi Zhao
7 Replies

I suppose that

Inactivate[Outer[Times, {x, y, z}, {x, y, z}], Times]

does not inactivate Times is because Times does not appear in Outer[Times, {x, y, z}, {x, y, z}] as head of an expression. The documentation is somewhat unclear on this. Compare:

Inactivate[g[f], f]
Inactivate[f[g], f]
POSTED BY: Gianluca Gorni
Posted 1 year ago

You want to use just Inactive, like Inactive[Times], specifically:

Outer[Inactive[Times], {1, 2, 3}, {4, 5, 6}]

Inactivate works on whole expressions, wrapping the heads in Inactive, but Inactivate[Times] is operating on just the expression Times, which is a raw symbol with no head. You already know the specific head you want to inactivate, so just wrap it in Inactive directly.

POSTED BY: Eric Rimbey
Posted 1 year ago

To understand a complex problem, the best approach is to first comprehend the simplest scenario. Regarding the question discussed here, I believe the following comparison can best illustrate the fundamental reason:

In[1]:= (*
find the clue as below:
*)
Inactive[x+x]//FullForm
Inactivate[x+x]//FullForm

Out[1]//FullForm= Inactive[Plus[x,x]]
Out[2]//FullForm= Inactive[Plus][x,x]
POSTED BY: Hongyi Zhao

Yes - that appears to be the reason, because this is working:

Inactivate[Outer[Times[#1, #2] &, {x, y, z}, {x, y, z}], Times]

Thank you, @Gianluca Gorni, and best regards! -- Henrik

POSTED BY: Henrik Schachner

Sorry, Eric, I saw your answer too late! But I still don't understand why

Inactivate[Outer[Times, {x, y, z}, {x, y, z}], Times]

is not working.

POSTED BY: Henrik Schachner

I have no idea why your approach is not working - good question! But in any case you can try this:

Outer[Inactive@Times, {x, y, z}, {x, y, z}]

or - if it is for displaying reasons:

Outer[CenterDot, {x, y, z}, {x, y, z}]
POSTED BY: Henrik Schachner
Outer[Inactive[Times], {x, y, z}, {x, y, z}]
POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard