# [ot][spam][random][crazy][random][crazy]

Undescribed Horrific Abuse, One Victim & Survivor of Many gmkarl at gmail.com
Sat Nov 12 04:53:28 PST 2022

```goal: construct two different signals, that have frequencies aligned
with the different frequencies in fftfreq(6) . then consider the
product of multiplying these by a further third frequency, as if in a
fourier transform, with 10% or such difference between the sampling
rate and the signals.

what is the resulting product?

i infer it would be helpful to consider each signal separately, so as
to visually see the formula for this sum and product.

0721

This was the previous signal function with a frequency of 0.5:
>>> def signal(x):
...     return np.exp(2j * np.pi * x * 0.5)
...

Here are the frequencies for 6-valued data:
>>> np.fft.fftfreq(6)
array([ 0.        ,  0.16666667,  0.33333333, -0.5       , -0.33333333,
-0.16666667])

Here they are as degrees:
>>> np.fft.fftfreq(6)*2*np.pi*180//np.pi
array([   0.,   59.,  119., -181., -120.,  -60.])

So, 0.5 is 180 degrees, and the two new frequencies are 60 and 120
degrees. I guess degrees here means what? umm looks like

Maybe I'll make the signals be 60 degrees and 180 degrees and consider
them together at 120 degrees.
0725

>>> def signal_a(x):
...     return np.exp(2j * np.pi * x * 60/360)
...
>>> def signal_b(x):
...     return np.exp(2j * np.pi * x * 180/360)
...
>>> def signal_sum(x):
...     return signal_a(x) + signal_b(x)
...

0726

ok, first let's try the signals in a sample-aligned manner.

>>> sample_idcs = np.arange(6)
>>> aligned_products = [signal(sample_idcs) * np.exp(sample_idcs * 2j * np.pi * np.fft.fftfreq(6)) for signal in (signal_a, signal_b, signal_sum)]
>>> [(abs(product), np.angle(product) * 180 // np.pi) for product in aligned_products]
[(array([1., 1., 1., 1., 1., 1.]), array([  0., 180.,  -1., 179.,
-1., 179.])), (array([1., 1., 1., 1., 1., 1.]), array([   0.,  -61.,
-121.,  179.,  119.,   59.])), (array([2., 1., 1., 2., 1., 1.]),
array([   0., -121.,  -61.,  179.,   59.,  119.]))]

separating that output out:

signal_a at 120 degres:
array([1., 1., 1., 1., 1., 1.])
array([  0., 180.,  -1., 179.,  -1., 179.])

signal_b at 120 degrees:
array([1., 1., 1., 1., 1., 1.])
array([   0.,  -61., -121.,  179.,  119.,   59.])

signal_sum at 120 degrees:
array([2., 1., 1., 2., 1., 1.])
array([   0., -121.,  -61.,  179.,   59.,  119.])

0732
so first let's verify that signal_a and signal_b are understandable somehow

signal_a at 120 degres:
array([1., 1., 1., 1., 1., 1.])
array([  0., 180.,  -1., 179.,  -1., 179.])

60 + 120 = 180, so it makes sense the first sample is 180. The angle
of -1 doesn't seem quite right, shouldn't it be 0.0?

>>> aligned_products
array([ 1.+0.00000000e+00j, -1.+3.33066907e-16j,  1.-7.21644966e-16j,
-1.+3.67394040e-16j,  1.-1.44328993e-15j, -1.+1.44328993e-15j])

The angle being output as -1 is a complex number of 1 + -0j . so this
must just be an artefact of the angle conversion. Then it goes back to
180.

So the output from signal_a is cycling at 180 degrees/sample because
it is a 60 degree/sample signal harmonized with a 120 degree/sample
component.

Let's see signal_b's aligned output:
signal_b at 120 degrees:
array([1., 1., 1., 1., 1., 1.])
array([   0.,  -61., -121.,  179.,  119.,   59.])

signal_b moves at 180 degrees/sample, so harmonized with 120
degrees/sample, that makes 300 degrees/sample, which is -60+360 .

The parts of the output of signal_b are all increasing by this 300
degrees/sample amount:
>>> -60+300-360
-120
>>> -120+300
180
>>> 180+300-360
120
>>> 120+300-360
60

Now, we get to make things a little more complex. What does signal_sum
look like, and why?
I'm thinking signal_sum's output should be arithmetically equivalent
to the sum of the other outputs, not sure.

signal_sum is the sum of a 60 degree/sample signal and a 180
degree/sample signal, harmonized with a 120 degree/sample component.

signal_sum at 120 degrees:
array([2., 1., 1., 2., 1., 1.])
array([   0., -121.,  -61.,  179.,   59.,  119.])

When the two components resonate, the magnitude hits 2.0 .Note that
there are 2 total component signals here.
That starting angle of -120. How does it compare to the sum of the
previous advancing signals? signal_a was at 60 degrees with 120, so it
advanced by 180. signal_b was 180 degrees with 120, so it advanced by
300. 300 + 180 = 480. what is 480?

>>> 480 - 360
120

That's _positive_ 120 degrees. What we have here is _negative_ 120 degrees.

>>> -120 + 360
240

So it's not the sum of the angle advancements: it's actually twice that sum.

0740
[holy frack this is so hard to choose to do]
0741

Okay. The rates are summed when the data is _multiplied_. This data is summed.
How does summing two complex numbers affect their angles?
Alternatively, how do transforms on the underlying angles get affected
by this suming?

The first websearch result to stackoverflow says there is no clear
relation between the angle of the complex sum and the angles of the
summands other than the definition. The answer has only 1 upvote.

I'm imagining in my mind two vectors aimed in different directions and
summed, tip-to-tail.
What I am able to do to these vectors, is rotate them further by
multiplying by a complex constant. When I do this, both vector
components do indeed rotate the same amount.

So the idea of multiplying by a constant works when working with _only
one_ component, even though the result is a sum.

We should be able to verify that by making one of the components
destructively interfere, leaving only the other.
0745

Okay, one is interfering at 180 degree/sample, the other is
interfering at 300 degrees/sample, so if I unrotate it by 180 or by
300 degrees, it should leave only the other component in a resulting
sum? i wonder if i could unrotate it a second time to make them both
destructively interfere, is that meaningful or not meaningful? maybe
the first one doesn't even work?

I'll need some data spiraling at 180 or 300 degrees.

>>> freq_180 = np.exp(sample_idcs * 2j * np.pi * 180/360)
>>> freq_300 = np.exp(sample_idcs * 2j * np.pi * 300/360)

When I divide by this, I get data that is itself spiraling at 300
(which -60) degrees:
>>> [[np.abs(x), np.angle(x)*180//np.pi] for x in [aligned_products[-1] / freq_300]]
[[array([2., 1., 1., 2., 1., 1.]), array([  0., -61.,  59.,   0., -61.,  59.])]]
>>> -60+360
300

I'm assuming the second instance of 300 degrees is a coincidence. If I
sum this data, does the component that made 300 degrees cancel out? Or
do I have sometihng wrong?

I do have something wrong. This data is aligned.
>>> np.sum(aligned_products[-1]/freq_300)
(6.000000000000001-3.219646771412954e-15j)
>>> np.sum(aligned_products[-1])
(2.1649348980190553e-15+5.551115123125783e-16j)

The sum of rotating it all by a 300 degree/sample wave makes a sum of
6 exactly. Meanwhile, the original sum was 0 exactly (e-15 and e-16
are 0 in floating point math), because the data was aligned already.
I've actually pulled a wave out.

I guess I need to understand this a little better to succeed at it.
```