Redistribution/synchronization problem

68 Views Asked by At

I have a very peculiar problem.

I am interested to solve problems such as:

B>8 (first occurence of B>8) for 40*B = 15*D such that B and D are integer numbers.

The problem is also illustrated in the following image:

enter image description here

Given that the bottom (black) train of events runs at a certain rate and the top interval is also of a certain fixed periodicity, such that the number of black intervals per blue interval is an integral number, how then to choose the width of the green intervals such that their number is equal to or higher than a certain value and such that each green interval also contains an equal number of black intervals/events at t1. i.e. how to synchronize three periodic systems by adjusting 1.

The solution should be implementable as a function in a programming language (doesn't matter at this point).

I suspect that it has to do with prime numbers but I cannot put my finger on it (and I am no mathematician). This seems easy, but it is not :s

2

There are 2 best solutions below

2
On

If you divide both sides by $15$ you get $D=\frac 83B$ Now you need the smallest $B$ that is both greater than $8$ and a multiple of $3$ (so $D$ will be an integer). That is $9$, so $B=9, D=24$
For your comment, the procedure is quite general. From $aB=bD$ you divide by $b$ to get $\frac abB=D$. Reduce $\frac ab$ to lowest terms, then $B$ has to be a multiple of whatever denominator is left. Find the smallest multiple of that which is greater than $x$ and you have your answer.

2
On

This might work. I'm not really sure. It's in C:

    #include <stdlib.h>
    #include <stdio.h>
    #include <math.h>

    int doublemodulus ( double z, double i );

    double B, D, k, Sol;
    const double a, b, c = 1;

    int main() {

    D = a/b + doublemodulus( a, b ) * B;
    if ((doublemodulus( D, c ) != 0) || (doublemodulus( a, b ) != 0)) {
        k = 1 / doublemodulus( D, c);
        D = D*k;
        Sol = D/a;
    }
    else Sol = D/(a/b);
    printf("%lf", Sol);

    return 0;
    }

    int doublemodulus ( double z, double i ) {
        double result = z/i;
        result = floor(result);
        return z - (result * i);
    }