I am trying to come up with a diffeomorphism f the cube onto itself. The reason I am trying to do this is because for a study I am doing I need a way of deforming the cube (onto itself) and be able to perfectly "bring back" the deformed domain to the original, in order to test some numerical algorithm I am working. Clarification just in case I have the XY problem.

This is a follow up question from Example of a diffeomorphism on $\mathbb{R}^{3}$ onto itself (or cube onto itself). I am trying to make a real example out of it.

I start from defining "a smooth (at least continuously differentiable) vector field $V(x,y,z)$ on the cube $Q$, which vanishes on the boundary of the cube.

If I don't understand wrong this is a valid $V$: \begin{align*} V(x,y,z) = \bigl( &\sin(x \cdot \pi/L)\sin(y \cdot \pi/L)\sin(z \cdot \pi/L),\\ &\sin(x \cdot \pi/L)\sin(y \cdot \pi/L)\sin(z \cdot \pi/L),\\ &\sin(x \cdot \pi/L)\sin(y \cdot \pi/L)\sin(z \cdot \pi/L)\bigr), \end{align*} being $L$ the length of the cube.

Then I solve the ODE $$ \frac{d}{dt} h(x,y,z,t)= V(x,y,z) $$ with initial conditions $h(x,y,z,0) = (x,y,z)$.

If I am not wrong (I may be) the solution is: $$ \frac{d}{dt}[h_x(x,y,z,t), h_y(x,y,z,t), h_z(x,y,z,t)] = [V_x, V_y, V_z]. $$

And by integrating the right hand side from $t=0$ to $t=t_0$ $dt$ I get: $$ h_x(x,y,z,t) = x_0 + t\cdot\sin(x \cdot \pi/L)\sin(y \cdot \pi/L)\sin(z \cdot \pi/L) $$ (same with the other two).

This equation does indeed describe a map of the cube onto itself (automorphism?), that actually looks similar to the image in the original post (especially if you modify $L$ by e.g. $L/2$).

However, I am supposed to find the inverse map if I find the solution to $h_x(x,y,z,-t)$, which, if I am not wrong, simply translates to $$ h_x(x,y,z,-t)=x_0 - t\cdot\sin(x \cdot \pi/L)\sin(y \cdot \pi/L)\sin(z \cdot \pi/L) $$ in my case.

However, when numerically testing this, if I "warp" a grid with the first map, and then use this last one on those "warped" points, I do not get the original grid.

So questions:

  1. What is wrong with my maths? What did I miss?
  2. What is the solution for this map? Is there one?
  3. If this is a bad way of doing the thing, what should I do? How can I get a map of the cube onto itself that I can invert "perfectly" (meaning I don't want a numerical approximation)?

PD: MATLAB code that I am using for this:


x2=x - t.*sin(x.*pi/L).*sin(y.*pi/L).*sin(z.*pi/L);
y2=y - t.*sin(x.*pi/L).*sin(y.*pi/L).*sin(z.*pi/L);
z2=z - t.*sin(x.*pi/L).*sin(y.*pi/L).*sin(z.*pi/L);

x3=x2 + t.*sin(x2.*pi/L).*sin(y2.*pi/L).*sin(z2.*pi/L);
y3=y2 + t.*sin(x2.*pi/L).*sin(y2.*pi/L).*sin(z2.*pi/L);
z3=z2 + t.*sin(x2.*pi/L).*sin(y2.*pi/L).*sin(z2.*pi/L);

for indz=1:31
%     plot(x(:,:,indz),y(:,:,indz),'r.');

    hold on

    axis tight
  • $\begingroup$ I took the liberty of tweaking the LaTeX in your question. If I got anything wrong, please feel free to correct it. $\endgroup$ Sep 29, 2016 at 10:34
  • $\begingroup$ @AndrewD.Hwang nah, that edit makes the post look gorgeous ! $\endgroup$ Sep 29, 2016 at 10:34

1 Answer 1


The main problem appears to be the solution of the ODE: The equations are coupled and non-linear. Geometrically, the velocity of a point $(x_{0}, y_{0}, z_{0})$ depends on its location, and therefore "varies as the point moves". Consequently, integrating from $0$ to $t_{0}$ doesn't solve the ODE, it only parametrizes the line with specified initial position and velocity.

In case it helps, the one-dimensional version is $$ \frac{dx}{dt} = \sin(x\pi/L); $$ the solution is not $x(t) = x_{0} + t\sin(x_{0}\pi/L)$, but the inverse function of $$ t = \int_{x_{0}}^{x(t)} \frac{d\xi}{\sin(\xi\pi/L)}. $$ In practice, it's Highly Unlikely that a solution of a non-linear PDE has an elementary closed formula.

  • $\begingroup$ I see where I did the mistake, indeed. So, you are suggesting that obtaining a diffeomorphism on R3 that i know its exact inverse may not be something I can do? What about numerically in a grid? $\endgroup$ Sep 29, 2016 at 10:30
  • $\begingroup$ Unfortunately, solving (in closed form) even a quadratic ODE in three variables may be impossible. In principle, numerical solution on a grid is just linear algebra, but the details may be messy. I've added the numerical-methods tag.... :) $\endgroup$ Sep 29, 2016 at 10:38
  • $\begingroup$ Thanks! I see the problem. I may accept your answer (that kind of addresses my question) and open anew one on "how to numerically solve this", either here or on SO. $\endgroup$ Sep 29, 2016 at 11:10
  • 1
    $\begingroup$ I posted a follow up question: math.stackexchange.com/questions/1946433/… $\endgroup$ Sep 29, 2016 at 13:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .