Generating Irrational Ratios in Wave Simulations

Click For Summary

Discussion Overview

The discussion revolves around generating two random numbers whose ratio approximates an irrational number for use in wave simulations. Participants explore methods to achieve a long repeat period in the ratio, which is relevant to simulating non-periodic wave behavior.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant seeks an algorithm to generate two random numbers with a ratio that appears irrational for wave simulations.
  • Another participant suggests that any two pseudo-random numbers with sufficient precision could suffice.
  • A participant modified their approach by using a large prime number to ensure a long repeat period in the ratio, but noted limitations due to double precision representation.
  • Concerns were raised about the proximity of the generated numbers affecting the perceived periodicity of the resultant waveforms.
  • One suggestion involved starting with a desired ratio and back-calculating one of the numbers to maintain control over the simulation parameters.
  • Another participant questioned whether a ratio close to 1.00009 would still yield a periodic appearance in short simulations, emphasizing the need for long-term observation to detect aperiodicity.
  • Discussion included uncertainty about the nature of aperiodic behavior and its implications for waveforms generated from closely related frequencies.

Areas of Agreement / Disagreement

Participants express differing views on the effectiveness of various approaches to generating the desired ratios and the implications for wave behavior. The discussion remains unresolved regarding the best method and the characteristics of the resultant waveforms.

Contextual Notes

Participants acknowledge limitations related to numerical precision and the effects of closely spaced values on perceived periodicity, but do not resolve these issues.

roam
Messages
1,265
Reaction score
12
TL;DR
Is there a way to generate two random numbers such that their ratio simulates the behavior of an irrational number?
I am trying to write an algorithm that generates two random numbers in a given interval such that their ratio is an irrational number. I understand that all numbers stored on a computer are rational, so it is not possible to have a truly irrational number in a simulation. So, instead I am looking for an algorithm that generates two numbers whose ratio simply has a very long repeat period (it appears to be irrational during the simulation). How would such an algorithm look like (e.g., in Matlab)?

Any suggestions would be greatly appreciated.

P.S. I am simulating a physical situation where the ratio of the period of two waves is not rational (or rather, it has a very long repeat period), hence the resultant wave does not appear to be periodic.
 
Physics news on Phys.org
Any two (pseudo) random numbers to a reasonable level of precision would do - what happens when you try?
 
  • Like
Likes   Reactions: roam
Hi @pbuk

I modified my code, so that one of the numbers is always a large prime, so that the ratio of the two numbers will have a very long repeat period. However, as a double precision number, the number will still only have 16 significant digits.

Also, I believe the problem with my simulation might be something else. The two numbers that I am generating must be close in range, e.g., if they are both primes we might get:

##x_1 = 2051587##
##x_2 = 2051773##

Note that ##x_1## and ##x_2## represent periods of waves that I am trying to combine.

So, the ratio of the above numbers will be either 1.000090661522032 or 0.999909346696735. I think, that means that the two waves will be effectively in phase, and you will only see aperiodic behavior if you plot for an extremely large number of cycles. Is that right?

Any explanation would be appreciated.
 
I suggest starting with a random number for the ratio and back-calculating one of the initial numbers that you talked about. That allows you to control the ratio and know that it is what you want (very long repeating period, magnitude, etc.)
 
Hi @FactChecker

Do you think that would still be helpful if the ratio is of the order 1.00009?

If we have a ratio like that, doesn't it mean that the combined signal will still look periodic in the short range? I think one has to simulate over a very large number of periods to see any aperiodicity.
 
I don't know what your application is, but generating a random number in the range 0.999998 to 1.00009 is not difficult. Either approach should have a very long repetition period.
 
roam said:
So, the ratio of the above numbers will be either 1.000090661522032 or 0.999909346696735. I think, that means that the two waves will be effectively in phase, and you will only see aperiodic behavior if you plot for an extremely large number of cycles. Is that right?

Any explanation would be appreciated.
I'm not sure what aperiodic behaviour looks like, but if you mean that the combination of two waves with similar frequencies is a waveform with a pattern that only changes very slowly then that is correct. What did you expect? I think you need to look at why you are doing what you are doing because you seem to be focussing on unimportant or even meaningless things and ignoring the big picture.
 
  • Like
Likes   Reactions: roam

Similar threads

  • · Replies 19 ·
Replies
19
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
Replies
25
Views
4K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 2 ·
Replies
2
Views
9K
  • · Replies 5 ·
Replies
5
Views
2K
Replies
7
Views
11K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 33 ·
2
Replies
33
Views
11K