1. ## function finding

How to find function that have values:
f(0)=0, f(1)=0, f(2)=0, f(3)=0,... for period T=1
f(0)=0, f(1)=1, f(2)=0, f(3)=1,... for period T=2
f(0)=0, f(1)=1, f(2)=1, f(3)=0, f(4)=1, f(5)=1, f(6)=0,... for period T=3
f(0)=0, f(1)=1, f(2)=1, f(3)=1, f(4)=0, f(5)=1, f(6)=1, f(7)=1, f(8)=0,... for T=4
f(0)=0, f(1)=1, f(2)=1,..., f(n-1)=1, f(n)=0, f(n+1)=1,...,f(2n)=0,f(2n+1)=1,... T=n

or shortly:
0000000000000 T=1
0101010101010 T=2
0110110110110 T=3
0111011101110 T=4
...

So, I need function in two variables f(n,T)
The function must NOT have MOD, CEILING or FLOOR function.

2. ## Re: function finding

Originally Posted by Emilijo
How to find function that have values:
f(0)=0, f(1)=0, f(2)=0, f(3)=0,... for period T=1
f(0)=0, f(1)=1, f(2)=0, f(3)=1,... for period T=2
f(0)=0, f(1)=1, f(2)=1, f(3)=0, f(4)=1, f(5)=1, f(6)=0,... for period T=3
f(0)=0, f(1)=1, f(2)=1, f(3)=1, f(4)=0, f(5)=1, f(6)=1, f(7)=1, f(8)=0,... for T=4
f(0)=0, f(1)=1, f(2)=1,..., f(n-1)=1, f(n)=0, f(n+1)=1,...,f(2n)=0,f(2n+1)=1,... T=n

or shortly:
0000000000000 T=1
0101010101010 T=2
0110110110110 T=3
0111011101110 T=4
...

So, I need function in two variables f(n,T)
The function must NOT have MOD, CEILING or FLOOR function.
Why not try transforming a sine function?

3. ## Re: function finding

Originally Posted by Prove It
Why not try transforming a sine function?
How? It is possible? Can you give me more details? (or example)

4. ## Re: function finding

A function of the form \displaystyle \begin{align*} y = a \sin{\left[b\left(x - c\right)\right]} + d \end{align*} has a mean value of \displaystyle \begin{align*} d \end{align*}, which also corresponds to the vertical translation, an amplitude of \displaystyle \begin{align*} |a| \end{align*}, a horizontal translation of \displaystyle \begin{align*} c \end{align*}, and a period of \displaystyle \begin{align*} \frac{2\pi}{b} \end{align*}.

In your first example, you want the period to be 1, so \displaystyle \begin{align*} \frac{2\pi}{b} = 1 \implies b = 2\pi \end{align*}, and it would be appropriate to have \displaystyle \begin{align*} c = d = 0 \end{align*}, because it is unnecessary to translate the function at all. You can have \displaystyle \begin{align*} a \end{align*} be whatever you like.

5. ## Re: function finding

But try with period T=3 or T=4

6. ## Re: function finding

For t=3 you can use $a \sin^2(bx)$.

7. ## Re: function finding

Originally Posted by a tutor
For t=3 you can use $a \sin^2(bx)$.
No, I must have a general function for all periods.

8. ## Re: function finding

Originally Posted by Prove It
A function of the form \displaystyle \begin{align*} y = a \sin{\left[b\left(x - c\right)\right]} + d \end{align*} has a mean value of \displaystyle \begin{align*} d \end{align*}, which also corresponds to the vertical translation, an amplitude of \displaystyle \begin{align*} |a| \end{align*}, a horizontal translation of \displaystyle \begin{align*} c \end{align*}, and a period of \displaystyle \begin{align*} \frac{2\pi}{b} \end{align*}.

In your first example, you want the period to be 1, so \displaystyle \begin{align*} \frac{2\pi}{b} = 1 \implies b = 2\pi \end{align*}, and it would be appropriate to have \displaystyle \begin{align*} c = d = 0 \end{align*}, because it is unnecessary to translate the function at all. You can have \displaystyle \begin{align*} a \end{align*} be whatever you like.

Can you check your formula? I think it does not work for T=3 or bigger period. Can you give me example with your formula for T=3 ? Thanks
Have you another idea?

9. ## Re: function finding

I don't really know how to do piecewise functions in LaTeX, but

$f(n) = 0, n \equiv 0 (\mod T)$ and $f(n) = 1, n \not\equiv 0 (\mod T)$ easily works.

Too bad you can't use mod...