I'm trying to define a module (in Mathematica) that receives a point $\mathbf{p}(\mathbf{x})\in\mathbb{R}^n$ (expressed in the coordinate system $\mathbf{x}$) and a coordinate transformation $\bar{\mathbf{x}}(\mathbf{x})$ as inputs, and returns $\mathbf{p}(\bar{\mathbf{x}})$ as output; i.e., the module will return the point $\mathbf{p}$ expressed in the new coordinate system $\bar{\mathbf{x}}$.
Example: If $\mathbf{p}=(-1,1)$ in cartesian coordinates ($\mathbf{x}=(x,y)$) and $\bar{\mathbf{x}}(\mathbf{x})=(\sqrt{x^2+y^2},\arctan_2(y,x))$ (i.e., $\bar{\mathbf{x}}=(r,\theta)$), then the expected output is $(\sqrt{2},3\pi/4)$. If $\mathbf{p}=(1,2,3)$ in cartesian coordinates and $\bar{\mathbf{x}}(\mathbf{x})=(y+x,y-x,z-1)$, then the expected output is $(3,1,2)$. I want the module to work with a general coordinate transformation and dimension.
I feel like I tried everything. The module should be extremely simple, it's just that the syntax confuses me. How do I receive a function as an input? If the module reads "$f(x,y)"$, how do I connect between $x$ and $y$ to the first and second coordinate of $\mathbf{p}$ respectively?
Thanks!
transform[{x_, y_}] := {Sqrt[x^2 + y^2], ArcTan[x, y]}; p = {-1, 1}; transform[p]which gives{Sqrt[2], (3 Pi)/4}$\endgroup$