# Transform a region using the flow of differential equation

I was looking to apply a nonlinear transformation to a geometric region, say a rectangle to obtain a transformed region. According to the documentation for TransformedRegion, one requires a Region and a function. I am trying to use the flow (solution) of an ODE at some time $$t$$ as the function transforming the region. I am using ParametricNDSolveValue to get the flow numerically as a function of the initial condition at some given time. Here is my attempt.

(*Ft is the flow of the ODE at time t=1, starting at (a,b)*)
ODEs = {x'[t] == y[t], y'[t] == Sin[x[t]], x[0] == a, y[0] == b};
Ft = ParametricNDSolveValue[ODEs, {x[1], y[1]}, {t, 0, 2}, {a, b}];
R = Rectangle[{-1,-1},{1,1}];
FtR = TransformedRegion[R,Ft];


But I am getting the following error:

TransformedRegion::vfunc: ParametricFunction[1,InternalBag[<1>],0,1,{{a$109714,b$109715},<<5>>,{0,1}},{NDSolvebase\$109724,NDSolveNDSolveParametricFunction[0,{ParametricNDSolveValue,InternalBag[<2>],None,ParametricNDSolveValue},<<6>>,{},{2.}]}] evaluated at a list of length 2 should give a non-empty list.


I thought I could define some function:

FtF = Function[{a, b}, Ft[a, b]]


FtR = TransformedRegion[R, FtF]


Gives

TransformedRegion::vfunc: Function[{a,b},Ft[a,b]] evaluated at a list of length 2 should give a non-empty list.


Maybe TransformedRegion only accept symbol expression. By now we have to use ParametricPlot and DiscretizeGraphics to obtain such region.

ODEs = {x'[t] == y[t], y'[t] == Sin[x[t]], x[0] == a, y[0] == b};
Ft = ParametricNDSolveValue[ODEs, {x[1], y[1]}, {t, 0, 2}, {a, b}];
R = Rectangle[{-1, -1}, {1, 1}];
plot = ParametricPlot[Ft[a, b], {a, b} ∈ R]
DiscretizeGraphics[plot]


• That's so cool! Commented Mar 9, 2022 at 6:22

A work-around: Apply Ft to the MeshCoordinates of boundary-discretized R:

transformedRegion[reg_, f_] := MeshRegion[
f @@@ MeshCoordinates[#],
MeshCells[#, All]] & @
BoundaryDiscretizeRegion @ reg

transformedRegion[R, Ft]