Would like to take two vectors and multiply components at the same index.For example {a1, a2, a3} x {b1, b2, b3} to produce {a1 b1, a2 b2, a3 b3}. The following works, but are there some alternatives?

aMat = DiagonalMatrix[{a1, a2, a3}];
bMat = DiagonalMatrix[{b1, b2, b3}];
Diagonal @ Dot[aMat, bMat] 
result: {a1 b1, a2 b2, a3 b3}

closed as off-topic by m_goldberg, AccidentalFourierTransform, Michael E2, gwr, eyorble Sep 12 '18 at 21:02

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – m_goldberg, AccidentalFourierTransform, Michael E2, gwr, eyorble
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    $\begingroup$ {a1,a2,a3}*{b1,b2,b3} will give the required answer $\endgroup$ – mikado Sep 8 '18 at 19:22

No need to do anything fancy. This is just how ordinary list multiplication works:

{a1, a2, a3} {b1, b2, b3}


{a1 b1, a2 b2, a3 b3}
  • $\begingroup$ thanks! didn't even think to try that. $\endgroup$ – user6546 Sep 8 '18 at 19:25

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