Is there a way to map the interval $[0, \pi]$ to $[0, \pi/2]$ and $[\pi/2, 0]$?

274 Views Asked by At

I was running a bunch of simulations and computing the absolute value of the arctan of a ratio of numbers, using the atan2( ) function in Matlab; this gives me solutions that range from 0 to $\pi$, but I realize that it's a mistake and that I should have first taken the absolute value of the ratios, before computing the arctan, since I want the values to range only from 0 to $\frac{\pi}{2}$.

Is there a way to map the interval $[0, \pi ]$ to $[0, \frac{\pi}{2} ]$ and [$\frac{\pi}{2}$, 0 ]; that is,

Can I map [0, $\frac{\pi}{2}$] to itself, but then also map [$\frac{\pi}{2}, \pi]$ to [$\frac{\pi}{2}$, 0 ]?

1

There are 1 best solutions below

0
On BEST ANSWER

$$f(x) = \frac{\pi}{2} - \left| \frac{\pi}{2} - x\right|$$ is a possibility

though the range of atan2 in Matlab is actually $[-\pi,\pi]$ and if you want to force this to $\left[0,\frac{\pi}{2}\right]$ in the same sort of folding way then you might prefer $$f(x) = \frac{\pi}{2} - \left| \frac{\pi}{2} - |x|\right|$$