Parallelepiped inclusion function

Main author: Maël Godard

Use case

Consider a function \(\mathbf{f}:\mathbb{R}^n\to\mathbb{R}^m\). In the case where \(0<n<m\), a parallelepiped inclusion function is available in the library.

A parallelepiped inclusion function of \(\mathbf{f}\) is noted \(\langle\mathbf{f}\rangle\). For a \(n\)-dimensional box \([\mathbf{x}]\), \(\langle\mathbf{f}\rangle([\mathbf{x}])\) is a parallelepiped which enclose \(\mathbf{f}([\mathbf{x}])\).

Note that this inclusion function also works with thick functions.

Examples

\(\mathbb{R}^1\to\mathbb{R}^2\)

Define the parabolic function \(\mathbf{f}:\mathbb{R}\to\mathbb{R}^2\) such that

\[\begin{split}\mathbf{f}(x)= \left( \begin{array}{c} x\\ x^{2} \end{array} \right)\end{split}\]

It can be defined in Codac as follows:

X_2d = ScalarVar()
f_2d = AnalyticFunction([X_2d], [X_2d,sqr(X_2d)])

The performances of the parallelepiped inclusion function can be visualized as follows:

dx_2d = 0.2
x0_2d = -2.0

while x0_2d <= 2.0:
    X0_2d = Interval(x0_2d, x0_2d+dx_2d)
    p = f_2d.parallelepiped_eval(X0_2d)
    DefaultFigure.draw_parallelepiped(p, Color.dark_green())
    
    x0_2d += dx_2d

The resulting plot is shown below. In green is the result of the evaluation using parallelepipeds.

2D Parabola with parallelepiped inclusion

\(\mathbb{R}^2\to\mathbb{R}^3\)

Define the parabolic function \(\mathbf{f}:\mathbb{R}^2\to\mathbb{R}^3\) such that

\[\begin{split}\mathbf{f}(\mathbf{x})= \left( \begin{array}{c} x_{1}\\ x_{2}\\ x_{1}^{2}+x_{2}^{2} \end{array} \right)\end{split}\]

It can be defined in Codac as follows:

X_3d = VectorVar(2)
f_3d = AnalyticFunction([X_3d], [X_3d[0], X_3d[1], sqr(X_3d[0]) + sqr(X_3d[1])])

The performances of the parallelepiped inclusion function can be visualized as follows:

fig_3d = Figure3D("3D")
dx_3d = 0.2
x0_3d = -2.0

while x0_3d <= 2.0:
    X0_3d = Interval(x0_3d, x0_3d+dx_3d)
    y0_3d = -2.0

    while y0_3d <= 2.0:
        Y0_3d = Interval(y0_3d, y0_3d+dx_3d)
        b = f_3d.eval([X0_3d, Y0_3d])
        p = f_3d.parallelepiped_eval([X0_3d, Y0_3d])

        fig_3d.draw_box(b, StyleProperties(Color.blue(0.3), "box"))
        fig_3d.draw_parallelepiped(p, StyleProperties(Color.green(0.3), "parallelepiped"))

        y0_3d += dx_3d
    
    x0_3d += dx_3d

The resulting figure is shown below. On the left is the result of the interval evaluation of Codac (layer “box”) (see Evaluations). On the right is the evaluation using parallelepipeds (layer “parallelepiped”).

3D Parabola with boxes and parallelepipeds

Thick function

Define the thick parabolic function \(\mathbf{f}:\mathbb{R}\to\mathbb{R}^2\) such that

\[\begin{split}\mathbf{f}(x)= \left( \begin{array}{c} x\\ \left[1.1,1.2\right]\cdot x^{2} \end{array} \right)\end{split}\]

It is called a thick function because the output of this function is always a box (here an interval) even when the input is a real number.

It can be defined in Codac as follows:

X_if = ScalarVar()
f_if = AnalyticFunction([X_if], [X_if,Interval(1.1,1.2)*sqr(X_if)])

The thickness of the function can be visualized by plotting the lower and upper trajectories:

f_lb = AnalyticTraj(AnalyticFunction([X_if],1.1*sqr(X_if)),Interval(-2.0,2.0))
f_ub = AnalyticTraj(AnalyticFunction([X_if],1.2*sqr(X_if)),Interval(-2.0,2.0))

DefaultFigure.plot_trajectory(f_lb.sampled(0.01))
DefaultFigure.plot_trajectory(f_ub.sampled(0.01))

The performances of the parallelepiped inclusion function can then be visualized as follows:

dx_if = 0.1
x0_if = -2.0

while x0_if <= 2.0:
    X0_if = Interval(x0_if, x0_if+dx_if)
    p = f_if.parallelepiped_eval(X0_if)
    DefaultFigure.draw_parallelepiped(p, Color.dark_green())
    
    x0_if += dx_if

The resulting plot is shown below. In green is the result of the evaluation using parallelepipeds, and in black are the lower and upper trajectories.

2D Parabola with parallelepiped inclusion