Srishti M
Srishti M

Reputation: 543

How to square a complex number with itself

a = [1;2;3];

square_real = a'*a;

ans =

14

a =

 1
 2
 3

In this example I am squaring the numbers in variable a (an array) with itself.

TO do the same operation i.e., square for a complex number with itself, what is the operation? Should I take ctranpose or conjugate transpose? I am confused.

>> ac=[1 + 1j; 2 + 2j; 3 + 0.1j]

ac =

   1.0000 + 1.0000i
   2.0000 + 2.0000i
   3.0000 + 0.1000i

>> ac'*ac

ans =

   19.0100

I don't know if I am taking the correct operator.

UPDATE based on comments received : I don't want the elements of the complex valued array to change its sign. I want to multiply the array with itself so as to get a scalar answer upon multiplication. In order to do that what should be the symbol in maths and the corresponding command in Matlab?

Upvotes: 0

Views: 1321

Answers (1)

Sardar Usama
Sardar Usama

Reputation: 19689

As noted in the comments and by you, you need transpose .' here not complex conjugate transpose '. For real numbers, transpose and complex conjugate transpose are same since there is no iota i or j involved. So what you're looking for is this:

ac = [1 + 1j; 2 + 2j; 3 + 0.1j];
req = ac.' * ac;

If you want its scalar magnitude as output, use abs i.e.

abs(req)

As far as notations in Mathematics are concerned, transpose is usually represented by:
• Aᵀ
• A' (it is complex conjugate transpose in MATLAB though)

whereas complex conjugate transpose is usually denoted by:
• Aᴴ
• (A̅)T
• A*

But be careful, as Wikipedia mentioned:

In some contexts, A* denotes the matrix with complex conjugated entries, and the conjugate transpose is then denoted by A*ᵀ or Aᵀ*

It is always a good practice to define the notations that you're going to use in your text.

Upvotes: 1

Related Questions