hello
how is it possible to calculate with imaginary numbers in PD besides the fft stuff.
thank you in advance der.brandt
On Fri, 28 Aug 2009, brandt@subnet.at wrote:
how is it possible to calculate with imaginary numbers in PD besides the fft stuff.
basically, if you know that something is an imaginary number, you can use a real number in its place and just remember to multiply by square root of -1 in your head.
but if you want to combine real and imaginary numbers, then you need complex numbers, each of which is a real and an imaginary number.
let i be sqrt(-1)... then let's say you have two complex numbers, a+bi, c+di, as four floats. the sum is (a+c)+(b+d)i, that is you add the real parts together, and add the imaginary parts together. From this, you can guess how to subtract. The product formula is (a*c-b*d)+(a*d+b*c)i, which you can often see in Miller's FFT patches as a cluster of four [*~].
You can find more such formulas on Wikipedia, PlanetMath, MathWorld, or other, but if you can't find one or have trouble getting one to work, ask pd-list again.
Abstractions could have been made for some of these, especially *, /, exp, log, but I don't think any such library exists. GridFlow provides those operations as an external if you need something fast.
_ _ __ ___ _____ ________ _____________ _____________________ ... | Mathieu Bouchard, Montréal, Québec. téléphone: +1.514.383.3801
Thank you very much
as i am on windows, unfortunally there is no gridflow. - and i tried to make sqrt from pd, but it does not like -1.
thanks again der.brandt
On Fri, 28 Aug 2009, brandt@subnet.at wrote:
how is it possible to calculate with imaginary numbers in PD besides the fft stuff.
basically, if you know that something is an imaginary number, you can use a real number in its place and just remember to multiply by square root of -1 in your head.
but if you want to combine real and imaginary numbers, then you need complex numbers, each of which is a real and an imaginary number.
let i be sqrt(-1)... then let's say you have two complex numbers, a+bi, c+di, as four floats. the sum is (a+c)+(b+d)i, that is you add the real parts together, and add the imaginary parts together. From this, you can guess how to subtract. The product formula is (a*c-b*d)+(a*d+b*c)i, which you can often see in Miller's FFT patches as a cluster of four [*~].
You can find more such formulas on Wikipedia, PlanetMath, MathWorld, or other, but if you can't find one or have trouble getting one to work, ask pd-list again.
Abstractions could have been made for some of these, especially *, /, exp, log, but I don't think any such library exists. GridFlow provides those operations as an external if you need something fast.
_ _ __ ___ _____ ________ _____________ _____________________ ... | Mathieu Bouchard, Montréal, Québec. téléphone: +1.514.383.3801
On Sat, 29 Aug 2009, brandt@subnet.at wrote:
and i tried to make sqrt from pd, but it does not like -1.
I'm sorry, I didn't explain this one. In the formulas I gave, "i" represents square root of -1, but you can't use that as a number in pd because pd only supports plain floats and not complex floats. But a non-complex number system can be used to make a complex number system, and the formulas are usually not very long.
A float can only be half of the data of a complex number. It's called complex because it has two parts. The second float stands for the part that is a multiple of "i", and the first float stands for the part that is not. It's also often considered as a 2-D vector with extra operators, with the x (cosine) standing for the real part, and the y (sine) standing for the imaginary part.
http://en.wikipedia.org/wiki/Complex_numbers#The_complex_plane
But don't try to read the whole wikipedia articles on math topics, they're huge and contain much stuff you don't need.
_ _ __ ___ _____ ________ _____________ _____________________ ... | Mathieu Bouchard, Montréal, Québec. téléphone: +1.514.383.3801