8
$\begingroup$

I would like to exponentiate the vector x = {x1,x2} element-wise with the non-square matrix A = {{1,0},{1,1},{0,1}} so that the result is x^A = {x1, x1x2, x2}. Is there an operation for element-wise vector-matrix exponentiation in Mathematica?

To clarify, the operation should be the following:

{{x1^1 * x2^0},
 {x1^1 * x2^1},
 {x1^0 * x2^1}}

= {x1,
   x1 x2,
   x2}
$\endgroup$

5 Answers 5

7
$\begingroup$
Times @@@ Map[x^# &, A]

{x1, x1 x2, x2}

$\endgroup$
6
  • 1
    $\begingroup$ great, thanks a lot @eldo! $\endgroup$
    – hr8tpa
    Mar 23 at 16:30
  • $\begingroup$ You're most welcome $\endgroup$
    – eldo
    Mar 23 at 16:30
  • $\begingroup$ @eldo Please explane about symbol @@@ I don't understand. $\endgroup$ Mar 25 at 0:01
  • 1
    $\begingroup$ It's the short form of MapApply $\endgroup$
    – eldo
    Mar 25 at 0:03
  • $\begingroup$ I notice that you did not accept an answer to this question. Is there something that remains to be addressed? $\endgroup$
    – eldo
    Mar 29 at 0:53
5
$\begingroup$
Inner[ReverseApplied[Power], A, x, Times]

(* {x1, x1 x2, x2} *)
$\endgroup$
5
$\begingroup$

You can do it directly:

Times @@ (x^Transpose@A)
(* {x1, x1 x2, x2} *)
$\endgroup$
4
$\begingroup$
x = {x1, x2};
A = {{1, 0}, {1, 1}, {0, 1}};

Using Table:

Table[Times @@ (x^#[[i]]), {i, Length@#}] &@A

{x1, x1 x2, x2}

$\endgroup$
3
$\begingroup$
x = {x1, x2};
A = {{1, 0}, {1, 1}, {0, 1}}
Pick[x, #, 1] & /@ A // Map[Apply[Times]]

{x1, x1 x2, x2}

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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