Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Dot Product's imaginary component (dot.m)

Subject: Dot Product's imaginary component (dot.m)

From: Jeff

Date: 9 May, 2010 00:20:26

Message: 1 of 5

Hi, I am just learning about dot products. Why is the built in function dot(u,v) returning the complex conjugate of what I think the right answer is (and the answer in my Professors notes).

x = (2; 1 + i; i)
y = (2 - i; 2; 1 + 2i)

< x; y >= 2(2 + i) + (1 + i)(2) + i(1 - 2i) = 4 + 2i + 2 + 2i + i - 2i^2 = 8 + 5i

but:
EDU>> x=[2,1+i,i]; y=[2-i,2,1+2i];
EDU>> dot(x,y)
ans =
            8 - 5i <-- wrong answer

note, though:
EDU>> dot(y,x) <-- backwards
ans =
            8 + 5i <-- right answer

Subject: Dot Product's imaginary component (dot.m)

From: James Tursa

Date: 9 May, 2010 00:37:05

Message: 2 of 5

"Jeff " <spREMOVEHITSjeffAT@SIGNoptonline.net> wrote in message <hs4v4a$rqm$1@fred.mathworks.com>...
> Hi, I am just learning about dot products. Why is the built in function dot(u,v) returning the complex conjugate of what I think the right answer is (and the answer in my Professors notes).

For two column vectors x and y, dot is defined as x' * y. The first vector is conjugated. In addition to MATLAB, that is also the way the dot product is defined in other languages as well, e.g. Fortran. So MATLAB is being consistent with other languages.

James Tursa

Subject: Dot Product's imaginary component (dot.m)

From: Matt Fig

Date: 9 May, 2010 00:46:06

Message: 3 of 5

If I remember correctly, for a Hermitian product, the choice of which vector to conjugate is arbitrary. I have seen it both ways.

Subject: Dot Product's imaginary component (dot.m)

From: Jeff

Date: 9 May, 2010 01:00:19

Message: 4 of 5

"James Tursa" <aclassyguy_with_a_k_not_a_c@hotmail.com> wrote in message <hs503h$l7$1@fred.mathworks.com>...
> "Jeff " <spREMOVEHITSjeffAT@SIGNoptonline.net> wrote in message <hs4v4a$rqm$1@fred.mathworks.com>...
> > Hi, I am just learning about dot products. Why is the built in function dot(u,v) returning the complex conjugate of what I think the right answer is (and the answer in my Professors notes).
>
> For two column vectors x and y, dot is defined as x' * y. The first vector is conjugated. In addition to MATLAB, that is also the way the dot product is defined in other languages as well, e.g. Fortran. So MATLAB is being consistent with other languages.
>
> James Tursa

Thanks.

My textbook and teacher conjugates the second one (or I'm reading it wrong - I haven't had anything to do with complex numbers since HS over a decade ago). I guess learning which one to conjugate is a subject for the future (or a question for my prof).

Subject: Dot Product's imaginary component (dot.m)

From: Jeff

Date: 9 May, 2010 01:02:05

Message: 5 of 5

"James Tursa" <aclassyguy_with_a_k_not_a_c@hotmail.com> wrote in message <hs503h$l7$1@fred.mathworks.com>...
> "Jeff " <spREMOVEHITSjeffAT@SIGNoptonline.net> wrote in message <hs4v4a$rqm$1@fred.mathworks.com>...
> > Hi, I am just learning about dot products. Why is the built in function dot(u,v) returning the complex conjugate of what I think the right answer is (and the answer in my Professors notes).
>
> For two column vectors x and y, dot is defined as x' * y. The first vector is conjugated. In addition to MATLAB, that is also the way the dot product is defined in other languages as well, e.g. Fortran. So MATLAB is being consistent with other languages.
>
> James Tursa

Oh wait (don't read that last post!). You can define many dot products in a vector space. :D.

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us