Message Boards Message Boards

GROUPS:

How to put Wolfram|Alpha output in a Block

Posted 2 months ago
373 Views
|
1 Reply
|
1 Total Likes
|

Hi Everyone,

I am using Wolfram|Alpha inside a Mathematica notebook for getting a permutation matrix for a particular order. I want to use output of this inside a Block but its not happening.

Posted 2 months ago

Hi Aditya

MatrixForm is not computable. Also avoid use of symbol names starting with an uppercase letter, WL built-in symbols use that convention. And using %, especially in a function definition is asking for trouble.

m = WolframAlpha[
   "matrix of the permutation (4 3 2)(1)", {{"PermutationMatrix", 1}, 
    "ComputableData"}] // ReleaseHold

my[r_] := Block[{a, b}, a = m; b = a . r . a\[Transpose]]; (* Why do you need Block here? *)

my[{{1/2, 0, 0, -(1/2)}, {-(1/2), 1, 0, -(1/2)}, {-(1/2), 0, 1, -(1/2)}, {-(1/2), 0, 0, 1/2}}]
(* {{1/2, -(1/2), 0, 0}, {-(1/2), 1/2, 0, 0}, {-(1/2), -(1/2), 1, 0}, {-(1/2), -(1/2), 0, 1}} *)
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