Let {\color{orange}\varphi} =
\color{red}q \cdot \pi
an angle with
\displaystyle
piFraction((L-1/4)*3.14159,1)
< {\color{orange}\varphi}
< piFraction((L+1/4)*3.14159,1)
and
\color{blue}f
the function with
\displaystyle {\color{blue}f(x) =
\sin \left(\frac{q}4
x-{\color{orange}\varphi}\right)}
.
Determine \color{red}q
such that
\displaystyle
{\color{blue}f\left(\pi\right) = y}
.
It is
\displaystyle
{\color{blue}f\left(\pi\right) =
\sin \left(piFraction(q/4*3.14,1)
-{\color{orange}\varphi}\right)}
.
We now look for
{\color{orange}\varphi}
with
\displaystyle
piFraction((L-1/4)*3.14159,1) <
{\color{orange}\varphi} <
piFraction((L+1/4)*3.14159,1)
and
\displaystyle {\color{blue}
\sin \left(piFraction(q/4*3.14,1)
-{\color{orange}\varphi}\right) = y}
.
This gives
\displaystyle
piFraction(q/4*3.14,1)
-{\color{orange}\varphi} =
piFraction((4-n)/2*3.14,1),
hence
\displaystyle
{\color{orange}\varphi} =
piFraction((q-8+2*n)/4*3.14,1),
and eventually
\color{red}q =
fractionReduce((q-8+2*n),4)
.