How to find the difference between angles of two complex numbers

Hi

I have two vectors represented as complex numbers and need to calculate angle between in most efficient way.

This is for implementing in C.

If I use tan-1 to take angles of both and subtract it will take a lot of processing power.

So, please suggest me an efficient method for this.

Thanks and Regards

Ashok

Re: How to find the difference between angles of two complex numbers

Ashok, I assume you are using rectangular coordinates, this is and it doesn't really matter that they are complex numbers. Remember dot product where is the smallest angle between them, so it is always true that .

So you can use . You still need to find the dot product, that is just and the length of the vectors, that is

so I'm not sure how much memory you are saving with this. And this will give you the smallest angle, that may not be what you need, I don't know.

I advice you look up some math library for c, I'm sure there is an "arg" function implemented that gives you the angles, if you don't want to use that, you can look at the code (if it is accessible) and

get a better idea. I hope that helped, regards

Damián Vallejo.

You can visit my blog if you want, it is Math 911 I expose some math topics there.

Re: How to find the difference between angles of two complex numbers

But the problem of finding is reducible to the problem of finding the angle between two vectors: given y, is the angle between (1, y) and (1, 0). Therefore, the problem of finding the angle is at least as hard as the problem of computing the .

From the standpoint of good programming practices, it is probably good to use a library dealing with complex numbers. It must have a function returning the argument of a given complex number (internally, this function is likely to use or some other inverse trigonometric function).

On the other hand, if the angle between vectors is not your ultimate goal (for example, if you are taking its tangent), then there may be ways to avoid computing or a similar function.

Re: How to find the difference between angles of two complex numbers

Hi

the the cos method gives the difference but it won't give the direction, I mean it won't give negative values.

standard Library functions are less efficient for me.

Actually I have one more step after this, shifting the phase of second vector based on the angle difference

Is there any method to do these steps together ? (with least complexity , so best timing efficiency)

Regards

Quote:

Originally Posted by

**chalaman1403** Ashok, I assume you are using rectangular coordinates, this is

and

it doesn't really matter that they are complex numbers. Remember dot product

where

is the smallest angle between them, so it is always true that

.

So you can use

. You still need to find the dot product, that is just

and the length of the vectors, that is

so I'm not sure how much memory you are saving with this. And this will give you the smallest angle, that may not be what you need, I don't know.

I advice you look up some math library for c, I'm sure there is an "arg" function implemented that gives you the angles, if you don't want to use that, you can look at the code (if it is accessible) and

get a better idea. I hope that helped, regards

Damián Vallejo.

You can visit my blog if you want, it is

Math 911 I expose some math topics there.

Re: How to find the difference between angles of two complex numbers

Hi

Thanks for the reply.

The tan inverse method is better. But it has not helped me to reach my ultimate goal within my processing time constraint.

As you guessed my ultimate goal is different :)

Actually I have one more step after this, shifting the phase of second vector based on the angle difference

Is there any method to do these steps together ? (with least complexity , so best timing efficiency)

Thanks and Regards

Quote:

Originally Posted by

**emakarov** But the problem of finding

is reducible to the problem of finding the angle between two vectors: given y,

is the angle between (1, y) and (1, 0). Therefore, the problem of finding the angle is at least as hard as the problem of computing the

.

From the standpoint of good programming practices, it is probably good to use a library dealing with complex numbers. It must have a function returning the

argument of a given complex number (internally, this function is likely to use

or some other inverse trigonometric function).

On the other hand, if the angle between vectors is not your ultimate goal (for example, if you are taking its tangent), then there may be ways to avoid computing

or a similar function.