# Question:How to convert this trig expression into a periodic piecewise function

## Question:How to convert this trig expression into a periodic piecewise function

Maple

Question 1
Let theta a real number in the range 0..2*Pi.
Is there a way to "convert"

`f := theta -> arccos(cos(theta))+arcsin(sin(theta))`

into

`f1 := theta -> piecewise(theta < 0, 0, theta < (1/2)*Pi, 2*theta, theta < Pi, Pi, theta <= (3/2)*Pi, 3*Pi-2*theta, 0)`

Question 2
As f1 is  2*Pi periodic, is there a way to convert f into a periodic function where the "pattern" is f1(theta)?
To be clearer I thought to something close to what we get when we do this

```solve(cos(x)=1, allsolutions);
2 Pi _Z2
Originally _Z1, renamed _Z1~:
is assumed to be: integer
```

and I imagined

```Some_Transformation(f(theta))
f1(theta+2*Pi*_Z1~)
Originally _Z1, renamed _Z1~:
is assumed to be: integer
```

For the moment I build the periodized f1 this way

```f2 := (theta, K) -> int(f1(theta-z)*add(Dirac(z-2*Pi*k), k=-K..K), z=-infinity..+infinity);
# or
f2 := (theta, K) -> sum(int(f1(theta-z)*Dirac(z-2*Pi*k), z=-infinity..+infinity), k=-K..K);

```