This is a repository containing tools to rearrange two-variables functions in MATLAB.
Add the folder "Code" to your MATLAB path and you are ready to go!
Fucntions are stored as contourLines
objects. This is a class that contains all the needed informations to rearrange.
Given a two-variables function F
, you want to pass it to the constructor as a function handle.
function z = F(x,y)
z=x+y;
end
Fsharp = contourLines(@F);
The line Fsharp = contourLines(@F);
will create a contourLines object named Fsharp, which stores 100 levels of the function F . The complete constructor method can be called as follows.
Fsharp = contourLines(@F, gridCoordinates,numberOfCells,numberOfLevels);
When specified, the variables should be of the following form:
gridCoordinates=[xmin xmax ymin ymax]
is describing the square domain in which the function is restricted to; default[-1 1 -1 1]
;numberOfCells
determines how many points are constructed in the grid; default20
will give a 20x20 grid;numberOfLevels
determines how many levels of the function are stored; default100
If you want to construct a function with a domain E different from a rectangle, you can pass to the constructor method a function F
which is -inf
outside of E.
Given a function F and the contourLines object Fsharp
relative to it, you can call the Schwarz (spherically decreasing) rearrangement of F as the function
Fsharp.Schwarz(x,y);
with NaN
will be given as an output.
An example is given in the file Rearrangement2.m
.
Given two functions F
, G
and the respective contourLines objects Fsharp
and Gsharp
, you can call the rearrangement of F along G as the function
Fsharp.Schwarz(x,y,Gsharp);
with x and y real numbers. If the couple (x,y) is outside of the set where the Schwarz rearrangement is defined (i.e. the biggest superlevel set of G inside the initial grid), a NaN
will be given as an output.
Given a contourLines object Fsharp
, you can plot the i
-th level of Fsharp
with the line
Fsharp.plotLevel(i)
The number i
can go from 1 to Fsharp.numberOfLevels
. Bigger the i
, smaller the level set.
The distribution function of
A distribution function is stored inside the class contourLines. If Fsharp is a contourLines object, you can call its distribution function by
Fsharp.distributionFunction(t);
where t
is a real number.
The radially decreasing rearrangement of
The radially decreasing rearrangement function is stored in the contourLines object, and you can call it by
Fsharp.radDecrRearr(m);
where m
is a real number.