Message Boards Message Boards

0
|
6343 Views
|
2 Replies
|
1 Total Likes
View groups...
Share
Share this post:

How to get a dot product to explicitly show the algebra it is performing?

Posted 10 years ago

a.b See elements being multiplied and added rather than just the solution?

POSTED BY: Douglas Youvan
2 Replies

Mathematica generally does not show its intermediate steps in doing a computation--which, in the general case, may be very algorithmically complex and not anything like the way you might do it by hand.

In the case of your very simple dot product question the computations is probably done exactly the way you would do it by hand: taking the product of the components and adding them term by term. What further insight do you wish to gather?

This is what happens if you do an example problem symbolically:

In[1]:= a = {a1, a2, a3};
b = {b1, b2, b3};

In[3]:= a.b

Out[3]= a1 b1 + a2 b2 + a3 b3

And TracePrint can show you some of the sequence of steps that are taking place internally--at least at the level of manipulation of the Mathematica code itself:

In[4]:= TracePrint[a.b]

During evaluation of In[4]:=  a.b

During evaluation of In[4]:=   Dot

During evaluation of In[4]:=   a

During evaluation of In[4]:=   {a1,a2,a3}

During evaluation of In[4]:=   b

During evaluation of In[4]:=   {b1,b2,b3}

During evaluation of In[4]:=  {a1,a2,a3}.{b1,b2,b3}

During evaluation of In[4]:=  a1 b1+a2 b2+a3 b3

Out[4]= a1 b1 + a2 b2 + a3 b3
POSTED BY: David Reiss

David,

Thank you. Back to work. That will do it for me.

Doug

POSTED BY: Douglas Youvan
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