Author Topic: Interpolating Complex Numbers  (Read 29852 times)

0 Members and 2 Guests are viewing this topic.

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: Interpolating Complex Numbers
« Reply #25 on: January 19, 2015, 01:24:19 pm »
Quote
If I have phase and magnitude I can leave them in that form for multiplication/division but to add/subtract it has to be converted to rectangular format.

All arithmetic operations can be done in either forms, or exponent form as well.
================================
https://dannyelectronics.wordpress.com/
 

Offline IanB

  • Super Contributor
  • ***
  • Posts: 11882
  • Country: us
Re: Interpolating Complex Numbers
« Reply #26 on: January 19, 2015, 05:44:32 pm »
It may not be the most suitable method however, as for example if your data points trace out curves on a Smith chart, you would want to use circular segments to interpolate.  The suggestion of higher order interpolation methods (such as splines: quadratic or cubic curves, polynomial least-squares, etc.) will have similar results.

Perhaps what you really want is a number whose magnitude is halfway between that of the two numbers you started with, and a phase that's halfway between the two as well. In that case, you'd need to convert to polar coordinates before taking your average, and then back again. You'd end up with (1/SQRT(2)) + i(1/SQRT(2)), which has a different "correct" magnitude and phase.

As I implied, and as you spelled out, both procedures/answers are valid.

Which is preferable depends on the significance/meaning/interpretation placed on those numbers in a specific application.

Taking all these answers together and summarizing for people reading along, what it tells us is that interpolation is a path dependent process. If you want to know what value is "half way" between points A and B you need to know what path is followed in getting from A to B. You can then find the point that is half way along this path. The path may be a straight line, an elliptical arc, or some other path. (For instance, if you wanted to interpolate the intermediate position of a planet in orbit you would interpolate along an elliptical arc.)

The arithmetic mean makes the assumption of a straight line path, but this is not always the actual or most meaningful path.
 

Offline IanB

  • Super Contributor
  • ***
  • Posts: 11882
  • Country: us
Re: Interpolating Complex Numbers
« Reply #27 on: January 19, 2015, 05:47:22 pm »
All arithmetic operations can be done in either forms, or exponent form as well.

Of course, but "can be done" does not mean convenient.

For instance, can you demonstrate to us how to compute the sum of (5 angle 30°) and (3 angle 170°) in polar coordinates?
 

Offline AlfBaz

  • Super Contributor
  • ***
  • Posts: 2184
  • Country: au
Re: Interpolating Complex Numbers
« Reply #28 on: January 19, 2015, 10:08:43 pm »
Angle and magnitude are perfect for multiplication and division (multiply/divide the magnitudes, add/subtract the angles), but inconvenient for addition and subtraction.
All arithmetic operations can be done in either forms, or exponent form as well.
For instance, can you demonstrate to us how to compute the sum of (5 angle 30°) and (3 angle 170°) in polar coordinates?
In IanB's first quote he states inconvenient not impossible. I did a quick search and couldn't find any examples so I too would be interested in seeing it. I imagine there'd be some trig involved
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: Interpolating Complex Numbers
« Reply #29 on: January 19, 2015, 10:12:52 pm »
Quote
I imagine there'd be some trig involved

depending on your starting point.
================================
https://dannyelectronics.wordpress.com/
 

Offline tggzzz

  • Super Contributor
  • ***
  • Posts: 19494
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: Interpolating Complex Numbers
« Reply #30 on: January 19, 2015, 11:36:13 pm »
All arithmetic operations can be done in either forms, or exponent form as well.

Of course, but "can be done" does not mean convenient.

For instance, can you demonstrate to us how to compute the sum of (5 angle 30°) and (3 angle 170°) in polar coordinates?

Half the battle is choosing the best coordinate system which makes the subsequent maths easier - not original,merely a standard truism.

One consideration in determining the best coordinate system is to avoid singularities and ambiguities. A good example is the parametric representation of a straight line, cf the traditional y=MX+c. See maths textbooks for examples.
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 

Offline AlfBaz

  • Super Contributor
  • ***
  • Posts: 2184
  • Country: au
Re: Interpolating Complex Numbers
« Reply #31 on: January 24, 2015, 03:05:54 am »
In IanB's first quote he states inconvenient not impossible. I did a quick search and couldn't find any examples so I too would be interested in seeing it. I imagine there'd be some trig involved
Is this an example of it from Tek?
Equation 2 derived from equation 1
Add to that Equation 3 used to get the phase angle and it seems to be simply convoluting what would otherwise be a fairly simplistic solution using rectangular form.
Is there any reason they have gone this way?
 

Offline IanB

  • Super Contributor
  • ***
  • Posts: 11882
  • Country: us
Re: Interpolating Complex Numbers
« Reply #32 on: January 24, 2015, 03:50:50 am »
Is this an example of it from Tek?
Equation 2 derived from equation 1
Add to that Equation 3 used to get the phase angle and it seems to be simply convoluting what would otherwise be a fairly simplistic solution using rectangular form.
Is there any reason they have gone this way?

That example does lead to a certain amount of painful arithmetic. I don't think it can be completely avoided, however.

They want to work out Zx from the equation below:

    Zx = VA2 / (VA1 - VA2) * Rref

This involves both a subtraction and a division. The subtraction will be most convenient in rectangular coordinates and the division most convenient in polar coordinates. So in some ways it is a lose-lose situation. They have chosen to say, "It can be shown that..." then then presented pre-derived formulas. They are skipping over the hard part and just having the student plug in numbers. This is fine for a measurement lab, but would be short-changing the student in an analysis lesson.

(Of course, if you had a good calculator and knew how to use it you could just plug the numbers into the calculator and let it take care of the complex arithmetic.)
« Last Edit: January 24, 2015, 07:01:07 am by IanB »
 

Offline IanB

  • Super Contributor
  • ***
  • Posts: 11882
  • Country: us
Re: Interpolating Complex Numbers
« Reply #33 on: January 24, 2015, 04:44:58 am »
To show the working step by step as it might be done with a scientific calculator:

    VA1 = 1.929 V angle 0°
    VA2 = 0.310 V angle -79.95°
    Rref = 1000 ohms
    f = 100 Hz

First we plug in VA1 giving (1.929, 0) in rectangular coordinates.

Then we plug in VA2 giving (0.0541, -0.3052) in rectangular coordinates.

Then we subtract the second from the first giving (1.875, 0.3052) in rectangular coordinates, which is 1.900 V angle 9.247°

Then we do the division, giving 0.1632 angle -89.20°.

Lastly we multiply by 1000 to give 163.2 angle -89.20°, which is (2.287, -163.2) in rectangular coordinates.

We therefore find that the resistance is:

    RESR = 2.287 ohms

and the reactance is:

    XC = -163.2 ohms (the negative sign makes it a capacitance)

The capacitance is therefore:

    C = -1 / {2(pi) f Xc}
    C = -1 / {2(pi) * 100 * -163.2} = 9.75 µF

« Last Edit: January 24, 2015, 05:20:53 pm by IanB »
 

Offline f5r5e5d

  • Frequent Contributor
  • **
  • Posts: 349
Re: Interpolating Complex Numbers
« Reply #34 on: January 24, 2015, 11:44:13 am »
anybody remember the complex conjugate? division is a fine basic operation with complex numbers if you use the conjugate of the denominator

really is basic to complex arithmetic

sometime the polar view is good too - but not needed here for the calc
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: Interpolating Complex Numbers
« Reply #35 on: January 24, 2015, 01:31:54 pm »
Most complex libraries do division via conjugate multification.

The polar form's issue is with singularity.
================================
https://dannyelectronics.wordpress.com/
 

Offline AlfBaz

  • Super Contributor
  • ***
  • Posts: 2184
  • Country: au
Re: Interpolating Complex Numbers
« Reply #36 on: January 24, 2015, 03:46:03 pm »
To show the working step step as it might be done with a scientific calculator:
Thanks for that Ian. That's exactly how I did it. As I'm teaching myself and seeing a lot of AC math in that "polar" form I was starting to think there may be a reason not to do it in rectangular.

If the math in that Tek note is considered "complex" then it appears I was taught it as a first year electrical apprentice with a protractor and a ruler :)
 

Offline AlfBaz

  • Super Contributor
  • ***
  • Posts: 2184
  • Country: au
Re: Interpolating Complex Numbers
« Reply #37 on: January 24, 2015, 04:05:36 pm »
anybody remember the complex conjugate?
Yeah that's how I was doing it until I progressed to learning about polar math. It's just more steps and more numbers to round down, loosing accuracy along the way by writing down intermediate value.

My casio fx-180Pv has only 6 memory slots plus M+ and, unfortunately, only 38 steps for a program which isn't quite enough to get to the end solution if you want to do the calc several times.

I've resorted to simple C/C++ console programs using complex.h and it certainly makes life easy, enter the numbers in what ever form you like/have do the calcs with "single" variables and spit them out in what ever form you like/need. I have a C/C++ compiler on my android tablet, input/ouput via the console. No need to waste bench space with PC/laptop. I have yet to find a decent app that is essentially a programmable calculator that does complex numbers and allows scientific notation for the absolute and argument parameters
 

Offline Kalvin

  • Super Contributor
  • ***
  • Posts: 2145
  • Country: fi
  • Embedded SW/HW.
Re: Interpolating Complex Numbers
« Reply #38 on: January 24, 2015, 04:10:35 pm »
My casio fx-180Pv has only 6 memory slots plus M+ and, unfortunately, only 38 steps for a program which isn't quite enough to get to the end solution if you want to do the calc several times.

If you have an Android phone, there are some programmable scientific calculators and calculator emulators available, even for free. 
 

Offline AlfBaz

  • Super Contributor
  • ***
  • Posts: 2184
  • Country: au
Re: Interpolating Complex Numbers
« Reply #39 on: January 24, 2015, 04:17:32 pm »
If you have an Android phone, there are some programmable scientific calculators and calculator emulators available, even for free.
Thanks, I have started looking but so far the ones I have tried fall short of ideal. Any suggestions would be greatly appreciated
 

Offline IanB

  • Super Contributor
  • ***
  • Posts: 11882
  • Country: us
Re: Interpolating Complex Numbers
« Reply #40 on: January 24, 2015, 05:28:13 pm »
If the math in that Tek note is considered "complex" then it appears I was taught it as a first year electrical apprentice with a protractor and a ruler :)

Ha. When one says "complex arithmetic" one means, of course, arithmetic with complex numbers. Not so much "arithmetic that is complex" (though there might be a little of that too...)  ;D

I have yet to find a decent app that is essentially a programmable calculator that does complex numbers and allows scientific notation for the absolute and argument parameters

An HP calculator should be able to do that. I ran the above example through the HP-15C, for instance. Though I think your C/C++ programming approach is nice enough.
 

Offline bson

  • Supporter
  • ****
  • Posts: 2270
  • Country: us
Re: Interpolating Complex Numbers
« Reply #41 on: January 24, 2015, 10:20:55 pm »
For instance, can you demonstrate to us how to compute the sum of (5 angle 30°) and (3 angle 170°) in polar coordinates?
But you can interpolate between them easily: (5+3)/2 angle (30°+170°)/2 mod 360° = 4 angle 100° for the halfpoint.  If you plot them on a circle you'll see why this makes sense, and why there's no need to compute the vector sum in the first place.  It'll come out to the same as a linear interpolation on the flat plane.

Edit: just for clarification, the interpolation is along a line with a linearly growing magnitude that forms a spiral and any point along the spiral can easily be interpolated.
« Last Edit: January 24, 2015, 10:32:09 pm by bson »
 

Offline IanB

  • Super Contributor
  • ***
  • Posts: 11882
  • Country: us
Re: Interpolating Complex Numbers
« Reply #42 on: January 24, 2015, 11:15:06 pm »
It'll come out to the same as a linear interpolation on the flat plane.

But a linear interpolation on the flat plane (Euclidean geometry) is along a straight line between the two points, not a spiral. So it can't come out the same unless the two points are on a straight line passing through the origin.
 

Offline tggzzz

  • Super Contributor
  • ***
  • Posts: 19494
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: Interpolating Complex Numbers
« Reply #43 on: January 24, 2015, 11:38:58 pm »
It'll come out to the same as a linear interpolation on the flat plane.

But a linear interpolation on the flat plane (Euclidean geometry) is along a straight line between the two points, not a spiral. So it can't come out the same unless the two points are on a straight line passing through the origin.

I refer you to your previous posting, with which I agree.
https://www.eevblog.com/forum/projects/interpolating-complex-numbers/msg590375/#msg590375
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 

Offline miguelvp

  • Super Contributor
  • ***
  • Posts: 5550
  • Country: us
Re: Interpolating Complex Numbers
« Reply #44 on: January 25, 2015, 12:19:41 am »
From the math review of MITx 6.002x Circuits and Electronics

Polar coordinates Part 1:


Explains the basics of polar coordinates.

Polar coordinates Part 2:


shows the problem where
z = 1 - j
and
z = -1 + j

Are different angles for Z
<z = tan^-1(-1/1) = -Pi/4
<z = tan^-1(1/-1) = 3Pi/4 (even if a calculator will give you -Pi/4) because tan^-1(y/z) is really a two argument function in the complex plane.

Euler's formula
e^(j*theta) = cos(theta) + j * sin(theta)



This shows the relation between Euler's formula and complex numbers.

z = x+j*y = r*cos(theta) + j*r*sin(theta) to obtain r & theta (polar coordinates)
and that is = r*(cos(theta)+j*sin(theta)) which by Euler's formula is = r*e^(j*theta)

So, complex to cartesian to polar:
z = x+j*y =  r*e^(j*theta)

Now Inverse Euler



Not really useful for complex conversion, but useful for finding integrals of sines and cosines.

There are more before and after in the series, the class just started Jan 20th, maybe worth your while at least to get to the Math review section on Complex Numbers.
https://www.edx.org/course/circuits-electronics-mitx-6-002x-0

« Last Edit: January 25, 2015, 12:30:57 am by miguelvp »
 

Offline IanB

  • Super Contributor
  • ***
  • Posts: 11882
  • Country: us
Re: Interpolating Complex Numbers
« Reply #45 on: January 25, 2015, 02:25:55 am »
I refer you to your previous posting, with which I agree.
https://www.eevblog.com/forum/projects/interpolating-complex-numbers/msg590375/#msg590375

This discussion seems to be going round in spirals. The good thing about spirals is they do at least converge on a stationary point if you follow them in the right direction.
 

Offline miguelvp

  • Super Contributor
  • ***
  • Posts: 5550
  • Country: us
Re: Interpolating Complex Numbers
« Reply #46 on: January 25, 2015, 02:33:22 am »
This discussion seems to be going round in spirals. The good thing about spirals is they do at least converge on a stationary point if you follow them in the right direction.

Which is ok if they are 2*n*Pi for any n that is a natural number negative or positive :)
Well, nobody mentioned Euler angles, and they are quite handy for going back and forth polar and complex.
 

Offline T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 21678
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: Interpolating Complex Numbers
« Reply #47 on: January 25, 2015, 06:15:34 am »
Remember your coordinate system matters, too.  Doing it on a Smith chart (impedance/reflectance, depending on which set of axes you pick) may be more practical.  You generally get superpositions of circles, but the centers and rates of them all vary, so that picking a unique curve is probably better done with higher order interpolation (i.e., curve fitting rather than linear).

Tim
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 

Offline jaxbirdTopic starter

  • Frequent Contributor
  • **
  • Posts: 778
  • Country: 00
Re: Interpolating Complex Numbers
« Reply #48 on: January 26, 2015, 11:44:54 am »
Just a quick thanks to everyone for excellent explanations and discussions.

Got the calibration interpolation working just fine now:

Analog Discovery Projects: http://www.thestuffmade.com
Youtube random project videos: https://www.youtube.com/user/TheStuffMade
 

Offline Kalvin

  • Super Contributor
  • ***
  • Posts: 2145
  • Country: fi
  • Embedded SW/HW.
Re: Interpolating Complex Numbers
« Reply #49 on: January 26, 2015, 11:51:03 am »
Just a quick thanks to everyone for excellent explanations and discussions.

Got the calibration interpolation working just fine now:

What kind of algorithm you use for the complex number interpolation?

Br,
Kalvin
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf