# Example of a diffeomorphism on $\mathbb{R}^{3}$ onto itself (or cube onto itself)

I am looking for an example (or a method to create my own examples) of diffeomorphism on a cube onto itself, similar to the wikipedia example on the page with the same name:

but in 3D. I'd like to have an example, but ideally I'd like to learn how to create examples myself. I understand the constrains that a diffeomorphism should have, and I think I'd be able to see if a given function is a diffeomorphism, but I dont know how to do the inverse.

(I guess that my problem is not a diffeomorphism)

• Every smooth function defines via gradient a smooth vector field. Every vector field defines a flow consisting of diffeomorphisms by solving an ODE. Sep 23, 2016 at 13:02
• @MoisheCohen Sorry, my maths background is quite weak. Care to clarify what you mean? Sep 23, 2016 at 13:03

I assume that you at least took a vector calculus and differential equations class (or classes). What you need is a smooth (at least continuously differentiable) vector field $V(x,y,z)$ on the cube $Q$, which vanishes on the boundary of the cube. For instance, you can (but do not have to) take $V$ as the gradient vector field of a smooth (at least twice continuously differentiable) function $f: Q\to {\mathbb R}$ whose 1st order partial derivatives vanish on the boundary of the cube: $$V=(\frac{\partial f}{\partial x}, \frac{\partial f}{\partial y}, \frac{\partial f}{\partial z}).$$
If you have hard time finding vector fields $V$, you can prescribe them numerically, on a sufficiently fine rectangular grid.

Once you have a vector field $V$, you consider the following ODE (ordinary differential equation; more precisely, a system of ODEs) $$\frac{d}{dt} h(x,y,z,t)= V(x,y,z)$$ with the unknown function $h$ and the initial condition $h(x,y,z,0)=(x,y,z)$. Now, there is a theorem saying that this differential equation has a unique solution $h(x,y,z,t)$ for all $t\ge 0$, which defines a family of diffeomorphisms given, for each value of $t=t_0\ge 0$ (say, $t_0=1$), by the map $$(x,y,z)\mapsto h(x,y,z, t_0).$$ Every such map will send the cube to itself, fix the boundary pointwise (i.e. send each boundary point to itself).

Solving ODEs is not easy but you should be able to find some software that does it for you numerically, which, I think, is all what you care about. For instance, both Mathematica and Matlab will do it. There is probably even some free software available.

You can also ask if every diffeomorphism of the cube to itself arises this way. This is not true but not far from being true. For instance, if you require that the diffeomorphism fixes some neighborhood of the boundary of the cube pointwise, then it will appear as a solution (for $t=1$) of a non-autonomous ODE very similar to the one I described above: $$\frac{d}{dt} h(x,y,z,t)= V(x,y,z,t),$$ where $V$ is again a vector field on $Q$, but now it is also time-dependent ($V$ vanishes near the boundary of the cube). The initial condition is the same as above. The fact that all diffeomorphisms appear this way is a much-much harder theorem than the one I mentioned earlier. (For instance, this theorem is false once the dimension of the cube is $\ge 6$.)

Hope it helps.

• This is a brilliant answer, thank you. I'll have a better look whenever I can and I'll accept it. Sep 23, 2016 at 20:04
• Thank's, I got to test this with some analytic function and it works ( e.g. $f(x,y,z)=cos(x*pi/L)*cos(y*pi/L)*cos(z*pi/L)$) and actually gives something quite similar to the image I posted. I face another problem now, which I failed to express in my original question: I actually need a diffeomorphism because I want to be able to compute the forward map, but also the inverse exact map of that deformation, as I want to use this deformation as a "perfect solution" test in some research I am doing. Is this too much to ask? should I open a new question about it, or leave it because its impossible? Sep 26, 2016 at 14:39
• @AnderBiguri The inverse solution to $h(x,y,z,t)$ is given by $h(x,y,z, -t)$. Sep 26, 2016 at 15:28
• Follow up question: math.stackexchange.com/questions/1943544/… Sep 27, 2016 at 14:13

There a second way (perhaps simpler) to construct lots of diffeomorphisms of the cube to itself, and with it you can probably more easily reconstruct the picture you posted in your question statement.

The basic idea is this:

If $f$ is a smooth function with domain the closed interval $(0,1)$, taking values in $\mathbb{R}$, such that $\lim_{x \to 0^+} f(x) = 0$ and $\lim_{x \to 1^-} f(x) = 1$, and $f' \geq \epsilon > 0$, then $f$ is a diffeomorphism of $(0,1)$ to itself.

The idea is that since $f$ is strictly monotonic, it is a bijection of $(0,1)$ to itself. And since $f' \neq 0$, it is everywhere a local diffeomorphism. Therefore $f$ is in fact a diffeomorphism.

Now, there is an easy way to guarantee that $f$ is a function with limits $\lim_{x\to 0^+} f(x) = 0$ and $\lim_{x\to 1^-} f(x) = 1$ and that $f' \geq \epsilon$: we can suppose that our function

$$f(x) = x + g(x)$$

where $g(x)$ is any smooth function that vanishes at $x = 0$ and $x = 1$, and such that $|g'(x)| < 1 - \epsilon$.

This can be extended to the higher dimensional case as follows.

Let $\phi$ denote the desired diffeomorphism, and make the assumption that

$$\phi(x_1, x_2, x_3) = (x_1,x_2,x_3) + (u,v,w)$$

where $u,v,w$ are real functions of $x_1, x_2, x_3$. We require that the three functions are smooth, that they vanish on the boundary of the cube, and that the sum of the gradients

$$|\nabla u|^2 + |\nabla v|^2 + |\nabla w|^2 < 1 - \epsilon$$

This will guarantee that $\phi$ is a smooth map whose Jacobian derivative is invertible, and also using what is discussed in the first part of this answer that $\phi$ is bijective onto the cube.

Example:

In the two dimensional case, you can let

$$u(x,y) = \frac{1}{4\pi} \sin(2\pi y) \sin(\pi x)$$

and

$$v(x,y) = - \frac{1}{4\pi}\sin(2\pi x) \sin(\pi y)$$

and you will get a picture that looks something like what you showed above in the question.

In the cubic case, then you can do something similar by setting, for example,

$$u(x,y,z) = \frac{1}{7\pi} \sin(\pi x) \sin(2\pi y) \sin(3\pi z)$$

$$v(x,y,z) = - \frac{1}{7\pi} \sin(3\pi x) \sin(\pi y) \sin(2\pi z)$$

and

$$w(x,y,z) = \frac{1}{7\pi} \sin(2\pi x) \sin(3\pi y) \sin(\pi z)$$

The crucial thing (which was used to determine the coefficient $\frac{1}{7\pi}$, is that we want the sum of the squares of the gradients of $u$, $v$ and $w$ to be strictly less than 1. A naive estimate using that trigonometric functions are bounded in absolute value by $1$ shows that $$|\nabla u|^2 \leq \frac{\pi^2 + (2\pi)^2 + (3\pi)^2}{(7\pi)^2} = \frac{2}{7}$$ and similarly for $|\nabla v|^2$ and $|\nabla w|^2$, so the condition is verified.

• Great! this is a fantastic answer. This is a really great way of getting those nice diffeomorphisms! In case you are interested, I am following this up further, as I need the inverse map, not only the forward map. math.stackexchange.com/questions/1946433/… Sep 29, 2016 at 13:58
• To get exact analytical expressions of the inverse map would be quite a bit harder in general. But if you are happy with just a "grid", you can just compute the inverse map by hand on a case by case basis: just take your original grid values $(x_i, y_i, z_i)$, apply the transformation to it to get $(x_i + u_i, y_i + v_i, z_i + w_i)$, then you would know precisely what the inverse map is on those values (since the inverse map must then carry $(x_i + u_i, y_i + v_i, z_i + w_i)$ back to $(x_i, y_i, z_i)$). Furthermore, since you know the gradients at all those points (using that the derivatives Sep 29, 2016 at 14:04
• of inverse functions are the inverses of the derivatives of the original function), you can even patch them together with bicubic interpolation to get a reasonable approximation of the inverse map away from the grid points. Sep 29, 2016 at 14:06
• Ahh, yes, indeed. Currently I am in the search of getting the inverse map in a regular grid in the deformed space, though. I am not sure if its even possible, but if It is, it will be a really good example in my scietific paper. I guess that if I can not get it i'll go for something like you said Sep 29, 2016 at 14:08