Using the floor function to define a periodic function

106 Views Asked by At

Is it possible to define the function defined in the following image using the floor function? If so, how?

enter image description here

Update

I tried your suggestion with Matlab's symbolic toolbox,

syms x clear
clear f
f(x)=abs(x-2*floor(x/2));
fplot(f(x),[0,8])

but I got the following picture, which is not correct.

enter image description here

1

There are 1 best solutions below

0
On BEST ANSWER

Define the fractional part $\{x\}$ to be $$ x = \left\lfloor x \right\rfloor + \left\{ x \right\}\quad \Rightarrow \quad 0 \le \left\{ x \right\} < 1 $$ note that it does not actually reach to $1$.

Then stretch and shift it so to obtain $$ 1 - 2\left\{ {{x \over 2}} \right\} $$

Finally take the absolute value $$ f(x) = \left| {\,1 - 2\left\{ {{x \over 2}} \right\}\,} \right| = \left| {\,1 - x + 2\left\lfloor {{x \over 2}} \right\rfloor \,} \right| $$

Sega_con_Floor