# Thread: Deriving the wavelength of a modulated frequency

1. ## Deriving the wavelength of a modulated frequency

Given a a graph of the function
$y = A*cos ( 2PI * N / x )$

With $1 < x < N$, and $N$ being a large number (6 digits or more).
How do I calculate the wavelength (frequency) of the function at any given point $x$?

I see a sinusoidal function whose frequency decreases as $x$ increases, or it's wavelength increases with $x$.

I fudged an algorithm, but it's off by about %.0001 which is unwieldy for large $N$.

My reasoning was that every time $N/x$ struck an integer, the function would peak.
Therefore, the wavelength would equal the 'distance' between peaks.
Moreover, since Y = ... blah I think this is where I got lost..

My function for the wavelength was
$\lambda = \frac{N/((N/x)+1)) - (N/((N/x)-1)}2$
I made this up ad hoc to get the answer I needed, but it is not accurate

2. What do you mean by wavelength at a point?

3. Thanks for the prompt reply.
Perhaps I am using incorrect terminology. To clarify, I offer the image~

Where N = 221 and
$y = cos (2PI * N / x)$ (green)
$y = N / x$ (blue)
and my attempt at the wavelength -
$y = (N / (N/x)+1) - (N / (N/x)-1)$ is shown red.
I hope this helps..

When $x = \sqrt N$ (~14.866), the wavelength equals 1.

I understand you may not have a wavelength at a 'point' (uncertainty principle aside)

But what is the correct way to derive the wavelength of the original function?

4. I think I understand better now, and I think this is wrong, so see below instead

Spoiler:
***preserved for hysterical raisins****

I'm still not quite sure what you mean...

Let's restrict to x>0. You are correct: the function has extrema at x = N/k for all positive integers k. The extrema alternate between minima and maxima. The wavelength is generally defined to be the distance peak to peak (or trough to trough). So if you are standing on a peak (resp. trough) at x=N/k and you look along the negative x-axis toward the next peak (resp. trough) you will measure a wavelength of $\frac Nk - \frac N{k+2} = {2N\over k(k+2)}$. Now you can formally substitute N/x for k and get an expression for all x ( $x^2N \over N(N+2x)$), but its not clear to me how valid that is. It is definitely not 1 when $x=\sqrt{N}$... how do you know that the wavelength should be 1 at $\sqrt{N}$?

5. Thanks again, Maddas for the brain time..

I think $\frac Nk - \frac N{k+2} = {N(k+1)\over k(k+2)}$
should read $\frac Nk - \frac N{k+2} = {2N\over k(k+2)}$

I believe you are understanding me.. I am 20 yrs removed from college calculus, so please forgive my lack of clarity.

May I start from scratch?

$Y = A * cos (2PI * \frac{N} x)$

Where A = 1 (for ease), and
N = 221, and
x > 1 and,
x < N.

There is an infinite number of peaks between the asymptote (0) and 1, so let x > 1
We find half the maxima (value of 1) to be between x = 1 and 2 (because N / x decreases from N to half of N (N/2) as x goes from 1 to 2. Each integer between N and N/2 creates a corresponding peak between 1 and 2 on our graph. This trend continues as x increases.
At the point $x = \sqrt N$, The peak ratio transitions from more than 1 interval per x.. to less than 1 per x.

I consider this to mean that the 'instantaneous wavelength' of the function at $x = \sqrt N$ is 1

So I said.. "ok.. then I should be able to take the difference of (N/x) -1 and (N/x + 1) and divide it in half to get the 'wavelength' for any x"?? $y = (N / (N/x)+1) - (N / (N/x)-1)$divided by 2.
I'll use your k substitution method to simplify this into $\frac {N}{(N/x)^2-1}$
But this is wrong.. I think because the + 1 and - 1 makes the algorithm biased somehow..

Any Ideas?

6. Ah, sorry. Cancelled the wrong term >_< Should be fixed, but now I think the spacing is wrong for what you're saying, so. disregard my last comment.

Hold on, I'll edit this in a minute.

edit: k.

This is my horrible drawing ;] The extrema occur at x=2N/k, where k is a positive integer If k is even, the extrema is a maximum, and if k is odd, it is a minimum. The one furthest right is at x=2N, and is a minimum.

I'll try this again. If you stand at a peak at x=2N/k, and look along the negative x-axis, you see the next peak at x=2N/(k+2). The distance between these peaks is $4N\over k(k+2)$ (thanks for the correction) and if we sub in k=2N/x, we get $x^2 \over N+x$ for the "wavelength" at a point x. This has some of the qualitative properties you would expect. It goes to infinity as x goes to infinity and it goes to zero when x goes to zero. At $x=\sqrt{N}$, it is $1\over 1+\frac1{\sqrt{N}}$, which is $\approx 1$ if N is large.

So I would suggest that the wavelength is $x^2 \over N+x$ and the frequency is $\frac N{x^2} + \frac1x$.

But we're still not on the same page, I don't think....... Could you explain what you mean when you say "The peak ratio transitions from more than 1 interval per x.. to less than 1 per x."? My interest is sort of perked; I couldn't have told you that it was going to be 1 without an equation...

7. Thanks for the prompt reply.. Your interest is appreciated. Sorry, was my night to cook.. Mexican night

Ok..
I'll try this again. If you stand at a peak at x=2N/k, and look along the negative x-axis, you see the next peak at x=2N/(k+2). The distance between these peaks is
In my graph, it shows peaks whenever N/x is an integer, and troughs when remainder is .5
In other words, I used 2PI as a constant so that it would complete a cycle at n/n-1, n/n-2, n/n-3... n/1.. (hope I am saying this right).
It seems your Van Gogh rendition has PI as the constant (not 2PI).

Secondly, If I may refer to the image in my last post..
N = 221, and has a square root about 14.866.. You may notice that prior to 14 on the x-axis, the peaks occur > 1 time per x.. after 15 and beyond is where the peaks diverge and we near n/4, n/3, n/2, n/1..
The distance between the peaks increases 221/4 to 221/3 to 221/2 to 221/1 as shown in your drawing..

I think you are nearing the solution. I may not be my sharpest at the moment.. $IQ = \frac{1}{how full I am}$

8. Mexican food!! :o

No, I used $2\pi$ as the constant. We have the same thing - peaks occur whenever N/x is an integer (meaning x=2N/k for some even integer k) and troughs occur when N/x is a half integer (meaning x=2N/k for some odd integer k). I see how you can tell that the wavelength should be 1 near $x=\sqrt{N}$ now. So is the last expression I gave acceptable?

What exactly are you trying to do with this btw?

9. wavelength is
I'll plug this in and see how close we lie by tomorrow afternoon.

What exactly are you trying to do with this btw?
I PM'd ya.

10. Maddas, I was a bit off yesterday, your picture is correct.. I was confused that you used 2N while I was calculating for N..

I also realize a DUH! in my assumptions.. This method can only produce the wavelength from one peak to the next higher or lower peak, but not both. The 'instantaneous wavelength' that I seek is not what I thought it was, and may not be 1 at $x = \sqrt N$.

$\lambda = {N^2 \over N+x}$ is still not entirely precise.

11. Oh, I see what you're saying. In brief: $\cos(\pi x)$ peaks when x is an integer, $\cos (\pi N/x)$ peaks when N/x is an integer, so their sum peaks when x is an integer dividing N. I'm not sure how the wavelength gets involved though.

Note that the sum $\cos(\pi x) + \cos(\pi N/x) = 2\cos\Big(\pi\frac{x^2-N}{x}\Big)\cos\Big(\pi\frac{x^2+N}{x}\Big)$. The M-shape comes from the $\cos\Big(\pi\frac{x^2+N}{x}\Big)$ which is the modulating (carrier) wave. If you're going to check for peaks, it suffices to check just this function for peaks (it has fewer, so it will be slightly easier).

I'm also pretty sure there are much better ways to find factors...

12. Arggh.. You are right. but I meant to say 'the product of'. not the sum.. This is what is shown in the graph.

The product $cos(2\pi X) * cos(2 \pi \frac N {x})$ was more useful than the sum. Is there a simpler method? As you can see, my methods are still quite coarse.

If I can find the correct derivative for the wavelength between the peaks.. I can simply jump to the Nth peak at will, instead of waiting the age of the known universe and all that rot.

I'm giving myself a crash course in Hilbert Tranforms.. It seems this may be the direction I need for the correct algorithm.

13. Oh, I wondered why my graph didn't look like yours.

If I can find the correct derivative for the wavelength between the peaks.. I can simply jump to the Nth peak at will, instead of waiting the age of the known universe and all that rot.
How? I mean, isn't that still alot of peaks to check?

14. Perhaps.. this is actually the basis of my whole question. The product of these functions produces a beat frequency with much fewer peaks. I am not entirely sure if there is a reliable way to predict where the next 'group peak' lies. If there is, we can go directly to it, evaluate it, and jump higher or lower without calculating each and every integer in-between, thus homing in on a factor.
As I mentioned, I can do this visually by scrolling through the graph, but if we can teach the computer how to do this, progress would be made.
I used UBasic originally for the script, but found Python to be much faster.
Just need that elusive derivative, I think..